@rsdoctor/types 0.0.2-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 (111) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +15 -0
  3. package/dist/babel.d.ts +13 -0
  4. package/dist/babel.js +2 -0
  5. package/dist/client.d.ts +108 -0
  6. package/dist/client.js +29 -0
  7. package/dist/common.d.ts +26 -0
  8. package/dist/common.js +2 -0
  9. package/dist/constants.d.ts +16 -0
  10. package/dist/constants.js +36 -0
  11. package/dist/emo.d.ts +28 -0
  12. package/dist/emo.js +9 -0
  13. package/dist/error.d.ts +137 -0
  14. package/dist/error.js +10 -0
  15. package/dist/esbuild.d.ts +30 -0
  16. package/dist/esbuild.js +2 -0
  17. package/dist/index.d.ts +14 -0
  18. package/dist/index.js +40 -0
  19. package/dist/linter/diagnostic.d.ts +45 -0
  20. package/dist/linter/diagnostic.js +5 -0
  21. package/dist/linter/index.d.ts +2 -0
  22. package/dist/linter/index.js +18 -0
  23. package/dist/linter/rule.d.ts +107 -0
  24. package/dist/linter/rule.js +2 -0
  25. package/dist/logger.d.ts +34 -0
  26. package/dist/logger.js +15 -0
  27. package/dist/manifest.d.ts +55 -0
  28. package/dist/manifest.js +17 -0
  29. package/dist/modules.d.ts +7 -0
  30. package/dist/modules.js +2 -0
  31. package/dist/plugin/baseCompiler.d.ts +20 -0
  32. package/dist/plugin/baseCompiler.js +2 -0
  33. package/dist/plugin/baseLoader.d.ts +71 -0
  34. package/dist/plugin/baseLoader.js +2 -0
  35. package/dist/plugin/baseStats.d.ts +114 -0
  36. package/dist/plugin/baseStats.js +2 -0
  37. package/dist/plugin/index.d.ts +4 -0
  38. package/dist/plugin/index.js +20 -0
  39. package/dist/plugin/plugin.d.ts +32 -0
  40. package/dist/plugin/plugin.js +2 -0
  41. package/dist/rule/code/E1001.d.ts +3 -0
  42. package/dist/rule/code/E1001.js +31 -0
  43. package/dist/rule/code/E1002.d.ts +3 -0
  44. package/dist/rule/code/E1002.js +31 -0
  45. package/dist/rule/code/E1003.d.ts +3 -0
  46. package/dist/rule/code/E1003.js +39 -0
  47. package/dist/rule/code/E1004.d.ts +3 -0
  48. package/dist/rule/code/E1004.js +15 -0
  49. package/dist/rule/code/index.d.ts +23 -0
  50. package/dist/rule/code/index.js +51 -0
  51. package/dist/rule/code/type.d.ts +27 -0
  52. package/dist/rule/code/type.js +23 -0
  53. package/dist/rule/data.d.ts +132 -0
  54. package/dist/rule/data.js +2 -0
  55. package/dist/rule/index.d.ts +2 -0
  56. package/dist/rule/index.js +18 -0
  57. package/dist/sdk/chunk.d.ts +125 -0
  58. package/dist/sdk/chunk.js +2 -0
  59. package/dist/sdk/config.d.ts +8 -0
  60. package/dist/sdk/config.js +2 -0
  61. package/dist/sdk/context.d.ts +23 -0
  62. package/dist/sdk/context.js +2 -0
  63. package/dist/sdk/envinfo.d.ts +19 -0
  64. package/dist/sdk/envinfo.js +2 -0
  65. package/dist/sdk/hooks.d.ts +13 -0
  66. package/dist/sdk/hooks.js +2 -0
  67. package/dist/sdk/index.d.ts +16 -0
  68. package/dist/sdk/index.js +32 -0
  69. package/dist/sdk/instance.d.ts +149 -0
  70. package/dist/sdk/instance.js +2 -0
  71. package/dist/sdk/loader.d.ts +64 -0
  72. package/dist/sdk/loader.js +2 -0
  73. package/dist/sdk/module.d.ts +303 -0
  74. package/dist/sdk/module.js +28 -0
  75. package/dist/sdk/package.d.ts +113 -0
  76. package/dist/sdk/package.js +2 -0
  77. package/dist/sdk/plugin.d.ts +21 -0
  78. package/dist/sdk/plugin.js +2 -0
  79. package/dist/sdk/process.d.ts +10 -0
  80. package/dist/sdk/process.js +2 -0
  81. package/dist/sdk/resolver.d.ts +52 -0
  82. package/dist/sdk/resolver.js +2 -0
  83. package/dist/sdk/result.d.ts +41 -0
  84. package/dist/sdk/result.js +2 -0
  85. package/dist/sdk/server/apis/alerts.d.ts +26 -0
  86. package/dist/sdk/server/apis/alerts.js +3 -0
  87. package/dist/sdk/server/apis/graph.d.ts +41 -0
  88. package/dist/sdk/server/apis/graph.js +3 -0
  89. package/dist/sdk/server/apis/index.d.ts +128 -0
  90. package/dist/sdk/server/apis/index.js +72 -0
  91. package/dist/sdk/server/apis/loader.d.ts +46 -0
  92. package/dist/sdk/server/apis/loader.js +3 -0
  93. package/dist/sdk/server/apis/pagination.d.ts +11 -0
  94. package/dist/sdk/server/apis/pagination.js +2 -0
  95. package/dist/sdk/server/apis/plugin.d.ts +19 -0
  96. package/dist/sdk/server/apis/plugin.js +3 -0
  97. package/dist/sdk/server/apis/project.d.ts +16 -0
  98. package/dist/sdk/server/apis/project.js +3 -0
  99. package/dist/sdk/server/apis/resolver.d.ts +18 -0
  100. package/dist/sdk/server/apis/resolver.js +3 -0
  101. package/dist/sdk/server/index.d.ts +23 -0
  102. package/dist/sdk/server/index.js +27 -0
  103. package/dist/sdk/statement.d.ts +177 -0
  104. package/dist/sdk/statement.js +147 -0
  105. package/dist/sdk/summary.d.ts +18 -0
  106. package/dist/sdk/summary.js +2 -0
  107. package/dist/sdk/treeShaking.d.ts +152 -0
  108. package/dist/sdk/treeShaking.js +2 -0
  109. package/dist/thirdparty.d.ts +2 -0
  110. package/dist/thirdparty.js +2 -0
  111. package/package.json +39 -0
@@ -0,0 +1,177 @@
1
+ import type { SourceRange, ModuleInstance } from './module';
2
+ import type { NonFunctionProperties } from '../common';
3
+ /** Statement position */
4
+ export interface StatementPosition {
5
+ /**
6
+ * Source code location
7
+ * - Because sourceMap may not exist, there may not be a value here
8
+ * There are many reasons why sourceMap does not exist, it may be a parsing failure, or it may be ignored during the loader conversion process
9
+ */
10
+ source?: SourceRange;
11
+ /** Converted code position */
12
+ transformed: SourceRange;
13
+ }
14
+ /** statement category */
15
+ export declare enum StatementKind {
16
+ /**
17
+ * Import by default
18
+ * @example
19
+ * ```ts
20
+ * import defaultName from 'name';
21
+ * ```
22
+ */
23
+ ImportDefault = 100,
24
+ /**
25
+ * Named import
26
+ * @example
27
+ * ```ts
28
+ * import { name1, name as name2 } from 'name';
29
+ * ```
30
+ */
31
+ ImportNamed = 101,
32
+ /**
33
+ * Default and named import
34
+ * @example
35
+ * ```ts
36
+ * import defaultName, { name1 } from 'name';
37
+ * ```
38
+ */
39
+ ImportDefaultWithNamed = 102,
40
+ /**
41
+ * Default and Namespace import
42
+ * @example
43
+ * ```ts
44
+ * import defaultName, * as name from 'name';
45
+ * ```
46
+ */
47
+ ImportDefaultWithNamespace = 103,
48
+ /**
49
+ * Namespace import
50
+ * @example
51
+ * ```ts
52
+ * import * as namespaceName from 'name';
53
+ * ```
54
+ */
55
+ ImportNamespace = 104,
56
+ /**
57
+ * Side effects import
58
+ * @example
59
+ * ```ts
60
+ * import 'name';
61
+ * ```
62
+ */
63
+ ImportSideEffect = 105,
64
+ /**
65
+ * Dynamic import
66
+ * @example
67
+ * ```ts
68
+ * import('name');
69
+ * ```
70
+ */
71
+ ImportDynamic = 106,
72
+ /**
73
+ * Declare export
74
+ * @example
75
+ * ```ts
76
+ * export const name = '123';
77
+ * ```
78
+ */
79
+ ExportDeclaration = 200,
80
+ /**
81
+ * List export
82
+ * @example
83
+ * ```ts
84
+ * export { item1, item as item2 };
85
+ * ```
86
+ */
87
+ ExportList = 201,
88
+ /**
89
+ * Default export
90
+ * @example
91
+ * ```ts
92
+ * export default name;
93
+ * ```
94
+ */
95
+ ExportDefault = 202,
96
+ /**
97
+ * Re-export
98
+ * @example
99
+ * ```ts
100
+ * export { default as defaultName, item1, item as item2 } from 'name';
101
+ * ```
102
+ */
103
+ ExportAggregating = 203,
104
+ /**
105
+ * Re-export to Namespace
106
+ * @example
107
+ * ```ts
108
+ * export * as namespaceName from 'name';
109
+ * ```
110
+ */
111
+ ExportNamespace = 204,
112
+ /**
113
+ * CJS module import
114
+ * @example
115
+ * ```ts
116
+ * require('name');
117
+ * ```
118
+ */
119
+ RequireCall = 300,
120
+ /**
121
+ * CJS named import
122
+ * @example
123
+ * ```ts
124
+ * require('name').name
125
+ * ```
126
+ */
127
+ RequireName = 301,
128
+ /**
129
+ * Overall export
130
+ * @example
131
+ * ```ts
132
+ * module.exports = {};
133
+ * ```
134
+ */
135
+ RequireExports = 302,
136
+ /**
137
+ * CJS re-export
138
+ * @example
139
+ * ```ts
140
+ * module.exports = require('name');
141
+ * ```
142
+ */
143
+ RequireExportAggregating = 303,
144
+ /**
145
+ * Named export
146
+ * @example
147
+ * ```ts
148
+ * export.name = '123';
149
+ * ```
150
+ */
151
+ RequireExportName = 304,
152
+ /**
153
+ * Unknown statement
154
+ */
155
+ Unknown = 999
156
+ }
157
+ /** Statement class */
158
+ export interface StatementInstance {
159
+ /** Current statement position */
160
+ readonly position: StatementPosition;
161
+ /** Module where the statement is located */
162
+ readonly module: ModuleInstance;
163
+ /** Is it the same statement */
164
+ isSame(statement: StatementInstance): boolean;
165
+ /**
166
+ * Get original location
167
+ * - When running for the first time and the Module contains sourceMap, it will be calculated
168
+ */
169
+ getSourcePosition(): SourceRange | undefined;
170
+ /** Output data */
171
+ toData(): StatementData;
172
+ }
173
+ /** statement data */
174
+ export interface StatementData extends Omit<NonFunctionProperties<StatementInstance>, 'module'> {
175
+ /** Module number where the statement is located */
176
+ module: number;
177
+ }
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StatementKind = void 0;
4
+ /** statement category */
5
+ var StatementKind;
6
+ (function (StatementKind) {
7
+ /**
8
+ * Import by default
9
+ * @example
10
+ * ```ts
11
+ * import defaultName from 'name';
12
+ * ```
13
+ */
14
+ StatementKind[StatementKind["ImportDefault"] = 100] = "ImportDefault";
15
+ /**
16
+ * Named import
17
+ * @example
18
+ * ```ts
19
+ * import { name1, name as name2 } from 'name';
20
+ * ```
21
+ */
22
+ StatementKind[StatementKind["ImportNamed"] = 101] = "ImportNamed";
23
+ /**
24
+ * Default and named import
25
+ * @example
26
+ * ```ts
27
+ * import defaultName, { name1 } from 'name';
28
+ * ```
29
+ */
30
+ StatementKind[StatementKind["ImportDefaultWithNamed"] = 102] = "ImportDefaultWithNamed";
31
+ /**
32
+ * Default and Namespace import
33
+ * @example
34
+ * ```ts
35
+ * import defaultName, * as name from 'name';
36
+ * ```
37
+ */
38
+ StatementKind[StatementKind["ImportDefaultWithNamespace"] = 103] = "ImportDefaultWithNamespace";
39
+ /**
40
+ * Namespace import
41
+ * @example
42
+ * ```ts
43
+ * import * as namespaceName from 'name';
44
+ * ```
45
+ */
46
+ StatementKind[StatementKind["ImportNamespace"] = 104] = "ImportNamespace";
47
+ /**
48
+ * Side effects import
49
+ * @example
50
+ * ```ts
51
+ * import 'name';
52
+ * ```
53
+ */
54
+ StatementKind[StatementKind["ImportSideEffect"] = 105] = "ImportSideEffect";
55
+ /**
56
+ * Dynamic import
57
+ * @example
58
+ * ```ts
59
+ * import('name');
60
+ * ```
61
+ */
62
+ StatementKind[StatementKind["ImportDynamic"] = 106] = "ImportDynamic";
63
+ /**
64
+ * Declare export
65
+ * @example
66
+ * ```ts
67
+ * export const name = '123';
68
+ * ```
69
+ */
70
+ StatementKind[StatementKind["ExportDeclaration"] = 200] = "ExportDeclaration";
71
+ /**
72
+ * List export
73
+ * @example
74
+ * ```ts
75
+ * export { item1, item as item2 };
76
+ * ```
77
+ */
78
+ StatementKind[StatementKind["ExportList"] = 201] = "ExportList";
79
+ /**
80
+ * Default export
81
+ * @example
82
+ * ```ts
83
+ * export default name;
84
+ * ```
85
+ */
86
+ StatementKind[StatementKind["ExportDefault"] = 202] = "ExportDefault";
87
+ /**
88
+ * Re-export
89
+ * @example
90
+ * ```ts
91
+ * export { default as defaultName, item1, item as item2 } from 'name';
92
+ * ```
93
+ */
94
+ StatementKind[StatementKind["ExportAggregating"] = 203] = "ExportAggregating";
95
+ /**
96
+ * Re-export to Namespace
97
+ * @example
98
+ * ```ts
99
+ * export * as namespaceName from 'name';
100
+ * ```
101
+ */
102
+ StatementKind[StatementKind["ExportNamespace"] = 204] = "ExportNamespace";
103
+ /**
104
+ * CJS module import
105
+ * @example
106
+ * ```ts
107
+ * require('name');
108
+ * ```
109
+ */
110
+ StatementKind[StatementKind["RequireCall"] = 300] = "RequireCall";
111
+ /**
112
+ * CJS named import
113
+ * @example
114
+ * ```ts
115
+ * require('name').name
116
+ * ```
117
+ */
118
+ StatementKind[StatementKind["RequireName"] = 301] = "RequireName";
119
+ /**
120
+ * Overall export
121
+ * @example
122
+ * ```ts
123
+ * module.exports = {};
124
+ * ```
125
+ */
126
+ StatementKind[StatementKind["RequireExports"] = 302] = "RequireExports";
127
+ /**
128
+ * CJS re-export
129
+ * @example
130
+ * ```ts
131
+ * module.exports = require('name');
132
+ * ```
133
+ */
134
+ StatementKind[StatementKind["RequireExportAggregating"] = 303] = "RequireExportAggregating";
135
+ /**
136
+ * Named export
137
+ * @example
138
+ * ```ts
139
+ * export.name = '123';
140
+ * ```
141
+ */
142
+ StatementKind[StatementKind["RequireExportName"] = 304] = "RequireExportName";
143
+ /**
144
+ * Unknown statement
145
+ */
146
+ StatementKind[StatementKind["Unknown"] = 999] = "Unknown";
147
+ })(StatementKind || (exports.StatementKind = StatementKind = {}));
@@ -0,0 +1,18 @@
1
+ interface SummaryCostsData {
2
+ /**
3
+ * such as 'bootstrap' / 'compile' / 'minify' or else.
4
+ */
5
+ name: string;
6
+ /**
7
+ * the start timestamp of the data.
8
+ */
9
+ startAt: number;
10
+ costs: number;
11
+ }
12
+ export interface SummaryData {
13
+ /**
14
+ * costs of different data.
15
+ */
16
+ costs: SummaryCostsData[];
17
+ }
18
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,152 @@
1
+ import type { ModuleInstance, DependencyInstance } from './module';
2
+ import type { StatementInstance, StatementData } from './statement';
3
+ import type { NonFunctionProperties } from '../common';
4
+ /** Variable data */
5
+ export interface VariableInstance {
6
+ /** Variable number */
7
+ readonly id: number;
8
+ /** Variable name */
9
+ readonly name: string;
10
+ /** Module */
11
+ readonly module: ModuleInstance;
12
+ /** Is it used */
13
+ readonly usedInfo: string;
14
+ /** variable identifier declaration location */
15
+ readonly identifier: StatementInstance;
16
+ /** Set as export variable */
17
+ setExportInfo(info: ExportInstance): void;
18
+ /** Get export information */
19
+ getExportInfo(): ExportInstance | undefined;
20
+ /** Get data */
21
+ toData(): VariableData;
22
+ }
23
+ export interface VariableData extends Omit<NonFunctionProperties<VariableInstance>, 'identifier' | 'module'> {
24
+ identifier: StatementData;
25
+ module: number;
26
+ exported?: number;
27
+ }
28
+ /** Export variable */
29
+ export interface ExportInstance {
30
+ /** Number */
31
+ readonly id: number;
32
+ /**
33
+ * Export name
34
+ * - Default export is 'default'
35
+ */
36
+ readonly name: string;
37
+ /**
38
+ * Variable data
39
+ * - This item is empty when the original variable does not exist
40
+ */
41
+ readonly variable?: VariableInstance;
42
+ /**
43
+ * The position of the export variable in the export statement
44
+ * - If it is exported as namespace or reexport, this item does not exist
45
+ */
46
+ readonly identifier?: StatementInstance;
47
+ /** Is it a re-export */
48
+ readonly isReExport: boolean;
49
+ /** Set as export variable */
50
+ addSideEffect(info: SideEffectInstance): void;
51
+ /** Get all side effects */
52
+ getSideEffects(): SideEffectInstance[];
53
+ /** Set superior export */
54
+ setFromExport(from: ExportInstance): void;
55
+ /**
56
+ * Obtain superior data
57
+ * Will return to itself when there is no superior data
58
+ * @param [number] - depth is Infinity by default, get the original export, get the superior export when it is 1
59
+ */
60
+ getRecursiveExport(depth?: number): ExportInstance;
61
+ toData(): ExportData;
62
+ }
63
+ /** Export variable data */
64
+ export interface ExportData extends Omit<NonFunctionProperties<ExportInstance>, 'identifier' | 'variable'> {
65
+ from?: number;
66
+ root?: number;
67
+ used: number[];
68
+ identifier?: StatementData;
69
+ variable?: number;
70
+ }
71
+ /** Import variable data */
72
+ export interface SideEffectInstance {
73
+ /** Number */
74
+ readonly id: number;
75
+ /**
76
+ * Import name
77
+ * - default import is 'default'
78
+ */
79
+ readonly name: string;
80
+ /**
81
+ * Import original name
82
+ * - default import is 'default'
83
+ * - 'namespace' for full import
84
+ */
85
+ readonly originName?: string;
86
+ /** Module */
87
+ readonly module: ModuleInstance;
88
+ /** The position of the imported variable in the statement */
89
+ readonly identifier: StatementInstance;
90
+ /** Variable data */
91
+ readonly variable?: VariableInstance;
92
+ /** Superior export statement */
93
+ readonly exports?: ExportInstance[];
94
+ /** Whether it is a named import */
95
+ readonly isNameSpace: boolean;
96
+ /**
97
+ * Dependency derived from side effects
98
+ * - This item is empty when it is a local side effect
99
+ */
100
+ readonly fromDependency?: DependencyInstance;
101
+ /** Connect all exported data of the module */
102
+ setModuleExport(module: ModuleGraphModuleInstance): void;
103
+ /** Connect to export data */
104
+ setExportInfo(info: ExportInstance): void;
105
+ toData(): SideEffectData;
106
+ }
107
+ export interface SideEffectData extends Omit<NonFunctionProperties<SideEffectInstance>, 'module' | 'exports' | 'identifier' | 'variable' | 'isNameSpace' | 'fromDependency'> {
108
+ module: number;
109
+ identifier: StatementData;
110
+ fromDependency?: number;
111
+ variable?: number;
112
+ exports?: number[];
113
+ isNameSpace?: boolean;
114
+ }
115
+ export interface ModuleGraphModuleInstance {
116
+ /** Current Module */
117
+ readonly module: ModuleInstance;
118
+ /**
119
+ * Dynamic reference
120
+ * - indicates that when referencing this module, the module's exportsType is 'dynamic ' , and tree-shaking analysis will be ignored
121
+ */
122
+ readonly dynamic: boolean;
123
+ /** Add export data */
124
+ addExportInfo(data: ExportInstance): void;
125
+ /** Add side effect data */
126
+ addSideEffect(data: SideEffectInstance): void;
127
+ /** Add variable data */
128
+ addVariable(data: VariableInstance): void;
129
+ /** Get all exports */
130
+ getExports(): ExportInstance[];
131
+ /** Get all imports */
132
+ getSideEffects(name?: string): SideEffectInstance[];
133
+ /** Get local export */
134
+ getOwnExports(): ExportInstance[];
135
+ /** Get export data */
136
+ getExport(name: string): ExportInstance | undefined;
137
+ /** Get self-exported data */
138
+ getOwnExport(name: string): ExportInstance | undefined;
139
+ /** Get re-exported data */
140
+ getReExport(name: string): ExportInstance | undefined;
141
+ toData(): ModuleGraphModuleData;
142
+ }
143
+ export interface ModuleGraphModuleData extends Omit<NonFunctionProperties<ModuleGraphModuleInstance>, 'module'> {
144
+ /** Module number */
145
+ module: number;
146
+ /** Export data */
147
+ exports: number[];
148
+ /** Side effect data */
149
+ sideEffects: number[];
150
+ /** Variable data */
151
+ variables: number[];
152
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ import type connect from 'connect';
2
+ export { connect };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@rsdoctor/types",
3
+ "version": "0.0.2-beta.0",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "https://github.com/web-infra-dev/rsdoctor",
7
+ "directory": "packages/types"
8
+ },
9
+ "license": "MIT",
10
+ "main": "dist/index.js",
11
+ "types": "dist/index.d.ts",
12
+ "files": [
13
+ "dist"
14
+ ],
15
+ "dependencies": {
16
+ "@rspack/core": "0.3.14",
17
+ "@types/connect": "3.4.35",
18
+ "@types/estree": "1.0.0",
19
+ "@types/tapable": "2.2.2",
20
+ "@types/webpack": "5.28.0",
21
+ "source-map": "^0.7.4"
22
+ },
23
+ "devDependencies": {
24
+ "@types/node": "^16",
25
+ "@types/react": "^18",
26
+ "tslib": "2.4.1",
27
+ "typescript": "^5.2.2"
28
+ },
29
+ "publishConfig": {
30
+ "access": "public",
31
+ "provenance": true,
32
+ "registry": "https://registry.npmjs.org/"
33
+ },
34
+ "scripts": {
35
+ "build": "tsc -p tsconfig.json",
36
+ "dev": "npm run start",
37
+ "start": "npm run build -- -w"
38
+ }
39
+ }