[6a3a178] | 1 | /**
|
---|
| 2 | * @license
|
---|
| 3 | * Copyright Google LLC All Rights Reserved.
|
---|
| 4 | *
|
---|
| 5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 6 | * found in the LICENSE file at https://angular.io/license
|
---|
| 7 | */
|
---|
| 8 | (function (factory) {
|
---|
| 9 | if (typeof module === "object" && typeof module.exports === "object") {
|
---|
| 10 | var v = factory(require, exports);
|
---|
| 11 | if (v !== undefined) module.exports = v;
|
---|
| 12 | }
|
---|
| 13 | else if (typeof define === "function" && define.amd) {
|
---|
| 14 | define("@angular/compiler/src/aot/generated_file", ["require", "exports", "@angular/compiler/src/output/output_ast", "@angular/compiler/src/output/ts_emitter"], factory);
|
---|
| 15 | }
|
---|
| 16 | })(function (require, exports) {
|
---|
| 17 | "use strict";
|
---|
| 18 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
| 19 | exports.toTypeScript = exports.GeneratedFile = void 0;
|
---|
| 20 | var output_ast_1 = require("@angular/compiler/src/output/output_ast");
|
---|
| 21 | var ts_emitter_1 = require("@angular/compiler/src/output/ts_emitter");
|
---|
| 22 | var GeneratedFile = /** @class */ (function () {
|
---|
| 23 | function GeneratedFile(srcFileUrl, genFileUrl, sourceOrStmts) {
|
---|
| 24 | this.srcFileUrl = srcFileUrl;
|
---|
| 25 | this.genFileUrl = genFileUrl;
|
---|
| 26 | if (typeof sourceOrStmts === 'string') {
|
---|
| 27 | this.source = sourceOrStmts;
|
---|
| 28 | this.stmts = null;
|
---|
| 29 | }
|
---|
| 30 | else {
|
---|
| 31 | this.source = null;
|
---|
| 32 | this.stmts = sourceOrStmts;
|
---|
| 33 | }
|
---|
| 34 | }
|
---|
| 35 | GeneratedFile.prototype.isEquivalent = function (other) {
|
---|
| 36 | if (this.genFileUrl !== other.genFileUrl) {
|
---|
| 37 | return false;
|
---|
| 38 | }
|
---|
| 39 | if (this.source) {
|
---|
| 40 | return this.source === other.source;
|
---|
| 41 | }
|
---|
| 42 | if (other.stmts == null) {
|
---|
| 43 | return false;
|
---|
| 44 | }
|
---|
| 45 | // Note: the constructor guarantees that if this.source is not filled,
|
---|
| 46 | // then this.stmts is.
|
---|
| 47 | return output_ast_1.areAllEquivalent(this.stmts, other.stmts);
|
---|
| 48 | };
|
---|
| 49 | return GeneratedFile;
|
---|
| 50 | }());
|
---|
| 51 | exports.GeneratedFile = GeneratedFile;
|
---|
| 52 | function toTypeScript(file, preamble) {
|
---|
| 53 | if (preamble === void 0) { preamble = ''; }
|
---|
| 54 | if (!file.stmts) {
|
---|
| 55 | throw new Error("Illegal state: No stmts present on GeneratedFile " + file.genFileUrl);
|
---|
| 56 | }
|
---|
| 57 | return new ts_emitter_1.TypeScriptEmitter().emitStatements(file.genFileUrl, file.stmts, preamble);
|
---|
| 58 | }
|
---|
| 59 | exports.toTypeScript = toTypeScript;
|
---|
| 60 | });
|
---|
| 61 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2VuZXJhdGVkX2ZpbGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9jb21waWxlci9zcmMvYW90L2dlbmVyYXRlZF9maWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7R0FNRzs7Ozs7Ozs7Ozs7OztJQUVILHNFQUFpRTtJQUNqRSxzRUFBdUQ7SUFFdkQ7UUFJRSx1QkFDVyxVQUFrQixFQUFTLFVBQWtCLEVBQUUsYUFBaUM7WUFBaEYsZUFBVSxHQUFWLFVBQVUsQ0FBUTtZQUFTLGVBQVUsR0FBVixVQUFVLENBQVE7WUFDdEQsSUFBSSxPQUFPLGFBQWEsS0FBSyxRQUFRLEVBQUU7Z0JBQ3JDLElBQUksQ0FBQyxNQUFNLEdBQUcsYUFBYSxDQUFDO2dCQUM1QixJQUFJLENBQUMsS0FBSyxHQUFHLElBQUksQ0FBQzthQ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