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/summary_resolver", ["require", "exports", "@angular/compiler/src/aot/summary_serializer", "@angular/compiler/src/aot/util"], factory);
|
---|
15 | }
|
---|
16 | })(function (require, exports) {
|
---|
17 | "use strict";
|
---|
18 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
19 | exports.AotSummaryResolver = void 0;
|
---|
20 | var summary_serializer_1 = require("@angular/compiler/src/aot/summary_serializer");
|
---|
21 | var util_1 = require("@angular/compiler/src/aot/util");
|
---|
22 | var AotSummaryResolver = /** @class */ (function () {
|
---|
23 | function AotSummaryResolver(host, staticSymbolCache) {
|
---|
24 | this.host = host;
|
---|
25 | this.staticSymbolCache = staticSymbolCache;
|
---|
26 | // Note: this will only contain StaticSymbols without members!
|
---|
27 | this.summaryCache = new Map();
|
---|
28 | this.loadedFilePaths = new Map();
|
---|
29 | // Note: this will only contain StaticSymbols without members!
|
---|
30 | this.importAs = new Map();
|
---|
31 | this.knownFileNameToModuleNames = new Map();
|
---|
32 | }
|
---|
33 | AotSummaryResolver.prototype.isLibraryFile = function (filePath) {
|
---|
34 | // Note: We need to strip the .ngfactory. file path,
|
---|
35 | // so this method also works for generated files
|
---|
36 | // (for which host.isSourceFile will always return false).
|
---|
37 | return !this.host.isSourceFile(util_1.stripGeneratedFileSuffix(filePath));
|
---|
38 | };
|
---|
39 | AotSummaryResolver.prototype.toSummaryFileName = function (filePath, referringSrcFileName) {
|
---|
40 | return this.host.toSummaryFileName(filePath, referringSrcFileName);
|
---|
41 | };
|
---|
42 | AotSummaryResolver.prototype.fromSummaryFileName = function (fileName, referringLibFileName) {
|
---|
43 | return this.host.fromSummaryFileName(fileName, referringLibFileName);
|
---|
44 | };
|
---|
45 | AotSummaryResolver.prototype.resolveSummary = function (staticSymbol) {
|
---|
46 | var rootSymbol = staticSymbol.members.length ?
|
---|
47 | this.staticSymbolCache.get(staticSymbol.filePath, staticSymbol.name) :
|
---|
48 | staticSymbol;
|
---|
49 | var summary = this.summaryCache.get(rootSymbol);
|
---|
50 | if (!summary) {
|
---|
51 | this._loadSummaryFile(staticSymbol.filePath);
|
---|
52 | summary = this.summaryCache.get(staticSymbol);
|
---|
53 | }
|
---|
54 | return (rootSymbol === staticSymbol && summary) || null;
|
---|
55 | };
|
---|
56 | AotSummaryResolver.prototype.getSymbolsOf = function (filePath) {
|
---|
57 | if (this._loadSummaryFile(filePath)) {
|
---|
58 | return Array.from(this.summaryCache.keys()).filter(function (symbol) { return symbol.filePath === filePath; });
|
---|
59 | }
|
---|
60 | return null;
|
---|
61 | };
|
---|
62 | AotSummaryResolver.prototype.getImportAs = function (staticSymbol) {
|
---|
63 | staticSymbol.assertNoMembers();
|
---|
64 | return this.importAs.get(staticSymbol);
|
---|
65 | };
|
---|
66 | /**
|
---|
67 | * Converts a file path to a module name that can be used as an `import`.
|
---|
68 | */
|
---|
69 | AotSummaryResolver.prototype.getKnownModuleName = function (importedFilePath) {
|
---|
70 | return this.knownFileNameToModuleNames.get(importedFilePath) || null;
|
---|
71 | };
|
---|
72 | AotSummaryResolver.prototype.addSummary = function (summary) {
|
---|
73 | this.summaryCache.set(summary.symbol, summary);
|
---|
74 | };
|
---|
75 | AotSummaryResolver.prototype._loadSummaryFile = function (filePath) {
|
---|
76 | var _this = this;
|
---|
77 | var hasSummary = this.loadedFilePaths.get(filePath);
|
---|
78 | if (hasSummary != null) {
|
---|
79 | return hasSummary;
|
---|
80 | }
|
---|
81 | var json = null;
|
---|
82 | if (this.isLibraryFile(filePath)) {
|
---|
83 | var summaryFilePath = util_1.summaryFileName(filePath);
|
---|
84 | try {
|
---|
85 | json = this.host.loadSummary(summaryFilePath);
|
---|
86 | }
|
---|
87 | catch (e) {
|
---|
88 | console.error("Error loading summary file " + summaryFilePath);
|
---|
89 | throw e;
|
---|
90 | }
|
---|
91 | }
|
---|
92 | hasSummary = json != null;
|
---|
93 | this.loadedFilePaths.set(filePath, hasSummary);
|
---|
94 | if (json) {
|
---|
95 | var _a = summary_serializer_1.deserializeSummaries(this.staticSymbolCache, this, filePath, json), moduleName = _a.moduleName, summaries = _a.summaries, importAs = _a.importAs;
|
---|
96 | summaries.forEach(function (summary) { return _this.summaryCache.set(summary.symbol, summary); });
|
---|
97 | if (moduleName) {
|
---|
98 | this.knownFileNameToModuleNames.set(filePath, moduleName);
|
---|
99 | }
|
---|
100 | importAs.forEach(function (importAs) {
|
---|
101 | _this.importAs.set(importAs.symbol, importAs.importAs);
|
---|
102 | });
|
---|
103 | }
|
---|
104 | return hasSummary;
|
---|
105 | };
|
---|
106 | return AotSummaryResolver;
|
---|
107 | }());
|
---|
108 | exports.AotSummaryResolver = AotSummaryResolver;
|
---|
109 | });
|
---|
110 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3VtbWFyeV9yZXNvbHZlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL2NvbXBpbGVyL3NyYy9hb3Qvc3VtbWFyeV9yZXNvbHZlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7Ozs7Ozs7Ozs7Ozs7SUFLSCxtRkFBMEQ7SUFDMUQsdURBQWlFO0lBNkJqRTtRQVFFLDRCQUFvQixJQUE0QixFQUFVLGlCQUFvQztZQUExRSxTQUFJLEdBQUosSUFBSSxDQUF3QjtZQUFVLHNCQUFpQixHQUFqQixpQkFBaUIsQ0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