@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.
- package/LICENSE +21 -0
- package/README.md +15 -0
- package/dist/babel.d.ts +13 -0
- package/dist/babel.js +2 -0
- package/dist/client.d.ts +108 -0
- package/dist/client.js +29 -0
- package/dist/common.d.ts +26 -0
- package/dist/common.js +2 -0
- package/dist/constants.d.ts +16 -0
- package/dist/constants.js +36 -0
- package/dist/emo.d.ts +28 -0
- package/dist/emo.js +9 -0
- package/dist/error.d.ts +137 -0
- package/dist/error.js +10 -0
- package/dist/esbuild.d.ts +30 -0
- package/dist/esbuild.js +2 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +40 -0
- package/dist/linter/diagnostic.d.ts +45 -0
- package/dist/linter/diagnostic.js +5 -0
- package/dist/linter/index.d.ts +2 -0
- package/dist/linter/index.js +18 -0
- package/dist/linter/rule.d.ts +107 -0
- package/dist/linter/rule.js +2 -0
- package/dist/logger.d.ts +34 -0
- package/dist/logger.js +15 -0
- package/dist/manifest.d.ts +55 -0
- package/dist/manifest.js +17 -0
- package/dist/modules.d.ts +7 -0
- package/dist/modules.js +2 -0
- package/dist/plugin/baseCompiler.d.ts +20 -0
- package/dist/plugin/baseCompiler.js +2 -0
- package/dist/plugin/baseLoader.d.ts +71 -0
- package/dist/plugin/baseLoader.js +2 -0
- package/dist/plugin/baseStats.d.ts +114 -0
- package/dist/plugin/baseStats.js +2 -0
- package/dist/plugin/index.d.ts +4 -0
- package/dist/plugin/index.js +20 -0
- package/dist/plugin/plugin.d.ts +32 -0
- package/dist/plugin/plugin.js +2 -0
- package/dist/rule/code/E1001.d.ts +3 -0
- package/dist/rule/code/E1001.js +31 -0
- package/dist/rule/code/E1002.d.ts +3 -0
- package/dist/rule/code/E1002.js +31 -0
- package/dist/rule/code/E1003.d.ts +3 -0
- package/dist/rule/code/E1003.js +39 -0
- package/dist/rule/code/E1004.d.ts +3 -0
- package/dist/rule/code/E1004.js +15 -0
- package/dist/rule/code/index.d.ts +23 -0
- package/dist/rule/code/index.js +51 -0
- package/dist/rule/code/type.d.ts +27 -0
- package/dist/rule/code/type.js +23 -0
- package/dist/rule/data.d.ts +132 -0
- package/dist/rule/data.js +2 -0
- package/dist/rule/index.d.ts +2 -0
- package/dist/rule/index.js +18 -0
- package/dist/sdk/chunk.d.ts +125 -0
- package/dist/sdk/chunk.js +2 -0
- package/dist/sdk/config.d.ts +8 -0
- package/dist/sdk/config.js +2 -0
- package/dist/sdk/context.d.ts +23 -0
- package/dist/sdk/context.js +2 -0
- package/dist/sdk/envinfo.d.ts +19 -0
- package/dist/sdk/envinfo.js +2 -0
- package/dist/sdk/hooks.d.ts +13 -0
- package/dist/sdk/hooks.js +2 -0
- package/dist/sdk/index.d.ts +16 -0
- package/dist/sdk/index.js +32 -0
- package/dist/sdk/instance.d.ts +149 -0
- package/dist/sdk/instance.js +2 -0
- package/dist/sdk/loader.d.ts +64 -0
- package/dist/sdk/loader.js +2 -0
- package/dist/sdk/module.d.ts +303 -0
- package/dist/sdk/module.js +28 -0
- package/dist/sdk/package.d.ts +113 -0
- package/dist/sdk/package.js +2 -0
- package/dist/sdk/plugin.d.ts +21 -0
- package/dist/sdk/plugin.js +2 -0
- package/dist/sdk/process.d.ts +10 -0
- package/dist/sdk/process.js +2 -0
- package/dist/sdk/resolver.d.ts +52 -0
- package/dist/sdk/resolver.js +2 -0
- package/dist/sdk/result.d.ts +41 -0
- package/dist/sdk/result.js +2 -0
- package/dist/sdk/server/apis/alerts.d.ts +26 -0
- package/dist/sdk/server/apis/alerts.js +3 -0
- package/dist/sdk/server/apis/graph.d.ts +41 -0
- package/dist/sdk/server/apis/graph.js +3 -0
- package/dist/sdk/server/apis/index.d.ts +128 -0
- package/dist/sdk/server/apis/index.js +72 -0
- package/dist/sdk/server/apis/loader.d.ts +46 -0
- package/dist/sdk/server/apis/loader.js +3 -0
- package/dist/sdk/server/apis/pagination.d.ts +11 -0
- package/dist/sdk/server/apis/pagination.js +2 -0
- package/dist/sdk/server/apis/plugin.d.ts +19 -0
- package/dist/sdk/server/apis/plugin.js +3 -0
- package/dist/sdk/server/apis/project.d.ts +16 -0
- package/dist/sdk/server/apis/project.js +3 -0
- package/dist/sdk/server/apis/resolver.d.ts +18 -0
- package/dist/sdk/server/apis/resolver.js +3 -0
- package/dist/sdk/server/index.d.ts +23 -0
- package/dist/sdk/server/index.js +27 -0
- package/dist/sdk/statement.d.ts +177 -0
- package/dist/sdk/statement.js +147 -0
- package/dist/sdk/summary.d.ts +18 -0
- package/dist/sdk/summary.js +2 -0
- package/dist/sdk/treeShaking.d.ts +152 -0
- package/dist/sdk/treeShaking.js +2 -0
- package/dist/thirdparty.d.ts +2 -0
- package/dist/thirdparty.js +2 -0
- package/package.json +39 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import type { Configuration } from 'webpack';
|
|
2
|
+
import type { SourceMapConsumer, RawSourceMap } from 'source-map';
|
|
3
|
+
import { LoaderData } from './loader';
|
|
4
|
+
import { ResolverData } from './resolver';
|
|
5
|
+
import { PluginData } from './plugin';
|
|
6
|
+
import { BuilderStoreData, EMOStoreData, StoreData } from './result';
|
|
7
|
+
import { ModuleGraphInstance } from './module';
|
|
8
|
+
import { DoctorManifestClientRoutes, DoctorManifestWithShardingFiles } from '../manifest';
|
|
9
|
+
import { SummaryData } from './summary';
|
|
10
|
+
import { RuntimeContext, RuntimeContextOptions } from './context';
|
|
11
|
+
import { DoctorServerInstance } from './server';
|
|
12
|
+
import { PlainObject } from '../common';
|
|
13
|
+
import { EmoCheckData } from '../emo';
|
|
14
|
+
import { Hooks } from './hooks';
|
|
15
|
+
export type WriteStoreOptionsType = {};
|
|
16
|
+
export interface DoctorBuilderSDKInstance extends DoctorSDKInstance {
|
|
17
|
+
readonly server: DoctorServerInstance;
|
|
18
|
+
/** Report configuration information */
|
|
19
|
+
reportConfiguration(config: Configuration): void;
|
|
20
|
+
/** Report error message */
|
|
21
|
+
reportError(errors: Error[]): void;
|
|
22
|
+
/** Report error message */
|
|
23
|
+
reportLoader(data: LoaderData): void;
|
|
24
|
+
/** Report path request information */
|
|
25
|
+
reportResolver(data: ResolverData): void;
|
|
26
|
+
/** Report plugin information */
|
|
27
|
+
reportPlugin(data: PluginData): void;
|
|
28
|
+
/** Report module chart data */
|
|
29
|
+
reportModuleGraph(data: ModuleGraphInstance): void;
|
|
30
|
+
/** report the data of summary */
|
|
31
|
+
reportSummaryData(part: Partial<SummaryData>): void;
|
|
32
|
+
/** Report sourceMap data */
|
|
33
|
+
reportSourceMap(data: RawSourceMap): void;
|
|
34
|
+
/** report tile graph like webpack bundle analyzer data */
|
|
35
|
+
reportTileHtml(data: string): void;
|
|
36
|
+
getClientRoutes(): DoctorManifestClientRoutes[];
|
|
37
|
+
addClientRoutes(routes: DoctorManifestClientRoutes[]): void;
|
|
38
|
+
/** Application error modification */
|
|
39
|
+
applyErrorFix(id: number): Promise<void>;
|
|
40
|
+
/** Get build result data */
|
|
41
|
+
getStoreData(): BuilderStoreData;
|
|
42
|
+
/** Get build resource entry file */
|
|
43
|
+
getManifestData(): DoctorManifestWithShardingFiles;
|
|
44
|
+
/** Get rule context */
|
|
45
|
+
getRuleContext(options: RuntimeContextOptions): RuntimeContext;
|
|
46
|
+
/** Get SourceMap from cache */
|
|
47
|
+
getSourceMap(file: string): Promise<SourceMapConsumer | undefined>;
|
|
48
|
+
/** clear cache */
|
|
49
|
+
clearSourceMapCache(): void;
|
|
50
|
+
/** Clear all data */
|
|
51
|
+
clear(): void;
|
|
52
|
+
}
|
|
53
|
+
export interface DoctorEMOSDKInstance extends DoctorSDKInstance {
|
|
54
|
+
reportEmoData(data: EmoCheckData): void;
|
|
55
|
+
getStoreData(): EMOStoreData;
|
|
56
|
+
}
|
|
57
|
+
export interface DoctorSDKInstance {
|
|
58
|
+
readonly name: string;
|
|
59
|
+
readonly root: string;
|
|
60
|
+
readonly extraConfig: SDKOptionsType | undefined;
|
|
61
|
+
readonly hooks: Hooks;
|
|
62
|
+
/**
|
|
63
|
+
* folder of manifest
|
|
64
|
+
* - used to save the manifest.json and sharding files.
|
|
65
|
+
* @default ".rsdoctor"
|
|
66
|
+
*/
|
|
67
|
+
readonly outputDir: string;
|
|
68
|
+
/** manifest local path */
|
|
69
|
+
diskManifestPath: string;
|
|
70
|
+
/** start */
|
|
71
|
+
bootstrap(): Promise<void>;
|
|
72
|
+
dispose(): Promise<void>;
|
|
73
|
+
/** Change output path */
|
|
74
|
+
setOutputDir(outputDir: string): void;
|
|
75
|
+
/** Change build name */
|
|
76
|
+
setName(name: string): void;
|
|
77
|
+
setHash(hash: string): void;
|
|
78
|
+
/**
|
|
79
|
+
* write the manifest to a folder
|
|
80
|
+
* - use this.outputDir
|
|
81
|
+
* @returns the absolute path of manifest.json.
|
|
82
|
+
*/
|
|
83
|
+
saveManifest(storeData: PlainObject, options: WriteStoreOptionsType): Promise<string>;
|
|
84
|
+
}
|
|
85
|
+
export type SDKOptionsType = {
|
|
86
|
+
disableTOSUpload: boolean;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* @deprecated
|
|
90
|
+
*/
|
|
91
|
+
export interface DoctorSdkInstance {
|
|
92
|
+
readonly name: string;
|
|
93
|
+
readonly root: string;
|
|
94
|
+
readonly server: DoctorServerInstance;
|
|
95
|
+
/**
|
|
96
|
+
* folder of manifest
|
|
97
|
+
* - used to save the manifest.json and sharding files.
|
|
98
|
+
* @default ".rsdoctor"
|
|
99
|
+
*/
|
|
100
|
+
readonly outputDir: string;
|
|
101
|
+
/** manifest local path */
|
|
102
|
+
diskManifestPath: string;
|
|
103
|
+
/** start */
|
|
104
|
+
bootstrap(): Promise<void>;
|
|
105
|
+
/** Close */
|
|
106
|
+
dispose(): Promise<void>;
|
|
107
|
+
/** Clear all data */
|
|
108
|
+
clear(): void;
|
|
109
|
+
/** Change output path */
|
|
110
|
+
setOutputDir(outputDir: string): void;
|
|
111
|
+
/** Change build name */
|
|
112
|
+
setName(name: string): void;
|
|
113
|
+
/** Report configuration information */
|
|
114
|
+
reportConfiguration(config: Configuration): void;
|
|
115
|
+
/** Report error message */
|
|
116
|
+
reportError(errors: Error[]): void;
|
|
117
|
+
/** Report error message */
|
|
118
|
+
reportLoader(data: LoaderData): void;
|
|
119
|
+
/** Report path request information */
|
|
120
|
+
reportResolver(data: ResolverData): void;
|
|
121
|
+
/** Report plugin information */
|
|
122
|
+
reportPlugin(data: PluginData): void;
|
|
123
|
+
/** Report module chart data */
|
|
124
|
+
reportModuleGraph(data: ModuleGraphInstance): void;
|
|
125
|
+
/** report the data of summary */
|
|
126
|
+
reportSummaryData(part: Partial<SummaryData>): void;
|
|
127
|
+
/** Report sourceMap data */
|
|
128
|
+
reportSourceMap(data: RawSourceMap): void;
|
|
129
|
+
getClientRoutes(): DoctorManifestClientRoutes[];
|
|
130
|
+
addClientRoutes(routes: DoctorManifestClientRoutes[]): void;
|
|
131
|
+
/**
|
|
132
|
+
* write the manifest to a folder
|
|
133
|
+
* - use this.outputDir
|
|
134
|
+
* @returns the absolute path of manifest.json.
|
|
135
|
+
*/
|
|
136
|
+
writeStore(options?: WriteStoreOptionsType): Promise<string>;
|
|
137
|
+
/** Application error modification */
|
|
138
|
+
applyErrorFix(id: number): Promise<void>;
|
|
139
|
+
/** Get build result data */
|
|
140
|
+
getStoreData(): StoreData;
|
|
141
|
+
/** Get build resource entry file */
|
|
142
|
+
getManifestData(): DoctorManifestWithShardingFiles;
|
|
143
|
+
/** Get rule context */
|
|
144
|
+
getRuleContext(options: RuntimeContextOptions): RuntimeContext;
|
|
145
|
+
/** Get SourceMap from cache */
|
|
146
|
+
getSourceMap(file: string): Promise<SourceMapConsumer | undefined>;
|
|
147
|
+
/** clear cache */
|
|
148
|
+
clearSourceMapCache(): void;
|
|
149
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { PlainObject } from '../common';
|
|
2
|
+
import { DevToolErrorInstance } from '../error';
|
|
3
|
+
import { ProcessData } from './process';
|
|
4
|
+
/** Single Loader conversion data for processing files */
|
|
5
|
+
export interface LoaderTransformData extends ProcessData {
|
|
6
|
+
/** loader name */
|
|
7
|
+
loader: string;
|
|
8
|
+
/**
|
|
9
|
+
* loader index
|
|
10
|
+
*/
|
|
11
|
+
loaderIndex: number;
|
|
12
|
+
/** loader path */
|
|
13
|
+
path: string;
|
|
14
|
+
input: string | null;
|
|
15
|
+
/**
|
|
16
|
+
* - isPitch: true: the result of loader.pitch()
|
|
17
|
+
* - isPitch: false: the code result of loader()
|
|
18
|
+
*/
|
|
19
|
+
result: string | null;
|
|
20
|
+
/** Timestamp when called */
|
|
21
|
+
startAt: number;
|
|
22
|
+
endAt: number;
|
|
23
|
+
/** loader configuration */
|
|
24
|
+
options: PlainObject;
|
|
25
|
+
/** pitching loader */
|
|
26
|
+
isPitch: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* is sync
|
|
29
|
+
*/
|
|
30
|
+
sync: boolean;
|
|
31
|
+
/** Error during conversion */
|
|
32
|
+
errors: DevToolErrorInstance[];
|
|
33
|
+
}
|
|
34
|
+
/** Original file data */
|
|
35
|
+
export interface ResourceData {
|
|
36
|
+
/**
|
|
37
|
+
* Resource path
|
|
38
|
+
* @example '/abc/resource.js'
|
|
39
|
+
*/
|
|
40
|
+
path: string;
|
|
41
|
+
/**
|
|
42
|
+
* Resource parameters
|
|
43
|
+
* @example '?rrr'
|
|
44
|
+
*/
|
|
45
|
+
queryRaw: string;
|
|
46
|
+
/**
|
|
47
|
+
* Resource parameter object
|
|
48
|
+
* @example '{ abc: true }'
|
|
49
|
+
*/
|
|
50
|
+
query: PlainObject;
|
|
51
|
+
/**
|
|
52
|
+
* @example 'js'
|
|
53
|
+
* @example 'txt'
|
|
54
|
+
*/
|
|
55
|
+
ext: string;
|
|
56
|
+
}
|
|
57
|
+
/** File conversion process data */
|
|
58
|
+
export interface ResourceLoaderData {
|
|
59
|
+
/** File data */
|
|
60
|
+
resource: ResourceData;
|
|
61
|
+
/** Passing loader */
|
|
62
|
+
loaders: LoaderTransformData[];
|
|
63
|
+
}
|
|
64
|
+
export type LoaderData = ResourceLoaderData[];
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import type { Program } from 'estree';
|
|
2
|
+
import type { SourceMapConsumer } from 'source-map';
|
|
3
|
+
import type { NonFunctionProperties } from '../common';
|
|
4
|
+
import type { ChunkInstance } from './chunk';
|
|
5
|
+
import type { StatementInstance, StatementData } from './statement';
|
|
6
|
+
import type { PackageData } from './package';
|
|
7
|
+
import type { ModuleGraphModuleInstance, ModuleGraphModuleData, ExportData, ExportInstance, SideEffectData, SideEffectInstance, VariableData, VariableInstance } from './treeShaking';
|
|
8
|
+
export declare enum DependencyKind {
|
|
9
|
+
Unknown = 0,
|
|
10
|
+
ImportStatement = 1,
|
|
11
|
+
DynamicImport = 2,
|
|
12
|
+
RequireCall = 3,
|
|
13
|
+
AMDRequire = 4
|
|
14
|
+
}
|
|
15
|
+
/** Source code location */
|
|
16
|
+
export interface SourcePosition {
|
|
17
|
+
line?: number;
|
|
18
|
+
column?: number;
|
|
19
|
+
index?: number;
|
|
20
|
+
}
|
|
21
|
+
/** Source code range */
|
|
22
|
+
export interface SourceRange {
|
|
23
|
+
start: SourcePosition;
|
|
24
|
+
end?: SourcePosition;
|
|
25
|
+
}
|
|
26
|
+
/** Module size */
|
|
27
|
+
export interface ModuleSize {
|
|
28
|
+
sourceSize: number;
|
|
29
|
+
/** Code size after transformed */
|
|
30
|
+
transformedSize: number;
|
|
31
|
+
/**
|
|
32
|
+
* Code size after compiled
|
|
33
|
+
* - The size the module occupies in the product after packing.
|
|
34
|
+
*/
|
|
35
|
+
parsedSize: number;
|
|
36
|
+
}
|
|
37
|
+
/** Module source code */
|
|
38
|
+
export interface ModuleSource {
|
|
39
|
+
/** source code */
|
|
40
|
+
source: string;
|
|
41
|
+
/** transformed code */
|
|
42
|
+
transformed: string;
|
|
43
|
+
parsedSource: string;
|
|
44
|
+
}
|
|
45
|
+
/** Module Metadata */
|
|
46
|
+
export interface ModuleBuildMeta {
|
|
47
|
+
/**
|
|
48
|
+
* Whether to include the esModule flag statement
|
|
49
|
+
* ```js
|
|
50
|
+
* Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
+
* ```
|
|
52
|
+
* - This statement usually appears in the object code of the tsc to cjs module.
|
|
53
|
+
*/
|
|
54
|
+
hasSetEsModuleStatement: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Strict ESM module.
|
|
57
|
+
*/
|
|
58
|
+
strictHarmonyModule: boolean;
|
|
59
|
+
packageData?: PackageData;
|
|
60
|
+
}
|
|
61
|
+
/** Module type */
|
|
62
|
+
export declare enum ModuleKind {
|
|
63
|
+
/** Normal module */
|
|
64
|
+
Normal = 0,
|
|
65
|
+
/** Aggregation module */
|
|
66
|
+
Concatenation = 1
|
|
67
|
+
}
|
|
68
|
+
export declare enum ToDataType {
|
|
69
|
+
/** Normal mode */
|
|
70
|
+
Normal = 0,
|
|
71
|
+
/** Lite mode */
|
|
72
|
+
Lite = 1,
|
|
73
|
+
/** Lite & No Assets Code mode */
|
|
74
|
+
LiteAndNoAsset = 2
|
|
75
|
+
}
|
|
76
|
+
export interface ModuleInstance {
|
|
77
|
+
/** Module identifier */
|
|
78
|
+
readonly id: number;
|
|
79
|
+
/** webpack identifier */
|
|
80
|
+
readonly webpackId: string;
|
|
81
|
+
/** Module path */
|
|
82
|
+
readonly path: string;
|
|
83
|
+
readonly isEntry: boolean;
|
|
84
|
+
readonly kind: ModuleKind;
|
|
85
|
+
/** Root module in aggregate module */
|
|
86
|
+
readonly rootModule?: ModuleInstance;
|
|
87
|
+
/**
|
|
88
|
+
* Preference to source location
|
|
89
|
+
* - Indicates that the source code is not empty and there is source code location mapping data.
|
|
90
|
+
*/
|
|
91
|
+
isPreferSource: boolean;
|
|
92
|
+
/** Build properties */
|
|
93
|
+
meta: ModuleBuildMeta;
|
|
94
|
+
/** Get the Chunks instance where the module in.*/
|
|
95
|
+
getChunks(): ChunkInstance[];
|
|
96
|
+
/** Add Chunk instance */
|
|
97
|
+
addChunk(chunk: ChunkInstance): void;
|
|
98
|
+
removeChunk(chunk: ChunkInstance): void;
|
|
99
|
+
getDependencies(): DependencyInstance[];
|
|
100
|
+
getDependencyByRequest(request: string): DependencyInstance | undefined;
|
|
101
|
+
/** Get dependency data from module */
|
|
102
|
+
getDependencyByModule(module: ModuleInstance): DependencyInstance | undefined;
|
|
103
|
+
removeDependency(dependency: DependencyInstance): void;
|
|
104
|
+
/** Remove dependency data from module */
|
|
105
|
+
removeDependencyByModule(module: ModuleInstance): void;
|
|
106
|
+
removeImported(module: ModuleInstance): void;
|
|
107
|
+
getImported(): ModuleInstance[];
|
|
108
|
+
addImported(module: ModuleInstance): void;
|
|
109
|
+
addDependency(request: string, module: ModuleInstance, kind: DependencyKind, statements?: StatementInstance[]): DependencyInstance | undefined;
|
|
110
|
+
toData(contextPath?: string): ModuleData;
|
|
111
|
+
setSource(source: Partial<ModuleSource>): void;
|
|
112
|
+
getSource(): ModuleSource;
|
|
113
|
+
/**Set code AST after transform */
|
|
114
|
+
setProgram(program: Program): void;
|
|
115
|
+
/** Get the converted code AST */
|
|
116
|
+
getProgram(): Program | undefined;
|
|
117
|
+
/** Set module size information */
|
|
118
|
+
setSize(size: Partial<ModuleSize>): void;
|
|
119
|
+
getSize(): ModuleSize;
|
|
120
|
+
setSourceMap(sourcemap: SourceMapConsumer): void;
|
|
121
|
+
/** Get source code mapping */
|
|
122
|
+
getSourceMap(): SourceMapConsumer | undefined;
|
|
123
|
+
/**
|
|
124
|
+
* Generate statement instances
|
|
125
|
+
* @param transformed {SourceRange} The location of the transformed code.
|
|
126
|
+
*/
|
|
127
|
+
getStatement(transformed: SourceRange): StatementInstance | undefined;
|
|
128
|
+
/**
|
|
129
|
+
* Generate original code location
|
|
130
|
+
* @param transformed {SourceRange} The location of the transformed code.
|
|
131
|
+
*/
|
|
132
|
+
getSourceRange(transformed: SourceRange): SourceRange | undefined;
|
|
133
|
+
/** Add connected submodules */
|
|
134
|
+
addNormalModule(module: ModuleInstance): void;
|
|
135
|
+
/** If it is currently a connection module, return all connected base subpackages */
|
|
136
|
+
getNormalModules(): ModuleInstance[];
|
|
137
|
+
/** Added aggregation module */
|
|
138
|
+
addConcatenationModule(module: ModuleInstance): void;
|
|
139
|
+
/** Get all aggregated modules to which the current module belongs */
|
|
140
|
+
getConcatenationModules(): ModuleInstance[];
|
|
141
|
+
}
|
|
142
|
+
/** Depends on Metadata */
|
|
143
|
+
export interface DependencyBuildMeta {
|
|
144
|
+
/**
|
|
145
|
+
* Types of dependencies between modules
|
|
146
|
+
* - The basis for webpack to add runtime to modules.
|
|
147
|
+
*
|
|
148
|
+
* @link https://github.com/webpack/webpack/blob/v5.75.0/lib/Module.js#L428
|
|
149
|
+
* @link https://github.com/webpack/webpack/blob/v4.46.0/lib/RuntimeTemplate.js#L215
|
|
150
|
+
*/
|
|
151
|
+
exportsType: 'namespace' | 'default-only' | 'default-with-named' | 'dynamic';
|
|
152
|
+
}
|
|
153
|
+
export interface DependencyInstance {
|
|
154
|
+
/** Identifier */
|
|
155
|
+
readonly id: number;
|
|
156
|
+
/**
|
|
157
|
+
* Original request
|
|
158
|
+
* - refers to the original request in the import statement
|
|
159
|
+
* - @example `import {Instance} from'chalk'` in the statement 'chalk'
|
|
160
|
+
*/
|
|
161
|
+
readonly request: string;
|
|
162
|
+
/** actual requested path */
|
|
163
|
+
readonly resolvedRequest: string;
|
|
164
|
+
/** Module */
|
|
165
|
+
readonly module: ModuleInstance;
|
|
166
|
+
/**
|
|
167
|
+
* Dependency Module
|
|
168
|
+
* - Always non-aggregated modules
|
|
169
|
+
*/
|
|
170
|
+
readonly dependency: ModuleInstance;
|
|
171
|
+
/**
|
|
172
|
+
* Original dependency module
|
|
173
|
+
* - Aggregation module preferred
|
|
174
|
+
*/
|
|
175
|
+
readonly originDependency: ModuleInstance;
|
|
176
|
+
/**
|
|
177
|
+
* Citation method
|
|
178
|
+
* - Numeric enumeration
|
|
179
|
+
*/
|
|
180
|
+
readonly kind: DependencyKind;
|
|
181
|
+
/**
|
|
182
|
+
* Citation method
|
|
183
|
+
* - string enumeration
|
|
184
|
+
*/
|
|
185
|
+
readonly kindString: keyof typeof DependencyKind;
|
|
186
|
+
/** Whether to connect to the aggregation module */
|
|
187
|
+
readonly resolveConcatenationModule: boolean;
|
|
188
|
+
/** quote statement */
|
|
189
|
+
readonly statements: StatementInstance[];
|
|
190
|
+
/** build attribute */
|
|
191
|
+
meta: DependencyBuildMeta;
|
|
192
|
+
/** Generate data */
|
|
193
|
+
toData(): DependencyData;
|
|
194
|
+
/** Add statement */
|
|
195
|
+
addStatement(statement: StatementInstance): void;
|
|
196
|
+
/** Whether this statement is included */
|
|
197
|
+
hasStatement(statement: StatementInstance): boolean;
|
|
198
|
+
/**
|
|
199
|
+
* Is it the same dependency?
|
|
200
|
+
* - Check properties other than id and statements
|
|
201
|
+
*/
|
|
202
|
+
isSameWithoutStatements(dep: DependencyInstance): boolean;
|
|
203
|
+
}
|
|
204
|
+
export type ModuleGraphToDataArgs = {
|
|
205
|
+
contextPath: string;
|
|
206
|
+
};
|
|
207
|
+
export interface ModuleGraphInstance {
|
|
208
|
+
/** Clear data */
|
|
209
|
+
clear(): void;
|
|
210
|
+
/** How many modules are there in total */
|
|
211
|
+
size(): number;
|
|
212
|
+
/** overwrite data */
|
|
213
|
+
fromInstance(data: ModuleGraphInstance): void;
|
|
214
|
+
/** Create module connection data */
|
|
215
|
+
addModuleGraphModule(info: ModuleGraphModuleInstance): void;
|
|
216
|
+
/** Get module connection data */
|
|
217
|
+
getModuleGraphModule(module: ModuleInstance): ModuleGraphModuleInstance;
|
|
218
|
+
/** Get all module connection data */
|
|
219
|
+
getModuleGraphModules(): ModuleGraphModuleInstance[];
|
|
220
|
+
/** Get all modules */
|
|
221
|
+
getModules(): ModuleInstance[];
|
|
222
|
+
/** Get all modules */
|
|
223
|
+
getDependencies(): DependencyInstance[];
|
|
224
|
+
/** Get connection by id */
|
|
225
|
+
getDependencyById(id: number): DependencyInstance | undefined;
|
|
226
|
+
/** Get entrance module */
|
|
227
|
+
getEntryModules(): ModuleInstance[];
|
|
228
|
+
/** Get the subgraph of the current node as the entry point */
|
|
229
|
+
getSubGraphByModule(module: ModuleInstance): ModuleInstance[];
|
|
230
|
+
/** Get module by id */
|
|
231
|
+
getModuleById(id: number): ModuleInstance | undefined;
|
|
232
|
+
/** get module by webpackId */
|
|
233
|
+
getModuleByWebpackId(webpackId: string): ModuleInstance | undefined;
|
|
234
|
+
/** Get module by path */
|
|
235
|
+
getModuleByFile(file: string): ModuleInstance | undefined;
|
|
236
|
+
/** Add Module */
|
|
237
|
+
addModule(module: ModuleInstance): void;
|
|
238
|
+
/** Add module connection */
|
|
239
|
+
addDependency(module: DependencyInstance): void;
|
|
240
|
+
/**
|
|
241
|
+
* Remove module
|
|
242
|
+
* - The connection relationship of this module will also be removed
|
|
243
|
+
*/
|
|
244
|
+
removeModule(module: ModuleInstance): void;
|
|
245
|
+
/**
|
|
246
|
+
* Remove connection
|
|
247
|
+
* - If one of the connected endpoints is an independent module, this module will also be removed from the module diagram
|
|
248
|
+
*/
|
|
249
|
+
removeDependency(dependency: DependencyInstance): void;
|
|
250
|
+
/** Add export data */
|
|
251
|
+
addExportInfo(data: ExportInstance): void;
|
|
252
|
+
/** Add side effect data */
|
|
253
|
+
addSideEffect(data: SideEffectInstance): void;
|
|
254
|
+
/** Add variable data */
|
|
255
|
+
addVariable(data: VariableInstance): void;
|
|
256
|
+
/** Generate data */
|
|
257
|
+
toData(configs?: ModuleGraphToDataArgs): ModuleGraphData;
|
|
258
|
+
/** Generate data */
|
|
259
|
+
toCodeData(): ModuleCodeData;
|
|
260
|
+
}
|
|
261
|
+
export interface ModuleData extends Omit<NonFunctionProperties<ModuleInstance>, 'rootModule' | 'isEntry' | 'concatenationModules' | 'meta'> {
|
|
262
|
+
/** chunk identifier */
|
|
263
|
+
chunks: string[];
|
|
264
|
+
/** Module identifier on which the module depends */
|
|
265
|
+
dependencies: number[];
|
|
266
|
+
/** Identifier of the dependent module */
|
|
267
|
+
imported: number[];
|
|
268
|
+
/** Is it an entrance module */
|
|
269
|
+
isEntry?: boolean | undefined;
|
|
270
|
+
/** Use source code location first */
|
|
271
|
+
isPreferSource: boolean;
|
|
272
|
+
/** Module size */
|
|
273
|
+
size: ModuleSize;
|
|
274
|
+
/** Connected base subpackage */
|
|
275
|
+
modules?: number[];
|
|
276
|
+
/** root module number */
|
|
277
|
+
rootModule?: number;
|
|
278
|
+
/** Affiliated aggregation module number */
|
|
279
|
+
concatenationModules?: number[];
|
|
280
|
+
/** Module Id */
|
|
281
|
+
webpackId: string;
|
|
282
|
+
/** Build original attributes */
|
|
283
|
+
meta?: Partial<Omit<ModuleBuildMeta, 'packageData'>>;
|
|
284
|
+
}
|
|
285
|
+
export type ModuleCodeData = Record<number, ModuleSource>;
|
|
286
|
+
export interface DependencyData extends Omit<NonFunctionProperties<DependencyInstance>, 'module' | 'dependency' | 'statements' | 'originDependency' | 'kindString' | 'resolveConcatenationModule' | 'meta'> {
|
|
287
|
+
/** Module Identifier */
|
|
288
|
+
module: number;
|
|
289
|
+
/** Dependency Module Identifier */
|
|
290
|
+
dependency: number;
|
|
291
|
+
/** Original module identifier */
|
|
292
|
+
originDependency: number;
|
|
293
|
+
/** quote statement */
|
|
294
|
+
statements: StatementData[];
|
|
295
|
+
}
|
|
296
|
+
export interface ModuleGraphData {
|
|
297
|
+
dependencies: DependencyData[];
|
|
298
|
+
modules: ModuleData[];
|
|
299
|
+
moduleGraphModules: ModuleGraphModuleData[];
|
|
300
|
+
exports: ExportData[];
|
|
301
|
+
sideEffects: SideEffectData[];
|
|
302
|
+
variables: VariableData[];
|
|
303
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ToDataType = exports.ModuleKind = exports.DependencyKind = void 0;
|
|
4
|
+
var DependencyKind;
|
|
5
|
+
(function (DependencyKind) {
|
|
6
|
+
DependencyKind[DependencyKind["Unknown"] = 0] = "Unknown";
|
|
7
|
+
DependencyKind[DependencyKind["ImportStatement"] = 1] = "ImportStatement";
|
|
8
|
+
DependencyKind[DependencyKind["DynamicImport"] = 2] = "DynamicImport";
|
|
9
|
+
DependencyKind[DependencyKind["RequireCall"] = 3] = "RequireCall";
|
|
10
|
+
DependencyKind[DependencyKind["AMDRequire"] = 4] = "AMDRequire";
|
|
11
|
+
})(DependencyKind || (exports.DependencyKind = DependencyKind = {}));
|
|
12
|
+
/** Module type */
|
|
13
|
+
var ModuleKind;
|
|
14
|
+
(function (ModuleKind) {
|
|
15
|
+
/** Normal module */
|
|
16
|
+
ModuleKind[ModuleKind["Normal"] = 0] = "Normal";
|
|
17
|
+
/** Aggregation module */
|
|
18
|
+
ModuleKind[ModuleKind["Concatenation"] = 1] = "Concatenation";
|
|
19
|
+
})(ModuleKind || (exports.ModuleKind = ModuleKind = {}));
|
|
20
|
+
var ToDataType;
|
|
21
|
+
(function (ToDataType) {
|
|
22
|
+
/** Normal mode */
|
|
23
|
+
ToDataType[ToDataType["Normal"] = 0] = "Normal";
|
|
24
|
+
/** Lite mode */
|
|
25
|
+
ToDataType[ToDataType["Lite"] = 1] = "Lite";
|
|
26
|
+
/** Lite & No Assets Code mode */
|
|
27
|
+
ToDataType[ToDataType["LiteAndNoAsset"] = 2] = "LiteAndNoAsset";
|
|
28
|
+
})(ToDataType || (exports.ToDataType = ToDataType = {}));
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { ModuleInstance, DependencyInstance, ModuleSize } from './module';
|
|
2
|
+
import type { NonFunctionProperties } from '../common';
|
|
3
|
+
export interface PackageJSONData {
|
|
4
|
+
/** package name */
|
|
5
|
+
name: string;
|
|
6
|
+
version: string;
|
|
7
|
+
}
|
|
8
|
+
export interface PackageBasicData extends PackageJSONData {
|
|
9
|
+
/** Directory where the package is located */
|
|
10
|
+
root: string;
|
|
11
|
+
}
|
|
12
|
+
export interface PackageInstance extends PackageBasicData {
|
|
13
|
+
id: number;
|
|
14
|
+
/** Get all modules contained in the package */
|
|
15
|
+
getModules(): ModuleInstance[];
|
|
16
|
+
/** Get all dependencies */
|
|
17
|
+
getDependencies(): PackageDependencyInstance[];
|
|
18
|
+
/** Get the dependency chain of the current package */
|
|
19
|
+
getDependenciesChain(graph: PackageGraphInstance): PackageDependencyInstance[];
|
|
20
|
+
/** Get all dependencies */
|
|
21
|
+
getImported(): PackageInstance[];
|
|
22
|
+
addModule(module: ModuleInstance): void;
|
|
23
|
+
/** Add package dependencies */
|
|
24
|
+
addDependency(dep: PackageDependencyInstance): void;
|
|
25
|
+
/** Add dependency */
|
|
26
|
+
addImported(pkg: PackageInstance): void;
|
|
27
|
+
/** Whether this path is included */
|
|
28
|
+
contain(path: string): boolean;
|
|
29
|
+
/** Is it the same package */
|
|
30
|
+
isSame(pkg: PackageInstance): boolean;
|
|
31
|
+
/** Get package size */
|
|
32
|
+
getSize(): ModuleSize;
|
|
33
|
+
/** Get data */
|
|
34
|
+
toData(): PackageData;
|
|
35
|
+
}
|
|
36
|
+
export interface PackageData extends NonFunctionProperties<PackageInstance> {
|
|
37
|
+
modules: number[];
|
|
38
|
+
size: ModuleSize;
|
|
39
|
+
}
|
|
40
|
+
export interface PackageDependencyInstance {
|
|
41
|
+
/** Number */
|
|
42
|
+
id: number;
|
|
43
|
+
/** Dependency package */
|
|
44
|
+
dependency: PackageInstance;
|
|
45
|
+
/**
|
|
46
|
+
* Current package
|
|
47
|
+
* - This item is local package data when using user code
|
|
48
|
+
*/
|
|
49
|
+
package: PackageInstance;
|
|
50
|
+
/** Module dependency where the dependency statement is located */
|
|
51
|
+
refDependency: DependencyInstance;
|
|
52
|
+
/** Is it the same reference */
|
|
53
|
+
isSame(dep: PackageDependencyInstance): boolean;
|
|
54
|
+
/** Get data */
|
|
55
|
+
toData(): PackageDependencyData;
|
|
56
|
+
}
|
|
57
|
+
export interface PackageDependencyData extends Omit<NonFunctionProperties<PackageDependencyInstance>, 'dependency' | 'package' | 'refDependency'> {
|
|
58
|
+
dependency: number;
|
|
59
|
+
package: number;
|
|
60
|
+
refDependency: number;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get the contents of the package.json file
|
|
64
|
+
* @param {string} Relative project root directory path
|
|
65
|
+
*/
|
|
66
|
+
export type GetPackageFile = (path: string) => PackageJSONData | undefined;
|
|
67
|
+
export interface PackageGraphInstance {
|
|
68
|
+
/**
|
|
69
|
+
* Get all package data
|
|
70
|
+
*/
|
|
71
|
+
getPackages(): PackageInstance[];
|
|
72
|
+
/**
|
|
73
|
+
* Get package data from module
|
|
74
|
+
* The new package will create new data and join the cache
|
|
75
|
+
* - If created, old data will be returned
|
|
76
|
+
*/
|
|
77
|
+
getPackageByModule(module: ModuleInstance, readFile?: GetPackageFile): PackageInstance | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* Get package data from file
|
|
80
|
+
* - No new data will be created
|
|
81
|
+
*/
|
|
82
|
+
getPackageByFile(file: string): PackageInstance | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* Get package data from data
|
|
85
|
+
* - No new data will be created
|
|
86
|
+
*/
|
|
87
|
+
getPackageByData(data: PackageBasicData): PackageInstance | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* Get package data from name
|
|
90
|
+
*/
|
|
91
|
+
getPackagesByName(name: string): PackageInstance[];
|
|
92
|
+
/**
|
|
93
|
+
* Get dependencies from package
|
|
94
|
+
* - The input package is dependent
|
|
95
|
+
*/
|
|
96
|
+
getDependenciesFromPackage(pkg: PackageInstance): PackageDependencyInstance[];
|
|
97
|
+
/** Get package dependencies imported from user code */
|
|
98
|
+
getDependenciesFromOrigin(): PackageDependencyInstance[];
|
|
99
|
+
/** Add package data */
|
|
100
|
+
addPackage(pkg: PackageInstance): void;
|
|
101
|
+
/** Add dependency data */
|
|
102
|
+
addDependency(dep: PackageDependencyInstance): void;
|
|
103
|
+
/** Get duplicate package data */
|
|
104
|
+
getDuplicatePackages(): PackageInstance[][];
|
|
105
|
+
toData(): PackageGraphData;
|
|
106
|
+
}
|
|
107
|
+
export interface PackageGraphData {
|
|
108
|
+
packages: PackageData[];
|
|
109
|
+
dependencies: PackageDependencyData[];
|
|
110
|
+
}
|
|
111
|
+
export interface OtherReports {
|
|
112
|
+
tileReportHtml?: string;
|
|
113
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DevToolErrorInstance } from '../error';
|
|
2
|
+
export interface PluginHookData {
|
|
3
|
+
/** hook tap name */
|
|
4
|
+
tapName: string;
|
|
5
|
+
/** hook call time-consuming */
|
|
6
|
+
costs: number;
|
|
7
|
+
startAt: number;
|
|
8
|
+
endAt: number;
|
|
9
|
+
/** hook function type */
|
|
10
|
+
type: 'sync' | 'async' | 'promise';
|
|
11
|
+
/** hook function result */
|
|
12
|
+
result: any;
|
|
13
|
+
/** hook function running error */
|
|
14
|
+
error: DevToolErrorInstance[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Plugin data
|
|
18
|
+
* - Key name Hook name
|
|
19
|
+
* - Key value is the hook data array
|
|
20
|
+
*/
|
|
21
|
+
export type PluginData = Record<string, PluginHookData[]>;
|