@coolon/angular-ui-powerups 0.0.101 → 0.0.102

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.
Files changed (53) hide show
  1. package/bundles/coolon-angular-ui-powerups.umd.js +896 -620
  2. package/bundles/coolon-angular-ui-powerups.umd.js.map +1 -1
  3. package/bundles/coolon-angular-ui-powerups.umd.min.js +1 -1
  4. package/bundles/coolon-angular-ui-powerups.umd.min.js.map +1 -1
  5. package/coolon-angular-ui-powerups.metadata.json +1 -1
  6. package/esm2015/coolon-angular-ui-powerups.js +2 -2
  7. package/esm2015/index.js +2 -2
  8. package/esm2015/lib/interaction/components/activity-container/activity-container.component.js +2 -1
  9. package/esm2015/lib/interaction/interaction-context-base.js +21 -8
  10. package/esm2015/lib/interaction/interaction-context.js +56 -3
  11. package/esm2015/lib/interaction/services/interaction.service.js +11 -7
  12. package/esm2015/lib/place/guards/navigation-state.js +216 -135
  13. package/esm2015/lib/place/guards/place-component-deactivation-handler.js +63 -28
  14. package/esm2015/lib/place/guards/place.guard.js +215 -0
  15. package/esm2015/lib/place/index.js +2 -3
  16. package/esm2015/lib/place/place-router.js +34 -36
  17. package/esm2015/lib/place/url-snapshot.js +69 -53
  18. package/esm2015/public_api.js +2 -2
  19. package/esm5/coolon-angular-ui-powerups.js +2 -2
  20. package/esm5/index.js +2 -2
  21. package/esm5/lib/interaction/components/activity-container/activity-container.component.js +2 -1
  22. package/esm5/lib/interaction/interaction-context-base.js +25 -8
  23. package/esm5/lib/interaction/interaction-context.js +88 -10
  24. package/esm5/lib/interaction/services/interaction.service.js +17 -8
  25. package/esm5/lib/place/guards/navigation-state.js +280 -162
  26. package/esm5/lib/place/guards/place-component-deactivation-handler.js +73 -27
  27. package/esm5/lib/place/guards/place.guard.js +300 -0
  28. package/esm5/lib/place/index.js +2 -3
  29. package/esm5/lib/place/place-router.js +52 -39
  30. package/esm5/lib/place/url-snapshot.js +85 -58
  31. package/esm5/public_api.js +2 -2
  32. package/fesm2015/coolon-angular-ui-powerups.js +661 -519
  33. package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
  34. package/fesm5/coolon-angular-ui-powerups.js +896 -619
  35. package/fesm5/coolon-angular-ui-powerups.js.map +1 -1
  36. package/lib/interaction/interaction-context-base.d.ts +3 -1
  37. package/lib/interaction/interaction-context.d.ts +9 -2
  38. package/lib/interaction/services/interaction.service.d.ts +2 -2
  39. package/lib/place/guards/navigation-state.d.ts +44 -38
  40. package/lib/place/guards/place-component-deactivation-handler.d.ts +7 -4
  41. package/lib/place/guards/{abstract-place.guard.d.ts → place.guard.d.ts} +8 -3
  42. package/lib/place/index.d.ts +1 -2
  43. package/lib/place/place-router.d.ts +2 -0
  44. package/lib/place/url-snapshot.d.ts +14 -9
  45. package/package.json +1 -1
  46. package/schematics/place-routes/place-def.js +1 -0
  47. package/schematics/place-routes/place-def.js.map +1 -1
  48. package/schematics/place-routes/templates/place-routes.ts.template +10 -11
  49. package/esm2015/lib/place/guards/abstract-place.guard.js +0 -166
  50. package/esm2015/lib/place/guards/interaction.guard.js +0 -121
  51. package/esm5/lib/place/guards/abstract-place.guard.js +0 -213
  52. package/esm5/lib/place/guards/interaction.guard.js +0 -133
  53. package/lib/place/guards/interaction.guard.d.ts +0 -17
@@ -1,14 +1,13 @@
1
1
  import { DOCUMENT, CommonModule, Location } from '@angular/common';
2
- import { Directive, ElementRef, Inject, Input, HostListener, NgZone, NgModule, EventEmitter, Output, Component, InjectionToken, Injector, ComponentFactoryResolver, ViewContainerRef, ViewChild, ViewChildren, Injectable, ɵɵdefineInjectable, ɵɵinject, Optional, SkipSelf, HostBinding, INJECTOR } from '@angular/core';
2
+ import { Directive, ElementRef, Inject, Input, HostListener, NgZone, NgModule, EventEmitter, Output, Component, InjectionToken, Injector, ComponentFactoryResolver, ViewContainerRef, ViewChild, ViewChildren, Injectable, ɵɵdefineInjectable, ɵɵinject, Optional, SkipSelf, HostBinding } from '@angular/core';
3
3
  import { FormsModule } from '@angular/forms';
4
4
  import { MatInputModule, MatFormFieldModule, MatSelectModule, MatButtonModule, MatDialogModule, MatTabsModule as MatTabsModule$1, MatProgressSpinnerModule, MatDialog } from '@angular/material';
5
5
  import { MatTabsModule } from '@angular/material/tabs';
6
6
  import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
7
7
  import { __extends, __decorate, __metadata, __awaiter, __generator, __assign, __spread } from 'tslib';
8
- import { DelegatingValueModel, assert, UnaryCommand, lang, Dsl, GarbageCollector, Logger, DelegatingFormValueModel, UseDelegate, ValueModel, ListModel, StoreInListModel, DelegatingListModel, Deferred, MutableStream, MutableValueModel, MutableListModel, Binding, Trace, Guard, StoreInValueModel, Command, OptionsHelper, ValueHolder } from '@coolon/pectin';
8
+ import { DelegatingValueModel, assert, UnaryCommand, lang, Dsl, GarbageCollector, Logger, DelegatingFormValueModel, UseDelegate, ValueModel, ListModel, StoreInListModel, Trace, DelegatingListModel, Deferred, MutableStream, MutableValueModel, MutableListModel, Binding, Guard, StoreInValueModel, Command, OptionsHelper, ValueHolder } from '@coolon/pectin';
9
9
  import { PortalModule } from '@angular/cdk/portal';
10
- import { RouterModule, UrlSegment, UrlSegmentGroup, NavigationStart, NavigationEnd, NavigationError, NavigationCancel, Router, UrlSerializer, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
11
- import ___default, { last, isNil, isEqual } from 'lodash';
10
+ import { RouterModule, NavigationStart, NavigationCancel, UrlSegment, NavigationEnd, NavigationError, Router, UrlSerializer } from '@angular/router';
12
11
  import { assert as assert$1, Opts, Klass } from '@coolon/typescript-utilities';
13
12
  import { MatIconModule } from '@angular/material/icon';
14
13
  import { MatListModule } from '@angular/material/list';
@@ -16,6 +15,7 @@ import { MatTooltipModule } from '@angular/material/tooltip';
16
15
  import { Memoize } from '@typescript-plus/fast-memoize-decorator/dist/src';
17
16
  import { Memoize as Memoize$1 } from '@typescript-plus/fast-memoize-decorator';
18
17
  import 'reflect-metadata';
18
+ import ___default, { isNil, isEqual } from 'lodash';
19
19
  import { style, query, group, animate, trigger, transition } from '@angular/animations';
20
20
  import ResizeObserver from 'resize-observer-polyfill';
21
21
  import { MatDialogConfig, MAT_DIALOG_DEFAULT_OPTIONS, MatDialog as MatDialog$1 } from '@angular/material/dialog';
@@ -1100,10 +1100,7 @@ if (false) {
1100
1100
  /**
1101
1101
  * @abstract
1102
1102
  */
1103
- var /**
1104
- * @abstract
1105
- */
1106
- InteractionContext = /** @class */ (function (_super) {
1103
+ var InteractionContext = /** @class */ (function (_super) {
1107
1104
  __extends(InteractionContext, _super);
1108
1105
  function InteractionContext() {
1109
1106
  return _super !== null && _super.apply(this, arguments) || this;
@@ -1134,17 +1131,101 @@ InteractionContext = /** @class */ (function (_super) {
1134
1131
  assert.isFalsey(this.isActive());
1135
1132
  _super.prototype.dispose.call(this);
1136
1133
  };
1134
+ /**
1135
+ * Cancels the current activity and returns true the context is no longer active, false if
1136
+ * there is still another activity running.
1137
+ */
1138
+ /**
1139
+ * Cancels the current activity and returns true the context is no longer active, false if
1140
+ * there is still another activity running.
1141
+ * @return {?}
1142
+ */
1143
+ InteractionContext.prototype.cancelCurrentActivity = /**
1144
+ * Cancels the current activity and returns true the context is no longer active, false if
1145
+ * there is still another activity running.
1146
+ * @return {?}
1147
+ */
1148
+ function () {
1149
+ return __awaiter(this, void 0, void 0, function () {
1150
+ var when, activity;
1151
+ var _this = this;
1152
+ return __generator(this, function (_a) {
1153
+ switch (_a.label) {
1154
+ case 0:
1155
+ when = Dsl.disposeWith(this).when;
1156
+ return [4 /*yield*/, this.getCurrentActivity()];
1157
+ case 1:
1158
+ activity = _a.sent();
1159
+ return [2 /*return*/, new Promise((/**
1160
+ * @param {?} resolve
1161
+ * @return {?}
1162
+ */
1163
+ function (resolve) {
1164
+ when.valueOf(_this.activeActivity)
1165
+ .changes((/**
1166
+ * @param {?} nextActivity
1167
+ * @return {?}
1168
+ */
1169
+ function (nextActivity) {
1170
+ resolve(!nextActivity);
1171
+ }), { once: true });
1172
+ activity.cancel();
1173
+ }))];
1174
+ }
1175
+ });
1176
+ });
1177
+ };
1178
+ /**
1179
+ * @return {?}
1180
+ */
1181
+ InteractionContext.prototype.abort = /**
1182
+ * @return {?}
1183
+ */
1184
+ function () {
1185
+ return __awaiter(this, void 0, void 0, function () {
1186
+ var count;
1187
+ return __generator(this, function (_a) {
1188
+ switch (_a.label) {
1189
+ case 0:
1190
+ assert.isTruthy(this.isActive());
1191
+ count = 1;
1192
+ return [4 /*yield*/, this.cancelCurrentActivity()];
1193
+ case 1:
1194
+ _a.sent();
1195
+ console.log("aborted -> " + count++);
1196
+ _a.label = 2;
1197
+ case 2:
1198
+ if (!this.isActive()) return [3 /*break*/, 4];
1199
+ return [4 /*yield*/, this.cancelCurrentActivity()];
1200
+ case 3:
1201
+ _a.sent();
1202
+ console.log("aborted -> " + count++);
1203
+ return [3 /*break*/, 2];
1204
+ case 4: return [2 /*return*/];
1205
+ }
1206
+ });
1207
+ });
1208
+ };
1209
+ __decorate([
1210
+ Trace(),
1211
+ __metadata("design:type", Function),
1212
+ __metadata("design:paramtypes", []),
1213
+ __metadata("design:returntype", Promise)
1214
+ ], InteractionContext.prototype, "abort", null);
1137
1215
  return InteractionContext;
1138
1216
  }(GarbageCollector));
1139
1217
  if (false) {
1218
+ /** @type {?} */
1219
+ InteractionContext.prototype.active;
1140
1220
  /** @type {?} */
1141
1221
  InteractionContext.prototype.activityList;
1142
1222
  /** @type {?} */
1143
- InteractionContext.prototype.active;
1223
+ InteractionContext.prototype.activeActivity;
1144
1224
  /**
1145
1225
  * Returns the activity that is currently active.
1146
1226
  * This model is only updated in the next tick after the view has been updated.
1147
1227
  * @abstract
1228
+ * @protected
1148
1229
  * @return {?}
1149
1230
  */
1150
1231
  InteractionContext.prototype.getCurrentActivity = function () { };
@@ -1353,13 +1434,14 @@ InteractionContextBase = /** @class */ (function (_super) {
1353
1434
  */
1354
1435
  _this._activityListDelegate = new DelegatingListModel();
1355
1436
  var _a = Dsl.disposeWith(_this), chain = _a.chain, valueOf = _a.valueOf, before = _a.before, when = _a.when, after = _a.after, observe = _a.observe, switchOn = _a.switchOn;
1356
- when.listOf(_this.activityList).becomesPopulated((/**
1357
- * @param {?} activities
1437
+ _this._currentActivity = chain(_this.activityList).last();
1438
+ when.valueOf(_this._currentActivity).becomesTruthy((/**
1439
+ * @param {?} activity
1358
1440
  * @return {?}
1359
1441
  */
1360
- function (activities) {
1442
+ function (activity) {
1361
1443
  if (_this.deferredGetCurrentActivity) {
1362
- _this.deferredGetCurrentActivity.resolve(last(activities));
1444
+ _this.deferredGetCurrentActivity.resolve(activity);
1363
1445
  _this.deferredGetCurrentActivity = null;
1364
1446
  }
1365
1447
  }));
@@ -1388,6 +1470,16 @@ InteractionContextBase = /** @class */ (function (_super) {
1388
1470
  enumerable: true,
1389
1471
  configurable: true
1390
1472
  });
1473
+ Object.defineProperty(InteractionContextBase.prototype, "activeActivity", {
1474
+ get: /**
1475
+ * @return {?}
1476
+ */
1477
+ function () {
1478
+ return this._currentActivity;
1479
+ },
1480
+ enumerable: true,
1481
+ configurable: true
1482
+ });
1391
1483
  /**
1392
1484
  * Returns the activity that is currently active.
1393
1485
  * This model is only updated in the next tick after the view has been updated.
@@ -1414,12 +1506,14 @@ InteractionContextBase = /** @class */ (function (_super) {
1414
1506
  return [2 /*return*/, this.deferredGetCurrentActivity.promise];
1415
1507
  }
1416
1508
  else {
1417
- if (this.activityList.length < 1) {
1509
+ if (!this._currentActivity.value) {
1510
+ // we'be been asked before we've got any activities, create a deferred promise
1511
+ // that we resolve when the list populates.
1418
1512
  this.deferredGetCurrentActivity = Deferred.defer();
1419
1513
  return [2 /*return*/, this.deferredGetCurrentActivity.promise];
1420
1514
  }
1421
1515
  else {
1422
- return [2 /*return*/, last(this.activityList.value)];
1516
+ return [2 /*return*/, this._currentActivity.value];
1423
1517
  }
1424
1518
  }
1425
1519
  }
@@ -1521,6 +1615,11 @@ if (false) {
1521
1615
  * @private
1522
1616
  */
1523
1617
  InteractionContextBase.prototype.deferredGetCurrentActivity;
1618
+ /**
1619
+ * @type {?}
1620
+ * @private
1621
+ */
1622
+ InteractionContextBase.prototype._currentActivity;
1524
1623
  /**
1525
1624
  * @abstract
1526
1625
  * @protected
@@ -1947,6 +2046,7 @@ var ActivityContainerComponent = /** @class */ (function (_super) {
1947
2046
  * @return {?}
1948
2047
  */
1949
2048
  function () {
2049
+ this.updateActivityList();
1950
2050
  this._initialActivityOutletContext.value = null;
1951
2051
  this.initialActivityOutletContextEvent.emit(null);
1952
2052
  };
@@ -2182,6 +2282,15 @@ var InteractionService = /** @class */ (function () {
2182
2282
  function () {
2183
2283
  return this.active.value;
2184
2284
  };
2285
+ /**
2286
+ * @return {?}
2287
+ */
2288
+ InteractionService.prototype.isModalActive = /**
2289
+ * @return {?}
2290
+ */
2291
+ function () {
2292
+ return this.modelInteractionActive.value;
2293
+ };
2185
2294
  /**
2186
2295
  * @param {?} disposable
2187
2296
  * @return {?}
@@ -2207,19 +2316,19 @@ var InteractionService = /** @class */ (function () {
2207
2316
  function (interactionContext) {
2208
2317
  interactionContext.registerDisposable(new InteractionService.Monitor("ip" + ++inplaceMonitorCount, interactionContext, this._activeInlineInteractionContextModel, this.exclusiveContext));
2209
2318
  };
2319
+ // @Trace()
2320
+ // @Trace()
2210
2321
  /**
2211
2322
  * @return {?}
2212
2323
  */
2213
- InteractionService.prototype.getCurrentActivity = /**
2324
+ InteractionService.prototype.getActiveContext =
2325
+ // @Trace()
2326
+ /**
2214
2327
  * @return {?}
2215
2328
  */
2216
2329
  function () {
2217
- return __awaiter(this, void 0, void 0, function () {
2218
- return __generator(this, function (_a) {
2219
- assert$1.isTruthy(this.isActive());
2220
- return [2 /*return*/, this._activeInteractionContext.value.getCurrentActivity()];
2221
- });
2222
- });
2330
+ assert$1.isTruthy(this.isActive());
2331
+ return this._activeInteractionContext.value;
2223
2332
  };
2224
2333
  /**
2225
2334
  * Creates an interaction context that will prevent any other contexts from starting an
@@ -3552,67 +3661,110 @@ if (false) {
3552
3661
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3553
3662
  */
3554
3663
  var PlaceComponentDeactivationHandler = /** @class */ (function () {
3555
- function PlaceComponentDeactivationHandler(component, navigationSession) {
3664
+ function PlaceComponentDeactivationHandler(component, navigationState, isPrimaryComponent) {
3556
3665
  this.component = component;
3557
- this.navigationSession = navigationSession;
3666
+ this.navigationState = navigationState;
3667
+ this.isPrimaryComponent = isPrimaryComponent;
3558
3668
  }
3669
+ Object.defineProperty(PlaceComponentDeactivationHandler.prototype, "interactionService", {
3670
+ get: /**
3671
+ * @return {?}
3672
+ */
3673
+ function () {
3674
+ return this.navigationState.interactionService;
3675
+ },
3676
+ enumerable: true,
3677
+ configurable: true
3678
+ });
3679
+ Object.defineProperty(PlaceComponentDeactivationHandler.prototype, "placeRouter", {
3680
+ get: /**
3681
+ * @return {?}
3682
+ */
3683
+ function () {
3684
+ return this.navigationState.placeRouter;
3685
+ },
3686
+ enumerable: true,
3687
+ configurable: true
3688
+ });
3559
3689
  /**
3690
+ * @param {?} currentUrl
3560
3691
  * @param {?} nextState
3561
3692
  * @return {?}
3562
3693
  */
3563
3694
  PlaceComponentDeactivationHandler.prototype.canDeactivate = /**
3695
+ * @param {?} currentUrl
3564
3696
  * @param {?} nextState
3565
3697
  * @return {?}
3566
3698
  */
3567
- function (nextState) {
3699
+ function (currentUrl, nextState) {
3568
3700
  return __awaiter(this, void 0, void 0, function () {
3569
3701
  return __generator(this, function (_a) {
3570
3702
  // We'll get called multiple times if there's any parameter sanitisation so
3571
3703
  // we always return true if we accepted promise from a previous cycle of the current
3572
3704
  // navigation session.
3573
3705
  if (!this.canDeactivatePromise) {
3574
- this.canDeactivatePromise = this.canDeactivateComponent(nextState);
3706
+ console.log("creating deactivate promise for -> " + this.component.constructor.name);
3707
+ this.canDeactivatePromise = this.canDeactivateComponent(currentUrl, nextState);
3575
3708
  }
3576
3709
  return [2 /*return*/, this.canDeactivatePromise];
3577
3710
  });
3578
3711
  });
3579
3712
  };
3713
+ // @Trace()
3714
+ // @Trace()
3580
3715
  /**
3581
3716
  * @protected
3717
+ * @param {?} currentUrl
3582
3718
  * @param {?} nextState
3583
3719
  * @return {?}
3584
3720
  */
3585
- PlaceComponentDeactivationHandler.prototype.canDeactivateComponent = /**
3721
+ PlaceComponentDeactivationHandler.prototype.canDeactivateComponent =
3722
+ // @Trace()
3723
+ /**
3586
3724
  * @protected
3725
+ * @param {?} currentUrl
3587
3726
  * @param {?} nextState
3588
3727
  * @return {?}
3589
3728
  */
3590
- function (nextState) {
3729
+ function (currentUrl, nextState) {
3591
3730
  return __awaiter(this, void 0, void 0, function () {
3592
- var activity;
3731
+ var routeIds, currentIds;
3593
3732
  return __generator(this, function (_a) {
3594
3733
  switch (_a.label) {
3595
3734
  case 0:
3596
- if (!(this.navigationSession.isPopState && this.component.interactionContext && this.component.interactionContext.isActive())) return [3 /*break*/, 2];
3597
- // Note: Modal interactions are run in a different router outlet so we never get place deactivating while
3598
- // a model interaction is active. This is because:
3599
- // 1. the user can't click anything to navigate away
3600
- // 2. clicking the back button will only change the outlet route portion of the URL. This
3601
- // is all handled by the InteractionGuard and so the component guards will never run.
3602
- //
3603
- // Now we just cancel the current activity...
3604
- return [4 /*yield*/, this.component.interactionContext.getCurrentActivity()];
3735
+ console.log(this.navigationState.toString());
3736
+ if (!this.navigationState.isPopState) return [3 /*break*/, 5];
3737
+ if (!(this.isPrimaryComponent && this.interactionService.isModalActive())) return [3 /*break*/, 3];
3738
+ routeIds = this.placeRouter.getActiveInteractionIdsFromUrl(nextState.url);
3739
+ currentIds = this.interactionService.activeInteractionContextIds.value;
3740
+ if (!!isEqual(currentIds, routeIds)) return [3 /*break*/, 2];
3741
+ return [4 /*yield*/, this.interactionService.getActiveContext().cancelCurrentActivity()];
3605
3742
  case 1:
3606
- activity = _a.sent();
3607
- activity.cancel(null);
3608
- return [2 /*return*/, false]; // ..and stay where we are.
3609
- case 2:
3743
+ _a.sent();
3744
+ return [2 /*return*/, currentUrl.updateInteractionIds(this.interactionService.activeInteractionContextIds.value)];
3745
+ case 2: return [3 /*break*/, 5];
3746
+ case 3:
3747
+ if (!(this.component.interactionContext && this.component.interactionContext.isActive())) return [3 /*break*/, 5];
3748
+ return [4 /*yield*/, this.component.interactionContext.cancelCurrentActivity()];
3749
+ case 4:
3750
+ _a.sent();
3751
+ return [2 /*return*/, currentUrl
3752
+ .updateInteractionIds(this.interactionService.activeInteractionContextIds.value)];
3753
+ case 5:
3610
3754
  // Ok, so now we're really leaving, so we ask the component if we should.;
3611
- if (this.isNotJustAChangeInRouteId(nextState) && this.component.canDeactivate) {
3612
- // No interaction in progress, so ask the component .
3613
- // This may start an interaction, hence checking the interaction context before now. I.e. if the place pops up the dialog, and
3614
- // the user clicks back again, we'll re-enter here and go bang when the component tries to open another dialog.
3615
- return [2 /*return*/, this.component.canDeactivate(this.navigationSession.interactionContext)];
3755
+ if (this.isNotJustAChangeInRouteId(nextState)) {
3756
+ if (this.component.canDeactivate) {
3757
+ // No interaction in progress, so ask the component .
3758
+ // This may start an interaction, hence checking the interaction context before now. I.e. if the place pops up the dialog, and
3759
+ // the user clicks back again, we'll re-enter here and go bang when the component tries to open another dialog.
3760
+ return [2 /*return*/, this.component.canDeactivate(this.navigationState.interactionContext)];
3761
+ }
3762
+ // The component has an active interaction but no deactivation hook. Rather than guessing what to do
3763
+ // we'll just cancel the navigation and print a warning.
3764
+ if (this.component.interactionContext && this.component.interactionContext.isActive()) {
3765
+ console.warn('Route changed while component has active interaction, cancelling navigation');
3766
+ return [2 /*return*/, false];
3767
+ }
3616
3768
  }
3617
3769
  return [2 /*return*/, true];
3618
3770
  }
@@ -3646,7 +3798,9 @@ if (false) {
3646
3798
  /** @type {?} */
3647
3799
  PlaceComponentDeactivationHandler.prototype.component;
3648
3800
  /** @type {?} */
3649
- PlaceComponentDeactivationHandler.prototype.navigationSession;
3801
+ PlaceComponentDeactivationHandler.prototype.navigationState;
3802
+ /** @type {?} */
3803
+ PlaceComponentDeactivationHandler.prototype.isPrimaryComponent;
3650
3804
  }
3651
3805
 
3652
3806
  /**
@@ -3667,6 +3821,16 @@ NavigationState = /** @class */ (function (_super) {
3667
3821
  _this._visits = new Map();
3668
3822
  return _this;
3669
3823
  }
3824
+ Object.defineProperty(NavigationState.prototype, "name", {
3825
+ get: /**
3826
+ * @return {?}
3827
+ */
3828
+ function () {
3829
+ return this.constructor.name;
3830
+ },
3831
+ enumerable: true,
3832
+ configurable: true
3833
+ });
3670
3834
  Object.defineProperty(NavigationState.prototype, "idle", {
3671
3835
  get: /**
3672
3836
  * @return {?}
@@ -3729,6 +3893,19 @@ NavigationState = /** @class */ (function (_super) {
3729
3893
  function (placeDef) {
3730
3894
  return this._visits.get(placeDef);
3731
3895
  };
3896
+ /**
3897
+ * @param {?} visit
3898
+ * @param {?} initialUrl
3899
+ * @return {?}
3900
+ */
3901
+ NavigationState.prototype.onPlaceNavigationStart = /**
3902
+ * @param {?} visit
3903
+ * @param {?} initialUrl
3904
+ * @return {?}
3905
+ */
3906
+ function (visit, initialUrl) {
3907
+ return this.illegalTransition('onPlaceNavigationStart');
3908
+ };
3732
3909
  /**
3733
3910
  * @param {?} event
3734
3911
  * @return {?}
@@ -3744,7 +3921,7 @@ NavigationState = /** @class */ (function (_super) {
3744
3921
  * @param {?} event
3745
3922
  * @return {?}
3746
3923
  */
3747
- NavigationState.prototype.onStart = /**
3924
+ NavigationState.prototype.onRouterStarted = /**
3748
3925
  * @param {?} event
3749
3926
  * @return {?}
3750
3927
  */
@@ -3755,7 +3932,7 @@ NavigationState = /** @class */ (function (_super) {
3755
3932
  * @param {?} event
3756
3933
  * @return {?}
3757
3934
  */
3758
- NavigationState.prototype.onCancel = /**
3935
+ NavigationState.prototype.onRouterCancelled = /**
3759
3936
  * @param {?} event
3760
3937
  * @return {?}
3761
3938
  */
@@ -3766,7 +3943,7 @@ NavigationState = /** @class */ (function (_super) {
3766
3943
  * @param {?} event
3767
3944
  * @return {?}
3768
3945
  */
3769
- NavigationState.prototype.onError = /**
3946
+ NavigationState.prototype.onRouterError = /**
3770
3947
  * @param {?} event
3771
3948
  * @return {?}
3772
3949
  */
@@ -3777,7 +3954,7 @@ NavigationState = /** @class */ (function (_super) {
3777
3954
  * @param {?} event
3778
3955
  * @return {?}
3779
3956
  */
3780
- NavigationState.prototype.onEnd = /**
3957
+ NavigationState.prototype.onRouterEnd = /**
3781
3958
  * @param {?} event
3782
3959
  * @return {?}
3783
3960
  */
@@ -3797,15 +3974,17 @@ NavigationState = /** @class */ (function (_super) {
3797
3974
  };
3798
3975
  /**
3799
3976
  * @param {?} component
3800
- * @param {?} nextState
3977
+ * @param {?} currentUrl
3978
+ * @param {?} nextUrl
3801
3979
  * @return {?}
3802
3980
  */
3803
3981
  NavigationState.prototype.canDeactivatePlace = /**
3804
3982
  * @param {?} component
3805
- * @param {?} nextState
3983
+ * @param {?} currentUrl
3984
+ * @param {?} nextUrl
3806
3985
  * @return {?}
3807
3986
  */
3808
- function (component, nextState) {
3987
+ function (component, currentUrl, nextUrl) {
3809
3988
  return __awaiter(this, void 0, void 0, function () {
3810
3989
  return __generator(this, function (_a) {
3811
3990
  return [2 /*return*/, this.illegalTransition('canDeactivatePlace')];
@@ -3858,12 +4037,29 @@ NavigationState = /** @class */ (function (_super) {
3858
4037
  * @return {?}
3859
4038
  */
3860
4039
  function (event) {
3861
- // TODO: check if the event is purely for interaction context changes.
3862
4040
  /** @type {?} */
3863
4041
  var popstate = event.navigationTrigger === 'popstate';
3864
4042
  return popstate ?
3865
- new NavigationState.NavigationBackTransition(this.context, popstate, this.currentRouterUrl()) :
3866
- new NavigationState.NavigationTransition(this.context, popstate, this.currentRouterUrl());
4043
+ this.interactionService.isActive() ?
4044
+ new NavigationState.InteractionPopStateTransition(this.context, this.currentRouterUrl()) :
4045
+ new NavigationState.PopStateTransition(this.context, this.currentRouterUrl())
4046
+ :
4047
+ this.interactionService.isActive() ?
4048
+ new NavigationState.InteractionTransition(this.context, this.currentRouterUrl()) :
4049
+ new NavigationState.NavigationTransition(this.context, this.currentRouterUrl());
4050
+ };
4051
+ /**
4052
+ * @protected
4053
+ * @return {?}
4054
+ */
4055
+ NavigationState.prototype.createIdleState = /**
4056
+ * @protected
4057
+ * @return {?}
4058
+ */
4059
+ function () {
4060
+ return this.interactionService.isActive() ?
4061
+ new NavigationState.IdleDuringInteraction(this.context, this.currentRouterUrl()) :
4062
+ new NavigationState.Idle(this.context);
3867
4063
  };
3868
4064
  /**
3869
4065
  * @param {?} url
@@ -3874,12 +4070,7 @@ NavigationState = /** @class */ (function (_super) {
3874
4070
  * @return {?}
3875
4071
  */
3876
4072
  function (url) {
3877
- var _this = this;
3878
- // TODO: Should this be a navigate operation to avoid confusing the router...??
3879
- setTimeout((/**
3880
- * @return {?}
3881
- */
3882
- function () { return _this.placeRouter.resetBrowserLocation(url); }));
4073
+ this.placeRouter.resetBrowserLocation(url);
3883
4074
  };
3884
4075
  /**
3885
4076
  * @return {?}
@@ -3937,11 +4128,27 @@ if (false) {
3937
4128
  _this.isPopState = false;
3938
4129
  return _this;
3939
4130
  }
4131
+ /**
4132
+ * @param {?} visit
4133
+ * @param {?} initialUrl
4134
+ * @return {?}
4135
+ */
4136
+ Idle.prototype.onPlaceNavigationStart = /**
4137
+ * @param {?} visit
4138
+ * @param {?} initialUrl
4139
+ * @return {?}
4140
+ */
4141
+ function (visit, initialUrl) {
4142
+ /** @type {?} */
4143
+ var navigationTransition = new NavigationTransition(this.context, initialUrl);
4144
+ navigationTransition.storeVisit(visit);
4145
+ return navigationTransition;
4146
+ };
3940
4147
  /**
3941
4148
  * @param {?} event
3942
4149
  * @return {?}
3943
4150
  */
3944
- Idle.prototype.onStart = /**
4151
+ Idle.prototype.onRouterStarted = /**
3945
4152
  * @param {?} event
3946
4153
  * @return {?}
3947
4154
  */
@@ -3989,9 +4196,8 @@ if (false) {
3989
4196
  */
3990
4197
  AbstractNavigationTransition = /** @class */ (function (_super) {
3991
4198
  __extends(AbstractNavigationTransition, _super);
3992
- function AbstractNavigationTransition(context, isPopState, startingUrl) {
4199
+ function AbstractNavigationTransition(context, startingUrl) {
3993
4200
  var _this = _super.call(this, context) || this;
3994
- _this.isPopState = isPopState;
3995
4201
  _this.startingUrl = startingUrl;
3996
4202
  _this.isTransitional = true;
3997
4203
  _this.componentDeactivationHandlers = new Map();
@@ -4024,7 +4230,7 @@ if (false) {
4024
4230
  * @param {?} event
4025
4231
  * @return {?}
4026
4232
  */
4027
- AbstractNavigationTransition.prototype.onStart = /**
4233
+ AbstractNavigationTransition.prototype.onRouterStarted = /**
4028
4234
  * @param {?} event
4029
4235
  * @return {?}
4030
4236
  */
@@ -4037,7 +4243,7 @@ if (false) {
4037
4243
  * @param {?} event
4038
4244
  * @return {?}
4039
4245
  */
4040
- AbstractNavigationTransition.prototype.onEnd = /**
4246
+ AbstractNavigationTransition.prototype.onRouterEnd = /**
4041
4247
  * @param {?} event
4042
4248
  * @return {?}
4043
4249
  */
@@ -4055,37 +4261,38 @@ if (false) {
4055
4261
  * @return {?}
4056
4262
  */
4057
4263
  function (locationTriggerUrl) {
4058
- // detach the interactoin from the session so it doesn't get disposed until the activity
4059
- // has completed.
4264
+ Logger.get(this).info("back button pressed during navigation session interaction promise");
4265
+ // detach the interaction from the session so it doesn't get disposed until the activity has completed.
4060
4266
  /** @type {?} */
4061
- var context = this.detachInteractionContext();
4062
- var when = Dsl.disposeWith(context).when;
4267
+ var navigationInteraction = this.detachInteractionContext();
4268
+ var when = Dsl.disposeWith(navigationInteraction).when;
4063
4269
  // TODO: I need to make the exclusive interaction context disallow nested activities or
4064
- // that would mess things up entirely.
4065
- context.getCurrentActivity().then((/**
4066
- * @param {?} activity
4270
+ // that would mess things up entirely. Or, can I do a context.abortAll().then(..)
4271
+ navigationInteraction.cancelCurrentActivity().then((/**
4067
4272
  * @return {?}
4068
4273
  */
4069
- function (activity) {
4070
- when.valueOf(context.active).becomesFalsey((/**
4071
- * @return {?}
4072
- */
4073
- function () { return context.dispose(); }), { once: true });
4074
- activity.cancel(null);
4274
+ function () {
4275
+ navigationInteraction.dispose();
4075
4276
  }));
4076
- return new CancelledDuringNavigationInteraction(this.context, this.startingUrl, locationTriggerUrl);
4277
+ return new CancelledDuringNavigationInteraction(this.context, this.startingUrl, this.isPopState, locationTriggerUrl);
4077
4278
  };
4279
+ // @Trace()
4280
+ // @Trace()
4078
4281
  /**
4079
4282
  * @param {?} component
4080
- * @param {?} nextState
4283
+ * @param {?} currentUrl
4284
+ * @param {?} nextUrl
4081
4285
  * @return {?}
4082
4286
  */
4083
- AbstractNavigationTransition.prototype.canDeactivatePlace = /**
4287
+ AbstractNavigationTransition.prototype.canDeactivatePlace =
4288
+ // @Trace()
4289
+ /**
4084
4290
  * @param {?} component
4085
- * @param {?} nextState
4291
+ * @param {?} currentUrl
4292
+ * @param {?} nextUrl
4086
4293
  * @return {?}
4087
4294
  */
4088
- function (component, nextState) {
4295
+ function (component, currentUrl, nextUrl) {
4089
4296
  return __awaiter(this, void 0, void 0, function () {
4090
4297
  var handler, isPrimaryHandler;
4091
4298
  return __generator(this, function (_a) {
@@ -4093,10 +4300,10 @@ if (false) {
4093
4300
  handler = this.componentDeactivationHandlers.get(component);
4094
4301
  if (!handler) {
4095
4302
  isPrimaryHandler = this.componentDeactivationHandlers.size === 0;
4096
- handler = new PlaceComponentDeactivationHandler(component, this);
4303
+ handler = new PlaceComponentDeactivationHandler(component, this, isPrimaryHandler);
4097
4304
  this.componentDeactivationHandlers.set(component, handler);
4098
4305
  }
4099
- return [2 /*return*/, handler.canDeactivate(nextState)];
4306
+ return [2 /*return*/, handler.canDeactivate(currentUrl, nextUrl)];
4100
4307
  });
4101
4308
  });
4102
4309
  };
@@ -4131,8 +4338,6 @@ if (false) {
4131
4338
  */
4132
4339
  AbstractNavigationTransition.prototype._interactionContext;
4133
4340
  /** @type {?} */
4134
- AbstractNavigationTransition.prototype.isPopState;
4135
- /** @type {?} */
4136
4341
  AbstractNavigationTransition.prototype.startingUrl;
4137
4342
  }
4138
4343
  var NavigationTransition = /** @class */ (function (_super) {
@@ -4146,44 +4351,18 @@ if (false) {
4146
4351
  * @param {?} event
4147
4352
  * @return {?}
4148
4353
  */
4149
- NavigationTransition.prototype.onStart = /**
4354
+ NavigationTransition.prototype.onRouterCancelled = /**
4150
4355
  * @param {?} event
4151
4356
  * @return {?}
4152
4357
  */
4153
4358
  function (event) {
4154
- // active sessions can have many cancel start cycles due
4155
- // to place guard redirects
4156
4359
  return this;
4157
4360
  };
4158
4361
  /**
4159
4362
  * @param {?} event
4160
4363
  * @return {?}
4161
4364
  */
4162
- NavigationTransition.prototype.onEnd = /**
4163
- * @param {?} event
4164
- * @return {?}
4165
- */
4166
- function (event) {
4167
- // navigation succeeded
4168
- this.context.notifySuccess(this);
4169
- return new Idle(this.context);
4170
- };
4171
- /**
4172
- * @param {?} event
4173
- * @return {?}
4174
- */
4175
- NavigationTransition.prototype.onCancel = /**
4176
- * @param {?} event
4177
- * @return {?}
4178
- */
4179
- function (event) {
4180
- return new Idle(this.context);
4181
- };
4182
- /**
4183
- * @param {?} event
4184
- * @return {?}
4185
- */
4186
- NavigationTransition.prototype.onError = /**
4365
+ NavigationTransition.prototype.onRouterError = /**
4187
4366
  * @param {?} event
4188
4367
  * @return {?}
4189
4368
  */
@@ -4207,9 +4386,9 @@ if (false) {
4207
4386
  /** @type {?} */
4208
4387
  NavigationTransition.prototype.isPopState;
4209
4388
  }
4210
- var NavigationBackTransition = /** @class */ (function (_super) {
4211
- __extends(NavigationBackTransition, _super);
4212
- function NavigationBackTransition() {
4389
+ var PopStateTransition = /** @class */ (function (_super) {
4390
+ __extends(PopStateTransition, _super);
4391
+ function PopStateTransition() {
4213
4392
  var _this = _super !== null && _super.apply(this, arguments) || this;
4214
4393
  _this.isPopState = true;
4215
4394
  return _this;
@@ -4218,7 +4397,7 @@ if (false) {
4218
4397
  * @param {?} event
4219
4398
  * @return {?}
4220
4399
  */
4221
- NavigationBackTransition.prototype.onCancel = /**
4400
+ PopStateTransition.prototype.onRouterCancelled = /**
4222
4401
  * @param {?} event
4223
4402
  * @return {?}
4224
4403
  */
@@ -4233,7 +4412,7 @@ if (false) {
4233
4412
  * @param {?} event
4234
4413
  * @return {?}
4235
4414
  */
4236
- NavigationBackTransition.prototype.onError = /**
4415
+ PopStateTransition.prototype.onRouterError = /**
4237
4416
  * @param {?} event
4238
4417
  * @return {?}
4239
4418
  */
@@ -4247,12 +4426,82 @@ if (false) {
4247
4426
  }
4248
4427
  return new Idle(this.context);
4249
4428
  };
4250
- return NavigationBackTransition;
4429
+ return PopStateTransition;
4251
4430
  }(AbstractNavigationTransition));
4252
- NavigationState.NavigationBackTransition = NavigationBackTransition;
4431
+ NavigationState.PopStateTransition = PopStateTransition;
4432
+ if (false) {
4433
+ /** @type {?} */
4434
+ PopStateTransition.prototype.isPopState;
4435
+ }
4436
+ var IdleDuringInteraction = /** @class */ (function (_super) {
4437
+ __extends(IdleDuringInteraction, _super);
4438
+ function IdleDuringInteraction(context, startingUrl) {
4439
+ var _this = _super.call(this, context) || this;
4440
+ _this.startingUrl = startingUrl;
4441
+ _this.isTransitional = false;
4442
+ _this.isPopState = false;
4443
+ return _this;
4444
+ }
4445
+ /**
4446
+ * @param {?} visit
4447
+ * @param {?} initialUrl
4448
+ * @return {?}
4449
+ */
4450
+ IdleDuringInteraction.prototype.onPlaceNavigationStart = /**
4451
+ * @param {?} visit
4452
+ * @param {?} initialUrl
4453
+ * @return {?}
4454
+ */
4455
+ function (visit, initialUrl) {
4456
+ /** @type {?} */
4457
+ var navigationTransition = new InteractionTransition(this.context, initialUrl);
4458
+ navigationTransition.storeVisit(visit);
4459
+ return navigationTransition;
4460
+ };
4461
+ /**
4462
+ * @param {?} event
4463
+ * @return {?}
4464
+ */
4465
+ IdleDuringInteraction.prototype.onRouterStarted = /**
4466
+ * @param {?} event
4467
+ * @return {?}
4468
+ */
4469
+ function (event) {
4470
+ return new InteractionTransition(this.context, event.url);
4471
+ };
4472
+ /**
4473
+ * @param {?} event
4474
+ * @return {?}
4475
+ */
4476
+ IdleDuringInteraction.prototype.onPopState = /**
4477
+ * @param {?} event
4478
+ * @return {?}
4479
+ */
4480
+ function (event) {
4481
+ return new InteractionPopStateTransition(this.context, event.url);
4482
+ };
4483
+ __decorate([
4484
+ Trace(),
4485
+ __metadata("design:type", Function),
4486
+ __metadata("design:paramtypes", [NavigationStart]),
4487
+ __metadata("design:returntype", NavigationState)
4488
+ ], IdleDuringInteraction.prototype, "onRouterStarted", null);
4489
+ __decorate([
4490
+ Trace(),
4491
+ __metadata("design:type", Function),
4492
+ __metadata("design:paramtypes", [NavigationStart]),
4493
+ __metadata("design:returntype", NavigationState)
4494
+ ], IdleDuringInteraction.prototype, "onPopState", null);
4495
+ return IdleDuringInteraction;
4496
+ }(NavigationState));
4497
+ NavigationState.IdleDuringInteraction = IdleDuringInteraction;
4253
4498
  if (false) {
4254
4499
  /** @type {?} */
4255
- NavigationBackTransition.prototype.isPopState;
4500
+ IdleDuringInteraction.prototype.isTransitional;
4501
+ /** @type {?} */
4502
+ IdleDuringInteraction.prototype.isPopState;
4503
+ /** @type {?} */
4504
+ IdleDuringInteraction.prototype.startingUrl;
4256
4505
  }
4257
4506
  /**
4258
4507
  * @abstract
@@ -4263,29 +4512,13 @@ if (false) {
4263
4512
  AbstractInteractionTransition = /** @class */ (function (_super) {
4264
4513
  __extends(AbstractInteractionTransition, _super);
4265
4514
  function AbstractInteractionTransition(context, startingUrl) {
4266
- var _this = _super.call(this, context) || this;
4515
+ var _this = _super.call(this, context, startingUrl) || this;
4267
4516
  _this.startingUrl = startingUrl;
4268
4517
  _this.isTransitional = true;
4269
4518
  return _this;
4270
4519
  }
4271
- /**
4272
- * @protected
4273
- * @return {?}
4274
- */
4275
- AbstractInteractionTransition.prototype.reinstateInteractionRoute = /**
4276
- * @protected
4277
- * @return {?}
4278
- */
4279
- function () {
4280
- var _this = this;
4281
- console.log(this.startingUrl);
4282
- setTimeout((/**
4283
- * @return {?}
4284
- */
4285
- function () { return _this.placeRouter.syncInteractionIdsWithRouter(); }));
4286
- };
4287
4520
  return AbstractInteractionTransition;
4288
- }(NavigationState));
4521
+ }(AbstractNavigationTransition));
4289
4522
  NavigationState.AbstractInteractionTransition = AbstractInteractionTransition;
4290
4523
  if (false) {
4291
4524
  /** @type {?} */
@@ -4312,115 +4545,122 @@ if (false) {
4312
4545
  * @param {?} event
4313
4546
  * @return {?}
4314
4547
  */
4315
- InteractionTransition.prototype.onEnd = /**
4548
+ InteractionTransition.prototype.onRouterCancelled = /**
4316
4549
  * @param {?} event
4317
4550
  * @return {?}
4318
4551
  */
4319
4552
  function (event) {
4320
4553
  if (this.context.interactionService.isActive()) {
4321
- this.reinstateInteractionRoute();
4554
+ /** @type {?} */
4555
+ var interactionIds = this.interactionService.activeInteractionContextIds.value;
4556
+ this.resetBrowserLocation(this.placeRouter.parseUrl(this.startingUrl).updateInteractionIds(interactionIds).url);
4322
4557
  return new IdleDuringInteraction(this.context, this.startingUrl);
4323
4558
  }
4324
4559
  else {
4325
4560
  return new Idle(this.context);
4326
4561
  }
4327
4562
  };
4328
- return InteractionTransition;
4329
- }(AbstractInteractionTransition));
4330
- NavigationState.InteractionTransition = InteractionTransition;
4331
- if (false) {
4332
- /** @type {?} */
4333
- InteractionTransition.prototype.isPopState;
4334
- }
4335
- /**
4336
- * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4337
- * happily ignore interaction contexts.
4338
- */
4339
- var /**
4340
- * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4341
- * happily ignore interaction contexts.
4342
- */
4343
- InteractionBackTransition = /** @class */ (function (_super) {
4344
- __extends(InteractionBackTransition, _super);
4345
- function InteractionBackTransition() {
4346
- var _this = _super !== null && _super.apply(this, arguments) || this;
4347
- _this.isPopState = true;
4348
- return _this;
4349
- }
4350
4563
  /**
4351
4564
  * @param {?} event
4352
4565
  * @return {?}
4353
4566
  */
4354
- InteractionBackTransition.prototype.onEnd = /**
4567
+ InteractionTransition.prototype.onRouterError = /**
4355
4568
  * @param {?} event
4356
4569
  * @return {?}
4357
4570
  */
4358
4571
  function (event) {
4359
- if (this.interactionService.isActive()) {
4360
- this.reinstateInteractionRoute();
4572
+ // navigation was aborted.
4573
+ return new IdleDuringInteraction(this.context, this.startingUrl);
4574
+ };
4575
+ /**
4576
+ * @param {?} event
4577
+ * @return {?}
4578
+ */
4579
+ InteractionTransition.prototype.onRouterEnd = /**
4580
+ * @param {?} event
4581
+ * @return {?}
4582
+ */
4583
+ function (event) {
4584
+ if (this.context.interactionService.isActive()) {
4361
4585
  return new IdleDuringInteraction(this.context, this.startingUrl);
4362
4586
  }
4363
4587
  else {
4364
4588
  return new Idle(this.context);
4365
4589
  }
4366
4590
  };
4367
- return InteractionBackTransition;
4591
+ return InteractionTransition;
4368
4592
  }(AbstractInteractionTransition));
4369
- NavigationState.InteractionBackTransition = InteractionBackTransition;
4593
+ NavigationState.InteractionTransition = InteractionTransition;
4370
4594
  if (false) {
4371
4595
  /** @type {?} */
4372
- InteractionBackTransition.prototype.isPopState;
4596
+ InteractionTransition.prototype.isPopState;
4373
4597
  }
4374
- var IdleDuringInteraction = /** @class */ (function (_super) {
4375
- __extends(IdleDuringInteraction, _super);
4376
- function IdleDuringInteraction(context, startingUrl) {
4377
- var _this = _super.call(this, context) || this;
4378
- _this.startingUrl = startingUrl;
4379
- _this.isTransitional = false;
4380
- _this.isPopState = false;
4598
+ /**
4599
+ * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4600
+ * happily ignore interaction contexts.
4601
+ */
4602
+ var /**
4603
+ * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4604
+ * happily ignore interaction contexts.
4605
+ */
4606
+ InteractionPopStateTransition = /** @class */ (function (_super) {
4607
+ __extends(InteractionPopStateTransition, _super);
4608
+ function InteractionPopStateTransition() {
4609
+ var _this = _super !== null && _super.apply(this, arguments) || this;
4610
+ _this.isPopState = true;
4381
4611
  return _this;
4382
4612
  }
4383
4613
  /**
4384
4614
  * @param {?} event
4385
4615
  * @return {?}
4386
4616
  */
4387
- IdleDuringInteraction.prototype.onStart = /**
4617
+ InteractionPopStateTransition.prototype.onRouterCancelled = /**
4388
4618
  * @param {?} event
4389
4619
  * @return {?}
4390
4620
  */
4391
4621
  function (event) {
4392
- return new InteractionTransition(this.context, event.url);
4622
+ if (this.interactionService.isActive()) {
4623
+ /** @type {?} */
4624
+ var interactionIds = this.interactionService.activeInteractionContextIds.value;
4625
+ this.resetBrowserLocation(this.placeRouter.parseUrl(this.startingUrl).updateInteractionIds(interactionIds).url);
4626
+ return new IdleDuringInteraction(this.context, this.startingUrl);
4627
+ }
4628
+ else {
4629
+ return new Idle(this.context);
4630
+ }
4393
4631
  };
4394
4632
  /**
4395
4633
  * @param {?} event
4396
4634
  * @return {?}
4397
4635
  */
4398
- IdleDuringInteraction.prototype.onPopState = /**
4636
+ InteractionPopStateTransition.prototype.onRouterEnd = /**
4399
4637
  * @param {?} event
4400
4638
  * @return {?}
4401
4639
  */
4402
4640
  function (event) {
4403
- return new InteractionBackTransition(this.context, event.url);
4641
+ if (this.context.interactionService.isActive()) {
4642
+ return new IdleDuringInteraction(this.context, this.startingUrl);
4643
+ }
4644
+ else {
4645
+ return new Idle(this.context);
4646
+ }
4404
4647
  };
4405
- return IdleDuringInteraction;
4406
- }(NavigationState));
4407
- NavigationState.IdleDuringInteraction = IdleDuringInteraction;
4648
+ return InteractionPopStateTransition;
4649
+ }(AbstractInteractionTransition));
4650
+ NavigationState.InteractionPopStateTransition = InteractionPopStateTransition;
4408
4651
  if (false) {
4409
4652
  /** @type {?} */
4410
- IdleDuringInteraction.prototype.isTransitional;
4411
- /** @type {?} */
4412
- IdleDuringInteraction.prototype.isPopState;
4413
- /** @type {?} */
4414
- IdleDuringInteraction.prototype.startingUrl;
4653
+ InteractionPopStateTransition.prototype.isPopState;
4415
4654
  }
4416
4655
  var CancelledDuringNavigationInteraction = /** @class */ (function (_super) {
4417
4656
  __extends(CancelledDuringNavigationInteraction, _super);
4418
- function CancelledDuringNavigationInteraction(context, startingUrl, locationChangeTriggerUrl) {
4657
+ function CancelledDuringNavigationInteraction(context, startingUrl, startingEventWasAPopState, locationChangeTriggerUrl) {
4419
4658
  var _this = _super.call(this, context) || this;
4420
4659
  _this.startingUrl = startingUrl;
4660
+ _this.startingEventWasAPopState = startingEventWasAPopState;
4421
4661
  _this.locationChangeTriggerUrl = locationChangeTriggerUrl;
4422
4662
  _this.isPopState = false;
4423
- _this.capturedFauxRouterStart = false;
4663
+ _this.gotPopStateWithLeavingUrl = false;
4424
4664
  return _this;
4425
4665
  }
4426
4666
  Object.defineProperty(CancelledDuringNavigationInteraction.prototype, "isTransitional", {
@@ -4428,7 +4668,7 @@ if (false) {
4428
4668
  * @return {?}
4429
4669
  */
4430
4670
  function () {
4431
- return !this.capturedFauxRouterStart;
4671
+ return true;
4432
4672
  },
4433
4673
  enumerable: true,
4434
4674
  configurable: true
@@ -4437,35 +4677,34 @@ if (false) {
4437
4677
  * @param {?} event
4438
4678
  * @return {?}
4439
4679
  */
4440
- CancelledDuringNavigationInteraction.prototype.onStart = /**
4680
+ CancelledDuringNavigationInteraction.prototype.onRouterStarted = /**
4441
4681
  * @param {?} event
4442
4682
  * @return {?}
4443
4683
  */
4444
4684
  function (event) {
4445
- if (event.url === this.locationChangeTriggerUrl && !this.capturedFauxRouterStart) {
4446
- this.capturedFauxRouterStart = true;
4447
- return this.ignore(event, 'url matched back button location change');
4448
- }
4449
- else {
4450
- return this.createTransitionStateFor(event);
4451
- }
4685
+ return this.ignore(event);
4452
4686
  };
4453
4687
  /**
4454
4688
  * @param {?} event
4455
4689
  * @return {?}
4456
4690
  */
4457
- CancelledDuringNavigationInteraction.prototype.onCancel = /**
4691
+ CancelledDuringNavigationInteraction.prototype.onRouterCancelled = /**
4458
4692
  * @param {?} event
4459
4693
  * @return {?}
4460
4694
  */
4461
4695
  function (event) {
4462
- return this.ignore(event);
4696
+ // Depending on the state of the router and what was done we get a different
4697
+ // sequence of events. I.e. If they just clicked a link we'll get a cancel
4698
+ // with the locationChangeTriggerUrl as the final event. However the user
4699
+ // started the initial navigation with a pop state then we'll get one of
4700
+ // those with the locationChangeTriggerUrl but no cancel event with it.
4701
+ return this.gotPopStateWithLeavingUrl || this.locationChangeTriggerUrl === event.url ? this.createIdleState() : this.ignore(event);
4463
4702
  };
4464
4703
  /**
4465
4704
  * @param {?} event
4466
4705
  * @return {?}
4467
4706
  */
4468
- CancelledDuringNavigationInteraction.prototype.onEnd = /**
4707
+ CancelledDuringNavigationInteraction.prototype.onRouterEnd = /**
4469
4708
  * @param {?} event
4470
4709
  * @return {?}
4471
4710
  */
@@ -4476,7 +4715,7 @@ if (false) {
4476
4715
  * @param {?} event
4477
4716
  * @return {?}
4478
4717
  */
4479
- CancelledDuringNavigationInteraction.prototype.onError = /**
4718
+ CancelledDuringNavigationInteraction.prototype.onRouterError = /**
4480
4719
  * @param {?} event
4481
4720
  * @return {?}
4482
4721
  */
@@ -4492,7 +4731,31 @@ if (false) {
4492
4731
  * @return {?}
4493
4732
  */
4494
4733
  function (event) {
4495
- return this.createTransitionStateFor(event);
4734
+ this.gotPopStateWithLeavingUrl = this.gotPopStateWithLeavingUrl || event.url === this.locationChangeTriggerUrl;
4735
+ return this.ignore(event);
4736
+ };
4737
+ // @Trace()
4738
+ // @Trace()
4739
+ /**
4740
+ * @param {?} component
4741
+ * @param {?} currentUrl
4742
+ * @param {?} nextUrl
4743
+ * @return {?}
4744
+ */
4745
+ CancelledDuringNavigationInteraction.prototype.canDeactivatePlace =
4746
+ // @Trace()
4747
+ /**
4748
+ * @param {?} component
4749
+ * @param {?} currentUrl
4750
+ * @param {?} nextUrl
4751
+ * @return {?}
4752
+ */
4753
+ function (component, currentUrl, nextUrl) {
4754
+ return __awaiter(this, void 0, void 0, function () {
4755
+ return __generator(this, function (_a) {
4756
+ return [2 /*return*/, false];
4757
+ });
4758
+ });
4496
4759
  };
4497
4760
  /**
4498
4761
  * @param {?} event
@@ -4505,7 +4768,7 @@ if (false) {
4505
4768
  * @return {?}
4506
4769
  */
4507
4770
  function (event, reason) {
4508
- reason = reason ? " (" + reason + ")" : '';
4771
+ reason = reason ? " -> " + reason : '';
4509
4772
  Logger.get(this).info("ignoring router event" + reason + ": " + event.constructor.name + " -> " + event.url);
4510
4773
  return this;
4511
4774
  };
@@ -4516,8 +4779,14 @@ if (false) {
4516
4779
  * @return {?}
4517
4780
  */
4518
4781
  function () {
4519
- return this.constructor.name + "(startingUrl: " + this.startingUrl + ", locationChangeTriggerUrl:" + this.locationChangeTriggerUrl + ")";
4782
+ return this.constructor.name + "(isIdl: " + this.idle + ", startingUrl: " + this.startingUrl + ", locationChangeTriggerUrl:" + this.locationChangeTriggerUrl + ")";
4520
4783
  };
4784
+ __decorate([
4785
+ Trace(),
4786
+ __metadata("design:type", Function),
4787
+ __metadata("design:paramtypes", [NavigationCancel]),
4788
+ __metadata("design:returntype", NavigationState)
4789
+ ], CancelledDuringNavigationInteraction.prototype, "onRouterCancelled", null);
4521
4790
  return CancelledDuringNavigationInteraction;
4522
4791
  }(NavigationState));
4523
4792
  NavigationState.CancelledDuringNavigationInteraction = CancelledDuringNavigationInteraction;
@@ -4528,10 +4797,12 @@ if (false) {
4528
4797
  * @type {?}
4529
4798
  * @private
4530
4799
  */
4531
- CancelledDuringNavigationInteraction.prototype.capturedFauxRouterStart;
4800
+ CancelledDuringNavigationInteraction.prototype.gotPopStateWithLeavingUrl;
4532
4801
  /** @type {?} */
4533
4802
  CancelledDuringNavigationInteraction.prototype.startingUrl;
4534
4803
  /** @type {?} */
4804
+ CancelledDuringNavigationInteraction.prototype.startingEventWasAPopState;
4805
+ /** @type {?} */
4535
4806
  CancelledDuringNavigationInteraction.prototype.locationChangeTriggerUrl;
4536
4807
  }
4537
4808
  })(NavigationState || (NavigationState = {}));
@@ -4622,25 +4893,26 @@ if (false) {
4622
4893
  */
4623
4894
  var UrlSnapshot = /** @class */ (function () {
4624
4895
  // TODO: Update this accept a url Parser so it can be immutable and generate new trees on mutation using toString() are parseUrl.
4625
- function UrlSnapshot(urlSerializer, url) {
4896
+ function UrlSnapshot(urlSerializer, url, options) {
4626
4897
  this.urlSerializer = urlSerializer;
4627
4898
  this.url = url;
4899
+ this.options = options;
4628
4900
  this.urlTree = urlSerializer.parse(url);
4629
4901
  }
4630
4902
  /**
4631
- * @protected
4632
4903
  * @param {?} visit
4633
4904
  * @return {?}
4634
4905
  */
4635
- UrlSnapshot.prototype.replaceExistingVisitSegmentsWith = /**
4636
- * @protected
4906
+ UrlSnapshot.prototype.updateVisitSegments = /**
4637
4907
  * @param {?} visit
4638
4908
  * @return {?}
4639
4909
  */
4640
4910
  function (visit) {
4911
+ /** @type {?} */
4912
+ var urlTree = this.urlSerializer.parse(this.url);
4641
4913
  // Ugly, but it works for now.
4642
4914
  /** @type {?} */
4643
- var segments = __spread(this.getPrimarySegments());
4915
+ var segments = __spread(this.getPrimarySegments(urlTree));
4644
4916
  /** @type {?} */
4645
4917
  var visitSegments = this.getSegmentsFor(visit);
4646
4918
  /** @type {?} */
@@ -4651,17 +4923,20 @@ var UrlSnapshot = /** @class */ (function () {
4651
4923
  function (segment) { return segment.path === visitSegments[0].path; }));
4652
4924
  // do not use the return value, it's the items that were removed!
4653
4925
  segments.splice.apply(segments, __spread([replaceAt, visitSegments.length], visitSegments));
4654
- return segments;
4926
+ urlTree.root.children.primary.segments = segments;
4927
+ return new UrlSnapshot(this.urlSerializer, urlTree.toString(), this.options);
4655
4928
  };
4656
4929
  /**
4657
4930
  * @private
4931
+ * @param {?} urlTree
4658
4932
  * @return {?}
4659
4933
  */
4660
4934
  UrlSnapshot.prototype.getPrimarySegments = /**
4661
4935
  * @private
4936
+ * @param {?} urlTree
4662
4937
  * @return {?}
4663
4938
  */
4664
- function () {
4939
+ function (urlTree) {
4665
4940
  return this.urlTree.root.children.primary.segments;
4666
4941
  };
4667
4942
  /**
@@ -4694,31 +4969,6 @@ var UrlSnapshot = /** @class */ (function () {
4694
4969
  new UrlSegment(visit.placeDefinition.path, visit.placeDefinition.getFormattedRouteParameters(visit))
4695
4970
  ];
4696
4971
  };
4697
- /**
4698
- * @param {?} visit
4699
- * @return {?}
4700
- */
4701
- UrlSnapshot.prototype.createRedirectCommandsFor = /**
4702
- * @param {?} visit
4703
- * @return {?}
4704
- */
4705
- function (visit) {
4706
- /** @type {?} */
4707
- var segments = this.replaceExistingVisitSegmentsWith(visit);
4708
- /** @type {?} */
4709
- var commands = [];
4710
- segments.forEach((/**
4711
- * @param {?} s
4712
- * @return {?}
4713
- */
4714
- function (s) {
4715
- commands.push(s.path);
4716
- if (s.parameterMap.keys.length > 0) {
4717
- commands.push(s.parameters);
4718
- }
4719
- }));
4720
- return commands;
4721
- };
4722
4972
  /**
4723
4973
  * @param {?} placeDef
4724
4974
  * @return {?}
@@ -4728,7 +4978,7 @@ var UrlSnapshot = /** @class */ (function () {
4728
4978
  * @return {?}
4729
4979
  */
4730
4980
  function (placeDef) {
4731
- return this.getPrimarySegments().find((/**
4981
+ return this.getPrimarySegments(this.urlTree).find((/**
4732
4982
  * @param {?} s
4733
4983
  * @return {?}
4734
4984
  */
@@ -4742,53 +4992,101 @@ var UrlSnapshot = /** @class */ (function () {
4742
4992
  */
4743
4993
  function () {
4744
4994
  /** @type {?} */
4745
- var interactionOutlet = this.urlTree.root.children[UrlSnapshot.INTERACTION_ROUTER_OUTLET];
4746
- if (interactionOutlet) {
4747
- assert.isTruthy(interactionOutlet.segments.length === 2);
4748
- assert.isTruthy(interactionOutlet.segments[0].path === UrlSnapshot.INTERACTION_ROUTER_PATH);
4749
- return UrlSnapshot.parseInteractionIds(interactionOutlet.segments[1].path);
4995
+ var queryParam = this.urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM];
4996
+ if (queryParam) {
4997
+ return UrlSnapshot.parseInteractionIds(queryParam);
4750
4998
  }
4751
4999
  else {
4752
5000
  return [];
4753
5001
  }
4754
5002
  };
5003
+ /**
5004
+ * @return {?}
5005
+ */
5006
+ UrlSnapshot.prototype.hasInteractionIds = /**
5007
+ * @return {?}
5008
+ */
5009
+ function () {
5010
+ return this.getInteractionIds().length > 0;
5011
+ };
4755
5012
  // @Trace()
4756
5013
  // @Trace()
4757
5014
  /**
4758
5015
  * @param {?} ids
4759
5016
  * @return {?}
4760
5017
  */
4761
- UrlSnapshot.prototype.addOrReplaceInteractionIds =
5018
+ UrlSnapshot.prototype.updateInteractionIds =
4762
5019
  // @Trace()
4763
5020
  /**
4764
5021
  * @param {?} ids
4765
5022
  * @return {?}
4766
5023
  */
4767
5024
  function (ids) {
5025
+ if (ids.length === 0) {
5026
+ return this.removeInteractionIds();
5027
+ }
5028
+ else {
5029
+ /** @type {?} */
5030
+ var urlTree = this.urlSerializer.parse(this.url);
5031
+ urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM] = UrlSnapshot.createPathIdFor(ids);
5032
+ return new UrlSnapshot(this.urlSerializer, urlTree.toString(), this.options);
5033
+ }
5034
+ };
5035
+ // @Trace()
5036
+ // @Trace()
5037
+ /**
5038
+ * @return {?}
5039
+ */
5040
+ UrlSnapshot.prototype.removeInteractionIds =
5041
+ // @Trace()
5042
+ /**
5043
+ * @return {?}
5044
+ */
5045
+ function () {
4768
5046
  /** @type {?} */
4769
5047
  var urlTree = this.urlSerializer.parse(this.url);
4770
- urlTree.root.children[UrlSnapshot.INTERACTION_ROUTER_OUTLET] = new UrlSegmentGroup([
4771
- new UrlSegment(UrlSnapshot.INTERACTION_ROUTER_PATH, {}),
4772
- new UrlSegment(UrlSnapshot.createPathIdFor(ids), {})
4773
- ], {});
4774
- return new UrlSnapshot(this.urlSerializer, urlTree.toString());
5048
+ if (urlTree.queryParams && urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM]) {
5049
+ urlTree.queryParams = {}; //[UrlSnapshot.INTERACTION_ROUTER_OUTLET]
5050
+ }
5051
+ return new UrlSnapshot(this.urlSerializer, urlTree.toString(), this.options);
5052
+ };
5053
+ /**
5054
+ * @param {?} options
5055
+ * @return {?}
5056
+ */
5057
+ UrlSnapshot.prototype.withOptions = /**
5058
+ * @param {?} options
5059
+ * @return {?}
5060
+ */
5061
+ function (options) {
5062
+ return new UrlSnapshot(this.urlSerializer, this.url, options);
5063
+ };
5064
+ /**
5065
+ * @return {?}
5066
+ */
5067
+ UrlSnapshot.prototype.getNavigationExtras = /**
5068
+ * @return {?}
5069
+ */
5070
+ function () {
5071
+ return this.options;
4775
5072
  };
4776
5073
  return UrlSnapshot;
4777
5074
  }());
4778
5075
  if (false) {
4779
- /**
4780
- * @type {?}
4781
- * @private
4782
- */
5076
+ /** @type {?} */
4783
5077
  UrlSnapshot.prototype.urlTree;
4784
5078
  /** @type {?} */
4785
5079
  UrlSnapshot.prototype.urlSerializer;
4786
5080
  /** @type {?} */
4787
5081
  UrlSnapshot.prototype.url;
5082
+ /**
5083
+ * @type {?}
5084
+ * @private
5085
+ */
5086
+ UrlSnapshot.prototype.options;
4788
5087
  }
4789
5088
  (function (UrlSnapshot) {
4790
- UrlSnapshot.INTERACTION_ROUTER_OUTLET = 'aup-interactions';
4791
- UrlSnapshot.INTERACTION_ROUTER_PATH = 'active';
5089
+ UrlSnapshot.INTERACTION_QUERY_PARAM = 'aup-interactions';
4792
5090
  UrlSnapshot.INTERACTION_ID_SEPARATOR = '--';
4793
5091
  /**
4794
5092
  * @param {?} path
@@ -4807,13 +5105,14 @@ if (false) {
4807
5105
  }
4808
5106
  UrlSnapshot.createPathIdFor = createPathIdFor;
4809
5107
  /**
4810
- * @param {?} interactionIds
4811
- * @return {?}
5108
+ * @record
4812
5109
  */
4813
- function createInteractionOutletRouterCommands(interactionIds) {
4814
- return [UrlSnapshot.INTERACTION_ROUTER_PATH, createPathIdFor(interactionIds)];
5110
+ function NavigationOptions() { }
5111
+ UrlSnapshot.NavigationOptions = NavigationOptions;
5112
+ if (false) {
5113
+ /** @type {?|undefined} */
5114
+ NavigationOptions.prototype.replaceUrl;
4815
5115
  }
4816
- UrlSnapshot.createInteractionOutletRouterCommands = createInteractionOutletRouterCommands;
4817
5116
  })(UrlSnapshot || (UrlSnapshot = {}));
4818
5117
 
4819
5118
  /**
@@ -4860,7 +5159,6 @@ var PlaceRouter = /** @class */ (function (_super) {
4860
5159
  // NavigationStart -> .... -> NavigationError --> navigation aborted, end session.
4861
5160
  // =======================
4862
5161
  if (event instanceof NavigationStart) {
4863
- console.log(event);
4864
5162
  if (event.navigationTrigger === 'popstate') {
4865
5163
  _this.runStateTransition((/**
4866
5164
  * @param {?} state
@@ -4873,7 +5171,7 @@ var PlaceRouter = /** @class */ (function (_super) {
4873
5171
  * @param {?} state
4874
5172
  * @return {?}
4875
5173
  */
4876
- function (state) { return state.onStart(event); }));
5174
+ function (state) { return state.onRouterStarted(event); }));
4877
5175
  }
4878
5176
  }
4879
5177
  if (event instanceof NavigationEnd) {
@@ -4882,7 +5180,7 @@ var PlaceRouter = /** @class */ (function (_super) {
4882
5180
  * @param {?} state
4883
5181
  * @return {?}
4884
5182
  */
4885
- function (state) { return state.onEnd(event); }));
5183
+ function (state) { return state.onRouterEnd(event); }));
4886
5184
  }
4887
5185
  if (event instanceof NavigationError) {
4888
5186
  console.log(event);
@@ -4890,7 +5188,7 @@ var PlaceRouter = /** @class */ (function (_super) {
4890
5188
  * @param {?} state
4891
5189
  * @return {?}
4892
5190
  */
4893
- function (state) { return state.onError(event); }));
5191
+ function (state) { return state.onRouterError(event); }));
4894
5192
  }
4895
5193
  if (event instanceof NavigationCancel) {
4896
5194
  console.log(event);
@@ -4898,7 +5196,7 @@ var PlaceRouter = /** @class */ (function (_super) {
4898
5196
  * @param {?} state
4899
5197
  * @return {?}
4900
5198
  */
4901
- function (state) { return state.onCancel(event); }));
5199
+ function (state) { return state.onRouterCancelled(event); }));
4902
5200
  }
4903
5201
  }));
4904
5202
  // Push dialog state to the url so we can capture the back button.
@@ -4927,12 +5225,11 @@ var PlaceRouter = /** @class */ (function (_super) {
4927
5225
  var navigationState = _this._navigationStateModel.value;
4928
5226
  console.log("URLChange -> " + url, { state: navigationState });
4929
5227
  urlChanges.publish({ url: url, state: navigationState });
4930
- // We've entered a navigation transition
4931
- if (navigationState instanceof NavigationState.NavigationTransition) {
5228
+ // The url has changed while we're in a transitional state
5229
+ if (navigationState.isTransitional) {
4932
5230
  /** @type {?} */
4933
5231
  var navigationInteraction = _this.navigationState.interactionContext;
4934
5232
  if (navigationInteraction && navigationInteraction.isActive()) {
4935
- Logger.get(_this).info("back button pressed during navigation session interaction promise");
4936
5233
  _this.runStateTransition((/**
4937
5234
  * @param {?} state
4938
5235
  * @return {?}
@@ -5073,9 +5370,9 @@ var PlaceRouter = /** @class */ (function (_super) {
5073
5370
  */
5074
5371
  function (router) {
5075
5372
  /** @type {?} */
5076
- var commands = _this.parseUrl(_this.router.routerState.snapshot.url).createRedirectCommandsFor(next);
5077
- console.log('### Push Changes to route Redirect', { commands: commands });
5078
- return router.navigate(commands);
5373
+ var urlSnapshot = _this.parseUrl(_this.router.routerState.snapshot.url).updateVisitSegments(next);
5374
+ console.log('### Push Changes to route Redirect', { commands: urlSnapshot.url });
5375
+ return _this.navigateByUrl(urlSnapshot);
5079
5376
  }))];
5080
5377
  }
5081
5378
  return [2 /*return*/];
@@ -5107,7 +5404,7 @@ var PlaceRouter = /** @class */ (function (_super) {
5107
5404
  */
5108
5405
  function (current) {
5109
5406
  /** @type {?} */
5110
- var session = new NavigationState.NavigationTransition(_this._navigationSessionContext, false, _this.router.routerState.snapshot.url);
5407
+ var session = _this.navigationState.onPlaceNavigationStart(visit, _this.getCurrentRouterUrl());
5111
5408
  session.storeVisit(visit);
5112
5409
  return session;
5113
5410
  }));
@@ -5126,7 +5423,7 @@ var PlaceRouter = /** @class */ (function (_super) {
5126
5423
  * @param {?} session
5127
5424
  * @return {?}
5128
5425
  */
5129
- function (session) { return session.onEnd(new NavigationEnd(-1, '', '')); }));
5426
+ function (session) { return session.onRouterEnd(new NavigationEnd(-1, '', '')); }));
5130
5427
  }
5131
5428
  return [7 /*endfinally*/];
5132
5429
  case 4: return [2 /*return*/];
@@ -5134,12 +5431,16 @@ var PlaceRouter = /** @class */ (function (_super) {
5134
5431
  });
5135
5432
  });
5136
5433
  };
5434
+ // @Trace()
5435
+ // @Trace()
5137
5436
  /**
5138
5437
  * @protected
5139
5438
  * @param {?} transition
5140
5439
  * @return {?}
5141
5440
  */
5142
- PlaceRouter.prototype.runStateTransition = /**
5441
+ PlaceRouter.prototype.runStateTransition =
5442
+ // @Trace()
5443
+ /**
5143
5444
  * @protected
5144
5445
  * @param {?} transition
5145
5446
  * @return {?}
@@ -5196,7 +5497,7 @@ var PlaceRouter = /** @class */ (function (_super) {
5196
5497
  * @return {?}
5197
5498
  */
5198
5499
  function (url) {
5199
- return new UrlSnapshot(this.urlSerializer, url);
5500
+ return new UrlSnapshot(this.urlSerializer, url, {});
5200
5501
  };
5201
5502
  /**
5202
5503
  * @param {?} url
@@ -5218,6 +5519,15 @@ var PlaceRouter = /** @class */ (function (_super) {
5218
5519
  function () {
5219
5520
  return this.router.routerState ? this.router.routerState.snapshot.url : null;
5220
5521
  };
5522
+ /**
5523
+ * @return {?}
5524
+ */
5525
+ PlaceRouter.prototype.getCurrentRouteSnapshot = /**
5526
+ * @return {?}
5527
+ */
5528
+ function () {
5529
+ return this.parseUrl(this.getCurrentRouterUrl());
5530
+ };
5221
5531
  /**
5222
5532
  * @param {?} url
5223
5533
  * @return {?}
@@ -5244,14 +5554,32 @@ var PlaceRouter = /** @class */ (function (_super) {
5244
5554
  function (url) {
5245
5555
  return this.getActiveInteractionIdsFromUrl(url).length > 0;
5246
5556
  };
5557
+ // @Trace()
5558
+ // @Trace()
5559
+ /**
5560
+ * @param {?} urlSnapshot
5561
+ * @return {?}
5562
+ */
5563
+ PlaceRouter.prototype.navigateByUrl =
5564
+ // @Trace()
5565
+ /**
5566
+ * @param {?} urlSnapshot
5567
+ * @return {?}
5568
+ */
5569
+ function (urlSnapshot) {
5570
+ this.router.navigateByUrl(urlSnapshot.urlTree, urlSnapshot.getNavigationExtras());
5571
+ };
5572
+ // @Trace()
5573
+ // @Trace()
5247
5574
  /**
5248
5575
  * @return {?}
5249
5576
  */
5250
- PlaceRouter.prototype.syncInteractionIdsWithRouter = /**
5577
+ PlaceRouter.prototype.syncInteractionIdsWithRouter =
5578
+ // @Trace()
5579
+ /**
5251
5580
  * @return {?}
5252
5581
  */
5253
5582
  function () {
5254
- var _a, _b;
5255
5583
  assert.isFalsey(this.navigationInProgress.value); // Updating interaction routes during an existing navigation breaks all the things.
5256
5584
  // Updating interaction routes during an existing navigation breaks all the things.
5257
5585
  /** @type {?} */
@@ -5261,22 +5589,12 @@ var PlaceRouter = /** @class */ (function (_super) {
5261
5589
  }
5262
5590
  else {
5263
5591
  if (currentIds.length < 1) {
5264
- this.router.navigate(['.', {
5265
- outlets: (_a = {},
5266
- _a[UrlSnapshot.INTERACTION_ROUTER_OUTLET] = null,
5267
- _a)
5268
- }], {
5269
- replaceUrl: true // remove the interaction from the history.
5270
- });
5592
+ // no more interactions to remove from history.
5593
+ this.navigateByUrl(this.getCurrentRouteSnapshot().removeInteractionIds());
5271
5594
  }
5272
5595
  else {
5273
- /** @type {?} */
5274
- var urlSnapshot = this.parseUrl(this.getCurrentRouterUrl());
5275
- this.router.navigate(['.', {
5276
- outlets: (_b = {},
5277
- _b[UrlSnapshot.INTERACTION_ROUTER_OUTLET] = UrlSnapshot.createInteractionOutletRouterCommands(currentIds),
5278
- _b)
5279
- }]);
5596
+ // todo was or is...
5597
+ this.navigateByUrl(this.getCurrentRouteSnapshot().updateInteractionIds(currentIds));
5280
5598
  }
5281
5599
  }
5282
5600
  };
@@ -5294,12 +5612,6 @@ var PlaceRouter = /** @class */ (function (_super) {
5294
5612
  { type: InteractionService }
5295
5613
  ]; };
5296
5614
  /** @nocollapse */ PlaceRouter.ngInjectableDef = ɵɵdefineInjectable({ factory: function PlaceRouter_Factory() { return new PlaceRouter(ɵɵinject(Router), ɵɵinject(UrlSerializer), ɵɵinject(Location), ɵɵinject(PlaceHistory), ɵɵinject(InteractionService)); }, token: PlaceRouter, providedIn: "root" });
5297
- __decorate([
5298
- Trace(),
5299
- __metadata("design:type", Function),
5300
- __metadata("design:paramtypes", []),
5301
- __metadata("design:returntype", void 0)
5302
- ], PlaceRouter.prototype, "syncInteractionIdsWithRouter", null);
5303
5615
  return PlaceRouter;
5304
5616
  }(GarbageCollector));
5305
5617
  if (false) {
@@ -6865,139 +7177,42 @@ function Place(options) {
6865
7177
  * @fileoverview added by tsickle
6866
7178
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
6867
7179
  */
6868
- var VisitSanitiser = /** @class */ (function () {
6869
- function VisitSanitiser(activatedRoute, router, placeHistory, injector) {
6870
- this.activatedRoute = activatedRoute;
6871
- this.router = router;
6872
- this.placeHistory = placeHistory;
6873
- this.injector = injector;
7180
+ /**
7181
+ * This a work around for the fact that an activated route with multiple segments doesn't
7182
+ * include the segment params in the paramMap as well as each segment returns an empty
7183
+ * param map even when `parameter`s has content.
7184
+ */
7185
+ var ConsolidatedParameterMap = /** @class */ (function () {
7186
+ function ConsolidatedParameterMap(paramMap, urlSegments) {
7187
+ this.paramMaps = [paramMap].concat((urlSegments || []).map((/**
7188
+ * @param {?} s
7189
+ * @return {?}
7190
+ */
7191
+ function (s) { return new ParamMapAdapter(s.parameters); }))).filter((/**
7192
+ * @param {?} m
7193
+ * @return {?}
7194
+ */
7195
+ function (m) { return !!m; })); // the activated route param map can be null
6874
7196
  }
6875
- // @Trace()
6876
- // @Trace()
6877
7197
  /**
6878
- * @param {?} visit
7198
+ * @param {?} name
6879
7199
  * @return {?}
6880
7200
  */
6881
- VisitSanitiser.prototype.sanitise =
6882
- // @Trace()
7201
+ ConsolidatedParameterMap.prototype.get = /**
7202
+ * @param {?} name
7203
+ * @return {?}
7204
+ */
7205
+ function (name) {
7206
+ /** @type {?} */
7207
+ var paramMap = this.paramMaps.find((/**
7208
+ * @param {?} m
7209
+ * @return {?}
7210
+ */
7211
+ function (m) { return m.has(name); }));
7212
+ return paramMap.get(name);
7213
+ };
6883
7214
  /**
6884
- * @param {?} visit
6885
- * @return {?}
6886
- */
6887
- function (visit) {
6888
- return __awaiter(this, void 0, void 0, function () {
6889
- var placeDef, routeIdDef, routeId, sanitisedValue, parameterDefs, sanitisedVisit, i, def, value, sanitisedValue;
6890
- return __generator(this, function (_a) {
6891
- switch (_a.label) {
6892
- case 0:
6893
- placeDef = visit.placeDefinition;
6894
- if (!placeDef.hasRouteId()) return [3 /*break*/, 2];
6895
- routeIdDef = placeDef.getRouteIdParameterDef();
6896
- routeId = visit.getRouteId();
6897
- return [4 /*yield*/, routeIdDef.sanitise(routeId, visit, this.placeHistory, this.injector)];
6898
- case 1:
6899
- sanitisedValue = _a.sent();
6900
- // console.log({routeId, sanitisedValue});
6901
- // ###------- EARLY EXIT --------###
6902
- if (routeIdDef.hasChanged(routeId, sanitisedValue)) {
6903
- // if the route id has changed we redirect immediately as other
6904
- // parameter sanitisers might use it.
6905
- return [2 /*return*/, visit.replace(routeIdDef, sanitisedValue)];
6906
- }
6907
- _a.label = 2;
6908
- case 2:
6909
- // if we didn't replace the routeId we continue the url present parameters.
6910
- parameterDefs = placeDef.getVisitParameterDefs({
6911
- includeRouteParameters: true,
6912
- includeNonRouteParameters: true
6913
- });
6914
- sanitisedVisit = visit;
6915
- i = 0;
6916
- _a.label = 3;
6917
- case 3:
6918
- if (!(i < parameterDefs.length)) return [3 /*break*/, 6];
6919
- def = parameterDefs[i];
6920
- value = visit.getParameter(def.name);
6921
- return [4 /*yield*/, def.sanitise(value, sanitisedVisit, this.placeHistory, this.injector)];
6922
- case 4:
6923
- sanitisedValue = _a.sent();
6924
- if (def.hasChanged(value, sanitisedValue)) {
6925
- sanitisedVisit = sanitisedVisit.replace(def, sanitisedValue);
6926
- }
6927
- _a.label = 5;
6928
- case 5:
6929
- i++;
6930
- return [3 /*break*/, 3];
6931
- case 6: return [2 /*return*/, sanitisedVisit.hasChangedFrom(visit) ? sanitisedVisit : visit];
6932
- }
6933
- });
6934
- });
6935
- };
6936
- return VisitSanitiser;
6937
- }());
6938
- if (false) {
6939
- /**
6940
- * @type {?}
6941
- * @private
6942
- */
6943
- VisitSanitiser.prototype.activatedRoute;
6944
- /**
6945
- * @type {?}
6946
- * @private
6947
- */
6948
- VisitSanitiser.prototype.router;
6949
- /**
6950
- * @type {?}
6951
- * @private
6952
- */
6953
- VisitSanitiser.prototype.placeHistory;
6954
- /**
6955
- * @type {?}
6956
- * @private
6957
- */
6958
- VisitSanitiser.prototype.injector;
6959
- }
6960
-
6961
- /**
6962
- * @fileoverview added by tsickle
6963
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
6964
- */
6965
- /**
6966
- * This a work around for the fact that an activated route with multiple segments doesn't
6967
- * include the segment params in the paramMap as well as each segment returns an empty
6968
- * param map even when `parameter`s has content.
6969
- */
6970
- var ConsolidatedParameterMap = /** @class */ (function () {
6971
- function ConsolidatedParameterMap(paramMap, urlSegments) {
6972
- this.paramMaps = [paramMap].concat((urlSegments || []).map((/**
6973
- * @param {?} s
6974
- * @return {?}
6975
- */
6976
- function (s) { return new ParamMapAdapter(s.parameters); }))).filter((/**
6977
- * @param {?} m
6978
- * @return {?}
6979
- */
6980
- function (m) { return !!m; })); // the activated route param map can be null
6981
- }
6982
- /**
6983
- * @param {?} name
6984
- * @return {?}
6985
- */
6986
- ConsolidatedParameterMap.prototype.get = /**
6987
- * @param {?} name
6988
- * @return {?}
6989
- */
6990
- function (name) {
6991
- /** @type {?} */
6992
- var paramMap = this.paramMaps.find((/**
6993
- * @param {?} m
6994
- * @return {?}
6995
- */
6996
- function (m) { return m.has(name); }));
6997
- return paramMap.get(name);
6998
- };
6999
- /**
7000
- * @param {?} name
7215
+ * @param {?} name
7001
7216
  * @return {?}
7002
7217
  */
7003
7218
  ConsolidatedParameterMap.prototype.getAll = /**
@@ -7120,15 +7335,151 @@ if (false) {
7120
7335
  * @fileoverview added by tsickle
7121
7336
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
7122
7337
  */
7338
+ var NoopAuthGuard = /** @class */ (function () {
7339
+ function NoopAuthGuard() {
7340
+ }
7341
+ /**
7342
+ * @param {?} activatedRoute
7343
+ * @param {?} state
7344
+ * @return {?}
7345
+ */
7346
+ NoopAuthGuard.prototype.canActivate = /**
7347
+ * @param {?} activatedRoute
7348
+ * @param {?} state
7349
+ * @return {?}
7350
+ */
7351
+ function (activatedRoute, state) {
7352
+ return __awaiter(this, void 0, void 0, function () {
7353
+ return __generator(this, function (_a) {
7354
+ return [2 /*return*/, true];
7355
+ });
7356
+ });
7357
+ };
7358
+ NoopAuthGuard.decorators = [
7359
+ { type: Injectable, args: [{
7360
+ providedIn: 'root'
7361
+ },] }
7362
+ ];
7363
+ /** @nocollapse */
7364
+ NoopAuthGuard.ctorParameters = function () { return []; };
7365
+ /** @nocollapse */ NoopAuthGuard.ngInjectableDef = ɵɵdefineInjectable({ factory: function NoopAuthGuard_Factory() { return new NoopAuthGuard(); }, token: NoopAuthGuard, providedIn: "root" });
7366
+ return NoopAuthGuard;
7367
+ }());
7368
+
7123
7369
  /**
7370
+ * @fileoverview added by tsickle
7371
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
7372
+ */
7373
+ var VisitSanitiser = /** @class */ (function () {
7374
+ function VisitSanitiser(activatedRoute, router, placeHistory, injector) {
7375
+ this.activatedRoute = activatedRoute;
7376
+ this.router = router;
7377
+ this.placeHistory = placeHistory;
7378
+ this.injector = injector;
7379
+ }
7380
+ // @Trace()
7381
+ // @Trace()
7382
+ /**
7383
+ * @param {?} visit
7384
+ * @return {?}
7385
+ */
7386
+ VisitSanitiser.prototype.sanitise =
7387
+ // @Trace()
7388
+ /**
7389
+ * @param {?} visit
7390
+ * @return {?}
7391
+ */
7392
+ function (visit) {
7393
+ return __awaiter(this, void 0, void 0, function () {
7394
+ var placeDef, routeIdDef, routeId, sanitisedValue, parameterDefs, sanitisedVisit, i, def, value, sanitisedValue;
7395
+ return __generator(this, function (_a) {
7396
+ switch (_a.label) {
7397
+ case 0:
7398
+ placeDef = visit.placeDefinition;
7399
+ if (!placeDef.hasRouteId()) return [3 /*break*/, 2];
7400
+ routeIdDef = placeDef.getRouteIdParameterDef();
7401
+ routeId = visit.getRouteId();
7402
+ return [4 /*yield*/, routeIdDef.sanitise(routeId, visit, this.placeHistory, this.injector)];
7403
+ case 1:
7404
+ sanitisedValue = _a.sent();
7405
+ // console.log({routeId, sanitisedValue});
7406
+ // ###------- EARLY EXIT --------###
7407
+ if (routeIdDef.hasChanged(routeId, sanitisedValue)) {
7408
+ // if the route id has changed we redirect immediately as other
7409
+ // parameter sanitisers might use it.
7410
+ return [2 /*return*/, visit.replace(routeIdDef, sanitisedValue)];
7411
+ }
7412
+ _a.label = 2;
7413
+ case 2:
7414
+ // if we didn't replace the routeId we continue the url present parameters.
7415
+ parameterDefs = placeDef.getVisitParameterDefs({
7416
+ includeRouteParameters: true,
7417
+ includeNonRouteParameters: true
7418
+ });
7419
+ sanitisedVisit = visit;
7420
+ i = 0;
7421
+ _a.label = 3;
7422
+ case 3:
7423
+ if (!(i < parameterDefs.length)) return [3 /*break*/, 6];
7424
+ def = parameterDefs[i];
7425
+ value = visit.getParameter(def.name);
7426
+ return [4 /*yield*/, def.sanitise(value, sanitisedVisit, this.placeHistory, this.injector)];
7427
+ case 4:
7428
+ sanitisedValue = _a.sent();
7429
+ if (def.hasChanged(value, sanitisedValue)) {
7430
+ sanitisedVisit = sanitisedVisit.replace(def, sanitisedValue);
7431
+ }
7432
+ _a.label = 5;
7433
+ case 5:
7434
+ i++;
7435
+ return [3 /*break*/, 3];
7436
+ case 6: return [2 /*return*/, sanitisedVisit.hasChangedFrom(visit) ? sanitisedVisit : visit];
7437
+ }
7438
+ });
7439
+ });
7440
+ };
7441
+ return VisitSanitiser;
7442
+ }());
7443
+ if (false) {
7444
+ /**
7445
+ * @type {?}
7446
+ * @private
7447
+ */
7448
+ VisitSanitiser.prototype.activatedRoute;
7449
+ /**
7450
+ * @type {?}
7451
+ * @private
7452
+ */
7453
+ VisitSanitiser.prototype.router;
7454
+ /**
7455
+ * @type {?}
7456
+ * @private
7457
+ */
7458
+ VisitSanitiser.prototype.placeHistory;
7459
+ /**
7460
+ * @type {?}
7461
+ * @private
7462
+ */
7463
+ VisitSanitiser.prototype.injector;
7464
+ }
7465
+
7466
+ /**
7467
+ * @fileoverview added by tsickle
7468
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
7469
+ */
7470
+ /**
7471
+ * @abstract
7472
+ */
7473
+ var /**
7124
7474
  * @abstract
7125
7475
  */
7126
- var AbstractPlaceGuard = /** @class */ (function () {
7127
- function AbstractPlaceGuard(router, urlSerializer, placeRouter, placeHistory, injector) {
7476
+ PlaceGuard = /** @class */ (function () {
7477
+ function PlaceGuard(router, urlSerializer, placeRouter, placeHistory, interactionService, injector) {
7128
7478
  this.router = router;
7129
7479
  this.urlSerializer = urlSerializer;
7130
7480
  this.placeRouter = placeRouter;
7131
7481
  this.placeHistory = placeHistory;
7482
+ this.interactionService = interactionService;
7132
7483
  this.injector = injector;
7133
7484
  }
7134
7485
  // @Trace()
@@ -7138,7 +7489,7 @@ var AbstractPlaceGuard = /** @class */ (function () {
7138
7489
  * @param {?} state
7139
7490
  * @return {?}
7140
7491
  */
7141
- AbstractPlaceGuard.prototype.canActivate =
7492
+ PlaceGuard.prototype.canActivate =
7142
7493
  // @Trace()
7143
7494
  /**
7144
7495
  * @param {?} activatedRoute
@@ -7149,44 +7500,59 @@ var AbstractPlaceGuard = /** @class */ (function () {
7149
7500
  return __awaiter(this, void 0, void 0, function () {
7150
7501
  var _this = this;
7151
7502
  return __generator(this, function (_a) {
7503
+ // TODO: this is ugly now that I'm return UrlSnapshots and not UrlTrees. It'd be better if the functions
7504
+ // weren't nested or if I implemented a handler chain.
7152
7505
  return [2 /*return*/, this.authorisePlaceThen(activatedRoute, state, (/**
7153
7506
  * @param {?} placeDefinition
7154
7507
  * @return {?}
7155
7508
  */
7156
7509
  function (placeDefinition) { return __awaiter(_this, void 0, void 0, function () {
7157
- var params, parsedParams, initialVisit, sanitiser, sanitisedVisit, commands;
7510
+ var result;
7511
+ var _this = this;
7158
7512
  return __generator(this, function (_a) {
7159
7513
  switch (_a.label) {
7160
- case 0:
7161
- // Parse our route params.
7162
- params = new ConsolidatedParameterMap(activatedRoute.paramMap, activatedRoute.url);
7163
- parsedParams = placeDefinition.parseRouteParams(params);
7164
- initialVisit = this.placeRouter.navigationState.getVisitFor(placeDefinition) || new Visit(placeDefinition, parsedParams);
7165
- sanitiser = new VisitSanitiser(activatedRoute, this.router, this.placeHistory, this.injector);
7166
- return [4 /*yield*/, sanitiser.sanitise(initialVisit.mergeRouteParameters(parsedParams))];
7514
+ case 0: return [4 /*yield*/, this.cleanInteractionState(activatedRoute, state, (/**
7515
+ * @return {?}
7516
+ */
7517
+ function () { return __awaiter(_this, void 0, void 0, function () {
7518
+ var params, parsedParams, initialVisit, sanitiser, sanitisedVisit, urlSnapshot;
7519
+ return __generator(this, function (_a) {
7520
+ switch (_a.label) {
7521
+ case 0:
7522
+ // Parse our route params.
7523
+ params = new ConsolidatedParameterMap(activatedRoute.paramMap, activatedRoute.url);
7524
+ parsedParams = placeDefinition.parseRouteParams(params);
7525
+ initialVisit = this.placeRouter.navigationState.getVisitFor(placeDefinition) || new Visit(placeDefinition, parsedParams);
7526
+ sanitiser = new VisitSanitiser(activatedRoute, this.router, this.placeHistory, this.injector);
7527
+ return [4 /*yield*/, sanitiser.sanitise(initialVisit.mergeRouteParameters(parsedParams))];
7528
+ case 1:
7529
+ sanitisedVisit = _a.sent();
7530
+ // Save the visit with any updated parameters. We need to save it so we remember any non route parameters
7531
+ this.placeRouter.navigationState.storeVisit(sanitisedVisit);
7532
+ if (initialVisit.hasRoutingChangedFrom(sanitisedVisit)) {
7533
+ // Regenerate the url
7534
+ urlSnapshot = this.placeRouter.parseUrl(state.url).updateVisitSegments(sanitisedVisit);
7535
+ console.log('##### Place Guard Redirect', urlSnapshot);
7536
+ return [2 /*return*/, urlSnapshot];
7537
+ }
7538
+ else {
7539
+ return [2 /*return*/, true];
7540
+ }
7541
+ return [2 /*return*/];
7542
+ }
7543
+ });
7544
+ }); }))];
7167
7545
  case 1:
7168
- sanitisedVisit = _a.sent();
7169
- // Save the visit with any updated parameters. We need to save it so we remember any non route parameters
7170
- this.placeRouter.navigationState.storeVisit(sanitisedVisit);
7171
- if (initialVisit.hasRoutingChangedFrom(sanitisedVisit)) {
7172
- // Regenerate the url
7173
- commands = this.placeRouter.parseUrl(state.url).createRedirectCommandsFor(sanitisedVisit);
7174
- console.log('##### Place Guard Redirect', commands);
7175
- return [2 /*return*/, this.router.createUrlTree(commands, {
7176
- replaceUrl: true,
7177
- skipLocationChange: false
7178
- })];
7179
- }
7180
- else {
7181
- return [2 /*return*/, true];
7182
- }
7183
- return [2 /*return*/];
7546
+ result = _a.sent();
7547
+ return [2 /*return*/, this.handleGuardResult(result)];
7184
7548
  }
7185
7549
  });
7186
7550
  }); }))];
7187
7551
  });
7188
7552
  });
7189
7553
  };
7554
+ // @Trace()
7555
+ // @Trace()
7190
7556
  /**
7191
7557
  * @param {?} component
7192
7558
  * @param {?} currentRoute
@@ -7194,7 +7560,9 @@ var AbstractPlaceGuard = /** @class */ (function () {
7194
7560
  * @param {?=} nextState
7195
7561
  * @return {?}
7196
7562
  */
7197
- AbstractPlaceGuard.prototype.canDeactivate = /**
7563
+ PlaceGuard.prototype.canDeactivate =
7564
+ // @Trace()
7565
+ /**
7198
7566
  * @param {?} component
7199
7567
  * @param {?} currentRoute
7200
7568
  * @param {?} currentState
@@ -7203,11 +7571,38 @@ var AbstractPlaceGuard = /** @class */ (function () {
7203
7571
  */
7204
7572
  function (component, currentRoute, currentState, nextState) {
7205
7573
  return __awaiter(this, void 0, void 0, function () {
7574
+ var currentUrl, nextUrl, result;
7206
7575
  return __generator(this, function (_a) {
7207
- return [2 /*return*/, this.placeRouter.navigationState.canDeactivatePlace(component, this.placeRouter.parseUrl(nextState.url))];
7576
+ switch (_a.label) {
7577
+ case 0:
7578
+ currentUrl = this.placeRouter.parseUrl(currentState.url);
7579
+ nextUrl = this.placeRouter.parseUrl(nextState.url);
7580
+ return [4 /*yield*/, this.placeRouter.navigationState.canDeactivatePlace(component, currentUrl, nextUrl)];
7581
+ case 1:
7582
+ result = _a.sent();
7583
+ return [2 /*return*/, this.handleGuardResult(result)];
7584
+ }
7208
7585
  });
7209
7586
  });
7210
7587
  };
7588
+ /**
7589
+ * @private
7590
+ * @param {?} result
7591
+ * @return {?}
7592
+ */
7593
+ PlaceGuard.prototype.handleGuardResult = /**
7594
+ * @private
7595
+ * @param {?} result
7596
+ * @return {?}
7597
+ */
7598
+ function (result) {
7599
+ if (result instanceof UrlSnapshot) {
7600
+ return result.urlTree;
7601
+ }
7602
+ else {
7603
+ return result;
7604
+ }
7605
+ };
7211
7606
  // @Trace()
7212
7607
  // @Trace()
7213
7608
  /**
@@ -7217,7 +7612,7 @@ var AbstractPlaceGuard = /** @class */ (function () {
7217
7612
  * @param {?} runPlaceGuards
7218
7613
  * @return {?}
7219
7614
  */
7220
- AbstractPlaceGuard.prototype.authorisePlaceThen =
7615
+ PlaceGuard.prototype.authorisePlaceThen =
7221
7616
  // @Trace()
7222
7617
  /**
7223
7618
  * @protected
@@ -7259,12 +7654,16 @@ var AbstractPlaceGuard = /** @class */ (function () {
7259
7654
  });
7260
7655
  });
7261
7656
  };
7657
+ // @Trace()
7658
+ // @Trace()
7262
7659
  /**
7263
7660
  * @param {?} activatedRoute
7264
7661
  * @param {?} state
7265
7662
  * @return {?}
7266
7663
  */
7267
- AbstractPlaceGuard.prototype.isAuthorised = /**
7664
+ PlaceGuard.prototype.isAuthorised =
7665
+ // @Trace()
7666
+ /**
7268
7667
  * @param {?} activatedRoute
7269
7668
  * @param {?} state
7270
7669
  * @return {?}
@@ -7278,201 +7677,79 @@ var AbstractPlaceGuard = /** @class */ (function () {
7278
7677
  });
7279
7678
  });
7280
7679
  };
7281
- __decorate([
7282
- Trace(),
7283
- __metadata("design:type", Function),
7284
- __metadata("design:paramtypes", [ActivatedRouteSnapshot, RouterStateSnapshot]),
7285
- __metadata("design:returntype", Promise)
7286
- ], AbstractPlaceGuard.prototype, "isAuthorised", null);
7287
- return AbstractPlaceGuard;
7288
- }());
7289
- if (false) {
7290
- /**
7291
- * @type {?}
7292
- * @private
7293
- */
7294
- AbstractPlaceGuard.prototype.router;
7295
- /**
7296
- * @type {?}
7297
- * @private
7298
- */
7299
- AbstractPlaceGuard.prototype.urlSerializer;
7300
- /**
7301
- * @type {?}
7302
- * @private
7303
- */
7304
- AbstractPlaceGuard.prototype.placeRouter;
7305
- /**
7306
- * @type {?}
7307
- * @private
7308
- */
7309
- AbstractPlaceGuard.prototype.placeHistory;
7310
- /**
7311
- * @type {?}
7312
- * @private
7313
- */
7314
- AbstractPlaceGuard.prototype.injector;
7315
- /**
7316
- * @abstract
7317
- * @param {?} injector
7318
- * @return {?}
7319
- */
7320
- AbstractPlaceGuard.prototype.getAuthGuard = function (injector) { };
7321
- }
7322
-
7323
- /**
7324
- * @fileoverview added by tsickle
7325
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
7326
- */
7327
- var InteractionGuard = /** @class */ (function () {
7328
- function InteractionGuard(router, injector, placeRouter, angularLocation, interactionService) {
7329
- this.router = router;
7330
- this.injector = injector;
7331
- this.placeRouter = placeRouter;
7332
- this.angularLocation = angularLocation;
7333
- this.interactionService = interactionService;
7334
- }
7680
+ // @Trace()
7681
+ // @Trace()
7335
7682
  /**
7336
7683
  * @param {?} route
7337
7684
  * @param {?} state
7685
+ * @param {?} then
7338
7686
  * @return {?}
7339
7687
  */
7340
- InteractionGuard.prototype.canActivate = /**
7688
+ PlaceGuard.prototype.cleanInteractionState =
7689
+ // @Trace()
7690
+ /**
7341
7691
  * @param {?} route
7342
7692
  * @param {?} state
7693
+ * @param {?} then
7343
7694
  * @return {?}
7344
7695
  */
7345
- function (route, state) {
7346
- /** @type {?} */
7347
- var url = this.router.parseUrl(state.url);
7348
- if (!this.interactionService.isActive() && url.root.children[UrlSnapshot.INTERACTION_ROUTER_OUTLET]) {
7349
- // This happens if we reload the page or the url was pasted as the route should only be activated
7350
- // after the interaction context has become active.
7351
- delete url.root.children[UrlSnapshot.INTERACTION_ROUTER_OUTLET];
7352
- return url;
7353
- }
7354
- else {
7355
- return true;
7356
- }
7357
- };
7358
- /**
7359
- * @param {?} component
7360
- * @param {?} currentRoute
7361
- * @param {?} currentState
7362
- * @param {?=} nextState
7363
- * @return {?}
7364
- */
7365
- InteractionGuard.prototype.canDeactivate = /**
7366
- * @param {?} component
7367
- * @param {?} currentRoute
7368
- * @param {?} currentState
7369
- * @param {?=} nextState
7370
- * @return {?}
7371
- */
7372
- function (component, currentRoute, currentState, nextState) {
7696
+ function (route, state, then) {
7373
7697
  return __awaiter(this, void 0, void 0, function () {
7374
- var currentIds, routeIds, activity;
7698
+ var url;
7375
7699
  return __generator(this, function (_a) {
7376
- switch (_a.label) {
7377
- case 0:
7378
- if (!this.interactionService.isActive()) return [3 /*break*/, 2];
7379
- currentIds = this.interactionService.activeInteractionContextIds.value;
7380
- routeIds = this.placeRouter.getActiveInteractionIdsFromUrl(nextState.url);
7381
- if (!!isEqual(currentIds, routeIds)) return [3 /*break*/, 2];
7382
- // The activity is still active so the route change was triggered by the back button.
7383
- return [4 /*yield*/, this.interactionService.getCurrentActivity()];
7384
- case 1:
7385
- activity = _a.sent();
7386
- activity.cancel();
7387
- _a.label = 2;
7388
- case 2:
7389
- // IMPORTANT:
7390
- // We always return true, the router state engine will redirect as required. Return false
7391
- // during the guard causes all kinds of grief. It might be worth trying a redirect here
7392
- // again now that our state engine is more thorough.
7393
- return [2 /*return*/, true];
7700
+ url = this.placeRouter.parseUrl(state.url);
7701
+ if (!this.interactionService.isActive() && url.hasInteractionIds()) {
7702
+ // This happens if we reload the page or the url was pasted as the route should only be activated
7703
+ // after the interaction context has become active.
7704
+ return [2 /*return*/, url.removeInteractionIds()];
7394
7705
  }
7706
+ else {
7707
+ return [2 /*return*/, then()];
7708
+ }
7709
+ return [2 /*return*/];
7395
7710
  });
7396
7711
  });
7397
7712
  };
7398
- InteractionGuard.decorators = [
7399
- { type: Injectable, args: [{
7400
- providedIn: 'root'
7401
- },] }
7402
- ];
7403
- /** @nocollapse */
7404
- InteractionGuard.ctorParameters = function () { return [
7405
- { type: Router },
7406
- { type: Injector },
7407
- { type: PlaceRouter },
7408
- { type: Location },
7409
- { type: InteractionService }
7410
- ]; };
7411
- /** @nocollapse */ InteractionGuard.ngInjectableDef = ɵɵdefineInjectable({ factory: function InteractionGuard_Factory() { return new InteractionGuard(ɵɵinject(Router), ɵɵinject(INJECTOR), ɵɵinject(PlaceRouter), ɵɵinject(Location), ɵɵinject(InteractionService)); }, token: InteractionGuard, providedIn: "root" });
7412
- return InteractionGuard;
7713
+ return PlaceGuard;
7413
7714
  }());
7414
7715
  if (false) {
7415
7716
  /**
7416
7717
  * @type {?}
7417
7718
  * @private
7418
7719
  */
7419
- InteractionGuard.prototype.router;
7720
+ PlaceGuard.prototype.router;
7420
7721
  /**
7421
7722
  * @type {?}
7422
7723
  * @private
7423
7724
  */
7424
- InteractionGuard.prototype.injector;
7725
+ PlaceGuard.prototype.urlSerializer;
7425
7726
  /**
7426
7727
  * @type {?}
7427
7728
  * @private
7428
7729
  */
7429
- InteractionGuard.prototype.placeRouter;
7730
+ PlaceGuard.prototype.placeRouter;
7430
7731
  /**
7431
7732
  * @type {?}
7432
7733
  * @private
7433
7734
  */
7434
- InteractionGuard.prototype.angularLocation;
7735
+ PlaceGuard.prototype.placeHistory;
7435
7736
  /**
7436
7737
  * @type {?}
7437
7738
  * @private
7438
7739
  */
7439
- InteractionGuard.prototype.interactionService;
7440
- }
7441
-
7442
- /**
7443
- * @fileoverview added by tsickle
7444
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
7445
- */
7446
- var NoopAuthGuard = /** @class */ (function () {
7447
- function NoopAuthGuard() {
7448
- }
7740
+ PlaceGuard.prototype.interactionService;
7449
7741
  /**
7450
- * @param {?} activatedRoute
7451
- * @param {?} state
7452
- * @return {?}
7742
+ * @type {?}
7743
+ * @private
7453
7744
  */
7454
- NoopAuthGuard.prototype.canActivate = /**
7455
- * @param {?} activatedRoute
7456
- * @param {?} state
7745
+ PlaceGuard.prototype.injector;
7746
+ /**
7747
+ * @abstract
7748
+ * @param {?} injector
7457
7749
  * @return {?}
7458
7750
  */
7459
- function (activatedRoute, state) {
7460
- return __awaiter(this, void 0, void 0, function () {
7461
- return __generator(this, function (_a) {
7462
- return [2 /*return*/, true];
7463
- });
7464
- });
7465
- };
7466
- NoopAuthGuard.decorators = [
7467
- { type: Injectable, args: [{
7468
- providedIn: 'root'
7469
- },] }
7470
- ];
7471
- /** @nocollapse */
7472
- NoopAuthGuard.ctorParameters = function () { return []; };
7473
- /** @nocollapse */ NoopAuthGuard.ngInjectableDef = ɵɵdefineInjectable({ factory: function NoopAuthGuard_Factory() { return new NoopAuthGuard(); }, token: NoopAuthGuard, providedIn: "root" });
7474
- return NoopAuthGuard;
7475
- }());
7751
+ PlaceGuard.prototype.getAuthGuard = function (injector) { };
7752
+ }
7476
7753
 
7477
7754
  /**
7478
7755
  * @fileoverview added by tsickle
@@ -7754,5 +8031,5 @@ if (false) {
7754
8031
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
7755
8032
  */
7756
8033
 
7757
- export { ACTIVITY_DATA, AUP_PLACE_CONFIG, AbstractActivity, AbstractInputComponent, AbstractPlaceGuard, AbstractPlaceNavigationComponent, Activity, ActivityContainerComponent, ActivityOutletComponent, AlertDialogComponent, AngularUiPowerupsModule, Bounds, BusyOverlayComponent, CommandDirective, ComponentsModule, ConfirmThenDialogComponent, ConfirmationDialogComponent, ConsolidatedParameterMap, DEFINITION_META_DATA_KEY, DIALOG_INTERACTION_SERVICE_DEFAULTS, DialogInteractionContext, DialogInteractionContextFactory, Dimension, DirectivesModule, DisposableComponent, EmptyStateComponent, FocusBindingDirective, Formatter, InplaceInteractionContextComponent, InteractionContext, InteractionContextBase, InteractionGuard, InteractionModule, InteractionOutletComponent, InteractionService, LEFT_RIGHT_PLACE_ANIMATION, ListPlaceNavComponent, ModalInteractionContextFactory, NavigationState, NoopAuthGuard, NoopComponent, NumberInputComponent, ParameterDefinition, PasswordInputComponent, Place, PlaceComponent, PlaceComponentDeactivationHandler, PlaceDefinition, PlaceHistory, PlaceModule, PlaceOutletComponent, PlaceRouter, Point, ROUTE_PARAMETER_LIST_KEY, ResizeAwareComponent, RouteId, SelectInputComponent, StringInputComponent, TabbedPlaceNavigationComponent, UrlSnapshot, Visit, VisitParameter, VisitParameterList, VisitSanitiser, leftRightPlaceAnimation, slideDownAndUpAnimation, DirectivesModule as ɵa, CommandDirective as ɵb, InteractionModule as ɵba, ActivityContainerComponent as ɵbb, InteractionContextBase as ɵbc, InteractionContext as ɵbd, ActivityOutletComponent as ɵbe, ConfirmationDialogComponent as ɵbf, AbstractActivity as ɵbg, ACTIVITY_DATA as ɵbh, Activity as ɵbi, ConfirmThenDialogComponent as ɵbk, AlertDialogComponent as ɵbl, InteractionOutletComponent as ɵbn, InplaceInteractionContextComponent as ɵbo, FocusBindingDirective as ɵc, DisposableComponent as ɵd, ComponentsModule as ɵe, NumberInputComponent as ɵf, AbstractInputComponent as ɵg, StringInputComponent as ɵh, PasswordInputComponent as ɵi, SelectInputComponent as ɵj, NoopComponent as ɵk, PlaceModule as ɵl, EmptyStateComponent as ɵm, BusyOverlayComponent as ɵn, PlaceOutletComponent as ɵo, leftRightPlaceAnimation as ɵp, LEFT_RIGHT_PLACE_ANIMATION as ɵq, AUP_PLACE_CONFIG as ɵr, PlaceRouter as ɵt, PlaceHistory as ɵu, InteractionService as ɵv, ModalInteractionContextFactory as ɵw, TabbedPlaceNavigationComponent as ɵx, AbstractPlaceNavigationComponent as ɵy, ListPlaceNavComponent as ɵz };
8034
+ export { ACTIVITY_DATA, AUP_PLACE_CONFIG, AbstractActivity, AbstractInputComponent, AbstractPlaceNavigationComponent, Activity, ActivityContainerComponent, ActivityOutletComponent, AlertDialogComponent, AngularUiPowerupsModule, Bounds, BusyOverlayComponent, CommandDirective, ComponentsModule, ConfirmThenDialogComponent, ConfirmationDialogComponent, ConsolidatedParameterMap, DEFINITION_META_DATA_KEY, DIALOG_INTERACTION_SERVICE_DEFAULTS, DialogInteractionContext, DialogInteractionContextFactory, Dimension, DirectivesModule, DisposableComponent, EmptyStateComponent, FocusBindingDirective, Formatter, InplaceInteractionContextComponent, InteractionContext, InteractionContextBase, InteractionModule, InteractionOutletComponent, InteractionService, LEFT_RIGHT_PLACE_ANIMATION, ListPlaceNavComponent, ModalInteractionContextFactory, NavigationState, NoopAuthGuard, NoopComponent, NumberInputComponent, ParameterDefinition, PasswordInputComponent, Place, PlaceComponent, PlaceComponentDeactivationHandler, PlaceDefinition, PlaceGuard, PlaceHistory, PlaceModule, PlaceOutletComponent, PlaceRouter, Point, ROUTE_PARAMETER_LIST_KEY, ResizeAwareComponent, RouteId, SelectInputComponent, StringInputComponent, TabbedPlaceNavigationComponent, UrlSnapshot, Visit, VisitParameter, VisitParameterList, VisitSanitiser, leftRightPlaceAnimation, slideDownAndUpAnimation, DirectivesModule as ɵa, CommandDirective as ɵb, InteractionModule as ɵba, ActivityContainerComponent as ɵbb, InteractionContextBase as ɵbc, InteractionContext as ɵbd, ActivityOutletComponent as ɵbe, ConfirmationDialogComponent as ɵbf, AbstractActivity as ɵbg, ACTIVITY_DATA as ɵbh, Activity as ɵbi, ConfirmThenDialogComponent as ɵbk, AlertDialogComponent as ɵbl, InteractionOutletComponent as ɵbn, InplaceInteractionContextComponent as ɵbo, FocusBindingDirective as ɵc, DisposableComponent as ɵd, ComponentsModule as ɵe, NumberInputComponent as ɵf, AbstractInputComponent as ɵg, StringInputComponent as ɵh, PasswordInputComponent as ɵi, SelectInputComponent as ɵj, NoopComponent as ɵk, PlaceModule as ɵl, EmptyStateComponent as ɵm, BusyOverlayComponent as ɵn, PlaceOutletComponent as ɵo, leftRightPlaceAnimation as ɵp, LEFT_RIGHT_PLACE_ANIMATION as ɵq, AUP_PLACE_CONFIG as ɵr, PlaceRouter as ɵt, PlaceHistory as ɵu, InteractionService as ɵv, ModalInteractionContextFactory as ɵw, TabbedPlaceNavigationComponent as ɵx, AbstractPlaceNavigationComponent as ɵy, ListPlaceNavComponent as ɵz };
7758
8035
  //# sourceMappingURL=coolon-angular-ui-powerups.js.map