@rsdoctor/utils 1.5.7 → 1.5.9
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/{rslib-runtime.js → 0~rslib-runtime.js} +1 -11
- package/dist/496.js +1 -1
- package/dist/build.js +1 -1
- package/dist/common/fetch.d.ts +10 -0
- package/dist/common/index.d.ts +1 -0
- package/dist/common.cjs +47 -6
- package/dist/common.js +42 -4
- package/dist/ruleUtils.cjs +1 -1
- package/dist/ruleUtils.js +2 -2
- package/package.json +2 -2
|
@@ -1,19 +1,9 @@
|
|
|
1
|
-
var
|
|
2
|
-
function __webpack_require__(moduleId) {
|
|
3
|
-
var cachedModule = __webpack_module_cache__[moduleId];
|
|
4
|
-
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
5
|
-
var module = __webpack_module_cache__[moduleId] = {
|
|
6
|
-
exports: {}
|
|
7
|
-
};
|
|
8
|
-
return __webpack_modules__[moduleId](module, module.exports, __webpack_require__), module.exports;
|
|
9
|
-
}
|
|
1
|
+
var __webpack_require__ = {};
|
|
10
2
|
__webpack_require__.d = (exports, definition)=>{
|
|
11
3
|
for(var key in definition)__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key) && Object.defineProperty(exports, key, {
|
|
12
4
|
enumerable: !0,
|
|
13
5
|
get: definition[key]
|
|
14
6
|
});
|
|
15
|
-
}, __webpack_require__.add = function(modules) {
|
|
16
|
-
Object.assign(__webpack_require__.m, modules);
|
|
17
7
|
}, __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop), __webpack_require__.r = (exports)=>{
|
|
18
8
|
"u" > typeof Symbol && Symbol.toStringTag && Object.defineProperty(exports, Symbol.toStringTag, {
|
|
19
9
|
value: 'Module'
|
package/dist/496.js
CHANGED
package/dist/build.js
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare function getFetch(): typeof fetch;
|
|
2
|
+
export interface FetchOptions {
|
|
3
|
+
timeout?: number;
|
|
4
|
+
method?: string;
|
|
5
|
+
headers?: Record<string, string>;
|
|
6
|
+
body?: string;
|
|
7
|
+
signal?: AbortSignal;
|
|
8
|
+
}
|
|
9
|
+
export declare function fetchWithTimeout(url: string, options?: FetchOptions): Promise<Response>;
|
|
10
|
+
export declare function postJSON(url: string, body: unknown, timeout?: number): Promise<Response>;
|
package/dist/common/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export * as Url from './url.js';
|
|
|
11
11
|
export * as Plugin from './plugin.js';
|
|
12
12
|
export * as Data from './data/index.js';
|
|
13
13
|
export * as Alerts from './alerts.js';
|
|
14
|
+
export * as Fetch from './fetch.js';
|
|
14
15
|
export * as Rspack from './rspack.js';
|
|
15
16
|
export * as Package from './package.js';
|
|
16
17
|
export * as Lodash from './lodash.js';
|
package/dist/common.cjs
CHANGED
|
@@ -73,6 +73,45 @@ var __webpack_modules__ = {
|
|
|
73
73
|
}(object, '$');
|
|
74
74
|
}
|
|
75
75
|
},
|
|
76
|
+
"./src/common/fetch.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
77
|
+
function getFetch() {
|
|
78
|
+
let currentFetch = globalThis.fetch;
|
|
79
|
+
if ('function' != typeof currentFetch) throw Error('fetch is not available in this environment');
|
|
80
|
+
return currentFetch.bind(globalThis);
|
|
81
|
+
}
|
|
82
|
+
async function fetchWithTimeout(url, options = {}) {
|
|
83
|
+
let { timeout = 30000, signal: externalSignal, ...init } = options, controller = new AbortController(), timeoutId = setTimeout(()=>controller.abort(), timeout);
|
|
84
|
+
externalSignal && (externalSignal.aborted ? controller.abort() : externalSignal.addEventListener('abort', ()=>controller.abort(), {
|
|
85
|
+
once: !0
|
|
86
|
+
}));
|
|
87
|
+
let fetchImpl = getFetch();
|
|
88
|
+
try {
|
|
89
|
+
let res = await fetchImpl(url, {
|
|
90
|
+
...init,
|
|
91
|
+
signal: controller.signal
|
|
92
|
+
});
|
|
93
|
+
if (!res.ok) throw Error(`Request failed with status ${res.status}`);
|
|
94
|
+
return res;
|
|
95
|
+
} finally{
|
|
96
|
+
clearTimeout(timeoutId);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
async function postJSON(url, body, timeout = 30000) {
|
|
100
|
+
return fetchWithTimeout(url, {
|
|
101
|
+
method: 'POST',
|
|
102
|
+
headers: {
|
|
103
|
+
'Content-Type': 'application/json'
|
|
104
|
+
},
|
|
105
|
+
body: JSON.stringify(body),
|
|
106
|
+
timeout
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
__webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_exports__, {
|
|
110
|
+
fetchWithTimeout: ()=>fetchWithTimeout,
|
|
111
|
+
getFetch: ()=>getFetch,
|
|
112
|
+
postJSON: ()=>postJSON
|
|
113
|
+
});
|
|
114
|
+
},
|
|
76
115
|
"./src/common/file.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
77
116
|
function isStyleExt(path) {
|
|
78
117
|
return /\.(c|le|sa|sc)ss(\?.*)?$/.test(path);
|
|
@@ -349,10 +388,11 @@ for(var __rspack_i in (()=>{
|
|
|
349
388
|
Alerts: ()=>alerts_namespaceObject,
|
|
350
389
|
Package: ()=>package_namespaceObject,
|
|
351
390
|
decycle: ()=>decycle.Y,
|
|
352
|
-
|
|
391
|
+
Plugin: ()=>common_plugin,
|
|
353
392
|
Data: ()=>data_namespaceObject,
|
|
393
|
+
Fetch: ()=>fetch,
|
|
354
394
|
Manifest: ()=>manifest_namespaceObject,
|
|
355
|
-
|
|
395
|
+
Resolver: ()=>resolver_namespaceObject,
|
|
356
396
|
File: ()=>common_file,
|
|
357
397
|
Graph: ()=>graph_namespaceObject,
|
|
358
398
|
Bundle: ()=>bundle_namespaceObject,
|
|
@@ -597,7 +637,7 @@ for(var __rspack_i in (()=>{
|
|
|
597
637
|
return {
|
|
598
638
|
...data,
|
|
599
639
|
loaders: data.loaders.map((el)=>{
|
|
600
|
-
let { input, result, ...loaderWithoutCode } = el;
|
|
640
|
+
let { input: _input, result: _result, ...loaderWithoutCode } = el;
|
|
601
641
|
return {
|
|
602
642
|
...loaderWithoutCode,
|
|
603
643
|
loader: getLoadrName(el.loader),
|
|
@@ -1400,7 +1440,7 @@ for(var __rspack_i in (()=>{
|
|
|
1400
1440
|
case types_.SDK.ServerAPI.API.GetChunkGraphAI:
|
|
1401
1441
|
return this.loader.loadData('chunkGraph').then((res)=>{
|
|
1402
1442
|
let { assets = [] } = res || {};
|
|
1403
|
-
return assets.map(({ content, ...rest })=>rest);
|
|
1443
|
+
return assets.map(({ content: _, ...rest })=>rest);
|
|
1404
1444
|
});
|
|
1405
1445
|
case types_.SDK.ServerAPI.API.GetChunkByIdAI:
|
|
1406
1446
|
return Promise.all([
|
|
@@ -1429,7 +1469,7 @@ for(var __rspack_i in (()=>{
|
|
|
1429
1469
|
}
|
|
1430
1470
|
}
|
|
1431
1471
|
}
|
|
1432
|
-
var lodash = __webpack_require__("./src/common/lodash.ts");
|
|
1472
|
+
var fetch = __webpack_require__("./src/common/fetch.ts"), lodash = __webpack_require__("./src/common/lodash.ts");
|
|
1433
1473
|
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)=>{
|
|
1434
1474
|
var data;
|
|
1435
1475
|
let res, paths = modulePath.match(MODULE_PATH_PACKAGES);
|
|
@@ -1477,12 +1517,13 @@ for(var __rspack_i in (()=>{
|
|
|
1477
1517
|
return external_path_default().join(rsdoctorDir, 'mcp.json');
|
|
1478
1518
|
}
|
|
1479
1519
|
var common_file = __webpack_require__("./src/common/file.ts"), decycle = __webpack_require__("./src/common/decycle.ts");
|
|
1480
|
-
})(), 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 === [
|
|
1520
|
+
})(), 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.Fetch = __webpack_exports__.Fetch, 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 === [
|
|
1481
1521
|
"Alerts",
|
|
1482
1522
|
"Algorithm",
|
|
1483
1523
|
"Bundle",
|
|
1484
1524
|
"Crypto",
|
|
1485
1525
|
"Data",
|
|
1526
|
+
"Fetch",
|
|
1486
1527
|
"File",
|
|
1487
1528
|
"GlobalConfig",
|
|
1488
1529
|
"Graph",
|
package/dist/common.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
1
|
+
import { __webpack_require__ } from "./0~rslib-runtime.js";
|
|
2
2
|
import { deflateSync, inflateSync } from "zlib";
|
|
3
3
|
import { Buffer } from "buffer";
|
|
4
4
|
import path_0, { isAbsolute, relative } from "path";
|
|
@@ -34,6 +34,12 @@ var data_namespaceObject = {};
|
|
|
34
34
|
__webpack_require__.r(data_namespaceObject), __webpack_require__.d(data_namespaceObject, {
|
|
35
35
|
APIDataLoader: ()=>APIDataLoader
|
|
36
36
|
});
|
|
37
|
+
var fetch_namespaceObject = {};
|
|
38
|
+
__webpack_require__.r(fetch_namespaceObject), __webpack_require__.d(fetch_namespaceObject, {
|
|
39
|
+
fetchWithTimeout: ()=>fetchWithTimeout,
|
|
40
|
+
getFetch: ()=>getFetch,
|
|
41
|
+
postJSON: ()=>postJSON
|
|
42
|
+
});
|
|
37
43
|
var file_namespaceObject = {};
|
|
38
44
|
__webpack_require__.r(file_namespaceObject), __webpack_require__.d(file_namespaceObject, {
|
|
39
45
|
isJsExt: ()=>isJsExt,
|
|
@@ -307,7 +313,7 @@ function getLoaderFileDetails(path, loaders) {
|
|
|
307
313
|
return {
|
|
308
314
|
...data,
|
|
309
315
|
loaders: data.loaders.map((el)=>{
|
|
310
|
-
let { input, result, ...loaderWithoutCode } = el;
|
|
316
|
+
let { input: _input, result: _result, ...loaderWithoutCode } = el;
|
|
311
317
|
return {
|
|
312
318
|
...loaderWithoutCode,
|
|
313
319
|
loader: getLoadrName(el.loader),
|
|
@@ -1185,7 +1191,7 @@ class APIDataLoader {
|
|
|
1185
1191
|
case SDK.ServerAPI.API.GetChunkGraphAI:
|
|
1186
1192
|
return this.loader.loadData('chunkGraph').then((res)=>{
|
|
1187
1193
|
let { assets = [] } = res || {};
|
|
1188
|
-
return assets.map(({ content, ...rest })=>rest);
|
|
1194
|
+
return assets.map(({ content: _, ...rest })=>rest);
|
|
1189
1195
|
});
|
|
1190
1196
|
case SDK.ServerAPI.API.GetChunkByIdAI:
|
|
1191
1197
|
return Promise.all([
|
|
@@ -1214,6 +1220,38 @@ class APIDataLoader {
|
|
|
1214
1220
|
}
|
|
1215
1221
|
}
|
|
1216
1222
|
}
|
|
1223
|
+
function getFetch() {
|
|
1224
|
+
let currentFetch = globalThis.fetch;
|
|
1225
|
+
if ('function' != typeof currentFetch) throw Error('fetch is not available in this environment');
|
|
1226
|
+
return currentFetch.bind(globalThis);
|
|
1227
|
+
}
|
|
1228
|
+
async function fetchWithTimeout(url, options = {}) {
|
|
1229
|
+
let { timeout = 30000, signal: externalSignal, ...init } = options, controller = new AbortController(), timeoutId = setTimeout(()=>controller.abort(), timeout);
|
|
1230
|
+
externalSignal && (externalSignal.aborted ? controller.abort() : externalSignal.addEventListener('abort', ()=>controller.abort(), {
|
|
1231
|
+
once: !0
|
|
1232
|
+
}));
|
|
1233
|
+
let fetchImpl = getFetch();
|
|
1234
|
+
try {
|
|
1235
|
+
let res = await fetchImpl(url, {
|
|
1236
|
+
...init,
|
|
1237
|
+
signal: controller.signal
|
|
1238
|
+
});
|
|
1239
|
+
if (!res.ok) throw Error(`Request failed with status ${res.status}`);
|
|
1240
|
+
return res;
|
|
1241
|
+
} finally{
|
|
1242
|
+
clearTimeout(timeoutId);
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
async function postJSON(url, body, timeout = 30000) {
|
|
1246
|
+
return fetchWithTimeout(url, {
|
|
1247
|
+
method: 'POST',
|
|
1248
|
+
headers: {
|
|
1249
|
+
'Content-Type': 'application/json'
|
|
1250
|
+
},
|
|
1251
|
+
body: JSON.stringify(body),
|
|
1252
|
+
timeout
|
|
1253
|
+
});
|
|
1254
|
+
}
|
|
1217
1255
|
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)=>{
|
|
1218
1256
|
var data;
|
|
1219
1257
|
let res, paths = modulePath.match(MODULE_PATH_PACKAGES);
|
|
@@ -1287,4 +1325,4 @@ function decycle(object) {
|
|
|
1287
1325
|
}(object, '$');
|
|
1288
1326
|
}
|
|
1289
1327
|
export { Lodash } from "./496.js";
|
|
1290
|
-
export { alerts_namespaceObject as Alerts, algorithm_namespaceObject as Algorithm, bundle_namespaceObject as Bundle, crypto_namespaceObject as Crypto, data_namespaceObject as Data, decycle, file_namespaceObject as File, getPackageMetaFromModulePath, global_config_namespaceObject as GlobalConfig, graph_namespaceObject as Graph, loader_namespaceObject as Loader, manifest_namespaceObject as Manifest, package_namespaceObject as Package, plugin_namespaceObject as Plugin, random, resolver_namespaceObject as Resolver, rspack_namespaceObject as Rspack, summary_namespaceObject as Summary, time_namespaceObject as Time, url_namespaceObject as Url };
|
|
1328
|
+
export { alerts_namespaceObject as Alerts, algorithm_namespaceObject as Algorithm, bundle_namespaceObject as Bundle, crypto_namespaceObject as Crypto, data_namespaceObject as Data, decycle, fetch_namespaceObject as Fetch, file_namespaceObject as File, getPackageMetaFromModulePath, global_config_namespaceObject as GlobalConfig, graph_namespaceObject as Graph, loader_namespaceObject as Loader, manifest_namespaceObject as Manifest, package_namespaceObject as Package, plugin_namespaceObject as Plugin, random, resolver_namespaceObject as Resolver, rspack_namespaceObject as Rspack, summary_namespaceObject as Summary, time_namespaceObject as Time, url_namespaceObject as Url };
|
package/dist/ruleUtils.cjs
CHANGED
package/dist/ruleUtils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
1
|
+
import { __webpack_require__ } from "./0~rslib-runtime.js";
|
|
2
2
|
import { LinesAndColumns } from "lines-and-columns";
|
|
3
3
|
import { Parser, parse } from "acorn";
|
|
4
4
|
import { importAttributes } from "acorn-import-attributes";
|
|
@@ -211,7 +211,7 @@ function canParse(code, ecmaVersion) {
|
|
|
211
211
|
ecmaVersion,
|
|
212
212
|
sourceType: 'number' == typeof ecmaVersion && ecmaVersion <= 5 ? "script" : 'module'
|
|
213
213
|
}), !0;
|
|
214
|
-
} catch
|
|
214
|
+
} catch {
|
|
215
215
|
return !1;
|
|
216
216
|
}
|
|
217
217
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdoctor/utils",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.9",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/web-infra-dev/rsdoctor",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"picocolors": "^1.1.1",
|
|
77
77
|
"rslog": "^1.3.2",
|
|
78
78
|
"strip-ansi": "^6.0.1",
|
|
79
|
-
"@rsdoctor/types": "1.5.
|
|
79
|
+
"@rsdoctor/types": "1.5.9"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
82
|
"@types/babel__code-frame": "7.27.0",
|