@rsdoctor/utils 1.3.13-beta.1 → 1.3.13

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/build.cjs CHANGED
@@ -1,6 +1,123 @@
1
1
  "use strict";
2
2
  const __rslib_import_meta_url__ = 'undefined' == typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
3
- var __webpack_require__ = {};
3
+ var __webpack_modules__ = {
4
+ "./src/common/algorithm.ts" (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
5
+ function random(min, max) {
6
+ return Math.floor(Math.random() * (max - min + 1) + min);
7
+ }
8
+ __webpack_require__.d(__webpack_exports__, {
9
+ random: ()=>random
10
+ }), require("zlib"), require("buffer"), __webpack_require__("./src/logger.ts");
11
+ },
12
+ "./src/common/index.ts" (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
13
+ __webpack_require__.d(__webpack_exports__, {
14
+ Package: ()=>package_namespaceObject
15
+ });
16
+ var package_namespaceObject = {};
17
+ __webpack_require__.r(package_namespaceObject), __webpack_require__.d(package_namespaceObject, {
18
+ MODULE_PATH_PACKAGES: ()=>MODULE_PATH_PACKAGES,
19
+ PACKAGE_PATH_NAME: ()=>PACKAGE_PATH_NAME,
20
+ getPackageMetaFromModulePath: ()=>getPackageMetaFromModulePath
21
+ }), __webpack_require__("./src/common/algorithm.ts"), __webpack_require__("path"), __webpack_require__("process"), __webpack_require__("@rsdoctor/types"), __webpack_require__("./src/logger.ts"), RegExp(`(.*)${/[-|.]/.source}${/[a-z|A-Z|0-9]{4,32}/.source}(${/(?:\.[a-z|A-Z|0-9]{2,}){1,}/.source})$`);
22
+ var lodash = __webpack_require__("./src/common/lodash.ts");
23
+ let PACKAGE_SLUG = /[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*/, MODULE_PATH_PACKAGES = RegExp(`(?:${/(?:node_modules|~)(?:\/\.pnpm)?/.source}/)(?:(?:@${PACKAGE_SLUG.source}[/|+])?(?:${PACKAGE_SLUG.source}\\+)*(?:${PACKAGE_SLUG.source})(?:${/@[\w|\-|_|.]+/.source})?)(?:_(?:@${PACKAGE_SLUG.source}[/|+])?(?:${PACKAGE_SLUG.source})(?:@${PACKAGE_SLUG.source})?)*/`, 'g'), PACKAGE_PATH_NAME = /(?:(?:node_modules|~)(?:\/\.pnpm)?\/)(?:((?:@[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*[/|+])?(?:(?:[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*\+)*)(?:[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*))(?:@[\w|\-|_|.]+)?)(?:_((?:@[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*[/|+])?(?:[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*))(?:@[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*))*\//gm, getPackageMetaFromModulePath = (modulePath)=>{
24
+ var data;
25
+ let res, paths = modulePath.match(MODULE_PATH_PACKAGES);
26
+ if (!paths) return {
27
+ name: '',
28
+ version: ''
29
+ };
30
+ let names = (data = paths.flatMap((packagePath)=>{
31
+ let found = packagePath.matchAll(PACKAGE_PATH_NAME);
32
+ return found ? (0, lodash.compact)([
33
+ ...found
34
+ ].flat()).slice(1).filter(Boolean).map((name)=>name.replace(/\+/g, '/')) : [];
35
+ }), res = [], data.forEach((item, index)=>{
36
+ data.slice(index + 1).includes(item) || res.push(item);
37
+ }), res);
38
+ if ((0, lodash.isEmpty)(names)) return {
39
+ name: '',
40
+ version: ''
41
+ };
42
+ let name = (0, lodash.last)(names), pattern = RegExp(`(.*)(${(0, lodash.last)(paths)}).*`), path = modulePath.replace(pattern, '$1$2').replace(/\/$/, '');
43
+ return {
44
+ name,
45
+ version: path && name && path.match(RegExp(`${name}@([\\d.]+)`))?.flat().slice(1)?.[0] || ''
46
+ };
47
+ };
48
+ __webpack_require__("fs"), __webpack_require__("os");
49
+ },
50
+ "./src/common/lodash.ts" (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
51
+ function isEmpty(value) {
52
+ return null == value || Array.isArray(value) && 0 === value.length || 'object' == typeof value && 0 === Object.keys(value).length;
53
+ }
54
+ function last(array) {
55
+ return array[array.length - 1];
56
+ }
57
+ function compact(array) {
58
+ return array.filter((item)=>null != item || !item);
59
+ }
60
+ __webpack_require__.d(__webpack_exports__, {
61
+ compact: ()=>compact,
62
+ isEmpty: ()=>isEmpty,
63
+ last: ()=>last
64
+ });
65
+ },
66
+ "./src/logger.ts" (__unused_webpack_module, __unused_webpack___webpack_exports__, __webpack_require__) {
67
+ let external_picocolors_namespaceObject = require("picocolors");
68
+ var external_picocolors_default = __webpack_require__.n(external_picocolors_namespaceObject);
69
+ let external_rslog_namespaceObject = require("rslog");
70
+ __webpack_require__("@rsdoctor/types"), (0, external_rslog_namespaceObject.createLogger)().override({
71
+ log: (message)=>{
72
+ console.log(`${external_picocolors_default().green('[RSDOCTOR LOG]')} ${message}`);
73
+ },
74
+ info: (message)=>{
75
+ console.log(`${external_picocolors_default().yellow('[RSDOCTOR INFO]')} ${message}`);
76
+ },
77
+ warn: (message)=>{
78
+ console.warn(`${external_picocolors_default().yellow('[RSDOCTOR WARN]')} ${message}`);
79
+ },
80
+ start: (message)=>{
81
+ console.log(`${external_picocolors_default().green('[RSDOCTOR START]')} ${message}`);
82
+ },
83
+ ready: (message)=>{
84
+ console.log(`${external_picocolors_default().green('[RSDOCTOR READY]')} ${message}`);
85
+ },
86
+ error: (message)=>{
87
+ console.error(`${external_picocolors_default().red('[RSDOCTOR ERROR]')} ${message}`);
88
+ },
89
+ success: (message)=>{
90
+ console.error(`${external_picocolors_default().green('[RSDOCTOR SUCCESS]')} ${message}`);
91
+ },
92
+ debug: (message)=>{
93
+ process.env.DEBUG && console.log(`${external_picocolors_default().blue('[RSDOCTOR DEBUG]')} ${message}`);
94
+ }
95
+ });
96
+ },
97
+ "@rsdoctor/types" (module) {
98
+ module.exports = require("@rsdoctor/types");
99
+ },
100
+ fs (module) {
101
+ module.exports = require("fs");
102
+ },
103
+ os (module) {
104
+ module.exports = require("os");
105
+ },
106
+ path (module) {
107
+ module.exports = require("path");
108
+ },
109
+ process (module) {
110
+ module.exports = require("process");
111
+ }
112
+ }, __webpack_module_cache__ = {};
113
+ function __webpack_require__(moduleId) {
114
+ var cachedModule = __webpack_module_cache__[moduleId];
115
+ if (void 0 !== cachedModule) return cachedModule.exports;
116
+ var module = __webpack_module_cache__[moduleId] = {
117
+ exports: {}
118
+ };
119
+ return __webpack_modules__[moduleId](module, module.exports, __webpack_require__), module.exports;
120
+ }
4
121
  __webpack_require__.n = (module)=>{
5
122
  var getter = module && module.__esModule ? ()=>module.default : ()=>module;
6
123
  return __webpack_require__.d(getter, {
@@ -19,1164 +136,167 @@ __webpack_require__.n = (module)=>{
19
136
  });
20
137
  };
21
138
  var __webpack_exports__ = {};
22
- __webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_exports__, {
23
- Server: ()=>server_namespaceObject,
24
- File: ()=>file_namespaceObject,
25
- Json: ()=>json_namespaceObject,
26
- EnvInfo: ()=>envinfo_namespaceObject,
27
- Process: ()=>process_namespaceObject
28
- });
29
- var cache_namespaceObject = {};
30
- __webpack_require__.r(cache_namespaceObject), __webpack_require__.d(cache_namespaceObject, {
31
- readFile: ()=>cache_readFile,
32
- readFileSync: ()=>readFileSync,
33
- readJSON: ()=>readJSON,
34
- readJSONSync: ()=>readJSONSync
35
- });
36
- var file_namespaceObject = {};
37
- __webpack_require__.r(file_namespaceObject), __webpack_require__.d(file_namespaceObject, {
38
- FileSharding: ()=>FileSharding,
39
- cache: ()=>cache_namespaceObject,
40
- fse: ()=>external_fs_extra_namespaceObject
41
- });
42
- var json_namespaceObject = {};
43
- __webpack_require__.r(json_namespaceObject), __webpack_require__.d(json_namespaceObject, {
44
- readPackageJson: ()=>readPackageJson,
45
- stringify: ()=>stringify
46
- });
47
- var server_namespaceObject = {};
48
- __webpack_require__.r(server_namespaceObject), __webpack_require__.d(server_namespaceObject, {
49
- createApp: ()=>createApp,
50
- createGetPortSyncFunctionString: ()=>createGetPortSyncFunctionString,
51
- createServer: ()=>createServer,
52
- defaultPort: ()=>defaultPort,
53
- getPort: ()=>getPort,
54
- getPortSync: ()=>getPortSync
55
- });
56
- var envinfo_namespaceObject = {};
57
- __webpack_require__.r(envinfo_namespaceObject), __webpack_require__.d(envinfo_namespaceObject, {
58
- getCPUInfo: ()=>getCPUInfo,
59
- getGitBranch: ()=>getGitBranch,
60
- getGitRepo: ()=>getGitRepo,
61
- getGlobalNpmPackageVersion: ()=>getGlobalNpmPackageVersion,
62
- getMemoryInfo: ()=>getMemoryInfo,
63
- getNodeVersion: ()=>getNodeVersion,
64
- getNpmPackageVersion: ()=>getNpmPackageVersion,
65
- getNpmVersion: ()=>getNpmVersion,
66
- getOSInfo: ()=>getOSInfo,
67
- getPnpmVersion: ()=>getPnpmVersion,
68
- getYarnVersion: ()=>getYarnVersion
69
- });
70
- var process_namespaceObject = {};
71
- __webpack_require__.r(process_namespaceObject), __webpack_require__.d(process_namespaceObject, {
72
- getMemoryUsage: ()=>getMemoryUsage,
73
- getMemoryUsageMessage: ()=>getMemoryUsageMessage
74
- });
75
- const external_fs_extra_namespaceObject = require("fs-extra");
76
- var external_fs_extra_default = __webpack_require__.n(external_fs_extra_namespaceObject);
77
- const external_fs_namespaceObject = require("fs");
78
- var external_fs_default = __webpack_require__.n(external_fs_namespaceObject);
79
- const external_path_namespaceObject = require("path");
80
- var external_path_default = __webpack_require__.n(external_path_namespaceObject);
81
- class FileSharding {
82
- content;
83
- limitBytes;
84
- encoding;
85
- constructor(content, limitBytes = 10485760, encoding = 'utf-8'){
86
- this.content = content, this.limitBytes = limitBytes, this.encoding = encoding;
87
- }
88
- createVirtualShardingFiles(ext = '', index = 0) {
89
- let bf = Buffer.from(this.content, this.encoding), res = [], threshold = this.limitBytes, tmpBytes = 0;
90
- for(; bf.byteLength > tmpBytes;)res.push(bf.subarray(tmpBytes, tmpBytes + threshold)), tmpBytes += threshold;
91
- return res.map((e, i)=>({
92
- filename: `${i + index}${ext}`,
93
- content: e
94
- }));
95
- }
96
- async writeStringToFolder(folder, ext = '', index) {
97
- let dist = external_path_default().resolve(folder);
98
- await external_fs_extra_default().ensureDir(dist);
99
- let res = this.createVirtualShardingFiles(ext, index);
100
- return await Promise.all(res.map((e)=>new Promise((resolve, reject)=>{
101
- let stream = external_fs_default().createWriteStream(external_path_default().join(dist, e.filename), this.encoding);
102
- stream.end(e.content), stream.once('close', ()=>resolve(void 0)), stream.once('error', (err)=>reject(err));
103
- }))), res;
104
- }
105
- }
106
- const external_node_fs_namespaceObject = require("node:fs");
107
- var external_node_fs_default = __webpack_require__.n(external_node_fs_namespaceObject);
108
- const cache = new Map();
109
- async function cache_readFile(path1) {
110
- if (cache.has(path1)) return cache.get(path1);
111
- let res = await external_node_fs_default().promises.readFile(path1, 'utf-8');
112
- return cache.set(path1, res), res;
113
- }
114
- function readFileSync(path1) {
115
- if (cache.has(path1)) return cache.get(path1);
116
- let res = external_node_fs_default().readFileSync(path1, 'utf-8');
117
- return cache.set(path1, res), res;
118
- }
119
- async function readJSON(path1) {
120
- return JSON.parse(await cache_readFile(path1));
121
- }
122
- function readJSONSync(path1) {
123
- return JSON.parse(readFileSync(path1));
124
- }
125
- const external_json_stream_stringify_namespaceObject = require("json-stream-stringify"), external_zlib_namespaceObject = require("zlib"), external_buffer_namespaceObject = require("buffer"), external_picocolors_namespaceObject = require("picocolors");
126
- var external_picocolors_default = __webpack_require__.n(external_picocolors_namespaceObject);
127
- const external_rslog_namespaceObject = require("rslog"), types_namespaceObject = require("@rsdoctor/types");
128
- function debug(getMsg, prefix = '') {
129
- process.env.DEBUG && (logger.level = 'verbose', logger.debug(`${prefix} ${getMsg()}`));
130
- }
131
- const rsdoctorLogger = (0, external_rslog_namespaceObject.createLogger)();
132
- rsdoctorLogger.override({
133
- log: (message)=>{
134
- console.log(`${external_picocolors_default().green('[RSDOCTOR LOG]')} ${message}`);
135
- },
136
- info: (message)=>{
137
- console.log(`${external_picocolors_default().yellow('[RSDOCTOR INFO]')} ${message}`);
138
- },
139
- warn: (message)=>{
140
- console.warn(`${external_picocolors_default().yellow('[RSDOCTOR WARN]')} ${message}`);
141
- },
142
- start: (message)=>{
143
- console.log(`${external_picocolors_default().green('[RSDOCTOR START]')} ${message}`);
144
- },
145
- ready: (message)=>{
146
- console.log(`${external_picocolors_default().green('[RSDOCTOR READY]')} ${message}`);
147
- },
148
- error: (message)=>{
149
- console.error(`${external_picocolors_default().red('[RSDOCTOR ERROR]')} ${message}`);
150
- },
151
- success: (message)=>{
152
- console.error(`${external_picocolors_default().green('[RSDOCTOR SUCCESS]')} ${message}`);
153
- },
154
- debug: (message)=>{
155
- process.env.DEBUG && console.log(`${external_picocolors_default().blue('[RSDOCTOR DEBUG]')} ${message}`);
156
- }
157
- });
158
- const _timers = new Map();
159
- function time(label) {
160
- process.env.DEBUG !== Constants.RsdoctorProcessEnvDebugKey || _timers.has(label) || _timers.set(label, Date.now());
161
- }
162
- function timeEnd(label) {
163
- if (process.env.DEBUG !== Constants.RsdoctorProcessEnvDebugKey) return;
164
- let start = _timers.get(label);
165
- if (null == start) return void logger.debug(`Timer '${label}' does not exist.`);
166
- let duration = Date.now() - start;
167
- logger.debug(`Timer '${label}' ended: ${duration}ms`), _timers.delete(label);
168
- }
169
- function algorithm_mergeIntervals(intervals) {
170
- let previous, current;
171
- intervals.sort((a, b)=>a[0] - b[0]);
172
- let result = [];
173
- for(let i = 0; i < intervals.length; i++)current = intervals[i], !previous || current[0] > previous[1] ? (previous = current, result.push(current)) : previous[1] = Math.max(previous[1], current[1]);
174
- return result;
175
- }
176
- function compressText(input) {
177
- try {
178
- return deflateSync(input).toString('base64');
179
- } catch (e) {
180
- return logger.debug(`compressText error: ${e}`), '';
181
- }
182
- }
183
- function algorithm_decompressText(input) {
184
- return inflateSync(Buffer.from(input, 'base64')).toString();
185
- }
186
- function random(min, max) {
187
- return Math.floor(Math.random() * (max - min + 1) + min);
188
- }
189
- function isUrl(uri) {
190
- return /^https?:\/\//.test(uri);
191
- }
192
- function isFilePath(uri) {
193
- return isAbsolute(uri);
194
- }
195
- function url_isRemoteUrl(uri) {
196
- return !!('string' == typeof uri && (isUrl(uri) || isFilePath(uri)));
197
- }
198
- function isShardingData(data) {
199
- return !!(Array.isArray(data) && data.length > 0 && data.every((e)=>isRemoteUrl(e)));
200
- }
201
- async function fetchShardingData(shardingFiles, fetchImplement) {
202
- let res = await Promise.all(shardingFiles.map((url)=>fetchImplement(url))), strings = 0 === res.length ? [] : res.reduce((t, e)=>t + e);
203
- return 'object' == typeof strings ? strings : JSON.parse(decompressText(strings));
204
- }
205
- async function fetchShardingFiles(data, fetchImplement, filterKeys) {
206
- return (await Promise.all(Object.keys(data).map(async (_key)=>{
207
- let val = data[_key];
208
- return filterKeys?.length && 0 > filterKeys.indexOf(_key) ? {
209
- [_key]: []
210
- } : isShardingData(val) ? {
211
- [_key]: await fetchShardingData(val, fetchImplement)
212
- } : {
213
- [_key]: val
214
- };
215
- }))).reduce((t, c)=>Object.assign(t, c));
216
- }
217
- function findLoaderTotalTiming(loaders) {
218
- let start = 1 / 0, end = -1 / 0;
219
- for(let i = 0; i < loaders.length; i++){
220
- let loader = loaders[i];
221
- loader.startAt <= start && (start = loader.startAt), loader.endAt >= end && (end = loader.endAt);
222
- }
223
- return {
224
- start,
225
- end
226
- };
227
- }
228
- function getLoadersCosts(filter, loaders) {
229
- let match = {}, others = {};
230
- loaders.forEach((e)=>{
231
- filter(e) ? (match[e.pid] || (match[e.pid] = []), match[e.pid].push([
232
- e.startAt,
233
- e.endAt
234
- ])) : (others[e.pid] || (others[e.pid] = []), others[e.pid].push([
235
- e.startAt,
236
- e.endAt
237
- ]));
139
+ for(var __rspack_i in (()=>{
140
+ __webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_exports__, {
141
+ Server: ()=>server_namespaceObject,
142
+ File: ()=>file_namespaceObject,
143
+ Json: ()=>json_namespaceObject,
144
+ EnvInfo: ()=>envinfo_namespaceObject,
145
+ Process: ()=>process_namespaceObject
238
146
  });
239
- let costs = 0, pids = Object.keys(match);
240
- for(let i = 0; i < pids.length; i++){
241
- let pid = pids[i], _match = mergeIntervals(match[pid]), _others = mergeIntervals(others[pid] || []).filter(([s, e])=>_match.some((el)=>s >= el[0] && e <= el[1]));
242
- costs += (_match.length ? _match.reduce((t, c)=>t += c[1] - c[0], 0) : 0) - (_others.length ? _others.reduce((t, c)=>t += c[1] - c[0], 0) : 0);
243
- }
244
- return costs;
245
- }
246
- function getLoaderCosts(loader, loaders) {
247
- let blocked = loaders.filter((e)=>!e.loader.includes('builtin') && e !== loader && e.pid === loader.pid && !!(e.startAt >= loader.startAt) && !!(e.endAt <= loader.endAt)), costs = loader.endAt - loader.startAt;
248
- return blocked.length && mergeIntervals(blocked.map((e)=>[
249
- Math.max(e.startAt, loader.startAt),
250
- Math.min(e.endAt, loader.endAt)
251
- ])).forEach((e)=>{
252
- let sub = e[1] - e[0];
253
- costs -= sub;
254
- }), costs;
255
- }
256
- function getLoaderNames(loaders) {
257
- let names = new Set();
258
- return loaders.forEach((e)=>e.loaders.forEach((l)=>names.add(getLoadrName(l.loader)))), [
259
- ...names
260
- ];
261
- }
262
- function getLoadersTransformData(loaders) {
263
- let res = [];
264
- for(let i = 0; i < loaders.length; i++){
265
- let item = loaders[i];
266
- for(let j = 0; j < item.loaders.length; j++){
267
- let loader = item.loaders[j];
268
- res.push(loader);
269
- }
270
- }
271
- return res;
272
- }
273
- function getLoaderChartData(loaders) {
274
- let res = [], list = getLoadersTransformData(loaders);
275
- return loaders.forEach((item)=>{
276
- item.loaders.forEach((el)=>{
277
- res.push({
278
- layer: item.resource.layer,
279
- loader: getLoadrName(el.loader),
280
- isPitch: el.isPitch,
281
- startAt: el.startAt,
282
- endAt: el.endAt,
283
- pid: el.pid,
284
- sync: el.sync,
285
- resource: item.resource.path,
286
- costs: getLoaderCosts(el, list)
287
- });
288
- });
289
- }), res;
290
- }
291
- function getLoaderFileTree(loaders) {
292
- let list = getLoadersTransformData(loaders);
293
- return loaders.map((data)=>{
294
- let { loaders: arr, resource } = data;
295
- return {
296
- path: resource.path,
297
- layer: resource.layer,
298
- loaders: arr.map((l)=>({
299
- key: l.path,
300
- loader: getLoadrName(l.loader),
301
- path: l.path,
302
- errors: l.errors,
303
- costs: getLoaderCosts(l, list)
304
- }))
305
- };
147
+ var cache_namespaceObject = {};
148
+ __webpack_require__.r(cache_namespaceObject), __webpack_require__.d(cache_namespaceObject, {
149
+ readFile: ()=>cache_readFile,
150
+ readFileSync: ()=>readFileSync,
151
+ readJSON: ()=>readJSON,
152
+ readJSONSync: ()=>readJSONSync
306
153
  });
307
- }
308
- function getLoaderFileDetails(path1, loaders) {
309
- let data = loaders.find((e)=>e.resource.path === path1);
310
- if (!data) throw Error(`"${path1}" not match any loader data`);
311
- let list = getLoadersTransformData(loaders);
312
- return {
313
- ...data,
314
- loaders: data.loaders.map((el)=>({
315
- ...el,
316
- loader: getLoadrName(el.loader),
317
- costs: getLoaderCosts(el, list)
318
- }))
319
- };
320
- }
321
- function getLoaderFolderStatistics(folder, loaders) {
322
- let datas = loaders.filter((data)=>{
323
- let { path: path1 } = data.resource;
324
- return path1.startsWith(folder);
325
- }), filteredLoaders = [], uniqueLoaders = new Map();
326
- return datas.forEach((data)=>{
327
- data.loaders.forEach((fl)=>{
328
- let uniqueLoader = uniqueLoaders.get(fl.loader);
329
- return uniqueLoader ? uniqueLoaders.set(fl.loader, {
330
- files: uniqueLoader.files + 1,
331
- path: fl.path
332
- }) : uniqueLoaders.set(fl.loader, {
333
- files: 1,
334
- path: fl.path
335
- }), filteredLoaders.push({
336
- loader: fl.loader,
337
- startAt: fl.startAt,
338
- endAt: fl.endAt,
339
- pid: fl.pid
340
- });
341
- });
342
- }), Array.from(uniqueLoaders).map((uniqueLoader)=>{
343
- let costs = getLoadersCosts((l)=>l.loader === uniqueLoader[0], filteredLoaders);
344
- return {
345
- loader: uniqueLoader[0],
346
- files: uniqueLoader[1].files,
347
- path: uniqueLoader[1].path,
348
- costs
349
- };
154
+ var file_namespaceObject = {};
155
+ __webpack_require__.r(file_namespaceObject), __webpack_require__.d(file_namespaceObject, {
156
+ FileSharding: ()=>FileSharding,
157
+ cache: ()=>cache_namespaceObject,
158
+ fse: ()=>external_fs_extra_namespaceObject
350
159
  });
351
- }
352
- function collectResourceDirectories(loaders, root) {
353
- let directories = new Set();
354
- return loaders.forEach((item)=>{
355
- if (item.resource.path.startsWith(root)) {
356
- let pathParts = item.resource.path.split(root).slice(1).join('/').split('/');
357
- if (pathParts.length >= 2) {
358
- let twoLevelDir = pathParts.slice(0, 2).join('/');
359
- directories.add(`${root}/${twoLevelDir}`);
360
- }
361
- } else {
362
- let pathParts = item.resource.path.split('/'), twoLevelDir = pathParts.slice(0, pathParts.length - 1).join('/');
363
- directories.add(twoLevelDir);
364
- }
365
- }), Array.from(directories);
366
- }
367
- function getDirectoriesLoaders(loaders, root) {
368
- return collectResourceDirectories(loaders, root || process.cwd()).map((directory)=>{
369
- let stats = getLoaderFolderStatistics(directory, loaders);
370
- return {
371
- directory,
372
- stats
373
- };
160
+ var json_namespaceObject = {};
161
+ __webpack_require__.r(json_namespaceObject), __webpack_require__.d(json_namespaceObject, {
162
+ readPackageJson: ()=>readPackageJson,
163
+ stringify: ()=>stringify
374
164
  });
375
- }
376
- function getLoaderFileFirstInput(file, loaders) {
377
- for(let i = 0; i < loaders.length; i++){
378
- let item = loaders[i];
379
- if (item.resource.path === file) {
380
- let nonPitchLoaders = item.loaders.filter((e)=>!e.isPitch);
381
- if (!nonPitchLoaders.length) return '';
382
- return nonPitchLoaders[0].input || '';
383
- }
384
- }
385
- return '';
386
- }
387
- function getLoaderFileInputAndOutput(file, loader, loaderIndex, loaders) {
388
- for(let i = 0; i < loaders.length; i++){
389
- let item = loaders[i];
390
- if (item.resource.path === file) for(let j = 0; j < item.loaders.length; j++){
391
- let l = item.loaders[j];
392
- if (l.loader === loader && l.loaderIndex === loaderIndex) return {
393
- input: l.input || '',
394
- output: l.result || ''
395
- };
396
- return {
397
- input: '',
398
- output: ''
399
- };
400
- }
401
- }
402
- return {
403
- input: '',
404
- output: ''
405
- };
406
- }
407
- const LoaderInternalPropertyName = '__l__', isVue = (compiler)=>('module' in compiler.options && compiler.options.module.rules || []).some((rule)=>!!(rule && 'object' == typeof rule && rule.test instanceof RegExp && rule.test?.test('.vue'))), getLoadrName = (loader)=>{
408
- let regResults = loader.includes('node_modules') ? loader.split('node_modules') : null;
409
- return regResults ? regResults[regResults.length - 1] : loader;
410
- }, external_process_namespaceObject = require("process");
411
- function toFixedDigits(num, digits = 2) {
412
- return 0 === digits ? Math.floor(num) : +num.toFixed(digits);
413
- }
414
- function getUnit(num, type) {
415
- return 'm' === type ? num > 1 ? 'mins' : 'min' : num > 1 ? 'hours' : 'hour';
416
- }
417
- function formatCosts(costs) {
418
- if ((costs = Number(costs)) >= 1000) {
419
- let sec = costs / 1000;
420
- if (sec >= 60) {
421
- let mins = sec / 60;
422
- if (mins >= 60) {
423
- let hours = toFixedDigits(mins / 60, 0), restMins = toFixedDigits(mins % 60, 1), hUnit = getUnit(hours, 'h');
424
- return restMins > 0 ? `${hours}${hUnit} ${restMins}${getUnit(restMins, 'm')}` : `${hours}${hUnit}`;
425
- }
426
- let mUnit = getUnit(mins = toFixedDigits(mins, 0), 'm'), restSec = toFixedDigits(sec % 60, 0);
427
- return restSec > 0 ? `${mins}${mUnit} ${restSec}s` : `${mins}${mUnit}`;
428
- }
429
- return `${toFixedDigits(sec, 1)}s`;
430
- }
431
- if (costs >= 10) return `${+toFixedDigits(costs, 0)}ms`;
432
- if (costs >= 1) return `${+toFixedDigits(costs, 1)}ms`;
433
- let r = +toFixedDigits(costs, 2);
434
- return 0 === r && (r = +toFixedDigits(costs, 3)), `${r}ms`;
435
- }
436
- function getCurrentTimestamp(start, startHRTime) {
437
- let endHRTime = hrtime(startHRTime);
438
- return start + 1000 * endHRTime[0] + (process.env.RSTEST ? Math.round(endHRTime[1] / 1000000) : endHRTime[1] / 1000000);
439
- }
440
- function isResolveSuccessData(data) {
441
- return !!data.result;
442
- }
443
- function isResolveFailData(data) {
444
- return !!data.error;
445
- }
446
- function getResolverCosts(resolver, resolvers) {
447
- let blocked = resolvers.filter((e)=>e !== resolver && e.pid === resolver.pid && e.startAt >= resolver.startAt && e.endAt <= resolver.endAt), costs = resolver.endAt - resolver.startAt;
448
- return blocked.length && mergeIntervals(blocked.map((e)=>[
449
- Math.max(e.startAt, resolver.startAt),
450
- Math.min(e.endAt, resolver.endAt)
451
- ])).forEach((e)=>{
452
- let sub = e[1] - e[0];
453
- costs -= sub;
454
- }), costs;
455
- }
456
- function getResolverFileTree(resolver) {
457
- return resolver.map((e)=>({
458
- issuerPath: e.issuerPath
459
- }));
460
- }
461
- function getResolverFileDetails(filepath, resolvers, modules, moduleCodeMap) {
462
- let module = modules.find((item)=>item.path === filepath), matchResolvers = resolvers.filter((e)=>e.issuerPath === filepath), before = module && moduleCodeMap && moduleCodeMap[module.id] ? moduleCodeMap[module.id].source : '', after = matchResolvers.reduce((t, c)=>c.request && isResolveSuccessData(c) ? t.replace(RegExp(`["']${c.request}["']`), `"${c.result}"`) : t, before);
463
- return {
464
- filepath,
465
- before,
466
- after,
467
- resolvers: matchResolvers.map((e)=>({
468
- ...e,
469
- costs: getResolverCosts(e, resolvers)
470
- }))
471
- };
472
- }
473
- function modules_getModulesByAsset(asset, chunks, modules, filterModules, checkModules) {
474
- return getModulesByChunks(getChunksByChunkIds(getChunkIdsByAsset(asset), chunks), modules, filterModules, checkModules);
475
- }
476
- function getModuleIdsByChunk(chunk) {
477
- let { modules = [] } = chunk;
478
- return modules;
479
- }
480
- function getModuleIdsByModulesIds(moduleIds, modules) {
481
- return moduleIds.map((id)=>modules.find((m)=>m.id === id)).filter(Boolean);
482
- }
483
- function getModulesByChunk(chunk, modules, filterModules) {
484
- return getModuleIdsByChunk(chunk).map((id)=>{
485
- let module = modules.find((e)=>e.id === id);
486
- if (filterModules && filterModules.length > 0) {
487
- if (!module) return null;
488
- let filtered = {};
489
- for (let key of filterModules)void 0 !== module[key] && (filtered[key] = module[key]);
490
- return filtered;
491
- }
492
- return module;
493
- }).filter(Boolean);
494
- }
495
- function getModulesByChunks(chunks, modules, filterModules, checkModules) {
496
- let res = [];
497
- try {
498
- chunks.forEach((chunk)=>{
499
- getModulesByChunk(chunk, modules, filterModules).forEach((md)=>{
500
- (!checkModules || checkModules(md)) && !res.filter((_m)=>_m.id === md.id).length && res.push(md);
501
- });
502
- });
503
- } catch (error) {
504
- logger.debug(error);
505
- }
506
- return res;
507
- }
508
- function getModuleByDependency(dep, modules) {
509
- return modules.find((item)=>item.id === dep.module);
510
- }
511
- function filterModulesAndDependenciesByPackageDeps(deps, dependencies, modules) {
512
- let _dependencies = [], _modules = [];
513
- for(let i = 0; i < deps.length; i++){
514
- let dep = getDependencyByPackageData(deps[i], dependencies);
515
- if (dep) {
516
- _dependencies.push(dep);
517
- let module = getModuleByDependency(dep, modules);
518
- module && _modules.push(module);
519
- }
520
- }
521
- return {
522
- dependencies: _dependencies,
523
- modules: _modules
524
- };
525
- }
526
- function getModuleDetails(moduleId, modules, dependencies) {
527
- let module = modules.find((e)=>e.id === moduleId);
528
- return {
529
- module,
530
- dependencies: getDependenciesByModule(module, dependencies)
531
- };
532
- }
533
- const EXT = 'js|css|html', hashPattern = /[a-z|A-Z|0-9]{4,32}/, hashSeparatorPattern = /[-|.]/, fileExtensionPattern = /(?:\.[a-z|A-Z|0-9]{2,}){1,}/, filenamePattern = RegExp(`(.*)${hashSeparatorPattern.source}${hashPattern.source}(${fileExtensionPattern.source})$`);
534
- function formatAssetName(assetName, fileConfig) {
535
- let splitFilesList = fileConfig?.split('.'), outputFileTailName = '', unHashedFileName = assetName;
536
- return splitFilesList?.length && splitFilesList.length >= 3 && splitFilesList[splitFilesList.length - 2]?.indexOf('[') < 0 && 'js|css|html'.indexOf(splitFilesList[splitFilesList.length - 1]) > -1 ? (outputFileTailName = splitFilesList[splitFilesList.length - 2], unHashedFileName = assetName.replace(/(.*)(\.[a-f0-9]{4,32})([^.]*.[^.]+){2,}/g, '$1'), `${unHashedFileName}.${outputFileTailName}.${assetName.substring(assetName.lastIndexOf('.') + 1)}`) : assetName.replace(filenamePattern, '$1$2');
537
- }
538
- function isAssetMatchExtension(asset, ext) {
539
- return asset.path.slice(-ext.length) === ext || extname(asset.path) === ext;
540
- }
541
- function isAssetMatchExtensions(asset, exts) {
542
- return !!exts.length && exts.some((ext)=>isAssetMatchExtension(asset, ext));
543
- }
544
- function filterAssetsByExtensions(assets, exts) {
545
- return 'string' == typeof exts ? assets.filter((e)=>isAssetMatchExtension(e, exts)) : Array.isArray(exts) ? assets.filter((e)=>isAssetMatchExtensions(e, exts)) : [];
546
- }
547
- function filterAssets(assets, filterOrExtensions) {
548
- return filterOrExtensions && (assets = 'function' == typeof filterOrExtensions ? assets.filter(filterOrExtensions) : filterAssetsByExtensions(assets, filterOrExtensions)), assets;
549
- }
550
- function getAssetsSizeInfo(assets, chunks, options = {}) {
551
- let { withFileContent = !0, filterOrExtensions } = options;
552
- return (assets = assets.filter((e)=>!isAssetMatchExtensions(e, Constants.MapExtensions)), filterOrExtensions && (assets = filterAssets(assets, filterOrExtensions)), assets.length) ? {
553
- count: assets.length,
554
- size: assets.reduce((t, c)=>t + c.size, 0),
555
- files: assets.map((e)=>({
556
- path: e.path,
557
- size: e.size,
558
- gzipSize: e.gzipSize,
559
- initial: isInitialAsset(e, chunks),
560
- content: withFileContent ? e.content : void 0
561
- }))
562
- } : {
563
- count: 0,
564
- size: 0,
565
- files: []
566
- };
567
- }
568
- function isInitialAsset(asset, chunks) {
569
- return getChunksByAsset(asset, chunks).some((e)=>!!e.initial);
570
- }
571
- function getInitialAssetsSizeInfo(assets, chunks, options = {}) {
572
- return options.filterOrExtensions && (assets = filterAssets(assets, options.filterOrExtensions)), getAssetsSizeInfo(assets, chunks, {
573
- ...options,
574
- filterOrExtensions: (asset)=>isInitialAsset(asset, chunks)
165
+ var server_namespaceObject = {};
166
+ __webpack_require__.r(server_namespaceObject), __webpack_require__.d(server_namespaceObject, {
167
+ createApp: ()=>createApp,
168
+ createGetPortSyncFunctionString: ()=>createGetPortSyncFunctionString,
169
+ createServer: ()=>createServer,
170
+ defaultPort: ()=>defaultPort,
171
+ getPort: ()=>getPort,
172
+ getPortSync: ()=>getPortSync
575
173
  });
576
- }
577
- function getAssetsDiffResult(baseline, current) {
578
- return {
579
- all: {
580
- total: diffAssetsByExtensions(baseline, current)
581
- },
582
- js: {
583
- total: diffAssetsByExtensions(baseline, current, Constants.JSExtension),
584
- initial: diffAssetsByExtensions(baseline, current, Constants.JSExtension, !0)
585
- },
586
- css: {
587
- total: diffAssetsByExtensions(baseline, current, Constants.CSSExtension),
588
- initial: diffAssetsByExtensions(baseline, current, Constants.CSSExtension, !0)
589
- },
590
- imgs: {
591
- total: diffAssetsByExtensions(baseline, current, Constants.ImgExtensions)
592
- },
593
- html: {
594
- total: diffAssetsByExtensions(baseline, current, Constants.HtmlExtension)
595
- },
596
- media: {
597
- total: diffAssetsByExtensions(baseline, current, Constants.MediaExtensions)
598
- },
599
- fonts: {
600
- total: diffAssetsByExtensions(baseline, current, Constants.FontExtensions)
601
- },
602
- others: {
603
- total: diffAssetsByExtensions(baseline, current, (asset)=>!isAssetMatchExtensions(asset, [
604
- Constants.JSExtension,
605
- Constants.CSSExtension,
606
- Constants.HtmlExtension
607
- ].concat(Constants.ImgExtensions, Constants.MediaExtensions, Constants.FontExtensions, Constants.MapExtensions)))
608
- }
609
- };
610
- }
611
- function diffSize(bSize, cSize) {
612
- let isEqual = bSize === cSize;
613
- return {
614
- percent: isEqual ? 0 : 0 === bSize ? 100 : Math.abs(cSize - bSize) / bSize * 100,
615
- state: isEqual ? Client.RsdoctorClientDiffState.Equal : bSize > cSize ? Client.RsdoctorClientDiffState.Down : Client.RsdoctorClientDiffState.Up
616
- };
617
- }
618
- function diffAssetsByExtensions(baseline, current, filterOrExtensions, isInitial = !1) {
619
- let cSize, cCount, { size: bSize, count: bCount } = isInitial ? getInitialAssetsSizeInfo(baseline.assets, baseline.chunks, {
620
- filterOrExtensions
621
- }) : getAssetsSizeInfo(baseline.assets, baseline.chunks, {
622
- filterOrExtensions
174
+ var envinfo_namespaceObject = {};
175
+ __webpack_require__.r(envinfo_namespaceObject), __webpack_require__.d(envinfo_namespaceObject, {
176
+ getCPUInfo: ()=>getCPUInfo,
177
+ getGitBranch: ()=>getGitBranch,
178
+ getGitRepo: ()=>getGitRepo,
179
+ getGlobalNpmPackageVersion: ()=>getGlobalNpmPackageVersion,
180
+ getMemoryInfo: ()=>getMemoryInfo,
181
+ getNodeVersion: ()=>getNodeVersion,
182
+ getNpmPackageVersion: ()=>getNpmPackageVersion,
183
+ getNpmVersion: ()=>getNpmVersion,
184
+ getOSInfo: ()=>getOSInfo,
185
+ getPnpmVersion: ()=>getPnpmVersion,
186
+ getYarnVersion: ()=>getYarnVersion
623
187
  });
624
- if (baseline === current) cSize = bSize, cCount = bCount;
625
- else {
626
- let { size, count } = isInitial ? getInitialAssetsSizeInfo(current.assets, current.chunks, {
627
- filterOrExtensions
628
- }) : getAssetsSizeInfo(current.assets, current.chunks, {
629
- filterOrExtensions
630
- });
631
- cSize = size, cCount = count;
632
- }
633
- let { percent, state } = diffSize(bSize, cSize);
634
- return {
635
- size: {
636
- baseline: bSize,
637
- current: cSize
638
- },
639
- count: {
640
- baseline: bCount,
641
- current: cCount
642
- },
643
- percent,
644
- state
645
- };
646
- }
647
- function getAssetsSummary(assets, chunks, options = {}) {
648
- let jsOpt = {
649
- ...options,
650
- filterOrExtensions: Constants.JSExtension
651
- }, cssOpt = {
652
- ...options,
653
- filterOrExtensions: Constants.CSSExtension
654
- }, imgOpt = {
655
- ...options,
656
- filterOrExtensions: Constants.ImgExtensions
657
- }, htmlOpt = {
658
- ...options,
659
- filterOrExtensions: Constants.HtmlExtension
660
- }, mediaOpt = {
661
- ...options,
662
- filterOrExtensions: Constants.MediaExtensions
663
- }, fontOpt = {
664
- ...options,
665
- filterOrExtensions: Constants.FontExtensions
666
- }, otherOpt = {
667
- ...options,
668
- filterOrExtensions: (asset)=>!isAssetMatchExtensions(asset, [
669
- Constants.JSExtension,
670
- Constants.CSSExtension,
671
- Constants.HtmlExtension
672
- ].concat(Constants.ImgExtensions, Constants.MediaExtensions, Constants.FontExtensions, Constants.MapExtensions))
673
- };
674
- return {
675
- all: {
676
- total: getAssetsSizeInfo(assets, chunks, options)
677
- },
678
- js: {
679
- total: getAssetsSizeInfo(assets, chunks, jsOpt),
680
- initial: getInitialAssetsSizeInfo(assets, chunks, jsOpt)
681
- },
682
- css: {
683
- total: getAssetsSizeInfo(assets, chunks, cssOpt),
684
- initial: getInitialAssetsSizeInfo(assets, chunks, cssOpt)
685
- },
686
- imgs: {
687
- total: getAssetsSizeInfo(assets, chunks, imgOpt)
688
- },
689
- html: {
690
- total: getAssetsSizeInfo(assets, chunks, htmlOpt)
691
- },
692
- media: {
693
- total: getAssetsSizeInfo(assets, chunks, mediaOpt)
694
- },
695
- fonts: {
696
- total: getAssetsSizeInfo(assets, chunks, fontOpt)
697
- },
698
- others: {
699
- total: getAssetsSizeInfo(assets, chunks, otherOpt)
188
+ var process_namespaceObject = {};
189
+ __webpack_require__.r(process_namespaceObject), __webpack_require__.d(process_namespaceObject, {
190
+ getMemoryUsage: ()=>getMemoryUsage,
191
+ getMemoryUsageMessage: ()=>getMemoryUsageMessage
192
+ });
193
+ let external_fs_extra_namespaceObject = require("fs-extra");
194
+ var external_fs_extra_default = __webpack_require__.n(external_fs_extra_namespaceObject), external_fs_ = __webpack_require__("fs"), external_fs_default = __webpack_require__.n(external_fs_), external_path_ = __webpack_require__("path"), external_path_default = __webpack_require__.n(external_path_);
195
+ class FileSharding {
196
+ content;
197
+ limitBytes;
198
+ encoding;
199
+ constructor(content, limitBytes = 10485760, encoding = 'utf-8'){
200
+ this.content = content, this.limitBytes = limitBytes, this.encoding = encoding;
700
201
  }
701
- };
702
- }
703
- function getAssetDetails(assetPath, assets, chunks, modules, checkModules) {
704
- let asset = assets.find((e)=>e.path === assetPath);
705
- return {
706
- asset,
707
- chunks: getChunksByAsset(asset, chunks),
708
- modules: getModulesByAsset(asset, chunks, modules, void 0, checkModules)
709
- };
710
- }
711
- function getAllBundleData(assets, chunks, modules, filtersModules) {
712
- let result = [];
713
- try {
714
- for(let i = 0; i < assets.length; i++){
715
- let asset = assets[i];
716
- result.push({
717
- asset,
718
- modules: getModulesByAsset(asset, chunks, modules, filtersModules)
719
- });
202
+ createVirtualShardingFiles(ext = '', index = 0) {
203
+ let bf = Buffer.from(this.content, this.encoding), res = [], threshold = this.limitBytes, tmpBytes = 0;
204
+ for(; bf.byteLength > tmpBytes;)res.push(bf.subarray(tmpBytes, tmpBytes + threshold)), tmpBytes += threshold;
205
+ return res.map((e, i)=>({
206
+ filename: `${i + index}${ext}`,
207
+ content: e
208
+ }));
209
+ }
210
+ async writeStringToFolder(folder, ext = '', index) {
211
+ let dist = external_path_default().resolve(folder);
212
+ await external_fs_extra_default().ensureDir(dist);
213
+ let res = this.createVirtualShardingFiles(ext, index);
214
+ return await Promise.all(res.map((e)=>new Promise((resolve, reject)=>{
215
+ let stream = external_fs_default().createWriteStream(external_path_default().join(dist, e.filename), this.encoding);
216
+ stream.end(e.content), stream.once('close', ()=>resolve(void 0)), stream.once('error', (err)=>reject(err));
217
+ }))), res;
720
218
  }
721
- return result;
722
- } catch (error) {
723
- return console.error(error), [];
724
- }
725
- }
726
- function extname(filename) {
727
- let matches = filename.split('?')[0].match(/\.([0-9a-z]+)(?:[\?#]|$)/i);
728
- return matches ? `.${matches[1]}` : '';
729
- }
730
- const sep = ',';
731
- function getBundleDiffPageQueryString(files) {
732
- let qs = encodeURIComponent(files.join(','));
733
- return qs && (qs = `?${Client.RsdoctorClientUrlQuery.BundleDiffFiles}=${qs}`), qs;
734
- }
735
- function getBundleDiffPageUrl(files) {
736
- let qs = getBundleDiffPageQueryString(files);
737
- if ('development' === process.env.NODE_ENV && 'undefined' != typeof location) {
738
- let { search = '', origin } = location;
739
- return search && (qs += `&${search.slice(1)}`), `${origin}${qs}#${Client.RsdoctorClientRoutes.BundleDiff}`;
740
219
  }
741
- return `${qs}#${Client.RsdoctorClientRoutes.BundleDiff}`;
742
- }
743
- function parseFilesFromBundlePageUrlQuery(queryValue) {
744
- return decodeURIComponent(queryValue).split(',');
745
- }
746
- function getPackageRelationAlertDetails(modules, dependencies, root, packageDependencies, moduleCodeMap) {
747
- return packageDependencies.slice().reverse().map((dep)=>{
748
- let dependency = dependencies.find((item)=>item.id === dep.dependencyId);
749
- if (!dependency) return null;
750
- let module = modules.find((item)=>item.id === dependency.module);
751
- return module ? {
752
- group: dep.group,
753
- module,
754
- dependency,
755
- relativePath: relative(root, module.path),
756
- moduleCode: moduleCodeMap?.[module.id]
757
- } : null;
758
- }).filter(Boolean);
759
- }
760
- class APIDataLoader {
761
- loader;
762
- constructor(loader){
763
- this.loader = loader, this.loadAPI = this.loadAPI.bind(this);
220
+ let external_node_fs_namespaceObject = require("node:fs");
221
+ var external_node_fs_default = __webpack_require__.n(external_node_fs_namespaceObject);
222
+ let cache = new Map();
223
+ async function cache_readFile(path) {
224
+ if (cache.has(path)) return cache.get(path);
225
+ let res = await external_node_fs_default().promises.readFile(path, 'utf-8');
226
+ return cache.set(path, res), res;
764
227
  }
765
- log(...args) {
766
- console.log(`[${this.constructor.name}]`, ...args);
228
+ function readFileSync(path) {
229
+ if (cache.has(path)) return cache.get(path);
230
+ let res = external_node_fs_default().readFileSync(path, 'utf-8');
231
+ return cache.set(path, res), res;
767
232
  }
768
- loadAPI(...args) {
769
- let [api, body] = args;
770
- switch(api){
771
- case SDK.ServerAPI.API.LoadDataByKey:
772
- return this.loader.loadData(body.key);
773
- case SDK.ServerAPI.API.GetProjectInfo:
774
- return Promise.all([
775
- this.loader.loadData('root'),
776
- this.loader.loadData('pid'),
777
- this.loader.loadData('hash'),
778
- this.loader.loadData('summary'),
779
- this.loader.loadData('configs'),
780
- this.loader.loadData('envinfo'),
781
- this.loader.loadData('errors')
782
- ]).then(([root, pid, hash, summary, configs, envinfo, errors])=>({
783
- root,
784
- pid,
785
- hash,
786
- summary,
787
- configs,
788
- envinfo,
789
- errors
790
- }));
791
- case SDK.ServerAPI.API.GetClientRoutes:
792
- if ('undefined' != typeof window && window?.[Constants.WINDOW_RSDOCTOR_TAG]) return window[Constants.WINDOW_RSDOCTOR_TAG].enableRoutes;
793
- return this.loader.loadManifest().then((res)=>{
794
- let { enableRoutes = [] } = res.client || {};
795
- return enableRoutes;
796
- });
797
- case SDK.ServerAPI.API.GetLoaderNames:
798
- return this.loader.loadData('loader').then((res)=>Loader.getLoaderNames(res || []));
799
- case SDK.ServerAPI.API.GetLayers:
800
- return this.loader.loadData('moduleGraph').then((res)=>{
801
- let { layers } = res || {};
802
- return layers;
803
- });
804
- case SDK.ServerAPI.API.GetLoaderChartData:
805
- return this.loader.loadData('loader').then((res)=>Loader.getLoaderChartData(res || []));
806
- case SDK.ServerAPI.API.GetLoaderFileTree:
807
- return this.loader.loadData('loader').then((res)=>Loader.getLoaderFileTree(res || []));
808
- case SDK.ServerAPI.API.GetLoaderFileDetails:
809
- return this.loader.loadData('loader').then((res)=>Loader.getLoaderFileDetails(body.path, res || []));
810
- case SDK.ServerAPI.API.GetLoaderFolderStatistics:
811
- return this.loader.loadData('loader').then((res)=>Loader.getLoaderFolderStatistics(body.folder, res || []));
812
- case SDK.ServerAPI.API.GetLoaderFileFirstInput:
813
- return this.loader.loadData('loader').then((res)=>Loader.getLoaderFileFirstInput(body.file, res || []));
814
- case SDK.ServerAPI.API.GetLoaderFileInputAndOutput:
815
- return this.loader.loadData('loader').then((res)=>Loader.getLoaderFileFirstInput(body.file, res || []));
816
- case SDK.ServerAPI.API.GetResolverFileTree:
817
- return this.loader.loadData('resolver').then((res)=>Resolver.getResolverFileTree(res || []));
818
- case SDK.ServerAPI.API.GetResolverFileDetails:
819
- return Promise.all([
820
- this.loader.loadData('resolver'),
821
- this.loader.loadData('moduleGraph.modules'),
822
- this.loader.loadData('moduleCodeMap')
823
- ]).then((res)=>{
824
- let resolverData = res[0], modules = res[1], moduleCodeMap = res[2];
825
- return Resolver.getResolverFileDetails(body.filepath, resolverData || [], modules || [], moduleCodeMap || {});
826
- });
827
- case SDK.ServerAPI.API.GetPluginSummary:
828
- return this.loader.loadData('plugin').then((res)=>Plugin.getPluginSummary(res || {}));
829
- case SDK.ServerAPI.API.GetPluginData:
830
- return this.loader.loadData('plugin').then((res)=>{
831
- let { hooks, tapNames } = body;
832
- return Plugin.getPluginData(res || {}, hooks, tapNames);
833
- });
834
- case SDK.ServerAPI.API.GetAssetsSummary:
835
- return this.loader.loadData('chunkGraph').then((res)=>{
836
- let { withFileContent = !0 } = body, { assets = [], chunks = [] } = res || {};
837
- return Graph.getAssetsSummary(assets, chunks, {
838
- withFileContent
839
- });
840
- });
841
- case SDK.ServerAPI.API.GetAssetDetails:
842
- return Promise.all([
843
- this.loader.loadData('chunkGraph'),
844
- this.loader.loadData('moduleGraph'),
845
- this.loader.loadData('configs')
846
- ]).then((res)=>{
847
- let { assetPath } = body, { isRspack, hasSourceMap } = checkSourceMapSupport(res[2] || []), { assets = [], chunks = [] } = res[0] || {}, { modules = [] } = res[1] || {};
848
- return Graph.getAssetDetails(assetPath, assets, chunks, modules, isRspack || hasSourceMap ? (_module)=>!0 : ()=>!0);
849
- });
850
- case SDK.ServerAPI.API.GetSummaryBundles:
851
- return Promise.all([
852
- this.loader.loadData('chunkGraph'),
853
- this.loader.loadData('moduleGraph'),
854
- this.loader.loadData('configs')
855
- ]).then((res)=>{
856
- let { assets = [], chunks = [] } = res[0] || {}, { modules = [] } = res[1] || {}, configs = res[2] || [], filteredAssets = assets;
857
- return Array.isArray(configs) && configs[0]?.config?.name === 'lynx' && (filteredAssets = assets.filter((asset)=>!asset.path.endsWith('/template.js'))), Graph.getAllBundleData(filteredAssets, chunks, modules, [
858
- 'id',
859
- 'path',
860
- 'size',
861
- 'kind'
862
- ]);
863
- });
864
- case SDK.ServerAPI.API.GetChunksByModuleId:
865
- return Promise.all([
866
- this.loader.loadData('chunkGraph'),
867
- this.loader.loadData('moduleGraph')
868
- ]).then((res)=>{
869
- let { moduleId } = body, { chunks = [] } = res[0] || {}, { modules = [] } = res[1] || {};
870
- return Graph.getChunksByModuleId(moduleId, modules, chunks);
871
- });
872
- case SDK.ServerAPI.API.GetModuleDetails:
873
- return Promise.all([
874
- this.loader.loadData('chunkGraph'),
875
- this.loader.loadData('moduleGraph')
876
- ]).then((res)=>{
877
- let { moduleId } = body, { modules = [], dependencies = [] } = res[1] || {};
878
- return Graph.getModuleDetails(moduleId, modules, dependencies);
879
- });
880
- case SDK.ServerAPI.API.GetModulesByModuleIds:
881
- return this.loader.loadData('moduleGraph').then((res)=>{
882
- let { moduleIds } = body, { modules = [] } = res || {};
883
- return Graph.getModuleIdsByModulesIds(moduleIds, modules);
884
- });
885
- case SDK.ServerAPI.API.GetEntryPoints:
886
- return Promise.all([
887
- this.loader.loadData('chunkGraph')
888
- ]).then((res)=>{
889
- let [chunkGraph] = res, { entrypoints = [] } = chunkGraph || {};
890
- return Graph.getEntryPoints(entrypoints);
891
- });
892
- case SDK.ServerAPI.API.GetModuleCodeByModuleId:
893
- return this.loader.loadData('moduleCodeMap').then((moduleCodeMap)=>{
894
- let { moduleId } = body;
895
- return moduleCodeMap ? moduleCodeMap[moduleId] : {
896
- source: '',
897
- transformed: '',
898
- parsedSource: ''
899
- };
900
- });
901
- case SDK.ServerAPI.API.GetModuleCodeByModuleIds:
902
- return this.loader.loadData('moduleCodeMap').then((moduleCodeMap)=>{
903
- let { moduleIds } = body, _moduleCodeData = {};
904
- return moduleCodeMap ? (moduleIds.forEach((id)=>{
905
- _moduleCodeData[id] = moduleCodeMap[id];
906
- }), _moduleCodeData) : [];
907
- });
908
- case SDK.ServerAPI.API.GetAllModuleGraph:
909
- return this.loader.loadData('moduleGraph').then((moduleGraph)=>moduleGraph?.modules);
910
- case SDK.ServerAPI.API.GetSearchModules:
911
- return Promise.all([
912
- this.loader.loadData('moduleGraph'),
913
- this.loader.loadData('chunkGraph')
914
- ]).then((res)=>{
915
- let [moduleGraph, chunkGraph] = res, { moduleName } = body;
916
- if (!moduleName) return [];
917
- let assetMap = chunkGraph.chunks.reduce((acc, chunk)=>(chunk.assets.forEach((asset)=>{
918
- acc[chunk.id] || (acc[chunk.id] = []), acc[chunk.id].push(asset);
919
- }), acc), {}), searchedChunksMap = new Map();
920
- return moduleGraph?.modules.filter((module)=>{
921
- module.webpackId.includes(moduleName) && module.chunks.forEach((chunk)=>{
922
- searchedChunksMap.has(chunk) || (assetMap[chunk] || []).forEach((asset)=>{
923
- asset.endsWith('.js') && searchedChunksMap.set(chunk, asset);
924
- });
925
- });
926
- }), Object.fromEntries(searchedChunksMap);
927
- });
928
- case SDK.ServerAPI.API.GetSearchModuleInChunk:
929
- return Promise.all([
930
- this.loader.loadData('moduleGraph'),
931
- this.loader.loadData('root')
932
- ]).then((res)=>{
933
- let [moduleGraph, root] = res, { moduleName, chunk } = body;
934
- return moduleName ? moduleGraph?.modules.filter((module)=>module.webpackId.includes(moduleName) && module.chunks.includes(chunk)).map((filteredModule)=>({
935
- id: filteredModule.id,
936
- path: filteredModule.path,
937
- relativePath: relative(root, filteredModule.path)
938
- })) : [];
939
- });
940
- case SDK.ServerAPI.API.GetAllChunkGraph:
941
- return this.loader.loadData('chunkGraph').then((chunkGraph)=>chunkGraph?.chunks);
942
- case SDK.ServerAPI.API.GetPackageRelationAlertDetails:
943
- return Promise.all([
944
- this.loader.loadData('moduleGraph'),
945
- this.loader.loadData('errors'),
946
- this.loader.loadData('root'),
947
- this.loader.loadData('moduleCodeMap')
948
- ]).then((res)=>{
949
- let { id, target } = body, [moduleGraph, errors = [], root = '', moduleCodeMap] = res, { modules = [], dependencies = [] } = moduleGraph || {}, { packages = [] } = errors.find((e)=>e.id === id) || {}, { dependencies: pkgDependencies = [] } = packages.find((e)=>e.target.name === target.name && e.target.root === target.root && e.target.version === target.version) || {};
950
- return Alerts.getPackageRelationAlertDetails(modules, dependencies, root, pkgDependencies, moduleCodeMap || {});
951
- });
952
- case SDK.ServerAPI.API.GetOverlayAlerts:
953
- return this.loader.loadData('errors').then((res)=>(res || []).filter((e)=>e.code === Rule.RuleMessageCodeEnumerated.Overlay));
954
- case SDK.ServerAPI.API.BundleDiffManifest:
955
- return this.loader.loadManifest();
956
- case SDK.ServerAPI.API.GetBundleDiffSummary:
957
- return Promise.all([
958
- this.loader.loadManifest(),
959
- this.loader.loadData('root'),
960
- this.loader.loadData('hash'),
961
- this.loader.loadData('errors'),
962
- this.loader.loadData('chunkGraph'),
963
- this.loader.loadData('moduleGraph'),
964
- this.loader.loadData('moduleCodeMap'),
965
- this.loader.loadData('packageGraph'),
966
- this.loader.loadData('configs')
967
- ]).then(([_manifest, root = '', hash = '', errors = {}, chunkGraph = {}, moduleGraph = {}, moduleCodeMap = {}, packageGraph = {}, configs = []])=>{
968
- let outputFilename = '';
969
- return 'string' == typeof configs[0]?.config?.output?.chunkFilename && (outputFilename = configs[0]?.config.output.chunkFilename), {
970
- root,
971
- hash,
972
- errors,
973
- chunkGraph,
974
- moduleGraph,
975
- packageGraph,
976
- outputFilename,
977
- moduleCodeMap
978
- };
979
- });
980
- case SDK.ServerAPI.API.GetChunkGraph:
981
- return this.loader.loadData('chunkGraph').then((res)=>{
982
- let { chunks = [] } = res || {};
983
- return chunks;
984
- });
985
- case SDK.ServerAPI.API.GetAllModuleGraphFilter:
986
- return this.loader.loadData('moduleGraph').then((moduleGraph)=>moduleGraph?.modules.map((m)=>({
987
- id: m.id,
988
- webpackId: m.webpackId,
989
- path: m.path,
990
- size: m.size,
991
- chunks: m.chunks,
992
- kind: m.kind
993
- })));
994
- case SDK.ServerAPI.API.GetModuleByName:
995
- return this.loader.loadData('moduleGraph').then((moduleGraph)=>{
996
- let { moduleName } = body, { modules = [] } = moduleGraph || {};
997
- return modules.filter((m)=>m.path.includes(moduleName)).map((m)=>({
998
- id: m.id,
999
- path: m.path
1000
- })) || [];
1001
- });
1002
- case SDK.ServerAPI.API.GetModuleIssuerPath:
1003
- return this.loader.loadData('moduleGraph').then((moduleGraph)=>{
1004
- let { moduleId } = body, modules = moduleGraph?.modules || [], issuerPath = modules.find((m)=>String(m.id) === moduleId)?.issuerPath || [];
1005
- return Array.isArray(issuerPath) && issuerPath.length > 0 && 'number' == typeof issuerPath[0] ? issuerPath.map((id)=>modules.find((m)=>m.id === id)?.path).filter(Boolean) : issuerPath;
1006
- });
1007
- case SDK.ServerAPI.API.GetPackageInfo:
1008
- return this.loader.loadData('packageGraph').then((packageGraph)=>packageGraph?.packages);
1009
- case SDK.ServerAPI.API.GetPackageDependency:
1010
- return this.loader.loadData('packageGraph').then((packageGraph)=>packageGraph?.dependencies || []);
1011
- case SDK.ServerAPI.API.GetChunkGraphAI:
1012
- return this.loader.loadData('chunkGraph').then((res)=>{
1013
- let { chunks = [] } = res || {};
1014
- return chunks.map(({ modules, ...rest })=>rest);
1015
- });
1016
- case SDK.ServerAPI.API.GetChunkByIdAI:
1017
- return Promise.all([
1018
- this.loader.loadData('chunkGraph'),
1019
- this.loader.loadData('moduleGraph')
1020
- ]).then(([chunkGraph, moduleGraph])=>{
1021
- let { chunks = [] } = chunkGraph || {}, { modules = [] } = moduleGraph || {}, { chunkId } = body, chunkInfo = chunks.find((c)=>c.id === chunkId);
1022
- if (!chunkInfo) return null;
1023
- let chunkModules = modules.filter((m)=>chunkInfo.modules.includes(m.id)).map((module)=>({
1024
- id: module.id,
1025
- path: module.path,
1026
- size: module.size,
1027
- chunks: module.chunks,
1028
- kind: module.kind,
1029
- issuerPath: module.issuerPath
1030
- }));
1031
- return chunkInfo.modulesInfo = chunkModules, chunkInfo;
1032
- });
1033
- case SDK.ServerAPI.API.GetDirectoriesLoaders:
1034
- return Promise.all([
1035
- this.loader.loadData('root'),
1036
- this.loader.loadData('loader')
1037
- ]).then(([root, loaders])=>Loader.getDirectoriesLoaders(loaders || [], root || ''));
1038
- default:
1039
- throw Error(`API not implement: "${api}"`);
1040
- }
233
+ async function readJSON(path) {
234
+ return JSON.parse(await cache_readFile(path));
1041
235
  }
1042
- }
1043
- function isUndefined(value) {
1044
- return void 0 === value;
1045
- }
1046
- function isNumber(value) {
1047
- return 'number' == typeof value && !Number.isNaN(value);
1048
- }
1049
- function isObject(value) {
1050
- return 'object' == typeof value && null !== value;
1051
- }
1052
- function isEmpty(value) {
1053
- return null == value || Array.isArray(value) && 0 === value.length || 'object' == typeof value && 0 === Object.keys(value).length;
1054
- }
1055
- function last(array) {
1056
- return array[array.length - 1];
1057
- }
1058
- function compact(array) {
1059
- return array.filter((item)=>null != item || !item);
1060
- }
1061
- function isNil(value) {
1062
- return null == value;
1063
- }
1064
- const isPlainObject = (obj)=>null !== obj && 'object' == typeof obj && Object.getPrototypeOf(obj) === Object.prototype, isString = (v)=>'string' == typeof v || !!v && 'object' == typeof v && !Array.isArray(v) && '[object String]' === ({}).toString.call(v);
1065
- function pick(obj, keys) {
1066
- let result = {};
1067
- for(let i = 0; i < keys.length; i++){
1068
- let key = keys[i];
1069
- Object.hasOwn(obj, key) && (result[key] = obj[key]);
236
+ function readJSONSync(path) {
237
+ return JSON.parse(readFileSync(path));
1070
238
  }
1071
- return result;
1072
- }
1073
- const PACKAGE_PREFIX = /(?:node_modules|~)(?:\/\.pnpm)?/, PACKAGE_SLUG = /[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*/, VERSION = /@[\w|\-|_|.]+/, VERSION_NUMBER = '@([\\d.]+)', MODULE_PATH_PACKAGES = RegExp(`(?:${PACKAGE_PREFIX.source}/)(?:(?:@${PACKAGE_SLUG.source}[/|+])?(?:${PACKAGE_SLUG.source}\\+)*(?:${PACKAGE_SLUG.source})(?:${VERSION.source})?)(?:_(?:@${PACKAGE_SLUG.source}[/|+])?(?:${PACKAGE_SLUG.source})(?:@${PACKAGE_SLUG.source})?)*/`, 'g'), PACKAGE_PATH_NAME = /(?:(?:node_modules|~)(?:\/\.pnpm)?\/)(?:((?:@[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*[/|+])?(?:(?:[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*\+)*)(?:[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*))(?:@[\w|\-|_|.]+)?)(?:_((?:@[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*[/|+])?(?:[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*))(?:@[a-zA-Z0-9]+(?:[-|_|.]+[a-zA-Z0-9]+)*))*\//gm, uniqLast = (data)=>{
1074
- let res = [];
1075
- return data.forEach((item, index)=>{
1076
- data.slice(index + 1).includes(item) || res.push(item);
1077
- }), res;
1078
- }, getPackageMetaFromModulePath = (modulePath)=>{
1079
- let paths = modulePath.match(MODULE_PATH_PACKAGES);
1080
- if (!paths) return {
1081
- name: '',
1082
- version: ''
1083
- };
1084
- let names = uniqLast(paths.flatMap((packagePath)=>{
1085
- let found = packagePath.matchAll(PACKAGE_PATH_NAME);
1086
- return found ? compact([
1087
- ...found
1088
- ].flat()).slice(1).filter(Boolean).map((name)=>name.replace(/\+/g, '/')) : [];
1089
- }));
1090
- if (isEmpty(names)) return {
1091
- name: '',
1092
- version: ''
1093
- };
1094
- let name = last(names), pattern = RegExp(`(.*)(${last(paths)}).*`), path1 = modulePath.replace(pattern, '$1$2').replace(/\/$/, '');
1095
- return {
1096
- name,
1097
- version: path1 && name && path1.match(RegExp(`${name}@([\\d.]+)`))?.flat().slice(1)?.[0] || ''
1098
- };
1099
- }, external_os_namespaceObject = require("os");
1100
- var external_os_default = __webpack_require__.n(external_os_namespaceObject);
1101
- function writeMcpPort(port, builderName) {
1102
- let homeDir = os.homedir(), rsdoctorDir = path.join(homeDir, '.cache/rsdoctor'), mcpPortFilePath = path.join(rsdoctorDir, 'mcp.json');
1103
- fs.existsSync(rsdoctorDir) || fs.mkdirSync(rsdoctorDir, {
1104
- recursive: !0
1105
- });
1106
- let mcpJson = {
1107
- portList: {},
1108
- port: 0
1109
- };
1110
- if (fs.existsSync(mcpPortFilePath)) try {
1111
- mcpJson = JSON.parse(fs.readFileSync(mcpPortFilePath, 'utf8'));
1112
- } catch (error) {
1113
- logger.debug('Failed to parse mcp.json', error);
239
+ let external_json_stream_stringify_namespaceObject = require("json-stream-stringify");
240
+ var common = __webpack_require__("./src/common/index.ts");
241
+ let external_stream_namespaceObject = require("stream");
242
+ function stringify(json, replacer, space, cycle) {
243
+ let jsonList = [];
244
+ return json && 'object' == typeof json ? new Promise((resolve, reject)=>{
245
+ let stream = new external_json_stream_stringify_namespaceObject.JsonStreamStringify(json, replacer, space, cycle), currentLength = 0, currentContent = '', batchProcessor = new external_stream_namespaceObject.Transform({
246
+ readableObjectMode: !0,
247
+ transform (chunk, _encoding, callback) {
248
+ chunk.toString().split('\\n').forEach((line)=>{
249
+ currentLength + line.length > 419430400 && (jsonList.push(currentContent), currentContent = '', currentLength = 0), line.length && (currentContent += line, currentLength += line.length);
250
+ }), callback();
251
+ }
252
+ });
253
+ stream.pipe(batchProcessor).on('data', (line)=>{
254
+ currentLength + line.length > 419430400 && (jsonList.push(currentContent), currentContent = '', currentLength = 0), line.length && (currentContent += line, currentLength += line.length);
255
+ }).on('end', ()=>{
256
+ jsonList.length < 1 && jsonList.push(currentContent), resolve(jsonList);
257
+ }).on('error', (err)=>reject(err));
258
+ }) : Promise.resolve(JSON.stringify(json, replacer, space));
1114
259
  }
1115
- mcpJson.portList || (mcpJson.portList = {}), mcpJson.portList[builderName || 'builder'] = port, mcpJson.port = port, fs.writeFileSync(mcpPortFilePath, JSON.stringify(mcpJson, null, 2), 'utf8');
1116
- }
1117
- function getMcpConfigPath() {
1118
- let homeDir = os.homedir(), rsdoctorDir = path.join(homeDir, '.cache/rsdoctor');
1119
- return path.join(rsdoctorDir, 'mcp.json');
1120
- }
1121
- const external_stream_namespaceObject = require("stream"), maxFileSize = 419430400;
1122
- function stringify(json, replacer, space, cycle) {
1123
- let jsonList = [];
1124
- return json && 'object' == typeof json ? new Promise((resolve, reject)=>{
1125
- let stream = new external_json_stream_stringify_namespaceObject.JsonStreamStringify(json, replacer, space, cycle), currentLength = 0, currentContent = '', batchProcessor = new external_stream_namespaceObject.Transform({
1126
- readableObjectMode: !0,
1127
- transform (chunk, _encoding, callback) {
1128
- chunk.toString().split('\\n').forEach((line)=>{
1129
- currentLength + line.length > 419430400 && (jsonList.push(currentContent), currentContent = '', currentLength = 0), line.length && (currentContent += line, currentLength += line.length);
1130
- }), callback();
1131
- }
260
+ let readPackageJson = (file, readFile)=>{
261
+ let result, current = file;
262
+ for(; '/' !== current && !result;){
263
+ let parent = (0, external_path_.dirname)(current);
264
+ if (parent === current) break;
265
+ current = parent, readFile && (result = readFile((0, external_path_.join)(current, 'package.json'))), readFile ? result?.name || (result = void 0) : result = common.Package.getPackageMetaFromModulePath(file);
266
+ }
267
+ if (result) return !readFile || result.name && result.version ? {
268
+ ...result,
269
+ root: current
270
+ } : readPackageJson((0, external_path_.dirname)(current), readFile);
271
+ }, index_js_namespaceObject = require("../compiled/connect/index.js");
272
+ var index_js_default = __webpack_require__.n(index_js_namespaceObject);
273
+ let external_http_namespaceObject = require("http");
274
+ var external_http_default = __webpack_require__.n(external_http_namespaceObject), external_os_ = __webpack_require__("os"), external_os_default = __webpack_require__.n(external_os_);
275
+ let external_get_port_namespaceObject = require("get-port");
276
+ var external_get_port_default = __webpack_require__.n(external_get_port_namespaceObject);
277
+ let external_child_process_namespaceObject = require("child_process");
278
+ var algorithm = __webpack_require__("./src/common/algorithm.ts");
279
+ let RESTRICTED_PORTS = [
280
+ 3659,
281
+ 4045,
282
+ 6000,
283
+ 6665,
284
+ 6666,
285
+ 6667,
286
+ 6668,
287
+ 6669
288
+ ], defaultPort = function(min, max) {
289
+ let port;
290
+ do port = (0, algorithm.random)(3000, 8999);
291
+ while (RESTRICTED_PORTS.includes(port));
292
+ return port;
293
+ }(0, 0);
294
+ async function getPort(expectPort) {
295
+ return external_get_port_default()({
296
+ port: expectPort
1132
297
  });
1133
- stream.pipe(batchProcessor).on('data', (line)=>{
1134
- currentLength + line.length > 419430400 && (jsonList.push(currentContent), currentContent = '', currentLength = 0), line.length && (currentContent += line, currentLength += line.length);
1135
- }).on('end', ()=>{
1136
- jsonList.length < 1 && jsonList.push(currentContent), resolve(jsonList);
1137
- }).on('error', (err)=>reject(err));
1138
- }) : Promise.resolve(JSON.stringify(json, replacer, space));
1139
- }
1140
- const readPackageJson = (file, readFile)=>{
1141
- let result, current = file;
1142
- for(; '/' !== current && !result;){
1143
- let parent = (0, external_path_namespaceObject.dirname)(current);
1144
- if (parent === current) break;
1145
- current = parent, readFile && (result = readFile((0, external_path_namespaceObject.join)(current, 'package.json'))), readFile ? result?.name || (result = void 0) : result = getPackageMetaFromModulePath(file);
1146
298
  }
1147
- if (result) return !readFile || result.name && result.version ? {
1148
- ...result,
1149
- root: current
1150
- } : readPackageJson((0, external_path_namespaceObject.dirname)(current), readFile);
1151
- }, index_js_namespaceObject = require("../compiled/connect/index.js");
1152
- var index_js_default = __webpack_require__.n(index_js_namespaceObject);
1153
- const external_http_namespaceObject = require("http");
1154
- var external_http_default = __webpack_require__.n(external_http_namespaceObject);
1155
- const external_get_port_namespaceObject = require("get-port");
1156
- var external_get_port_default = __webpack_require__.n(external_get_port_namespaceObject);
1157
- const external_child_process_namespaceObject = require("child_process"), RESTRICTED_PORTS = [
1158
- 3659,
1159
- 4045,
1160
- 6000,
1161
- 6665,
1162
- 6666,
1163
- 6667,
1164
- 6668,
1165
- 6669
1166
- ];
1167
- function getRandomPort(min, max) {
1168
- let port;
1169
- do port = random(min, max);
1170
- while (RESTRICTED_PORTS.includes(port));
1171
- return port;
1172
- }
1173
- const defaultPort = getRandomPort(3000, 8999);
1174
- async function getPort(expectPort) {
1175
- return external_get_port_default()({
1176
- port: expectPort
1177
- });
1178
- }
1179
- const createGetPortSyncFunctionString = (expectPort)=>`
299
+ let createGetPortSyncFunctionString = (expectPort)=>`
1180
300
  (() => {
1181
301
  const net = require('net');
1182
302
 
@@ -1209,98 +329,99 @@ async function getAvailablePort(expectPort) {
1209
329
  getAvailablePort(${expectPort}).then(port => process.stdout.write(port.toString()));
1210
330
  })();
1211
331
  `.trim();
1212
- function getPortSync(expectPort) {
1213
- let statement = '\n' === external_os_default().EOL ? createGetPortSyncFunctionString(expectPort) : createGetPortSyncFunctionString(expectPort).replace(/\n/g, '');
1214
- return Number((0, external_child_process_namespaceObject.execSync)(`node -e "${statement}"`, {
1215
- encoding: 'utf-8'
1216
- }));
1217
- }
1218
- function createApp() {
1219
- return index_js_default()();
1220
- }
1221
- async function createServer(port) {
1222
- let app = createApp(), server = external_http_default().createServer(app), res = {
1223
- app,
1224
- server,
1225
- port,
1226
- close: ()=>new Promise((resolve, reject)=>{
1227
- 'closeAllConnections' in server && server.closeAllConnections(), 'closeIdleConnections' in server && server.closeIdleConnections(), server.close((err)=>{
1228
- err && reject(err), resolve();
1229
- });
1230
- })
1231
- };
1232
- return new Promise((resolve)=>{
1233
- server.listen(port, ()=>{
1234
- resolve(res);
332
+ function getPortSync(expectPort) {
333
+ let statement = '\n' === external_os_default().EOL ? createGetPortSyncFunctionString(expectPort) : createGetPortSyncFunctionString(expectPort).replace(/\n/g, '');
334
+ return Number((0, external_child_process_namespaceObject.execSync)(`node -e "${statement}"`, {
335
+ encoding: 'utf-8'
336
+ }));
337
+ }
338
+ function createApp() {
339
+ return index_js_default()();
340
+ }
341
+ async function createServer(port) {
342
+ let app = createApp(), server = external_http_default().createServer(app), res = {
343
+ app,
344
+ server,
345
+ port,
346
+ close: ()=>new Promise((resolve, reject)=>{
347
+ 'closeAllConnections' in server && server.closeAllConnections(), 'closeIdleConnections' in server && server.closeIdleConnections(), server.close((err)=>{
348
+ err && reject(err), resolve();
349
+ });
350
+ })
351
+ };
352
+ return new Promise((resolve)=>{
353
+ server.listen(port, ()=>{
354
+ resolve(res);
355
+ });
1235
356
  });
1236
- });
1237
- }
1238
- const external_envinfo_namespaceObject = require("envinfo");
1239
- var external_envinfo_default = __webpack_require__.n(external_envinfo_namespaceObject);
1240
- const helpers = external_envinfo_default().helpers, run = external_envinfo_default().run, getCPUInfo = ()=>helpers.getCPUInfo().then((res)=>res[1]), getOSInfo = ()=>helpers.getOSInfo().then((res)=>res[1]), getMemoryInfo = ()=>helpers.getMemoryInfo().then((res)=>res[1]), getNodeVersion = ()=>helpers.getNodeInfo().then((res)=>res[1]), getYarnVersion = ()=>helpers.getYarnInfo().then((res)=>res[1]), getNpmVersion = ()=>helpers.getnpmInfo().then((res)=>res[1]), getPnpmVersion = ()=>helpers.getpnpmInfo().then((res)=>res[1]);
1241
- function getNpmPackageVersion(pkg) {
1242
- let isArray = Array.isArray(pkg);
1243
- return run({
1244
- npmPackages: isArray ? pkg : [
1245
- pkg
1246
- ]
1247
- }, {
1248
- json: !0,
1249
- showNotFound: !0
1250
- }).then((res)=>{
1251
- let { npmPackages = {} } = JSON.parse(res) || {};
1252
- return isArray ? pkg.map((e)=>npmPackages[e] || 'Not Found') : npmPackages[pkg];
1253
- });
1254
- }
1255
- function getGlobalNpmPackageVersion(pkg) {
1256
- let isArray = Array.isArray(pkg);
1257
- return run({
1258
- npmGlobalPackages: isArray ? pkg : [
1259
- pkg
1260
- ]
1261
- }, {
1262
- json: !0,
1263
- showNotFound: !0
1264
- }).then((res)=>{
1265
- let { npmGlobalPackages = {} } = JSON.parse(res) || {};
1266
- return isArray ? pkg.map((e)=>npmGlobalPackages[e] || 'Not Found') : npmGlobalPackages[pkg];
1267
- });
1268
- }
1269
- function getGitBranch() {
1270
- return new Promise((resolve, reject)=>{
1271
- (0, external_child_process_namespaceObject.exec)('git branch --show-current', (err, stdout)=>{
1272
- err ? (0, external_child_process_namespaceObject.exec)('git branch', (err, stdout)=>{
1273
- err ? reject(err) : resolve(stdout.split('\n').map((e)=>e.replace('* ', '')).join('').trim());
1274
- }) : resolve(stdout.trim());
357
+ }
358
+ let external_envinfo_namespaceObject = require("envinfo");
359
+ var external_envinfo_default = __webpack_require__.n(external_envinfo_namespaceObject);
360
+ let helpers = external_envinfo_default().helpers, run = external_envinfo_default().run, getCPUInfo = ()=>helpers.getCPUInfo().then((res)=>res[1]), getOSInfo = ()=>helpers.getOSInfo().then((res)=>res[1]), getMemoryInfo = ()=>helpers.getMemoryInfo().then((res)=>res[1]), getNodeVersion = ()=>helpers.getNodeInfo().then((res)=>res[1]), getYarnVersion = ()=>helpers.getYarnInfo().then((res)=>res[1]), getNpmVersion = ()=>helpers.getnpmInfo().then((res)=>res[1]), getPnpmVersion = ()=>helpers.getpnpmInfo().then((res)=>res[1]);
361
+ function getNpmPackageVersion(pkg) {
362
+ let isArray = Array.isArray(pkg);
363
+ return run({
364
+ npmPackages: isArray ? pkg : [
365
+ pkg
366
+ ]
367
+ }, {
368
+ json: !0,
369
+ showNotFound: !0
370
+ }).then((res)=>{
371
+ let { npmPackages = {} } = JSON.parse(res) || {};
372
+ return isArray ? pkg.map((e)=>npmPackages[e] || 'Not Found') : npmPackages[pkg];
1275
373
  });
1276
- });
1277
- }
1278
- function getGitRepo() {
1279
- return new Promise((resolve, reject)=>{
1280
- (0, external_child_process_namespaceObject.exec)('git config --get remote.origin.url', (err, stdout)=>{
1281
- err ? reject(err) : resolve(stdout.trim());
374
+ }
375
+ function getGlobalNpmPackageVersion(pkg) {
376
+ let isArray = Array.isArray(pkg);
377
+ return run({
378
+ npmGlobalPackages: isArray ? pkg : [
379
+ pkg
380
+ ]
381
+ }, {
382
+ json: !0,
383
+ showNotFound: !0
384
+ }).then((res)=>{
385
+ let { npmGlobalPackages = {} } = JSON.parse(res) || {};
386
+ return isArray ? pkg.map((e)=>npmGlobalPackages[e] || 'Not Found') : npmGlobalPackages[pkg];
1282
387
  });
1283
- });
1284
- }
1285
- const filesize_index_js_namespaceObject = require("../compiled/filesize/index.js");
1286
- function getMemoryUsage() {
1287
- return (0, external_process_namespaceObject.memoryUsage)();
1288
- }
1289
- function getMemoryUsageMessage() {
1290
- let usage = getMemoryUsage(), msgs = [
1291
- `RSS: ${(0, filesize_index_js_namespaceObject.filesize)(usage.rss)}`,
1292
- `Heap Total: ${(0, filesize_index_js_namespaceObject.filesize)(usage.heapTotal)}`,
1293
- `Heap Used: ${(0, filesize_index_js_namespaceObject.filesize)(usage.heapUsed)}`
1294
- ];
1295
- return usage.arrayBuffers && msgs.push(`ArrayBuffers: ${(0, filesize_index_js_namespaceObject.filesize)(usage.arrayBuffers)}`), usage.external && msgs.push(`External: ${(0, filesize_index_js_namespaceObject.filesize)(usage.external)}`), `["${external_process_namespaceObject.pid}" Memory Usage] ${msgs.join(', ')}`;
1296
- }
1297
- for(var __webpack_i__ in exports.EnvInfo = __webpack_exports__.EnvInfo, exports.File = __webpack_exports__.File, exports.Json = __webpack_exports__.Json, exports.Process = __webpack_exports__.Process, exports.Server = __webpack_exports__.Server, __webpack_exports__)-1 === [
388
+ }
389
+ function getGitBranch() {
390
+ return new Promise((resolve, reject)=>{
391
+ (0, external_child_process_namespaceObject.exec)('git branch --show-current', (err, stdout)=>{
392
+ err ? (0, external_child_process_namespaceObject.exec)('git branch', (err, stdout)=>{
393
+ err ? reject(err) : resolve(stdout.split('\n').map((e)=>e.replace('* ', '')).join('').trim());
394
+ }) : resolve(stdout.trim());
395
+ });
396
+ });
397
+ }
398
+ function getGitRepo() {
399
+ return new Promise((resolve, reject)=>{
400
+ (0, external_child_process_namespaceObject.exec)('git config --get remote.origin.url', (err, stdout)=>{
401
+ err ? reject(err) : resolve(stdout.trim());
402
+ });
403
+ });
404
+ }
405
+ let filesize_index_js_namespaceObject = require("../compiled/filesize/index.js");
406
+ var external_process_ = __webpack_require__("process");
407
+ function getMemoryUsage() {
408
+ return (0, external_process_.memoryUsage)();
409
+ }
410
+ function getMemoryUsageMessage() {
411
+ let usage = getMemoryUsage(), msgs = [
412
+ `RSS: ${(0, filesize_index_js_namespaceObject.filesize)(usage.rss)}`,
413
+ `Heap Total: ${(0, filesize_index_js_namespaceObject.filesize)(usage.heapTotal)}`,
414
+ `Heap Used: ${(0, filesize_index_js_namespaceObject.filesize)(usage.heapUsed)}`
415
+ ];
416
+ return usage.arrayBuffers && msgs.push(`ArrayBuffers: ${(0, filesize_index_js_namespaceObject.filesize)(usage.arrayBuffers)}`), usage.external && msgs.push(`External: ${(0, filesize_index_js_namespaceObject.filesize)(usage.external)}`), `["${external_process_.pid}" Memory Usage] ${msgs.join(', ')}`;
417
+ }
418
+ })(), exports.EnvInfo = __webpack_exports__.EnvInfo, exports.File = __webpack_exports__.File, exports.Json = __webpack_exports__.Json, exports.Process = __webpack_exports__.Process, exports.Server = __webpack_exports__.Server, __webpack_exports__)-1 === [
1298
419
  "EnvInfo",
1299
420
  "File",
1300
421
  "Json",
1301
422
  "Process",
1302
423
  "Server"
1303
- ].indexOf(__webpack_i__) && (exports[__webpack_i__] = __webpack_exports__[__webpack_i__]);
424
+ ].indexOf(__rspack_i) && (exports[__rspack_i] = __webpack_exports__[__rspack_i]);
1304
425
  Object.defineProperty(exports, '__esModule', {
1305
426
  value: !0
1306
427
  });