@rsdoctor/utils 1.1.10 → 1.2.0-beta.1
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/cjs/build/envinfo.js +107 -95
- package/dist/cjs/build/file/cache.js +65 -56
- package/dist/cjs/build/file/index.js +78 -41
- package/dist/cjs/build/file/sharding.js +90 -78
- package/dist/cjs/build/index.js +49 -47
- package/dist/cjs/build/json.js +91 -98
- package/dist/cjs/build/process.js +47 -42
- package/dist/cjs/build/server.js +110 -87
- package/dist/cjs/common/alerts.js +46 -44
- package/dist/cjs/common/algorithm.js +63 -54
- package/dist/cjs/common/bundle.js +52 -46
- package/dist/cjs/common/crypto.js +47 -46
- package/dist/cjs/common/data/index.js +381 -455
- package/dist/cjs/common/file.js +44 -0
- package/dist/cjs/common/global-config.js +72 -64
- package/dist/cjs/common/graph/assets.js +274 -308
- package/dist/cjs/common/graph/chunk.js +66 -63
- package/dist/cjs/common/graph/dependency.js +42 -32
- package/dist/cjs/common/graph/entrypoints.js +33 -25
- package/dist/cjs/common/graph/index.js +93 -27
- package/dist/cjs/common/graph/modules.js +113 -98
- package/dist/cjs/common/index.js +101 -83
- package/dist/cjs/common/loader.js +277 -273
- package/dist/cjs/common/lodash.js +73 -62
- package/dist/cjs/common/manifest.js +57 -59
- package/dist/cjs/common/package.js +79 -80
- package/dist/cjs/common/plugin.js +78 -73
- package/dist/cjs/common/resolver.js +79 -69
- package/dist/cjs/common/rspack.js +43 -34
- package/dist/cjs/common/summary.js +39 -31
- package/dist/cjs/common/time.js +73 -78
- package/dist/cjs/common/url.js +44 -36
- package/dist/cjs/error/error.js +183 -220
- package/dist/cjs/error/index.js +70 -28
- package/dist/cjs/error/transform.js +150 -143
- package/dist/cjs/error/utils.js +54 -58
- package/dist/cjs/index.js +37 -38
- package/dist/cjs/logger.js +99 -73
- package/dist/cjs/rule-utils/document/document.js +83 -82
- package/dist/cjs/rule-utils/document/index.js +75 -23
- package/dist/cjs/rule-utils/document/server.js +42 -35
- package/dist/cjs/rule-utils/document/types.js +17 -15
- package/dist/cjs/rule-utils/index.js +66 -21
- package/dist/cjs/rule-utils/parser/asserts.js +129 -147
- package/dist/cjs/rule-utils/parser/index.js +84 -25
- package/dist/cjs/rule-utils/parser/parser.js +50 -85
- package/dist/cjs/rule-utils/parser/types.js +38 -30
- package/dist/cjs/rule-utils/parser/utils.js +141 -168
- package/dist/esm/build/envinfo.mjs +57 -0
- package/dist/esm/build/file/cache.mjs +23 -0
- package/dist/esm/build/file/index.mjs +4 -0
- package/dist/esm/build/file/sharding.mjs +50 -0
- package/dist/esm/build/index.mjs +6 -0
- package/dist/esm/build/json.mjs +66 -0
- package/dist/esm/build/process.mjs +17 -0
- package/dist/esm/build/server.mjs +96 -0
- package/dist/esm/common/alerts.mjs +17 -0
- package/dist/esm/common/algorithm.mjs +32 -0
- package/dist/esm/common/bundle.mjs +22 -0
- package/dist/esm/common/crypto.mjs +17 -0
- package/dist/esm/common/data/index.mjs +354 -0
- package/dist/esm/common/file.mjs +7 -0
- package/dist/esm/common/global-config.mjs +32 -0
- package/dist/esm/common/graph/assets.mjs +238 -0
- package/dist/esm/common/graph/chunk.mjs +32 -0
- package/dist/esm/common/graph/dependency.mjs +10 -0
- package/dist/esm/common/graph/entrypoints.mjs +4 -0
- package/dist/esm/common/graph/index.mjs +5 -0
- package/dist/esm/common/graph/modules.mjs +78 -0
- package/dist/esm/common/index.mjs +19 -0
- package/dist/esm/common/loader.mjs +247 -0
- package/dist/esm/common/lodash.mjs +32 -0
- package/dist/esm/common/manifest.mjs +30 -0
- package/dist/esm/common/package.mjs +56 -0
- package/dist/esm/common/plugin.mjs +48 -0
- package/dist/esm/common/resolver.mjs +46 -0
- package/dist/esm/common/rspack.mjs +9 -0
- package/dist/esm/common/summary.mjs +8 -0
- package/dist/esm/common/time.mjs +43 -0
- package/dist/esm/common/url.mjs +14 -0
- package/dist/esm/error/error.mjs +154 -0
- package/dist/esm/error/index.mjs +3 -0
- package/dist/esm/error/transform.mjs +138 -0
- package/dist/esm/error/utils.mjs +22 -0
- package/dist/esm/index.mjs +3 -0
- package/dist/esm/logger.mjs +50 -0
- package/dist/esm/rule-utils/document/document.mjs +58 -0
- package/dist/esm/rule-utils/document/index.mjs +3 -0
- package/dist/esm/rule-utils/document/server.mjs +12 -0
- package/dist/esm/rule-utils/index.mjs +2 -0
- package/dist/esm/rule-utils/parser/asserts.mjs +104 -0
- package/dist/esm/rule-utils/parser/index.mjs +4 -0
- package/dist/esm/rule-utils/parser/parser.mjs +23 -0
- package/dist/esm/rule-utils/parser/types.mjs +7 -0
- package/dist/esm/rule-utils/parser/utils.mjs +109 -0
- package/dist/type/common/file.d.ts +3 -0
- package/dist/type/common/file.d.ts.map +1 -0
- package/dist/type/common/graph/modules.d.ts +1 -1
- package/dist/type/common/graph/modules.d.ts.map +1 -1
- package/dist/type/common/index.d.ts +1 -0
- package/dist/type/common/index.d.ts.map +1 -1
- package/dist/type/logger.d.ts +3 -1
- package/dist/type/logger.d.ts.map +1 -1
- package/package.json +13 -12
- package/dist/esm/build/envinfo.js +0 -75
- package/dist/esm/build/file/cache.js +0 -30
- package/dist/esm/build/file/index.js +0 -7
- package/dist/esm/build/file/sharding.js +0 -50
- package/dist/esm/build/index.js +0 -12
- package/dist/esm/build/json.js +0 -85
- package/dist/esm/build/process.js +0 -24
- package/dist/esm/build/server.js +0 -96
- package/dist/esm/common/alerts.js +0 -25
- package/dist/esm/common/algorithm.js +0 -39
- package/dist/esm/common/bundle.js +0 -30
- package/dist/esm/common/crypto.js +0 -28
- package/dist/esm/common/data/index.js +0 -428
- package/dist/esm/common/global-config.js +0 -38
- package/dist/esm/common/graph/assets.js +0 -310
- package/dist/esm/common/graph/chunk.js +0 -49
- package/dist/esm/common/graph/dependency.js +0 -14
- package/dist/esm/common/graph/entrypoints.js +0 -6
- package/dist/esm/common/graph/index.js +0 -5
- package/dist/esm/common/graph/modules.js +0 -90
- package/dist/esm/common/index.js +0 -36
- package/dist/esm/common/loader.js +0 -279
- package/dist/esm/common/lodash.js +0 -49
- package/dist/esm/common/manifest.js +0 -46
- package/dist/esm/common/package.js +0 -71
- package/dist/esm/common/plugin.js +0 -59
- package/dist/esm/common/resolver.js +0 -54
- package/dist/esm/common/rspack.js +0 -12
- package/dist/esm/common/summary.js +0 -10
- package/dist/esm/common/time.js +0 -64
- package/dist/esm/common/url.js +0 -20
- package/dist/esm/error/error.js +0 -202
- package/dist/esm/error/index.js +0 -5
- package/dist/esm/error/transform.js +0 -141
- package/dist/esm/error/utils.js +0 -40
- package/dist/esm/index.js +0 -6
- package/dist/esm/logger.js +0 -44
- package/dist/esm/rule-utils/document/document.js +0 -67
- package/dist/esm/rule-utils/document/index.js +0 -3
- package/dist/esm/rule-utils/document/server.js +0 -17
- package/dist/esm/rule-utils/index.js +0 -2
- package/dist/esm/rule-utils/parser/asserts.js +0 -132
- package/dist/esm/rule-utils/parser/index.js +0 -4
- package/dist/esm/rule-utils/parser/parser.js +0 -58
- package/dist/esm/rule-utils/parser/types.js +0 -9
- package/dist/esm/rule-utils/parser/utils.js +0 -164
- /package/dist/esm/rule-utils/document/{types.js → types.mjs} +0 -0
|
@@ -1,33 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
ECMAVersion: ()=>ECMAVersion
|
|
22
28
|
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
var ECMAVersion = /*#__PURE__*/ function(ECMAVersion) {
|
|
30
|
+
ECMAVersion["ES5"] = "ES5";
|
|
31
|
+
ECMAVersion["ES6"] = "ES6";
|
|
32
|
+
ECMAVersion["ES7P"] = "ES7+";
|
|
33
|
+
return ECMAVersion;
|
|
34
|
+
}({});
|
|
35
|
+
exports.ECMAVersion = __webpack_exports__.ECMAVersion;
|
|
36
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
37
|
+
"ECMAVersion"
|
|
38
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
39
|
+
Object.defineProperty(exports, '__esModule', {
|
|
40
|
+
value: true
|
|
33
41
|
});
|
|
@@ -1,197 +1,170 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
isES6: ()=>isES6,
|
|
28
|
+
getIdentifierInDeclaration: ()=>getIdentifierInDeclaration,
|
|
29
|
+
getIdentifierInExport: ()=>getIdentifierInExport,
|
|
30
|
+
isSameSemantics: ()=>isSameSemantics,
|
|
31
|
+
getIdentifierInImport: ()=>getIdentifierInImport,
|
|
32
|
+
canParse: ()=>canParse,
|
|
33
|
+
getIdentifierInPattern: ()=>getIdentifierInPattern,
|
|
34
|
+
getDefaultImports: ()=>getDefaultImports,
|
|
35
|
+
isES5: ()=>isES5,
|
|
36
|
+
detectECMAVersion: ()=>detectECMAVersion
|
|
31
37
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
var import_asserts = require("./asserts");
|
|
38
|
+
const external_acorn_namespaceObject = require("acorn");
|
|
39
|
+
const external_types_js_namespaceObject = require("./types.js");
|
|
40
|
+
const external_asserts_js_namespaceObject = require("./asserts.js");
|
|
36
41
|
function isSameSemantics(node1, node2) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
if (node1.type !== node2.type) return false;
|
|
43
|
+
switch(node1.type){
|
|
44
|
+
case 'CallExpression':
|
|
45
|
+
{
|
|
46
|
+
const next = node2;
|
|
47
|
+
return node1.arguments.length === next.arguments.length && Boolean(node1.optional) === Boolean(next.optional) && isSameSemantics(node1.callee, next.callee) && node1.arguments.every((node, i)=>isSameSemantics(node, next.arguments[i]));
|
|
48
|
+
}
|
|
49
|
+
case 'MemberExpression':
|
|
50
|
+
{
|
|
51
|
+
const next = node2;
|
|
52
|
+
return node1.computed === next.computed && Boolean(node1.optional) === Boolean(next.optional) && isSameSemantics(node1.object, next.object) && isSameSemantics(node1.property, next.property);
|
|
53
|
+
}
|
|
54
|
+
case 'Identifier':
|
|
55
|
+
return node1.name === node2.name;
|
|
56
|
+
case 'Literal':
|
|
57
|
+
if (external_asserts_js_namespaceObject.asserts.isSimpleLiteral(node1) && external_asserts_js_namespaceObject.asserts.isSimpleLiteral(node2)) return node1.value === node2.value;
|
|
58
|
+
return node1.raw === node2.raw;
|
|
59
|
+
case 'ObjectExpression':
|
|
60
|
+
{
|
|
61
|
+
const next = node2;
|
|
62
|
+
return node1.properties.length === next.properties.length && node1.properties.every((prop, i)=>isSameSemantics(prop, next.properties[i]));
|
|
63
|
+
}
|
|
64
|
+
case 'Property':
|
|
65
|
+
{
|
|
66
|
+
const next = node2;
|
|
67
|
+
return node1.computed === next.computed && node1.kind === next.kind && node1.method === next.method && isSameSemantics(node1.key, next.key) && isSameSemantics(node1.value, next.value);
|
|
68
|
+
}
|
|
69
|
+
default:
|
|
70
|
+
throw new Error(`Unknown node type: ${node1.type}`);
|
|
46
71
|
}
|
|
47
|
-
case "MemberExpression": {
|
|
48
|
-
const next = node2;
|
|
49
|
-
return node1.computed === next.computed && Boolean(node1.optional) === Boolean(next.optional) && isSameSemantics(node1.object, next.object) && isSameSemantics(node1.property, next.property);
|
|
50
|
-
}
|
|
51
|
-
case "Identifier": {
|
|
52
|
-
return node1.name === node2.name;
|
|
53
|
-
}
|
|
54
|
-
case "Literal": {
|
|
55
|
-
if (import_asserts.asserts.isSimpleLiteral(node1) && import_asserts.asserts.isSimpleLiteral(node2)) {
|
|
56
|
-
return node1.value === node2.value;
|
|
57
|
-
}
|
|
58
|
-
return node1.raw === node2.raw;
|
|
59
|
-
}
|
|
60
|
-
case "ObjectExpression": {
|
|
61
|
-
const next = node2;
|
|
62
|
-
return node1.properties.length === next.properties.length && node1.properties.every(
|
|
63
|
-
(prop, i) => isSameSemantics(prop, next.properties[i])
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
case "Property": {
|
|
67
|
-
const next = node2;
|
|
68
|
-
return node1.computed === next.computed && node1.kind === next.kind && node1.method === next.method && isSameSemantics(node1.key, next.key) && isSameSemantics(node1.value, next.value);
|
|
69
|
-
}
|
|
70
|
-
default: {
|
|
71
|
-
throw new Error(`Unknown node type: ${node1.type}`);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
72
|
}
|
|
75
73
|
function getDefaultImports(node) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
return false;
|
|
85
|
-
});
|
|
74
|
+
return node.body.filter((statement)=>{
|
|
75
|
+
var _statement_specifiers;
|
|
76
|
+
if ('ImportDeclaration' !== statement.type) return false;
|
|
77
|
+
const specifier = null == statement ? void 0 : null == (_statement_specifiers = statement.specifiers) ? void 0 : _statement_specifiers[0];
|
|
78
|
+
if ((null == specifier ? void 0 : specifier.type) === 'ImportDefaultSpecifier') return true;
|
|
79
|
+
return false;
|
|
80
|
+
});
|
|
86
81
|
}
|
|
87
82
|
function getIdentifierInPattern(name, node) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
for (const prop of node.properties) {
|
|
93
|
-
if (import_asserts.asserts.isAssignmentProperty(prop)) {
|
|
94
|
-
return getIdentifierInPattern(name, prop.value);
|
|
95
|
-
}
|
|
96
|
-
if (import_asserts.asserts.isRestElement(prop)) {
|
|
97
|
-
return getIdentifierInPattern(name, prop);
|
|
98
|
-
}
|
|
83
|
+
if (external_asserts_js_namespaceObject.asserts.isIdentifier(node) && node.name === name) return node;
|
|
84
|
+
if (external_asserts_js_namespaceObject.asserts.isObjectPattern(node)) for (const prop of node.properties){
|
|
85
|
+
if (external_asserts_js_namespaceObject.asserts.isAssignmentProperty(prop)) return getIdentifierInPattern(name, prop.value);
|
|
86
|
+
if (external_asserts_js_namespaceObject.asserts.isRestElement(prop)) return getIdentifierInPattern(name, prop);
|
|
99
87
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
const result = getIdentifierInPattern(name, el);
|
|
105
|
-
if (result) {
|
|
106
|
-
return result;
|
|
88
|
+
if (external_asserts_js_namespaceObject.asserts.isArrayPattern(node)) {
|
|
89
|
+
for (const el of node.elements)if (el) {
|
|
90
|
+
const result = getIdentifierInPattern(name, el);
|
|
91
|
+
if (result) return result;
|
|
107
92
|
}
|
|
108
|
-
}
|
|
109
93
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
return getIdentifierInPattern(name, node.argument);
|
|
113
|
-
}
|
|
114
|
-
if (import_asserts.asserts.isAssignmentPattern(node)) {
|
|
115
|
-
return getIdentifierInPattern(name, node.left);
|
|
116
|
-
}
|
|
94
|
+
if (external_asserts_js_namespaceObject.asserts.isRestElement(node)) return getIdentifierInPattern(name, node.argument);
|
|
95
|
+
if (external_asserts_js_namespaceObject.asserts.isAssignmentPattern(node)) return getIdentifierInPattern(name, node.left);
|
|
117
96
|
}
|
|
118
97
|
function getIdentifierInDeclaration(name, node) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
return getId(node);
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
if (import_asserts.asserts.isVariableDeclaration(node)) {
|
|
129
|
-
return node.declarations.find(
|
|
130
|
-
(item) => getIdentifierInPattern(name, item.id)
|
|
131
|
-
)?.id;
|
|
132
|
-
}
|
|
98
|
+
function getId(node) {
|
|
99
|
+
return external_asserts_js_namespaceObject.asserts.isIdentifier(node.id) && node.id.name === name ? node.id : void 0;
|
|
100
|
+
}
|
|
101
|
+
if (external_asserts_js_namespaceObject.asserts.isFunctionDeclaration(node)) return getId(node);
|
|
102
|
+
if (external_asserts_js_namespaceObject.asserts.isClassDeclaration(node)) return getId(node);
|
|
103
|
+
if (external_asserts_js_namespaceObject.asserts.isVariableDeclaration(node)) {
|
|
104
|
+
var _node_declarations_find;
|
|
105
|
+
return null == (_node_declarations_find = node.declarations.find((item)=>getIdentifierInPattern(name, item.id))) ? void 0 : _node_declarations_find.id;
|
|
106
|
+
}
|
|
133
107
|
}
|
|
134
108
|
function getIdentifierInImport(name, node) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
if (specifier.local.name === name) {
|
|
138
|
-
return specifier.local;
|
|
139
|
-
}
|
|
109
|
+
if (external_asserts_js_namespaceObject.asserts.isImportDeclaration(node)) {
|
|
110
|
+
for (const specifier of node.specifiers ?? [])if (specifier.local.name === name) return specifier.local;
|
|
140
111
|
}
|
|
141
|
-
}
|
|
142
112
|
}
|
|
143
113
|
function getIdentifierInExport(name, node) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
for (const specifier of node.specifiers ?? []) {
|
|
149
|
-
if (specifier.exported.name === name) {
|
|
150
|
-
return specifier.exported;
|
|
151
|
-
}
|
|
114
|
+
if (external_asserts_js_namespaceObject.asserts.isExportNamedDeclaration(node)) {
|
|
115
|
+
if (node.declaration) return getIdentifierInDeclaration(name, node.declaration);
|
|
116
|
+
for (const specifier of node.specifiers ?? [])if (specifier.exported.name === name) return specifier.exported;
|
|
152
117
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
if (node.exported.name === name) {
|
|
156
|
-
return node.exported;
|
|
118
|
+
if (external_asserts_js_namespaceObject.asserts.isExportAllDeclaration(node) && node.exported) {
|
|
119
|
+
if (node.exported.name === name) return node.exported;
|
|
157
120
|
}
|
|
158
|
-
}
|
|
159
121
|
}
|
|
160
|
-
function canParse(code,
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
122
|
+
function canParse(code, ecmaVersion) {
|
|
123
|
+
try {
|
|
124
|
+
(0, external_acorn_namespaceObject.parse)(code, {
|
|
125
|
+
ecmaVersion,
|
|
126
|
+
sourceType: 'number' == typeof ecmaVersion && ecmaVersion <= 5 ? "script" : 'module'
|
|
127
|
+
});
|
|
128
|
+
return true;
|
|
129
|
+
} catch (err) {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
170
132
|
}
|
|
171
133
|
function isES5(code) {
|
|
172
|
-
|
|
134
|
+
return canParse(code, 5);
|
|
173
135
|
}
|
|
174
136
|
function isES6(code) {
|
|
175
|
-
|
|
137
|
+
return canParse(code, 6);
|
|
176
138
|
}
|
|
177
139
|
function detectECMAVersion(code) {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
return import_types.ECMAVersion.ES7P;
|
|
140
|
+
if (isES6(code)) {
|
|
141
|
+
if (isES5(code)) return external_types_js_namespaceObject.ECMAVersion.ES5;
|
|
142
|
+
return external_types_js_namespaceObject.ECMAVersion.ES6;
|
|
143
|
+
}
|
|
144
|
+
return external_types_js_namespaceObject.ECMAVersion.ES7P;
|
|
184
145
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
146
|
+
exports.canParse = __webpack_exports__.canParse;
|
|
147
|
+
exports.detectECMAVersion = __webpack_exports__.detectECMAVersion;
|
|
148
|
+
exports.getDefaultImports = __webpack_exports__.getDefaultImports;
|
|
149
|
+
exports.getIdentifierInDeclaration = __webpack_exports__.getIdentifierInDeclaration;
|
|
150
|
+
exports.getIdentifierInExport = __webpack_exports__.getIdentifierInExport;
|
|
151
|
+
exports.getIdentifierInImport = __webpack_exports__.getIdentifierInImport;
|
|
152
|
+
exports.getIdentifierInPattern = __webpack_exports__.getIdentifierInPattern;
|
|
153
|
+
exports.isES5 = __webpack_exports__.isES5;
|
|
154
|
+
exports.isES6 = __webpack_exports__.isES6;
|
|
155
|
+
exports.isSameSemantics = __webpack_exports__.isSameSemantics;
|
|
156
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
157
|
+
"canParse",
|
|
158
|
+
"detectECMAVersion",
|
|
159
|
+
"getDefaultImports",
|
|
160
|
+
"getIdentifierInDeclaration",
|
|
161
|
+
"getIdentifierInExport",
|
|
162
|
+
"getIdentifierInImport",
|
|
163
|
+
"getIdentifierInPattern",
|
|
164
|
+
"isES5",
|
|
165
|
+
"isES6",
|
|
166
|
+
"isSameSemantics"
|
|
167
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
168
|
+
Object.defineProperty(exports, '__esModule', {
|
|
169
|
+
value: true
|
|
197
170
|
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { helpers, run } from "envinfo";
|
|
2
|
+
import { exec } from "child_process";
|
|
3
|
+
const getCPUInfo = ()=>helpers.getCPUInfo().then((res)=>res[1]);
|
|
4
|
+
const getOSInfo = ()=>helpers.getOSInfo().then((res)=>res[1]);
|
|
5
|
+
const getMemoryInfo = ()=>helpers.getMemoryInfo().then((res)=>res[1]);
|
|
6
|
+
const getNodeVersion = ()=>helpers.getNodeInfo().then((res)=>res[1]);
|
|
7
|
+
const getYarnVersion = ()=>helpers.getYarnInfo().then((res)=>res[1]);
|
|
8
|
+
const getNpmVersion = ()=>helpers.getnpmInfo().then((res)=>res[1]);
|
|
9
|
+
const getPnpmVersion = ()=>helpers.getpnpmInfo().then((res)=>res[1]);
|
|
10
|
+
function getNpmPackageVersion(pkg) {
|
|
11
|
+
const isArray = Array.isArray(pkg);
|
|
12
|
+
return run({
|
|
13
|
+
npmPackages: isArray ? pkg : [
|
|
14
|
+
pkg
|
|
15
|
+
]
|
|
16
|
+
}, {
|
|
17
|
+
json: true,
|
|
18
|
+
showNotFound: true
|
|
19
|
+
}).then((res)=>{
|
|
20
|
+
const { npmPackages = {} } = JSON.parse(res) || {};
|
|
21
|
+
return isArray ? pkg.map((e)=>npmPackages[e] || 'Not Found') : npmPackages[pkg];
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function getGlobalNpmPackageVersion(pkg) {
|
|
25
|
+
const isArray = Array.isArray(pkg);
|
|
26
|
+
return run({
|
|
27
|
+
npmGlobalPackages: isArray ? pkg : [
|
|
28
|
+
pkg
|
|
29
|
+
]
|
|
30
|
+
}, {
|
|
31
|
+
json: true,
|
|
32
|
+
showNotFound: true
|
|
33
|
+
}).then((res)=>{
|
|
34
|
+
const { npmGlobalPackages = {} } = JSON.parse(res) || {};
|
|
35
|
+
return isArray ? pkg.map((e)=>npmGlobalPackages[e] || 'Not Found') : npmGlobalPackages[pkg];
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function getGitBranch() {
|
|
39
|
+
return new Promise((resolve, reject)=>{
|
|
40
|
+
exec('git branch --show-current', (err, stdout)=>{
|
|
41
|
+
if (err) exec('git branch', (err, stdout)=>{
|
|
42
|
+
if (err) reject(err);
|
|
43
|
+
else resolve(stdout.split('\n').map((e)=>e.replace('* ', '')).join('').trim());
|
|
44
|
+
});
|
|
45
|
+
else resolve(stdout.trim());
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function getGitRepo() {
|
|
50
|
+
return new Promise((resolve, reject)=>{
|
|
51
|
+
exec('git config --get remote.origin.url', (err, stdout)=>{
|
|
52
|
+
if (err) reject(err);
|
|
53
|
+
else resolve(stdout.trim());
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
export { getCPUInfo, getGitBranch, getGitRepo, getGlobalNpmPackageVersion, getMemoryInfo, getNodeVersion, getNpmPackageVersion, getNpmVersion, getOSInfo, getPnpmVersion, getYarnVersion };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import fs_extra from "fs-extra";
|
|
2
|
+
const cache = new Map();
|
|
3
|
+
async function readFile(path) {
|
|
4
|
+
if (cache.has(path)) return cache.get(path);
|
|
5
|
+
const res = await fs_extra.readFile(path, 'utf-8');
|
|
6
|
+
cache.set(path, res);
|
|
7
|
+
return res;
|
|
8
|
+
}
|
|
9
|
+
function readFileSync(path) {
|
|
10
|
+
if (cache.has(path)) return cache.get(path);
|
|
11
|
+
const res = fs_extra.readFileSync(path, 'utf-8');
|
|
12
|
+
cache.set(path, res);
|
|
13
|
+
return res;
|
|
14
|
+
}
|
|
15
|
+
async function readJSON(path) {
|
|
16
|
+
const str = await readFile(path);
|
|
17
|
+
return JSON.parse(str);
|
|
18
|
+
}
|
|
19
|
+
function readJSONSync(path) {
|
|
20
|
+
const str = readFileSync(path);
|
|
21
|
+
return JSON.parse(str);
|
|
22
|
+
}
|
|
23
|
+
export { readFile, readFileSync, readJSON, readJSONSync };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export * from "./sharding.mjs";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_fs_extra_ce68a66b__ from "fs-extra";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE__cache_mjs_b6df9da1__ from "./cache.mjs";
|
|
4
|
+
export { __WEBPACK_EXTERNAL_MODULE__cache_mjs_b6df9da1__ as cache, __WEBPACK_EXTERNAL_MODULE_fs_extra_ce68a66b__ as fse };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import fs_extra from "fs-extra";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
function _define_property(obj, key, value) {
|
|
5
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
6
|
+
value: value,
|
|
7
|
+
enumerable: true,
|
|
8
|
+
configurable: true,
|
|
9
|
+
writable: true
|
|
10
|
+
});
|
|
11
|
+
else obj[key] = value;
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
class FileSharding {
|
|
15
|
+
createVirtualShardingFiles(ext = '', index = 0) {
|
|
16
|
+
const bf = Buffer.from(this.content, this.encoding);
|
|
17
|
+
const res = [];
|
|
18
|
+
const threshold = this.limitBytes;
|
|
19
|
+
let tmpBytes = 0;
|
|
20
|
+
while(bf.byteLength > tmpBytes){
|
|
21
|
+
res.push(bf.subarray(tmpBytes, tmpBytes + threshold));
|
|
22
|
+
tmpBytes += threshold;
|
|
23
|
+
}
|
|
24
|
+
return res.map((e, i)=>({
|
|
25
|
+
filename: `${i + index}${ext}`,
|
|
26
|
+
content: e
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
async writeStringToFolder(folder, ext = '', index) {
|
|
30
|
+
const dist = path.resolve(folder);
|
|
31
|
+
await fs_extra.ensureDir(dist);
|
|
32
|
+
const res = this.createVirtualShardingFiles(ext, index);
|
|
33
|
+
await Promise.all(res.map((e)=>new Promise((resolve, reject)=>{
|
|
34
|
+
const stream = fs.createWriteStream(path.join(dist, e.filename), this.encoding);
|
|
35
|
+
stream.end(e.content);
|
|
36
|
+
stream.once('close', ()=>resolve(void 0));
|
|
37
|
+
stream.once('error', (err)=>reject(err));
|
|
38
|
+
})));
|
|
39
|
+
return res;
|
|
40
|
+
}
|
|
41
|
+
constructor(content, limitBytes = 10485760, encoding = 'utf-8'){
|
|
42
|
+
_define_property(this, "content", void 0);
|
|
43
|
+
_define_property(this, "limitBytes", void 0);
|
|
44
|
+
_define_property(this, "encoding", void 0);
|
|
45
|
+
this.content = content;
|
|
46
|
+
this.limitBytes = limitBytes;
|
|
47
|
+
this.encoding = encoding;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export { FileSharding };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE__file_index_mjs_bb48710d__ from "./file/index.mjs";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE__json_mjs_4d5c7582__ from "./json.mjs";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE__server_mjs_d774bffd__ from "./server.mjs";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE__envinfo_mjs_e2a5d4a8__ from "./envinfo.mjs";
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE__process_mjs_2ae7d58e__ from "./process.mjs";
|
|
6
|
+
export { __WEBPACK_EXTERNAL_MODULE__envinfo_mjs_e2a5d4a8__ as EnvInfo, __WEBPACK_EXTERNAL_MODULE__file_index_mjs_bb48710d__ as File, __WEBPACK_EXTERNAL_MODULE__json_mjs_4d5c7582__ as Json, __WEBPACK_EXTERNAL_MODULE__process_mjs_2ae7d58e__ as Process, __WEBPACK_EXTERNAL_MODULE__server_mjs_d774bffd__ as Server };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { JsonStreamStringify } from "json-stream-stringify";
|
|
2
|
+
import { dirname, join } from "path";
|
|
3
|
+
import { Package } from "../common/index.mjs";
|
|
4
|
+
import { Transform } from "stream";
|
|
5
|
+
const maxFileSize = 419430400;
|
|
6
|
+
function stringify(json, replacer, space, cycle) {
|
|
7
|
+
const jsonList = [];
|
|
8
|
+
if (json && 'object' == typeof json) return new Promise((resolve, reject)=>{
|
|
9
|
+
const stream = new JsonStreamStringify(json, replacer, space, cycle);
|
|
10
|
+
let currentLength = 0;
|
|
11
|
+
let currentContent = '';
|
|
12
|
+
const batchProcessor = new Transform({
|
|
13
|
+
readableObjectMode: true,
|
|
14
|
+
transform (chunk, _encoding, callback) {
|
|
15
|
+
const lines = chunk.toString().split('\\n');
|
|
16
|
+
lines.forEach((line)=>{
|
|
17
|
+
if (currentLength + line.length > maxFileSize) {
|
|
18
|
+
jsonList.push(currentContent);
|
|
19
|
+
currentContent = '';
|
|
20
|
+
currentLength = 0;
|
|
21
|
+
}
|
|
22
|
+
if (line.length) {
|
|
23
|
+
currentContent += line;
|
|
24
|
+
currentLength += line.length;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
callback();
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
stream.pipe(batchProcessor).on('data', (line)=>{
|
|
31
|
+
if (currentLength + line.length > maxFileSize) {
|
|
32
|
+
jsonList.push(currentContent);
|
|
33
|
+
currentContent = '';
|
|
34
|
+
currentLength = 0;
|
|
35
|
+
}
|
|
36
|
+
if (line.length) {
|
|
37
|
+
currentContent += line;
|
|
38
|
+
currentLength += line.length;
|
|
39
|
+
}
|
|
40
|
+
}).on('end', ()=>{
|
|
41
|
+
if (jsonList.length < 1) jsonList.push(currentContent);
|
|
42
|
+
resolve(jsonList);
|
|
43
|
+
}).on('error', (err)=>reject(err));
|
|
44
|
+
});
|
|
45
|
+
return Promise.resolve(JSON.stringify(json, replacer, space));
|
|
46
|
+
}
|
|
47
|
+
const readPackageJson = (file, readFile)=>{
|
|
48
|
+
let result;
|
|
49
|
+
let current = file;
|
|
50
|
+
while('/' !== current && !result){
|
|
51
|
+
const parent = dirname(current);
|
|
52
|
+
if (parent === current) break;
|
|
53
|
+
current = parent;
|
|
54
|
+
if (readFile) result = readFile(join(current, 'package.json'));
|
|
55
|
+
if (readFile) {
|
|
56
|
+
if (!(null == result ? void 0 : result.name)) result = void 0;
|
|
57
|
+
} else result = Package.getPackageMetaFromModulePath(file);
|
|
58
|
+
}
|
|
59
|
+
if (!result) return;
|
|
60
|
+
if (readFile && (!result.name || !result.version)) return readPackageJson(dirname(current), readFile);
|
|
61
|
+
return {
|
|
62
|
+
...result,
|
|
63
|
+
root: current
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
export { readPackageJson, stringify };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { filesize } from "filesize";
|
|
2
|
+
import { memoryUsage, pid } from "process";
|
|
3
|
+
function getMemoryUsage() {
|
|
4
|
+
return memoryUsage();
|
|
5
|
+
}
|
|
6
|
+
function getMemoryUsageMessage() {
|
|
7
|
+
const usage = getMemoryUsage();
|
|
8
|
+
const msgs = [
|
|
9
|
+
`RSS: ${filesize(usage.rss)}`,
|
|
10
|
+
`Heap Total: ${filesize(usage.heapTotal)}`,
|
|
11
|
+
`Heap Used: ${filesize(usage.heapUsed)}`
|
|
12
|
+
];
|
|
13
|
+
if (usage.arrayBuffers) msgs.push(`ArrayBuffers: ${filesize(usage.arrayBuffers)}`);
|
|
14
|
+
if (usage.external) msgs.push(`External: ${filesize(usage.external)}`);
|
|
15
|
+
return `["${pid}" Memory Usage] ${msgs.join(', ')}`;
|
|
16
|
+
}
|
|
17
|
+
export { getMemoryUsage, getMemoryUsageMessage };
|