@emfts/codegen 0.0.1-next.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/README.md +39 -0
- package/dist/cli/commands/generate-rest-client.d.ts +3 -0
- package/dist/cli/commands/generate-rest-client.d.ts.map +1 -0
- package/dist/cli/commands/generate-rest-client.js +38 -0
- package/dist/cli/commands/generate-rest-client.js.map +1 -0
- package/dist/cli/commands/generate.d.ts +3 -0
- package/dist/cli/commands/generate.d.ts.map +1 -0
- package/dist/cli/commands/generate.js +108 -0
- package/dist/cli/commands/generate.js.map +1 -0
- package/dist/cli/commands/init.d.ts +3 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +57 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +15 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/debug-abstract.d.ts +2 -0
- package/dist/debug-abstract.d.ts.map +1 -0
- package/dist/debug-abstract.js +25 -0
- package/dist/debug-abstract.js.map +1 -0
- package/dist/debug-genmodel.d.ts +2 -0
- package/dist/debug-genmodel.d.ts.map +1 -0
- package/dist/debug-genmodel.js +41 -0
- package/dist/debug-genmodel.js.map +1 -0
- package/dist/genconfig/GenConfig.d.ts +125 -0
- package/dist/genconfig/GenConfig.d.ts.map +1 -0
- package/dist/genconfig/GenConfig.js +46 -0
- package/dist/genconfig/GenConfig.js.map +1 -0
- package/dist/genconfig/GenConfigConverter.d.ts +64 -0
- package/dist/genconfig/GenConfigConverter.d.ts.map +1 -0
- package/dist/genconfig/GenConfigConverter.js +293 -0
- package/dist/genconfig/GenConfigConverter.js.map +1 -0
- package/dist/genconfig/GenConfigLoader.d.ts +83 -0
- package/dist/genconfig/GenConfigLoader.d.ts.map +1 -0
- package/dist/genconfig/GenConfigLoader.js +455 -0
- package/dist/genconfig/GenConfigLoader.js.map +1 -0
- package/dist/genconfig/index.d.ts +4 -0
- package/dist/genconfig/index.d.ts.map +1 -0
- package/dist/genconfig/index.js +4 -0
- package/dist/genconfig/index.js.map +1 -0
- package/dist/generator/CodeGenerator.d.ts +45 -0
- package/dist/generator/CodeGenerator.d.ts.map +1 -0
- package/dist/generator/CodeGenerator.js +142 -0
- package/dist/generator/CodeGenerator.js.map +1 -0
- package/dist/generator/GeneratedFile.d.ts +23 -0
- package/dist/generator/GeneratedFile.d.ts.map +1 -0
- package/dist/generator/GeneratedFile.js +42 -0
- package/dist/generator/GeneratedFile.js.map +1 -0
- package/dist/generator/GeneratorContext.d.ts +73 -0
- package/dist/generator/GeneratorContext.d.ts.map +1 -0
- package/dist/generator/GeneratorContext.js +99 -0
- package/dist/generator/GeneratorContext.js.map +1 -0
- package/dist/generator/GeneratorOptions.d.ts +26 -0
- package/dist/generator/GeneratorOptions.d.ts.map +1 -0
- package/dist/generator/GeneratorOptions.js +16 -0
- package/dist/generator/GeneratorOptions.js.map +1 -0
- package/dist/generator/ImportResolver.d.ts +85 -0
- package/dist/generator/ImportResolver.d.ts.map +1 -0
- package/dist/generator/ImportResolver.js +381 -0
- package/dist/generator/ImportResolver.js.map +1 -0
- package/dist/generator/RestClientGenerator.d.ts +72 -0
- package/dist/generator/RestClientGenerator.d.ts.map +1 -0
- package/dist/generator/RestClientGenerator.js +488 -0
- package/dist/generator/RestClientGenerator.js.map +1 -0
- package/dist/generator/TypeMapper.d.ts +62 -0
- package/dist/generator/TypeMapper.d.ts.map +1 -0
- package/dist/generator/TypeMapper.js +224 -0
- package/dist/generator/TypeMapper.js.map +1 -0
- package/dist/generator/index.d.ts +9 -0
- package/dist/generator/index.d.ts.map +1 -0
- package/dist/generator/index.js +9 -0
- package/dist/generator/index.js.map +1 -0
- package/dist/generator/modes/BaseGenerator.d.ts +67 -0
- package/dist/generator/modes/BaseGenerator.d.ts.map +1 -0
- package/dist/generator/modes/BaseGenerator.js +128 -0
- package/dist/generator/modes/BaseGenerator.js.map +1 -0
- package/dist/generator/modes/DecoratorGenerator.d.ts +28 -0
- package/dist/generator/modes/DecoratorGenerator.d.ts.map +1 -0
- package/dist/generator/modes/DecoratorGenerator.js +147 -0
- package/dist/generator/modes/DecoratorGenerator.js.map +1 -0
- package/dist/generator/modes/EmfGenerator.d.ts +22 -0
- package/dist/generator/modes/EmfGenerator.d.ts.map +1 -0
- package/dist/generator/modes/EmfGenerator.js +202 -0
- package/dist/generator/modes/EmfGenerator.js.map +1 -0
- package/dist/generator/modes/PlainGenerator.d.ts +16 -0
- package/dist/generator/modes/PlainGenerator.d.ts.map +1 -0
- package/dist/generator/modes/PlainGenerator.js +95 -0
- package/dist/generator/modes/PlainGenerator.js.map +1 -0
- package/dist/generator/modes/index.d.ts +5 -0
- package/dist/generator/modes/index.d.ts.map +1 -0
- package/dist/generator/modes/index.js +5 -0
- package/dist/generator/modes/index.js.map +1 -0
- package/dist/genmodel/GenClass.d.ts +37 -0
- package/dist/genmodel/GenClass.d.ts.map +1 -0
- package/dist/genmodel/GenClass.js +14 -0
- package/dist/genmodel/GenClass.js.map +1 -0
- package/dist/genmodel/GenDataType.d.ts +19 -0
- package/dist/genmodel/GenDataType.d.ts.map +1 -0
- package/dist/genmodel/GenDataType.js +46 -0
- package/dist/genmodel/GenDataType.js.map +1 -0
- package/dist/genmodel/GenEnum.d.ts +30 -0
- package/dist/genmodel/GenEnum.d.ts.map +1 -0
- package/dist/genmodel/GenEnum.js +11 -0
- package/dist/genmodel/GenEnum.js.map +1 -0
- package/dist/genmodel/GenFeature.d.ts +30 -0
- package/dist/genmodel/GenFeature.d.ts.map +1 -0
- package/dist/genmodel/GenFeature.js +15 -0
- package/dist/genmodel/GenFeature.js.map +1 -0
- package/dist/genmodel/GenModel.d.ts +54 -0
- package/dist/genmodel/GenModel.d.ts.map +1 -0
- package/dist/genmodel/GenModel.js +24 -0
- package/dist/genmodel/GenModel.js.map +1 -0
- package/dist/genmodel/GenOperation.d.ts +19 -0
- package/dist/genmodel/GenOperation.d.ts.map +1 -0
- package/dist/genmodel/GenOperation.js +10 -0
- package/dist/genmodel/GenOperation.js.map +1 -0
- package/dist/genmodel/GenPackage.d.ts +42 -0
- package/dist/genmodel/GenPackage.d.ts.map +1 -0
- package/dist/genmodel/GenPackage.js +25 -0
- package/dist/genmodel/GenPackage.js.map +1 -0
- package/dist/genmodel/GenerationMode.d.ts +23 -0
- package/dist/genmodel/GenerationMode.d.ts.map +1 -0
- package/dist/genmodel/GenerationMode.js +25 -0
- package/dist/genmodel/GenerationMode.js.map +1 -0
- package/dist/genmodel/index.d.ts +9 -0
- package/dist/genmodel/index.d.ts.map +1 -0
- package/dist/genmodel/index.js +10 -0
- package/dist/genmodel/index.js.map +1 -0
- package/dist/index.d.ts +66 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +110 -0
- package/dist/index.js.map +1 -0
- package/dist/loader/EcoreLoader.d.ts +33 -0
- package/dist/loader/EcoreLoader.d.ts.map +1 -0
- package/dist/loader/EcoreLoader.js +91 -0
- package/dist/loader/EcoreLoader.js.map +1 -0
- package/dist/loader/index.d.ts +2 -0
- package/dist/loader/index.d.ts.map +1 -0
- package/dist/loader/index.js +2 -0
- package/dist/loader/index.js.map +1 -0
- package/dist/templates/partials/decorator/class-file.ejs +98 -0
- package/dist/templates/partials/decorator/enum-file.ejs +35 -0
- package/dist/templates/partials/decorator/interface-file.ejs +61 -0
- package/dist/templates/partials/decorator/model-annotations.ejs +91 -0
- package/dist/templates/partials/decorator/package-file.ejs +7 -0
- package/dist/templates/partials/emf/class-file.ejs +226 -0
- package/dist/templates/partials/emf/enum-file.ejs +36 -0
- package/dist/templates/partials/emf/factory-file.ejs +54 -0
- package/dist/templates/partials/emf/index-file.ejs +29 -0
- package/dist/templates/partials/emf/interface-file.ejs +72 -0
- package/dist/templates/partials/emf/package-file.ejs +149 -0
- package/dist/templates/partials/plain/class-file.ejs +75 -0
- package/dist/templates/partials/plain/enum-file.ejs +28 -0
- package/dist/templates/partials/plain/interface-file.ejs +61 -0
- package/dist/templates/partials/plain/package-file.ejs +6 -0
- package/dist/templates/templates/partials/decorator/class-file.ejs +98 -0
- package/dist/templates/templates/partials/decorator/enum-file.ejs +35 -0
- package/dist/templates/templates/partials/decorator/interface-file.ejs +61 -0
- package/dist/templates/templates/partials/decorator/model-annotations.ejs +91 -0
- package/dist/templates/templates/partials/decorator/package-file.ejs +7 -0
- package/dist/templates/templates/partials/emf/class-file.ejs +226 -0
- package/dist/templates/templates/partials/emf/enum-file.ejs +36 -0
- package/dist/templates/templates/partials/emf/factory-file.ejs +54 -0
- package/dist/templates/templates/partials/emf/index-file.ejs +29 -0
- package/dist/templates/templates/partials/emf/interface-file.ejs +72 -0
- package/dist/templates/templates/partials/emf/package-file.ejs +149 -0
- package/dist/templates/templates/partials/plain/class-file.ejs +75 -0
- package/dist/templates/templates/partials/plain/enum-file.ejs +28 -0
- package/dist/templates/templates/partials/plain/interface-file.ejs +61 -0
- package/dist/templates/templates/partials/plain/package-file.ejs +6 -0
- package/dist/util/EObjectHelper.d.ts +90 -0
- package/dist/util/EObjectHelper.d.ts.map +1 -0
- package/dist/util/EObjectHelper.js +381 -0
- package/dist/util/EObjectHelper.js.map +1 -0
- package/dist/util/StringUtils.d.ts +44 -0
- package/dist/util/StringUtils.d.ts.map +1 -0
- package/dist/util/StringUtils.js +115 -0
- package/dist/util/StringUtils.js.map +1 -0
- package/dist/util/index.d.ts +3 -0
- package/dist/util/index.d.ts.map +1 -0
- package/dist/util/index.js +3 -0
- package/dist/util/index.js.map +1 -0
- package/package.json +60 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { createDefaultOptions } from './GeneratorOptions.js';
|
|
2
|
+
import { GeneratorContext } from './GeneratorContext.js';
|
|
3
|
+
import { PlainGenerator, DecoratorGenerator, EmfGenerator } from './modes/index.js';
|
|
4
|
+
import { GenerationMode } from '../genmodel/GenerationMode.js';
|
|
5
|
+
import { getName } from '../util/EObjectHelper.js';
|
|
6
|
+
/**
|
|
7
|
+
* Main code generator that orchestrates generation based on mode
|
|
8
|
+
*/
|
|
9
|
+
export class CodeGenerator {
|
|
10
|
+
genModel;
|
|
11
|
+
context;
|
|
12
|
+
generator;
|
|
13
|
+
constructor(genModel, options) {
|
|
14
|
+
this.genModel = genModel;
|
|
15
|
+
this.context = new GeneratorContext(genModel, createDefaultOptions(options));
|
|
16
|
+
this.generator = this.createModeGenerator(genModel.generationMode);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Create the appropriate generator for the mode
|
|
20
|
+
*/
|
|
21
|
+
createModeGenerator(mode) {
|
|
22
|
+
switch (mode) {
|
|
23
|
+
case GenerationMode.PLAIN:
|
|
24
|
+
return new PlainGenerator(this.context);
|
|
25
|
+
case GenerationMode.DECORATOR:
|
|
26
|
+
return new DecoratorGenerator(this.context);
|
|
27
|
+
case GenerationMode.EMF:
|
|
28
|
+
return new EmfGenerator(this.context);
|
|
29
|
+
default:
|
|
30
|
+
this.context.warn(`Unknown mode: ${mode}, falling back to DECORATOR`);
|
|
31
|
+
return new DecoratorGenerator(this.context);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Generate all code for the model
|
|
36
|
+
*/
|
|
37
|
+
async generate() {
|
|
38
|
+
const files = [];
|
|
39
|
+
try {
|
|
40
|
+
// Generate each package
|
|
41
|
+
for (const genPackage of this.genModel.genPackages) {
|
|
42
|
+
const packageFiles = await this.generatePackage(genPackage);
|
|
43
|
+
files.push(...packageFiles);
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
files,
|
|
47
|
+
diagnostics: this.context.diagnostics,
|
|
48
|
+
success: !this.context.hasErrors()
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
this.context.error(error instanceof Error ? error.message : String(error));
|
|
53
|
+
return {
|
|
54
|
+
files,
|
|
55
|
+
diagnostics: this.context.diagnostics,
|
|
56
|
+
success: false
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Generate files for a package
|
|
62
|
+
*/
|
|
63
|
+
async generatePackage(genPackage) {
|
|
64
|
+
const files = [];
|
|
65
|
+
this.context.info(`Generating package: ${genPackage.ecorePackage.getName()}`);
|
|
66
|
+
// Generate enums first (they might be referenced by classes)
|
|
67
|
+
for (const genEnum of genPackage.genEnums) {
|
|
68
|
+
this.context.info(`Generating enum: ${getName(genEnum.ecoreEnum)}`);
|
|
69
|
+
const file = await this.generator.generateEnum(genEnum, genPackage);
|
|
70
|
+
files.push(file);
|
|
71
|
+
}
|
|
72
|
+
// Generate interfaces if configured
|
|
73
|
+
if (this.genModel.generateInterfaces) {
|
|
74
|
+
for (const genClass of genPackage.genClasses) {
|
|
75
|
+
if (genClass.generateInterface) {
|
|
76
|
+
this.context.info(`Generating interface: ${genClass.ecoreClass.getName()}`);
|
|
77
|
+
const file = await this.generator.generateInterface(genClass, genPackage);
|
|
78
|
+
files.push(file);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// Generate classes if configured
|
|
83
|
+
if (this.genModel.generateClasses) {
|
|
84
|
+
for (const genClass of genPackage.genClasses) {
|
|
85
|
+
if (genClass.generateImpl && !genClass.ecoreClass.isInterface()) {
|
|
86
|
+
this.context.info(`Generating class: ${genClass.ecoreClass.getName()}`);
|
|
87
|
+
const file = await this.generator.generateClass(genClass, genPackage);
|
|
88
|
+
files.push(file);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// Generate package file
|
|
93
|
+
if (this.genModel.generatePackage) {
|
|
94
|
+
this.context.info(`Generating package file`);
|
|
95
|
+
const packageFile = await this.generator.generatePackageFile(genPackage);
|
|
96
|
+
files.push(packageFile);
|
|
97
|
+
}
|
|
98
|
+
// Generate factory if configured and supported
|
|
99
|
+
if (this.genModel.generateFactory) {
|
|
100
|
+
const factoryFile = await this.generator.generateFactory(genPackage);
|
|
101
|
+
if (factoryFile) {
|
|
102
|
+
this.context.info(`Generating factory`);
|
|
103
|
+
files.push(factoryFile);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
// Generate mode-specific additional files
|
|
107
|
+
if (this.generator instanceof DecoratorGenerator) {
|
|
108
|
+
const annotationsFile = await this.generator.generateModelAnnotations(genPackage);
|
|
109
|
+
files.push(annotationsFile);
|
|
110
|
+
}
|
|
111
|
+
if (this.generator instanceof EmfGenerator) {
|
|
112
|
+
const indexFile = await this.generator.generateIndex(genPackage);
|
|
113
|
+
files.push(indexFile);
|
|
114
|
+
}
|
|
115
|
+
// Generate nested packages recursively
|
|
116
|
+
for (const nestedPackage of genPackage.nestedGenPackages) {
|
|
117
|
+
const nestedFiles = await this.generatePackage(nestedPackage);
|
|
118
|
+
files.push(...nestedFiles);
|
|
119
|
+
}
|
|
120
|
+
return files;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Write all generated files to disk
|
|
124
|
+
*/
|
|
125
|
+
async writeFiles(files) {
|
|
126
|
+
for (const file of files) {
|
|
127
|
+
await file.write();
|
|
128
|
+
this.context.info(`Written: ${file.getFullPath()}`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Generate and write all files
|
|
133
|
+
*/
|
|
134
|
+
async run() {
|
|
135
|
+
const result = await this.generate();
|
|
136
|
+
if (result.success) {
|
|
137
|
+
await this.writeFiles(result.files);
|
|
138
|
+
}
|
|
139
|
+
return result;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=CodeGenerator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeGenerator.js","sourceRoot":"","sources":["../../src/generator/CodeGenerator.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAmB,MAAM,uBAAuB,CAAC;AAE1E,OAAO,EAAiB,c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P,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;QAErC,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACtC,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a generated file
|
|
3
|
+
*/
|
|
4
|
+
export declare class GeneratedFile {
|
|
5
|
+
/** Relative file path */
|
|
6
|
+
readonly path: string;
|
|
7
|
+
/** File content */
|
|
8
|
+
readonly content: string;
|
|
9
|
+
/** Whether this file was actually generated (vs skipped) */
|
|
10
|
+
readonly generated: boolean;
|
|
11
|
+
/** Output base directory */
|
|
12
|
+
private outputDir;
|
|
13
|
+
constructor(path: string, content: string, outputDir: string, generated?: boolean);
|
|
14
|
+
/**
|
|
15
|
+
* Get the full output path
|
|
16
|
+
*/
|
|
17
|
+
getFullPath(): string;
|
|
18
|
+
/**
|
|
19
|
+
* Write the file to disk
|
|
20
|
+
*/
|
|
21
|
+
write(): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=GeneratedFile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GeneratedFile.d.ts","sourceRoot":"","sources":["../../src/generator/GeneratedFile.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,qBAAa,aAAa;IACxB,yBAAyB;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,mBAAmB;IACnB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,4DAA4D;IAC5D,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAE5B,4BAA4B;IAC5B,OAAO,CAAC,SAAS,CAAS;gBAEd,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,GAAE,OAAc;IAOvF;;OAEG;IACH,WAAW,IAAI,MAAM;IAIrB;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAc7B"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { writeFile, mkdir } from 'fs/promises';
|
|
2
|
+
import { dirname, join } from 'path';
|
|
3
|
+
/**
|
|
4
|
+
* Represents a generated file
|
|
5
|
+
*/
|
|
6
|
+
export class GeneratedFile {
|
|
7
|
+
/** Relative file path */
|
|
8
|
+
path;
|
|
9
|
+
/** File content */
|
|
10
|
+
content;
|
|
11
|
+
/** Whether this file was actually generated (vs skipped) */
|
|
12
|
+
generated;
|
|
13
|
+
/** Output base directory */
|
|
14
|
+
outputDir;
|
|
15
|
+
constructor(path, content, outputDir, generated = true) {
|
|
16
|
+
this.path = path;
|
|
17
|
+
this.content = content;
|
|
18
|
+
this.outputDir = outputDir;
|
|
19
|
+
this.generated = generated;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get the full output path
|
|
23
|
+
*/
|
|
24
|
+
getFullPath() {
|
|
25
|
+
return join(this.outputDir, this.path);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Write the file to disk
|
|
29
|
+
*/
|
|
30
|
+
async write() {
|
|
31
|
+
if (!this.generated) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const fullPath = this.getFullPath();
|
|
35
|
+
const dir = dirname(fullPath);
|
|
36
|
+
// Ensure directory exists
|
|
37
|
+
await mkdir(dir, { recursive: true });
|
|
38
|
+
// Write file
|
|
39
|
+
await writeFile(fullPath, this.content, 'utf-8');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=GeneratedFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GeneratedFile.js","sourceRoot":"","sources":["../../src/generator/GeneratedFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAErC;;GAEG;AACH,MAAM,OAAO,aAAa;IACxB,yBAAyB;IAChB,IAAI,CAAS;IAEtB,mBAAmB;IACV,OAAO,CAAS;IAEzB,4DAA4D;IACnD,SAAS,CAAU;IAE5B,4BAA4B;IACpB,SAAS,CAAS;IAE1B,YAAY,IAAY,EAAE,OAAe,EAAE,SAAiB,EAAE,YAAqB,IAAI;QACrF,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,WAAW;QACT,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACpB,OAAO;QACT,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QACpC,MAAM,GAAG,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;QAE9B,0BAA0B;QAC1B,MAAM,KAAK,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAEtC,aAAa;QACb,MAAM,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACnD,CAAC;CACF"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { GenModel } from '../genmodel/GenModel.js';
|
|
2
|
+
import type { GenPackage } from '../genmodel/GenPackage.js';
|
|
3
|
+
import type { GenClass } from '../genmodel/GenClass.js';
|
|
4
|
+
import type { GeneratorOptions } from './GeneratorOptions.js';
|
|
5
|
+
import { TypeMapper } from './TypeMapper.js';
|
|
6
|
+
import { ImportResolver } from './ImportResolver.js';
|
|
7
|
+
/**
|
|
8
|
+
* Diagnostic message from generation
|
|
9
|
+
*/
|
|
10
|
+
export interface Diagnostic {
|
|
11
|
+
level: 'info' | 'warning' | 'error';
|
|
12
|
+
message: string;
|
|
13
|
+
source?: string;
|
|
14
|
+
line?: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Context shared during code generation
|
|
18
|
+
*/
|
|
19
|
+
export declare class GeneratorContext {
|
|
20
|
+
readonly genModel: GenModel;
|
|
21
|
+
readonly options: GeneratorOptions;
|
|
22
|
+
readonly typeMapper: TypeMapper;
|
|
23
|
+
readonly importResolver: ImportResolver;
|
|
24
|
+
readonly diagnostics: Diagnostic[];
|
|
25
|
+
private currentPackage;
|
|
26
|
+
private currentClass;
|
|
27
|
+
constructor(genModel: GenModel, options: GeneratorOptions);
|
|
28
|
+
/**
|
|
29
|
+
* Set the current package being processed
|
|
30
|
+
*/
|
|
31
|
+
setCurrentPackage(pkg: GenPackage): void;
|
|
32
|
+
/**
|
|
33
|
+
* Get the current package being processed
|
|
34
|
+
*/
|
|
35
|
+
getCurrentPackage(): GenPackage | null;
|
|
36
|
+
/**
|
|
37
|
+
* Set the current class being processed
|
|
38
|
+
*/
|
|
39
|
+
setCurrentClass(cls: GenClass): void;
|
|
40
|
+
/**
|
|
41
|
+
* Get the current class being processed
|
|
42
|
+
*/
|
|
43
|
+
getCurrentClass(): GenClass | null;
|
|
44
|
+
/**
|
|
45
|
+
* Add an info diagnostic
|
|
46
|
+
*/
|
|
47
|
+
info(message: string, source?: string): void;
|
|
48
|
+
/**
|
|
49
|
+
* Add a warning diagnostic
|
|
50
|
+
*/
|
|
51
|
+
warn(message: string, source?: string): void;
|
|
52
|
+
/**
|
|
53
|
+
* Add an error diagnostic
|
|
54
|
+
*/
|
|
55
|
+
error(message: string, source?: string): void;
|
|
56
|
+
/**
|
|
57
|
+
* Check if there are any errors
|
|
58
|
+
*/
|
|
59
|
+
hasErrors(): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Get the file header
|
|
62
|
+
*/
|
|
63
|
+
getFileHeader(): string;
|
|
64
|
+
/**
|
|
65
|
+
* Get indentation string
|
|
66
|
+
*/
|
|
67
|
+
getIndent(level?: number): string;
|
|
68
|
+
/**
|
|
69
|
+
* Get line ending string
|
|
70
|
+
*/
|
|
71
|
+
getLineEnding(): string;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=GeneratorContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GeneratorContext.d.ts","sourceRoot":"","sources":["../../src/generator/GeneratorContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,qBAAa,gBAAgB;IAC3B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC;IACnC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IACxC,QAAQ,CAAC,WAAW,EAAE,UAAU,EAAE,CAAM;IAExC,OAAO,CAAC,cAAc,CAA2B;IACjD,OAAO,CAAC,YAAY,CAAyB;gBAEjC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,gBAAgB;IAOzD;;OAEG;IACH,iBAAiB,CAAC,GAAG,EAAE,UAAU,GAAG,IAAI;IAIxC;;OAEG;IACH,iBAAiB,IAAI,UAAU,GAAG,IAAI;IAItC;;OAEG;IACH,eAAe,CAAC,GAAG,EAAE,QAAQ,GAAG,IAAI;IAIpC;;OAEG;IACH,eAAe,IAAI,QAAQ,GAAG,IAAI;IAIlC;;OAEG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;IAI5C;;OAEG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;IAI5C;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;IAI7C;;OAEG;IACH,SAAS,IAAI,OAAO;IAIpB;;OAEG;IACH,aAAa,IAAI,MAAM;IAiBvB;;OAEG;IACH,SAAS,CAAC,KAAK,GAAE,MAAU,GAAG,MAAM;IAKpC;;OAEG;IACH,aAAa,IAAI,MAAM;CAGxB"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { TypeMapper } from './TypeMapper.js';
|
|
2
|
+
import { ImportResolver } from './ImportResolver.js';
|
|
3
|
+
/**
|
|
4
|
+
* Context shared during code generation
|
|
5
|
+
*/
|
|
6
|
+
export class GeneratorContext {
|
|
7
|
+
genModel;
|
|
8
|
+
options;
|
|
9
|
+
typeMapper;
|
|
10
|
+
importResolver;
|
|
11
|
+
diagnostics = [];
|
|
12
|
+
currentPackage = null;
|
|
13
|
+
currentClass = null;
|
|
14
|
+
constructor(genModel, options) {
|
|
15
|
+
this.genModel = genModel;
|
|
16
|
+
this.options = options;
|
|
17
|
+
this.typeMapper = new TypeMapper();
|
|
18
|
+
this.importResolver = new ImportResolver();
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Set the current package being processed
|
|
22
|
+
*/
|
|
23
|
+
setCurrentPackage(pkg) {
|
|
24
|
+
this.currentPackage = pkg;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Get the current package being processed
|
|
28
|
+
*/
|
|
29
|
+
getCurrentPackage() {
|
|
30
|
+
return this.currentPackage;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Set the current class being processed
|
|
34
|
+
*/
|
|
35
|
+
setCurrentClass(cls) {
|
|
36
|
+
this.currentClass = cls;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get the current class being processed
|
|
40
|
+
*/
|
|
41
|
+
getCurrentClass() {
|
|
42
|
+
return this.currentClass;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Add an info diagnostic
|
|
46
|
+
*/
|
|
47
|
+
info(message, source) {
|
|
48
|
+
this.diagnostics.push({ level: 'info', message, source });
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Add a warning diagnostic
|
|
52
|
+
*/
|
|
53
|
+
warn(message, source) {
|
|
54
|
+
this.diagnostics.push({ level: 'warning', message, source });
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Add an error diagnostic
|
|
58
|
+
*/
|
|
59
|
+
error(message, source) {
|
|
60
|
+
this.diagnostics.push({ level: 'error', message, source });
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Check if there are any errors
|
|
64
|
+
*/
|
|
65
|
+
hasErrors() {
|
|
66
|
+
return this.diagnostics.some(d => d.level === 'error');
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Get the file header
|
|
70
|
+
*/
|
|
71
|
+
getFileHeader() {
|
|
72
|
+
if (this.options.fileHeader) {
|
|
73
|
+
return this.options.fileHeader;
|
|
74
|
+
}
|
|
75
|
+
if (this.genModel.copyrightText) {
|
|
76
|
+
return `/*\n * ${this.genModel.copyrightText.split('\n').join('\n * ')}\n */`;
|
|
77
|
+
}
|
|
78
|
+
return `/*
|
|
79
|
+
* This file was generated by emfts-codegen.
|
|
80
|
+
* DO NOT EDIT - changes will be overwritten.
|
|
81
|
+
*
|
|
82
|
+
* @generated
|
|
83
|
+
*/`;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Get indentation string
|
|
87
|
+
*/
|
|
88
|
+
getIndent(level = 1) {
|
|
89
|
+
const char = this.options.indentation === 'tabs' ? '\t' : ' '.repeat(this.options.indentSize);
|
|
90
|
+
return char.repeat(level);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Get line ending string
|
|
94
|
+
*/
|
|
95
|
+
getLineEnding() {
|
|
96
|
+
return this.options.lineEnding === 'crlf' ? '\r\n' : '\n';
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=GeneratorContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GeneratorContext.js","sourceRoot":"","sources":["../../src/generator/GeneratorContext.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAarD;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAClB,QAAQ,CAAW;IACnB,OAAO,CAAmB;IAC1B,UAAU,CAAa;IACvB,cAAc,CAAiB;IAC/B,WAAW,GAAiB,EAAE,CAAC;IAEhC,cAAc,GAAsB,IAAI,CAAC;IACzC,YAAY,GAAoB,IAAI,CAAC;IAE7C,YAAY,QAAkB,EAAE,OAAyB;QACvD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC;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AE,CAAC;YAChC,OAAO,UAAU,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QAChF,CAAC;QAED,OAAO;;;;;IAKP,CAAC;IACH,CAAC;IAED;;OAEG;IACH,SAAS,CAAC,QAAgB,CAAC;QACzB,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAC9F,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,aAAa;QACX,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;IAC5D,CAAC;CACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for code generation
|
|
3
|
+
*/
|
|
4
|
+
export interface GeneratorOptions {
|
|
5
|
+
/** Output directory for generated files */
|
|
6
|
+
outputDirectory: string;
|
|
7
|
+
/** Whether to overwrite existing files */
|
|
8
|
+
overwrite: boolean;
|
|
9
|
+
/** Whether to format generated code */
|
|
10
|
+
formatCode: boolean;
|
|
11
|
+
/** File header template */
|
|
12
|
+
fileHeader?: string;
|
|
13
|
+
/** Whether to generate JSDoc comments */
|
|
14
|
+
generateJsDoc: boolean;
|
|
15
|
+
/** Line ending style */
|
|
16
|
+
lineEnding: 'lf' | 'crlf';
|
|
17
|
+
/** Indentation style */
|
|
18
|
+
indentation: 'spaces' | 'tabs';
|
|
19
|
+
/** Indentation size (for spaces) */
|
|
20
|
+
indentSize: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Default generator options
|
|
24
|
+
*/
|
|
25
|
+
export declare function createDefaultOptions(partial?: Partial<GeneratorOptions>): GeneratorOptions;
|
|
26
|
+
//# sourceMappingURL=GeneratorOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GeneratorOptions.d.ts","sourceRoot":"","sources":["../../src/generator/GeneratorOptions.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,2CAA2C;IAC3C,eAAe,EAAE,MAAM,CAAC;IAExB,0CAA0C;IAC1C,SAAS,EAAE,OAAO,CAAC;IAEnB,uCAAuC;IACvC,UAAU,EAAE,OAAO,CAAC;IAEpB,2BAA2B;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,yCAAyC;IACzC,aAAa,EAAE,OAAO,CAAC;IAEvB,wBAAwB;IACxB,UAAU,EAAE,IAAI,GAAG,MAAM,CAAC;IAE1B,wBAAwB;IACxB,WAAW,EAAE,QAAQ,GAAG,MAAM,CAAC;IAE/B,oCAAoC;IACpC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,OAAO,CAAC,gBAAgB,CAAM,GAAG,gBAAgB,CAW9F"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default generator options
|
|
3
|
+
*/
|
|
4
|
+
export function createDefaultOptions(partial = {}) {
|
|
5
|
+
return {
|
|
6
|
+
outputDirectory: './generated',
|
|
7
|
+
overwrite: true,
|
|
8
|
+
formatCode: true,
|
|
9
|
+
generateJsDoc: true,
|
|
10
|
+
lineEnding: 'lf',
|
|
11
|
+
indentation: 'spaces',
|
|
12
|
+
indentSize: 2,
|
|
13
|
+
...partial
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=GeneratorOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GeneratorOptions.js","sourceRoot":"","sources":["../../src/generator/GeneratorOptions.ts"],"names":[],"mappings":"AA6BA;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,UAAqC,EAAE;IAC1E,OAAO;QACL,eAAe,EAAE,aAAa;QAC9B,SAAS,EAAE,IAAI;QACf,UAAU,EAAE,IAAI;QAChB,aAAa,EAAE,IAAI;QACnB,UAAU,EAAE,IAAI;QAChB,WAAW,EAAE,QAAQ;QACrB,UAAU,EAAE,CAAC;QACb,GAAG,OAAO;KACX,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { EClass } from '@emfts/core';
|
|
2
|
+
import type { GenPackage } from '../genmodel/GenPackage.js';
|
|
3
|
+
import type { GenerationMode } from '../genmodel/GenerationMode.js';
|
|
4
|
+
/**
|
|
5
|
+
* Represents an import statement
|
|
6
|
+
*/
|
|
7
|
+
export interface ImportInfo {
|
|
8
|
+
/** Name of the type to import */
|
|
9
|
+
typeName: string;
|
|
10
|
+
/** Path to import from (relative or package) */
|
|
11
|
+
importPath: string;
|
|
12
|
+
/** Whether this is a type-only import */
|
|
13
|
+
isTypeOnly: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Resolves imports for generated files
|
|
17
|
+
*/
|
|
18
|
+
export declare class ImportResolver {
|
|
19
|
+
private packagePathMap;
|
|
20
|
+
/**
|
|
21
|
+
* Register a package with its import path
|
|
22
|
+
*/
|
|
23
|
+
registerPackage(nsURI: string, importPath: string): void;
|
|
24
|
+
/**
|
|
25
|
+
* Get all imports needed for a class
|
|
26
|
+
*/
|
|
27
|
+
resolveImportsForClass(eClass: EClass, genPackage: GenPackage, mode: GenerationMode): ImportInfo[];
|
|
28
|
+
/**
|
|
29
|
+
* Get super types from EClass (handles both static and dynamic)
|
|
30
|
+
*/
|
|
31
|
+
private getSuperTypes;
|
|
32
|
+
/**
|
|
33
|
+
* Get structural features from EClass (handles both static and dynamic)
|
|
34
|
+
*/
|
|
35
|
+
private getStructuralFeatures;
|
|
36
|
+
/**
|
|
37
|
+
* Add import for a classifier if needed
|
|
38
|
+
*/
|
|
39
|
+
private addImportForClassifier;
|
|
40
|
+
/**
|
|
41
|
+
* Add imports for a structural feature
|
|
42
|
+
*/
|
|
43
|
+
private addImportsForFeature;
|
|
44
|
+
/**
|
|
45
|
+
* Add imports for a generic type
|
|
46
|
+
*/
|
|
47
|
+
private addImportsForGenericType;
|
|
48
|
+
/**
|
|
49
|
+
* Resolve import for a proxy object
|
|
50
|
+
*/
|
|
51
|
+
private resolveProxyImport;
|
|
52
|
+
/**
|
|
53
|
+
* Get import path for a package
|
|
54
|
+
*/
|
|
55
|
+
private getImportPath;
|
|
56
|
+
/**
|
|
57
|
+
* Get registered import path for a package URI
|
|
58
|
+
*/
|
|
59
|
+
private getPackageImportPath;
|
|
60
|
+
/**
|
|
61
|
+
* Convert a URI to an import path
|
|
62
|
+
*/
|
|
63
|
+
private uriToImportPath;
|
|
64
|
+
/**
|
|
65
|
+
* Add mode-specific imports
|
|
66
|
+
*/
|
|
67
|
+
private addModeImports;
|
|
68
|
+
/**
|
|
69
|
+
* Get name from ENamedElement (works with both static and dynamic EObjects)
|
|
70
|
+
*/
|
|
71
|
+
private getName;
|
|
72
|
+
/**
|
|
73
|
+
* Get the package of a classifier
|
|
74
|
+
*/
|
|
75
|
+
private getEPackage;
|
|
76
|
+
/**
|
|
77
|
+
* Check if an object is an EPackage
|
|
78
|
+
*/
|
|
79
|
+
private isEPackage;
|
|
80
|
+
/**
|
|
81
|
+
* Format imports as TypeScript import statements
|
|
82
|
+
*/
|
|
83
|
+
formatImports(imports: ImportInfo[]): string;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=ImportResolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImportResolver.d.ts","sourceRoot":"","sources":["../../src/generator/ImportResolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAuE,MAAM,aAAa,CAAC;AAC/G,OAAO,KAAK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