source: trip-planner-front/node_modules/@angular/compiler/esm2015/src/aot/lazy_routes.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: 6.2 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 */
8import { tokenReference } from '../compile_metadata';
9export function listLazyRoutes(moduleMeta, reflector) {
10 const allLazyRoutes = [];
11 for (const { provider, module } of moduleMeta.transitiveModule.providers) {
12 if (tokenReference(provider.token) === reflector.ROUTES) {
13 const loadChildren = _collectLoadChildren(provider.useValue);
14 for (const route of loadChildren) {
15 allLazyRoutes.push(parseLazyRoute(route, reflector, module.reference));
16 }
17 }
18 }
19 return allLazyRoutes;
20}
21function _collectLoadChildren(routes, target = []) {
22 if (typeof routes === 'string') {
23 target.push(routes);
24 }
25 else if (Array.isArray(routes)) {
26 for (const route of routes) {
27 _collectLoadChildren(route, target);
28 }
29 }
30 else if (routes.loadChildren) {
31 _collectLoadChildren(routes.loadChildren, target);
32 }
33 else if (routes.children) {
34 _collectLoadChildren(routes.children, target);
35 }
36 return target;
37}
38export function parseLazyRoute(route, reflector, module) {
39 const [routePath, routeName] = route.split('#');
40 const referencedModule = reflector.resolveExternalReference({
41 moduleName: routePath,
42 name: routeName,
43 }, module ? module.filePath : undefined);
44 return { route: route, module: module || referencedModule, referencedModule };
45}
46//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGF6eV9yb3V0ZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9wYWNrYWdlcy9jb21waWxlci9zcmMvYW90L2xhenlfcm91dGVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7R0FNRztBQUVILE9BQU8sRUFBMEIsY0FBYyxFQUFDLE1BQU0scUJB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