@rsdoctor/utils 1.2.2 → 1.2.4-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/compiled/connect/index.d.ts +90 -0
- package/compiled/connect/index.js +2427 -0
- package/compiled/connect/license +25 -0
- package/compiled/connect/package.json +1 -0
- package/compiled/filesize/index.d.ts +58 -0
- package/compiled/filesize/index.js +255 -0
- package/compiled/filesize/license +28 -0
- package/compiled/filesize/package.json +1 -0
- package/dist/{type/build → build}/envinfo.d.ts +0 -1
- package/dist/{type/build → build}/file/cache.d.ts +0 -1
- package/dist/build/file/index.d.ts +3 -0
- package/dist/{type/build → build}/file/sharding.d.ts +0 -1
- package/dist/{type/build → build}/index.d.ts +0 -1
- package/dist/{type/build → build}/json.d.ts +0 -1
- package/dist/{type/build → build}/process.d.ts +0 -1
- package/dist/{type/build → build}/server.d.ts +0 -1
- package/dist/build.cjs +1310 -0
- package/dist/build.js +343 -0
- package/dist/{type/common → common}/alerts.d.ts +0 -1
- package/dist/{type/common → common}/algorithm.d.ts +0 -1
- package/dist/{type/common → common}/bundle.d.ts +0 -1
- package/dist/{type/common → common}/crypto.d.ts +0 -1
- package/dist/{type/common → common}/data/index.d.ts +0 -1
- package/dist/{type/common → common}/file.d.ts +0 -1
- package/dist/{type/common → common}/global-config.d.ts +0 -1
- package/dist/{type/common → common}/graph/assets.d.ts +0 -1
- package/dist/{type/common → common}/graph/chunk.d.ts +0 -1
- package/dist/{type/common → common}/graph/dependency.d.ts +0 -1
- package/dist/{type/common → common}/graph/entrypoints.d.ts +0 -1
- package/dist/{type/common → common}/graph/index.d.ts +0 -1
- package/dist/{type/common → common}/graph/modules.d.ts +0 -1
- package/dist/{type/common → common}/index.d.ts +0 -1
- package/dist/{type/common → common}/loader.d.ts +0 -1
- package/dist/{type/common → common}/lodash.d.ts +0 -1
- package/dist/{type/common → common}/manifest.d.ts +0 -1
- package/dist/{type/common → common}/package.d.ts +0 -1
- package/dist/{type/common → common}/plugin.d.ts +0 -1
- package/dist/{type/common → common}/resolver.d.ts +0 -1
- package/dist/{type/common → common}/rspack.d.ts +0 -1
- package/dist/{type/common → common}/summary.d.ts +0 -1
- package/dist/{type/common → common}/time.d.ts +0 -1
- package/dist/{type/common → common}/url.d.ts +0 -1
- package/dist/common.cjs +1328 -0
- package/dist/common.js +1255 -0
- package/dist/{type/error → error}/error.d.ts +0 -1
- package/dist/{type/error → error}/index.d.ts +0 -1
- package/dist/{type/error → error}/transform.d.ts +0 -1
- package/dist/{type/error → error}/utils.d.ts +0 -1
- package/dist/error.cjs +310 -0
- package/dist/error.js +232 -0
- package/dist/logger.cjs +82 -0
- package/dist/{type/logger.d.ts → logger.d.ts} +0 -1
- package/dist/{esm/logger.mjs → logger.js} +8 -13
- package/dist/{type/rule-utils → rule-utils}/document/document.d.ts +0 -1
- package/dist/{type/rule-utils → rule-utils}/document/index.d.ts +0 -1
- package/dist/{type/rule-utils → rule-utils}/document/server.d.ts +0 -1
- package/dist/{type/rule-utils → rule-utils}/document/types.d.ts +0 -1
- package/dist/{type/rule-utils → rule-utils}/index.d.ts +0 -1
- package/dist/{type/rule-utils → rule-utils}/parser/asserts.d.ts +0 -1
- package/dist/{type/rule-utils → rule-utils}/parser/index.d.ts +0 -1
- package/dist/{type/rule-utils → rule-utils}/parser/parser.d.ts +0 -1
- package/dist/{type/rule-utils → rule-utils}/parser/types.d.ts +0 -1
- package/dist/{type/rule-utils → rule-utils}/parser/utils.d.ts +0 -1
- package/dist/ruleUtils.cjs +320 -0
- package/dist/ruleUtils.js +256 -0
- package/package.json +35 -39
- package/dist/cjs/build/envinfo.js +0 -121
- package/dist/cjs/build/file/cache.js +0 -76
- package/dist/cjs/build/file/index.js +0 -81
- package/dist/cjs/build/file/sharding.js +0 -96
- package/dist/cjs/build/index.js +0 -52
- package/dist/cjs/build/json.js +0 -103
- package/dist/cjs/build/process.js +0 -54
- package/dist/cjs/build/server.js +0 -158
- package/dist/cjs/common/alerts.js +0 -51
- package/dist/cjs/common/algorithm.js +0 -75
- package/dist/cjs/common/bundle.js +0 -62
- package/dist/cjs/common/crypto.js +0 -54
- package/dist/cjs/common/data/index.js +0 -396
- package/dist/cjs/common/file.js +0 -44
- package/dist/cjs/common/global-config.js +0 -81
- package/dist/cjs/common/graph/assets.js +0 -314
- package/dist/cjs/common/graph/chunk.js +0 -81
- package/dist/cjs/common/graph/dependency.js +0 -50
- package/dist/cjs/common/graph/entrypoints.js +0 -38
- package/dist/cjs/common/graph/index.js +0 -96
- package/dist/cjs/common/graph/modules.js +0 -133
- package/dist/cjs/common/index.js +0 -104
- package/dist/cjs/common/loader.js +0 -320
- package/dist/cjs/common/lodash.js +0 -93
- package/dist/cjs/common/manifest.js +0 -70
- package/dist/cjs/common/package.js +0 -96
- package/dist/cjs/common/plugin.js +0 -91
- package/dist/cjs/common/resolver.js +0 -92
- package/dist/cjs/common/rspack.js +0 -65
- package/dist/cjs/common/summary.js +0 -42
- package/dist/cjs/common/time.js +0 -86
- package/dist/cjs/common/url.js +0 -54
- package/dist/cjs/error/error.js +0 -199
- package/dist/cjs/error/index.js +0 -73
- package/dist/cjs/error/transform.js +0 -182
- package/dist/cjs/error/utils.js +0 -62
- package/dist/cjs/index.js +0 -40
- package/dist/cjs/logger.js +0 -106
- package/dist/cjs/rule-utils/document/document.js +0 -92
- package/dist/cjs/rule-utils/document/index.js +0 -78
- package/dist/cjs/rule-utils/document/server.js +0 -49
- package/dist/cjs/rule-utils/document/types.js +0 -18
- package/dist/cjs/rule-utils/index.js +0 -69
- package/dist/cjs/rule-utils/parser/asserts.js +0 -138
- package/dist/cjs/rule-utils/parser/index.js +0 -87
- package/dist/cjs/rule-utils/parser/parser.js +0 -57
- package/dist/cjs/rule-utils/parser/types.js +0 -41
- package/dist/cjs/rule-utils/parser/utils.js +0 -170
- package/dist/esm/build/envinfo.mjs +0 -57
- package/dist/esm/build/file/cache.mjs +0 -23
- package/dist/esm/build/file/index.mjs +0 -4
- package/dist/esm/build/file/sharding.mjs +0 -50
- package/dist/esm/build/index.mjs +0 -6
- package/dist/esm/build/json.mjs +0 -66
- package/dist/esm/build/process.mjs +0 -17
- package/dist/esm/build/server.mjs +0 -96
- package/dist/esm/common/alerts.mjs +0 -17
- package/dist/esm/common/algorithm.mjs +0 -32
- package/dist/esm/common/bundle.mjs +0 -22
- package/dist/esm/common/crypto.mjs +0 -17
- package/dist/esm/common/data/index.mjs +0 -362
- package/dist/esm/common/file.mjs +0 -7
- package/dist/esm/common/global-config.mjs +0 -32
- package/dist/esm/common/graph/assets.mjs +0 -238
- package/dist/esm/common/graph/chunk.mjs +0 -32
- package/dist/esm/common/graph/dependency.mjs +0 -10
- package/dist/esm/common/graph/entrypoints.mjs +0 -4
- package/dist/esm/common/graph/index.mjs +0 -5
- package/dist/esm/common/graph/modules.mjs +0 -78
- package/dist/esm/common/index.mjs +0 -19
- package/dist/esm/common/loader.mjs +0 -247
- package/dist/esm/common/lodash.mjs +0 -32
- package/dist/esm/common/manifest.mjs +0 -30
- package/dist/esm/common/package.mjs +0 -56
- package/dist/esm/common/plugin.mjs +0 -48
- package/dist/esm/common/resolver.mjs +0 -46
- package/dist/esm/common/rspack.mjs +0 -25
- package/dist/esm/common/summary.mjs +0 -8
- package/dist/esm/common/time.mjs +0 -43
- package/dist/esm/common/url.mjs +0 -14
- package/dist/esm/error/error.mjs +0 -154
- package/dist/esm/error/index.mjs +0 -3
- package/dist/esm/error/transform.mjs +0 -138
- package/dist/esm/error/utils.mjs +0 -22
- package/dist/esm/index.mjs +0 -3
- package/dist/esm/rule-utils/document/document.mjs +0 -58
- package/dist/esm/rule-utils/document/index.mjs +0 -3
- package/dist/esm/rule-utils/document/server.mjs +0 -12
- package/dist/esm/rule-utils/document/types.mjs +0 -0
- package/dist/esm/rule-utils/index.mjs +0 -2
- package/dist/esm/rule-utils/parser/asserts.mjs +0 -104
- package/dist/esm/rule-utils/parser/index.mjs +0 -4
- package/dist/esm/rule-utils/parser/parser.mjs +0 -23
- package/dist/esm/rule-utils/parser/types.mjs +0 -7
- package/dist/esm/rule-utils/parser/utils.mjs +0 -109
- package/dist/type/build/envinfo.d.ts.map +0 -1
- package/dist/type/build/file/cache.d.ts.map +0 -1
- package/dist/type/build/file/index.d.ts +0 -4
- package/dist/type/build/file/index.d.ts.map +0 -1
- package/dist/type/build/file/sharding.d.ts.map +0 -1
- package/dist/type/build/index.d.ts.map +0 -1
- package/dist/type/build/json.d.ts.map +0 -1
- package/dist/type/build/process.d.ts.map +0 -1
- package/dist/type/build/server.d.ts.map +0 -1
- package/dist/type/common/alerts.d.ts.map +0 -1
- package/dist/type/common/algorithm.d.ts.map +0 -1
- package/dist/type/common/bundle.d.ts.map +0 -1
- package/dist/type/common/crypto.d.ts.map +0 -1
- package/dist/type/common/data/index.d.ts.map +0 -1
- package/dist/type/common/file.d.ts.map +0 -1
- package/dist/type/common/global-config.d.ts.map +0 -1
- package/dist/type/common/graph/assets.d.ts.map +0 -1
- package/dist/type/common/graph/chunk.d.ts.map +0 -1
- package/dist/type/common/graph/dependency.d.ts.map +0 -1
- package/dist/type/common/graph/entrypoints.d.ts.map +0 -1
- package/dist/type/common/graph/index.d.ts.map +0 -1
- package/dist/type/common/graph/modules.d.ts.map +0 -1
- package/dist/type/common/index.d.ts.map +0 -1
- package/dist/type/common/loader.d.ts.map +0 -1
- package/dist/type/common/lodash.d.ts.map +0 -1
- package/dist/type/common/manifest.d.ts.map +0 -1
- package/dist/type/common/package.d.ts.map +0 -1
- package/dist/type/common/plugin.d.ts.map +0 -1
- package/dist/type/common/resolver.d.ts.map +0 -1
- package/dist/type/common/rspack.d.ts.map +0 -1
- package/dist/type/common/summary.d.ts.map +0 -1
- package/dist/type/common/time.d.ts.map +0 -1
- package/dist/type/common/url.d.ts.map +0 -1
- package/dist/type/error/error.d.ts.map +0 -1
- package/dist/type/error/index.d.ts.map +0 -1
- package/dist/type/error/transform.d.ts.map +0 -1
- package/dist/type/error/utils.d.ts.map +0 -1
- package/dist/type/index.d.ts +0 -3
- package/dist/type/index.d.ts.map +0 -1
- package/dist/type/logger.d.ts.map +0 -1
- package/dist/type/rule-utils/document/document.d.ts.map +0 -1
- package/dist/type/rule-utils/document/index.d.ts.map +0 -1
- package/dist/type/rule-utils/document/server.d.ts.map +0 -1
- package/dist/type/rule-utils/document/types.d.ts.map +0 -1
- package/dist/type/rule-utils/index.d.ts.map +0 -1
- package/dist/type/rule-utils/parser/asserts.d.ts.map +0 -1
- package/dist/type/rule-utils/parser/index.d.ts.map +0 -1
- package/dist/type/rule-utils/parser/parser.d.ts.map +0 -1
- package/dist/type/rule-utils/parser/types.d.ts.map +0 -1
- package/dist/type/rule-utils/parser/utils.d.ts.map +0 -1
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { LinesAndColumns } from "lines-and-columns";
|
|
2
|
+
import { Parser, parse } from "acorn";
|
|
3
|
+
import { importAttributes } from "acorn-import-attributes";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE_acorn_walk_9c3ac672__ from "acorn-walk";
|
|
5
|
+
var ECMAVersion, __webpack_require__ = {};
|
|
6
|
+
__webpack_require__.d = (exports, definition)=>{
|
|
7
|
+
for(var key in definition)__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key) && Object.defineProperty(exports, key, {
|
|
8
|
+
enumerable: !0,
|
|
9
|
+
get: definition[key]
|
|
10
|
+
});
|
|
11
|
+
}, __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop), __webpack_require__.r = (exports)=>{
|
|
12
|
+
'undefined' != typeof Symbol && Symbol.toStringTag && Object.defineProperty(exports, Symbol.toStringTag, {
|
|
13
|
+
value: 'Module'
|
|
14
|
+
}), Object.defineProperty(exports, '__esModule', {
|
|
15
|
+
value: !0
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
var utils_namespaceObject = {};
|
|
19
|
+
function isUndefined(value) {
|
|
20
|
+
return void 0 === value;
|
|
21
|
+
}
|
|
22
|
+
function isNumber(value) {
|
|
23
|
+
return 'number' == typeof value && !Number.isNaN(value);
|
|
24
|
+
}
|
|
25
|
+
__webpack_require__.r(utils_namespaceObject), __webpack_require__.d(utils_namespaceObject, {
|
|
26
|
+
canParse: ()=>canParse,
|
|
27
|
+
detectECMAVersion: ()=>detectECMAVersion,
|
|
28
|
+
getDefaultImports: ()=>getDefaultImports,
|
|
29
|
+
getIdentifierInDeclaration: ()=>getIdentifierInDeclaration,
|
|
30
|
+
getIdentifierInExport: ()=>getIdentifierInExport,
|
|
31
|
+
getIdentifierInImport: ()=>getIdentifierInImport,
|
|
32
|
+
getIdentifierInPattern: ()=>getIdentifierInPattern,
|
|
33
|
+
isES5: ()=>isES5,
|
|
34
|
+
isES6: ()=>isES6,
|
|
35
|
+
isSameSemantics: ()=>isSameSemantics
|
|
36
|
+
});
|
|
37
|
+
class Document {
|
|
38
|
+
_text = '';
|
|
39
|
+
positionAt;
|
|
40
|
+
offsetAt;
|
|
41
|
+
constructor(content){
|
|
42
|
+
this._text, this._text = content, this.createFinder();
|
|
43
|
+
}
|
|
44
|
+
createFinder() {
|
|
45
|
+
let find = new LinesAndColumns(this._text);
|
|
46
|
+
this.positionAt = (offset)=>{
|
|
47
|
+
offset >= this._text.length && (offset = this._text.length - 1), offset < 0 && (offset = 0);
|
|
48
|
+
let result = find.locationForIndex(offset);
|
|
49
|
+
if (result) return {
|
|
50
|
+
line: result.line + 1,
|
|
51
|
+
column: result.column
|
|
52
|
+
};
|
|
53
|
+
}, this.offsetAt = (position)=>find.indexForLocation({
|
|
54
|
+
line: position.line - 1,
|
|
55
|
+
column: position.column
|
|
56
|
+
}) ?? void 0;
|
|
57
|
+
}
|
|
58
|
+
getText(range) {
|
|
59
|
+
if (!range) return this._text;
|
|
60
|
+
let start = 'number' == typeof range.start ? range.start : this.offsetAt(range.start), end = 'number' == typeof range.end ? range.end : this.offsetAt(range.end);
|
|
61
|
+
if (isUndefined(start)) throw Error(`Location ${JSON.stringify(start)} is illegal`);
|
|
62
|
+
if (isUndefined(end)) throw Error(`Location ${JSON.stringify(end)} is illegal`);
|
|
63
|
+
return this._text.slice(start, end);
|
|
64
|
+
}
|
|
65
|
+
edit(data) {
|
|
66
|
+
let { _text: content } = this, startOffset = isNumber(data.start) ? data.start : this.offsetAt(data.start), endOffset = isNumber(data.end) ? data.end : this.offsetAt(data.end);
|
|
67
|
+
if (isUndefined(startOffset) || isUndefined(endOffset)) return;
|
|
68
|
+
let startTxt = content.substring(0, startOffset), endTxt = content.substring(endOffset, content.length);
|
|
69
|
+
return startTxt + data.newText + endTxt;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
let store = new Map();
|
|
73
|
+
function getDocument(content) {
|
|
74
|
+
if (store.has(content)) return store.get(content);
|
|
75
|
+
let doc = new Document(content);
|
|
76
|
+
return store.set(content, doc), doc;
|
|
77
|
+
}
|
|
78
|
+
function clearDocument() {
|
|
79
|
+
store.clear();
|
|
80
|
+
}
|
|
81
|
+
function isSyntaxNode(node) {
|
|
82
|
+
return 'object' == typeof node && null !== node && 'type' in node;
|
|
83
|
+
}
|
|
84
|
+
function assertCreator(type) {
|
|
85
|
+
return (node)=>isSyntaxNode(node) && node.type === type;
|
|
86
|
+
}
|
|
87
|
+
let asserts = {
|
|
88
|
+
isProgram: assertCreator('Program'),
|
|
89
|
+
isEmptyStatement: assertCreator('EmptyStatement'),
|
|
90
|
+
isBlockStatement: assertCreator('BlockStatement'),
|
|
91
|
+
isStaticBlock: assertCreator('StaticBlock'),
|
|
92
|
+
isExpressionStatement: assertCreator('ExpressionStatement'),
|
|
93
|
+
isIfStatement: assertCreator('IfStatement'),
|
|
94
|
+
isLabeledStatement: assertCreator('LabeledStatement'),
|
|
95
|
+
isBreakStatement: assertCreator('BreakStatement'),
|
|
96
|
+
isContinueStatement: assertCreator('ContinueStatement'),
|
|
97
|
+
isWithStatement: assertCreator('WithStatement'),
|
|
98
|
+
isSwitchStatement: assertCreator('SwitchStatement'),
|
|
99
|
+
isReturnStatement: assertCreator('ReturnStatement'),
|
|
100
|
+
isThrowStatement: assertCreator('ThrowStatement'),
|
|
101
|
+
isTryStatement: assertCreator('TryStatement'),
|
|
102
|
+
isWhileStatement: assertCreator('WhileStatement'),
|
|
103
|
+
isDoWhileStatement: assertCreator('DoWhileStatement'),
|
|
104
|
+
isForStatement: assertCreator('ForStatement'),
|
|
105
|
+
isForInStatement: assertCreator('ForInStatement'),
|
|
106
|
+
isForOfStatement: assertCreator('ForOfStatement'),
|
|
107
|
+
isDebuggerStatement: assertCreator('DebuggerStatement'),
|
|
108
|
+
isFunctionDeclaration: assertCreator('FunctionDeclaration'),
|
|
109
|
+
isVariableDeclaration: assertCreator('VariableDeclaration'),
|
|
110
|
+
isVariableDeclarator: assertCreator('VariableDeclarator'),
|
|
111
|
+
isChainExpression: assertCreator('ChainExpression'),
|
|
112
|
+
isThisExpression: assertCreator('ThisExpression'),
|
|
113
|
+
isArrayExpression: assertCreator('ArrayExpression'),
|
|
114
|
+
isObjectExpression: assertCreator('ObjectExpression'),
|
|
115
|
+
isPrivateIdentifier: assertCreator('PrivateIdentifier'),
|
|
116
|
+
isProperty: assertCreator('Property'),
|
|
117
|
+
isPropertyDefinition: assertCreator('PropertyDefinition'),
|
|
118
|
+
isFunctionExpression: assertCreator('FunctionExpression'),
|
|
119
|
+
isSequenceExpression: assertCreator('SequenceExpression'),
|
|
120
|
+
isUnaryExpression: assertCreator('UnaryExpression'),
|
|
121
|
+
isBinaryExpression: assertCreator('BinaryExpression'),
|
|
122
|
+
isAssignmentExpression: assertCreator('AssignmentExpression'),
|
|
123
|
+
isUpdateExpression: assertCreator('UpdateExpression'),
|
|
124
|
+
isLogicalExpression: assertCreator('LogicalExpression'),
|
|
125
|
+
isConditionalExpression: assertCreator('ConditionalExpression'),
|
|
126
|
+
isNewExpression: assertCreator('NewExpression'),
|
|
127
|
+
isSwitchCase: assertCreator('SwitchCase'),
|
|
128
|
+
isCatchClause: assertCreator('CatchClause'),
|
|
129
|
+
isIdentifier: assertCreator('Identifier'),
|
|
130
|
+
isLiteral: assertCreator('Literal'),
|
|
131
|
+
isSuper: assertCreator('Super'),
|
|
132
|
+
isSpreadElement: assertCreator('SpreadElement'),
|
|
133
|
+
isArrowFunctionExpression: assertCreator('ArrowFunctionExpression'),
|
|
134
|
+
isYieldExpression: assertCreator('YieldExpression'),
|
|
135
|
+
isTemplateLiteral: assertCreator('TemplateLiteral'),
|
|
136
|
+
isTaggedTemplateExpression: assertCreator('TaggedTemplateExpression'),
|
|
137
|
+
isTemplateElement: assertCreator('TemplateElement'),
|
|
138
|
+
isObjectPattern: assertCreator('ObjectPattern'),
|
|
139
|
+
isArrayPattern: assertCreator('ArrayPattern'),
|
|
140
|
+
isRestElement: assertCreator('RestElement'),
|
|
141
|
+
isAssignmentPattern: assertCreator('AssignmentPattern'),
|
|
142
|
+
isClassBody: assertCreator('ClassBody'),
|
|
143
|
+
isClassDeclaration: assertCreator('ClassDeclaration'),
|
|
144
|
+
isClassExpression: assertCreator('ClassExpression'),
|
|
145
|
+
isMetaProperty: assertCreator('MetaProperty'),
|
|
146
|
+
isImportDeclaration: assertCreator('ImportDeclaration'),
|
|
147
|
+
isImportSpecifier: assertCreator('ImportSpecifier'),
|
|
148
|
+
isImportExpression: assertCreator('ImportExpression'),
|
|
149
|
+
isImportDefaultSpecifier: assertCreator('ImportDefaultSpecifier'),
|
|
150
|
+
isImportNamespaceSpecifier: assertCreator('ImportNamespaceSpecifier'),
|
|
151
|
+
isExportNamedDeclaration: assertCreator('ExportNamedDeclaration'),
|
|
152
|
+
isExportSpecifier: assertCreator('ExportSpecifier'),
|
|
153
|
+
isExportDefaultDeclaration: assertCreator('ExportDefaultDeclaration'),
|
|
154
|
+
isExportAllDeclaration: assertCreator('ExportAllDeclaration'),
|
|
155
|
+
isAwaitExpression: assertCreator('AwaitExpression'),
|
|
156
|
+
isMethodDefinition: assertCreator('MethodDefinition'),
|
|
157
|
+
isMemberExpression: assertCreator('MemberExpression'),
|
|
158
|
+
isComment: (node)=>isSyntaxNode(node) && ('Line' === node.type || 'Block' === node.type),
|
|
159
|
+
isDirective: (node)=>asserts.isExpressionStatement(node) && 'directive' in node,
|
|
160
|
+
isSimpleCallExpression: (node)=>isSyntaxNode(node) && 'CallExpression' === node.type,
|
|
161
|
+
isAssignmentProperty: (node)=>asserts.isProperty(node) && 'init' === node.kind,
|
|
162
|
+
isSimpleLiteral: (node)=>asserts.isLiteral(node) && !asserts.isRegExpLiteral(node) && !asserts.isBigIntLiteral(node),
|
|
163
|
+
isRegExpLiteral: (node)=>asserts.isLiteral(node) && 'regex' in node,
|
|
164
|
+
isBigIntLiteral: (node)=>asserts.isLiteral(node) && 'bigint' in node,
|
|
165
|
+
isExportStatement: (node)=>asserts.isExportAllDeclaration(node) || asserts.isExportDefaultDeclaration(node) || asserts.isExportNamedDeclaration(node)
|
|
166
|
+
};
|
|
167
|
+
var types_ECMAVersion = ((ECMAVersion = {}).ES5 = "ES5", ECMAVersion.ES6 = "ES6", ECMAVersion.ES7P = "ES7+", ECMAVersion);
|
|
168
|
+
function isSameSemantics(node1, node2) {
|
|
169
|
+
if (node1.type !== node2.type) return !1;
|
|
170
|
+
switch(node1.type){
|
|
171
|
+
case 'CallExpression':
|
|
172
|
+
return node1.arguments.length === node2.arguments.length && !!node1.optional == !!node2.optional && isSameSemantics(node1.callee, node2.callee) && node1.arguments.every((node, i)=>isSameSemantics(node, node2.arguments[i]));
|
|
173
|
+
case 'MemberExpression':
|
|
174
|
+
return node1.computed === node2.computed && !!node1.optional == !!node2.optional && isSameSemantics(node1.object, node2.object) && isSameSemantics(node1.property, node2.property);
|
|
175
|
+
case 'Identifier':
|
|
176
|
+
return node1.name === node2.name;
|
|
177
|
+
case 'Literal':
|
|
178
|
+
if (asserts.isSimpleLiteral(node1) && asserts.isSimpleLiteral(node2)) return node1.value === node2.value;
|
|
179
|
+
return node1.raw === node2.raw;
|
|
180
|
+
case 'ObjectExpression':
|
|
181
|
+
return node1.properties.length === node2.properties.length && node1.properties.every((prop, i)=>isSameSemantics(prop, node2.properties[i]));
|
|
182
|
+
case 'Property':
|
|
183
|
+
return node1.computed === node2.computed && node1.kind === node2.kind && node1.method === node2.method && isSameSemantics(node1.key, node2.key) && isSameSemantics(node1.value, node2.value);
|
|
184
|
+
default:
|
|
185
|
+
throw Error(`Unknown node type: ${node1.type}`);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
function getDefaultImports(node) {
|
|
189
|
+
return node.body.filter((statement)=>{
|
|
190
|
+
if ('ImportDeclaration' !== statement.type) return !1;
|
|
191
|
+
let specifier = statement?.specifiers?.[0];
|
|
192
|
+
return specifier?.type === 'ImportDefaultSpecifier';
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
function getIdentifierInPattern(name, node) {
|
|
196
|
+
if (asserts.isIdentifier(node) && node.name === name) return node;
|
|
197
|
+
if (asserts.isObjectPattern(node)) for (let prop of node.properties){
|
|
198
|
+
if (asserts.isAssignmentProperty(prop)) return getIdentifierInPattern(name, prop.value);
|
|
199
|
+
if (asserts.isRestElement(prop)) return getIdentifierInPattern(name, prop);
|
|
200
|
+
}
|
|
201
|
+
if (asserts.isArrayPattern(node)) {
|
|
202
|
+
for (let el of node.elements)if (el) {
|
|
203
|
+
let result = getIdentifierInPattern(name, el);
|
|
204
|
+
if (result) return result;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return asserts.isRestElement(node) ? getIdentifierInPattern(name, node.argument) : asserts.isAssignmentPattern(node) ? getIdentifierInPattern(name, node.left) : void 0;
|
|
208
|
+
}
|
|
209
|
+
function getIdentifierInDeclaration(name, node) {
|
|
210
|
+
var node1;
|
|
211
|
+
return asserts.isFunctionDeclaration(node) || asserts.isClassDeclaration(node) ? (node1 = node, asserts.isIdentifier(node1.id) && node1.id.name === name ? node1.id : void 0) : asserts.isVariableDeclaration(node) ? node.declarations.find((item)=>getIdentifierInPattern(name, item.id))?.id : void 0;
|
|
212
|
+
}
|
|
213
|
+
function getIdentifierInImport(name, node) {
|
|
214
|
+
if (asserts.isImportDeclaration(node)) {
|
|
215
|
+
for (let specifier of node.specifiers ?? [])if (specifier.local.name === name) return specifier.local;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
function getIdentifierInExport(name, node) {
|
|
219
|
+
if (asserts.isExportNamedDeclaration(node)) {
|
|
220
|
+
if (node.declaration) return getIdentifierInDeclaration(name, node.declaration);
|
|
221
|
+
for (let specifier of node.specifiers ?? [])if (specifier.exported.name === name) return specifier.exported;
|
|
222
|
+
}
|
|
223
|
+
if (asserts.isExportAllDeclaration(node) && node.exported && node.exported.name === name) return node.exported;
|
|
224
|
+
}
|
|
225
|
+
function canParse(code, ecmaVersion) {
|
|
226
|
+
try {
|
|
227
|
+
return parse(code, {
|
|
228
|
+
ecmaVersion,
|
|
229
|
+
sourceType: 'number' == typeof ecmaVersion && ecmaVersion <= 5 ? "script" : 'module'
|
|
230
|
+
}), !0;
|
|
231
|
+
} catch (err) {
|
|
232
|
+
return !1;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
function isES5(code) {
|
|
236
|
+
return canParse(code, 5);
|
|
237
|
+
}
|
|
238
|
+
function isES6(code) {
|
|
239
|
+
return canParse(code, 6);
|
|
240
|
+
}
|
|
241
|
+
function detectECMAVersion(code) {
|
|
242
|
+
return isES6(code) ? isES5(code) ? types_ECMAVersion.ES5 : types_ECMAVersion.ES6 : types_ECMAVersion.ES7P;
|
|
243
|
+
}
|
|
244
|
+
let acornParserInternal = Parser.extend(importAttributes), acornParserExport = Parser.extend(importAttributes), parser = {
|
|
245
|
+
walk: __WEBPACK_EXTERNAL_MODULE_acorn_walk_9c3ac672__,
|
|
246
|
+
parse: (input, options)=>acornParserExport.parse(input, options),
|
|
247
|
+
parseExpressionAt: (input, pos, options)=>acornParserExport.parseExpressionAt(input, pos, options),
|
|
248
|
+
extend: (...args)=>acornParserExport = acornParserExport.extend(...args),
|
|
249
|
+
asserts: asserts,
|
|
250
|
+
utils: utils_namespaceObject,
|
|
251
|
+
internal: {
|
|
252
|
+
parse: (input, options)=>acornParserInternal.parse(input, options),
|
|
253
|
+
parseExpressionAt: (input, pos, options)=>acornParserInternal.parseExpressionAt(input, pos, options)
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
export { Document, types_ECMAVersion as ECMAVersion, asserts, canParse, clearDocument, detectECMAVersion, getDefaultImports, getDocument, getIdentifierInDeclaration, getIdentifierInExport, getIdentifierInImport, getIdentifierInPattern, isES5, isES6, isSameSemantics, parser };
|
package/package.json
CHANGED
|
@@ -1,70 +1,65 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsdoctor/utils",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4-beta.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/web-infra-dev/rsdoctor",
|
|
7
7
|
"directory": "packages/utils"
|
|
8
8
|
},
|
|
9
|
+
"type": "module",
|
|
9
10
|
"license": "MIT",
|
|
10
11
|
"exports": {
|
|
11
|
-
".": {
|
|
12
|
-
"types": "./dist/type/index.d.ts",
|
|
13
|
-
"require": "./dist/cjs/index.js",
|
|
14
|
-
"import": "./dist/esm/index.mjs"
|
|
15
|
-
},
|
|
16
12
|
"./common": {
|
|
17
|
-
"types": "./dist/
|
|
18
|
-
"
|
|
19
|
-
"
|
|
13
|
+
"types": "./dist/common/index.d.ts",
|
|
14
|
+
"import": "./dist/common.js",
|
|
15
|
+
"default": "./dist/common.cjs"
|
|
20
16
|
},
|
|
21
17
|
"./build": {
|
|
22
|
-
"types": "./dist/
|
|
23
|
-
"
|
|
24
|
-
"
|
|
18
|
+
"types": "./dist/build/index.d.ts",
|
|
19
|
+
"import": "./dist/build.js",
|
|
20
|
+
"default": "./dist/build.cjs"
|
|
25
21
|
},
|
|
26
22
|
"./error": {
|
|
27
|
-
"types": "./dist/
|
|
28
|
-
"
|
|
29
|
-
"
|
|
23
|
+
"types": "./dist/error/index.d.ts",
|
|
24
|
+
"import": "./dist/error.js",
|
|
25
|
+
"default": "./dist/error.cjs"
|
|
30
26
|
},
|
|
31
27
|
"./ruleUtils": {
|
|
32
|
-
"types": "./dist/
|
|
33
|
-
"
|
|
34
|
-
"
|
|
28
|
+
"types": "./dist/rule-utils/index.d.ts",
|
|
29
|
+
"import": "./dist/ruleUtils.js",
|
|
30
|
+
"default": "./dist/ruleUtils.cjs"
|
|
35
31
|
},
|
|
36
32
|
"./logger": {
|
|
37
|
-
"types": "./dist/
|
|
38
|
-
"
|
|
39
|
-
"
|
|
33
|
+
"types": "./dist/logger.d.ts",
|
|
34
|
+
"import": "./dist/logger.js",
|
|
35
|
+
"default": "./dist/logger.cjs"
|
|
40
36
|
}
|
|
41
37
|
},
|
|
42
38
|
"typesVersions": {
|
|
43
39
|
"*": {
|
|
44
|
-
".": [
|
|
45
|
-
"./dist/type/index.d.ts"
|
|
46
|
-
],
|
|
47
40
|
"common": [
|
|
48
|
-
"./dist/
|
|
41
|
+
"./dist/common/index.d.ts"
|
|
49
42
|
],
|
|
50
43
|
"build": [
|
|
51
|
-
"./dist/
|
|
44
|
+
"./dist/build/index.d.ts"
|
|
52
45
|
],
|
|
53
46
|
"error": [
|
|
54
|
-
"./dist/
|
|
47
|
+
"./dist/error/index.d.ts"
|
|
55
48
|
],
|
|
56
49
|
"ruleUtils": [
|
|
57
|
-
"./dist/
|
|
50
|
+
"./dist/rule-utils/index.d.ts"
|
|
58
51
|
],
|
|
59
52
|
"logger": [
|
|
60
|
-
"./dist/
|
|
53
|
+
"./dist/logger.d.ts"
|
|
61
54
|
]
|
|
62
55
|
}
|
|
63
56
|
},
|
|
64
|
-
"main": "dist/
|
|
65
|
-
"
|
|
57
|
+
"main": "dist/build.cjs",
|
|
58
|
+
"module": "dist/build.js",
|
|
59
|
+
"types": "dist/build/index.d.ts",
|
|
66
60
|
"files": [
|
|
67
|
-
"dist"
|
|
61
|
+
"dist",
|
|
62
|
+
"compiled"
|
|
68
63
|
],
|
|
69
64
|
"dependencies": {
|
|
70
65
|
"@babel/code-frame": "7.26.2",
|
|
@@ -72,10 +67,8 @@
|
|
|
72
67
|
"acorn": "^8.10.0",
|
|
73
68
|
"acorn-import-attributes": "^1.9.5",
|
|
74
69
|
"acorn-walk": "8.3.4",
|
|
75
|
-
"connect": "3.7.0",
|
|
76
70
|
"deep-eql": "4.1.4",
|
|
77
71
|
"envinfo": "7.14.0",
|
|
78
|
-
"filesize": "^10.1.6",
|
|
79
72
|
"fs-extra": "^11.1.1",
|
|
80
73
|
"get-port": "5.1.1",
|
|
81
74
|
"json-stream-stringify": "3.0.1",
|
|
@@ -83,27 +76,30 @@
|
|
|
83
76
|
"picocolors": "^1.1.1",
|
|
84
77
|
"rslog": "^1.2.9",
|
|
85
78
|
"strip-ansi": "^6.0.1",
|
|
86
|
-
"@rsdoctor/types": "1.2.
|
|
79
|
+
"@rsdoctor/types": "1.2.4-beta.0"
|
|
87
80
|
},
|
|
88
81
|
"devDependencies": {
|
|
89
|
-
"@rslib/core": "^0.11.0",
|
|
90
82
|
"@types/babel__code-frame": "7.0.6",
|
|
91
83
|
"@types/connect": "3.4.38",
|
|
92
84
|
"@types/deep-eql": "4.0.2",
|
|
93
85
|
"@types/envinfo": "7.8.4",
|
|
94
86
|
"@types/fs-extra": "^11.0.4",
|
|
95
87
|
"@types/node": "^22.8.1",
|
|
88
|
+
"prebundle": "1.4.1",
|
|
89
|
+
"filesize": "^10.1.6",
|
|
90
|
+
"connect": "3.7.0",
|
|
96
91
|
"tslib": "2.8.1",
|
|
97
|
-
"typescript": "^5.
|
|
92
|
+
"typescript": "^5.9.2"
|
|
98
93
|
},
|
|
99
94
|
"publishConfig": {
|
|
100
95
|
"access": "public",
|
|
101
96
|
"registry": "https://registry.npmjs.org/"
|
|
102
97
|
},
|
|
103
98
|
"scripts": {
|
|
104
|
-
"build": "rslib build",
|
|
99
|
+
"build": "npm run prebundle && rslib build",
|
|
105
100
|
"dev": "npm run start",
|
|
106
101
|
"start": "rslib build -w",
|
|
107
|
-
"test": "rstest run"
|
|
102
|
+
"test": "rstest run",
|
|
103
|
+
"prebundle": "prebundle"
|
|
108
104
|
}
|
|
109
105
|
}
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
-
getYarnVersion: ()=>getYarnVersion,
|
|
28
|
-
getNpmVersion: ()=>getNpmVersion,
|
|
29
|
-
getMemoryInfo: ()=>getMemoryInfo,
|
|
30
|
-
getNodeVersion: ()=>getNodeVersion,
|
|
31
|
-
getNpmPackageVersion: ()=>getNpmPackageVersion,
|
|
32
|
-
getGlobalNpmPackageVersion: ()=>getGlobalNpmPackageVersion,
|
|
33
|
-
getOSInfo: ()=>getOSInfo,
|
|
34
|
-
getPnpmVersion: ()=>getPnpmVersion,
|
|
35
|
-
getGitBranch: ()=>getGitBranch,
|
|
36
|
-
getGitRepo: ()=>getGitRepo,
|
|
37
|
-
getCPUInfo: ()=>getCPUInfo
|
|
38
|
-
});
|
|
39
|
-
const external_envinfo_namespaceObject = require("envinfo");
|
|
40
|
-
const external_child_process_namespaceObject = require("child_process");
|
|
41
|
-
const getCPUInfo = ()=>external_envinfo_namespaceObject.helpers.getCPUInfo().then((res)=>res[1]);
|
|
42
|
-
const getOSInfo = ()=>external_envinfo_namespaceObject.helpers.getOSInfo().then((res)=>res[1]);
|
|
43
|
-
const getMemoryInfo = ()=>external_envinfo_namespaceObject.helpers.getMemoryInfo().then((res)=>res[1]);
|
|
44
|
-
const getNodeVersion = ()=>external_envinfo_namespaceObject.helpers.getNodeInfo().then((res)=>res[1]);
|
|
45
|
-
const getYarnVersion = ()=>external_envinfo_namespaceObject.helpers.getYarnInfo().then((res)=>res[1]);
|
|
46
|
-
const getNpmVersion = ()=>external_envinfo_namespaceObject.helpers.getnpmInfo().then((res)=>res[1]);
|
|
47
|
-
const getPnpmVersion = ()=>external_envinfo_namespaceObject.helpers.getpnpmInfo().then((res)=>res[1]);
|
|
48
|
-
function getNpmPackageVersion(pkg) {
|
|
49
|
-
const isArray = Array.isArray(pkg);
|
|
50
|
-
return (0, external_envinfo_namespaceObject.run)({
|
|
51
|
-
npmPackages: isArray ? pkg : [
|
|
52
|
-
pkg
|
|
53
|
-
]
|
|
54
|
-
}, {
|
|
55
|
-
json: true,
|
|
56
|
-
showNotFound: true
|
|
57
|
-
}).then((res)=>{
|
|
58
|
-
const { npmPackages = {} } = JSON.parse(res) || {};
|
|
59
|
-
return isArray ? pkg.map((e)=>npmPackages[e] || 'Not Found') : npmPackages[pkg];
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
function getGlobalNpmPackageVersion(pkg) {
|
|
63
|
-
const isArray = Array.isArray(pkg);
|
|
64
|
-
return (0, external_envinfo_namespaceObject.run)({
|
|
65
|
-
npmGlobalPackages: isArray ? pkg : [
|
|
66
|
-
pkg
|
|
67
|
-
]
|
|
68
|
-
}, {
|
|
69
|
-
json: true,
|
|
70
|
-
showNotFound: true
|
|
71
|
-
}).then((res)=>{
|
|
72
|
-
const { npmGlobalPackages = {} } = JSON.parse(res) || {};
|
|
73
|
-
return isArray ? pkg.map((e)=>npmGlobalPackages[e] || 'Not Found') : npmGlobalPackages[pkg];
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
function getGitBranch() {
|
|
77
|
-
return new Promise((resolve, reject)=>{
|
|
78
|
-
(0, external_child_process_namespaceObject.exec)('git branch --show-current', (err, stdout)=>{
|
|
79
|
-
if (err) (0, external_child_process_namespaceObject.exec)('git branch', (err, stdout)=>{
|
|
80
|
-
if (err) reject(err);
|
|
81
|
-
else resolve(stdout.split('\n').map((e)=>e.replace('* ', '')).join('').trim());
|
|
82
|
-
});
|
|
83
|
-
else resolve(stdout.trim());
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
function getGitRepo() {
|
|
88
|
-
return new Promise((resolve, reject)=>{
|
|
89
|
-
(0, external_child_process_namespaceObject.exec)('git config --get remote.origin.url', (err, stdout)=>{
|
|
90
|
-
if (err) reject(err);
|
|
91
|
-
else resolve(stdout.trim());
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
exports.getCPUInfo = __webpack_exports__.getCPUInfo;
|
|
96
|
-
exports.getGitBranch = __webpack_exports__.getGitBranch;
|
|
97
|
-
exports.getGitRepo = __webpack_exports__.getGitRepo;
|
|
98
|
-
exports.getGlobalNpmPackageVersion = __webpack_exports__.getGlobalNpmPackageVersion;
|
|
99
|
-
exports.getMemoryInfo = __webpack_exports__.getMemoryInfo;
|
|
100
|
-
exports.getNodeVersion = __webpack_exports__.getNodeVersion;
|
|
101
|
-
exports.getNpmPackageVersion = __webpack_exports__.getNpmPackageVersion;
|
|
102
|
-
exports.getNpmVersion = __webpack_exports__.getNpmVersion;
|
|
103
|
-
exports.getOSInfo = __webpack_exports__.getOSInfo;
|
|
104
|
-
exports.getPnpmVersion = __webpack_exports__.getPnpmVersion;
|
|
105
|
-
exports.getYarnVersion = __webpack_exports__.getYarnVersion;
|
|
106
|
-
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
107
|
-
"getCPUInfo",
|
|
108
|
-
"getGitBranch",
|
|
109
|
-
"getGitRepo",
|
|
110
|
-
"getGlobalNpmPackageVersion",
|
|
111
|
-
"getMemoryInfo",
|
|
112
|
-
"getNodeVersion",
|
|
113
|
-
"getNpmPackageVersion",
|
|
114
|
-
"getNpmVersion",
|
|
115
|
-
"getOSInfo",
|
|
116
|
-
"getPnpmVersion",
|
|
117
|
-
"getYarnVersion"
|
|
118
|
-
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
119
|
-
Object.defineProperty(exports, '__esModule', {
|
|
120
|
-
value: true
|
|
121
|
-
});
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.n = (module)=>{
|
|
5
|
-
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
-
__webpack_require__.d(getter, {
|
|
7
|
-
a: getter
|
|
8
|
-
});
|
|
9
|
-
return getter;
|
|
10
|
-
};
|
|
11
|
-
})();
|
|
12
|
-
(()=>{
|
|
13
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: definition[key]
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
})();
|
|
20
|
-
(()=>{
|
|
21
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
-
})();
|
|
23
|
-
(()=>{
|
|
24
|
-
__webpack_require__.r = (exports1)=>{
|
|
25
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
-
value: 'Module'
|
|
27
|
-
});
|
|
28
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
-
value: true
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
})();
|
|
33
|
-
var __webpack_exports__ = {};
|
|
34
|
-
__webpack_require__.r(__webpack_exports__);
|
|
35
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
-
readJSONSync: ()=>readJSONSync,
|
|
37
|
-
readFile: ()=>readFile,
|
|
38
|
-
readFileSync: ()=>readFileSync,
|
|
39
|
-
readJSON: ()=>readJSON
|
|
40
|
-
});
|
|
41
|
-
const external_fs_extra_namespaceObject = require("fs-extra");
|
|
42
|
-
var external_fs_extra_default = /*#__PURE__*/ __webpack_require__.n(external_fs_extra_namespaceObject);
|
|
43
|
-
const cache = new Map();
|
|
44
|
-
async function readFile(path) {
|
|
45
|
-
if (cache.has(path)) return cache.get(path);
|
|
46
|
-
const res = await external_fs_extra_default().readFile(path, 'utf-8');
|
|
47
|
-
cache.set(path, res);
|
|
48
|
-
return res;
|
|
49
|
-
}
|
|
50
|
-
function readFileSync(path) {
|
|
51
|
-
if (cache.has(path)) return cache.get(path);
|
|
52
|
-
const res = external_fs_extra_default().readFileSync(path, 'utf-8');
|
|
53
|
-
cache.set(path, res);
|
|
54
|
-
return res;
|
|
55
|
-
}
|
|
56
|
-
async function readJSON(path) {
|
|
57
|
-
const str = await readFile(path);
|
|
58
|
-
return JSON.parse(str);
|
|
59
|
-
}
|
|
60
|
-
function readJSONSync(path) {
|
|
61
|
-
const str = readFileSync(path);
|
|
62
|
-
return JSON.parse(str);
|
|
63
|
-
}
|
|
64
|
-
exports.readFile = __webpack_exports__.readFile;
|
|
65
|
-
exports.readFileSync = __webpack_exports__.readFileSync;
|
|
66
|
-
exports.readJSON = __webpack_exports__.readJSON;
|
|
67
|
-
exports.readJSONSync = __webpack_exports__.readJSONSync;
|
|
68
|
-
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
69
|
-
"readFile",
|
|
70
|
-
"readFileSync",
|
|
71
|
-
"readJSON",
|
|
72
|
-
"readJSONSync"
|
|
73
|
-
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
74
|
-
Object.defineProperty(exports, '__esModule', {
|
|
75
|
-
value: true
|
|
76
|
-
});
|