router_config_loader.js
3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/**
* @license
* Copyright Google Inc. 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
*/
import { Compiler, OpaqueToken } from '@angular/core';
import { fromPromise } from 'rxjs/observable/fromPromise';
import { of } from 'rxjs/observable/of';
import { map } from 'rxjs/operator/map';
import { mergeMap } from 'rxjs/operator/mergeMap';
import { flatten, wrapIntoObservable } from './utils/collection';
/**
* @experimental
*/
export var /** @type {?} */ ROUTES = new OpaqueToken('ROUTES');
export var LoadedRouterConfig = (function () {
/**
* @param {?} routes
* @param {?} injector
* @param {?} factoryResolver
* @param {?} injectorFactory
*/
function LoadedRouterConfig(routes, injector, factoryResolver, injectorFactory) {
this.routes = routes;
this.injector = injector;
this.factoryResolver = factoryResolver;
this.injectorFactory = injectorFactory;
}
return LoadedRouterConfig;
}());
function LoadedRouterConfig_tsickle_Closure_declarations() {
/** @type {?} */
LoadedRouterConfig.prototype.routes;
/** @type {?} */
LoadedRouterConfig.prototype.injector;
/** @type {?} */
LoadedRouterConfig.prototype.factoryResolver;
/** @type {?} */
LoadedRouterConfig.prototype.injectorFactory;
}
export var RouterConfigLoader = (function () {
/**
* @param {?} loader
* @param {?} compiler
*/
function RouterConfigLoader(loader, compiler) {
this.loader = loader;
this.compiler = compiler;
}
/**
* @param {?} parentInjector
* @param {?} loadChildren
* @return {?}
*/
RouterConfigLoader.prototype.load = function (parentInjector, loadChildren) {
return map.call(this.loadModuleFactory(loadChildren), function (r) {
var /** @type {?} */ ref = r.create(parentInjector);
var /** @type {?} */ injectorFactory = function (parent) { return r.create(parent).injector; };
return new LoadedRouterConfig(flatten(ref.injector.get(ROUTES)), ref.injector, ref.componentFactoryResolver, injectorFactory);
});
};
/**
* @param {?} loadChildren
* @return {?}
*/
RouterConfigLoader.prototype.loadModuleFactory = function (loadChildren) {
var _this = this;
if (typeof loadChildren === 'string') {
return fromPromise(this.loader.load(loadChildren));
}
else {
var /** @type {?} */ offlineMode_1 = this.compiler instanceof Compiler;
return mergeMap.call(wrapIntoObservable(loadChildren()), function (t) { return offlineMode_1 ? of(/** @type {?} */ (t)) : fromPromise(_this.compiler.compileModuleAsync(t)); });
}
};
return RouterConfigLoader;
}());
function RouterConfigLoader_tsickle_Closure_declarations() {
/** @type {?} */
RouterConfigLoader.prototype.loader;
/** @type {?} */
RouterConfigLoader.prototype.compiler;
}
//# sourceMappingURL=router_config_loader.js.map