@rsdoctor/utils 1.1.9 → 1.2.0-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.
Files changed (151) hide show
  1. package/dist/cjs/build/envinfo.js +107 -95
  2. package/dist/cjs/build/file/cache.js +65 -56
  3. package/dist/cjs/build/file/index.js +78 -41
  4. package/dist/cjs/build/file/sharding.js +90 -78
  5. package/dist/cjs/build/index.js +49 -47
  6. package/dist/cjs/build/json.js +91 -98
  7. package/dist/cjs/build/process.js +47 -42
  8. package/dist/cjs/build/server.js +110 -87
  9. package/dist/cjs/common/alerts.js +46 -44
  10. package/dist/cjs/common/algorithm.js +63 -54
  11. package/dist/cjs/common/bundle.js +52 -46
  12. package/dist/cjs/common/crypto.js +47 -46
  13. package/dist/cjs/common/data/index.js +381 -455
  14. package/dist/cjs/common/file.js +44 -0
  15. package/dist/cjs/common/global-config.js +72 -64
  16. package/dist/cjs/common/graph/assets.js +274 -308
  17. package/dist/cjs/common/graph/chunk.js +66 -63
  18. package/dist/cjs/common/graph/dependency.js +42 -32
  19. package/dist/cjs/common/graph/entrypoints.js +33 -25
  20. package/dist/cjs/common/graph/index.js +93 -27
  21. package/dist/cjs/common/graph/modules.js +113 -98
  22. package/dist/cjs/common/index.js +101 -83
  23. package/dist/cjs/common/loader.js +277 -273
  24. package/dist/cjs/common/lodash.js +73 -62
  25. package/dist/cjs/common/manifest.js +57 -59
  26. package/dist/cjs/common/package.js +79 -80
  27. package/dist/cjs/common/plugin.js +78 -73
  28. package/dist/cjs/common/resolver.js +79 -69
  29. package/dist/cjs/common/rspack.js +43 -34
  30. package/dist/cjs/common/summary.js +39 -31
  31. package/dist/cjs/common/time.js +73 -78
  32. package/dist/cjs/common/url.js +44 -36
  33. package/dist/cjs/error/error.js +183 -220
  34. package/dist/cjs/error/index.js +70 -28
  35. package/dist/cjs/error/transform.js +150 -143
  36. package/dist/cjs/error/utils.js +54 -58
  37. package/dist/cjs/index.js +37 -38
  38. package/dist/cjs/logger.js +99 -73
  39. package/dist/cjs/rule-utils/document/document.js +83 -82
  40. package/dist/cjs/rule-utils/document/index.js +75 -23
  41. package/dist/cjs/rule-utils/document/server.js +42 -35
  42. package/dist/cjs/rule-utils/document/types.js +17 -15
  43. package/dist/cjs/rule-utils/index.js +66 -21
  44. package/dist/cjs/rule-utils/parser/asserts.js +129 -147
  45. package/dist/cjs/rule-utils/parser/index.js +84 -25
  46. package/dist/cjs/rule-utils/parser/parser.js +50 -85
  47. package/dist/cjs/rule-utils/parser/types.js +38 -30
  48. package/dist/cjs/rule-utils/parser/utils.js +141 -168
  49. package/dist/esm/build/envinfo.mjs +57 -0
  50. package/dist/esm/build/file/cache.mjs +23 -0
  51. package/dist/esm/build/file/index.mjs +4 -0
  52. package/dist/esm/build/file/sharding.mjs +50 -0
  53. package/dist/esm/build/index.mjs +6 -0
  54. package/dist/esm/build/json.mjs +66 -0
  55. package/dist/esm/build/process.mjs +17 -0
  56. package/dist/esm/build/server.mjs +96 -0
  57. package/dist/esm/common/alerts.mjs +17 -0
  58. package/dist/esm/common/algorithm.mjs +32 -0
  59. package/dist/esm/common/bundle.mjs +22 -0
  60. package/dist/esm/common/crypto.mjs +17 -0
  61. package/dist/esm/common/data/index.mjs +354 -0
  62. package/dist/esm/common/file.mjs +7 -0
  63. package/dist/esm/common/global-config.mjs +32 -0
  64. package/dist/esm/common/graph/assets.mjs +238 -0
  65. package/dist/esm/common/graph/chunk.mjs +32 -0
  66. package/dist/esm/common/graph/dependency.mjs +10 -0
  67. package/dist/esm/common/graph/entrypoints.mjs +4 -0
  68. package/dist/esm/common/graph/index.mjs +5 -0
  69. package/dist/esm/common/graph/modules.mjs +78 -0
  70. package/dist/esm/common/index.mjs +19 -0
  71. package/dist/esm/common/loader.mjs +247 -0
  72. package/dist/esm/common/lodash.mjs +32 -0
  73. package/dist/esm/common/manifest.mjs +30 -0
  74. package/dist/esm/common/package.mjs +56 -0
  75. package/dist/esm/common/plugin.mjs +48 -0
  76. package/dist/esm/common/resolver.mjs +46 -0
  77. package/dist/esm/common/rspack.mjs +9 -0
  78. package/dist/esm/common/summary.mjs +8 -0
  79. package/dist/esm/common/time.mjs +43 -0
  80. package/dist/esm/common/url.mjs +14 -0
  81. package/dist/esm/error/error.mjs +154 -0
  82. package/dist/esm/error/index.mjs +3 -0
  83. package/dist/esm/error/transform.mjs +138 -0
  84. package/dist/esm/error/utils.mjs +22 -0
  85. package/dist/esm/index.mjs +3 -0
  86. package/dist/esm/logger.mjs +49 -0
  87. package/dist/esm/rule-utils/document/document.mjs +58 -0
  88. package/dist/esm/rule-utils/document/index.mjs +3 -0
  89. package/dist/esm/rule-utils/document/server.mjs +12 -0
  90. package/dist/esm/rule-utils/index.mjs +2 -0
  91. package/dist/esm/rule-utils/parser/asserts.mjs +104 -0
  92. package/dist/esm/rule-utils/parser/index.mjs +4 -0
  93. package/dist/esm/rule-utils/parser/parser.mjs +23 -0
  94. package/dist/esm/rule-utils/parser/types.mjs +7 -0
  95. package/dist/esm/rule-utils/parser/utils.mjs +109 -0
  96. package/dist/type/common/file.d.ts +3 -0
  97. package/dist/type/common/file.d.ts.map +1 -0
  98. package/dist/type/common/graph/modules.d.ts +1 -1
  99. package/dist/type/common/graph/modules.d.ts.map +1 -1
  100. package/dist/type/common/index.d.ts +1 -0
  101. package/dist/type/common/index.d.ts.map +1 -1
  102. package/dist/type/logger.d.ts +3 -0
  103. package/dist/type/logger.d.ts.map +1 -1
  104. package/package.json +13 -12
  105. package/dist/esm/build/envinfo.js +0 -75
  106. package/dist/esm/build/file/cache.js +0 -30
  107. package/dist/esm/build/file/index.js +0 -7
  108. package/dist/esm/build/file/sharding.js +0 -50
  109. package/dist/esm/build/index.js +0 -12
  110. package/dist/esm/build/json.js +0 -85
  111. package/dist/esm/build/process.js +0 -24
  112. package/dist/esm/build/server.js +0 -96
  113. package/dist/esm/common/alerts.js +0 -25
  114. package/dist/esm/common/algorithm.js +0 -39
  115. package/dist/esm/common/bundle.js +0 -30
  116. package/dist/esm/common/crypto.js +0 -28
  117. package/dist/esm/common/data/index.js +0 -428
  118. package/dist/esm/common/global-config.js +0 -38
  119. package/dist/esm/common/graph/assets.js +0 -310
  120. package/dist/esm/common/graph/chunk.js +0 -49
  121. package/dist/esm/common/graph/dependency.js +0 -14
  122. package/dist/esm/common/graph/entrypoints.js +0 -6
  123. package/dist/esm/common/graph/index.js +0 -5
  124. package/dist/esm/common/graph/modules.js +0 -90
  125. package/dist/esm/common/index.js +0 -36
  126. package/dist/esm/common/loader.js +0 -279
  127. package/dist/esm/common/lodash.js +0 -49
  128. package/dist/esm/common/manifest.js +0 -46
  129. package/dist/esm/common/package.js +0 -71
  130. package/dist/esm/common/plugin.js +0 -59
  131. package/dist/esm/common/resolver.js +0 -54
  132. package/dist/esm/common/rspack.js +0 -12
  133. package/dist/esm/common/summary.js +0 -10
  134. package/dist/esm/common/time.js +0 -64
  135. package/dist/esm/common/url.js +0 -20
  136. package/dist/esm/error/error.js +0 -202
  137. package/dist/esm/error/index.js +0 -5
  138. package/dist/esm/error/transform.js +0 -141
  139. package/dist/esm/error/utils.js +0 -40
  140. package/dist/esm/index.js +0 -6
  141. package/dist/esm/logger.js +0 -43
  142. package/dist/esm/rule-utils/document/document.js +0 -67
  143. package/dist/esm/rule-utils/document/index.js +0 -3
  144. package/dist/esm/rule-utils/document/server.js +0 -17
  145. package/dist/esm/rule-utils/index.js +0 -2
  146. package/dist/esm/rule-utils/parser/asserts.js +0 -132
  147. package/dist/esm/rule-utils/parser/index.js +0 -4
  148. package/dist/esm/rule-utils/parser/parser.js +0 -58
  149. package/dist/esm/rule-utils/parser/types.js +0 -9
  150. package/dist/esm/rule-utils/parser/utils.js +0 -164
  151. /package/dist/esm/rule-utils/document/{types.js → types.mjs} +0 -0
@@ -1,58 +0,0 @@
1
- import { Parser as AcornParser } from "acorn";
2
- import { importAttributes } from "acorn-import-attributes";
3
- import * as walk from "acorn-walk";
4
- import { asserts } from "./asserts";
5
- import * as utils from "./utils";
6
- const acornParserInternal = AcornParser.extend(importAttributes);
7
- let acornParserExport = AcornParser.extend(importAttributes);
8
- const parser = {
9
- /** AST iterator */
10
- walk,
11
- /**
12
- * Compile code
13
- * - Output root node is `Node.Program`
14
- */
15
- parse: (input, options) => {
16
- return acornParserExport.parse(input, options);
17
- },
18
- /**
19
- * Compile the next first expression
20
- * - The output root node is `Node.ExpressionStatement`
21
- */
22
- parseExpressionAt: (input, pos, options) => {
23
- return acornParserExport.parseExpressionAt(
24
- input,
25
- pos,
26
- options
27
- );
28
- },
29
- /**
30
- * add plugins for acorn
31
- */
32
- extend(...args) {
33
- acornParserExport = acornParserExport.extend(...args);
34
- return acornParserExport;
35
- },
36
- /** Set of assertions */
37
- asserts,
38
- utils,
39
- /**
40
- * @internal
41
- * parser for internal packages
42
- */
43
- internal: {
44
- parse: (input, options) => {
45
- return acornParserInternal.parse(input, options);
46
- },
47
- parseExpressionAt: (input, pos, options) => {
48
- return acornParserInternal.parseExpressionAt(
49
- input,
50
- pos,
51
- options
52
- );
53
- }
54
- }
55
- };
56
- export {
57
- parser
58
- };
@@ -1,9 +0,0 @@
1
- var ECMAVersion = /* @__PURE__ */ ((ECMAVersion2) => {
2
- ECMAVersion2["ES5"] = "ES5";
3
- ECMAVersion2["ES6"] = "ES6";
4
- ECMAVersion2["ES7P"] = "ES7+";
5
- return ECMAVersion2;
6
- })(ECMAVersion || {});
7
- export {
8
- ECMAVersion
9
- };
@@ -1,164 +0,0 @@
1
- import { parse } from "acorn";
2
- import { ECMAVersion } from "./types";
3
- import { asserts } from "./asserts";
4
- function isSameSemantics(node1, node2) {
5
- if (node1.type !== node2.type) {
6
- return false;
7
- }
8
- switch (node1.type) {
9
- case "CallExpression": {
10
- const next = node2;
11
- return node1.arguments.length === next.arguments.length && Boolean(node1.optional) === Boolean(next.optional) && isSameSemantics(node1.callee, next.callee) && node1.arguments.every(
12
- (node, i) => isSameSemantics(node, next.arguments[i])
13
- );
14
- }
15
- case "MemberExpression": {
16
- const next = node2;
17
- return node1.computed === next.computed && Boolean(node1.optional) === Boolean(next.optional) && isSameSemantics(node1.object, next.object) && isSameSemantics(node1.property, next.property);
18
- }
19
- case "Identifier": {
20
- return node1.name === node2.name;
21
- }
22
- case "Literal": {
23
- if (asserts.isSimpleLiteral(node1) && asserts.isSimpleLiteral(node2)) {
24
- return node1.value === node2.value;
25
- }
26
- return node1.raw === node2.raw;
27
- }
28
- case "ObjectExpression": {
29
- const next = node2;
30
- return node1.properties.length === next.properties.length && node1.properties.every(
31
- (prop, i) => isSameSemantics(prop, next.properties[i])
32
- );
33
- }
34
- case "Property": {
35
- const next = node2;
36
- return node1.computed === next.computed && node1.kind === next.kind && node1.method === next.method && isSameSemantics(node1.key, next.key) && isSameSemantics(node1.value, next.value);
37
- }
38
- default: {
39
- throw new Error(`Unknown node type: ${node1.type}`);
40
- }
41
- }
42
- }
43
- function getDefaultImports(node) {
44
- return node.body.filter((statement) => {
45
- if (statement.type !== "ImportDeclaration") {
46
- return false;
47
- }
48
- const specifier = statement?.specifiers?.[0];
49
- if (specifier?.type === "ImportDefaultSpecifier") {
50
- return true;
51
- }
52
- return false;
53
- });
54
- }
55
- function getIdentifierInPattern(name, node) {
56
- if (asserts.isIdentifier(node) && node.name === name) {
57
- return node;
58
- }
59
- if (asserts.isObjectPattern(node)) {
60
- for (const prop of node.properties) {
61
- if (asserts.isAssignmentProperty(prop)) {
62
- return getIdentifierInPattern(name, prop.value);
63
- }
64
- if (asserts.isRestElement(prop)) {
65
- return getIdentifierInPattern(name, prop);
66
- }
67
- }
68
- }
69
- if (asserts.isArrayPattern(node)) {
70
- for (const el of node.elements) {
71
- if (el) {
72
- const result = getIdentifierInPattern(name, el);
73
- if (result) {
74
- return result;
75
- }
76
- }
77
- }
78
- }
79
- if (asserts.isRestElement(node)) {
80
- return getIdentifierInPattern(name, node.argument);
81
- }
82
- if (asserts.isAssignmentPattern(node)) {
83
- return getIdentifierInPattern(name, node.left);
84
- }
85
- }
86
- function getIdentifierInDeclaration(name, node) {
87
- function getId(node2) {
88
- return asserts.isIdentifier(node2.id) && node2.id.name === name ? node2.id : void 0;
89
- }
90
- if (asserts.isFunctionDeclaration(node)) {
91
- return getId(node);
92
- }
93
- if (asserts.isClassDeclaration(node)) {
94
- return getId(node);
95
- }
96
- if (asserts.isVariableDeclaration(node)) {
97
- return node.declarations.find(
98
- (item) => getIdentifierInPattern(name, item.id)
99
- )?.id;
100
- }
101
- }
102
- function getIdentifierInImport(name, node) {
103
- if (asserts.isImportDeclaration(node)) {
104
- for (const specifier of node.specifiers ?? []) {
105
- if (specifier.local.name === name) {
106
- return specifier.local;
107
- }
108
- }
109
- }
110
- }
111
- function getIdentifierInExport(name, node) {
112
- if (asserts.isExportNamedDeclaration(node)) {
113
- if (node.declaration) {
114
- return getIdentifierInDeclaration(name, node.declaration);
115
- }
116
- for (const specifier of node.specifiers ?? []) {
117
- if (specifier.exported.name === name) {
118
- return specifier.exported;
119
- }
120
- }
121
- }
122
- if (asserts.isExportAllDeclaration(node) && node.exported) {
123
- if (node.exported.name === name) {
124
- return node.exported;
125
- }
126
- }
127
- }
128
- function canParse(code, ecmaVersion2) {
129
- try {
130
- parse(code, {
131
- ecmaVersion: ecmaVersion2,
132
- sourceType: typeof ecmaVersion2 === "number" && ecmaVersion2 <= 5 ? "script" : "module"
133
- });
134
- return true;
135
- } catch (err) {
136
- return false;
137
- }
138
- }
139
- function isES5(code) {
140
- return canParse(code, 5);
141
- }
142
- function isES6(code) {
143
- return canParse(code, 6);
144
- }
145
- function detectECMAVersion(code) {
146
- if (isES6(code)) {
147
- if (isES5(code))
148
- return ECMAVersion.ES5;
149
- return ECMAVersion.ES6;
150
- }
151
- return ECMAVersion.ES7P;
152
- }
153
- export {
154
- canParse,
155
- detectECMAVersion,
156
- getDefaultImports,
157
- getIdentifierInDeclaration,
158
- getIdentifierInExport,
159
- getIdentifierInImport,
160
- getIdentifierInPattern,
161
- isES5,
162
- isES6,
163
- isSameSemantics
164
- };