1 | (function (factory) {
|
---|
2 | if (typeof module === "object" && typeof module.exports === "object") {
|
---|
3 | var v = factory(require, exports);
|
---|
4 | if (v !== undefined) module.exports = v;
|
---|
5 | }
|
---|
6 | else if (typeof define === "function" && define.amd) {
|
---|
7 | define("@angular/compiler-cli/ngcc/src/rendering/renderer", ["require", "exports", "tslib", "@angular/compiler", "magic-string", "@angular/compiler-cli/src/ngtsc/translator", "@angular/compiler-cli/ngcc/src/constants", "@angular/compiler-cli/ngcc/src/rendering/rendering_formatter", "@angular/compiler-cli/ngcc/src/rendering/source_maps", "@angular/compiler-cli/ngcc/src/rendering/utils"], factory);
|
---|
8 | }
|
---|
9 | })(function (require, exports) {
|
---|
10 | "use strict";
|
---|
11 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
12 | exports.renderConstantPool = exports.Renderer = void 0;
|
---|
13 | var tslib_1 = require("tslib");
|
---|
14 | /**
|
---|
15 | * @license
|
---|
16 | * Copyright Google LLC All Rights Reserved.
|
---|
17 | *
|
---|
18 | * Use of this source code is governed by an MIT-style license that can be
|
---|
19 | * found in the LICENSE file at https://angular.io/license
|
---|
20 | */
|
---|
21 | var compiler_1 = require("@angular/compiler");
|
---|
22 | var magic_string_1 = require("magic-string");
|
---|
23 | var translator_1 = require("@angular/compiler-cli/src/ngtsc/translator");
|
---|
24 | var constants_1 = require("@angular/compiler-cli/ngcc/src/constants");
|
---|
25 | var rendering_formatter_1 = require("@angular/compiler-cli/ngcc/src/rendering/rendering_formatter");
|
---|
26 | var source_maps_1 = require("@angular/compiler-cli/ngcc/src/rendering/source_maps");
|
---|
27 | var utils_1 = require("@angular/compiler-cli/ngcc/src/rendering/utils");
|
---|
28 | /**
|
---|
29 | * A base-class for rendering an `AnalyzedFile`.
|
---|
30 | *
|
---|
31 | * Package formats have output files that must be rendered differently. Concrete sub-classes must
|
---|
32 | * implement the `addImports`, `addDefinitions` and `removeDecorators` abstract methods.
|
---|
33 | */
|
---|
34 | var Renderer = /** @class */ (function () {
|
---|
35 | function Renderer(host, srcFormatter, fs, logger, bundle, tsConfig) {
|
---|
36 | if (tsConfig === void 0) { tsConfig = null; }
|
---|
37 | this.host = host;
|
---|
38 | this.srcFormatter = srcFormatter;
|
---|
39 | this.fs = fs;
|
---|
40 | this.logger = logger;
|
---|
41 | this.bundle = bundle;
|
---|
42 | this.tsConfig = tsConfig;
|
---|
43 | }
|
---|
44 | Renderer.prototype.renderProgram = function (decorationAnalyses, switchMarkerAnalyses, privateDeclarationsAnalyses) {
|
---|
45 | var _this = this;
|
---|
46 | var renderedFiles = [];
|
---|
47 | // Transform the source files.
|
---|
48 | this.bundle.src.program.getSourceFiles().forEach(function (sourceFile) {
|
---|
49 | if (decorationAnalyses.has(sourceFile) || switchMarkerAnalyses.has(sourceFile) ||
|
---|
50 | sourceFile === _this.bundle.src.file) {
|
---|
51 | var compiledFile = decorationAnalyses.get(sourceFile);
|
---|
52 | var switchMarkerAnalysis = switchMarkerAnalyses.get(sourceFile);
|
---|
53 | renderedFiles.push.apply(renderedFiles, tslib_1.__spreadArray([], tslib_1.__read(_this.renderFile(sourceFile, compiledFile, switchMarkerAnalysis, privateDeclarationsAnalyses))));
|
---|
54 | }
|
---|
55 | });
|
---|
56 | return renderedFiles;
|
---|
57 | };
|
---|
58 | /**
|
---|
59 | * Render the source code and source-map for an Analyzed file.
|
---|
60 | * @param compiledFile The analyzed file to render.
|
---|
61 | * @param targetPath The absolute path where the rendered file will be written.
|
---|
62 | */
|
---|
63 | Renderer.prototype.renderFile = function (sourceFile, compiledFile, switchMarkerAnalysis, privateDeclarationsAnalyses) {
|
---|
64 | var _this = this;
|
---|
65 | var isEntryPoint = sourceFile === this.bundle.src.file;
|
---|
66 | var outputText = new magic_string_1.default(sourceFile.text);
|
---|
67 | if (switchMarkerAnalysis) {
|
---|
68 | this.srcFormatter.rewriteSwitchableDeclarations(outputText, switchMarkerAnalysis.sourceFile, switchMarkerAnalysis.declarations);
|
---|
69 | }
|
---|
70 | var importManager = new translator_1.ImportManager(utils_1.getImportRewriter(this.bundle.src.r3SymbolsFile, this.bundle.isCore, this.bundle.isFlatCore), constants_1.IMPORT_PREFIX);
|
---|
71 | if (compiledFile) {
|
---|
72 | // TODO: remove constructor param metadata and property decorators (we need info from the
|
---|
73 | // handlers to do this)
|
---|
74 | var decoratorsToRemove = this.computeDecoratorsToRemove(compiledFile.compiledClasses);
|
---|
75 | this.srcFormatter.removeDecorators(outputText, decoratorsToRemove);
|
---|
76 | compiledFile.compiledClasses.forEach(function (clazz) {
|
---|
77 | var _a;
|
---|
78 | var renderedDefinition = _this.renderDefinitions(compiledFile.sourceFile, clazz, importManager, !!((_a = _this.tsConfig) === null || _a === void 0 ? void 0 : _a.options.annotateForClosureCompiler));
|
---|
79 | _this.srcFormatter.addDefinitions(outputText, clazz, renderedDefinition);
|
---|
80 | var renderedStatements = _this.renderAdjacentStatements(compiledFile.sourceFile, clazz, importManager);
|
---|
81 | _this.srcFormatter.addAdjacentStatements(outputText, clazz, renderedStatements);
|
---|
82 | });
|
---|
83 | if (!isEntryPoint && compiledFile.reexports.length > 0) {
|
---|
84 | this.srcFormatter.addDirectExports(outputText, compiledFile.reexports, importManager, compiledFile.sourceFile);
|
---|
85 | }
|
---|
86 | this.srcFormatter.addConstants(outputText, renderConstantPool(this.srcFormatter, compiledFile.sourceFile, compiledFile.constantPool, importManager), compiledFile.sourceFile);
|
---|
87 | }
|
---|
88 | // Add exports to the entry-point file
|
---|
89 | if (isEntryPoint) {
|
---|
90 | var entryPointBasePath = utils_1.stripExtension(this.bundle.src.path);
|
---|
91 | this.srcFormatter.addExports(outputText, entryPointBasePath, privateDeclarationsAnalyses, importManager, sourceFile);
|
---|
92 | }
|
---|
93 | if (isEntryPoint || compiledFile) {
|
---|
94 | this.srcFormatter.addImports(outputText, importManager.getAllImports(sourceFile.fileName), sourceFile);
|
---|
95 | }
|
---|
96 | if (compiledFile || switchMarkerAnalysis || isEntryPoint) {
|
---|
97 | return source_maps_1.renderSourceAndMap(this.logger, this.fs, sourceFile, outputText);
|
---|
98 | }
|
---|
99 | else {
|
---|
100 | return [];
|
---|
101 | }
|
---|
102 | };
|
---|
103 | /**
|
---|
104 | * From the given list of classes, computes a map of decorators that should be removed.
|
---|
105 | * The decorators to remove are keyed by their container node, such that we can tell if
|
---|
106 | * we should remove the entire decorator property.
|
---|
107 | * @param classes The list of classes that may have decorators to remove.
|
---|
108 | * @returns A map of decorators to remove, keyed by their container node.
|
---|
109 | */
|
---|
110 | Renderer.prototype.computeDecoratorsToRemove = function (classes) {
|
---|
111 | var decoratorsToRemove = new rendering_formatter_1.RedundantDecoratorMap();
|
---|
112 | classes.forEach(function (clazz) {
|
---|
113 | if (clazz.decorators === null) {
|
---|
114 | return;
|
---|
115 | }
|
---|
116 | clazz.decorators.forEach(function (dec) {
|
---|
117 | if (dec.node === null) {
|
---|
118 | return;
|
---|
119 | }
|
---|
120 | var decoratorArray = dec.node.parent;
|
---|
121 | if (!decoratorsToRemove.has(decoratorArray)) {
|
---|
122 | decoratorsToRemove.set(decoratorArray, [dec.node]);
|
---|
123 | }
|
---|
124 | else {
|
---|
125 | decoratorsToRemove.get(decoratorArray).push(dec.node);
|
---|
126 | }
|
---|
127 | });
|
---|
128 | });
|
---|
129 | return decoratorsToRemove;
|
---|
130 | };
|
---|
131 | /**
|
---|
132 | * Render the definitions as source code for the given class.
|
---|
133 | * @param sourceFile The file containing the class to process.
|
---|
134 | * @param clazz The class whose definitions are to be rendered.
|
---|
135 | * @param compilation The results of analyzing the class - this is used to generate the rendered
|
---|
136 | * definitions.
|
---|
137 | * @param imports An object that tracks the imports that are needed by the rendered definitions.
|
---|
138 | */
|
---|
139 | Renderer.prototype.renderDefinitions = function (sourceFile, compiledClass, imports, annotateForClosureCompiler) {
|
---|
140 | var name = this.host.getInternalNameOfClass(compiledClass.declaration);
|
---|
141 | var leadingComment = annotateForClosureCompiler ? compiler_1.jsDocComment([{ tagName: 'nocollapse' }]) : undefined;
|
---|
142 | var statements = compiledClass.compilation.map(function (c) { return createAssignmentStatement(name, c.name, c.initializer, leadingComment); });
|
---|
143 | return this.renderStatements(sourceFile, statements, imports);
|
---|
144 | };
|
---|
145 | /**
|
---|
146 | * Render the adjacent statements as source code for the given class.
|
---|
147 | * @param sourceFile The file containing the class to process.
|
---|
148 | * @param clazz The class whose statements are to be rendered.
|
---|
149 | * @param compilation The results of analyzing the class - this is used to generate the rendered
|
---|
150 | * definitions.
|
---|
151 | * @param imports An object that tracks the imports that are needed by the rendered definitions.
|
---|
152 | */
|
---|
153 | Renderer.prototype.renderAdjacentStatements = function (sourceFile, compiledClass, imports) {
|
---|
154 | var e_1, _a;
|
---|
155 | var statements = [];
|
---|
156 | try {
|
---|
157 | for (var _b = tslib_1.__values(compiledClass.compilation), _c = _b.next(); !_c.done; _c = _b.next()) {
|
---|
158 | var c = _c.value;
|
---|
159 | statements.push.apply(statements, tslib_1.__spreadArray([], tslib_1.__read(c.statements)));
|
---|
160 | }
|
---|
161 | }
|
---|
162 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
---|
163 | finally {
|
---|
164 | try {
|
---|
165 | if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
---|
166 | }
|
---|
167 | finally { if (e_1) throw e_1.error; }
|
---|
168 | }
|
---|
169 | return this.renderStatements(sourceFile, statements, imports);
|
---|
170 | };
|
---|
171 | Renderer.prototype.renderStatements = function (sourceFile, statements, imports) {
|
---|
172 | var _this = this;
|
---|
173 | var printStatement = function (stmt) {
|
---|
174 | return _this.srcFormatter.printStatement(stmt, sourceFile, imports);
|
---|
175 | };
|
---|
176 | return statements.map(printStatement).join('\n');
|
---|
177 | };
|
---|
178 | return Renderer;
|
---|
179 | }());
|
---|
180 | exports.Renderer = Renderer;
|
---|
181 | /**
|
---|
182 | * Render the constant pool as source code for the given class.
|
---|
183 | */
|
---|
184 | function renderConstantPool(formatter, sourceFile, constantPool, imports) {
|
---|
185 | var printStatement = function (stmt) { return formatter.printStatement(stmt, sourceFile, imports); };
|
---|
186 | return constantPool.statements.map(printStatement).join('\n');
|
---|
187 | }
|
---|
188 | exports.renderConstantPool = renderConstantPool;
|
---|
189 | /**
|
---|
190 | * Create an Angular AST statement node that contains the assignment of the
|
---|
191 | * compiled decorator to be applied to the class.
|
---|
192 | * @param analyzedClass The info about the class whose statement we want to create.
|
---|
193 | */
|
---|
194 | function createAssignmentStatement(receiverName, propName, initializer, leadingComment) {
|
---|
195 | var receiver = new compiler_1.WrappedNodeExpr(receiverName);
|
---|
196 | var statement = new compiler_1.WritePropExpr(receiver, propName, initializer, /* type */ undefined, /* sourceSpan */ undefined)
|
---|
197 | .toStmt();
|
---|
198 | if (leadingComment !== undefined) {
|
---|
199 | statement.addLeadingComment(leadingComment);
|
---|
200 | }
|
---|
201 | return statement;
|
---|
202 | }
|
---|
203 | });
|
---|
204 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVuZGVyZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9jb21waWxlci1jbGkvbmdjYy9zcmMvcmVuZGVyaW5nL3JlbmRlcmVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7SUFBQTs7Ozs7O09BTUc7SUFDSCw4Q0FBb0k7SUFDcEksNkNBQXVDO0lBS3ZDLHlFQUE0RDtJQUs1RCxzRUFBMkM7SUFJM0Msb0dBQWdGO0lBQ2hGLG9GQUFpRDtJQUNqRCx3RUFBdUU7SUFFdkU7Ozs7O09BS0c7SUFDSDtRQUNFLGtCQUNZLElBQXdCLEVBQVUsWUFBZ0MsRUFDbEUsRUFBc0IsRUFBVSxNQUFjLEVBQVUsTUFBd0IsRUFDaEYsUUFBeUM7WUFBekMseUJBQUEsRUFBQSxlQUF5QztZQUZ6QyxTQUFJLEdBQUosSUFBSSxDQUFvQjtZQUFVLGlCQUFZLEdBQVosWU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