/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); if (v !== undefined) module.exports = v; } else if (typeof define === "function" && define.amd) { define("@angular/compiler/src/aot/summary_resolver", ["require", "exports", "@angular/compiler/src/aot/summary_serializer", "@angular/compiler/src/aot/util"], factory); } })(function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AotSummaryResolver = void 0; var summary_serializer_1 = require("@angular/compiler/src/aot/summary_serializer"); var util_1 = require("@angular/compiler/src/aot/util"); var AotSummaryResolver = /** @class */ (function () { function AotSummaryResolver(host, staticSymbolCache) { this.host = host; this.staticSymbolCache = staticSymbolCache; // Note: this will only contain StaticSymbols without members! this.summaryCache = new Map(); this.loadedFilePaths = new Map(); // Note: this will only contain StaticSymbols without members! this.importAs = new Map(); this.knownFileNameToModuleNames = new Map(); } AotSummaryResolver.prototype.isLibraryFile = function (filePath) { // Note: We need to strip the .ngfactory. file path, // so this method also works for generated files // (for which host.isSourceFile will always return false). return !this.host.isSourceFile(util_1.stripGeneratedFileSuffix(filePath)); }; AotSummaryResolver.prototype.toSummaryFileName = function (filePath, referringSrcFileName) { return this.host.toSummaryFileName(filePath, referringSrcFileName); }; AotSummaryResolver.prototype.fromSummaryFileName = function (fileName, referringLibFileName) { return this.host.fromSummaryFileName(fileName, referringLibFileName); }; AotSummaryResolver.prototype.resolveSummary = function (staticSymbol) { var rootSymbol = staticSymbol.members.length ? this.staticSymbolCache.get(staticSymbol.filePath, staticSymbol.name) : staticSymbol; var summary = this.summaryCache.get(rootSymbol); if (!summary) { this._loadSummaryFile(staticSymbol.filePath); summary = this.summaryCache.get(staticSymbol); } return (rootSymbol === staticSymbol && summary) || null; }; AotSummaryResolver.prototype.getSymbolsOf = function (filePath) { if (this._loadSummaryFile(filePath)) { return Array.from(this.summaryCache.keys()).filter(function (symbol) { return symbol.filePath === filePath; }); } return null; }; AotSummaryResolver.prototype.getImportAs = function (staticSymbol) { staticSymbol.assertNoMembers(); return this.importAs.get(staticSymbol); }; /** * Converts a file path to a module name that can be used as an `import`. */ AotSummaryResolver.prototype.getKnownModuleName = function (importedFilePath) { return this.knownFileNameToModuleNames.get(importedFilePath) || null; }; AotSummaryResolver.prototype.addSummary = function (summary) { this.summaryCache.set(summary.symbol, summary); }; AotSummaryResolver.prototype._loadSummaryFile = function (filePath) { var _this = this; var hasSummary = this.loadedFilePaths.get(filePath); if (hasSummary != null) { return hasSummary; } var json = null; if (this.isLibraryFile(filePath)) { var summaryFilePath = util_1.summaryFileName(filePath); try { json = this.host.loadSummary(summaryFilePath); } catch (e) { console.error("Error loading summary file " + summaryFilePath); throw e; } } hasSummary = json != null; this.loadedFilePaths.set(filePath, hasSummary); if (json) { var _a = summary_serializer_1.deserializeSummaries(this.staticSymbolCache, this, filePath, json), moduleName = _a.moduleName, summaries = _a.summaries, importAs = _a.importAs; summaries.forEach(function (summary) { return _this.summaryCache.set(summary.symbol, summary); }); if (moduleName) { this.knownFileNameToModuleNames.set(filePath, moduleName); } importAs.forEach(function (importAs) { _this.importAs.set(importAs.symbol, importAs.importAs); }); } return hasSummary; }; return AotSummaryResolver; }()); exports.AotSummaryResolver = AotSummaryResolver; }); //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3VtbWFyeV9yZXNvbHZlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL2NvbXBpbGVyL3NyYy9hb3Qvc3VtbWFyeV9yZXNvbHZlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7Ozs7Ozs7Ozs7Ozs7SUFLSCxtRkFBMEQ7SUFDMUQsdURBQWlFO0lBNkJqRTtRQVFFLDRCQUFvQixJQUE0QixFQUFVLGlCQUFvQztZQ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