@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.
@@ -2676,6 +2676,7 @@ class PlaceComponent extends DisposableComponent {
2676
2676
  initialiseBindings(visit) {
2677
2677
  assert.isNil(this.visit);
2678
2678
  this.visit = visit;
2679
+ // DebugContext.get(this.visit).tag(`${this.placeDefinition.component.name}.visit`);
2679
2680
  this.placeDefinition.getVisitParameterDefs().forEach((/**
2680
2681
  * @param {?} parameterDef
2681
2682
  * @return {?}
@@ -3060,6 +3061,7 @@ class NavigationState extends GarbageCollector {
3060
3061
  super();
3061
3062
  this.context = context;
3062
3063
  this._visits = new Map();
3064
+ this.debugPropertyKeys = [];
3063
3065
  }
3064
3066
  /**
3065
3067
  * @return {?}
@@ -3196,14 +3198,18 @@ class NavigationState extends GarbageCollector {
3196
3198
  createTransitionStateFor(event) {
3197
3199
  /** @type {?} */
3198
3200
  const popstate = event.navigationTrigger === 'popstate';
3199
- return popstate ?
3200
- this.interactionService.isActive() ?
3201
- new NavigationState.InteractionPopStateTransition(this.context, this.currentRouterUrl()) :
3202
- new NavigationState.PopStateTransition(this.context, this.currentRouterUrl())
3203
- :
3204
- this.interactionService.isActive() ?
3205
- new NavigationState.InteractionTransition(this.context, this.currentRouterUrl()) :
3206
- new NavigationState.NavigationTransition(this.context, this.currentRouterUrl());
3201
+ /** @type {?} */
3202
+ const inInteraction = this.interactionService.isActive();
3203
+ if (popstate) {
3204
+ return inInteraction ?
3205
+ new NavigationState.LeavingInteractionAfterPopStateTransition(this.context, this.currentRouterUrl(), event.url) :
3206
+ new NavigationState.PopStateTransition(this.context, this.currentRouterUrl(), event.url);
3207
+ }
3208
+ else {
3209
+ return inInteraction ?
3210
+ new NavigationState.StartingInteractionTransition(this.context, this.currentRouterUrl()) :
3211
+ new NavigationState.NavigationTransition(this.context, this.currentRouterUrl());
3212
+ }
3207
3213
  }
3208
3214
  /**
3209
3215
  * @protected
@@ -3214,6 +3220,7 @@ class NavigationState extends GarbageCollector {
3214
3220
  new NavigationState.IdleDuringInteraction(this.context, this.currentRouterUrl()) :
3215
3221
  new NavigationState.Idle(this.context);
3216
3222
  }
3223
+ //
3217
3224
  /**
3218
3225
  * @param {?} url
3219
3226
  * @return {?}
@@ -3221,11 +3228,35 @@ class NavigationState extends GarbageCollector {
3221
3228
  resetBrowserLocation(url) {
3222
3229
  this.placeRouter.resetBrowserLocation(url);
3223
3230
  }
3231
+ /**
3232
+ * @param {?} event
3233
+ * @param {?=} reason
3234
+ * @return {?}
3235
+ */
3236
+ ignore(event, reason) {
3237
+ reason = reason ? ` -> ${reason}` : '';
3238
+ Logger.get(this).info(`Ignoring router event${reason}: ${event.constructor.name} -> ${event.url} :: ${this.toString()}`);
3239
+ return this;
3240
+ }
3224
3241
  /**
3225
3242
  * @return {?}
3226
3243
  */
3227
3244
  toString() {
3228
- return this.constructor.name;
3245
+ return `${this.constructor.name}(${this.debugState()})`;
3246
+ }
3247
+ /**
3248
+ * @protected
3249
+ * @param {?=} properties
3250
+ * @return {?}
3251
+ */
3252
+ debugState(properties) {
3253
+ return (properties || this.debugPropertyKeys).map((/**
3254
+ * @param {?} p
3255
+ * @return {?}
3256
+ */
3257
+ p => {
3258
+ return `${p}: ${this[p]}`;
3259
+ })).join(', ');
3229
3260
  }
3230
3261
  }
3231
3262
  if (false) {
@@ -3240,6 +3271,8 @@ if (false) {
3240
3271
  NavigationState.prototype.startingUrl;
3241
3272
  /** @type {?} */
3242
3273
  NavigationState.prototype.isPopState;
3274
+ /** @type {?} */
3275
+ NavigationState.prototype.debugPropertyKeys;
3243
3276
  /**
3244
3277
  * @type {?}
3245
3278
  * @protected
@@ -3301,7 +3334,7 @@ if (false) {
3301
3334
  }
3302
3335
  if (this.placeRouter.hasActiveInteractionIds(event.url)) {
3303
3336
  Logger.get(this).info(`navigation started with interaction outlet -> ${event.url}`);
3304
- return new InteractionTransition(this.context, event.url);
3337
+ return new StartingInteractionTransition(this.context, event.url);
3305
3338
  }
3306
3339
  else {
3307
3340
  return this.createTransitionStateFor(event);
@@ -3376,10 +3409,10 @@ if (false) {
3376
3409
  return new Idle(this.context);
3377
3410
  }
3378
3411
  /**
3379
- * @param {?} locationTriggerUrl
3412
+ * @param {?} newUrl
3380
3413
  * @return {?}
3381
3414
  */
3382
- onBackClickedDuringNavigationInteraction(locationTriggerUrl) {
3415
+ onBackClickedDuringNavigationInteraction(newUrl) {
3383
3416
  Logger.get(this).info(`back button pressed during navigation session interaction promise`);
3384
3417
  // detach the interaction from the session so it doesn't get disposed until the activity has completed.
3385
3418
  /** @type {?} */
@@ -3387,15 +3420,15 @@ if (false) {
3387
3420
  const { when } = Dsl.disposeWith(navigationInteraction);
3388
3421
  // TODO: I need to make the exclusive interaction context disallow nested activities or
3389
3422
  // that would mess things up entirely. Or, can I do a context.abortAll().then(..)
3423
+ Logger.get(this).info('cancelling current navigation activity..');
3390
3424
  navigationInteraction.cancelActiveActivity().then((/**
3391
3425
  * @return {?}
3392
3426
  */
3393
3427
  () => {
3394
3428
  navigationInteraction.dispose();
3395
3429
  }));
3396
- return new CancelledDuringNavigationInteraction(this.context, this.startingUrl, this.isPopState, locationTriggerUrl);
3430
+ return this.createNavigationInteractionCancelledState(newUrl);
3397
3431
  }
3398
- // @Trace()
3399
3432
  /**
3400
3433
  * @param {?} component
3401
3434
  * @param {?} currentUrl
@@ -3417,7 +3450,7 @@ if (false) {
3417
3450
  });
3418
3451
  }
3419
3452
  /**
3420
- * @private
3453
+ * @protected
3421
3454
  * @return {?}
3422
3455
  */
3423
3456
  detachInteractionContext() {
@@ -3443,11 +3476,18 @@ if (false) {
3443
3476
  AbstractNavigationTransition.prototype._interactionContext;
3444
3477
  /** @type {?} */
3445
3478
  AbstractNavigationTransition.prototype.startingUrl;
3479
+ /**
3480
+ * @abstract
3481
+ * @param {?} newUrl
3482
+ * @return {?}
3483
+ */
3484
+ AbstractNavigationTransition.prototype.createNavigationInteractionCancelledState = function (newUrl) { };
3446
3485
  }
3447
3486
  class NavigationTransition extends AbstractNavigationTransition {
3448
3487
  constructor() {
3449
3488
  super(...arguments);
3450
3489
  this.isPopState = false;
3490
+ this.debugPropertyKeys = ['startingUrl'];
3451
3491
  }
3452
3492
  /**
3453
3493
  * @param {?} event
@@ -3465,21 +3505,31 @@ if (false) {
3465
3505
  return new Idle(this.context);
3466
3506
  }
3467
3507
  /**
3508
+ * @param {?} newUrl
3468
3509
  * @return {?}
3469
3510
  */
3470
- toString() {
3471
- return `${this.constructor.name}(startingUrl: ${this.startingUrl})`;
3511
+ createNavigationInteractionCancelledState(newUrl) {
3512
+ return new LinkTriggeredNavigationInteractionCancelled(this.context, this.startingUrl, newUrl);
3472
3513
  }
3473
3514
  }
3474
3515
  NavigationState.NavigationTransition = NavigationTransition;
3475
3516
  if (false) {
3476
3517
  /** @type {?} */
3477
3518
  NavigationTransition.prototype.isPopState;
3519
+ /** @type {?} */
3520
+ NavigationTransition.prototype.debugPropertyKeys;
3478
3521
  }
3479
3522
  class PopStateTransition extends AbstractNavigationTransition {
3480
- constructor() {
3481
- super(...arguments);
3523
+ /**
3524
+ * @param {?} context
3525
+ * @param {?} startingUrl
3526
+ * @param {?} poppedHistoryUrl
3527
+ */
3528
+ constructor(context, startingUrl, poppedHistoryUrl) {
3529
+ super(context, startingUrl);
3530
+ this.poppedHistoryUrl = poppedHistoryUrl;
3482
3531
  this.isPopState = true;
3532
+ this.debugPropertyKeys = ['startingUrl', 'poppedHistoryUrl'];
3483
3533
  }
3484
3534
  /**
3485
3535
  * @param {?} event
@@ -3489,7 +3539,8 @@ if (false) {
3489
3539
  // Angular doesn't preserve the url when a guard cancels the back button.
3490
3540
  // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
3491
3541
  Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
3492
- this.resetBrowserLocation(this.startingUrl);
3542
+ this.resetBrowserLocation(this.poppedHistoryUrl); // put the popped history item back in.
3543
+ this.resetBrowserLocation(this.startingUrl); // and now put our own url back in.
3493
3544
  return new Idle(this.context);
3494
3545
  }
3495
3546
  /**
@@ -3502,16 +3553,54 @@ if (false) {
3502
3553
  // Angular doesn't preserve the url when a guard cancels the back button.
3503
3554
  // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
3504
3555
  Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
3505
- this.resetBrowserLocation(this.startingUrl);
3556
+ this.resetBrowserLocation(this.poppedHistoryUrl); // put the popped history item back in.
3557
+ this.resetBrowserLocation(this.startingUrl); // and now put our own url back in.
3506
3558
  }
3507
3559
  return new Idle(this.context);
3508
3560
  }
3561
+ /**
3562
+ * @param {?} locationTriggerUrl
3563
+ * @return {?}
3564
+ */
3565
+ createNavigationInteractionCancelledState(locationTriggerUrl) {
3566
+ return new PopStateTriggeredNavigationInteractionCancelled(this.context, this.startingUrl, locationTriggerUrl, this.poppedHistoryUrl);
3567
+ }
3509
3568
  }
3510
3569
  NavigationState.PopStateTransition = PopStateTransition;
3511
3570
  if (false) {
3512
3571
  /** @type {?} */
3513
3572
  PopStateTransition.prototype.isPopState;
3573
+ /** @type {?} */
3574
+ PopStateTransition.prototype.debugPropertyKeys;
3575
+ /** @type {?} */
3576
+ PopStateTransition.prototype.poppedHistoryUrl;
3514
3577
  }
3578
+ /**
3579
+ * @abstract
3580
+ */
3581
+ class AbstractInteractionTransition extends AbstractNavigationTransition {
3582
+ /**
3583
+ * @param {?} context
3584
+ * @param {?} startingUrl
3585
+ */
3586
+ constructor(context, startingUrl) {
3587
+ super(context, startingUrl);
3588
+ this.startingUrl = startingUrl;
3589
+ this.isTransitional = true;
3590
+ }
3591
+ }
3592
+ NavigationState.AbstractInteractionTransition = AbstractInteractionTransition;
3593
+ if (false) {
3594
+ /** @type {?} */
3595
+ AbstractInteractionTransition.prototype.isTransitional;
3596
+ /** @type {?} */
3597
+ AbstractInteractionTransition.prototype.startingUrl;
3598
+ }
3599
+ // The following states exist to handle all events while any kind of navigation is in progress. That way all other states can
3600
+ // happily ignore interaction contexts.
3601
+ /**
3602
+ * This is the non transitional (i.e. rest) state that is used whenever an interaction context is active.
3603
+ */
3515
3604
  class IdleDuringInteraction extends NavigationState {
3516
3605
  /**
3517
3606
  * @param {?} context
@@ -3522,6 +3611,7 @@ if (false) {
3522
3611
  this.startingUrl = startingUrl;
3523
3612
  this.isTransitional = false;
3524
3613
  this.isPopState = false;
3614
+ this.debugPropertyKeys = ['startingUrl'];
3525
3615
  }
3526
3616
  /**
3527
3617
  * @param {?} visit
@@ -3529,26 +3619,26 @@ if (false) {
3529
3619
  * @return {?}
3530
3620
  */
3531
3621
  onPlaceNavigationStart(visit, initialUrl) {
3622
+ // we're in an interaction and the user clicked back
3532
3623
  /** @type {?} */
3533
- const navigationTransition = new InteractionTransition(this.context, initialUrl);
3624
+ const navigationTransition = new StartingInteractionTransition(this.context, initialUrl);
3534
3625
  navigationTransition.storeVisit(visit);
3535
3626
  return navigationTransition;
3536
3627
  }
3537
- // @Trace()
3538
3628
  /**
3539
3629
  * @param {?} event
3540
3630
  * @return {?}
3541
3631
  */
3542
3632
  onRouterStarted(event) {
3543
- return new InteractionTransition(this.context, event.url);
3633
+ return new StartingInteractionTransition(this.context, event.url);
3544
3634
  }
3545
- // @Trace()
3546
3635
  /**
3547
3636
  * @param {?} event
3548
3637
  * @return {?}
3549
3638
  */
3550
3639
  onPopState(event) {
3551
- return new InteractionPopStateTransition(this.context, event.url);
3640
+ // we're in an interaction and the user clicked back
3641
+ return new LeavingInteractionAfterPopStateTransition(this.context, event.url, event.url);
3552
3642
  }
3553
3643
  }
3554
3644
  NavigationState.IdleDuringInteraction = IdleDuringInteraction;
@@ -3558,39 +3648,21 @@ if (false) {
3558
3648
  /** @type {?} */
3559
3649
  IdleDuringInteraction.prototype.isPopState;
3560
3650
  /** @type {?} */
3561
- IdleDuringInteraction.prototype.startingUrl;
3562
- }
3563
- /**
3564
- * @abstract
3565
- */
3566
- class AbstractInteractionTransition extends AbstractNavigationTransition {
3567
- /**
3568
- * @param {?} context
3569
- * @param {?} startingUrl
3570
- */
3571
- constructor(context, startingUrl) {
3572
- super(context, startingUrl);
3573
- this.startingUrl = startingUrl;
3574
- this.isTransitional = true;
3575
- }
3576
- }
3577
- NavigationState.AbstractInteractionTransition = AbstractInteractionTransition;
3578
- if (false) {
3579
- /** @type {?} */
3580
- AbstractInteractionTransition.prototype.isTransitional;
3651
+ IdleDuringInteraction.prototype.debugPropertyKeys;
3581
3652
  /** @type {?} */
3582
- AbstractInteractionTransition.prototype.startingUrl;
3653
+ IdleDuringInteraction.prototype.startingUrl;
3583
3654
  }
3584
3655
  /**
3585
3656
  * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
3586
3657
  * happily ignore interaction contexts.
3658
+ * NOTE: This state is activated when ever an interaction is started. It might be better to split it into
3659
+ * different states for different scenarios, e.g. starting model, starting model during route guard etc.
3587
3660
  */
3588
- class InteractionTransition extends AbstractInteractionTransition {
3661
+ class StartingInteractionTransition extends AbstractInteractionTransition {
3589
3662
  constructor() {
3590
3663
  super(...arguments);
3591
3664
  this.isPopState = false;
3592
3665
  }
3593
- // @Trace()
3594
3666
  /**
3595
3667
  * @param {?} event
3596
3668
  * @return {?}
@@ -3606,7 +3678,6 @@ if (false) {
3606
3678
  return new Idle(this.context);
3607
3679
  }
3608
3680
  }
3609
- // @Trace()
3610
3681
  /**
3611
3682
  * @param {?} event
3612
3683
  * @return {?}
@@ -3615,7 +3686,6 @@ if (false) {
3615
3686
  // navigation was aborted.
3616
3687
  return new IdleDuringInteraction(this.context, this.startingUrl);
3617
3688
  }
3618
- // @Trace()
3619
3689
  /**
3620
3690
  * @param {?} event
3621
3691
  * @return {?}
@@ -3628,22 +3698,137 @@ if (false) {
3628
3698
  return new Idle(this.context);
3629
3699
  }
3630
3700
  }
3701
+ /**
3702
+ * @param {?} locationTriggerUrl
3703
+ * @return {?}
3704
+ */
3705
+ createNavigationInteractionCancelledState(locationTriggerUrl) {
3706
+ return new LeavingInteractionTransitionCancelled(this.context, this.startingUrl, locationTriggerUrl);
3707
+ }
3631
3708
  }
3632
- NavigationState.InteractionTransition = InteractionTransition;
3709
+ NavigationState.StartingInteractionTransition = StartingInteractionTransition;
3633
3710
  if (false) {
3634
3711
  /** @type {?} */
3635
- InteractionTransition.prototype.isPopState;
3712
+ StartingInteractionTransition.prototype.isPopState;
3713
+ }
3714
+ /**
3715
+ * The sequence of router events are:
3716
+ * Error -> url = url of navigation link
3717
+ * End
3718
+ * onPopState url = current intereaction url sans the query params
3719
+ * Cancel url == same as above.
3720
+ */
3721
+ class LeavingInteractionTransitionCancelled extends NavigationState {
3722
+ /**
3723
+ * @param {?} context
3724
+ * @param {?} startingUrl
3725
+ * @param {?} locationChangeTriggerUrl
3726
+ */
3727
+ constructor(context, startingUrl, locationChangeTriggerUrl) {
3728
+ super(context);
3729
+ this.startingUrl = startingUrl;
3730
+ this.locationChangeTriggerUrl = locationChangeTriggerUrl;
3731
+ this.isPopState = false;
3732
+ this.firstCancelHandled = false;
3733
+ this.popStateHandled = false;
3734
+ this.debugPropertyKeys = ['idle', 'startingUrl', 'poppedHistoryUrl', 'locationChangeTriggerUrl', 'popStateEventUrl', 'firstCancelHandled', 'popStateHandled'];
3735
+ }
3736
+ /**
3737
+ * @return {?}
3738
+ */
3739
+ get isTransitional() {
3740
+ return true;
3741
+ }
3742
+ /**
3743
+ * @param {?} event
3744
+ * @return {?}
3745
+ */
3746
+ onRouterStarted(event) {
3747
+ return this.ignore(event);
3748
+ }
3749
+ /**
3750
+ * @param {?} event
3751
+ * @return {?}
3752
+ */
3753
+ onRouterCancelled(event) {
3754
+ // Angular doesn't preserve the url when a guard cancels the back button.
3755
+ // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
3756
+ Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
3757
+ if (this.interactionService.isActive()) {
3758
+ /** @type {?} */
3759
+ const interactionIds = this.interactionService.activeInteractionContextIds.value;
3760
+ this.resetBrowserLocation(this.placeRouter.parseUrl(this.startingUrl).updateInteractionIds(interactionIds).url);
3761
+ }
3762
+ else {
3763
+ this.resetBrowserLocation(this.startingUrl); // and now put our own url back in.
3764
+ }
3765
+ return this.createIdleState();
3766
+ }
3767
+ /**
3768
+ * @param {?} event
3769
+ * @return {?}
3770
+ */
3771
+ onRouterEnd(event) {
3772
+ return this.ignore(event);
3773
+ }
3774
+ /**
3775
+ * @param {?} event
3776
+ * @return {?}
3777
+ */
3778
+ onRouterError(event) {
3779
+ return this.ignore(event);
3780
+ }
3781
+ /**
3782
+ * @param {?} event
3783
+ * @return {?}
3784
+ */
3785
+ onPopState(event) {
3786
+ return this.ignore(event);
3787
+ }
3788
+ /**
3789
+ * @param {?} component
3790
+ * @param {?} currentUrl
3791
+ * @param {?} nextUrl
3792
+ * @return {?}
3793
+ */
3794
+ canDeactivatePlace(component, currentUrl, nextUrl) {
3795
+ return __awaiter(this, void 0, void 0, function* () {
3796
+ return false;
3797
+ });
3798
+ }
3799
+ }
3800
+ NavigationState.LeavingInteractionTransitionCancelled = LeavingInteractionTransitionCancelled;
3801
+ if (false) {
3802
+ /** @type {?} */
3803
+ LeavingInteractionTransitionCancelled.prototype.isPopState;
3804
+ /** @type {?} */
3805
+ LeavingInteractionTransitionCancelled.prototype.firstCancelHandled;
3806
+ /** @type {?} */
3807
+ LeavingInteractionTransitionCancelled.prototype.popStateHandled;
3808
+ /** @type {?} */
3809
+ LeavingInteractionTransitionCancelled.prototype.popStateEventUrl;
3810
+ /** @type {?} */
3811
+ LeavingInteractionTransitionCancelled.prototype.debugPropertyKeys;
3812
+ /** @type {?} */
3813
+ LeavingInteractionTransitionCancelled.prototype.startingUrl;
3814
+ /** @type {?} */
3815
+ LeavingInteractionTransitionCancelled.prototype.locationChangeTriggerUrl;
3636
3816
  }
3637
3817
  /**
3638
3818
  * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
3639
3819
  * happily ignore interaction contexts.
3640
3820
  */
3641
- class InteractionPopStateTransition extends AbstractInteractionTransition {
3642
- constructor() {
3643
- super(...arguments);
3821
+ class LeavingInteractionAfterPopStateTransition extends AbstractInteractionTransition {
3822
+ /**
3823
+ * @param {?} context
3824
+ * @param {?} startingUrl
3825
+ * @param {?} poppedHistoryUrl
3826
+ */
3827
+ constructor(context, startingUrl, poppedHistoryUrl) {
3828
+ super(context, startingUrl);
3829
+ this.poppedHistoryUrl = poppedHistoryUrl;
3644
3830
  this.isPopState = true;
3645
3831
  }
3646
- // @Trace()
3647
3832
  /**
3648
3833
  * @param {?} event
3649
3834
  * @return {?}
@@ -3659,7 +3844,6 @@ if (false) {
3659
3844
  return new Idle(this.context);
3660
3845
  }
3661
3846
  }
3662
- // @Trace()
3663
3847
  /**
3664
3848
  * @param {?} event
3665
3849
  * @return {?}
@@ -3672,26 +3856,124 @@ if (false) {
3672
3856
  return new Idle(this.context);
3673
3857
  }
3674
3858
  }
3859
+ /**
3860
+ * @param {?} newUrl
3861
+ * @return {?}
3862
+ */
3863
+ createNavigationInteractionCancelledState(newUrl) {
3864
+ return this.illegalTransition("Leaving interaction after pop-state should't block so should never see a back button click");
3865
+ }
3675
3866
  }
3676
- NavigationState.InteractionPopStateTransition = InteractionPopStateTransition;
3867
+ NavigationState.LeavingInteractionAfterPopStateTransition = LeavingInteractionAfterPopStateTransition;
3677
3868
  if (false) {
3678
3869
  /** @type {?} */
3679
- InteractionPopStateTransition.prototype.isPopState;
3680
- }
3681
- class CancelledDuringNavigationInteraction extends NavigationState {
3870
+ LeavingInteractionAfterPopStateTransition.prototype.isPopState;
3871
+ /** @type {?} */
3872
+ LeavingInteractionAfterPopStateTransition.prototype.poppedHistoryUrl;
3873
+ }
3874
+ // See LeavingInteractionAfterPopStateTransition.createNavigationInteractionCancelledState(...) above.
3875
+ //
3876
+ // export class LeavingInteractionAfterPopStateCancelled extends NavigationState {
3877
+ //
3878
+ // readonly isPopState = false;
3879
+ // firstCancelHandled = false;
3880
+ // popStateHandled = false;
3881
+ // popStateEventUrl: string;
3882
+ // debugPropertyKeys = ['idle', 'startingUrl', 'poppedHistoryUrl', 'locationChangeTriggerUrl', 'popStateEventUrl', 'firstCancelHandled', 'popStateHandled'];
3883
+ //
3884
+ // constructor(context: Context,
3885
+ // readonly startingUrl: string,
3886
+ // readonly locationChangeTriggerUrl: string,
3887
+ // readonly poppedHistoryUrl: string) {
3888
+ // super(context);
3889
+ // }
3890
+ //
3891
+ // get isTransitional() {
3892
+ // return true;
3893
+ // }
3894
+ //
3895
+ // onRouterStarted(event: NavigationStart): NavigationState {
3896
+ // return this.ignore(event);
3897
+ // }
3898
+ //
3899
+ //
3900
+ // onRouterCancelled(event: NavigationCancel): NavigationState {
3901
+ //
3902
+ // // if (this.firstCancelHandled && this.popStateHandled) {
3903
+ // // // Angular doesn't preserve the url when a guard cancels the back button.
3904
+ // // // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
3905
+ // // Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
3906
+ // // this.resetBrowserLocation(this.locationChangeTriggerUrl); // put the second back click one back in.
3907
+ // // this.resetBrowserLocation(this.poppedHistoryUrl); // put the first back click one back in.
3908
+ // // if (this.interactionService.isActive()) {
3909
+ // // const interactionIds = this.interactionService.activeInteractionContextIds.value;
3910
+ // // this.resetBrowserLocation(this.placeRouter.parseUrl(this.startingUrl).updateInteractionIds(interactionIds).url);
3911
+ // // } else {
3912
+ // // this.resetBrowserLocation(this.startingUrl); // and now put our own url back in.
3913
+ // // }
3914
+ // // return this.createIdleState();
3915
+ // // } else {
3916
+ // // this.firstCancelHandled = true;
3917
+ // return this.ignore(event);
3918
+ // // }
3919
+ // }
3920
+ //
3921
+ //
3922
+ // onRouterEnd(event: NavigationEnd): NavigationState {
3923
+ // return this.ignore(event);
3924
+ // }
3925
+ //
3926
+ //
3927
+ // onRouterError(event: NavigationError): NavigationState {
3928
+ // return this.ignore(event);
3929
+ // }
3930
+ //
3931
+ //
3932
+ // onPopState(event: NavigationStart): NavigationState {
3933
+ // // this.popStateHandled = true;
3934
+ // // this.popStateEventUrl = event.url;
3935
+ // return this.ignore(event);
3936
+ // }
3937
+ //
3938
+ // async canDeactivatePlace(component: PlaceComponent, currentUrl: UrlSnapshot, nextUrl: UrlSnapshot): Promise<boolean | UrlSnapshot> {
3939
+ // return false;
3940
+ // }
3941
+ // }
3942
+ /**
3943
+ * This state handles the scenario where a link navigation triggered an interaction and the user clicked back a to cancel it.
3944
+ * The routing event sequence is different depending on the link that was clicked.
3945
+ *
3946
+ * 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:
3947
+ *
3948
+ * -> Idle -> NavigationTransition
3949
+ * -> confirm dialog shown.
3950
+ * -> click back
3951
+ * -> NavigationCancel -> clickedLinkUrl === cancel.url
3952
+ * -> NavigationEnd
3953
+ *
3954
+ * Otherwise if the link is different from teh history location then the sequence is:
3955
+ *
3956
+ * -> Idle -> NavigationTransition
3957
+ * -> confirm dialog shown.
3958
+ * -> click back
3959
+ * -> NavigationCancel -> clickedLinkUrl !== cancel.url
3960
+ * -> NavigationEnd
3961
+ * -> PopState
3962
+ * -> NavigationCancel
3963
+ */
3964
+ class LinkTriggeredNavigationInteractionCancelled extends NavigationState {
3682
3965
  /**
3683
3966
  * @param {?} context
3684
3967
  * @param {?} startingUrl
3685
- * @param {?} startingEventWasAPopState
3686
- * @param {?} locationChangeTriggerUrl
3968
+ * @param {?} clickedLinkUrl
3687
3969
  */
3688
- constructor(context, startingUrl, startingEventWasAPopState, locationChangeTriggerUrl) {
3970
+ constructor(context, startingUrl, clickedLinkUrl) {
3689
3971
  super(context);
3690
3972
  this.startingUrl = startingUrl;
3691
- this.startingEventWasAPopState = startingEventWasAPopState;
3692
- this.locationChangeTriggerUrl = locationChangeTriggerUrl;
3973
+ this.clickedLinkUrl = clickedLinkUrl;
3693
3974
  this.isPopState = false;
3694
- this.gotPopStateWithLeavingUrl = false;
3975
+ this.clickedLinkMatchedBackButtonUrl = false;
3976
+ this.debugPropertyKeys = ['idle', 'startingUrl', 'clickedLinkUrl', 'firstCancelEventUrl', 'clickedLinkMatchedBackButtonUrl', 'popStateEventUrl'];
3695
3977
  }
3696
3978
  /**
3697
3979
  * @return {?}
@@ -3706,29 +3988,35 @@ if (false) {
3706
3988
  onRouterStarted(event) {
3707
3989
  return this.ignore(event);
3708
3990
  }
3709
- // @Trace()
3710
3991
  /**
3711
3992
  * @param {?} event
3712
3993
  * @return {?}
3713
3994
  */
3714
3995
  onRouterCancelled(event) {
3715
- // Depending on the state of the router and what was done we get a different
3716
- // sequence of events.
3717
- // If the navigation change was triggered by clicking a link we'll get a cancel with the locationChangeTriggerUrl as the final event.
3718
- // 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.
3719
- if (this.gotPopStateWithLeavingUrl && this.interactionService.isActive()) {
3720
- /** @type {?} */
3721
- const interactionIds = this.interactionService.activeInteractionContextIds.value;
3722
- this.resetBrowserLocation(this.placeRouter.parseUrl(this.startingUrl).updateInteractionIds(interactionIds).url);
3996
+ // TODO: should really split this into two sub states in the first cancel event.
3997
+ if (!this.firstCancelEventUrl) {
3998
+ this.firstCancelEventUrl = event.url;
3999
+ this.clickedLinkMatchedBackButtonUrl = event.url === this.clickedLinkUrl;
4000
+ return this.ignore(event);
4001
+ }
4002
+ else {
4003
+ // we wait for our popped state to come in.
4004
+ if (!this.clickedLinkMatchedBackButtonUrl && this.popStateEventUrl) {
4005
+ return this.finaliseRouting();
4006
+ }
3723
4007
  }
3724
- return this.gotPopStateWithLeavingUrl || this.locationChangeTriggerUrl === event.url ? this.createIdleState() : this.ignore(event);
3725
4008
  }
3726
4009
  /**
3727
4010
  * @param {?} event
3728
4011
  * @return {?}
3729
4012
  */
3730
4013
  onRouterEnd(event) {
3731
- return this.ignore(event);
4014
+ if (this.clickedLinkMatchedBackButtonUrl) {
4015
+ return this.finaliseRouting();
4016
+ }
4017
+ else {
4018
+ return this.ignore(event);
4019
+ }
3732
4020
  }
3733
4021
  /**
3734
4022
  * @param {?} event
@@ -3742,10 +4030,27 @@ if (false) {
3742
4030
  * @return {?}
3743
4031
  */
3744
4032
  onPopState(event) {
3745
- this.gotPopStateWithLeavingUrl = this.gotPopStateWithLeavingUrl || event.url === this.locationChangeTriggerUrl;
4033
+ this.popStateEventUrl = event.url;
3746
4034
  return this.ignore(event);
3747
4035
  }
3748
- // @Trace()
4036
+ /**
4037
+ * @return {?}
4038
+ */
4039
+ finaliseRouting() {
4040
+ Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
4041
+ this.resetBrowserLocation(this.clickedLinkUrl); // put the back click one back in.
4042
+ if (this.interactionService.isActive()) {
4043
+ /** @type {?} */
4044
+ const interactionIds = this.interactionService.activeInteractionContextIds.value;
4045
+ // Angular doesn't preserve the url when a guard cancels the back button.
4046
+ // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
4047
+ this.resetBrowserLocation(this.placeRouter.parseUrl(this.startingUrl).updateInteractionIds(interactionIds).url);
4048
+ }
4049
+ else {
4050
+ this.resetBrowserLocation(this.startingUrl); // and now put our own url back in.
4051
+ }
4052
+ return this.createIdleState();
4053
+ }
3749
4054
  /**
3750
4055
  * @param {?} component
3751
4056
  * @param {?} currentUrl
@@ -3757,38 +4062,144 @@ if (false) {
3757
4062
  return false;
3758
4063
  });
3759
4064
  }
4065
+ }
4066
+ NavigationState.LinkTriggeredNavigationInteractionCancelled = LinkTriggeredNavigationInteractionCancelled;
4067
+ if (false) {
4068
+ /** @type {?} */
4069
+ LinkTriggeredNavigationInteractionCancelled.prototype.isPopState;
4070
+ /** @type {?} */
4071
+ LinkTriggeredNavigationInteractionCancelled.prototype.firstCancelEventUrl;
4072
+ /** @type {?} */
4073
+ LinkTriggeredNavigationInteractionCancelled.prototype.popStateEventUrl;
4074
+ /** @type {?} */
4075
+ LinkTriggeredNavigationInteractionCancelled.prototype.clickedLinkMatchedBackButtonUrl;
4076
+ /** @type {?} */
4077
+ LinkTriggeredNavigationInteractionCancelled.prototype.debugPropertyKeys;
4078
+ /** @type {?} */
4079
+ LinkTriggeredNavigationInteractionCancelled.prototype.startingUrl;
4080
+ /** @type {?} */
4081
+ LinkTriggeredNavigationInteractionCancelled.prototype.clickedLinkUrl;
4082
+ }
4083
+ /**
4084
+ * This state handles the scenario where a pop state triggered and interaction and the user clickeb back a second time to cancel it.
4085
+ * The sequence of routing events/state transitions is as follows.
4086
+ * -> Idle -> PopStateTransition (poppedHistoryUrl == page to go to, startingUrl = page to stay on )
4087
+ * -> confirm dialog shown.
4088
+ * -> click back
4089
+ * -> PopStateTransition -> CancelledDuringBackButtonNavigationInteraction(trigger url is the page before the popped history url)
4090
+ * -> NavigationCancel (for the previous back)
4091
+ * -> PopState
4092
+ * -> NavigationCancel
4093
+ */
4094
+ class PopStateTriggeredNavigationInteractionCancelled extends NavigationState {
4095
+ /**
4096
+ * @param {?} context
4097
+ * @param {?} startingUrl
4098
+ * @param {?} locationChangeTriggerUrl
4099
+ * @param {?} poppedHistoryUrl
4100
+ */
4101
+ constructor(context, startingUrl, locationChangeTriggerUrl, poppedHistoryUrl) {
4102
+ super(context);
4103
+ this.startingUrl = startingUrl;
4104
+ this.locationChangeTriggerUrl = locationChangeTriggerUrl;
4105
+ this.poppedHistoryUrl = poppedHistoryUrl;
4106
+ this.isPopState = false;
4107
+ this.firstCancelHandled = false;
4108
+ this.popStateHandled = false;
4109
+ this.debugPropertyKeys = ['idle', 'startingUrl', 'poppedHistoryUrl', 'locationChangeTriggerUrl', 'popStateEventUrl', 'firstCancelHandled', 'popStateHandled'];
4110
+ }
4111
+ /**
4112
+ * @return {?}
4113
+ */
4114
+ get isTransitional() {
4115
+ return true;
4116
+ }
3760
4117
  /**
3761
4118
  * @param {?} event
3762
- * @param {?=} reason
3763
4119
  * @return {?}
3764
4120
  */
3765
- ignore(event, reason) {
3766
- reason = reason ? ` -> ${reason}` : '';
3767
- Logger.get(this).info(`ignoring router event${reason}: ${event.constructor.name} -> ${event.url}`);
3768
- return this;
4121
+ onRouterStarted(event) {
4122
+ return this.ignore(event);
4123
+ }
4124
+ /**
4125
+ * @param {?} event
4126
+ * @return {?}
4127
+ */
4128
+ onRouterCancelled(event) {
4129
+ if (this.firstCancelHandled && this.popStateHandled) {
4130
+ // Angular doesn't preserve the url when a guard cancels the back button.
4131
+ // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
4132
+ Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
4133
+ this.resetBrowserLocation(this.locationChangeTriggerUrl); // put the second back click one back in.
4134
+ this.resetBrowserLocation(this.poppedHistoryUrl); // put the first back click one back in.
4135
+ if (this.interactionService.isActive()) {
4136
+ /** @type {?} */
4137
+ const interactionIds = this.interactionService.activeInteractionContextIds.value;
4138
+ this.resetBrowserLocation(this.placeRouter.parseUrl(this.startingUrl).updateInteractionIds(interactionIds).url);
4139
+ }
4140
+ else {
4141
+ this.resetBrowserLocation(this.startingUrl); // and now put our own url back in.
4142
+ }
4143
+ return this.createIdleState();
4144
+ }
4145
+ else {
4146
+ this.firstCancelHandled = true;
4147
+ return this.ignore(event);
4148
+ }
3769
4149
  }
3770
4150
  /**
4151
+ * @param {?} event
3771
4152
  * @return {?}
3772
4153
  */
3773
- toString() {
3774
- return `${this.constructor.name}(isIdl: ${this.idle}, startingUrl: ${this.startingUrl}, locationChangeTriggerUrl:${this.locationChangeTriggerUrl})`;
4154
+ onRouterEnd(event) {
4155
+ return this.ignore(event);
4156
+ }
4157
+ /**
4158
+ * @param {?} event
4159
+ * @return {?}
4160
+ */
4161
+ onRouterError(event) {
4162
+ return this.ignore(event);
4163
+ }
4164
+ /**
4165
+ * @param {?} event
4166
+ * @return {?}
4167
+ */
4168
+ onPopState(event) {
4169
+ this.popStateHandled = true;
4170
+ this.popStateEventUrl = event.url;
4171
+ return this.ignore(event);
4172
+ }
4173
+ /**
4174
+ * @param {?} component
4175
+ * @param {?} currentUrl
4176
+ * @param {?} nextUrl
4177
+ * @return {?}
4178
+ */
4179
+ canDeactivatePlace(component, currentUrl, nextUrl) {
4180
+ return __awaiter(this, void 0, void 0, function* () {
4181
+ return false;
4182
+ });
3775
4183
  }
3776
4184
  }
3777
- NavigationState.CancelledDuringNavigationInteraction = CancelledDuringNavigationInteraction;
4185
+ NavigationState.PopStateTriggeredNavigationInteractionCancelled = PopStateTriggeredNavigationInteractionCancelled;
3778
4186
  if (false) {
3779
4187
  /** @type {?} */
3780
- CancelledDuringNavigationInteraction.prototype.isPopState;
3781
- /**
3782
- * @type {?}
3783
- * @private
3784
- */
3785
- CancelledDuringNavigationInteraction.prototype.gotPopStateWithLeavingUrl;
4188
+ PopStateTriggeredNavigationInteractionCancelled.prototype.isPopState;
4189
+ /** @type {?} */
4190
+ PopStateTriggeredNavigationInteractionCancelled.prototype.firstCancelHandled;
4191
+ /** @type {?} */
4192
+ PopStateTriggeredNavigationInteractionCancelled.prototype.popStateHandled;
4193
+ /** @type {?} */
4194
+ PopStateTriggeredNavigationInteractionCancelled.prototype.popStateEventUrl;
4195
+ /** @type {?} */
4196
+ PopStateTriggeredNavigationInteractionCancelled.prototype.debugPropertyKeys;
3786
4197
  /** @type {?} */
3787
- CancelledDuringNavigationInteraction.prototype.startingUrl;
4198
+ PopStateTriggeredNavigationInteractionCancelled.prototype.startingUrl;
3788
4199
  /** @type {?} */
3789
- CancelledDuringNavigationInteraction.prototype.startingEventWasAPopState;
4200
+ PopStateTriggeredNavigationInteractionCancelled.prototype.locationChangeTriggerUrl;
3790
4201
  /** @type {?} */
3791
- CancelledDuringNavigationInteraction.prototype.locationChangeTriggerUrl;
4202
+ PopStateTriggeredNavigationInteractionCancelled.prototype.poppedHistoryUrl;
3792
4203
  }
3793
4204
  })(NavigationState || (NavigationState = {}));
3794
4205
 
@@ -6439,7 +6850,8 @@ function RouteId(type, options) {
6439
6850
  /** @type {?} */
6440
6851
  const param = new ParameterDefinition.RouteId(propertyKey.toString(), options, type);
6441
6852
  Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
6442
- UseDelegate({ tag: `@RouteId(${prototype.constructor.name}.${propertyKey.toString()})` })(prototype, propertyKey);
6853
+ // UseDelegate({tag: `@RouteId(${prototype.constructor.name}.${propertyKey.toString()})`})(prototype, propertyKey);
6854
+ UseDelegate()(prototype, propertyKey);
6443
6855
  });
6444
6856
  }
6445
6857
  /**
@@ -6459,7 +6871,8 @@ function VisitParameter(options) {
6459
6871
  /** @type {?} */
6460
6872
  const param = new ParameterDefinition.ValueParameter(propertyKey.toString(), options, opts.getOptional("storeInUrl", null));
6461
6873
  Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
6462
- UseDelegate({ tag: `@VisitParameter(${prototype.constructor.name}.${propertyKey.toString()})` })(prototype, propertyKey);
6874
+ // UseDelegate({tag: `@VisitParameter(${prototype.constructor.name}.${propertyKey.toString()})`})(prototype, propertyKey);
6875
+ UseDelegate()(prototype, propertyKey);
6463
6876
  });
6464
6877
  }
6465
6878
  /**
@@ -6479,7 +6892,8 @@ function VisitParameterList(options) {
6479
6892
  /** @type {?} */
6480
6893
  const param = new ParameterDefinition.ArrayParameter(propertyKey.toString(), options, opts.getOptional("storeInUrl", null));
6481
6894
  Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);
6482
- UseDelegate({ tag: `@VisitParameterList(${prototype.constructor.name}.${propertyKey.toString()})` })(prototype, propertyKey);
6895
+ UseDelegate()(prototype, propertyKey);
6896
+ // UseDelegate({tag: `@VisitParameterList(${prototype.constructor.name}.${propertyKey.toString()})`})(prototype, propertyKey);
6483
6897
  });
6484
6898
  }
6485
6899