@coolon/angular-ui-powerups 0.0.115 → 0.0.117

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.
@@ -3488,6 +3488,7 @@
3488
3488
  var _this = this;
3489
3489
  pectin.assert.isNil(this.visit);
3490
3490
  this.visit = visit;
3491
+ // DebugContext.get(this.visit).tag(`${this.placeDefinition.component.name}.visit`);
3491
3492
  this.placeDefinition.getVisitParameterDefs().forEach((/**
3492
3493
  * @param {?} parameterDef
3493
3494
  * @return {?}
@@ -3968,6 +3969,7 @@
3968
3969
  var _this = _super.call(this) || this;
3969
3970
  _this.context = context;
3970
3971
  _this._visits = new Map();
3972
+ _this.debugPropertyKeys = [];
3971
3973
  return _this;
3972
3974
  }
3973
3975
  Object.defineProperty(NavigationState.prototype, "name", {
@@ -4188,14 +4190,18 @@
4188
4190
  function (event) {
4189
4191
  /** @type {?} */
4190
4192
  var popstate = event.navigationTrigger === 'popstate';
4191
- return popstate ?
4192
- this.interactionService.isActive() ?
4193
- new NavigationState.InteractionPopStateTransition(this.context, this.currentRouterUrl()) :
4194
- new NavigationState.PopStateTransition(this.context, this.currentRouterUrl())
4195
- :
4196
- this.interactionService.isActive() ?
4197
- new NavigationState.InteractionTransition(this.context, this.currentRouterUrl()) :
4198
- new NavigationState.NavigationTransition(this.context, this.currentRouterUrl());
4193
+ /** @type {?} */
4194
+ var inInteraction = this.interactionService.isActive();
4195
+ if (popstate) {
4196
+ return inInteraction ?
4197
+ new NavigationState.LeavingInteractionAfterPopStateTransition(this.context, this.currentRouterUrl(), event.url) :
4198
+ new NavigationState.PopStateTransition(this.context, this.currentRouterUrl(), event.url);
4199
+ }
4200
+ else {
4201
+ return inInteraction ?
4202
+ new NavigationState.StartingInteractionTransition(this.context, this.currentRouterUrl()) :
4203
+ new NavigationState.NavigationTransition(this.context, this.currentRouterUrl());
4204
+ }
4199
4205
  };
4200
4206
  /**
4201
4207
  * @protected
@@ -4210,17 +4216,36 @@
4210
4216
  new NavigationState.IdleDuringInteraction(this.context, this.currentRouterUrl()) :
4211
4217
  new NavigationState.Idle(this.context);
4212
4218
  };
4219
+ //
4220
+ //
4213
4221
  /**
4214
4222
  * @param {?} url
4215
4223
  * @return {?}
4216
4224
  */
4217
- NavigationState.prototype.resetBrowserLocation = /**
4225
+ NavigationState.prototype.resetBrowserLocation =
4226
+ //
4227
+ /**
4218
4228
  * @param {?} url
4219
4229
  * @return {?}
4220
4230
  */
4221
4231
  function (url) {
4222
4232
  this.placeRouter.resetBrowserLocation(url);
4223
4233
  };
4234
+ /**
4235
+ * @param {?} event
4236
+ * @param {?=} reason
4237
+ * @return {?}
4238
+ */
4239
+ NavigationState.prototype.ignore = /**
4240
+ * @param {?} event
4241
+ * @param {?=} reason
4242
+ * @return {?}
4243
+ */
4244
+ function (event, reason) {
4245
+ reason = reason ? " -> " + reason : '';
4246
+ pectin.Logger.get(this).info("Ignoring router event" + reason + ": " + event.constructor.name + " -> " + event.url + " :: " + this.toString());
4247
+ return this;
4248
+ };
4224
4249
  /**
4225
4250
  * @return {?}
4226
4251
  */
@@ -4228,7 +4253,27 @@
4228
4253
  * @return {?}
4229
4254
  */
4230
4255
  function () {
4231
- return this.constructor.name;
4256
+ return this.constructor.name + "(" + this.debugState() + ")";
4257
+ };
4258
+ /**
4259
+ * @protected
4260
+ * @param {?=} properties
4261
+ * @return {?}
4262
+ */
4263
+ NavigationState.prototype.debugState = /**
4264
+ * @protected
4265
+ * @param {?=} properties
4266
+ * @return {?}
4267
+ */
4268
+ function (properties) {
4269
+ var _this = this;
4270
+ return (properties || this.debugPropertyKeys).map((/**
4271
+ * @param {?} p
4272
+ * @return {?}
4273
+ */
4274
+ function (p) {
4275
+ return p + ": " + _this[p];
4276
+ })).join(', ');
4232
4277
  };
4233
4278
  return NavigationState;
4234
4279
  }(pectin.GarbageCollector));
@@ -4244,6 +4289,8 @@
4244
4289
  exports.NavigationState.prototype.startingUrl;
4245
4290
  /** @type {?} */
4246
4291
  exports.NavigationState.prototype.isPopState;
4292
+ /** @type {?} */
4293
+ exports.NavigationState.prototype.debugPropertyKeys;
4247
4294
  /**
4248
4295
  * @type {?}
4249
4296
  * @protected
@@ -4309,7 +4356,7 @@
4309
4356
  }
4310
4357
  if (this.placeRouter.hasActiveInteractionIds(event.url)) {
4311
4358
  pectin.Logger.get(this).info("navigation started with interaction outlet -> " + event.url);
4312
- return new InteractionTransition(this.context, event.url);
4359
+ return new StartingInteractionTransition(this.context, event.url);
4313
4360
  }
4314
4361
  else {
4315
4362
  return this.createTransitionStateFor(event);
@@ -4402,14 +4449,14 @@
4402
4449
  return new Idle(this.context);
4403
4450
  };
4404
4451
  /**
4405
- * @param {?} locationTriggerUrl
4452
+ * @param {?} newUrl
4406
4453
  * @return {?}
4407
4454
  */
4408
4455
  AbstractNavigationTransition.prototype.onBackClickedDuringNavigationInteraction = /**
4409
- * @param {?} locationTriggerUrl
4456
+ * @param {?} newUrl
4410
4457
  * @return {?}
4411
4458
  */
4412
- function (locationTriggerUrl) {
4459
+ function (newUrl) {
4413
4460
  pectin.Logger.get(this).info("back button pressed during navigation session interaction promise");
4414
4461
  // detach the interaction from the session so it doesn't get disposed until the activity has completed.
4415
4462
  /** @type {?} */
@@ -4417,25 +4464,22 @@
4417
4464
  var when = pectin.Dsl.disposeWith(navigationInteraction).when;
4418
4465
  // TODO: I need to make the exclusive interaction context disallow nested activities or
4419
4466
  // that would mess things up entirely. Or, can I do a context.abortAll().then(..)
4467
+ pectin.Logger.get(this).info('cancelling current navigation activity..');
4420
4468
  navigationInteraction.cancelActiveActivity().then((/**
4421
4469
  * @return {?}
4422
4470
  */
4423
4471
  function () {
4424
4472
  navigationInteraction.dispose();
4425
4473
  }));
4426
- return new CancelledDuringNavigationInteraction(this.context, this.startingUrl, this.isPopState, locationTriggerUrl);
4474
+ return this.createNavigationInteractionCancelledState(newUrl);
4427
4475
  };
4428
- // @Trace()
4429
- // @Trace()
4430
4476
  /**
4431
4477
  * @param {?} component
4432
4478
  * @param {?} currentUrl
4433
4479
  * @param {?} nextUrl
4434
4480
  * @return {?}
4435
4481
  */
4436
- AbstractNavigationTransition.prototype.canDeactivatePlace =
4437
- // @Trace()
4438
- /**
4482
+ AbstractNavigationTransition.prototype.canDeactivatePlace = /**
4439
4483
  * @param {?} component
4440
4484
  * @param {?} currentUrl
4441
4485
  * @param {?} nextUrl
@@ -4457,11 +4501,11 @@
4457
4501
  });
4458
4502
  };
4459
4503
  /**
4460
- * @private
4504
+ * @protected
4461
4505
  * @return {?}
4462
4506
  */
4463
4507
  AbstractNavigationTransition.prototype.detachInteractionContext = /**
4464
- * @private
4508
+ * @protected
4465
4509
  * @return {?}
4466
4510
  */
4467
4511
  function () {
@@ -4488,12 +4532,19 @@
4488
4532
  AbstractNavigationTransition.prototype._interactionContext;
4489
4533
  /** @type {?} */
4490
4534
  AbstractNavigationTransition.prototype.startingUrl;
4535
+ /**
4536
+ * @abstract
4537
+ * @param {?} newUrl
4538
+ * @return {?}
4539
+ */
4540
+ AbstractNavigationTransition.prototype.createNavigationInteractionCancelledState = function (newUrl) { };
4491
4541
  }
4492
4542
  var NavigationTransition = /** @class */ (function (_super) {
4493
4543
  __extends(NavigationTransition, _super);
4494
4544
  function NavigationTransition() {
4495
4545
  var _this = _super !== null && _super.apply(this, arguments) || this;
4496
4546
  _this.isPopState = false;
4547
+ _this.debugPropertyKeys = ['startingUrl'];
4497
4548
  return _this;
4498
4549
  }
4499
4550
  /**
@@ -4520,13 +4571,15 @@
4520
4571
  return new Idle(this.context);
4521
4572
  };
4522
4573
  /**
4574
+ * @param {?} newUrl
4523
4575
  * @return {?}
4524
4576
  */
4525
- NavigationTransition.prototype.toString = /**
4577
+ NavigationTransition.prototype.createNavigationInteractionCancelledState = /**
4578
+ * @param {?} newUrl
4526
4579
  * @return {?}
4527
4580
  */
4528
- function () {
4529
- return this.constructor.name + "(startingUrl: " + this.startingUrl + ")";
4581
+ function (newUrl) {
4582
+ return new LinkTriggeredNavigationInteractionCancelled(this.context, this.startingUrl, newUrl);
4530
4583
  };
4531
4584
  return NavigationTransition;
4532
4585
  }(AbstractNavigationTransition));
@@ -4534,12 +4587,16 @@
4534
4587
  if (false) {
4535
4588
  /** @type {?} */
4536
4589
  NavigationTransition.prototype.isPopState;
4590
+ /** @type {?} */
4591
+ NavigationTransition.prototype.debugPropertyKeys;
4537
4592
  }
4538
4593
  var PopStateTransition = /** @class */ (function (_super) {
4539
4594
  __extends(PopStateTransition, _super);
4540
- function PopStateTransition() {
4541
- var _this = _super !== null && _super.apply(this, arguments) || this;
4595
+ function PopStateTransition(context, startingUrl, poppedHistoryUrl) {
4596
+ var _this = _super.call(this, context, startingUrl) || this;
4597
+ _this.poppedHistoryUrl = poppedHistoryUrl;
4542
4598
  _this.isPopState = true;
4599
+ _this.debugPropertyKeys = ['startingUrl', 'poppedHistoryUrl'];
4543
4600
  return _this;
4544
4601
  }
4545
4602
  /**
@@ -4554,7 +4611,8 @@
4554
4611
  // Angular doesn't preserve the url when a guard cancels the back button.
4555
4612
  // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
4556
4613
  pectin.Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
4557
- this.resetBrowserLocation(this.startingUrl);
4614
+ this.resetBrowserLocation(this.poppedHistoryUrl); // put the popped history item back in.
4615
+ this.resetBrowserLocation(this.startingUrl); // and now put our own url back in.
4558
4616
  return new Idle(this.context);
4559
4617
  };
4560
4618
  /**
@@ -4571,24 +4629,75 @@
4571
4629
  // Angular doesn't preserve the url when a guard cancels the back button.
4572
4630
  // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
4573
4631
  pectin.Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
4574
- this.resetBrowserLocation(this.startingUrl);
4632
+ this.resetBrowserLocation(this.poppedHistoryUrl); // put the popped history item back in.
4633
+ this.resetBrowserLocation(this.startingUrl); // and now put our own url back in.
4575
4634
  }
4576
4635
  return new Idle(this.context);
4577
4636
  };
4637
+ /**
4638
+ * @param {?} locationTriggerUrl
4639
+ * @return {?}
4640
+ */
4641
+ PopStateTransition.prototype.createNavigationInteractionCancelledState = /**
4642
+ * @param {?} locationTriggerUrl
4643
+ * @return {?}
4644
+ */
4645
+ function (locationTriggerUrl) {
4646
+ return new PopStateTriggeredNavigationInteractionCancelled(this.context, this.startingUrl, locationTriggerUrl, this.poppedHistoryUrl);
4647
+ };
4578
4648
  return PopStateTransition;
4579
4649
  }(AbstractNavigationTransition));
4580
4650
  NavigationState.PopStateTransition = PopStateTransition;
4581
4651
  if (false) {
4582
4652
  /** @type {?} */
4583
4653
  PopStateTransition.prototype.isPopState;
4654
+ /** @type {?} */
4655
+ PopStateTransition.prototype.debugPropertyKeys;
4656
+ /** @type {?} */
4657
+ PopStateTransition.prototype.poppedHistoryUrl;
4584
4658
  }
4585
- var IdleDuringInteraction = /** @class */ (function (_super) {
4659
+ /**
4660
+ * @abstract
4661
+ */
4662
+ var /**
4663
+ * @abstract
4664
+ */
4665
+ AbstractInteractionTransition = /** @class */ (function (_super) {
4666
+ __extends(AbstractInteractionTransition, _super);
4667
+ function AbstractInteractionTransition(context, startingUrl) {
4668
+ var _this = _super.call(this, context, startingUrl) || this;
4669
+ _this.startingUrl = startingUrl;
4670
+ _this.isTransitional = true;
4671
+ return _this;
4672
+ }
4673
+ return AbstractInteractionTransition;
4674
+ }(AbstractNavigationTransition));
4675
+ NavigationState.AbstractInteractionTransition = AbstractInteractionTransition;
4676
+ if (false) {
4677
+ /** @type {?} */
4678
+ AbstractInteractionTransition.prototype.isTransitional;
4679
+ /** @type {?} */
4680
+ AbstractInteractionTransition.prototype.startingUrl;
4681
+ }
4682
+ // The following states exist to handle all events while any kind of navigation is in progress. That way all other states can
4683
+ // happily ignore interaction contexts.
4684
+ /**
4685
+ * This is the non transitional (i.e. rest) state that is used whenever an interaction context is active.
4686
+ */
4687
+ var
4688
+ // The following states exist to handle all events while any kind of navigation is in progress. That way all other states can
4689
+ // happily ignore interaction contexts.
4690
+ /**
4691
+ * This is the non transitional (i.e. rest) state that is used whenever an interaction context is active.
4692
+ */
4693
+ IdleDuringInteraction = /** @class */ (function (_super) {
4586
4694
  __extends(IdleDuringInteraction, _super);
4587
4695
  function IdleDuringInteraction(context, startingUrl) {
4588
4696
  var _this = _super.call(this, context) || this;
4589
4697
  _this.startingUrl = startingUrl;
4590
4698
  _this.isTransitional = false;
4591
4699
  _this.isPopState = false;
4700
+ _this.debugPropertyKeys = ['startingUrl'];
4592
4701
  return _this;
4593
4702
  }
4594
4703
  /**
@@ -4602,40 +4711,34 @@
4602
4711
  * @return {?}
4603
4712
  */
4604
4713
  function (visit, initialUrl) {
4714
+ // we're in an interaction and the user clicked back
4605
4715
  /** @type {?} */
4606
- var navigationTransition = new InteractionTransition(this.context, initialUrl);
4716
+ var navigationTransition = new StartingInteractionTransition(this.context, initialUrl);
4607
4717
  navigationTransition.storeVisit(visit);
4608
4718
  return navigationTransition;
4609
4719
  };
4610
- // @Trace()
4611
- // @Trace()
4612
4720
  /**
4613
4721
  * @param {?} event
4614
4722
  * @return {?}
4615
4723
  */
4616
- IdleDuringInteraction.prototype.onRouterStarted =
4617
- // @Trace()
4618
- /**
4724
+ IdleDuringInteraction.prototype.onRouterStarted = /**
4619
4725
  * @param {?} event
4620
4726
  * @return {?}
4621
4727
  */
4622
4728
  function (event) {
4623
- return new InteractionTransition(this.context, event.url);
4729
+ return new StartingInteractionTransition(this.context, event.url);
4624
4730
  };
4625
- // @Trace()
4626
- // @Trace()
4627
4731
  /**
4628
4732
  * @param {?} event
4629
4733
  * @return {?}
4630
4734
  */
4631
- IdleDuringInteraction.prototype.onPopState =
4632
- // @Trace()
4633
- /**
4735
+ IdleDuringInteraction.prototype.onPopState = /**
4634
4736
  * @param {?} event
4635
4737
  * @return {?}
4636
4738
  */
4637
4739
  function (event) {
4638
- return new InteractionPopStateTransition(this.context, event.url);
4740
+ // we're in an interaction and the user clicked back
4741
+ return new LeavingInteractionAfterPopStateTransition(this.context, event.url, event.url);
4639
4742
  };
4640
4743
  return IdleDuringInteraction;
4641
4744
  }(NavigationState));
@@ -4646,55 +4749,34 @@
4646
4749
  /** @type {?} */
4647
4750
  IdleDuringInteraction.prototype.isPopState;
4648
4751
  /** @type {?} */
4649
- IdleDuringInteraction.prototype.startingUrl;
4650
- }
4651
- /**
4652
- * @abstract
4653
- */
4654
- var /**
4655
- * @abstract
4656
- */
4657
- AbstractInteractionTransition = /** @class */ (function (_super) {
4658
- __extends(AbstractInteractionTransition, _super);
4659
- function AbstractInteractionTransition(context, startingUrl) {
4660
- var _this = _super.call(this, context, startingUrl) || this;
4661
- _this.startingUrl = startingUrl;
4662
- _this.isTransitional = true;
4663
- return _this;
4664
- }
4665
- return AbstractInteractionTransition;
4666
- }(AbstractNavigationTransition));
4667
- NavigationState.AbstractInteractionTransition = AbstractInteractionTransition;
4668
- if (false) {
4669
- /** @type {?} */
4670
- AbstractInteractionTransition.prototype.isTransitional;
4752
+ IdleDuringInteraction.prototype.debugPropertyKeys;
4671
4753
  /** @type {?} */
4672
- AbstractInteractionTransition.prototype.startingUrl;
4754
+ IdleDuringInteraction.prototype.startingUrl;
4673
4755
  }
4674
4756
  /**
4675
4757
  * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4676
4758
  * happily ignore interaction contexts.
4759
+ * NOTE: This state is activated when ever an interaction is started. It might be better to split it into
4760
+ * different states for different scenarios, e.g. starting model, starting model during route guard etc.
4677
4761
  */
4678
4762
  var /**
4679
4763
  * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4680
4764
  * happily ignore interaction contexts.
4765
+ * NOTE: This state is activated when ever an interaction is started. It might be better to split it into
4766
+ * different states for different scenarios, e.g. starting model, starting model during route guard etc.
4681
4767
  */
4682
- InteractionTransition = /** @class */ (function (_super) {
4683
- __extends(InteractionTransition, _super);
4684
- function InteractionTransition() {
4768
+ StartingInteractionTransition = /** @class */ (function (_super) {
4769
+ __extends(StartingInteractionTransition, _super);
4770
+ function StartingInteractionTransition() {
4685
4771
  var _this = _super !== null && _super.apply(this, arguments) || this;
4686
4772
  _this.isPopState = false;
4687
4773
  return _this;
4688
4774
  }
4689
- // @Trace()
4690
- // @Trace()
4691
4775
  /**
4692
4776
  * @param {?} event
4693
4777
  * @return {?}
4694
4778
  */
4695
- InteractionTransition.prototype.onRouterCancelled =
4696
- // @Trace()
4697
- /**
4779
+ StartingInteractionTransition.prototype.onRouterCancelled = /**
4698
4780
  * @param {?} event
4699
4781
  * @return {?}
4700
4782
  */
@@ -4709,15 +4791,11 @@
4709
4791
  return new Idle(this.context);
4710
4792
  }
4711
4793
  };
4712
- // @Trace()
4713
- // @Trace()
4714
4794
  /**
4715
4795
  * @param {?} event
4716
4796
  * @return {?}
4717
4797
  */
4718
- InteractionTransition.prototype.onRouterError =
4719
- // @Trace()
4720
- /**
4798
+ StartingInteractionTransition.prototype.onRouterError = /**
4721
4799
  * @param {?} event
4722
4800
  * @return {?}
4723
4801
  */
@@ -4725,15 +4803,11 @@
4725
4803
  // navigation was aborted.
4726
4804
  return new IdleDuringInteraction(this.context, this.startingUrl);
4727
4805
  };
4728
- // @Trace()
4729
- // @Trace()
4730
4806
  /**
4731
4807
  * @param {?} event
4732
4808
  * @return {?}
4733
4809
  */
4734
- InteractionTransition.prototype.onRouterEnd =
4735
- // @Trace()
4736
- /**
4810
+ StartingInteractionTransition.prototype.onRouterEnd = /**
4737
4811
  * @param {?} event
4738
4812
  * @return {?}
4739
4813
  */
@@ -4745,12 +4819,163 @@
4745
4819
  return new Idle(this.context);
4746
4820
  }
4747
4821
  };
4748
- return InteractionTransition;
4822
+ /**
4823
+ * @param {?} locationTriggerUrl
4824
+ * @return {?}
4825
+ */
4826
+ StartingInteractionTransition.prototype.createNavigationInteractionCancelledState = /**
4827
+ * @param {?} locationTriggerUrl
4828
+ * @return {?}
4829
+ */
4830
+ function (locationTriggerUrl) {
4831
+ return new LeavingInteractionTransitionCancelled(this.context, this.startingUrl, locationTriggerUrl);
4832
+ };
4833
+ return StartingInteractionTransition;
4749
4834
  }(AbstractInteractionTransition));
4750
- NavigationState.InteractionTransition = InteractionTransition;
4835
+ NavigationState.StartingInteractionTransition = StartingInteractionTransition;
4836
+ if (false) {
4837
+ /** @type {?} */
4838
+ StartingInteractionTransition.prototype.isPopState;
4839
+ }
4840
+ /**
4841
+ * The sequence of router events are:
4842
+ * Error -> url = url of navigation link
4843
+ * End
4844
+ * onPopState url = current intereaction url sans the query params
4845
+ * Cancel url == same as above.
4846
+ */
4847
+ var /**
4848
+ * The sequence of router events are:
4849
+ * Error -> url = url of navigation link
4850
+ * End
4851
+ * onPopState url = current intereaction url sans the query params
4852
+ * Cancel url == same as above.
4853
+ */
4854
+ LeavingInteractionTransitionCancelled = /** @class */ (function (_super) {
4855
+ __extends(LeavingInteractionTransitionCancelled, _super);
4856
+ function LeavingInteractionTransitionCancelled(context, startingUrl, locationChangeTriggerUrl) {
4857
+ var _this = _super.call(this, context) || this;
4858
+ _this.startingUrl = startingUrl;
4859
+ _this.locationChangeTriggerUrl = locationChangeTriggerUrl;
4860
+ _this.isPopState = false;
4861
+ _this.firstCancelHandled = false;
4862
+ _this.popStateHandled = false;
4863
+ _this.debugPropertyKeys = ['idle', 'startingUrl', 'poppedHistoryUrl', 'locationChangeTriggerUrl', 'popStateEventUrl', 'firstCancelHandled', 'popStateHandled'];
4864
+ return _this;
4865
+ }
4866
+ Object.defineProperty(LeavingInteractionTransitionCancelled.prototype, "isTransitional", {
4867
+ get: /**
4868
+ * @return {?}
4869
+ */
4870
+ function () {
4871
+ return true;
4872
+ },
4873
+ enumerable: true,
4874
+ configurable: true
4875
+ });
4876
+ /**
4877
+ * @param {?} event
4878
+ * @return {?}
4879
+ */
4880
+ LeavingInteractionTransitionCancelled.prototype.onRouterStarted = /**
4881
+ * @param {?} event
4882
+ * @return {?}
4883
+ */
4884
+ function (event) {
4885
+ return this.ignore(event);
4886
+ };
4887
+ /**
4888
+ * @param {?} event
4889
+ * @return {?}
4890
+ */
4891
+ LeavingInteractionTransitionCancelled.prototype.onRouterCancelled = /**
4892
+ * @param {?} event
4893
+ * @return {?}
4894
+ */
4895
+ function (event) {
4896
+ // Angular doesn't preserve the url when a guard cancels the back button.
4897
+ // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
4898
+ pectin.Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
4899
+ if (this.interactionService.isActive()) {
4900
+ /** @type {?} */
4901
+ var interactionIds = this.interactionService.activeInteractionContextIds.value;
4902
+ this.resetBrowserLocation(this.placeRouter.parseUrl(this.startingUrl).updateInteractionIds(interactionIds).url);
4903
+ }
4904
+ else {
4905
+ this.resetBrowserLocation(this.startingUrl); // and now put our own url back in.
4906
+ }
4907
+ return this.createIdleState();
4908
+ };
4909
+ /**
4910
+ * @param {?} event
4911
+ * @return {?}
4912
+ */
4913
+ LeavingInteractionTransitionCancelled.prototype.onRouterEnd = /**
4914
+ * @param {?} event
4915
+ * @return {?}
4916
+ */
4917
+ function (event) {
4918
+ return this.ignore(event);
4919
+ };
4920
+ /**
4921
+ * @param {?} event
4922
+ * @return {?}
4923
+ */
4924
+ LeavingInteractionTransitionCancelled.prototype.onRouterError = /**
4925
+ * @param {?} event
4926
+ * @return {?}
4927
+ */
4928
+ function (event) {
4929
+ return this.ignore(event);
4930
+ };
4931
+ /**
4932
+ * @param {?} event
4933
+ * @return {?}
4934
+ */
4935
+ LeavingInteractionTransitionCancelled.prototype.onPopState = /**
4936
+ * @param {?} event
4937
+ * @return {?}
4938
+ */
4939
+ function (event) {
4940
+ return this.ignore(event);
4941
+ };
4942
+ /**
4943
+ * @param {?} component
4944
+ * @param {?} currentUrl
4945
+ * @param {?} nextUrl
4946
+ * @return {?}
4947
+ */
4948
+ LeavingInteractionTransitionCancelled.prototype.canDeactivatePlace = /**
4949
+ * @param {?} component
4950
+ * @param {?} currentUrl
4951
+ * @param {?} nextUrl
4952
+ * @return {?}
4953
+ */
4954
+ function (component, currentUrl, nextUrl) {
4955
+ return __awaiter(this, void 0, void 0, function () {
4956
+ return __generator(this, function (_a) {
4957
+ return [2 /*return*/, false];
4958
+ });
4959
+ });
4960
+ };
4961
+ return LeavingInteractionTransitionCancelled;
4962
+ }(NavigationState));
4963
+ NavigationState.LeavingInteractionTransitionCancelled = LeavingInteractionTransitionCancelled;
4751
4964
  if (false) {
4752
4965
  /** @type {?} */
4753
- InteractionTransition.prototype.isPopState;
4966
+ LeavingInteractionTransitionCancelled.prototype.isPopState;
4967
+ /** @type {?} */
4968
+ LeavingInteractionTransitionCancelled.prototype.firstCancelHandled;
4969
+ /** @type {?} */
4970
+ LeavingInteractionTransitionCancelled.prototype.popStateHandled;
4971
+ /** @type {?} */
4972
+ LeavingInteractionTransitionCancelled.prototype.popStateEventUrl;
4973
+ /** @type {?} */
4974
+ LeavingInteractionTransitionCancelled.prototype.debugPropertyKeys;
4975
+ /** @type {?} */
4976
+ LeavingInteractionTransitionCancelled.prototype.startingUrl;
4977
+ /** @type {?} */
4978
+ LeavingInteractionTransitionCancelled.prototype.locationChangeTriggerUrl;
4754
4979
  }
4755
4980
  /**
4756
4981
  * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
@@ -4760,22 +4985,19 @@
4760
4985
  * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4761
4986
  * happily ignore interaction contexts.
4762
4987
  */
4763
- InteractionPopStateTransition = /** @class */ (function (_super) {
4764
- __extends(InteractionPopStateTransition, _super);
4765
- function InteractionPopStateTransition() {
4766
- var _this = _super !== null && _super.apply(this, arguments) || this;
4988
+ LeavingInteractionAfterPopStateTransition = /** @class */ (function (_super) {
4989
+ __extends(LeavingInteractionAfterPopStateTransition, _super);
4990
+ function LeavingInteractionAfterPopStateTransition(context, startingUrl, poppedHistoryUrl) {
4991
+ var _this = _super.call(this, context, startingUrl) || this;
4992
+ _this.poppedHistoryUrl = poppedHistoryUrl;
4767
4993
  _this.isPopState = true;
4768
4994
  return _this;
4769
4995
  }
4770
- // @Trace()
4771
- // @Trace()
4772
4996
  /**
4773
4997
  * @param {?} event
4774
4998
  * @return {?}
4775
4999
  */
4776
- InteractionPopStateTransition.prototype.onRouterCancelled =
4777
- // @Trace()
4778
- /**
5000
+ LeavingInteractionAfterPopStateTransition.prototype.onRouterCancelled = /**
4779
5001
  * @param {?} event
4780
5002
  * @return {?}
4781
5003
  */
@@ -4790,15 +5012,11 @@
4790
5012
  return new Idle(this.context);
4791
5013
  }
4792
5014
  };
4793
- // @Trace()
4794
- // @Trace()
4795
5015
  /**
4796
5016
  * @param {?} event
4797
5017
  * @return {?}
4798
5018
  */
4799
- InteractionPopStateTransition.prototype.onRouterEnd =
4800
- // @Trace()
4801
- /**
5019
+ LeavingInteractionAfterPopStateTransition.prototype.onRouterEnd = /**
4802
5020
  * @param {?} event
4803
5021
  * @return {?}
4804
5022
  */
@@ -4810,25 +5028,219 @@
4810
5028
  return new Idle(this.context);
4811
5029
  }
4812
5030
  };
4813
- return InteractionPopStateTransition;
5031
+ /**
5032
+ * @param {?} newUrl
5033
+ * @return {?}
5034
+ */
5035
+ LeavingInteractionAfterPopStateTransition.prototype.createNavigationInteractionCancelledState = /**
5036
+ * @param {?} newUrl
5037
+ * @return {?}
5038
+ */
5039
+ function (newUrl) {
5040
+ return this.illegalTransition("Leaving interaction after pop-state should't block so should never see a back button click");
5041
+ };
5042
+ return LeavingInteractionAfterPopStateTransition;
4814
5043
  }(AbstractInteractionTransition));
4815
- NavigationState.InteractionPopStateTransition = InteractionPopStateTransition;
5044
+ NavigationState.LeavingInteractionAfterPopStateTransition = LeavingInteractionAfterPopStateTransition;
4816
5045
  if (false) {
4817
5046
  /** @type {?} */
4818
- InteractionPopStateTransition.prototype.isPopState;
5047
+ LeavingInteractionAfterPopStateTransition.prototype.isPopState;
5048
+ /** @type {?} */
5049
+ LeavingInteractionAfterPopStateTransition.prototype.poppedHistoryUrl;
4819
5050
  }
4820
- var CancelledDuringNavigationInteraction = /** @class */ (function (_super) {
4821
- __extends(CancelledDuringNavigationInteraction, _super);
4822
- function CancelledDuringNavigationInteraction(context, startingUrl, startingEventWasAPopState, locationChangeTriggerUrl) {
5051
+ // See LeavingInteractionAfterPopStateTransition.createNavigationInteractionCancelledState(...) above.
5052
+ //
5053
+ // export class LeavingInteractionAfterPopStateCancelled extends NavigationState {
5054
+ //
5055
+ // readonly isPopState = false;
5056
+ // firstCancelHandled = false;
5057
+ // popStateHandled = false;
5058
+ // popStateEventUrl: string;
5059
+ // debugPropertyKeys = ['idle', 'startingUrl', 'poppedHistoryUrl', 'locationChangeTriggerUrl', 'popStateEventUrl', 'firstCancelHandled', 'popStateHandled'];
5060
+ //
5061
+ // constructor(context: Context,
5062
+ // readonly startingUrl: string,
5063
+ // readonly locationChangeTriggerUrl: string,
5064
+ // readonly poppedHistoryUrl: string) {
5065
+ // super(context);
5066
+ // }
5067
+ //
5068
+ // get isTransitional() {
5069
+ // return true;
5070
+ // }
5071
+ //
5072
+ // onRouterStarted(event: NavigationStart): NavigationState {
5073
+ // return this.ignore(event);
5074
+ // }
5075
+ //
5076
+ //
5077
+ // onRouterCancelled(event: NavigationCancel): NavigationState {
5078
+ //
5079
+ // // if (this.firstCancelHandled && this.popStateHandled) {
5080
+ // // // Angular doesn't preserve the url when a guard cancels the back button.
5081
+ // // // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
5082
+ // // Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
5083
+ // // this.resetBrowserLocation(this.locationChangeTriggerUrl); // put the second back click one back in.
5084
+ // // this.resetBrowserLocation(this.poppedHistoryUrl); // put the first back click one back in.
5085
+ // // if (this.interactionService.isActive()) {
5086
+ // // const interactionIds = this.interactionService.activeInteractionContextIds.value;
5087
+ // // this.resetBrowserLocation(this.placeRouter.parseUrl(this.startingUrl).updateInteractionIds(interactionIds).url);
5088
+ // // } else {
5089
+ // // this.resetBrowserLocation(this.startingUrl); // and now put our own url back in.
5090
+ // // }
5091
+ // // return this.createIdleState();
5092
+ // // } else {
5093
+ // // this.firstCancelHandled = true;
5094
+ // return this.ignore(event);
5095
+ // // }
5096
+ // }
5097
+ //
5098
+ //
5099
+ // onRouterEnd(event: NavigationEnd): NavigationState {
5100
+ // return this.ignore(event);
5101
+ // }
5102
+ //
5103
+ //
5104
+ // onRouterError(event: NavigationError): NavigationState {
5105
+ // return this.ignore(event);
5106
+ // }
5107
+ //
5108
+ //
5109
+ // onPopState(event: NavigationStart): NavigationState {
5110
+ // // this.popStateHandled = true;
5111
+ // // this.popStateEventUrl = event.url;
5112
+ // return this.ignore(event);
5113
+ // }
5114
+ //
5115
+ // async canDeactivatePlace(component: PlaceComponent, currentUrl: UrlSnapshot, nextUrl: UrlSnapshot): Promise<boolean | UrlSnapshot> {
5116
+ // return false;
5117
+ // }
5118
+ // }
5119
+ /**
5120
+ * This state handles the scenario where a link navigation triggered an interaction and the user clicked back a to cancel it.
5121
+ * The routing event sequence is different depending on the link that was clicked.
5122
+ *
5123
+ * If the link was the same as the previous history location (i.e. they've gone back via a link rather than clicking back) then the sequence is:
5124
+ *
5125
+ * -> Idle -> NavigationTransition
5126
+ * -> confirm dialog shown.
5127
+ * -> click back
5128
+ * -> NavigationCancel -> clickedLinkUrl === cancel.url
5129
+ * -> NavigationEnd
5130
+ *
5131
+ * Otherwise if the link is different from teh history location then the sequence is:
5132
+ *
5133
+ * -> Idle -> NavigationTransition
5134
+ * -> confirm dialog shown.
5135
+ * -> click back
5136
+ * -> NavigationCancel -> clickedLinkUrl !== cancel.url
5137
+ * -> NavigationEnd
5138
+ * -> PopState
5139
+ * -> NavigationCancel
5140
+ */
5141
+ var
5142
+ // See LeavingInteractionAfterPopStateTransition.createNavigationInteractionCancelledState(...) above.
5143
+ //
5144
+ // export class LeavingInteractionAfterPopStateCancelled extends NavigationState {
5145
+ //
5146
+ // readonly isPopState = false;
5147
+ // firstCancelHandled = false;
5148
+ // popStateHandled = false;
5149
+ // popStateEventUrl: string;
5150
+ // debugPropertyKeys = ['idle', 'startingUrl', 'poppedHistoryUrl', 'locationChangeTriggerUrl', 'popStateEventUrl', 'firstCancelHandled', 'popStateHandled'];
5151
+ //
5152
+ // constructor(context: Context,
5153
+ // readonly startingUrl: string,
5154
+ // readonly locationChangeTriggerUrl: string,
5155
+ // readonly poppedHistoryUrl: string) {
5156
+ // super(context);
5157
+ // }
5158
+ //
5159
+ // get isTransitional() {
5160
+ // return true;
5161
+ // }
5162
+ //
5163
+ // onRouterStarted(event: NavigationStart): NavigationState {
5164
+ // return this.ignore(event);
5165
+ // }
5166
+ //
5167
+ //
5168
+ // onRouterCancelled(event: NavigationCancel): NavigationState {
5169
+ //
5170
+ // // if (this.firstCancelHandled && this.popStateHandled) {
5171
+ // // // Angular doesn't preserve the url when a guard cancels the back button.
5172
+ // // // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
5173
+ // // Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
5174
+ // // this.resetBrowserLocation(this.locationChangeTriggerUrl); // put the second back click one back in.
5175
+ // // this.resetBrowserLocation(this.poppedHistoryUrl); // put the first back click one back in.
5176
+ // // if (this.interactionService.isActive()) {
5177
+ // // const interactionIds = this.interactionService.activeInteractionContextIds.value;
5178
+ // // this.resetBrowserLocation(this.placeRouter.parseUrl(this.startingUrl).updateInteractionIds(interactionIds).url);
5179
+ // // } else {
5180
+ // // this.resetBrowserLocation(this.startingUrl); // and now put our own url back in.
5181
+ // // }
5182
+ // // return this.createIdleState();
5183
+ // // } else {
5184
+ // // this.firstCancelHandled = true;
5185
+ // return this.ignore(event);
5186
+ // // }
5187
+ // }
5188
+ //
5189
+ //
5190
+ // onRouterEnd(event: NavigationEnd): NavigationState {
5191
+ // return this.ignore(event);
5192
+ // }
5193
+ //
5194
+ //
5195
+ // onRouterError(event: NavigationError): NavigationState {
5196
+ // return this.ignore(event);
5197
+ // }
5198
+ //
5199
+ //
5200
+ // onPopState(event: NavigationStart): NavigationState {
5201
+ // // this.popStateHandled = true;
5202
+ // // this.popStateEventUrl = event.url;
5203
+ // return this.ignore(event);
5204
+ // }
5205
+ //
5206
+ // async canDeactivatePlace(component: PlaceComponent, currentUrl: UrlSnapshot, nextUrl: UrlSnapshot): Promise<boolean | UrlSnapshot> {
5207
+ // return false;
5208
+ // }
5209
+ // }
5210
+ /**
5211
+ * This state handles the scenario where a link navigation triggered an interaction and the user clicked back a to cancel it.
5212
+ * The routing event sequence is different depending on the link that was clicked.
5213
+ *
5214
+ * If the link was the same as the previous history location (i.e. they've gone back via a link rather than clicking back) then the sequence is:
5215
+ *
5216
+ * -> Idle -> NavigationTransition
5217
+ * -> confirm dialog shown.
5218
+ * -> click back
5219
+ * -> NavigationCancel -> clickedLinkUrl === cancel.url
5220
+ * -> NavigationEnd
5221
+ *
5222
+ * Otherwise if the link is different from teh history location then the sequence is:
5223
+ *
5224
+ * -> Idle -> NavigationTransition
5225
+ * -> confirm dialog shown.
5226
+ * -> click back
5227
+ * -> NavigationCancel -> clickedLinkUrl !== cancel.url
5228
+ * -> NavigationEnd
5229
+ * -> PopState
5230
+ * -> NavigationCancel
5231
+ */
5232
+ LinkTriggeredNavigationInteractionCancelled = /** @class */ (function (_super) {
5233
+ __extends(LinkTriggeredNavigationInteractionCancelled, _super);
5234
+ function LinkTriggeredNavigationInteractionCancelled(context, startingUrl, clickedLinkUrl) {
4823
5235
  var _this = _super.call(this, context) || this;
4824
5236
  _this.startingUrl = startingUrl;
4825
- _this.startingEventWasAPopState = startingEventWasAPopState;
4826
- _this.locationChangeTriggerUrl = locationChangeTriggerUrl;
5237
+ _this.clickedLinkUrl = clickedLinkUrl;
4827
5238
  _this.isPopState = false;
4828
- _this.gotPopStateWithLeavingUrl = false;
5239
+ _this.clickedLinkMatchedBackButtonUrl = false;
5240
+ _this.debugPropertyKeys = ['idle', 'startingUrl', 'clickedLinkUrl', 'firstCancelEventUrl', 'clickedLinkMatchedBackButtonUrl', 'popStateEventUrl'];
4829
5241
  return _this;
4830
5242
  }
4831
- Object.defineProperty(CancelledDuringNavigationInteraction.prototype, "isTransitional", {
5243
+ Object.defineProperty(LinkTriggeredNavigationInteractionCancelled.prototype, "isTransitional", {
4832
5244
  get: /**
4833
5245
  * @return {?}
4834
5246
  */
@@ -4842,53 +5254,56 @@
4842
5254
  * @param {?} event
4843
5255
  * @return {?}
4844
5256
  */
4845
- CancelledDuringNavigationInteraction.prototype.onRouterStarted = /**
5257
+ LinkTriggeredNavigationInteractionCancelled.prototype.onRouterStarted = /**
4846
5258
  * @param {?} event
4847
5259
  * @return {?}
4848
5260
  */
4849
5261
  function (event) {
4850
5262
  return this.ignore(event);
4851
5263
  };
4852
- // @Trace()
4853
- // @Trace()
4854
5264
  /**
4855
5265
  * @param {?} event
4856
5266
  * @return {?}
4857
5267
  */
4858
- CancelledDuringNavigationInteraction.prototype.onRouterCancelled =
4859
- // @Trace()
4860
- /**
5268
+ LinkTriggeredNavigationInteractionCancelled.prototype.onRouterCancelled = /**
4861
5269
  * @param {?} event
4862
5270
  * @return {?}
4863
5271
  */
4864
5272
  function (event) {
4865
- // Depending on the state of the router and what was done we get a different
4866
- // sequence of events.
4867
- // If the navigation change was triggered by clicking a link we'll get a cancel with the locationChangeTriggerUrl as the final event.
4868
- // If the navigation change was triggered with a pop state then we'll get an onPopState with the locationChangeTriggerUrl but no cancel event with it.
4869
- if (this.gotPopStateWithLeavingUrl && this.interactionService.isActive()) {
4870
- /** @type {?} */
4871
- var interactionIds = this.interactionService.activeInteractionContextIds.value;
4872
- this.resetBrowserLocation(this.placeRouter.parseUrl(this.startingUrl).updateInteractionIds(interactionIds).url);
5273
+ // TODO: should really split this into two sub states in the first cancel event.
5274
+ if (!this.firstCancelEventUrl) {
5275
+ this.firstCancelEventUrl = event.url;
5276
+ this.clickedLinkMatchedBackButtonUrl = event.url === this.clickedLinkUrl;
5277
+ return this.ignore(event);
5278
+ }
5279
+ else {
5280
+ // we wait for our popped state to come in.
5281
+ if (!this.clickedLinkMatchedBackButtonUrl && this.popStateEventUrl) {
5282
+ return this.finaliseRouting();
5283
+ }
4873
5284
  }
4874
- return this.gotPopStateWithLeavingUrl || this.locationChangeTriggerUrl === event.url ? this.createIdleState() : this.ignore(event);
4875
5285
  };
4876
5286
  /**
4877
5287
  * @param {?} event
4878
5288
  * @return {?}
4879
5289
  */
4880
- CancelledDuringNavigationInteraction.prototype.onRouterEnd = /**
5290
+ LinkTriggeredNavigationInteractionCancelled.prototype.onRouterEnd = /**
4881
5291
  * @param {?} event
4882
5292
  * @return {?}
4883
5293
  */
4884
5294
  function (event) {
4885
- return this.ignore(event);
5295
+ if (this.clickedLinkMatchedBackButtonUrl) {
5296
+ return this.finaliseRouting();
5297
+ }
5298
+ else {
5299
+ return this.ignore(event);
5300
+ }
4886
5301
  };
4887
5302
  /**
4888
5303
  * @param {?} event
4889
5304
  * @return {?}
4890
5305
  */
4891
- CancelledDuringNavigationInteraction.prototype.onRouterError = /**
5306
+ LinkTriggeredNavigationInteractionCancelled.prototype.onRouterError = /**
4892
5307
  * @param {?} event
4893
5308
  * @return {?}
4894
5309
  */
@@ -4899,25 +5314,42 @@
4899
5314
  * @param {?} event
4900
5315
  * @return {?}
4901
5316
  */
4902
- CancelledDuringNavigationInteraction.prototype.onPopState = /**
5317
+ LinkTriggeredNavigationInteractionCancelled.prototype.onPopState = /**
4903
5318
  * @param {?} event
4904
5319
  * @return {?}
4905
5320
  */
4906
5321
  function (event) {
4907
- this.gotPopStateWithLeavingUrl = this.gotPopStateWithLeavingUrl || event.url === this.locationChangeTriggerUrl;
5322
+ this.popStateEventUrl = event.url;
4908
5323
  return this.ignore(event);
4909
5324
  };
4910
- // @Trace()
4911
- // @Trace()
5325
+ /**
5326
+ * @return {?}
5327
+ */
5328
+ LinkTriggeredNavigationInteractionCancelled.prototype.finaliseRouting = /**
5329
+ * @return {?}
5330
+ */
5331
+ function () {
5332
+ pectin.Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
5333
+ this.resetBrowserLocation(this.clickedLinkUrl); // put the back click one back in.
5334
+ if (this.interactionService.isActive()) {
5335
+ /** @type {?} */
5336
+ var interactionIds = this.interactionService.activeInteractionContextIds.value;
5337
+ // Angular doesn't preserve the url when a guard cancels the back button.
5338
+ // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
5339
+ this.resetBrowserLocation(this.placeRouter.parseUrl(this.startingUrl).updateInteractionIds(interactionIds).url);
5340
+ }
5341
+ else {
5342
+ this.resetBrowserLocation(this.startingUrl); // and now put our own url back in.
5343
+ }
5344
+ return this.createIdleState();
5345
+ };
4912
5346
  /**
4913
5347
  * @param {?} component
4914
5348
  * @param {?} currentUrl
4915
5349
  * @param {?} nextUrl
4916
5350
  * @return {?}
4917
5351
  */
4918
- CancelledDuringNavigationInteraction.prototype.canDeactivatePlace =
4919
- // @Trace()
4920
- /**
5352
+ LinkTriggeredNavigationInteractionCancelled.prototype.canDeactivatePlace = /**
4921
5353
  * @param {?} component
4922
5354
  * @param {?} currentUrl
4923
5355
  * @param {?} nextUrl
@@ -4930,47 +5362,185 @@
4930
5362
  });
4931
5363
  });
4932
5364
  };
5365
+ return LinkTriggeredNavigationInteractionCancelled;
5366
+ }(NavigationState));
5367
+ NavigationState.LinkTriggeredNavigationInteractionCancelled = LinkTriggeredNavigationInteractionCancelled;
5368
+ if (false) {
5369
+ /** @type {?} */
5370
+ LinkTriggeredNavigationInteractionCancelled.prototype.isPopState;
5371
+ /** @type {?} */
5372
+ LinkTriggeredNavigationInteractionCancelled.prototype.firstCancelEventUrl;
5373
+ /** @type {?} */
5374
+ LinkTriggeredNavigationInteractionCancelled.prototype.popStateEventUrl;
5375
+ /** @type {?} */
5376
+ LinkTriggeredNavigationInteractionCancelled.prototype.clickedLinkMatchedBackButtonUrl;
5377
+ /** @type {?} */
5378
+ LinkTriggeredNavigationInteractionCancelled.prototype.debugPropertyKeys;
5379
+ /** @type {?} */
5380
+ LinkTriggeredNavigationInteractionCancelled.prototype.startingUrl;
5381
+ /** @type {?} */
5382
+ LinkTriggeredNavigationInteractionCancelled.prototype.clickedLinkUrl;
5383
+ }
5384
+ /**
5385
+ * This state handles the scenario where a pop state triggered and interaction and the user clickeb back a second time to cancel it.
5386
+ * The sequence of routing events/state transitions is as follows.
5387
+ * -> Idle -> PopStateTransition (poppedHistoryUrl == page to go to, startingUrl = page to stay on )
5388
+ * -> confirm dialog shown.
5389
+ * -> click back
5390
+ * -> PopStateTransition -> CancelledDuringBackButtonNavigationInteraction(trigger url is the page before the popped history url)
5391
+ * -> NavigationCancel (for the previous back)
5392
+ * -> PopState
5393
+ * -> NavigationCancel
5394
+ */
5395
+ var /**
5396
+ * This state handles the scenario where a pop state triggered and interaction and the user clickeb back a second time to cancel it.
5397
+ * The sequence of routing events/state transitions is as follows.
5398
+ * -> Idle -> PopStateTransition (poppedHistoryUrl == page to go to, startingUrl = page to stay on )
5399
+ * -> confirm dialog shown.
5400
+ * -> click back
5401
+ * -> PopStateTransition -> CancelledDuringBackButtonNavigationInteraction(trigger url is the page before the popped history url)
5402
+ * -> NavigationCancel (for the previous back)
5403
+ * -> PopState
5404
+ * -> NavigationCancel
5405
+ */
5406
+ PopStateTriggeredNavigationInteractionCancelled = /** @class */ (function (_super) {
5407
+ __extends(PopStateTriggeredNavigationInteractionCancelled, _super);
5408
+ function PopStateTriggeredNavigationInteractionCancelled(context, startingUrl, locationChangeTriggerUrl, poppedHistoryUrl) {
5409
+ var _this = _super.call(this, context) || this;
5410
+ _this.startingUrl = startingUrl;
5411
+ _this.locationChangeTriggerUrl = locationChangeTriggerUrl;
5412
+ _this.poppedHistoryUrl = poppedHistoryUrl;
5413
+ _this.isPopState = false;
5414
+ _this.firstCancelHandled = false;
5415
+ _this.popStateHandled = false;
5416
+ _this.debugPropertyKeys = ['idle', 'startingUrl', 'poppedHistoryUrl', 'locationChangeTriggerUrl', 'popStateEventUrl', 'firstCancelHandled', 'popStateHandled'];
5417
+ return _this;
5418
+ }
5419
+ Object.defineProperty(PopStateTriggeredNavigationInteractionCancelled.prototype, "isTransitional", {
5420
+ get: /**
5421
+ * @return {?}
5422
+ */
5423
+ function () {
5424
+ return true;
5425
+ },
5426
+ enumerable: true,
5427
+ configurable: true
5428
+ });
5429
+ /**
5430
+ * @param {?} event
5431
+ * @return {?}
5432
+ */
5433
+ PopStateTriggeredNavigationInteractionCancelled.prototype.onRouterStarted = /**
5434
+ * @param {?} event
5435
+ * @return {?}
5436
+ */
5437
+ function (event) {
5438
+ return this.ignore(event);
5439
+ };
4933
5440
  /**
4934
5441
  * @param {?} event
4935
- * @param {?=} reason
4936
5442
  * @return {?}
4937
5443
  */
4938
- CancelledDuringNavigationInteraction.prototype.ignore = /**
5444
+ PopStateTriggeredNavigationInteractionCancelled.prototype.onRouterCancelled = /**
4939
5445
  * @param {?} event
4940
- * @param {?=} reason
4941
5446
  * @return {?}
4942
5447
  */
4943
- function (event, reason) {
4944
- reason = reason ? " -> " + reason : '';
4945
- pectin.Logger.get(this).info("ignoring router event" + reason + ": " + event.constructor.name + " -> " + event.url);
4946
- return this;
5448
+ function (event) {
5449
+ if (this.firstCancelHandled && this.popStateHandled) {
5450
+ // Angular doesn't preserve the url when a guard cancels the back button.
5451
+ // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
5452
+ pectin.Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
5453
+ this.resetBrowserLocation(this.locationChangeTriggerUrl); // put the second back click one back in.
5454
+ this.resetBrowserLocation(this.poppedHistoryUrl); // put the first back click one back in.
5455
+ if (this.interactionService.isActive()) {
5456
+ /** @type {?} */
5457
+ var interactionIds = this.interactionService.activeInteractionContextIds.value;
5458
+ this.resetBrowserLocation(this.placeRouter.parseUrl(this.startingUrl).updateInteractionIds(interactionIds).url);
5459
+ }
5460
+ else {
5461
+ this.resetBrowserLocation(this.startingUrl); // and now put our own url back in.
5462
+ }
5463
+ return this.createIdleState();
5464
+ }
5465
+ else {
5466
+ this.firstCancelHandled = true;
5467
+ return this.ignore(event);
5468
+ }
4947
5469
  };
4948
5470
  /**
5471
+ * @param {?} event
4949
5472
  * @return {?}
4950
5473
  */
4951
- CancelledDuringNavigationInteraction.prototype.toString = /**
5474
+ PopStateTriggeredNavigationInteractionCancelled.prototype.onRouterEnd = /**
5475
+ * @param {?} event
4952
5476
  * @return {?}
4953
5477
  */
4954
- function () {
4955
- return this.constructor.name + "(isIdl: " + this.idle + ", startingUrl: " + this.startingUrl + ", locationChangeTriggerUrl:" + this.locationChangeTriggerUrl + ")";
5478
+ function (event) {
5479
+ return this.ignore(event);
5480
+ };
5481
+ /**
5482
+ * @param {?} event
5483
+ * @return {?}
5484
+ */
5485
+ PopStateTriggeredNavigationInteractionCancelled.prototype.onRouterError = /**
5486
+ * @param {?} event
5487
+ * @return {?}
5488
+ */
5489
+ function (event) {
5490
+ return this.ignore(event);
4956
5491
  };
4957
- return CancelledDuringNavigationInteraction;
5492
+ /**
5493
+ * @param {?} event
5494
+ * @return {?}
5495
+ */
5496
+ PopStateTriggeredNavigationInteractionCancelled.prototype.onPopState = /**
5497
+ * @param {?} event
5498
+ * @return {?}
5499
+ */
5500
+ function (event) {
5501
+ this.popStateHandled = true;
5502
+ this.popStateEventUrl = event.url;
5503
+ return this.ignore(event);
5504
+ };
5505
+ /**
5506
+ * @param {?} component
5507
+ * @param {?} currentUrl
5508
+ * @param {?} nextUrl
5509
+ * @return {?}
5510
+ */
5511
+ PopStateTriggeredNavigationInteractionCancelled.prototype.canDeactivatePlace = /**
5512
+ * @param {?} component
5513
+ * @param {?} currentUrl
5514
+ * @param {?} nextUrl
5515
+ * @return {?}
5516
+ */
5517
+ function (component, currentUrl, nextUrl) {
5518
+ return __awaiter(this, void 0, void 0, function () {
5519
+ return __generator(this, function (_a) {
5520
+ return [2 /*return*/, false];
5521
+ });
5522
+ });
5523
+ };
5524
+ return PopStateTriggeredNavigationInteractionCancelled;
4958
5525
  }(NavigationState));
4959
- NavigationState.CancelledDuringNavigationInteraction = CancelledDuringNavigationInteraction;
5526
+ NavigationState.PopStateTriggeredNavigationInteractionCancelled = PopStateTriggeredNavigationInteractionCancelled;
4960
5527
  if (false) {
4961
5528
  /** @type {?} */
4962
- CancelledDuringNavigationInteraction.prototype.isPopState;
4963
- /**
4964
- * @type {?}
4965
- * @private
4966
- */
4967
- CancelledDuringNavigationInteraction.prototype.gotPopStateWithLeavingUrl;
5529
+ PopStateTriggeredNavigationInteractionCancelled.prototype.isPopState;
5530
+ /** @type {?} */
5531
+ PopStateTriggeredNavigationInteractionCancelled.prototype.firstCancelHandled;
5532
+ /** @type {?} */
5533
+ PopStateTriggeredNavigationInteractionCancelled.prototype.popStateHandled;
5534
+ /** @type {?} */
5535
+ PopStateTriggeredNavigationInteractionCancelled.prototype.popStateEventUrl;
5536
+ /** @type {?} */
5537
+ PopStateTriggeredNavigationInteractionCancelled.prototype.debugPropertyKeys;
4968
5538
  /** @type {?} */
4969
- CancelledDuringNavigationInteraction.prototype.startingUrl;
5539
+ PopStateTriggeredNavigationInteractionCancelled.prototype.startingUrl;
4970
5540
  /** @type {?} */
4971
- CancelledDuringNavigationInteraction.prototype.startingEventWasAPopState;
5541
+ PopStateTriggeredNavigationInteractionCancelled.prototype.locationChangeTriggerUrl;
4972
5542
  /** @type {?} */
4973
- CancelledDuringNavigationInteraction.prototype.locationChangeTriggerUrl;
5543
+ PopStateTriggeredNavigationInteractionCancelled.prototype.poppedHistoryUrl;
4974
5544
  }
4975
5545
  })(exports.NavigationState || (exports.NavigationState = {}));
4976
5546
 
@@ -8130,7 +8700,8 @@
8130
8700
  /** @type {?} */
8131
8701
  var param = new exports.ParameterDefinition.RouteId(propertyKey.toString(), options, type);
8132
8702
  typescriptUtilities.Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
8133
- pectin.UseDelegate({ tag: "@RouteId(" + prototype.constructor.name + "." + propertyKey.toString() + ")" })(prototype, propertyKey);
8703
+ // UseDelegate({tag: `@RouteId(${prototype.constructor.name}.${propertyKey.toString()})`})(prototype, propertyKey);
8704
+ pectin.UseDelegate()(prototype, propertyKey);
8134
8705
  });
8135
8706
  }
8136
8707
  /**
@@ -8150,7 +8721,8 @@
8150
8721
  /** @type {?} */
8151
8722
  var param = new exports.ParameterDefinition.ValueParameter(propertyKey.toString(), options, opts.getOptional("storeInUrl", null));
8152
8723
  typescriptUtilities.Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
8153
- pectin.UseDelegate({ tag: "@VisitParameter(" + prototype.constructor.name + "." + propertyKey.toString() + ")" })(prototype, propertyKey);
8724
+ // UseDelegate({tag: `@VisitParameter(${prototype.constructor.name}.${propertyKey.toString()})`})(prototype, propertyKey);
8725
+ pectin.UseDelegate()(prototype, propertyKey);
8154
8726
  });
8155
8727
  }
8156
8728
  /**
@@ -8170,7 +8742,8 @@
8170
8742
  /** @type {?} */
8171
8743
  var param = new exports.ParameterDefinition.ArrayParameter(propertyKey.toString(), options, opts.getOptional("storeInUrl", null));
8172
8744
  typescriptUtilities.Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
8173
- pectin.UseDelegate({ tag: "@VisitParameterList(" + prototype.constructor.name + "." + propertyKey.toString() + ")" })(prototype, propertyKey);
8745
+ pectin.UseDelegate()(prototype, propertyKey);
8746
+ // UseDelegate({tag: `@VisitParameterList(${prototype.constructor.name}.${propertyKey.toString()})`})(prototype, propertyKey);
8174
8747
  });
8175
8748
  }
8176
8749