@irrelon/battlescript 3.2.6 → 4.0.1
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/bin/functionality.ts +16 -3
- package/bin/index.js +3767 -2232
- package/bin/index.js.map +1 -1
- package/dist/bin/functionality.cjs +43245 -0
- package/dist/bin/functionality.cjs.map +1 -0
- package/dist/bin/functionality.d.ts +5 -0
- package/dist/bin/functionality.d.ts.map +1 -1
- package/dist/bin/functionality.js +3769 -2234
- package/dist/bin/functionality.js.map +1 -1
- package/dist/exports/index.d.ts +0 -1
- package/dist/exports/index.d.ts.map +1 -1
- package/dist/exports/typescript/enums/EnumNodeKind.d.ts +50 -46
- package/dist/exports/typescript/enums/EnumNodeKind.d.ts.map +1 -1
- package/dist/exports/typescript/enums/EnumNodeProp.d.ts +54 -46
- package/dist/exports/typescript/enums/EnumNodeProp.d.ts.map +1 -1
- package/dist/exports/typescript/helpers/miniAstLayout.d.ts.map +1 -1
- package/dist/index.cjs +4280 -2448
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +4237 -2422
- package/dist/index.mjs.map +1 -1
- package/dist/scripts/exportGen/enums/generateEnums.d.ts.map +1 -1
- package/dist/services/fullAst/BattleScriptFromAST.d.ts +6 -2
- package/dist/services/fullAst/BattleScriptFromAST.d.ts.map +1 -1
- package/dist/services/fullAst/BattleScriptToAST.d.ts +10 -3
- package/dist/services/fullAst/BattleScriptToAST.d.ts.map +1 -1
- package/dist/services/grammar/ts/language/BattleScriptLexer.d.ts +102 -101
- package/dist/services/grammar/ts/language/BattleScriptLexer.d.ts.map +1 -1
- package/dist/services/grammar/ts/language/BattleScriptListener.d.ts +59 -15
- package/dist/services/grammar/ts/language/BattleScriptListener.d.ts.map +1 -1
- package/dist/services/grammar/ts/language/BattleScriptParser.d.ts +276 -213
- package/dist/services/grammar/ts/language/BattleScriptParser.d.ts.map +1 -1
- package/dist/services/grammar/ts/language/BattleScriptVisitor.d.ts +37 -9
- package/dist/services/grammar/ts/language/BattleScriptVisitor.d.ts.map +1 -1
- package/dist/services/index.d.ts +2 -0
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/miniAst/BattleScriptToMiniAST.d.ts +8 -0
- package/dist/services/miniAst/BattleScriptToMiniAST.d.ts.map +1 -1
- package/dist/services/miniAst/binaryReader.d.ts.map +1 -1
- package/dist/services/miniAst/binaryWriter.d.ts.map +1 -1
- package/dist/services/miniAst/index.d.ts +0 -1
- package/dist/services/miniAst/index.d.ts.map +1 -1
- package/dist/services/miniAst/miniAstLayout.d.ts.map +1 -1
- package/dist/services/moduleResolver.d.ts +151 -0
- package/dist/services/moduleResolver.d.ts.map +1 -0
- package/dist/services/treeShaker/DependencyAnalyzer.d.ts +38 -0
- package/dist/services/treeShaker/DependencyAnalyzer.d.ts.map +1 -0
- package/dist/services/treeShaker/EntryPointCollector.d.ts +17 -0
- package/dist/services/treeShaker/EntryPointCollector.d.ts.map +1 -0
- package/dist/services/treeShaker/TreeShaker.d.ts +17 -0
- package/dist/services/treeShaker/TreeShaker.d.ts.map +1 -0
- package/dist/services/treeShaker/index.d.ts +6 -0
- package/dist/services/treeShaker/index.d.ts.map +1 -0
- package/dist/services/treeShaker/treeShake.d.ts +12 -0
- package/dist/services/treeShaker/treeShake.d.ts.map +1 -0
- package/dist/services/treeShaker/types.d.ts +50 -0
- package/dist/services/treeShaker/types.d.ts.map +1 -0
- package/dist/tests/ast/export.test.d.ts +2 -0
- package/dist/tests/ast/export.test.d.ts.map +1 -0
- package/dist/tests/ast/import.test.d.ts +2 -0
- package/dist/tests/ast/import.test.d.ts.map +1 -0
- package/dist/tests/ast/moduleResolver.test.d.ts +2 -0
- package/dist/tests/ast/moduleResolver.test.d.ts.map +1 -0
- package/dist/tests/ast/tree-shaking.test.d.ts +2 -0
- package/dist/tests/ast/tree-shaking.test.d.ts.map +1 -0
- package/dist/tsconfig.types.tsbuildinfo +1 -1
- package/dist/types/BattleScriptTransformerOptions.d.ts +1 -0
- package/dist/types/BattleScriptTransformerOptions.d.ts.map +1 -1
- package/dist/types/MiniAstJson.d.ts +18 -1
- package/dist/types/MiniAstJson.d.ts.map +1 -1
- package/dist/types/TokenMetaData.d.ts +2 -0
- package/dist/types/TokenMetaData.d.ts.map +1 -1
- package/dist/types/ast/nodes/AstNode.d.ts +2 -2
- package/dist/types/ast/nodes/AstNode.d.ts.map +1 -1
- package/dist/types/ast/nodes/AstNodeBase.d.ts +2 -0
- package/dist/types/ast/nodes/AstNodeBase.d.ts.map +1 -1
- package/dist/types/ast/nodes/ConstantDeclarationNode.d.ts +2 -1
- package/dist/types/ast/nodes/ConstantDeclarationNode.d.ts.map +1 -1
- package/dist/types/ast/nodes/EndStatementNode.d.ts +1 -0
- package/dist/types/ast/nodes/EndStatementNode.d.ts.map +1 -1
- package/dist/types/ast/nodes/EnumDeclarationNode.d.ts +2 -1
- package/dist/types/ast/nodes/EnumDeclarationNode.d.ts.map +1 -1
- package/dist/types/ast/nodes/ExportNamedDeclarationNode.d.ts +32 -0
- package/dist/types/ast/nodes/ExportNamedDeclarationNode.d.ts.map +1 -0
- package/dist/types/ast/nodes/ExportSpecifierNode.d.ts +27 -0
- package/dist/types/ast/nodes/ExportSpecifierNode.d.ts.map +1 -0
- package/dist/types/ast/nodes/FunctionDeclarationNode.d.ts +2 -1
- package/dist/types/ast/nodes/FunctionDeclarationNode.d.ts.map +1 -1
- package/dist/types/ast/nodes/FunctionDefinitionNode.d.ts +2 -1
- package/dist/types/ast/nodes/FunctionDefinitionNode.d.ts.map +1 -1
- package/dist/types/ast/nodes/ImportDeclarationNode.d.ts +4 -2
- package/dist/types/ast/nodes/ImportDeclarationNode.d.ts.map +1 -1
- package/dist/types/ast/nodes/ImportSpecifierNode.d.ts +27 -0
- package/dist/types/ast/nodes/ImportSpecifierNode.d.ts.map +1 -0
- package/dist/types/ast/nodes/IncludeStatementNode.d.ts +13 -0
- package/dist/types/ast/nodes/IncludeStatementNode.d.ts.map +1 -0
- package/dist/types/ast/nodes/InterfaceNode.d.ts +2 -1
- package/dist/types/ast/nodes/InterfaceNode.d.ts.map +1 -1
- package/dist/types/ast/nodes/OffsetStatementNode.d.ts.map +1 -1
- package/dist/types/ast/nodes/ParityDeclarationNode.d.ts +12 -0
- package/dist/types/ast/nodes/ParityDeclarationNode.d.ts.map +1 -0
- package/dist/types/ast/nodes/ProtocolOpStatementNode.d.ts +1 -1
- package/dist/types/ast/nodes/ProtocolOpStatementNode.d.ts.map +1 -1
- package/dist/types/ast/nodes/ProtocolReadTypeNode.d.ts +1 -1
- package/dist/types/ast/nodes/ProtocolReadTypeNode.d.ts.map +1 -1
- package/dist/types/ast/nodes/RootNode.d.ts +1 -0
- package/dist/types/ast/nodes/RootNode.d.ts.map +1 -1
- package/dist/types/ast/nodes/RuleStatementNode.d.ts +4 -4
- package/dist/types/ast/nodes/RuleStatementNode.d.ts.map +1 -1
- package/dist/types/ast/nodes/StateDeclarationNode.d.ts +2 -1
- package/dist/types/ast/nodes/StateDeclarationNode.d.ts.map +1 -1
- package/dist/types/ast/nodes/VariableDeclarationNode.d.ts +2 -1
- package/dist/types/ast/nodes/VariableDeclarationNode.d.ts.map +1 -1
- package/dist/types/ast/nodes/index.d.ts +5 -1
- package/dist/types/ast/nodes/index.d.ts.map +1 -1
- package/package.json +77 -72
- package/dist/exports/typescript/enums/EnumOpCode.d.ts +0 -28
- package/dist/exports/typescript/enums/EnumOpCode.d.ts.map +0 -1
- package/dist/scripts/exportGen/enums/opCodes.d.ts +0 -2
- package/dist/scripts/exportGen/enums/opCodes.d.ts.map +0 -1
- package/dist/services/miniAst/miniAstInterpreter.d.ts +0 -17
- package/dist/services/miniAst/miniAstInterpreter.d.ts.map +0 -1
- package/dist/types/ast/nodes/EventDeclarationNode.d.ts +0 -15
- package/dist/types/ast/nodes/EventDeclarationNode.d.ts.map +0 -1
- package/dist/types/ast/nodes/ParityStatementNode.d.ts +0 -12
- package/dist/types/ast/nodes/ParityStatementNode.d.ts.map +0 -1
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Module Resolver Service
|
|
3
|
+
*
|
|
4
|
+
* Handles ES module-style import/export resolution for BattleScript.
|
|
5
|
+
* Supports:
|
|
6
|
+
* - Named imports with aliasing: import {foo, bar as baz} from "./module"
|
|
7
|
+
* - Named exports: export {foo, bar} and export {foo as bar}
|
|
8
|
+
* - Inline exports: export int a = 1;
|
|
9
|
+
* - Re-exports: export {foo, bar} from "./other"
|
|
10
|
+
* - Circular dependency resolution via static hoisting
|
|
11
|
+
* - Module deduplication (diamond dependency pattern)
|
|
12
|
+
*/
|
|
13
|
+
import type { AstNode, RootNode } from "@/types";
|
|
14
|
+
/** Information about an exported symbol */
|
|
15
|
+
export interface ExportedSymbol {
|
|
16
|
+
/** Name used locally in the module */
|
|
17
|
+
localName: string;
|
|
18
|
+
/** Name exposed for import */
|
|
19
|
+
exportedName: string;
|
|
20
|
+
/** The AST node being exported */
|
|
21
|
+
node: AstNode;
|
|
22
|
+
/** File path of the module that defines this export */
|
|
23
|
+
moduleId: string;
|
|
24
|
+
/** Whether this is a re-export from another module */
|
|
25
|
+
isReExport: boolean;
|
|
26
|
+
/** For re-exports, the source module path */
|
|
27
|
+
reExportSource?: string;
|
|
28
|
+
}
|
|
29
|
+
/** Information about an imported symbol */
|
|
30
|
+
export interface ImportedSymbol {
|
|
31
|
+
/** Name used in the importing module */
|
|
32
|
+
localName: string;
|
|
33
|
+
/** Name as exported from the source module */
|
|
34
|
+
importedName: string;
|
|
35
|
+
/** File path of the source module */
|
|
36
|
+
sourceModule: string;
|
|
37
|
+
}
|
|
38
|
+
/** Complete information about a parsed module */
|
|
39
|
+
export interface ModuleInfo {
|
|
40
|
+
/** Unique identifier (absolute file path) */
|
|
41
|
+
id: string;
|
|
42
|
+
/** Parsed AST of the module */
|
|
43
|
+
ast: RootNode;
|
|
44
|
+
/** Map of exported symbol names to their info */
|
|
45
|
+
exports: Map<string, ExportedSymbol>;
|
|
46
|
+
/** Map of local imported names to their info */
|
|
47
|
+
imports: Map<string, ImportedSymbol>;
|
|
48
|
+
/** Set of module IDs this module depends on */
|
|
49
|
+
dependencies: Set<string>;
|
|
50
|
+
/** Whether this module has been fully processed */
|
|
51
|
+
processed: boolean;
|
|
52
|
+
/** Whether this module is currently being processed (for cycle detection) */
|
|
53
|
+
processing: boolean;
|
|
54
|
+
}
|
|
55
|
+
/** Options for the module resolver */
|
|
56
|
+
export interface ModuleResolverOptions {
|
|
57
|
+
/** Entry module file path */
|
|
58
|
+
entryPath: string;
|
|
59
|
+
/** Function to resolve source code from a file path */
|
|
60
|
+
sourceResolver: (filePath: string) => string;
|
|
61
|
+
/** Function to parse source code into AST */
|
|
62
|
+
parseSource: (source: string, filePath: string) => RootNode;
|
|
63
|
+
/** Whether to include metadata */
|
|
64
|
+
includeMetaData?: boolean;
|
|
65
|
+
}
|
|
66
|
+
/** Result of module resolution */
|
|
67
|
+
export interface ModuleResolutionResult {
|
|
68
|
+
/** Flattened body with all modules merged */
|
|
69
|
+
body: AstNode[];
|
|
70
|
+
/** Map of module IDs to their info */
|
|
71
|
+
modules: Map<string, ModuleInfo>;
|
|
72
|
+
/** Order in which modules should be processed (topological sort) */
|
|
73
|
+
moduleOrder: string[];
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Module Resolver
|
|
77
|
+
*
|
|
78
|
+
* Resolves ES module imports/exports and produces a flattened AST
|
|
79
|
+
* with all dependencies merged in the correct order.
|
|
80
|
+
*/
|
|
81
|
+
export declare class ModuleResolver {
|
|
82
|
+
private modules;
|
|
83
|
+
private options;
|
|
84
|
+
private moduleOrder;
|
|
85
|
+
constructor(options: ModuleResolverOptions);
|
|
86
|
+
/**
|
|
87
|
+
* Resolve all modules starting from the entry point
|
|
88
|
+
*/
|
|
89
|
+
resolve(): ModuleResolutionResult;
|
|
90
|
+
/**
|
|
91
|
+
* Build the module dependency graph by parsing all modules
|
|
92
|
+
*/
|
|
93
|
+
private buildModuleGraph;
|
|
94
|
+
/**
|
|
95
|
+
* Extract export information from a module's AST
|
|
96
|
+
*/
|
|
97
|
+
private extractExportsFromModule;
|
|
98
|
+
/**
|
|
99
|
+
* Extract import information from a module's AST
|
|
100
|
+
*/
|
|
101
|
+
private extractImportsFromModule;
|
|
102
|
+
/**
|
|
103
|
+
* Resolve all re-exports to their actual source declarations
|
|
104
|
+
*/
|
|
105
|
+
private resolveAllExports;
|
|
106
|
+
/**
|
|
107
|
+
* Resolve a re-export to its actual source declaration
|
|
108
|
+
*/
|
|
109
|
+
private resolveReExport;
|
|
110
|
+
/**
|
|
111
|
+
* Topological sort of modules for correct ordering
|
|
112
|
+
*/
|
|
113
|
+
private topologicalSort;
|
|
114
|
+
/**
|
|
115
|
+
* Flatten all modules into a single body array
|
|
116
|
+
*/
|
|
117
|
+
private flattenModules;
|
|
118
|
+
/**
|
|
119
|
+
* Add module metadata to a node
|
|
120
|
+
*/
|
|
121
|
+
private addModuleMetadata;
|
|
122
|
+
/**
|
|
123
|
+
* Check if a node is an exportable declaration type
|
|
124
|
+
*/
|
|
125
|
+
private isExportableDeclaration;
|
|
126
|
+
/**
|
|
127
|
+
* Get the name of a declaration node
|
|
128
|
+
*/
|
|
129
|
+
private getDeclarationName;
|
|
130
|
+
/**
|
|
131
|
+
* Find a local declaration by name in a module's AST
|
|
132
|
+
*/
|
|
133
|
+
private findLocalDeclaration;
|
|
134
|
+
/**
|
|
135
|
+
* Resolve a relative import path to an absolute path
|
|
136
|
+
*/
|
|
137
|
+
private resolveImportPath;
|
|
138
|
+
/**
|
|
139
|
+
* Validate that an imported symbol is actually exported
|
|
140
|
+
*/
|
|
141
|
+
validateImport(importingModule: string, importedName: string, sourceModule: string): void;
|
|
142
|
+
/**
|
|
143
|
+
* Get the exported symbols from a module
|
|
144
|
+
*/
|
|
145
|
+
getModuleExports(moduleId: string): Map<string, ExportedSymbol> | null;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Helper function to resolve modules for a given entry point
|
|
149
|
+
*/
|
|
150
|
+
export declare function resolveModules(options: ModuleResolverOptions): ModuleResolutionResult;
|
|
151
|
+
//# sourceMappingURL=moduleResolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"moduleResolver.d.ts","sourceRoot":"","sources":["../../services/moduleResolver.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { AstNode } from "@/types";
|
|
2
|
+
import type { DependencyGraph } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Analyzes AST to build a dependency graph of which nodes reference which symbols.
|
|
5
|
+
* Currently focused on function call dependencies.
|
|
6
|
+
*/
|
|
7
|
+
export declare class DependencyAnalyzer {
|
|
8
|
+
private graph;
|
|
9
|
+
/**
|
|
10
|
+
* Build the dependency graph for the given AST body
|
|
11
|
+
*/
|
|
12
|
+
analyze(body: AstNode[], entryPoints: Set<AstNode>): DependencyGraph;
|
|
13
|
+
/**
|
|
14
|
+
* Index all function declarations by name
|
|
15
|
+
*/
|
|
16
|
+
private indexDeclarations;
|
|
17
|
+
/**
|
|
18
|
+
* Analyze a node and its children for dependencies
|
|
19
|
+
*/
|
|
20
|
+
private analyzeNode;
|
|
21
|
+
/**
|
|
22
|
+
* Walk a node recursively to find all dependencies
|
|
23
|
+
*/
|
|
24
|
+
private walkNode;
|
|
25
|
+
/**
|
|
26
|
+
* Handle a function call expression
|
|
27
|
+
*/
|
|
28
|
+
private handleCallExpression;
|
|
29
|
+
/**
|
|
30
|
+
* Get the function name from a call expression callee
|
|
31
|
+
*/
|
|
32
|
+
private getFunctionName;
|
|
33
|
+
/**
|
|
34
|
+
* Walk all properties of a node that could contain AST nodes
|
|
35
|
+
*/
|
|
36
|
+
private walkNodeProperties;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=DependencyAnalyzer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DependencyAnalyzer.d.ts","sourceRoot":"","sources":["../../../services/treeShaker/DependencyAnalyzer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,OAAO,EAA4G,MAAM,SAAS,CAAC;AAChJ,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,SAAS,CAAC;AAE7C;;;GAGG;AACH,qBAAa,kBAAkB;IAC9B,OAAO,CAAC,KAAK,CAIX;IAEF;;OAEG;IACH,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,WAAW,EAAE,GAAG,CAAC,OAAO,CAAC,GAAG,eAAe;IAkBpE;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAWzB;;OAEG;IACH,OAAO,CAAC,WAAW;IAanB;;OAEG;IACH,OAAO,CAAC,QAAQ;IAoBhB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAkC5B;;OAEG;IACH,OAAO,CAAC,eAAe;IAqBvB;;OAEG;IACH,OAAO,CAAC,kBAAkB;CAiB1B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { AstNode } from "@/types";
|
|
2
|
+
/**
|
|
3
|
+
* Collects entry point nodes that must be retained during tree-shaking.
|
|
4
|
+
* Entry points are nodes that are executed or can be called at runtime.
|
|
5
|
+
*/
|
|
6
|
+
export declare class EntryPointCollector {
|
|
7
|
+
private entryPoints;
|
|
8
|
+
/**
|
|
9
|
+
* Collect all entry point nodes from the AST body
|
|
10
|
+
*/
|
|
11
|
+
collect(body: AstNode[]): Set<AstNode>;
|
|
12
|
+
/**
|
|
13
|
+
* Determine if a node is an entry point that must be retained
|
|
14
|
+
*/
|
|
15
|
+
private isEntryPoint;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=EntryPointCollector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EntryPointCollector.d.ts","sourceRoot":"","sources":["../../../services/treeShaker/EntryPointCollector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,SAAS,CAAC;AAErC;;;GAGG;AACH,qBAAa,mBAAmB;IAC/B,OAAO,CAAC,WAAW,CAA2B;IAE9C;;OAEG;IACH,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC;IAYtC;;OAEG;IACH,OAAO,CAAC,YAAY;CA6DpB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { AstNode } from "@/types";
|
|
2
|
+
import type { TreeShakeOptions, TreeShakeResult } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Main tree-shaking implementation.
|
|
5
|
+
* Removes unused function declarations from the AST.
|
|
6
|
+
*/
|
|
7
|
+
export declare class TreeShaker {
|
|
8
|
+
private options;
|
|
9
|
+
private entryPointCollector;
|
|
10
|
+
private dependencyAnalyzer;
|
|
11
|
+
constructor(options?: TreeShakeOptions);
|
|
12
|
+
/**
|
|
13
|
+
* Perform tree-shaking on the given AST body
|
|
14
|
+
*/
|
|
15
|
+
shake(body: AstNode[]): TreeShakeResult;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=TreeShaker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeShaker.d.ts","sourceRoot":"","sources":["../../../services/treeShaker/TreeShaker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,OAAO,EAAkE,MAAM,SAAS,CAAC;AAGtG,OAAO,KAAK,EAAC,gBAAgB,EAAE,eAAe,EAAC,MAAM,SAAS,CAAC;AAE/D;;;GAGG;AACH,qBAAa,UAAU;IACtB,OAAO,CAAC,OAAO,CAAmB;IAClC,OAAO,CAAC,mBAAmB,CAAsB;IACjD,OAAO,CAAC,kBAAkB,CAAqB;gBAEnC,OAAO,GAAE,gBAAqB;IAS1C;;OAEG;IACH,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,eAAe;CA+DvC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../services/treeShaker/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AstNode } from "@/types";
|
|
2
|
+
import type { TreeShakeOptions } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Convenience function to tree-shake an AST body.
|
|
5
|
+
* Removes unused function declarations.
|
|
6
|
+
*
|
|
7
|
+
* @param body - The AST body nodes to tree-shake
|
|
8
|
+
* @param options - Tree-shaking options
|
|
9
|
+
* @returns The filtered body with unused functions removed
|
|
10
|
+
*/
|
|
11
|
+
export declare const treeShake: (body: AstNode[], options?: TreeShakeOptions) => AstNode[];
|
|
12
|
+
//# sourceMappingURL=treeShake.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"treeShake.d.ts","sourceRoot":"","sources":["../../../services/treeShaker/treeShake.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,SAAS,CAAC;AAErC,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,SAAS,CAAC;AAE9C;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,GAAI,MAAM,OAAO,EAAE,EAAE,UAAS,gBAAqB,KAAG,OAAO,EAIlF,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { AstNode } from "@/types";
|
|
2
|
+
/**
|
|
3
|
+
* Configuration options for tree-shaking
|
|
4
|
+
*/
|
|
5
|
+
export interface TreeShakeOptions {
|
|
6
|
+
/**
|
|
7
|
+
* If true, enables tree-shaking. Default: true
|
|
8
|
+
*/
|
|
9
|
+
enabled?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* If true, provides verbose logging of tree-shaking decisions
|
|
12
|
+
*/
|
|
13
|
+
verbose?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Result of tree-shaking analysis
|
|
17
|
+
*/
|
|
18
|
+
export interface TreeShakeResult {
|
|
19
|
+
/**
|
|
20
|
+
* The filtered AST body with unused nodes removed
|
|
21
|
+
*/
|
|
22
|
+
body: AstNode[];
|
|
23
|
+
/**
|
|
24
|
+
* Statistics about what was removed
|
|
25
|
+
*/
|
|
26
|
+
stats: {
|
|
27
|
+
originalCount: number;
|
|
28
|
+
retainedCount: number;
|
|
29
|
+
removedCount: number;
|
|
30
|
+
removedNodes: string[];
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Internal type for tracking dependencies
|
|
35
|
+
*/
|
|
36
|
+
export interface DependencyGraph {
|
|
37
|
+
/**
|
|
38
|
+
* Map of symbol name to the nodes that depend on it
|
|
39
|
+
*/
|
|
40
|
+
dependencies: Map<string, Set<AstNode>>;
|
|
41
|
+
/**
|
|
42
|
+
* Set of all retained node references
|
|
43
|
+
*/
|
|
44
|
+
retained: Set<AstNode>;
|
|
45
|
+
/**
|
|
46
|
+
* Map of symbol name to its declaration node
|
|
47
|
+
*/
|
|
48
|
+
declarations: Map<string, AstNode>;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../services/treeShaker/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,SAAS,CAAC;AAErC;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B;;OAEG;IACH,IAAI,EAAE,OAAO,EAAE,CAAC;IAEhB;;OAEG;IACH,KAAK,EAAE;QACN,aAAa,EAAE,MAAM,CAAC;QACtB,aAAa,EAAE,MAAM,CAAC;QACtB,YAAY,EAAE,MAAM,CAAC;QACrB,YAAY,EAAE,MAAM,EAAE,CAAC;KACvB,CAAC;CACF;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B;;OAEG;IACH,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;IAExC;;OAEG;IACH,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IAEvB;;OAEG;IACH,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.test.d.ts","sourceRoot":"","sources":["../../../tests/ast/export.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import.test.d.ts","sourceRoot":"","sources":["../../../tests/ast/import.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"moduleResolver.test.d.ts","sourceRoot":"","sources":["../../../tests/ast/moduleResolver.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree-shaking.test.d.ts","sourceRoot":"","sources":["../../../tests/ast/tree-shaking.test.ts"],"names":[],"mappings":""}
|