@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
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023-present Bytedance, Inc. and its affiliates.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # Rsdoctor
2
+
3
+ Rsdoctor is a tool for diagnosing and analyzing the build process and build artifacts to help developers quickly identify and solve problems.
4
+
5
+ It also supports Webpack and Rspack builders, as well as various build frameworks, such as Rsbuild.
6
+
7
+ ## Documentation
8
+
9
+ ## Contributing
10
+
11
+ Please read the [Contributing Guide](https://github.com/web-infra-dev/rsdoctor/blob/main/CONTRIBUTING.md).
12
+
13
+ ## License
14
+
15
+ Rsdoctor is [MIT licensed](https://github.com/web-infra-dev/rsdoctor/blob/main/LICENSE).
@@ -0,0 +1,13 @@
1
+ /** Babel Error */
2
+ export interface Error {
3
+ code: string;
4
+ reasonCode: string;
5
+ message: string;
6
+ name: string;
7
+ stack: string;
8
+ pos?: number;
9
+ loc?: {
10
+ line: number;
11
+ column: number;
12
+ };
13
+ }
package/dist/babel.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,108 @@
1
+ export declare enum DoctorClientUrlQuery {
2
+ BundleDiffFiles = "__bundle_files__",
3
+ ManifestFile = "manifest"
4
+ }
5
+ export declare enum DoctorClientRoutes {
6
+ Overall = "/overall",
7
+ WebpackLoaderOverall = "/webpack/loaders/overall",
8
+ WebpackLoaderAnalysis = "/webpack/loaders/analysis",
9
+ ModuleResolve = "/module/resolve",
10
+ WebpackPlugins = "/webpack/plugins",
11
+ BundleSize = "/bundle/size",
12
+ ModuleAnalyze = "/module/analyze",
13
+ TreeShaking = "/treeshaking",
14
+ BundleDiff = "/resources/bundle/diff",
15
+ RuleIndex = "/resources/rules",
16
+ Uploader = "/resources/uploader",
17
+ EmoCheck = "/emo/check"
18
+ }
19
+ export declare enum DoctorClientDiffState {
20
+ Equal = "-",
21
+ Up = "UP",
22
+ Down = "DOWN"
23
+ }
24
+ export interface DoctorClientAssetsDiffItem {
25
+ size: {
26
+ baseline: number;
27
+ current: number;
28
+ };
29
+ count: {
30
+ baseline: number;
31
+ current: number;
32
+ };
33
+ percent: number;
34
+ state: DoctorClientDiffState;
35
+ }
36
+ export interface DoctorClientAssetsDiffResult {
37
+ all: {
38
+ total: DoctorClientAssetsDiffItem;
39
+ };
40
+ js: {
41
+ total: DoctorClientAssetsDiffItem;
42
+ initial: DoctorClientAssetsDiffItem;
43
+ };
44
+ css: {
45
+ total: DoctorClientAssetsDiffItem;
46
+ initial: DoctorClientAssetsDiffItem;
47
+ };
48
+ imgs: {
49
+ total: DoctorClientAssetsDiffItem;
50
+ };
51
+ html: {
52
+ total: DoctorClientAssetsDiffItem;
53
+ };
54
+ media: {
55
+ total: DoctorClientAssetsDiffItem;
56
+ };
57
+ fonts: {
58
+ total: DoctorClientAssetsDiffItem;
59
+ };
60
+ /**
61
+ * files exclude these extensions above
62
+ */
63
+ others: {
64
+ total: DoctorClientAssetsDiffItem;
65
+ };
66
+ }
67
+ interface AssetInfo {
68
+ size: number;
69
+ count: number;
70
+ files: {
71
+ path: string;
72
+ size: number;
73
+ initial: boolean;
74
+ content: string | void;
75
+ }[];
76
+ }
77
+ export interface DoctorClientAssetsSummary {
78
+ all: {
79
+ total: AssetInfo;
80
+ };
81
+ js: {
82
+ total: AssetInfo;
83
+ initial: AssetInfo;
84
+ };
85
+ css: {
86
+ total: AssetInfo;
87
+ initial: AssetInfo;
88
+ };
89
+ imgs: {
90
+ total: AssetInfo;
91
+ };
92
+ html: {
93
+ total: AssetInfo;
94
+ };
95
+ media: {
96
+ total: AssetInfo;
97
+ };
98
+ fonts: {
99
+ total: AssetInfo;
100
+ };
101
+ /**
102
+ * files exclude these extensions above
103
+ */
104
+ others: {
105
+ total: AssetInfo;
106
+ };
107
+ }
108
+ export {};
package/dist/client.js ADDED
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DoctorClientDiffState = exports.DoctorClientRoutes = exports.DoctorClientUrlQuery = void 0;
4
+ var DoctorClientUrlQuery;
5
+ (function (DoctorClientUrlQuery) {
6
+ DoctorClientUrlQuery["BundleDiffFiles"] = "__bundle_files__";
7
+ DoctorClientUrlQuery["ManifestFile"] = "manifest";
8
+ })(DoctorClientUrlQuery || (exports.DoctorClientUrlQuery = DoctorClientUrlQuery = {}));
9
+ var DoctorClientRoutes;
10
+ (function (DoctorClientRoutes) {
11
+ DoctorClientRoutes["Overall"] = "/overall";
12
+ DoctorClientRoutes["WebpackLoaderOverall"] = "/webpack/loaders/overall";
13
+ DoctorClientRoutes["WebpackLoaderAnalysis"] = "/webpack/loaders/analysis";
14
+ DoctorClientRoutes["ModuleResolve"] = "/module/resolve";
15
+ DoctorClientRoutes["WebpackPlugins"] = "/webpack/plugins";
16
+ DoctorClientRoutes["BundleSize"] = "/bundle/size";
17
+ DoctorClientRoutes["ModuleAnalyze"] = "/module/analyze";
18
+ DoctorClientRoutes["TreeShaking"] = "/treeshaking";
19
+ DoctorClientRoutes["BundleDiff"] = "/resources/bundle/diff";
20
+ DoctorClientRoutes["RuleIndex"] = "/resources/rules";
21
+ DoctorClientRoutes["Uploader"] = "/resources/uploader";
22
+ DoctorClientRoutes["EmoCheck"] = "/emo/check";
23
+ })(DoctorClientRoutes || (exports.DoctorClientRoutes = DoctorClientRoutes = {}));
24
+ var DoctorClientDiffState;
25
+ (function (DoctorClientDiffState) {
26
+ DoctorClientDiffState["Equal"] = "-";
27
+ DoctorClientDiffState["Up"] = "UP";
28
+ DoctorClientDiffState["Down"] = "DOWN";
29
+ })(DoctorClientDiffState || (exports.DoctorClientDiffState = DoctorClientDiffState = {}));
@@ -0,0 +1,26 @@
1
+ export type NonFunctionPropertyNames<T> = {
2
+ [K in keyof T]: T[K] extends Function ? never : K;
3
+ }[keyof T];
4
+ export type NonFunctionProperties<T> = Pick<T, NonFunctionPropertyNames<T>>;
5
+ export type PlainObject<T = any> = {
6
+ [key: string]: T;
7
+ };
8
+ export type PromiseReturnType<T> = T extends (...args: any[]) => Promise<infer P> ? P : T;
9
+ export type DeepRequired<T> = T extends PlainObject ? {
10
+ [K in keyof T]-?: DeepRequired<T[K]>;
11
+ } : T;
12
+ export type OrPromise<T> = T | Promise<T>;
13
+ export type Constructor<T> = T extends abstract new (...args: infer P1) => infer R1 ? new (...args: P1) => R1 : T extends new (...args: infer P2) => infer R2 ? new (...args: P2) => R2 : never;
14
+ export type Function<P extends any[] = any[], R = any> = (...args: P) => R;
15
+ export type FunctionPropertyNames<T> = {
16
+ [K in keyof T]: T[K] extends Function ? K : never;
17
+ }[keyof T];
18
+ export type Get<T, K, F = never> = K extends keyof T ? T[K] : F;
19
+ export type ObjectPropertyNames<T> = {
20
+ [K in keyof T]: T[K] extends PlainObject ? K : never;
21
+ }[keyof T];
22
+ export type ArrayToUnion<T extends any[]> = T[number];
23
+ export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
24
+ export type LastOf<T> = UnionToIntersection<T extends any ? () => T : never> extends () => infer R ? R : never;
25
+ export type Push<T extends any[], V> = [...T, V];
26
+ export type UnionToTuple<T, L = LastOf<T>, N = [T] extends [never] ? true : false> = true extends N ? [] : Push<UnionToTuple<Exclude<T, L>>, L>;
package/dist/common.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,16 @@
1
+ export declare const JSExtension = ".js";
2
+ export declare const CSSExtension = ".css";
3
+ export declare const HtmlExtension = ".html";
4
+ export declare const ImgExtensions: string[];
5
+ export declare const MediaExtensions: string[];
6
+ export declare const FontExtensions: string[];
7
+ export declare const MapExtensions: string[];
8
+ export declare const DoctorOutputFolder = ".rsdoctor";
9
+ export declare const DoctorOutputManifest = "manifest.json";
10
+ export declare const DoctorOutputManifestPath: ".rsdoctor/manifest.json";
11
+ export declare const StatsFilePath = "dist/stats.json";
12
+ export declare const DoctorMonitorNodeBId = "Rsdoctor";
13
+ export declare const DoctorMonitorWebBId = "Rsdoctor-Client";
14
+ export declare const DoctorMonitorDocBId = "Rsdoctor-Doc";
15
+ export declare const DoctorProcessEnvDebugKey = "RSDOCTOR_DEBUG";
16
+ export declare const RsdoctorClientUrl = "";
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RsdoctorClientUrl = exports.DoctorProcessEnvDebugKey = exports.DoctorMonitorDocBId = exports.DoctorMonitorWebBId = exports.DoctorMonitorNodeBId = exports.StatsFilePath = exports.DoctorOutputManifestPath = exports.DoctorOutputManifest = exports.DoctorOutputFolder = exports.MapExtensions = exports.FontExtensions = exports.MediaExtensions = exports.ImgExtensions = exports.HtmlExtension = exports.CSSExtension = exports.JSExtension = void 0;
4
+ exports.JSExtension = '.js';
5
+ exports.CSSExtension = '.css';
6
+ exports.HtmlExtension = '.html';
7
+ exports.ImgExtensions = [
8
+ '.png',
9
+ '.jpg',
10
+ '.svg',
11
+ '.webp',
12
+ '.jpeg',
13
+ '.gif',
14
+ '.bmp',
15
+ ];
16
+ exports.MediaExtensions = [
17
+ '.mp3',
18
+ '.mp4',
19
+ '.avi',
20
+ '.wav',
21
+ '.flv',
22
+ '.mov',
23
+ '.mpg',
24
+ '.mpeg',
25
+ ];
26
+ exports.FontExtensions = ['.ttf', '.fnt', '.fon', '.otf'];
27
+ exports.MapExtensions = ['.js.map', '.ts.map', '.LICENSE.txt'];
28
+ exports.DoctorOutputFolder = '.rsdoctor';
29
+ exports.DoctorOutputManifest = 'manifest.json';
30
+ exports.DoctorOutputManifestPath = `${exports.DoctorOutputFolder}/${exports.DoctorOutputManifest}`;
31
+ exports.StatsFilePath = 'dist/stats.json';
32
+ exports.DoctorMonitorNodeBId = 'Rsdoctor';
33
+ exports.DoctorMonitorWebBId = 'Rsdoctor-Client';
34
+ exports.DoctorMonitorDocBId = 'Rsdoctor-Doc';
35
+ exports.DoctorProcessEnvDebugKey = 'RSDOCTOR_DEBUG';
36
+ exports.RsdoctorClientUrl = ''; // TODO: rsdoctor client url
package/dist/emo.d.ts ADDED
@@ -0,0 +1,28 @@
1
+ export type WorkspaceCheckDataType = {
2
+ message: string;
3
+ type: 'issues' | 'message' | 'code';
4
+ title: string;
5
+ severity?: EmoCheckSeverity;
6
+ result?: {
7
+ package: string;
8
+ data: Record<string, string | string[]>[];
9
+ tag?: string;
10
+ } | {
11
+ path: string;
12
+ line?: number;
13
+ column?: number;
14
+ }[] | Record<string, {
15
+ version: string;
16
+ pkgname: string;
17
+ }>;
18
+ issues?: string[];
19
+ };
20
+ export type EmoCheckData = {
21
+ projectInfo: Record<string, string | Object>;
22
+ workspaceRes: Record<string, WorkspaceCheckDataType[]>;
23
+ };
24
+ export declare enum EmoCheckSeverity {
25
+ Error = 0,
26
+ Warn = 1,
27
+ Info = 2
28
+ }
package/dist/emo.js ADDED
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EmoCheckSeverity = void 0;
4
+ var EmoCheckSeverity;
5
+ (function (EmoCheckSeverity) {
6
+ EmoCheckSeverity[EmoCheckSeverity["Error"] = 0] = "Error";
7
+ EmoCheckSeverity[EmoCheckSeverity["Warn"] = 1] = "Warn";
8
+ EmoCheckSeverity[EmoCheckSeverity["Info"] = 2] = "Info";
9
+ })(EmoCheckSeverity || (exports.EmoCheckSeverity = EmoCheckSeverity = {}));
@@ -0,0 +1,137 @@
1
+ import type { NonFunctionProperties } from './common';
2
+ import type { BaseRuleStoreData } from './rule';
3
+ /**
4
+ * Position
5
+ * - `line` start with `1`
6
+ * - `column` start with `0`
7
+ */
8
+ export interface Position {
9
+ line: number;
10
+ column: number;
11
+ }
12
+ /** Range of Position */
13
+ export interface Range {
14
+ start: Position;
15
+ end: Position;
16
+ }
17
+ /** Offset range */
18
+ export interface OffsetRange {
19
+ start: number;
20
+ end: number;
21
+ }
22
+ /** Error Level */
23
+ export declare enum ErrorLevel {
24
+ Ignore = 0,
25
+ Warn = 1,
26
+ Error = 2
27
+ }
28
+ /** Code prompt location */
29
+ export interface CodeFramePosition {
30
+ line: number;
31
+ column?: number;
32
+ }
33
+ /** File options where the code is located */
34
+ export interface CodeFrameFileOption {
35
+ filePath: string;
36
+ }
37
+ /** Code indication options */
38
+ export interface CodeFrameNormalOption {
39
+ filePath: string;
40
+ fileContent: string;
41
+ start?: CodeFramePosition;
42
+ end?: CodeFramePosition;
43
+ }
44
+ /**
45
+ * Code indication options
46
+ * - This type is mainly for compatibility with esbuild.
47
+ */
48
+ export interface CodeFrameLineOption {
49
+ /** File path */
50
+ filePath: string;
51
+ /** Error line text */
52
+ lineText: string;
53
+ /** Starting point */
54
+ start?: CodeFramePosition;
55
+ /** Error character length */
56
+ length?: number;
57
+ }
58
+ export type CodeFrameOption = CodeFrameFileOption | CodeFrameNormalOption | CodeFrameLineOption;
59
+ /** Control item */
60
+ export interface ControllerOption {
61
+ /**
62
+ * Hide stack information
63
+ * - default is `true`
64
+ */
65
+ noStack?: boolean;
66
+ /**
67
+ * Do not display colors
68
+ * - default is `false`
69
+ */
70
+ noColor?: boolean;
71
+ }
72
+ /** repair data */
73
+ export interface FixData {
74
+ /** Modify the starting position of string in the original text. */
75
+ start: number;
76
+ /** Modify string in the key position of the original text */
77
+ end: number;
78
+ /**
79
+ * Replaced new text
80
+ * - If empty, delete the original text.
81
+ */
82
+ newText?: string;
83
+ /** Has it been fixed */
84
+ isFixed?: boolean;
85
+ }
86
+ /** Error Data */
87
+ export interface DevToolErrorData {
88
+ /** Error number */
89
+ id: number;
90
+ /** Wrong code */
91
+ code?: string;
92
+ /** Error category */
93
+ category?: string;
94
+ title: string;
95
+ message: string;
96
+ stack?: string;
97
+ fixData?: FixData;
98
+ detail?: any;
99
+ /** Absolute path where the error is located. */
100
+ path?: string;
101
+ /**
102
+ * Error level
103
+ * - default is `'Error'`
104
+ */
105
+ level?: keyof typeof ErrorLevel;
106
+ /** Error prompt */
107
+ hint?: string;
108
+ /** Description link */
109
+ referenceUrl?: string;
110
+ codeFrame?: CodeFrameOption;
111
+ }
112
+ /** Error data */
113
+ export interface DevToolErrorInstance extends DevToolErrorData {
114
+ /** Output stored data */
115
+ toData(): BaseRuleStoreData;
116
+ toString(): string;
117
+ toJSON(): {
118
+ message: string;
119
+ name: string;
120
+ stack?: string;
121
+ };
122
+ /** Set control items */
123
+ setControllerOption(opt: ControllerOption): void;
124
+ /** Set code instructions */
125
+ setCodeFrame(opt: CodeFrameOption): void;
126
+ /** Is the error the same */
127
+ isSame<T extends DevToolErrorInstance>(error: T): boolean;
128
+ }
129
+ export interface DevToolErrorsData {
130
+ errors: DevToolErrorInstance[];
131
+ warnings: DevToolErrorInstance[];
132
+ }
133
+ /** Incorrect data input */
134
+ export type DevToolErrorParams = Omit<NonFunctionProperties<DevToolErrorInstance>, 'message' | 'title' | 'path' | 'id'> & {
135
+ controller?: ControllerOption;
136
+ codeFrame?: CodeFrameOption;
137
+ };
package/dist/error.js ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ErrorLevel = void 0;
4
+ /** Error Level */
5
+ var ErrorLevel;
6
+ (function (ErrorLevel) {
7
+ ErrorLevel[ErrorLevel["Ignore"] = 0] = "Ignore";
8
+ ErrorLevel[ErrorLevel["Warn"] = 1] = "Warn";
9
+ ErrorLevel[ErrorLevel["Error"] = 2] = "Error";
10
+ })(ErrorLevel || (exports.ErrorLevel = ErrorLevel = {}));
@@ -0,0 +1,30 @@
1
+ /** Esbuild Error */
2
+ export interface Error {
3
+ id: string;
4
+ pluginName: string;
5
+ text: string;
6
+ location: Location | null;
7
+ notes: Note[];
8
+ /**
9
+ * Optional user-specified data that is passed through unmodified. You can
10
+ * use this to stash the original error, for example.
11
+ */
12
+ detail: any;
13
+ }
14
+ interface Note {
15
+ text: string;
16
+ location: Location | null;
17
+ }
18
+ interface Location {
19
+ file: string;
20
+ namespace: string;
21
+ /** 1-based */
22
+ line: number;
23
+ /** 0-based, in bytes */
24
+ column: number;
25
+ /** in bytes */
26
+ length: number;
27
+ lineText: string;
28
+ suggestion: string;
29
+ }
30
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,14 @@
1
+ export * as Manifest from './manifest';
2
+ export * as Esbuild from './esbuild';
3
+ export * as Babel from './babel';
4
+ export * as Common from './common';
5
+ export * as Err from './error';
6
+ export * as Logger from './logger';
7
+ export * as SDK from './sdk';
8
+ export * as Modules from './modules';
9
+ export * as Linter from './linter';
10
+ export * as Rule from './rule';
11
+ export * as Thirdparty from './thirdparty';
12
+ export * as Client from './client';
13
+ export * as Constants from './constants';
14
+ export * as Plugin from './plugin';
package/dist/index.js ADDED
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.Plugin = exports.Constants = exports.Client = exports.Thirdparty = exports.Rule = exports.Linter = exports.Modules = exports.SDK = exports.Logger = exports.Err = exports.Common = exports.Babel = exports.Esbuild = exports.Manifest = void 0;
27
+ exports.Manifest = __importStar(require("./manifest"));
28
+ exports.Esbuild = __importStar(require("./esbuild"));
29
+ exports.Babel = __importStar(require("./babel"));
30
+ exports.Common = __importStar(require("./common"));
31
+ exports.Err = __importStar(require("./error"));
32
+ exports.Logger = __importStar(require("./logger"));
33
+ exports.SDK = __importStar(require("./sdk"));
34
+ exports.Modules = __importStar(require("./modules"));
35
+ exports.Linter = __importStar(require("./linter"));
36
+ exports.Rule = __importStar(require("./rule"));
37
+ exports.Thirdparty = __importStar(require("./thirdparty"));
38
+ exports.Client = __importStar(require("./client"));
39
+ exports.Constants = __importStar(require("./constants"));
40
+ exports.Plugin = __importStar(require("./plugin"));
@@ -0,0 +1,45 @@
1
+ import { RuleMessage, BaseRuleStoreData, RuleStoreDataItem } from '../rule';
2
+ import { ErrorLevel as Severity, Range, FixData } from '../error';
3
+ export { ErrorLevel as Severity } from '../error';
4
+ export type { Range, OffsetRange, Position, FixData } from '../error';
5
+ /** Diagnostic recommendations */
6
+ export interface Suggestion {
7
+ description: string;
8
+ fixData?: FixData;
9
+ }
10
+ /** Error file information */
11
+ export interface ReportDocument {
12
+ /** file path */
13
+ path: string;
14
+ /** Is it a transformed code */
15
+ isTransformed?: boolean;
16
+ /** code content */
17
+ content: string;
18
+ range: Range;
19
+ }
20
+ /** Report erroneous data */
21
+ export interface ReportData {
22
+ /** Error message */
23
+ message: string;
24
+ /** Error file information */
25
+ document?: ReportDocument;
26
+ /** Diagnostic suggestiions */
27
+ suggestions?: Suggestion;
28
+ /**
29
+ * Detailed information
30
+ * - Mainly additional data provided to the platform.
31
+ */
32
+ detail?: any;
33
+ }
34
+ export type ReportDetailData<T extends BaseRuleStoreData> = Omit<T, keyof BaseRuleStoreData> & {
35
+ /**
36
+ * Error text
37
+ * - When this is present, Diagnostic ['message'] will be overwritten
38
+ */
39
+ description?: string;
40
+ };
41
+ export interface Diagnostic extends ReportData, Pick<RuleMessage, 'category' | 'code'> {
42
+ severity: Severity;
43
+ title: string;
44
+ detail?: RuleStoreDataItem;
45
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Severity = void 0;
4
+ var error_1 = require("../error");
5
+ Object.defineProperty(exports, "Severity", { enumerable: true, get: function () { return error_1.ErrorLevel; } });
@@ -0,0 +1,2 @@
1
+ export * from './diagnostic';
2
+ export * from './rule';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./diagnostic"), exports);
18
+ __exportStar(require("./rule"), exports);