@rsdoctor/utils 1.6.0 → 1.6.2-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build/json.d.cts +1 -1
- package/dist/build/json.d.ts +1 -1
- package/dist/build.cjs +18 -10
- package/dist/build.js +4 -4
- package/dist/common.cjs +40 -17
- package/dist/common.js +39 -26
- package/package.json +2 -2
package/dist/build/json.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { SDK } from '@rsdoctor/types';
|
|
2
|
-
export declare function stringify<T, P = T extends undefined ? undefined : string>(json: T, replacer?: (this: any, key: string, value: any) => any, space?: string | number, cycle?: boolean): Promise<P>;
|
|
2
|
+
export declare function stringify<T, P = T extends undefined ? undefined : string>(json: T, replacer?: (this: any, key: string, value: any) => any, space?: string | number, cycle?: boolean, chunkSize?: number): Promise<P>;
|
|
3
3
|
export declare const readPackageJson: (file: string, readFile?: SDK.GetPackageFile) => SDK.PackageBasicData | undefined;
|
package/dist/build/json.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { SDK } from '@rsdoctor/types';
|
|
2
|
-
export declare function stringify<T, P = T extends undefined ? undefined : string>(json: T, replacer?: (this: any, key: string, value: any) => any, space?: string | number, cycle?: boolean): Promise<P>;
|
|
2
|
+
export declare function stringify<T, P = T extends undefined ? undefined : string>(json: T, replacer?: (this: any, key: string, value: any) => any, space?: string | number, cycle?: boolean, chunkSize?: number): Promise<P>;
|
|
3
3
|
export declare const readPackageJson: (file: string, readFile?: SDK.GetPackageFile) => SDK.PackageBasicData | undefined;
|
package/dist/build.cjs
CHANGED
|
@@ -5,9 +5,9 @@ var __webpack_modules__ = {
|
|
|
5
5
|
function random(min, max) {
|
|
6
6
|
return Math.floor(Math.random() * (max - min + 1) + min);
|
|
7
7
|
}
|
|
8
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
8
|
+
__webpack_require__("zlib"), __webpack_require__("buffer"), __webpack_require__("./src/logger.ts"), __webpack_require__.d(__webpack_exports__, {
|
|
9
9
|
random: ()=>random
|
|
10
|
-
})
|
|
10
|
+
});
|
|
11
11
|
},
|
|
12
12
|
"./src/common/index.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
13
13
|
__webpack_require__.d(__webpack_exports__, {
|
|
@@ -16,7 +16,7 @@ var __webpack_modules__ = {
|
|
|
16
16
|
var package_namespaceObject = {};
|
|
17
17
|
__webpack_require__.r(package_namespaceObject), __webpack_require__.d(package_namespaceObject, {
|
|
18
18
|
getPackageMetaFromModulePath: ()=>getPackageMetaFromModulePath
|
|
19
|
-
}), __webpack_require__("./src/common/algorithm.ts"), __webpack_require__("
|
|
19
|
+
}), __webpack_require__("buffer"), __webpack_require__("stream"), require("string_decoder"), __webpack_require__("zlib"), __webpack_require__("path"), __webpack_require__("./src/common/algorithm.ts"), __webpack_require__("process"), __webpack_require__("@rsdoctor/types"), __webpack_require__("./src/logger.ts"), RegExp(`(.*)${/[-|.]/.source}(${/(?:[a-f0-9]{4,32}|[a-zA-Z]{3,}[0-9]|[a-zA-Z]*[0-9][a-zA-Z]{2,}|[a-zA-Z]*[0-9][a-zA-Z0-9]{3,31})/.source})(${/(?:\.[a-z|A-Z|0-9]{2,}){1,}/.source})$`);
|
|
20
20
|
var lodash = __webpack_require__("./src/common/lodash.ts");
|
|
21
21
|
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)=>{
|
|
22
22
|
var data;
|
|
@@ -95,6 +95,9 @@ var __webpack_modules__ = {
|
|
|
95
95
|
"@rsdoctor/types" (module) {
|
|
96
96
|
module.exports = require("@rsdoctor/types");
|
|
97
97
|
},
|
|
98
|
+
buffer (module) {
|
|
99
|
+
module.exports = require("buffer");
|
|
100
|
+
},
|
|
98
101
|
fs (module) {
|
|
99
102
|
module.exports = require("fs");
|
|
100
103
|
},
|
|
@@ -106,6 +109,12 @@ var __webpack_modules__ = {
|
|
|
106
109
|
},
|
|
107
110
|
process (module) {
|
|
108
111
|
module.exports = require("process");
|
|
112
|
+
},
|
|
113
|
+
stream (module) {
|
|
114
|
+
module.exports = require("stream");
|
|
115
|
+
},
|
|
116
|
+
zlib (module) {
|
|
117
|
+
module.exports = require("zlib");
|
|
109
118
|
}
|
|
110
119
|
}, __webpack_module_cache__ = {};
|
|
111
120
|
function __webpack_require__(moduleId) {
|
|
@@ -239,23 +248,22 @@ for(var __rspack_i in (()=>{
|
|
|
239
248
|
return JSON.parse(readFileSync(path));
|
|
240
249
|
}
|
|
241
250
|
let external_json_stream_stringify_namespaceObject = require("json-stream-stringify");
|
|
242
|
-
var common = __webpack_require__("./src/common/index.ts");
|
|
243
|
-
|
|
244
|
-
function stringify(json, replacer, space, cycle) {
|
|
251
|
+
var common = __webpack_require__("./src/common/index.ts"), external_stream_ = __webpack_require__("stream");
|
|
252
|
+
function stringify(json, replacer, space, cycle, chunkSize = 419430400) {
|
|
245
253
|
let jsonList = [];
|
|
246
254
|
return json && 'object' == typeof json ? new Promise((resolve, reject)=>{
|
|
247
|
-
let stream = new external_json_stream_stringify_namespaceObject.JsonStreamStringify(json, replacer, space, cycle), currentLength = 0, currentContent = '', batchProcessor = new
|
|
255
|
+
let stream = new external_json_stream_stringify_namespaceObject.JsonStreamStringify(json, replacer, space, cycle), currentLength = 0, currentContent = '', batchProcessor = new external_stream_.Transform({
|
|
248
256
|
readableObjectMode: !0,
|
|
249
257
|
transform (chunk, _encoding, callback) {
|
|
250
258
|
chunk.toString().split('\\n').forEach((line)=>{
|
|
251
|
-
currentLength + line.length >
|
|
259
|
+
currentLength + line.length > chunkSize && (jsonList.push(currentContent), currentContent = '', currentLength = 0), line.length && (currentContent += line, currentLength += line.length);
|
|
252
260
|
}), callback();
|
|
253
261
|
}
|
|
254
262
|
});
|
|
255
263
|
stream.pipe(batchProcessor).on('data', (line)=>{
|
|
256
|
-
currentLength + line.length >
|
|
264
|
+
currentLength + line.length > chunkSize && (jsonList.push(currentContent), currentContent = '', currentLength = 0), line.length && (currentContent += line, currentLength += line.length);
|
|
257
265
|
}).on('end', ()=>{
|
|
258
|
-
|
|
266
|
+
currentContent.length > 0 && jsonList.push(currentContent), resolve(jsonList);
|
|
259
267
|
}).on('error', (err)=>reject(err));
|
|
260
268
|
}) : Promise.resolve(JSON.stringify(json, replacer, space));
|
|
261
269
|
}
|
package/dist/build.js
CHANGED
|
@@ -103,21 +103,21 @@ async function readJSON(path) {
|
|
|
103
103
|
function readJSONSync(path) {
|
|
104
104
|
return JSON.parse(readFileSync(path));
|
|
105
105
|
}
|
|
106
|
-
function stringify(json, replacer, space, cycle) {
|
|
106
|
+
function stringify(json, replacer, space, cycle, chunkSize = 419430400) {
|
|
107
107
|
let jsonList = [];
|
|
108
108
|
return json && 'object' == typeof json ? new Promise((resolve, reject)=>{
|
|
109
109
|
let stream = new JsonStreamStringify(json, replacer, space, cycle), currentLength = 0, currentContent = '', batchProcessor = new Transform({
|
|
110
110
|
readableObjectMode: !0,
|
|
111
111
|
transform (chunk, _encoding, callback) {
|
|
112
112
|
chunk.toString().split('\\n').forEach((line)=>{
|
|
113
|
-
currentLength + line.length >
|
|
113
|
+
currentLength + line.length > chunkSize && (jsonList.push(currentContent), currentContent = '', currentLength = 0), line.length && (currentContent += line, currentLength += line.length);
|
|
114
114
|
}), callback();
|
|
115
115
|
}
|
|
116
116
|
});
|
|
117
117
|
stream.pipe(batchProcessor).on('data', (line)=>{
|
|
118
|
-
currentLength + line.length >
|
|
118
|
+
currentLength + line.length > chunkSize && (jsonList.push(currentContent), currentContent = '', currentLength = 0), line.length && (currentContent += line, currentLength += line.length);
|
|
119
119
|
}).on('end', ()=>{
|
|
120
|
-
|
|
120
|
+
currentContent.length > 0 && jsonList.push(currentContent), resolve(jsonList);
|
|
121
121
|
}).on('error', (err)=>reject(err));
|
|
122
122
|
}) : Promise.resolve(JSON.stringify(json, replacer, space));
|
|
123
123
|
}
|
package/dist/common.cjs
CHANGED
|
@@ -2,14 +2,8 @@
|
|
|
2
2
|
const __rslib_import_meta_url__ = "u" < typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
|
|
3
3
|
var __webpack_modules__ = {
|
|
4
4
|
"./src/common/algorithm.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
5
|
-
__webpack_require__.r(__webpack_exports__)
|
|
6
|
-
|
|
7
|
-
decompressText: ()=>decompressText,
|
|
8
|
-
mergeIntervals: ()=>mergeIntervals,
|
|
9
|
-
random: ()=>random
|
|
10
|
-
});
|
|
11
|
-
let external_zlib_namespaceObject = require("zlib"), external_buffer_namespaceObject = require("buffer");
|
|
12
|
-
var logger = __webpack_require__("./src/logger.ts");
|
|
5
|
+
__webpack_require__.r(__webpack_exports__);
|
|
6
|
+
var zlib__rspack_import_0 = __webpack_require__("zlib"), buffer__rspack_import_1 = __webpack_require__("buffer"), _logger__rspack_import_2 = __webpack_require__("./src/logger.ts");
|
|
13
7
|
function mergeIntervals(intervals) {
|
|
14
8
|
let previous, current;
|
|
15
9
|
intervals.sort((a, b)=>a[0] - b[0]);
|
|
@@ -19,17 +13,23 @@ var __webpack_modules__ = {
|
|
|
19
13
|
}
|
|
20
14
|
function compressText(input) {
|
|
21
15
|
try {
|
|
22
|
-
return (0,
|
|
16
|
+
return (0, zlib__rspack_import_0.deflateSync)(input).toString('base64');
|
|
23
17
|
} catch (e) {
|
|
24
|
-
return
|
|
18
|
+
return _logger__rspack_import_2.logger.debug(`compressText error: ${e}`), '';
|
|
25
19
|
}
|
|
26
20
|
}
|
|
27
21
|
function decompressText(input) {
|
|
28
|
-
return (0,
|
|
22
|
+
return (0, zlib__rspack_import_0.inflateSync)(buffer__rspack_import_1.Buffer.from(input, 'base64')).toString();
|
|
29
23
|
}
|
|
30
24
|
function random(min, max) {
|
|
31
25
|
return Math.floor(Math.random() * (max - min + 1) + min);
|
|
32
26
|
}
|
|
27
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
28
|
+
compressText: ()=>compressText,
|
|
29
|
+
decompressText: ()=>decompressText,
|
|
30
|
+
mergeIntervals: ()=>mergeIntervals,
|
|
31
|
+
random: ()=>random
|
|
32
|
+
});
|
|
33
33
|
},
|
|
34
34
|
"./src/common/crypto.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
35
35
|
function encode(str) {
|
|
@@ -338,6 +338,9 @@ var __webpack_modules__ = {
|
|
|
338
338
|
"@rsdoctor/types" (module) {
|
|
339
339
|
module.exports = require("@rsdoctor/types");
|
|
340
340
|
},
|
|
341
|
+
buffer (module) {
|
|
342
|
+
module.exports = require("buffer");
|
|
343
|
+
},
|
|
341
344
|
fs (module) {
|
|
342
345
|
module.exports = require("fs");
|
|
343
346
|
},
|
|
@@ -349,6 +352,12 @@ var __webpack_modules__ = {
|
|
|
349
352
|
},
|
|
350
353
|
process (module) {
|
|
351
354
|
module.exports = require("process");
|
|
355
|
+
},
|
|
356
|
+
stream (module) {
|
|
357
|
+
module.exports = require("stream");
|
|
358
|
+
},
|
|
359
|
+
zlib (module) {
|
|
360
|
+
module.exports = require("zlib");
|
|
352
361
|
}
|
|
353
362
|
}, __webpack_module_cache__ = {};
|
|
354
363
|
function __webpack_require__(moduleId) {
|
|
@@ -514,7 +523,9 @@ for(var __rspack_i in (()=>{
|
|
|
514
523
|
readMcpConfig: ()=>readMcpConfig,
|
|
515
524
|
writeMcpPort: ()=>writeMcpPort
|
|
516
525
|
});
|
|
517
|
-
var common_summary = __webpack_require__("./src/common/summary.ts"), common_crypto = __webpack_require__("./src/common/crypto.ts"),
|
|
526
|
+
var common_summary = __webpack_require__("./src/common/summary.ts"), common_crypto = __webpack_require__("./src/common/crypto.ts"), external_buffer_ = __webpack_require__("buffer"), external_stream_ = __webpack_require__("stream");
|
|
527
|
+
let external_string_decoder_namespaceObject = require("string_decoder");
|
|
528
|
+
var external_zlib_ = __webpack_require__("zlib"), external_path_ = __webpack_require__("path"), external_path_default = __webpack_require__.n(external_path_);
|
|
518
529
|
function isUrl(uri) {
|
|
519
530
|
return /^https?:\/\//.test(uri);
|
|
520
531
|
}
|
|
@@ -524,12 +535,23 @@ for(var __rspack_i in (()=>{
|
|
|
524
535
|
function isRemoteUrl(uri) {
|
|
525
536
|
return !!('string' == typeof uri && (isUrl(uri) || isFilePath(uri)));
|
|
526
537
|
}
|
|
538
|
+
async function* decodeBase64Shards(shardingFiles, fetchImplement) {
|
|
539
|
+
let remainder = '';
|
|
540
|
+
for (let url of shardingFiles){
|
|
541
|
+
let encodedText = remainder + await fetchImplement(url), decodableLength = encodedText.length - encodedText.length % 4;
|
|
542
|
+
decodableLength > 0 && (yield external_buffer_.Buffer.from(encodedText.slice(0, decodableLength), 'base64')), remainder = encodedText.slice(decodableLength);
|
|
543
|
+
}
|
|
544
|
+
remainder.length > 0 && (yield external_buffer_.Buffer.from(remainder, 'base64'));
|
|
545
|
+
}
|
|
527
546
|
function isShardingData(data) {
|
|
528
547
|
return !!(Array.isArray(data) && data.length > 0 && data.every((e)=>isRemoteUrl(e)));
|
|
529
548
|
}
|
|
530
549
|
async function fetchShardingData(shardingFiles, fetchImplement) {
|
|
531
|
-
|
|
532
|
-
|
|
550
|
+
if (0 === shardingFiles.length) return [];
|
|
551
|
+
let inflater = external_stream_.Readable.from(decodeBase64Shards(shardingFiles, fetchImplement)).pipe((0, external_zlib_.createInflate)()), decoder = new external_string_decoder_namespaceObject.StringDecoder('utf8'), jsonParts = [];
|
|
552
|
+
for await (let chunk of inflater)jsonParts.push(decoder.write(external_buffer_.Buffer.from(chunk)));
|
|
553
|
+
let finalPart = decoder.end();
|
|
554
|
+
return finalPart && jsonParts.push(finalPart), JSON.parse(jsonParts.join(''));
|
|
533
555
|
}
|
|
534
556
|
async function fetchShardingFiles(data, fetchImplement, filterKeys) {
|
|
535
557
|
return (await Promise.all(Object.keys(data).map(async (_key)=>{
|
|
@@ -543,6 +565,7 @@ for(var __rspack_i in (()=>{
|
|
|
543
565
|
};
|
|
544
566
|
}))).reduce((t, c)=>Object.assign(t, c));
|
|
545
567
|
}
|
|
568
|
+
var algorithm = __webpack_require__("./src/common/algorithm.ts");
|
|
546
569
|
function findLoaderTotalTiming(loaders) {
|
|
547
570
|
let start = 1 / 0, end = -1 / 0;
|
|
548
571
|
for(let i = 0; i < loaders.length; i++){
|
|
@@ -690,10 +713,10 @@ for(var __rspack_i in (()=>{
|
|
|
690
713
|
let directories, rootPath = root || process.cwd();
|
|
691
714
|
return (loaders1 = loaders, root1 = rootPath, directories = new Set(), loaders1.forEach((item)=>{
|
|
692
715
|
if (item.resource.path.startsWith(root1)) {
|
|
693
|
-
let pathParts = item.resource.path.
|
|
716
|
+
let pathParts = item.resource.path.slice(root1.length).replace(/^\/+/, '').split('/');
|
|
694
717
|
if (pathParts.length >= 2) {
|
|
695
|
-
let
|
|
696
|
-
directories.add(`${
|
|
718
|
+
let normalizedRoot = root1.replace(/\/+$/, '');
|
|
719
|
+
directories.add(`${normalizedRoot}/${pathParts[0]}`);
|
|
697
720
|
}
|
|
698
721
|
} else {
|
|
699
722
|
let pathParts = item.resource.path.split('/'), twoLevelDir = pathParts.slice(0, pathParts.length - 1).join('/');
|
package/dist/common.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { __webpack_require__ } from "./0~rslib-runtime.js";
|
|
2
|
-
import { deflateSync, inflateSync } from "zlib";
|
|
3
2
|
import { Buffer } from "buffer";
|
|
3
|
+
import { Readable } from "stream";
|
|
4
|
+
import { StringDecoder } from "string_decoder";
|
|
5
|
+
import { createInflate, deflateSync, inflateSync } from "zlib";
|
|
4
6
|
import path_0, { isAbsolute, relative } from "path";
|
|
5
7
|
import { hrtime } from "process";
|
|
6
8
|
import { Client, Constants, Rule, SDK } from "@rsdoctor/types";
|
|
@@ -170,26 +172,6 @@ function decode(str) {
|
|
|
170
172
|
for(let i = 0; i < str.length; i++)'!' === str[i] ? (res += String.fromCharCode(+tmp), tmp = '') : tmp += str[i];
|
|
171
173
|
return tmp && (res += String.fromCharCode(+tmp)), res;
|
|
172
174
|
}
|
|
173
|
-
function mergeIntervals(intervals) {
|
|
174
|
-
let previous, current;
|
|
175
|
-
intervals.sort((a, b)=>a[0] - b[0]);
|
|
176
|
-
let result = [];
|
|
177
|
-
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]);
|
|
178
|
-
return result;
|
|
179
|
-
}
|
|
180
|
-
function compressText(input) {
|
|
181
|
-
try {
|
|
182
|
-
return deflateSync(input).toString('base64');
|
|
183
|
-
} catch (e) {
|
|
184
|
-
return rsdoctorLogger.debug(`compressText error: ${e}`), '';
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
function decompressText(input) {
|
|
188
|
-
return inflateSync(Buffer.from(input, 'base64')).toString();
|
|
189
|
-
}
|
|
190
|
-
function random(min, max) {
|
|
191
|
-
return Math.floor(Math.random() * (max - min + 1) + min);
|
|
192
|
-
}
|
|
193
175
|
function isUrl(uri) {
|
|
194
176
|
return /^https?:\/\//.test(uri);
|
|
195
177
|
}
|
|
@@ -199,12 +181,23 @@ function isFilePath(uri) {
|
|
|
199
181
|
function isRemoteUrl(uri) {
|
|
200
182
|
return !!('string' == typeof uri && (isUrl(uri) || isAbsolute(uri)));
|
|
201
183
|
}
|
|
184
|
+
async function* decodeBase64Shards(shardingFiles, fetchImplement) {
|
|
185
|
+
let remainder = '';
|
|
186
|
+
for (let url of shardingFiles){
|
|
187
|
+
let encodedText = remainder + await fetchImplement(url), decodableLength = encodedText.length - encodedText.length % 4;
|
|
188
|
+
decodableLength > 0 && (yield Buffer.from(encodedText.slice(0, decodableLength), 'base64')), remainder = encodedText.slice(decodableLength);
|
|
189
|
+
}
|
|
190
|
+
remainder.length > 0 && (yield Buffer.from(remainder, 'base64'));
|
|
191
|
+
}
|
|
202
192
|
function isShardingData(data) {
|
|
203
193
|
return !!(Array.isArray(data) && data.length > 0 && data.every((e)=>isRemoteUrl(e)));
|
|
204
194
|
}
|
|
205
195
|
async function fetchShardingData(shardingFiles, fetchImplement) {
|
|
206
|
-
|
|
207
|
-
|
|
196
|
+
if (0 === shardingFiles.length) return [];
|
|
197
|
+
let inflater = Readable.from(decodeBase64Shards(shardingFiles, fetchImplement)).pipe(createInflate()), decoder = new StringDecoder('utf8'), jsonParts = [];
|
|
198
|
+
for await (let chunk of inflater)jsonParts.push(decoder.write(Buffer.from(chunk)));
|
|
199
|
+
let finalPart = decoder.end();
|
|
200
|
+
return finalPart && jsonParts.push(finalPart), JSON.parse(jsonParts.join(''));
|
|
208
201
|
}
|
|
209
202
|
async function fetchShardingFiles(data, fetchImplement, filterKeys) {
|
|
210
203
|
return (await Promise.all(Object.keys(data).map(async (_key)=>{
|
|
@@ -218,6 +211,26 @@ async function fetchShardingFiles(data, fetchImplement, filterKeys) {
|
|
|
218
211
|
};
|
|
219
212
|
}))).reduce((t, c)=>Object.assign(t, c));
|
|
220
213
|
}
|
|
214
|
+
function mergeIntervals(intervals) {
|
|
215
|
+
let previous, current;
|
|
216
|
+
intervals.sort((a, b)=>a[0] - b[0]);
|
|
217
|
+
let result = [];
|
|
218
|
+
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]);
|
|
219
|
+
return result;
|
|
220
|
+
}
|
|
221
|
+
function compressText(input) {
|
|
222
|
+
try {
|
|
223
|
+
return deflateSync(input).toString('base64');
|
|
224
|
+
} catch (e) {
|
|
225
|
+
return rsdoctorLogger.debug(`compressText error: ${e}`), '';
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
function decompressText(input) {
|
|
229
|
+
return inflateSync(Buffer.from(input, 'base64')).toString();
|
|
230
|
+
}
|
|
231
|
+
function random(min, max) {
|
|
232
|
+
return Math.floor(Math.random() * (max - min + 1) + min);
|
|
233
|
+
}
|
|
221
234
|
function findLoaderTotalTiming(loaders) {
|
|
222
235
|
let start = 1 / 0, end = -1 / 0;
|
|
223
236
|
for(let i = 0; i < loaders.length; i++){
|
|
@@ -360,10 +373,10 @@ function getDirectoriesLoaders(loaders, root) {
|
|
|
360
373
|
let directories, rootPath = root || process.cwd();
|
|
361
374
|
return (directories = new Set(), loaders.forEach((item)=>{
|
|
362
375
|
if (item.resource.path.startsWith(rootPath)) {
|
|
363
|
-
let pathParts = item.resource.path.
|
|
376
|
+
let pathParts = item.resource.path.slice(rootPath.length).replace(/^\/+/, '').split('/');
|
|
364
377
|
if (pathParts.length >= 2) {
|
|
365
|
-
let
|
|
366
|
-
directories.add(`${
|
|
378
|
+
let normalizedRoot = rootPath.replace(/\/+$/, '');
|
|
379
|
+
directories.add(`${normalizedRoot}/${pathParts[0]}`);
|
|
367
380
|
}
|
|
368
381
|
} else {
|
|
369
382
|
let pathParts = item.resource.path.split('/'), twoLevelDir = pathParts.slice(0, pathParts.length - 1).join('/');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdoctor/utils",
|
|
3
|
-
"version": "1.6.0",
|
|
3
|
+
"version": "1.6.2-beta.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/web-infra-dev/rsdoctor",
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"picocolors": "^1.1.1",
|
|
102
102
|
"rslog": "^2.1.2",
|
|
103
103
|
"strip-ansi": "^7.2.0",
|
|
104
|
-
"@rsdoctor/types": "1.6.0"
|
|
104
|
+
"@rsdoctor/types": "1.6.2-beta.0"
|
|
105
105
|
},
|
|
106
106
|
"devDependencies": {
|
|
107
107
|
"@types/babel__code-frame": "7.27.0",
|