@rsdoctor/utils 1.6.3-beta.0 → 1.6.4
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 +10 -18
- package/dist/build.js +4 -4
- package/dist/common.cjs +17 -48
- package/dist/common.js +26 -47
- 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
|
|
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>;
|
|
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
|
|
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>;
|
|
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__
|
|
8
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
9
9
|
random: ()=>random
|
|
10
|
-
});
|
|
10
|
+
}), require("zlib"), require("buffer"), __webpack_require__("./src/logger.ts");
|
|
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__("
|
|
19
|
+
}), __webpack_require__("./src/common/algorithm.ts"), __webpack_require__("path"), __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,9 +95,6 @@ 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
|
-
},
|
|
101
98
|
fs (module) {
|
|
102
99
|
module.exports = require("fs");
|
|
103
100
|
},
|
|
@@ -109,12 +106,6 @@ var __webpack_modules__ = {
|
|
|
109
106
|
},
|
|
110
107
|
process (module) {
|
|
111
108
|
module.exports = require("process");
|
|
112
|
-
},
|
|
113
|
-
stream (module) {
|
|
114
|
-
module.exports = require("stream");
|
|
115
|
-
},
|
|
116
|
-
zlib (module) {
|
|
117
|
-
module.exports = require("zlib");
|
|
118
109
|
}
|
|
119
110
|
}, __webpack_module_cache__ = {};
|
|
120
111
|
function __webpack_require__(moduleId) {
|
|
@@ -248,22 +239,23 @@ for(var __rspack_i in (()=>{
|
|
|
248
239
|
return JSON.parse(readFileSync(path));
|
|
249
240
|
}
|
|
250
241
|
let external_json_stream_stringify_namespaceObject = require("json-stream-stringify");
|
|
251
|
-
var common = __webpack_require__("./src/common/index.ts")
|
|
252
|
-
|
|
242
|
+
var common = __webpack_require__("./src/common/index.ts");
|
|
243
|
+
let external_stream_namespaceObject = require("stream");
|
|
244
|
+
function stringify(json, replacer, space, cycle) {
|
|
253
245
|
let jsonList = [];
|
|
254
246
|
return json && 'object' == typeof json ? new Promise((resolve, reject)=>{
|
|
255
|
-
let stream = new external_json_stream_stringify_namespaceObject.JsonStreamStringify(json, replacer, space, cycle), currentLength = 0, currentContent = '', batchProcessor = new
|
|
247
|
+
let stream = new external_json_stream_stringify_namespaceObject.JsonStreamStringify(json, replacer, space, cycle), currentLength = 0, currentContent = '', batchProcessor = new external_stream_namespaceObject.Transform({
|
|
256
248
|
readableObjectMode: !0,
|
|
257
249
|
transform (chunk, _encoding, callback) {
|
|
258
250
|
chunk.toString().split('\\n').forEach((line)=>{
|
|
259
|
-
currentLength + line.length >
|
|
251
|
+
currentLength + line.length > 419430400 && (jsonList.push(currentContent), currentContent = '', currentLength = 0), line.length && (currentContent += line, currentLength += line.length);
|
|
260
252
|
}), callback();
|
|
261
253
|
}
|
|
262
254
|
});
|
|
263
255
|
stream.pipe(batchProcessor).on('data', (line)=>{
|
|
264
|
-
currentLength + line.length >
|
|
256
|
+
currentLength + line.length > 419430400 && (jsonList.push(currentContent), currentContent = '', currentLength = 0), line.length && (currentContent += line, currentLength += line.length);
|
|
265
257
|
}).on('end', ()=>{
|
|
266
|
-
|
|
258
|
+
jsonList.length < 1 && jsonList.push(currentContent), resolve(jsonList);
|
|
267
259
|
}).on('error', (err)=>reject(err));
|
|
268
260
|
}) : Promise.resolve(JSON.stringify(json, replacer, space));
|
|
269
261
|
}
|
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) {
|
|
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 > 419430400 && (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 > 419430400 && (jsonList.push(currentContent), currentContent = '', currentLength = 0), line.length && (currentContent += line, currentLength += line.length);
|
|
119
119
|
}).on('end', ()=>{
|
|
120
|
-
|
|
120
|
+
jsonList.length < 1 && 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,8 +2,14 @@
|
|
|
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
|
-
|
|
5
|
+
__webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_exports__, {
|
|
6
|
+
compressText: ()=>compressText,
|
|
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");
|
|
7
13
|
function mergeIntervals(intervals) {
|
|
8
14
|
let previous, current;
|
|
9
15
|
intervals.sort((a, b)=>a[0] - b[0]);
|
|
@@ -13,23 +19,17 @@ var __webpack_modules__ = {
|
|
|
13
19
|
}
|
|
14
20
|
function compressText(input) {
|
|
15
21
|
try {
|
|
16
|
-
return (0,
|
|
22
|
+
return (0, external_zlib_namespaceObject.deflateSync)(input).toString('base64');
|
|
17
23
|
} catch (e) {
|
|
18
|
-
return
|
|
24
|
+
return logger.logger.debug(`compressText error: ${e}`), '';
|
|
19
25
|
}
|
|
20
26
|
}
|
|
21
27
|
function decompressText(input) {
|
|
22
|
-
return (0,
|
|
28
|
+
return (0, external_zlib_namespaceObject.inflateSync)(external_buffer_namespaceObject.Buffer.from(input, 'base64')).toString();
|
|
23
29
|
}
|
|
24
30
|
function random(min, max) {
|
|
25
31
|
return Math.floor(Math.random() * (max - min + 1) + min);
|
|
26
32
|
}
|
|
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,9 +338,6 @@ 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
|
-
},
|
|
344
341
|
fs (module) {
|
|
345
342
|
module.exports = require("fs");
|
|
346
343
|
},
|
|
@@ -352,12 +349,6 @@ var __webpack_modules__ = {
|
|
|
352
349
|
},
|
|
353
350
|
process (module) {
|
|
354
351
|
module.exports = require("process");
|
|
355
|
-
},
|
|
356
|
-
stream (module) {
|
|
357
|
-
module.exports = require("stream");
|
|
358
|
-
},
|
|
359
|
-
zlib (module) {
|
|
360
|
-
module.exports = require("zlib");
|
|
361
352
|
}
|
|
362
353
|
}, __webpack_module_cache__ = {};
|
|
363
354
|
function __webpack_require__(moduleId) {
|
|
@@ -523,9 +514,7 @@ for(var __rspack_i in (()=>{
|
|
|
523
514
|
readMcpConfig: ()=>readMcpConfig,
|
|
524
515
|
writeMcpPort: ()=>writeMcpPort
|
|
525
516
|
});
|
|
526
|
-
var common_summary = __webpack_require__("./src/common/summary.ts"), common_crypto = __webpack_require__("./src/common/crypto.ts"),
|
|
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_);
|
|
517
|
+
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_);
|
|
529
518
|
function isUrl(uri) {
|
|
530
519
|
return /^https?:\/\//.test(uri);
|
|
531
520
|
}
|
|
@@ -535,31 +524,12 @@ for(var __rspack_i in (()=>{
|
|
|
535
524
|
function isRemoteUrl(uri) {
|
|
536
525
|
return !!('string' == typeof uri && (isUrl(uri) || isFilePath(uri)));
|
|
537
526
|
}
|
|
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
|
-
}
|
|
546
527
|
function isShardingData(data) {
|
|
547
528
|
return !!(Array.isArray(data) && data.length > 0 && data.every((e)=>isRemoteUrl(e)));
|
|
548
529
|
}
|
|
549
530
|
async function fetchShardingData(shardingFiles, fetchImplement) {
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
await new Promise((resolve, reject)=>{
|
|
553
|
-
(0, external_stream_.pipeline)(external_stream_.Readable.from(decodeBase64Shards(shardingFiles, fetchImplement)), (0, external_zlib_.createInflate)(), new external_stream_.Writable({
|
|
554
|
-
write (chunk, _encoding, callback) {
|
|
555
|
-
jsonParts.push(decoder.write(external_buffer_.Buffer.from(chunk))), callback();
|
|
556
|
-
}
|
|
557
|
-
}), (error)=>{
|
|
558
|
-
error ? reject(error) : resolve();
|
|
559
|
-
});
|
|
560
|
-
});
|
|
561
|
-
let finalPart = decoder.end();
|
|
562
|
-
return finalPart && jsonParts.push(finalPart), JSON.parse(jsonParts.join(''));
|
|
531
|
+
let res = await Promise.all(shardingFiles.map((url)=>fetchImplement(url))), strings = 0 === res.length ? [] : res.reduce((t, e)=>t + e);
|
|
532
|
+
return 'object' == typeof strings ? strings : JSON.parse((0, algorithm.decompressText)(strings));
|
|
563
533
|
}
|
|
564
534
|
async function fetchShardingFiles(data, fetchImplement, filterKeys) {
|
|
565
535
|
return (await Promise.all(Object.keys(data).map(async (_key)=>{
|
|
@@ -573,7 +543,6 @@ for(var __rspack_i in (()=>{
|
|
|
573
543
|
};
|
|
574
544
|
}))).reduce((t, c)=>Object.assign(t, c));
|
|
575
545
|
}
|
|
576
|
-
var algorithm = __webpack_require__("./src/common/algorithm.ts");
|
|
577
546
|
function findLoaderTotalTiming(loaders) {
|
|
578
547
|
let start = 1 / 0, end = -1 / 0;
|
|
579
548
|
for(let i = 0; i < loaders.length; i++){
|
|
@@ -721,10 +690,10 @@ for(var __rspack_i in (()=>{
|
|
|
721
690
|
let directories, rootPath = root || process.cwd();
|
|
722
691
|
return (loaders1 = loaders, root1 = rootPath, directories = new Set(), loaders1.forEach((item)=>{
|
|
723
692
|
if (item.resource.path.startsWith(root1)) {
|
|
724
|
-
let pathParts = item.resource.path.
|
|
693
|
+
let pathParts = item.resource.path.split(root1).slice(1).join('/').split('/');
|
|
725
694
|
if (pathParts.length >= 2) {
|
|
726
|
-
let
|
|
727
|
-
directories.add(`${
|
|
695
|
+
let twoLevelDir = pathParts.slice(0, 2).join('/');
|
|
696
|
+
directories.add(`${root1}/${twoLevelDir}`);
|
|
728
697
|
}
|
|
729
698
|
} else {
|
|
730
699
|
let pathParts = item.resource.path.split('/'), twoLevelDir = pathParts.slice(0, pathParts.length - 1).join('/');
|
package/dist/common.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { __webpack_require__ } from "./0~rslib-runtime.js";
|
|
2
|
+
import { deflateSync, inflateSync } from "zlib";
|
|
2
3
|
import { Buffer } from "buffer";
|
|
3
|
-
import { Readable, Writable, pipeline } from "stream";
|
|
4
|
-
import { StringDecoder } from "string_decoder";
|
|
5
|
-
import { createInflate, deflateSync, inflateSync } from "zlib";
|
|
6
4
|
import path_0, { isAbsolute, relative } from "path";
|
|
7
5
|
import { hrtime } from "process";
|
|
8
6
|
import { Client, Constants, Rule, SDK } from "@rsdoctor/types";
|
|
@@ -172,6 +170,26 @@ function decode(str) {
|
|
|
172
170
|
for(let i = 0; i < str.length; i++)'!' === str[i] ? (res += String.fromCharCode(+tmp), tmp = '') : tmp += str[i];
|
|
173
171
|
return tmp && (res += String.fromCharCode(+tmp)), res;
|
|
174
172
|
}
|
|
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
|
+
}
|
|
175
193
|
function isUrl(uri) {
|
|
176
194
|
return /^https?:\/\//.test(uri);
|
|
177
195
|
}
|
|
@@ -181,31 +199,12 @@ function isFilePath(uri) {
|
|
|
181
199
|
function isRemoteUrl(uri) {
|
|
182
200
|
return !!('string' == typeof uri && (isUrl(uri) || isAbsolute(uri)));
|
|
183
201
|
}
|
|
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
|
-
}
|
|
192
202
|
function isShardingData(data) {
|
|
193
203
|
return !!(Array.isArray(data) && data.length > 0 && data.every((e)=>isRemoteUrl(e)));
|
|
194
204
|
}
|
|
195
205
|
async function fetchShardingData(shardingFiles, fetchImplement) {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
await new Promise((resolve, reject)=>{
|
|
199
|
-
pipeline(Readable.from(decodeBase64Shards(shardingFiles, fetchImplement)), createInflate(), new Writable({
|
|
200
|
-
write (chunk, _encoding, callback) {
|
|
201
|
-
jsonParts.push(decoder.write(Buffer.from(chunk))), callback();
|
|
202
|
-
}
|
|
203
|
-
}), (error)=>{
|
|
204
|
-
error ? reject(error) : resolve();
|
|
205
|
-
});
|
|
206
|
-
});
|
|
207
|
-
let finalPart = decoder.end();
|
|
208
|
-
return finalPart && jsonParts.push(finalPart), JSON.parse(jsonParts.join(''));
|
|
206
|
+
let res = await Promise.all(shardingFiles.map((url)=>fetchImplement(url))), strings = 0 === res.length ? [] : res.reduce((t, e)=>t + e);
|
|
207
|
+
return 'object' == typeof strings ? strings : JSON.parse(decompressText(strings));
|
|
209
208
|
}
|
|
210
209
|
async function fetchShardingFiles(data, fetchImplement, filterKeys) {
|
|
211
210
|
return (await Promise.all(Object.keys(data).map(async (_key)=>{
|
|
@@ -219,26 +218,6 @@ async function fetchShardingFiles(data, fetchImplement, filterKeys) {
|
|
|
219
218
|
};
|
|
220
219
|
}))).reduce((t, c)=>Object.assign(t, c));
|
|
221
220
|
}
|
|
222
|
-
function mergeIntervals(intervals) {
|
|
223
|
-
let previous, current;
|
|
224
|
-
intervals.sort((a, b)=>a[0] - b[0]);
|
|
225
|
-
let result = [];
|
|
226
|
-
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]);
|
|
227
|
-
return result;
|
|
228
|
-
}
|
|
229
|
-
function compressText(input) {
|
|
230
|
-
try {
|
|
231
|
-
return deflateSync(input).toString('base64');
|
|
232
|
-
} catch (e) {
|
|
233
|
-
return rsdoctorLogger.debug(`compressText error: ${e}`), '';
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
function decompressText(input) {
|
|
237
|
-
return inflateSync(Buffer.from(input, 'base64')).toString();
|
|
238
|
-
}
|
|
239
|
-
function random(min, max) {
|
|
240
|
-
return Math.floor(Math.random() * (max - min + 1) + min);
|
|
241
|
-
}
|
|
242
221
|
function findLoaderTotalTiming(loaders) {
|
|
243
222
|
let start = 1 / 0, end = -1 / 0;
|
|
244
223
|
for(let i = 0; i < loaders.length; i++){
|
|
@@ -381,10 +360,10 @@ function getDirectoriesLoaders(loaders, root) {
|
|
|
381
360
|
let directories, rootPath = root || process.cwd();
|
|
382
361
|
return (directories = new Set(), loaders.forEach((item)=>{
|
|
383
362
|
if (item.resource.path.startsWith(rootPath)) {
|
|
384
|
-
let pathParts = item.resource.path.
|
|
363
|
+
let pathParts = item.resource.path.split(rootPath).slice(1).join('/').split('/');
|
|
385
364
|
if (pathParts.length >= 2) {
|
|
386
|
-
let
|
|
387
|
-
directories.add(`${
|
|
365
|
+
let twoLevelDir = pathParts.slice(0, 2).join('/');
|
|
366
|
+
directories.add(`${rootPath}/${twoLevelDir}`);
|
|
388
367
|
}
|
|
389
368
|
} else {
|
|
390
369
|
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.
|
|
3
|
+
"version": "1.6.4",
|
|
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.
|
|
104
|
+
"@rsdoctor/types": "1.6.4"
|
|
105
105
|
},
|
|
106
106
|
"devDependencies": {
|
|
107
107
|
"@types/babel__code-frame": "7.27.0",
|