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