@angular/router 3.4.9 → 3.4.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v3.4.9
2
+ * @license Angular v3.4.10
3
3
  * (c) 2010-2017 Google, Inc. https://angular.io/
4
4
  * License: MIT
5
5
  */(function (global, factory) {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v3.4.9
2
+ * @license Angular v3.4.10
3
3
  * (c) 2010-2017 Google, Inc. https://angular.io/
4
4
  * License: MIT
5
5
  */(function (global, factory) {
@@ -32,30 +32,16 @@
32
32
  * @experimental
33
33
  */
34
34
  var RouterUpgradeInitializer = {
35
- provide: _angular_router.ROUTER_INITIALIZER,
36
- useFactory: initialRouterNavigation,
37
- deps: [_angular_upgrade_static.UpgradeModule, _angular_core.ApplicationRef, _angular_router.RouterPreloader, _angular_router.ROUTER_CONFIGURATION]
35
+ provide: _angular_core.APP_BOOTSTRAP_LISTENER,
36
+ multi: true,
37
+ useFactory: locationSyncBootstrapListener,
38
+ deps: [_angular_upgrade_static.UpgradeModule]
38
39
  };
39
40
  /**
40
41
  * @internal
41
42
  */
42
- function initialRouterNavigation(ngUpgrade, ref, preloader, opts) {
43
- return function () {
44
- if (!ngUpgrade.$injector) {
45
- throw new Error("\n RouterUpgradeInitializer can be used only after UpgradeModule.bootstrap has been called.\n Remove RouterUpgradeInitializer and call setUpLocationSync after UpgradeModule.bootstrap.\n ");
46
- }
47
- var router = ngUpgrade.injector.get(_angular_router.Router);
48
- var ref = ngUpgrade.injector.get(_angular_core.ApplicationRef);
49
- router.resetRootComponentType(ref.componentTypes[0]);
50
- preloader.setUpPreloading();
51
- if (opts.initialNavigation === false) {
52
- router.setUpLocationChangeListener();
53
- }
54
- else {
55
- router.initialNavigation();
56
- }
57
- setUpLocationSync(ngUpgrade);
58
- };
43
+ function locationSyncBootstrapListener(ngUpgrade) {
44
+ return function () { setUpLocationSync(ngUpgrade); };
59
45
  }
60
46
  /**
61
47
  * @whatItDoes Sets up a location synchronization.
@@ -66,6 +52,9 @@
66
52
  * @experimental
67
53
  */
68
54
  function setUpLocationSync(ngUpgrade) {
55
+ if (!ngUpgrade.$injector) {
56
+ throw new Error("\n RouterUpgradeInitializer can be used only after UpgradeModule.bootstrap has been called.\n Remove RouterUpgradeInitializer and call setUpLocationSync after UpgradeModule.bootstrap.\n ");
57
+ }
69
58
  var router = ngUpgrade.injector.get(_angular_router.Router);
70
59
  var url = document.createElement('a');
71
60
  ngUpgrade.$injector.get('$rootScope')
@@ -76,7 +65,7 @@
76
65
  }
77
66
 
78
67
  exports.RouterUpgradeInitializer = RouterUpgradeInitializer;
79
- exports.initialRouterNavigation = initialRouterNavigation;
68
+ exports.locationSyncBootstrapListener = locationSyncBootstrapListener;
80
69
  exports.setUpLocationSync = setUpLocationSync;
81
70
 
82
71
  }));
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @license Angular v3.4.9
2
+ * @license Angular v3.4.10
3
3
  * (c) 2010-2017 Google, Inc. https://angular.io/
4
4
  * License: MIT
5
5
  */
6
- !function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?factory(exports,require("@angular/core"),require("@angular/router"),require("@angular/upgrade/static")):"function"==typeof define&&define.amd?define(["exports","@angular/core","@angular/router","@angular/upgrade/static"],factory):factory((global.ng=global.ng||{},global.ng.router=global.ng.router||{},global.ng.router.upgrade=global.ng.router.upgrade||{}),global.ng.core,global.ng.router,global.ng.upgrade.static)}(this,function(exports,_angular_core,_angular_router,_angular_upgrade_static){"use strict";function initialRouterNavigation(ngUpgrade,ref,preloader,opts){return function(){if(!ngUpgrade.$injector)throw new Error("\n RouterUpgradeInitializer can be used only after UpgradeModule.bootstrap has been called.\n Remove RouterUpgradeInitializer and call setUpLocationSync after UpgradeModule.bootstrap.\n ");var router=ngUpgrade.injector.get(_angular_router.Router),ref=ngUpgrade.injector.get(_angular_core.ApplicationRef);router.resetRootComponentType(ref.componentTypes[0]),preloader.setUpPreloading(),opts.initialNavigation===!1?router.setUpLocationChangeListener():router.initialNavigation(),setUpLocationSync(ngUpgrade)}}function setUpLocationSync(ngUpgrade){var router=ngUpgrade.injector.get(_angular_router.Router),url=document.createElement("a");ngUpgrade.$injector.get("$rootScope").$on("$locationChangeStart",function(_,next,__){url.href=next,router.navigateByUrl(url.pathname)})}var RouterUpgradeInitializer={provide:_angular_router.ROUTER_INITIALIZER,useFactory:initialRouterNavigation,deps:[_angular_upgrade_static.UpgradeModule,_angular_core.ApplicationRef,_angular_router.RouterPreloader,_angular_router.ROUTER_CONFIGURATION]};exports.RouterUpgradeInitializer=RouterUpgradeInitializer,exports.initialRouterNavigation=initialRouterNavigation,exports.setUpLocationSync=setUpLocationSync});
6
+ !function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?factory(exports,require("@angular/core"),require("@angular/router"),require("@angular/upgrade/static")):"function"==typeof define&&define.amd?define(["exports","@angular/core","@angular/router","@angular/upgrade/static"],factory):factory((global.ng=global.ng||{},global.ng.router=global.ng.router||{},global.ng.router.upgrade=global.ng.router.upgrade||{}),global.ng.core,global.ng.router,global.ng.upgrade.static)}(this,function(exports,_angular_core,_angular_router,_angular_upgrade_static){"use strict";function locationSyncBootstrapListener(ngUpgrade){return function(){setUpLocationSync(ngUpgrade)}}function setUpLocationSync(ngUpgrade){if(!ngUpgrade.$injector)throw new Error("\n RouterUpgradeInitializer can be used only after UpgradeModule.bootstrap has been called.\n Remove RouterUpgradeInitializer and call setUpLocationSync after UpgradeModule.bootstrap.\n ");var router=ngUpgrade.injector.get(_angular_router.Router),url=document.createElement("a");ngUpgrade.$injector.get("$rootScope").$on("$locationChangeStart",function(_,next,__){url.href=next,router.navigateByUrl(url.pathname)})}var RouterUpgradeInitializer={provide:_angular_core.APP_BOOTSTRAP_LISTENER,multi:!0,useFactory:locationSyncBootstrapListener,deps:[_angular_upgrade_static.UpgradeModule]};exports.RouterUpgradeInitializer=RouterUpgradeInitializer,exports.locationSyncBootstrapListener=locationSyncBootstrapListener,exports.setUpLocationSync=setUpLocationSync});
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v3.4.9
2
+ * @license Angular v3.4.10
3
3
  * (c) 2010-2017 Google, Inc. https://angular.io/
4
4
  * License: MIT
5
5
  */(function (global, factory) {
@@ -3305,6 +3305,14 @@
3305
3305
  function defaultErrorHandler(error) {
3306
3306
  throw error;
3307
3307
  }
3308
+ /**
3309
+ * \@internal
3310
+ * @param {?} snapshot
3311
+ * @return {?}
3312
+ */
3313
+ function defaultRouterHook(snapshot) {
3314
+ return rxjs_observable_of.of(null);
3315
+ }
3308
3316
  /**
3309
3317
  * Does not detach any subtrees. Reuses routes as long as their route config is the same.
3310
3318
  */
@@ -3384,6 +3392,16 @@
3384
3392
  this.navigated = false;
3385
3393
  /**
3386
3394
  * Extracts and merges URLs. Used for Angular 1 to Angular 2 migrations.
3395
+ * Used by RouterModule. This allows us to
3396
+ * pause the navigation either before preactivation or after it.
3397
+ * @internal
3398
+ */
3399
+ this.hooks = {
3400
+ beforePreactivation: defaultRouterHook,
3401
+ afterPreactivation: defaultRouterHook
3402
+ };
3403
+ /**
3404
+ * Extracts and merges URLs. Used for AngularJS to Angular migrations.
3387
3405
  */
3388
3406
  this.urlHandlingStrategy = new DefaultUrlHandlingStrategy();
3389
3407
  this.routeReuseStrategy = new DefaultRouteReuseStrategy();
@@ -3760,16 +3778,19 @@
3760
3778
  else {
3761
3779
  urlAndSnapshot$ = rxjs_observable_of.of({ appliedUrl: url, snapshot: precreatedState });
3762
3780
  }
3781
+ var /** @type {?} */ beforePreactivationDone$ = rxjs_operator_mergeMap.mergeMap.call(urlAndSnapshot$, function (p) {
3782
+ return rxjs_operator_map.map.call(_this.hooks.beforePreactivation(p.snapshot), function () { return p; });
3783
+ });
3763
3784
  // run preactivation: guards and data resolvers
3764
3785
  var /** @type {?} */ preActivation;
3765
- var /** @type {?} */ preactivationTraverse$ = rxjs_operator_map.map.call(urlAndSnapshot$, function (_a) {
3786
+ var /** @type {?} */ preactivationTraverse$ = rxjs_operator_map.map.call(beforePreactivationDone$, function (_a) {
3766
3787
  var appliedUrl = _a.appliedUrl, snapshot = _a.snapshot;
3767
3788
  preActivation =
3768
3789
  new PreActivation(snapshot, _this.currentRouterState.snapshot, _this.injector);
3769
3790
  preActivation.traverse(_this.outletMap);
3770
3791
  return { appliedUrl: appliedUrl, snapshot: snapshot };
3771
3792
  });
3772
- var /** @type {?} */ preactivationCheckGuards = rxjs_operator_mergeMap.mergeMap.call(preactivationTraverse$, function (_a) {
3793
+ var /** @type {?} */ preactivationCheckGuards$ = rxjs_operator_mergeMap.mergeMap.call(preactivationTraverse$, function (_a) {
3773
3794
  var appliedUrl = _a.appliedUrl, snapshot = _a.snapshot;
3774
3795
  if (_this.navigationId !== id)
3775
3796
  return rxjs_observable_of.of(false);
@@ -3777,7 +3798,7 @@
3777
3798
  return { appliedUrl: appliedUrl, snapshot: snapshot, shouldActivate: shouldActivate };
3778
3799
  });
3779
3800
  });
3780
- var /** @type {?} */ preactivationResolveData$ = rxjs_operator_mergeMap.mergeMap.call(preactivationCheckGuards, function (p) {
3801
+ var /** @type {?} */ preactivationResolveData$ = rxjs_operator_mergeMap.mergeMap.call(preactivationCheckGuards$, function (p) {
3781
3802
  if (_this.navigationId !== id)
3782
3803
  return rxjs_observable_of.of(false);
3783
3804
  if (p.shouldActivate) {
@@ -3787,9 +3808,12 @@
3787
3808
  return rxjs_observable_of.of(p);
3788
3809
  }
3789
3810
  });
3811
+ var /** @type {?} */ preactivationDone$ = rxjs_operator_mergeMap.mergeMap.call(preactivationResolveData$, function (p) {
3812
+ return rxjs_operator_map.map.call(_this.hooks.afterPreactivation(p.snapshot), function () { return p; });
3813
+ });
3790
3814
  // create router state
3791
3815
  // this operation has side effects => route state is being affected
3792
- var /** @type {?} */ routerState$ = rxjs_operator_map.map.call(preactivationResolveData$, function (_a) {
3816
+ var /** @type {?} */ routerState$ = rxjs_operator_map.map.call(preactivationDone$, function (_a) {
3793
3817
  var appliedUrl = _a.appliedUrl, snapshot = _a.snapshot, shouldActivate = _a.shouldActivate;
3794
3818
  if (shouldActivate) {
3795
3819
  var /** @type {?} */ state = createRouterState(_this.routeReuseStrategy, snapshot, _this.currentRouterState);
@@ -5513,26 +5537,123 @@
5513
5537
  return router.routerState.root;
5514
5538
  }
5515
5539
  /**
5516
- * @param {?} router
5517
- * @param {?} ref
5518
- * @param {?} preloader
5519
- * @param {?} opts
5520
- * @return {?}
5540
+ * To initialize the router properly we need to do in two steps:
5541
+ *
5542
+ * We need to start the navigation in a APP_INITIALIZER to block the bootstrap if
5543
+ * a resolver or a guards executes asynchronously. Second, we need to actually run
5544
+ * activation in a BOOTSTRAP_LISTENER. We utilize the afterPreactivation
5545
+ * hook provided by the router to do that.
5546
+ *
5547
+ * The router navigation starts, reaches the point when preactivation is done, and then
5548
+ * pauses. It waits for the hook to be resolved. We then resolve it only in a bootstrap listener.
5521
5549
  */
5522
- function initialRouterNavigation(router, ref, preloader, opts) {
5523
- return function (bootstrappedComponentRef) {
5550
+ var RouterInitializer = (function () {
5551
+ /**
5552
+ * @param {?} injector
5553
+ */
5554
+ function RouterInitializer(injector) {
5555
+ this.injector = injector;
5556
+ this.initNavigation = false;
5557
+ this.resultOfPreactivationDone = new rxjs_Subject.Subject();
5558
+ }
5559
+ /**
5560
+ * @return {?}
5561
+ */
5562
+ RouterInitializer.prototype.appInitializer = function () {
5563
+ var _this = this;
5564
+ var /** @type {?} */ p = this.injector.get(_angular_common.LOCATION_INITIALIZED, Promise.resolve(null));
5565
+ return p.then(function () {
5566
+ var /** @type {?} */ resolve = null;
5567
+ var /** @type {?} */ res = new Promise(function (r) { return resolve = r; });
5568
+ var /** @type {?} */ router = _this.injector.get(Router);
5569
+ var /** @type {?} */ opts = _this.injector.get(ROUTER_CONFIGURATION);
5570
+ if (_this.isLegacyDisabled(opts) || _this.isLegacyEnabled(opts)) {
5571
+ resolve(true);
5572
+ }
5573
+ else if (opts.initialNavigation === 'disabled') {
5574
+ router.setUpLocationChangeListener();
5575
+ resolve(true);
5576
+ }
5577
+ else if (opts.initialNavigation === 'enabled') {
5578
+ router.hooks.afterPreactivation = function () {
5579
+ // only the initial navigation should be delayed
5580
+ if (!_this.initNavigation) {
5581
+ _this.initNavigation = true;
5582
+ resolve(true);
5583
+ return _this.resultOfPreactivationDone;
5584
+ }
5585
+ else {
5586
+ return rxjs_observable_of.of(null);
5587
+ }
5588
+ };
5589
+ router.initialNavigation();
5590
+ }
5591
+ else {
5592
+ throw new Error("Invalid initialNavigation options: '" + opts.initialNavigation + "'");
5593
+ }
5594
+ return res;
5595
+ });
5596
+ };
5597
+ /**
5598
+ * @param {?} bootstrappedComponentRef
5599
+ * @return {?}
5600
+ */
5601
+ RouterInitializer.prototype.bootstrapListener = function (bootstrappedComponentRef) {
5602
+ var /** @type {?} */ opts = this.injector.get(ROUTER_CONFIGURATION);
5603
+ var /** @type {?} */ preloader = this.injector.get(RouterPreloader);
5604
+ var /** @type {?} */ router = this.injector.get(Router);
5605
+ var /** @type {?} */ ref = this.injector.get(_angular_core.ApplicationRef);
5524
5606
  if (bootstrappedComponentRef !== ref.components[0]) {
5525
5607
  return;
5526
5608
  }
5527
- router.resetRootComponentType(ref.componentTypes[0]);
5528
- preloader.setUpPreloading();
5529
- if (opts.initialNavigation === false) {
5530
- router.setUpLocationChangeListener();
5531
- }
5532
- else {
5609
+ if (this.isLegacyEnabled(opts)) {
5533
5610
  router.initialNavigation();
5534
5611
  }
5612
+ else if (this.isLegacyDisabled(opts)) {
5613
+ router.setUpLocationChangeListener();
5614
+ }
5615
+ preloader.setUpPreloading();
5616
+ router.resetRootComponentType(ref.componentTypes[0]);
5617
+ this.resultOfPreactivationDone.next(null);
5618
+ this.resultOfPreactivationDone.complete();
5535
5619
  };
5620
+ /**
5621
+ * @param {?} opts
5622
+ * @return {?}
5623
+ */
5624
+ RouterInitializer.prototype.isLegacyEnabled = function (opts) {
5625
+ return opts.initialNavigation === 'legacy_enabled' || opts.initialNavigation === true ||
5626
+ opts.initialNavigation === undefined;
5627
+ };
5628
+ /**
5629
+ * @param {?} opts
5630
+ * @return {?}
5631
+ */
5632
+ RouterInitializer.prototype.isLegacyDisabled = function (opts) {
5633
+ return opts.initialNavigation === 'legacy_disabled' || opts.initialNavigation === false;
5634
+ };
5635
+ RouterInitializer.decorators = [
5636
+ { type: _angular_core.Injectable },
5637
+ ];
5638
+ /** @nocollapse */
5639
+ RouterInitializer.ctorParameters = function () { return [
5640
+ { type: _angular_core.Injector, },
5641
+ ]; };
5642
+ return RouterInitializer;
5643
+ }());
5644
+ /**
5645
+ * @param {?} r
5646
+ * @return {?}
5647
+ */
5648
+ function getAppInitializer(r) {
5649
+ return r.appInitializer.bind(r);
5650
+ }
5651
+ /**
5652
+ * @param {?} r
5653
+ * @return {?}
5654
+ */
5655
+ function getBootstrapListener(r) {
5656
+ return r.bootstrapListener.bind(r);
5536
5657
  }
5537
5658
  /**
5538
5659
  * A token for the router initializer that will be called after the app is bootstrapped.
@@ -5545,11 +5666,14 @@
5545
5666
  */
5546
5667
  function provideRouterInitializer() {
5547
5668
  return [
5669
+ RouterInitializer,
5548
5670
  {
5549
- provide: ROUTER_INITIALIZER,
5550
- useFactory: initialRouterNavigation,
5551
- deps: [Router, _angular_core.ApplicationRef, RouterPreloader, ROUTER_CONFIGURATION]
5671
+ provide: _angular_core.APP_INITIALIZER,
5672
+ multi: true,
5673
+ useFactory: getAppInitializer,
5674
+ deps: [RouterInitializer]
5552
5675
  },
5676
+ { provide: ROUTER_INITIALIZER, useFactory: getBootstrapListener, deps: [RouterInitializer] },
5553
5677
  { provide: _angular_core.APP_BOOTSTRAP_LISTENER, multi: true, useExisting: ROUTER_INITIALIZER },
5554
5678
  ];
5555
5679
  }
@@ -5557,7 +5681,7 @@
5557
5681
  /**
5558
5682
  * @stable
5559
5683
  */
5560
- var /** @type {?} */ VERSION = new _angular_core.Version('3.4.9');
5684
+ var /** @type {?} */ VERSION = new _angular_core.Version('3.4.10');
5561
5685
 
5562
5686
  var /** @type {?} */ __router_private__ = {
5563
5687
  ROUTER_PROVIDERS: ROUTER_PROVIDERS,