source: trip-planner-front/node_modules/@angular/compiler-cli/src/ngtsc/routing/src/analyzer.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 12.5 KB
Line 
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-cli/src/ngtsc/routing/src/analyzer", ["require", "exports", "tslib", "@angular/compiler-cli/src/ngtsc/routing/src/lazy", "@angular/compiler-cli/src/ngtsc/routing/src/route"], factory);
15 }
16})(function (require, exports) {
17 "use strict";
18 Object.defineProperty(exports, "__esModule", { value: true });
19 exports.NgModuleRouteAnalyzer = void 0;
20 var tslib_1 = require("tslib");
21 var lazy_1 = require("@angular/compiler-cli/src/ngtsc/routing/src/lazy");
22 var route_1 = require("@angular/compiler-cli/src/ngtsc/routing/src/route");
23 var NgModuleRouteAnalyzer = /** @class */ (function () {
24 function NgModuleRouteAnalyzer(moduleResolver, evaluator) {
25 this.evaluator = evaluator;
26 this.modules = new Map();
27 this.entryPointManager = new route_1.RouterEntryPointManager(moduleResolver);
28 }
29 NgModuleRouteAnalyzer.prototype.add = function (sourceFile, moduleName, imports, exports, providers) {
30 var key = route_1.entryPointKeyFor(sourceFile.fileName, moduleName);
31 if (this.modules.has(key)) {
32 throw new Error("Double route analyzing for '" + key + "'.");
33 }
34 this.modules.set(key, {
35 sourceFile: sourceFile,
36 moduleName: moduleName,
37 imports: imports,
38 exports: exports,
39 providers: providers,
40 });
41 };
42 NgModuleRouteAnalyzer.prototype.listLazyRoutes = function (entryModuleKey) {
43 var _this = this;
44 if ((entryModuleKey !== undefined) && !this.modules.has(entryModuleKey)) {
45 throw new Error("Failed to list lazy routes: Unknown module '" + entryModuleKey + "'.");
46 }
47 var routes = [];
48 var scannedModuleKeys = new Set();
49 var pendingModuleKeys = entryModuleKey ? [entryModuleKey] : Array.from(this.modules.keys());
50 // When listing lazy routes for a specific entry module, we need to recursively extract
51 // "transitive" routes from imported/exported modules. This is not necessary when listing all
52 // lazy routes, because all analyzed modules will be scanned anyway.
53 var scanRecursively = entryModuleKey !== undefined;
54 while (pendingModuleKeys.length > 0) {
55 var key = pendingModuleKeys.pop();
56 if (scannedModuleKeys.has(key)) {
57 continue;
58 }
59 else {
60 scannedModuleKeys.add(key);
61 }
62 var data = this.modules.get(key);
63 var entryPoints = lazy_1.scanForRouteEntryPoints(data.sourceFile, data.moduleName, data, this.entryPointManager, this.evaluator);
64 routes.push.apply(routes, tslib_1.__spreadArray([], tslib_1.__read(entryPoints.map(function (entryPoint) { return ({
65 route: entryPoint.loadChildren,
66 module: entryPoint.from,
67 referencedModule: entryPoint.resolvedTo,
68 }); }))));
69 if (scanRecursively) {
70 pendingModuleKeys.push.apply(pendingModuleKeys, tslib_1.__spreadArray([], tslib_1.__read(tslib_1.__spreadArray(tslib_1.__spreadArray(tslib_1.__spreadArray([], tslib_1.__read(entryPoints.map(function (_a) {
71 var resolvedTo = _a.resolvedTo;
72 return route_1.entryPointKeyFor(resolvedTo.filePath, resolvedTo.moduleName);
73 }))), tslib_1.__read(lazy_1.scanForCandidateTransitiveModules(data.imports, this.evaluator))), tslib_1.__read(lazy_1.scanForCandidateTransitiveModules(data.exports, this.evaluator))).filter(function (key) { return _this.modules.has(key); }))));
74 }
75 }
76 return routes;
77 };
78 return NgModuleRouteAnalyzer;
79 }());
80 exports.NgModuleRouteAnalyzer = NgModuleRouteAnalyzer;
81});
82//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYW5hbHl6ZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9jb21waW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aW5nTW9kdWxlS2V5cy5sZW5ndGggPiAwKSB7XG4gICAgICBjb25zdCBrZXkgPSBwZW5kaW5nTW9kdWxlS2V5cy5wb3AoKSE7XG5cbiAgICAgIGlmIChzY2FubmVkTW9kdWxlS2V5cy5oYXMoa2V5KSkge1xuICAgICAgICBjb250aW51ZTtcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIHNjYW5uZWRNb2R1bGVLZXlzLmFkZChrZXkpO1xuICAgICAgfVxuXG4gICAgICBjb25zdCBkYXRhID0gdGhpcy5tb2R1bGVzLmdldChrZXkpITtcbiAgICAgIGNvbnN0IGVudHJ5UG9pbnRzID0gc2NhbkZvclJvdXRlRW50cnlQb2ludHMoXG4gICAgICAgICAgZGF0YS5zb3VyY2VGaWxlLCBkYXRhLm1vZHVsZU5hbWUsIGRhdGEsIHRoaXMuZW50cnlQb2ludE1hbmFnZXIsIHRoaXMuZXZhbHVhdG9yKTtcblxuICAgICAgcm91dGVzLnB1c2goLi4uZW50cnlQb2ludHMubWFwKGVudHJ5UG9pbnQgPT4gKHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJvdXRlOiBlbnRyeVBvaW50LmxvYWRDaGlsZHJlbixcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1vZHVsZTogZW50cnlQb2ludC5mcm9tLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVmZXJlbmNlZE1vZHVsZTogZW50cnlQb2ludC5yZXNvbHZlZFRvLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pKSk7XG5cbiAgICAgIGlmIChzY2FuUmVjdXJzaXZlbHkpIHtcbiAgICAgICAgcGVuZGluZ01vZHVsZUtleXMucHVzaChcbiAgICAgICAgICAgIC4uLltcbiAgICAgICAgICAgICAgICAvLyBTY2FuIHRoZSByZXRyaWV2ZWQgbGF6eSByb3V0ZSBlbnRyeSBwb2ludHMuXG4gICAgICAgICAgICAgICAgLi4uZW50cnlQb2ludHMubWFwKFxuICAgICAgICAgICAgICAgICAgICAoe3Jlc29sdmVkVG99KSA9PiBlbnRyeVBvaW50S2V5Rm9yKHJlc29sdmVkVG8uZmlsZVBhdGgsIHJlc29sdmVkVG8ubW9kdWxlTmFtZSkpLFxuICAgICAgICAgICAgICAgIC8vIFNjYW4gdGhlIGN1cnJlbnQgbW9kdWxlJ3MgaW1wb3J0ZWQgbW9kdWxlcy5cbiAgICAgICAgICAgICAgICAuLi5zY2FuRm9yQ2FuZGlkYXRlVHJhbnNpdGl2ZU1vZHVsZXMoZGF0YS5pbXBvcnRzLCB0aGlzLmV2YWx1YXRvciksXG4gICAgICAgICAgICAgICAgLy8gU2NhbiB0aGUgY3VycmVudCBtb2R1bGUncyBleHBvcnRlZCBtb2R1bGVzLlxuICAgICAgICAgICAgICAgIC4uLnNjYW5Gb3JDYW5kaWRhdGVUcmFuc2l0aXZlTW9kdWxlcyhkYXRhLmV4cG9ydHMsIHRoaXMuZXZhbHVhdG9yKSxcbiAgICAgICAgXS5maWx0ZXIoa2V5ID0+IHRoaXMubW9kdWxlcy5oYXMoa2V5KSkpO1xuICAgICAgfVxuICAgIH1cblxuICAgIHJldHVybiByb3V0ZXM7XG4gIH1cbn1cbiJdfQ==
Note: See TracBrowser for help on using the repository browser.