@coolon/angular-ui-powerups 0.0.101 → 0.0.103

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 (64) hide show
  1. package/bundles/coolon-angular-ui-powerups.umd.js +885 -632
  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.d.ts +1 -2
  6. package/coolon-angular-ui-powerups.metadata.json +1 -1
  7. package/esm2015/coolon-angular-ui-powerups.js +3 -4
  8. package/esm2015/index.js +2 -2
  9. package/esm2015/lib/interaction/components/activity-container/activity-container.component.js +2 -1
  10. package/esm2015/lib/interaction/index.js +1 -2
  11. package/esm2015/lib/interaction/interaction-context-base.js +21 -8
  12. package/esm2015/lib/interaction/interaction-context.js +56 -3
  13. package/esm2015/lib/interaction/interaction.module.js +1 -4
  14. package/esm2015/lib/interaction/services/interaction.service.js +11 -7
  15. package/esm2015/lib/place/guards/navigation-state.js +216 -135
  16. package/esm2015/lib/place/guards/place-component-deactivation-handler.js +63 -28
  17. package/esm2015/lib/place/guards/place.guard.js +215 -0
  18. package/esm2015/lib/place/index.js +2 -3
  19. package/esm2015/lib/place/place-router.js +34 -36
  20. package/esm2015/lib/place/place.decorator.js +2 -2
  21. package/esm2015/lib/place/url-snapshot.js +69 -53
  22. package/esm2015/public_api.js +3 -3
  23. package/esm5/coolon-angular-ui-powerups.js +3 -4
  24. package/esm5/index.js +2 -2
  25. package/esm5/lib/interaction/components/activity-container/activity-container.component.js +2 -1
  26. package/esm5/lib/interaction/index.js +1 -2
  27. package/esm5/lib/interaction/interaction-context-base.js +25 -8
  28. package/esm5/lib/interaction/interaction-context.js +88 -10
  29. package/esm5/lib/interaction/interaction.module.js +1 -4
  30. package/esm5/lib/interaction/services/interaction.service.js +17 -8
  31. package/esm5/lib/place/guards/navigation-state.js +280 -162
  32. package/esm5/lib/place/guards/place-component-deactivation-handler.js +73 -27
  33. package/esm5/lib/place/guards/place.guard.js +300 -0
  34. package/esm5/lib/place/index.js +2 -3
  35. package/esm5/lib/place/place-router.js +52 -39
  36. package/esm5/lib/place/place.decorator.js +2 -2
  37. package/esm5/lib/place/url-snapshot.js +85 -58
  38. package/esm5/public_api.js +3 -3
  39. package/fesm2015/coolon-angular-ui-powerups.js +661 -539
  40. package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
  41. package/fesm5/coolon-angular-ui-powerups.js +884 -628
  42. package/fesm5/coolon-angular-ui-powerups.js.map +1 -1
  43. package/lib/interaction/index.d.ts +0 -1
  44. package/lib/interaction/interaction-context-base.d.ts +3 -1
  45. package/lib/interaction/interaction-context.d.ts +9 -2
  46. package/lib/interaction/services/interaction.service.d.ts +2 -2
  47. package/lib/place/guards/navigation-state.d.ts +44 -38
  48. package/lib/place/guards/place-component-deactivation-handler.d.ts +7 -4
  49. package/lib/place/guards/{abstract-place.guard.d.ts → place.guard.d.ts} +8 -3
  50. package/lib/place/index.d.ts +1 -2
  51. package/lib/place/place-router.d.ts +2 -0
  52. package/lib/place/url-snapshot.d.ts +14 -9
  53. package/package.json +1 -1
  54. package/schematics/place-routes/place-def.js +1 -0
  55. package/schematics/place-routes/place-def.js.map +1 -1
  56. package/schematics/place-routes/templates/place-routes.ts.template +10 -11
  57. package/esm2015/lib/interaction/components/interaction-outlet/interaction-outlet.component.js +0 -19
  58. package/esm2015/lib/place/guards/abstract-place.guard.js +0 -166
  59. package/esm2015/lib/place/guards/interaction.guard.js +0 -121
  60. package/esm5/lib/interaction/components/interaction-outlet/interaction-outlet.component.js +0 -21
  61. package/esm5/lib/place/guards/abstract-place.guard.js +0 -213
  62. package/esm5/lib/place/guards/interaction.guard.js +0 -133
  63. package/lib/interaction/components/interaction-outlet/interaction-outlet.component.d.ts +0 -3
  64. package/lib/place/guards/interaction.guard.d.ts +0 -17
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common'), require('@angular/core'), require('@angular/forms'), require('@angular/material'), require('@angular/material/tabs'), require('@angular/platform-browser/animations'), require('@coolon/pectin'), require('@angular/cdk/portal'), require('@angular/router'), require('lodash'), require('@coolon/typescript-utilities'), require('@angular/material/icon'), require('@angular/material/list'), require('@angular/material/tooltip'), require('@typescript-plus/fast-memoize-decorator/dist/src'), require('@typescript-plus/fast-memoize-decorator'), require('reflect-metadata'), require('@angular/animations'), require('resize-observer-polyfill'), require('@angular/material/dialog'), require('rxjs')) :
3
- typeof define === 'function' && define.amd ? define('@coolon/angular-ui-powerups', ['exports', '@angular/common', '@angular/core', '@angular/forms', '@angular/material', '@angular/material/tabs', '@angular/platform-browser/animations', '@coolon/pectin', '@angular/cdk/portal', '@angular/router', 'lodash', '@coolon/typescript-utilities', '@angular/material/icon', '@angular/material/list', '@angular/material/tooltip', '@typescript-plus/fast-memoize-decorator/dist/src', '@typescript-plus/fast-memoize-decorator', 'reflect-metadata', '@angular/animations', 'resize-observer-polyfill', '@angular/material/dialog', 'rxjs'], factory) :
4
- (global = global || self, factory((global.coolon = global.coolon || {}, global.coolon['angular-ui-powerups'] = {}), global.ng.common, global.ng.core, global.ng.forms, global.ng.material, global.ng.material.tabs, global.ng.platformBrowser.animations, global.pectin, global.ng.cdk.portal, global.ng.router, global.___default, global.typescriptUtilities, global.ng.material.icon, global.ng.material.list, global.ng.material.tooltip, global.src, global.fastMemoizeDecorator, null, global.ng.animations, global.ResizeObserver, global.ng.material.dialog, global.rxjs));
5
- }(this, function (exports, common, core, forms, material, tabs, animations, pectin, portal, router, ___default, typescriptUtilities, icon, list, tooltip, src, fastMemoizeDecorator, reflectMetadata, animations$1, ResizeObserver, dialog, rxjs) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common'), require('@angular/core'), require('@angular/forms'), require('@angular/material'), require('@angular/material/tabs'), require('@angular/platform-browser/animations'), require('@coolon/pectin'), require('@angular/cdk/portal'), require('@angular/router'), require('@coolon/typescript-utilities'), require('@angular/material/icon'), require('@angular/material/list'), require('@angular/material/tooltip'), require('@typescript-plus/fast-memoize-decorator/dist/src'), require('@typescript-plus/fast-memoize-decorator'), require('reflect-metadata'), require('lodash'), require('@angular/animations'), require('resize-observer-polyfill'), require('@angular/material/dialog'), require('rxjs')) :
3
+ typeof define === 'function' && define.amd ? define('@coolon/angular-ui-powerups', ['exports', '@angular/common', '@angular/core', '@angular/forms', '@angular/material', '@angular/material/tabs', '@angular/platform-browser/animations', '@coolon/pectin', '@angular/cdk/portal', '@angular/router', '@coolon/typescript-utilities', '@angular/material/icon', '@angular/material/list', '@angular/material/tooltip', '@typescript-plus/fast-memoize-decorator/dist/src', '@typescript-plus/fast-memoize-decorator', 'reflect-metadata', 'lodash', '@angular/animations', 'resize-observer-polyfill', '@angular/material/dialog', 'rxjs'], factory) :
4
+ (global = global || self, factory((global.coolon = global.coolon || {}, global.coolon['angular-ui-powerups'] = {}), global.ng.common, global.ng.core, global.ng.forms, global.ng.material, global.ng.material.tabs, global.ng.platformBrowser.animations, global.pectin, global.ng.cdk.portal, global.ng.router, global.typescriptUtilities, global.ng.material.icon, global.ng.material.list, global.ng.material.tooltip, global.src, global.fastMemoizeDecorator, null, global.___default, global.ng.animations, global.ResizeObserver, global.ng.material.dialog, global.rxjs));
5
+ }(this, function (exports, common, core, forms, material, tabs, animations, pectin, portal, router, typescriptUtilities, icon, list, tooltip, src, fastMemoizeDecorator, reflectMetadata, ___default, animations$1, ResizeObserver, dialog, rxjs) { 'use strict';
6
6
 
7
7
  var ___default__default = 'default' in ___default ? ___default['default'] : ___default;
8
8
  ResizeObserver = ResizeObserver && ResizeObserver.hasOwnProperty('default') ? ResizeObserver['default'] : ResizeObserver;
@@ -1283,10 +1283,7 @@
1283
1283
  /**
1284
1284
  * @abstract
1285
1285
  */
1286
- var /**
1287
- * @abstract
1288
- */
1289
- InteractionContext = /** @class */ (function (_super) {
1286
+ var InteractionContext = /** @class */ (function (_super) {
1290
1287
  __extends(InteractionContext, _super);
1291
1288
  function InteractionContext() {
1292
1289
  return _super !== null && _super.apply(this, arguments) || this;
@@ -1317,17 +1314,101 @@
1317
1314
  pectin.assert.isFalsey(this.isActive());
1318
1315
  _super.prototype.dispose.call(this);
1319
1316
  };
1317
+ /**
1318
+ * Cancels the current activity and returns true the context is no longer active, false if
1319
+ * there is still another activity running.
1320
+ */
1321
+ /**
1322
+ * Cancels the current activity and returns true the context is no longer active, false if
1323
+ * there is still another activity running.
1324
+ * @return {?}
1325
+ */
1326
+ InteractionContext.prototype.cancelCurrentActivity = /**
1327
+ * Cancels the current activity and returns true the context is no longer active, false if
1328
+ * there is still another activity running.
1329
+ * @return {?}
1330
+ */
1331
+ function () {
1332
+ return __awaiter(this, void 0, void 0, function () {
1333
+ var when, activity;
1334
+ var _this = this;
1335
+ return __generator(this, function (_a) {
1336
+ switch (_a.label) {
1337
+ case 0:
1338
+ when = pectin.Dsl.disposeWith(this).when;
1339
+ return [4 /*yield*/, this.getCurrentActivity()];
1340
+ case 1:
1341
+ activity = _a.sent();
1342
+ return [2 /*return*/, new Promise((/**
1343
+ * @param {?} resolve
1344
+ * @return {?}
1345
+ */
1346
+ function (resolve) {
1347
+ when.valueOf(_this.activeActivity)
1348
+ .changes((/**
1349
+ * @param {?} nextActivity
1350
+ * @return {?}
1351
+ */
1352
+ function (nextActivity) {
1353
+ resolve(!nextActivity);
1354
+ }), { once: true });
1355
+ activity.cancel();
1356
+ }))];
1357
+ }
1358
+ });
1359
+ });
1360
+ };
1361
+ /**
1362
+ * @return {?}
1363
+ */
1364
+ InteractionContext.prototype.abort = /**
1365
+ * @return {?}
1366
+ */
1367
+ function () {
1368
+ return __awaiter(this, void 0, void 0, function () {
1369
+ var count;
1370
+ return __generator(this, function (_a) {
1371
+ switch (_a.label) {
1372
+ case 0:
1373
+ pectin.assert.isTruthy(this.isActive());
1374
+ count = 1;
1375
+ return [4 /*yield*/, this.cancelCurrentActivity()];
1376
+ case 1:
1377
+ _a.sent();
1378
+ console.log("aborted -> " + count++);
1379
+ _a.label = 2;
1380
+ case 2:
1381
+ if (!this.isActive()) return [3 /*break*/, 4];
1382
+ return [4 /*yield*/, this.cancelCurrentActivity()];
1383
+ case 3:
1384
+ _a.sent();
1385
+ console.log("aborted -> " + count++);
1386
+ return [3 /*break*/, 2];
1387
+ case 4: return [2 /*return*/];
1388
+ }
1389
+ });
1390
+ });
1391
+ };
1392
+ __decorate([
1393
+ pectin.Trace(),
1394
+ __metadata("design:type", Function),
1395
+ __metadata("design:paramtypes", []),
1396
+ __metadata("design:returntype", Promise)
1397
+ ], InteractionContext.prototype, "abort", null);
1320
1398
  return InteractionContext;
1321
1399
  }(pectin.GarbageCollector));
1322
1400
  if (false) {
1401
+ /** @type {?} */
1402
+ InteractionContext.prototype.active;
1323
1403
  /** @type {?} */
1324
1404
  InteractionContext.prototype.activityList;
1325
1405
  /** @type {?} */
1326
- InteractionContext.prototype.active;
1406
+ InteractionContext.prototype.activeActivity;
1327
1407
  /**
1328
1408
  * Returns the activity that is currently active.
1329
1409
  * This model is only updated in the next tick after the view has been updated.
1330
1410
  * @abstract
1411
+ * @protected
1331
1412
  * @return {?}
1332
1413
  */
1333
1414
  InteractionContext.prototype.getCurrentActivity = function () { };
@@ -1536,13 +1617,14 @@
1536
1617
  */
1537
1618
  _this._activityListDelegate = new pectin.DelegatingListModel();
1538
1619
  var _a = pectin.Dsl.disposeWith(_this), chain = _a.chain, valueOf = _a.valueOf, before = _a.before, when = _a.when, after = _a.after, observe = _a.observe, switchOn = _a.switchOn;
1539
- when.listOf(_this.activityList).becomesPopulated((/**
1540
- * @param {?} activities
1620
+ _this._currentActivity = chain(_this.activityList).last();
1621
+ when.valueOf(_this._currentActivity).becomesTruthy((/**
1622
+ * @param {?} activity
1541
1623
  * @return {?}
1542
1624
  */
1543
- function (activities) {
1625
+ function (activity) {
1544
1626
  if (_this.deferredGetCurrentActivity) {
1545
- _this.deferredGetCurrentActivity.resolve(___default.last(activities));
1627
+ _this.deferredGetCurrentActivity.resolve(activity);
1546
1628
  _this.deferredGetCurrentActivity = null;
1547
1629
  }
1548
1630
  }));
@@ -1571,6 +1653,16 @@
1571
1653
  enumerable: true,
1572
1654
  configurable: true
1573
1655
  });
1656
+ Object.defineProperty(InteractionContextBase.prototype, "activeActivity", {
1657
+ get: /**
1658
+ * @return {?}
1659
+ */
1660
+ function () {
1661
+ return this._currentActivity;
1662
+ },
1663
+ enumerable: true,
1664
+ configurable: true
1665
+ });
1574
1666
  /**
1575
1667
  * Returns the activity that is currently active.
1576
1668
  * This model is only updated in the next tick after the view has been updated.
@@ -1597,12 +1689,14 @@
1597
1689
  return [2 /*return*/, this.deferredGetCurrentActivity.promise];
1598
1690
  }
1599
1691
  else {
1600
- if (this.activityList.length < 1) {
1692
+ if (!this._currentActivity.value) {
1693
+ // we'be been asked before we've got any activities, create a deferred promise
1694
+ // that we resolve when the list populates.
1601
1695
  this.deferredGetCurrentActivity = pectin.Deferred.defer();
1602
1696
  return [2 /*return*/, this.deferredGetCurrentActivity.promise];
1603
1697
  }
1604
1698
  else {
1605
- return [2 /*return*/, ___default.last(this.activityList.value)];
1699
+ return [2 /*return*/, this._currentActivity.value];
1606
1700
  }
1607
1701
  }
1608
1702
  }
@@ -1704,6 +1798,11 @@
1704
1798
  * @private
1705
1799
  */
1706
1800
  InteractionContextBase.prototype.deferredGetCurrentActivity;
1801
+ /**
1802
+ * @type {?}
1803
+ * @private
1804
+ */
1805
+ InteractionContextBase.prototype._currentActivity;
1707
1806
  /**
1708
1807
  * @abstract
1709
1808
  * @protected
@@ -2130,6 +2229,7 @@
2130
2229
  * @return {?}
2131
2230
  */
2132
2231
  function () {
2232
+ this.updateActivityList();
2133
2233
  this._initialActivityOutletContext.value = null;
2134
2234
  this.initialActivityOutletContextEvent.emit(null);
2135
2235
  };
@@ -2365,6 +2465,15 @@
2365
2465
  function () {
2366
2466
  return this.active.value;
2367
2467
  };
2468
+ /**
2469
+ * @return {?}
2470
+ */
2471
+ InteractionService.prototype.isModalActive = /**
2472
+ * @return {?}
2473
+ */
2474
+ function () {
2475
+ return this.modelInteractionActive.value;
2476
+ };
2368
2477
  /**
2369
2478
  * @param {?} disposable
2370
2479
  * @return {?}
@@ -2390,19 +2499,19 @@
2390
2499
  function (interactionContext) {
2391
2500
  interactionContext.registerDisposable(new InteractionService.Monitor("ip" + ++inplaceMonitorCount, interactionContext, this._activeInlineInteractionContextModel, this.exclusiveContext));
2392
2501
  };
2502
+ // @Trace()
2503
+ // @Trace()
2393
2504
  /**
2394
2505
  * @return {?}
2395
2506
  */
2396
- InteractionService.prototype.getCurrentActivity = /**
2507
+ InteractionService.prototype.getActiveContext =
2508
+ // @Trace()
2509
+ /**
2397
2510
  * @return {?}
2398
2511
  */
2399
2512
  function () {
2400
- return __awaiter(this, void 0, void 0, function () {
2401
- return __generator(this, function (_a) {
2402
- typescriptUtilities.assert.isTruthy(this.isActive());
2403
- return [2 /*return*/, this._activeInteractionContext.value.getCurrentActivity()];
2404
- });
2405
- });
2513
+ typescriptUtilities.assert.isTruthy(this.isActive());
2514
+ return this._activeInteractionContext.value;
2406
2515
  };
2407
2516
  /**
2408
2517
  * Creates an interaction context that will prevent any other contexts from starting an
@@ -2704,25 +2813,6 @@
2704
2813
  InplaceInteractionContextComponent.prototype.interactionService;
2705
2814
  }
2706
2815
 
2707
- /**
2708
- * @fileoverview added by tsickle
2709
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2710
- */
2711
- var InteractionOutletComponent = /** @class */ (function () {
2712
- function InteractionOutletComponent() {
2713
- }
2714
- InteractionOutletComponent.decorators = [
2715
- { type: core.Component, args: [{
2716
- selector: 'aup-interaction-outlet',
2717
- template: "<router-outlet name=\"interaction-context\"></router-outlet>\n",
2718
- styles: [":host{display:block}"]
2719
- }] }
2720
- ];
2721
- /** @nocollapse */
2722
- InteractionOutletComponent.ctorParameters = function () { return []; };
2723
- return InteractionOutletComponent;
2724
- }());
2725
-
2726
2816
  /**
2727
2817
  * @fileoverview added by tsickle
2728
2818
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -2746,13 +2836,11 @@
2746
2836
  exports.ɵbk,
2747
2837
  AlertDialogComponent,
2748
2838
  ActivityOutletComponent,
2749
- InteractionOutletComponent,
2750
2839
  InplaceInteractionContextComponent
2751
2840
  ],
2752
2841
  exports: [
2753
2842
  ActivityContainerComponent,
2754
2843
  ActivityOutletComponent,
2755
- InteractionOutletComponent,
2756
2844
  InplaceInteractionContextComponent
2757
2845
  ],
2758
2846
  entryComponents: [
@@ -3735,67 +3823,110 @@
3735
3823
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3736
3824
  */
3737
3825
  var PlaceComponentDeactivationHandler = /** @class */ (function () {
3738
- function PlaceComponentDeactivationHandler(component, navigationSession) {
3826
+ function PlaceComponentDeactivationHandler(component, navigationState, isPrimaryComponent) {
3739
3827
  this.component = component;
3740
- this.navigationSession = navigationSession;
3828
+ this.navigationState = navigationState;
3829
+ this.isPrimaryComponent = isPrimaryComponent;
3741
3830
  }
3831
+ Object.defineProperty(PlaceComponentDeactivationHandler.prototype, "interactionService", {
3832
+ get: /**
3833
+ * @return {?}
3834
+ */
3835
+ function () {
3836
+ return this.navigationState.interactionService;
3837
+ },
3838
+ enumerable: true,
3839
+ configurable: true
3840
+ });
3841
+ Object.defineProperty(PlaceComponentDeactivationHandler.prototype, "placeRouter", {
3842
+ get: /**
3843
+ * @return {?}
3844
+ */
3845
+ function () {
3846
+ return this.navigationState.placeRouter;
3847
+ },
3848
+ enumerable: true,
3849
+ configurable: true
3850
+ });
3742
3851
  /**
3852
+ * @param {?} currentUrl
3743
3853
  * @param {?} nextState
3744
3854
  * @return {?}
3745
3855
  */
3746
3856
  PlaceComponentDeactivationHandler.prototype.canDeactivate = /**
3857
+ * @param {?} currentUrl
3747
3858
  * @param {?} nextState
3748
3859
  * @return {?}
3749
3860
  */
3750
- function (nextState) {
3861
+ function (currentUrl, nextState) {
3751
3862
  return __awaiter(this, void 0, void 0, function () {
3752
3863
  return __generator(this, function (_a) {
3753
3864
  // We'll get called multiple times if there's any parameter sanitisation so
3754
3865
  // we always return true if we accepted promise from a previous cycle of the current
3755
3866
  // navigation session.
3756
3867
  if (!this.canDeactivatePromise) {
3757
- this.canDeactivatePromise = this.canDeactivateComponent(nextState);
3868
+ console.log("creating deactivate promise for -> " + this.component.constructor.name);
3869
+ this.canDeactivatePromise = this.canDeactivateComponent(currentUrl, nextState);
3758
3870
  }
3759
3871
  return [2 /*return*/, this.canDeactivatePromise];
3760
3872
  });
3761
3873
  });
3762
3874
  };
3875
+ // @Trace()
3876
+ // @Trace()
3763
3877
  /**
3764
3878
  * @protected
3879
+ * @param {?} currentUrl
3765
3880
  * @param {?} nextState
3766
3881
  * @return {?}
3767
3882
  */
3768
- PlaceComponentDeactivationHandler.prototype.canDeactivateComponent = /**
3883
+ PlaceComponentDeactivationHandler.prototype.canDeactivateComponent =
3884
+ // @Trace()
3885
+ /**
3769
3886
  * @protected
3887
+ * @param {?} currentUrl
3770
3888
  * @param {?} nextState
3771
3889
  * @return {?}
3772
3890
  */
3773
- function (nextState) {
3891
+ function (currentUrl, nextState) {
3774
3892
  return __awaiter(this, void 0, void 0, function () {
3775
- var activity;
3893
+ var routeIds, currentIds;
3776
3894
  return __generator(this, function (_a) {
3777
3895
  switch (_a.label) {
3778
3896
  case 0:
3779
- if (!(this.navigationSession.isPopState && this.component.interactionContext && this.component.interactionContext.isActive())) return [3 /*break*/, 2];
3780
- // Note: Modal interactions are run in a different router outlet so we never get place deactivating while
3781
- // a model interaction is active. This is because:
3782
- // 1. the user can't click anything to navigate away
3783
- // 2. clicking the back button will only change the outlet route portion of the URL. This
3784
- // is all handled by the InteractionGuard and so the component guards will never run.
3785
- //
3786
- // Now we just cancel the current activity...
3787
- return [4 /*yield*/, this.component.interactionContext.getCurrentActivity()];
3897
+ console.log(this.navigationState.toString());
3898
+ if (!this.navigationState.isPopState) return [3 /*break*/, 5];
3899
+ if (!(this.isPrimaryComponent && this.interactionService.isModalActive())) return [3 /*break*/, 3];
3900
+ routeIds = this.placeRouter.getActiveInteractionIdsFromUrl(nextState.url);
3901
+ currentIds = this.interactionService.activeInteractionContextIds.value;
3902
+ if (!!___default.isEqual(currentIds, routeIds)) return [3 /*break*/, 2];
3903
+ return [4 /*yield*/, this.interactionService.getActiveContext().cancelCurrentActivity()];
3788
3904
  case 1:
3789
- activity = _a.sent();
3790
- activity.cancel(null);
3791
- return [2 /*return*/, false]; // ..and stay where we are.
3792
- case 2:
3905
+ _a.sent();
3906
+ return [2 /*return*/, currentUrl.updateInteractionIds(this.interactionService.activeInteractionContextIds.value)];
3907
+ case 2: return [3 /*break*/, 5];
3908
+ case 3:
3909
+ if (!(this.component.interactionContext && this.component.interactionContext.isActive())) return [3 /*break*/, 5];
3910
+ return [4 /*yield*/, this.component.interactionContext.cancelCurrentActivity()];
3911
+ case 4:
3912
+ _a.sent();
3913
+ return [2 /*return*/, currentUrl
3914
+ .updateInteractionIds(this.interactionService.activeInteractionContextIds.value)];
3915
+ case 5:
3793
3916
  // Ok, so now we're really leaving, so we ask the component if we should.;
3794
- if (this.isNotJustAChangeInRouteId(nextState) && this.component.canDeactivate) {
3795
- // No interaction in progress, so ask the component .
3796
- // This may start an interaction, hence checking the interaction context before now. I.e. if the place pops up the dialog, and
3797
- // the user clicks back again, we'll re-enter here and go bang when the component tries to open another dialog.
3798
- return [2 /*return*/, this.component.canDeactivate(this.navigationSession.interactionContext)];
3917
+ if (this.isNotJustAChangeInRouteId(nextState)) {
3918
+ if (this.component.canDeactivate) {
3919
+ // No interaction in progress, so ask the component .
3920
+ // This may start an interaction, hence checking the interaction context before now. I.e. if the place pops up the dialog, and
3921
+ // the user clicks back again, we'll re-enter here and go bang when the component tries to open another dialog.
3922
+ return [2 /*return*/, this.component.canDeactivate(this.navigationState.interactionContext)];
3923
+ }
3924
+ // The component has an active interaction but no deactivation hook. Rather than guessing what to do
3925
+ // we'll just cancel the navigation and print a warning.
3926
+ if (this.component.interactionContext && this.component.interactionContext.isActive()) {
3927
+ console.warn('Route changed while component has active interaction, cancelling navigation');
3928
+ return [2 /*return*/, false];
3929
+ }
3799
3930
  }
3800
3931
  return [2 /*return*/, true];
3801
3932
  }
@@ -3829,7 +3960,9 @@
3829
3960
  /** @type {?} */
3830
3961
  PlaceComponentDeactivationHandler.prototype.component;
3831
3962
  /** @type {?} */
3832
- PlaceComponentDeactivationHandler.prototype.navigationSession;
3963
+ PlaceComponentDeactivationHandler.prototype.navigationState;
3964
+ /** @type {?} */
3965
+ PlaceComponentDeactivationHandler.prototype.isPrimaryComponent;
3833
3966
  }
3834
3967
 
3835
3968
  /**
@@ -3850,6 +3983,16 @@
3850
3983
  _this._visits = new Map();
3851
3984
  return _this;
3852
3985
  }
3986
+ Object.defineProperty(NavigationState.prototype, "name", {
3987
+ get: /**
3988
+ * @return {?}
3989
+ */
3990
+ function () {
3991
+ return this.constructor.name;
3992
+ },
3993
+ enumerable: true,
3994
+ configurable: true
3995
+ });
3853
3996
  Object.defineProperty(NavigationState.prototype, "idle", {
3854
3997
  get: /**
3855
3998
  * @return {?}
@@ -3912,6 +4055,19 @@
3912
4055
  function (placeDef) {
3913
4056
  return this._visits.get(placeDef);
3914
4057
  };
4058
+ /**
4059
+ * @param {?} visit
4060
+ * @param {?} initialUrl
4061
+ * @return {?}
4062
+ */
4063
+ NavigationState.prototype.onPlaceNavigationStart = /**
4064
+ * @param {?} visit
4065
+ * @param {?} initialUrl
4066
+ * @return {?}
4067
+ */
4068
+ function (visit, initialUrl) {
4069
+ return this.illegalTransition('onPlaceNavigationStart');
4070
+ };
3915
4071
  /**
3916
4072
  * @param {?} event
3917
4073
  * @return {?}
@@ -3927,7 +4083,7 @@
3927
4083
  * @param {?} event
3928
4084
  * @return {?}
3929
4085
  */
3930
- NavigationState.prototype.onStart = /**
4086
+ NavigationState.prototype.onRouterStarted = /**
3931
4087
  * @param {?} event
3932
4088
  * @return {?}
3933
4089
  */
@@ -3938,7 +4094,7 @@
3938
4094
  * @param {?} event
3939
4095
  * @return {?}
3940
4096
  */
3941
- NavigationState.prototype.onCancel = /**
4097
+ NavigationState.prototype.onRouterCancelled = /**
3942
4098
  * @param {?} event
3943
4099
  * @return {?}
3944
4100
  */
@@ -3949,7 +4105,7 @@
3949
4105
  * @param {?} event
3950
4106
  * @return {?}
3951
4107
  */
3952
- NavigationState.prototype.onError = /**
4108
+ NavigationState.prototype.onRouterError = /**
3953
4109
  * @param {?} event
3954
4110
  * @return {?}
3955
4111
  */
@@ -3960,7 +4116,7 @@
3960
4116
  * @param {?} event
3961
4117
  * @return {?}
3962
4118
  */
3963
- NavigationState.prototype.onEnd = /**
4119
+ NavigationState.prototype.onRouterEnd = /**
3964
4120
  * @param {?} event
3965
4121
  * @return {?}
3966
4122
  */
@@ -3980,15 +4136,17 @@
3980
4136
  };
3981
4137
  /**
3982
4138
  * @param {?} component
3983
- * @param {?} nextState
4139
+ * @param {?} currentUrl
4140
+ * @param {?} nextUrl
3984
4141
  * @return {?}
3985
4142
  */
3986
4143
  NavigationState.prototype.canDeactivatePlace = /**
3987
4144
  * @param {?} component
3988
- * @param {?} nextState
4145
+ * @param {?} currentUrl
4146
+ * @param {?} nextUrl
3989
4147
  * @return {?}
3990
4148
  */
3991
- function (component, nextState) {
4149
+ function (component, currentUrl, nextUrl) {
3992
4150
  return __awaiter(this, void 0, void 0, function () {
3993
4151
  return __generator(this, function (_a) {
3994
4152
  return [2 /*return*/, this.illegalTransition('canDeactivatePlace')];
@@ -4041,12 +4199,29 @@
4041
4199
  * @return {?}
4042
4200
  */
4043
4201
  function (event) {
4044
- // TODO: check if the event is purely for interaction context changes.
4045
4202
  /** @type {?} */
4046
4203
  var popstate = event.navigationTrigger === 'popstate';
4047
4204
  return popstate ?
4048
- new NavigationState.NavigationBackTransition(this.context, popstate, this.currentRouterUrl()) :
4049
- new NavigationState.NavigationTransition(this.context, popstate, this.currentRouterUrl());
4205
+ this.interactionService.isActive() ?
4206
+ new NavigationState.InteractionPopStateTransition(this.context, this.currentRouterUrl()) :
4207
+ new NavigationState.PopStateTransition(this.context, this.currentRouterUrl())
4208
+ :
4209
+ this.interactionService.isActive() ?
4210
+ new NavigationState.InteractionTransition(this.context, this.currentRouterUrl()) :
4211
+ new NavigationState.NavigationTransition(this.context, this.currentRouterUrl());
4212
+ };
4213
+ /**
4214
+ * @protected
4215
+ * @return {?}
4216
+ */
4217
+ NavigationState.prototype.createIdleState = /**
4218
+ * @protected
4219
+ * @return {?}
4220
+ */
4221
+ function () {
4222
+ return this.interactionService.isActive() ?
4223
+ new NavigationState.IdleDuringInteraction(this.context, this.currentRouterUrl()) :
4224
+ new NavigationState.Idle(this.context);
4050
4225
  };
4051
4226
  /**
4052
4227
  * @param {?} url
@@ -4057,12 +4232,7 @@
4057
4232
  * @return {?}
4058
4233
  */
4059
4234
  function (url) {
4060
- var _this = this;
4061
- // TODO: Should this be a navigate operation to avoid confusing the router...??
4062
- setTimeout((/**
4063
- * @return {?}
4064
- */
4065
- function () { return _this.placeRouter.resetBrowserLocation(url); }));
4235
+ this.placeRouter.resetBrowserLocation(url);
4066
4236
  };
4067
4237
  /**
4068
4238
  * @return {?}
@@ -4120,11 +4290,27 @@
4120
4290
  _this.isPopState = false;
4121
4291
  return _this;
4122
4292
  }
4293
+ /**
4294
+ * @param {?} visit
4295
+ * @param {?} initialUrl
4296
+ * @return {?}
4297
+ */
4298
+ Idle.prototype.onPlaceNavigationStart = /**
4299
+ * @param {?} visit
4300
+ * @param {?} initialUrl
4301
+ * @return {?}
4302
+ */
4303
+ function (visit, initialUrl) {
4304
+ /** @type {?} */
4305
+ var navigationTransition = new NavigationTransition(this.context, initialUrl);
4306
+ navigationTransition.storeVisit(visit);
4307
+ return navigationTransition;
4308
+ };
4123
4309
  /**
4124
4310
  * @param {?} event
4125
4311
  * @return {?}
4126
4312
  */
4127
- Idle.prototype.onStart = /**
4313
+ Idle.prototype.onRouterStarted = /**
4128
4314
  * @param {?} event
4129
4315
  * @return {?}
4130
4316
  */
@@ -4172,9 +4358,8 @@
4172
4358
  */
4173
4359
  AbstractNavigationTransition = /** @class */ (function (_super) {
4174
4360
  __extends(AbstractNavigationTransition, _super);
4175
- function AbstractNavigationTransition(context, isPopState, startingUrl) {
4361
+ function AbstractNavigationTransition(context, startingUrl) {
4176
4362
  var _this = _super.call(this, context) || this;
4177
- _this.isPopState = isPopState;
4178
4363
  _this.startingUrl = startingUrl;
4179
4364
  _this.isTransitional = true;
4180
4365
  _this.componentDeactivationHandlers = new Map();
@@ -4207,7 +4392,7 @@
4207
4392
  * @param {?} event
4208
4393
  * @return {?}
4209
4394
  */
4210
- AbstractNavigationTransition.prototype.onStart = /**
4395
+ AbstractNavigationTransition.prototype.onRouterStarted = /**
4211
4396
  * @param {?} event
4212
4397
  * @return {?}
4213
4398
  */
@@ -4220,7 +4405,7 @@
4220
4405
  * @param {?} event
4221
4406
  * @return {?}
4222
4407
  */
4223
- AbstractNavigationTransition.prototype.onEnd = /**
4408
+ AbstractNavigationTransition.prototype.onRouterEnd = /**
4224
4409
  * @param {?} event
4225
4410
  * @return {?}
4226
4411
  */
@@ -4238,37 +4423,38 @@
4238
4423
  * @return {?}
4239
4424
  */
4240
4425
  function (locationTriggerUrl) {
4241
- // detach the interactoin from the session so it doesn't get disposed until the activity
4242
- // has completed.
4426
+ pectin.Logger.get(this).info("back button pressed during navigation session interaction promise");
4427
+ // detach the interaction from the session so it doesn't get disposed until the activity has completed.
4243
4428
  /** @type {?} */
4244
- var context = this.detachInteractionContext();
4245
- var when = pectin.Dsl.disposeWith(context).when;
4429
+ var navigationInteraction = this.detachInteractionContext();
4430
+ var when = pectin.Dsl.disposeWith(navigationInteraction).when;
4246
4431
  // TODO: I need to make the exclusive interaction context disallow nested activities or
4247
- // that would mess things up entirely.
4248
- context.getCurrentActivity().then((/**
4249
- * @param {?} activity
4432
+ // that would mess things up entirely. Or, can I do a context.abortAll().then(..)
4433
+ navigationInteraction.cancelCurrentActivity().then((/**
4250
4434
  * @return {?}
4251
4435
  */
4252
- function (activity) {
4253
- when.valueOf(context.active).becomesFalsey((/**
4254
- * @return {?}
4255
- */
4256
- function () { return context.dispose(); }), { once: true });
4257
- activity.cancel(null);
4436
+ function () {
4437
+ navigationInteraction.dispose();
4258
4438
  }));
4259
- return new CancelledDuringNavigationInteraction(this.context, this.startingUrl, locationTriggerUrl);
4439
+ return new CancelledDuringNavigationInteraction(this.context, this.startingUrl, this.isPopState, locationTriggerUrl);
4260
4440
  };
4441
+ // @Trace()
4442
+ // @Trace()
4261
4443
  /**
4262
4444
  * @param {?} component
4263
- * @param {?} nextState
4445
+ * @param {?} currentUrl
4446
+ * @param {?} nextUrl
4264
4447
  * @return {?}
4265
4448
  */
4266
- AbstractNavigationTransition.prototype.canDeactivatePlace = /**
4449
+ AbstractNavigationTransition.prototype.canDeactivatePlace =
4450
+ // @Trace()
4451
+ /**
4267
4452
  * @param {?} component
4268
- * @param {?} nextState
4453
+ * @param {?} currentUrl
4454
+ * @param {?} nextUrl
4269
4455
  * @return {?}
4270
4456
  */
4271
- function (component, nextState) {
4457
+ function (component, currentUrl, nextUrl) {
4272
4458
  return __awaiter(this, void 0, void 0, function () {
4273
4459
  var handler, isPrimaryHandler;
4274
4460
  return __generator(this, function (_a) {
@@ -4276,10 +4462,10 @@
4276
4462
  handler = this.componentDeactivationHandlers.get(component);
4277
4463
  if (!handler) {
4278
4464
  isPrimaryHandler = this.componentDeactivationHandlers.size === 0;
4279
- handler = new PlaceComponentDeactivationHandler(component, this);
4465
+ handler = new PlaceComponentDeactivationHandler(component, this, isPrimaryHandler);
4280
4466
  this.componentDeactivationHandlers.set(component, handler);
4281
4467
  }
4282
- return [2 /*return*/, handler.canDeactivate(nextState)];
4468
+ return [2 /*return*/, handler.canDeactivate(currentUrl, nextUrl)];
4283
4469
  });
4284
4470
  });
4285
4471
  };
@@ -4314,8 +4500,6 @@
4314
4500
  */
4315
4501
  AbstractNavigationTransition.prototype._interactionContext;
4316
4502
  /** @type {?} */
4317
- AbstractNavigationTransition.prototype.isPopState;
4318
- /** @type {?} */
4319
4503
  AbstractNavigationTransition.prototype.startingUrl;
4320
4504
  }
4321
4505
  var NavigationTransition = /** @class */ (function (_super) {
@@ -4329,44 +4513,18 @@
4329
4513
  * @param {?} event
4330
4514
  * @return {?}
4331
4515
  */
4332
- NavigationTransition.prototype.onStart = /**
4516
+ NavigationTransition.prototype.onRouterCancelled = /**
4333
4517
  * @param {?} event
4334
4518
  * @return {?}
4335
4519
  */
4336
4520
  function (event) {
4337
- // active sessions can have many cancel start cycles due
4338
- // to place guard redirects
4339
4521
  return this;
4340
4522
  };
4341
4523
  /**
4342
4524
  * @param {?} event
4343
4525
  * @return {?}
4344
4526
  */
4345
- NavigationTransition.prototype.onEnd = /**
4346
- * @param {?} event
4347
- * @return {?}
4348
- */
4349
- function (event) {
4350
- // navigation succeeded
4351
- this.context.notifySuccess(this);
4352
- return new Idle(this.context);
4353
- };
4354
- /**
4355
- * @param {?} event
4356
- * @return {?}
4357
- */
4358
- NavigationTransition.prototype.onCancel = /**
4359
- * @param {?} event
4360
- * @return {?}
4361
- */
4362
- function (event) {
4363
- return new Idle(this.context);
4364
- };
4365
- /**
4366
- * @param {?} event
4367
- * @return {?}
4368
- */
4369
- NavigationTransition.prototype.onError = /**
4527
+ NavigationTransition.prototype.onRouterError = /**
4370
4528
  * @param {?} event
4371
4529
  * @return {?}
4372
4530
  */
@@ -4390,9 +4548,9 @@
4390
4548
  /** @type {?} */
4391
4549
  NavigationTransition.prototype.isPopState;
4392
4550
  }
4393
- var NavigationBackTransition = /** @class */ (function (_super) {
4394
- __extends(NavigationBackTransition, _super);
4395
- function NavigationBackTransition() {
4551
+ var PopStateTransition = /** @class */ (function (_super) {
4552
+ __extends(PopStateTransition, _super);
4553
+ function PopStateTransition() {
4396
4554
  var _this = _super !== null && _super.apply(this, arguments) || this;
4397
4555
  _this.isPopState = true;
4398
4556
  return _this;
@@ -4401,7 +4559,7 @@
4401
4559
  * @param {?} event
4402
4560
  * @return {?}
4403
4561
  */
4404
- NavigationBackTransition.prototype.onCancel = /**
4562
+ PopStateTransition.prototype.onRouterCancelled = /**
4405
4563
  * @param {?} event
4406
4564
  * @return {?}
4407
4565
  */
@@ -4416,7 +4574,7 @@
4416
4574
  * @param {?} event
4417
4575
  * @return {?}
4418
4576
  */
4419
- NavigationBackTransition.prototype.onError = /**
4577
+ PopStateTransition.prototype.onRouterError = /**
4420
4578
  * @param {?} event
4421
4579
  * @return {?}
4422
4580
  */
@@ -4430,90 +4588,105 @@
4430
4588
  }
4431
4589
  return new Idle(this.context);
4432
4590
  };
4433
- return NavigationBackTransition;
4591
+ return PopStateTransition;
4434
4592
  }(AbstractNavigationTransition));
4435
- NavigationState.NavigationBackTransition = NavigationBackTransition;
4593
+ NavigationState.PopStateTransition = PopStateTransition;
4436
4594
  if (false) {
4437
4595
  /** @type {?} */
4438
- NavigationBackTransition.prototype.isPopState;
4596
+ PopStateTransition.prototype.isPopState;
4439
4597
  }
4440
- /**
4441
- * @abstract
4442
- */
4443
- var /**
4444
- * @abstract
4445
- */
4446
- AbstractInteractionTransition = /** @class */ (function (_super) {
4447
- __extends(AbstractInteractionTransition, _super);
4448
- function AbstractInteractionTransition(context, startingUrl) {
4598
+ var IdleDuringInteraction = /** @class */ (function (_super) {
4599
+ __extends(IdleDuringInteraction, _super);
4600
+ function IdleDuringInteraction(context, startingUrl) {
4449
4601
  var _this = _super.call(this, context) || this;
4450
4602
  _this.startingUrl = startingUrl;
4451
- _this.isTransitional = true;
4603
+ _this.isTransitional = false;
4604
+ _this.isPopState = false;
4452
4605
  return _this;
4453
4606
  }
4454
4607
  /**
4455
- * @protected
4608
+ * @param {?} visit
4609
+ * @param {?} initialUrl
4456
4610
  * @return {?}
4457
4611
  */
4458
- AbstractInteractionTransition.prototype.reinstateInteractionRoute = /**
4459
- * @protected
4612
+ IdleDuringInteraction.prototype.onPlaceNavigationStart = /**
4613
+ * @param {?} visit
4614
+ * @param {?} initialUrl
4460
4615
  * @return {?}
4461
4616
  */
4462
- function () {
4463
- var _this = this;
4464
- console.log(this.startingUrl);
4465
- setTimeout((/**
4466
- * @return {?}
4467
- */
4468
- function () { return _this.placeRouter.syncInteractionIdsWithRouter(); }));
4617
+ function (visit, initialUrl) {
4618
+ /** @type {?} */
4619
+ var navigationTransition = new InteractionTransition(this.context, initialUrl);
4620
+ navigationTransition.storeVisit(visit);
4621
+ return navigationTransition;
4469
4622
  };
4470
- return AbstractInteractionTransition;
4471
- }(NavigationState));
4472
- NavigationState.AbstractInteractionTransition = AbstractInteractionTransition;
4473
- if (false) {
4474
- /** @type {?} */
4475
- AbstractInteractionTransition.prototype.isTransitional;
4476
- /** @type {?} */
4477
- AbstractInteractionTransition.prototype.startingUrl;
4478
- }
4479
- /**
4480
- * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4481
- * happily ignore interaction contexts.
4482
- */
4483
- var /**
4484
- * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4485
- * happily ignore interaction contexts.
4486
- */
4487
- InteractionTransition = /** @class */ (function (_super) {
4488
- __extends(InteractionTransition, _super);
4489
- function InteractionTransition() {
4490
- var _this = _super !== null && _super.apply(this, arguments) || this;
4491
- _this.isPopState = false;
4492
- return _this;
4493
- }
4494
4623
  /**
4495
4624
  * @param {?} event
4496
4625
  * @return {?}
4497
4626
  */
4498
- InteractionTransition.prototype.onEnd = /**
4627
+ IdleDuringInteraction.prototype.onRouterStarted = /**
4499
4628
  * @param {?} event
4500
4629
  * @return {?}
4501
4630
  */
4502
4631
  function (event) {
4503
- if (this.context.interactionService.isActive()) {
4504
- this.reinstateInteractionRoute();
4505
- return new IdleDuringInteraction(this.context, this.startingUrl);
4506
- }
4507
- else {
4508
- return new Idle(this.context);
4509
- }
4632
+ return new InteractionTransition(this.context, event.url);
4510
4633
  };
4511
- return InteractionTransition;
4512
- }(AbstractInteractionTransition));
4513
- NavigationState.InteractionTransition = InteractionTransition;
4634
+ /**
4635
+ * @param {?} event
4636
+ * @return {?}
4637
+ */
4638
+ IdleDuringInteraction.prototype.onPopState = /**
4639
+ * @param {?} event
4640
+ * @return {?}
4641
+ */
4642
+ function (event) {
4643
+ return new InteractionPopStateTransition(this.context, event.url);
4644
+ };
4645
+ __decorate([
4646
+ pectin.Trace(),
4647
+ __metadata("design:type", Function),
4648
+ __metadata("design:paramtypes", [router.NavigationStart]),
4649
+ __metadata("design:returntype", NavigationState)
4650
+ ], IdleDuringInteraction.prototype, "onRouterStarted", null);
4651
+ __decorate([
4652
+ pectin.Trace(),
4653
+ __metadata("design:type", Function),
4654
+ __metadata("design:paramtypes", [router.NavigationStart]),
4655
+ __metadata("design:returntype", NavigationState)
4656
+ ], IdleDuringInteraction.prototype, "onPopState", null);
4657
+ return IdleDuringInteraction;
4658
+ }(NavigationState));
4659
+ NavigationState.IdleDuringInteraction = IdleDuringInteraction;
4514
4660
  if (false) {
4515
4661
  /** @type {?} */
4516
- InteractionTransition.prototype.isPopState;
4662
+ IdleDuringInteraction.prototype.isTransitional;
4663
+ /** @type {?} */
4664
+ IdleDuringInteraction.prototype.isPopState;
4665
+ /** @type {?} */
4666
+ IdleDuringInteraction.prototype.startingUrl;
4667
+ }
4668
+ /**
4669
+ * @abstract
4670
+ */
4671
+ var /**
4672
+ * @abstract
4673
+ */
4674
+ AbstractInteractionTransition = /** @class */ (function (_super) {
4675
+ __extends(AbstractInteractionTransition, _super);
4676
+ function AbstractInteractionTransition(context, startingUrl) {
4677
+ var _this = _super.call(this, context, startingUrl) || this;
4678
+ _this.startingUrl = startingUrl;
4679
+ _this.isTransitional = true;
4680
+ return _this;
4681
+ }
4682
+ return AbstractInteractionTransition;
4683
+ }(AbstractNavigationTransition));
4684
+ NavigationState.AbstractInteractionTransition = AbstractInteractionTransition;
4685
+ if (false) {
4686
+ /** @type {?} */
4687
+ AbstractInteractionTransition.prototype.isTransitional;
4688
+ /** @type {?} */
4689
+ AbstractInteractionTransition.prototype.startingUrl;
4517
4690
  }
4518
4691
  /**
4519
4692
  * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
@@ -4523,87 +4696,133 @@
4523
4696
  * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4524
4697
  * happily ignore interaction contexts.
4525
4698
  */
4526
- InteractionBackTransition = /** @class */ (function (_super) {
4527
- __extends(InteractionBackTransition, _super);
4528
- function InteractionBackTransition() {
4699
+ InteractionTransition = /** @class */ (function (_super) {
4700
+ __extends(InteractionTransition, _super);
4701
+ function InteractionTransition() {
4529
4702
  var _this = _super !== null && _super.apply(this, arguments) || this;
4530
- _this.isPopState = true;
4703
+ _this.isPopState = false;
4531
4704
  return _this;
4532
4705
  }
4533
4706
  /**
4534
4707
  * @param {?} event
4535
4708
  * @return {?}
4536
4709
  */
4537
- InteractionBackTransition.prototype.onEnd = /**
4710
+ InteractionTransition.prototype.onRouterCancelled = /**
4538
4711
  * @param {?} event
4539
4712
  * @return {?}
4540
4713
  */
4541
4714
  function (event) {
4542
- if (this.interactionService.isActive()) {
4543
- this.reinstateInteractionRoute();
4715
+ if (this.context.interactionService.isActive()) {
4716
+ /** @type {?} */
4717
+ var interactionIds = this.interactionService.activeInteractionContextIds.value;
4718
+ this.resetBrowserLocation(this.placeRouter.parseUrl(this.startingUrl).updateInteractionIds(interactionIds).url);
4719
+ return new IdleDuringInteraction(this.context, this.startingUrl);
4720
+ }
4721
+ else {
4722
+ return new Idle(this.context);
4723
+ }
4724
+ };
4725
+ /**
4726
+ * @param {?} event
4727
+ * @return {?}
4728
+ */
4729
+ InteractionTransition.prototype.onRouterError = /**
4730
+ * @param {?} event
4731
+ * @return {?}
4732
+ */
4733
+ function (event) {
4734
+ // navigation was aborted.
4735
+ return new IdleDuringInteraction(this.context, this.startingUrl);
4736
+ };
4737
+ /**
4738
+ * @param {?} event
4739
+ * @return {?}
4740
+ */
4741
+ InteractionTransition.prototype.onRouterEnd = /**
4742
+ * @param {?} event
4743
+ * @return {?}
4744
+ */
4745
+ function (event) {
4746
+ if (this.context.interactionService.isActive()) {
4544
4747
  return new IdleDuringInteraction(this.context, this.startingUrl);
4545
4748
  }
4546
4749
  else {
4547
4750
  return new Idle(this.context);
4548
4751
  }
4549
4752
  };
4550
- return InteractionBackTransition;
4753
+ return InteractionTransition;
4551
4754
  }(AbstractInteractionTransition));
4552
- NavigationState.InteractionBackTransition = InteractionBackTransition;
4755
+ NavigationState.InteractionTransition = InteractionTransition;
4553
4756
  if (false) {
4554
4757
  /** @type {?} */
4555
- InteractionBackTransition.prototype.isPopState;
4758
+ InteractionTransition.prototype.isPopState;
4556
4759
  }
4557
- var IdleDuringInteraction = /** @class */ (function (_super) {
4558
- __extends(IdleDuringInteraction, _super);
4559
- function IdleDuringInteraction(context, startingUrl) {
4560
- var _this = _super.call(this, context) || this;
4561
- _this.startingUrl = startingUrl;
4562
- _this.isTransitional = false;
4563
- _this.isPopState = false;
4760
+ /**
4761
+ * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4762
+ * happily ignore interaction contexts.
4763
+ */
4764
+ var /**
4765
+ * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4766
+ * happily ignore interaction contexts.
4767
+ */
4768
+ InteractionPopStateTransition = /** @class */ (function (_super) {
4769
+ __extends(InteractionPopStateTransition, _super);
4770
+ function InteractionPopStateTransition() {
4771
+ var _this = _super !== null && _super.apply(this, arguments) || this;
4772
+ _this.isPopState = true;
4564
4773
  return _this;
4565
4774
  }
4566
4775
  /**
4567
4776
  * @param {?} event
4568
4777
  * @return {?}
4569
4778
  */
4570
- IdleDuringInteraction.prototype.onStart = /**
4779
+ InteractionPopStateTransition.prototype.onRouterCancelled = /**
4571
4780
  * @param {?} event
4572
4781
  * @return {?}
4573
4782
  */
4574
4783
  function (event) {
4575
- return new InteractionTransition(this.context, event.url);
4784
+ if (this.interactionService.isActive()) {
4785
+ /** @type {?} */
4786
+ var interactionIds = this.interactionService.activeInteractionContextIds.value;
4787
+ this.resetBrowserLocation(this.placeRouter.parseUrl(this.startingUrl).updateInteractionIds(interactionIds).url);
4788
+ return new IdleDuringInteraction(this.context, this.startingUrl);
4789
+ }
4790
+ else {
4791
+ return new Idle(this.context);
4792
+ }
4576
4793
  };
4577
4794
  /**
4578
4795
  * @param {?} event
4579
4796
  * @return {?}
4580
4797
  */
4581
- IdleDuringInteraction.prototype.onPopState = /**
4798
+ InteractionPopStateTransition.prototype.onRouterEnd = /**
4582
4799
  * @param {?} event
4583
4800
  * @return {?}
4584
4801
  */
4585
4802
  function (event) {
4586
- return new InteractionBackTransition(this.context, event.url);
4803
+ if (this.context.interactionService.isActive()) {
4804
+ return new IdleDuringInteraction(this.context, this.startingUrl);
4805
+ }
4806
+ else {
4807
+ return new Idle(this.context);
4808
+ }
4587
4809
  };
4588
- return IdleDuringInteraction;
4589
- }(NavigationState));
4590
- NavigationState.IdleDuringInteraction = IdleDuringInteraction;
4810
+ return InteractionPopStateTransition;
4811
+ }(AbstractInteractionTransition));
4812
+ NavigationState.InteractionPopStateTransition = InteractionPopStateTransition;
4591
4813
  if (false) {
4592
4814
  /** @type {?} */
4593
- IdleDuringInteraction.prototype.isTransitional;
4594
- /** @type {?} */
4595
- IdleDuringInteraction.prototype.isPopState;
4596
- /** @type {?} */
4597
- IdleDuringInteraction.prototype.startingUrl;
4815
+ InteractionPopStateTransition.prototype.isPopState;
4598
4816
  }
4599
4817
  var CancelledDuringNavigationInteraction = /** @class */ (function (_super) {
4600
4818
  __extends(CancelledDuringNavigationInteraction, _super);
4601
- function CancelledDuringNavigationInteraction(context, startingUrl, locationChangeTriggerUrl) {
4819
+ function CancelledDuringNavigationInteraction(context, startingUrl, startingEventWasAPopState, locationChangeTriggerUrl) {
4602
4820
  var _this = _super.call(this, context) || this;
4603
4821
  _this.startingUrl = startingUrl;
4822
+ _this.startingEventWasAPopState = startingEventWasAPopState;
4604
4823
  _this.locationChangeTriggerUrl = locationChangeTriggerUrl;
4605
4824
  _this.isPopState = false;
4606
- _this.capturedFauxRouterStart = false;
4825
+ _this.gotPopStateWithLeavingUrl = false;
4607
4826
  return _this;
4608
4827
  }
4609
4828
  Object.defineProperty(CancelledDuringNavigationInteraction.prototype, "isTransitional", {
@@ -4611,7 +4830,7 @@
4611
4830
  * @return {?}
4612
4831
  */
4613
4832
  function () {
4614
- return !this.capturedFauxRouterStart;
4833
+ return true;
4615
4834
  },
4616
4835
  enumerable: true,
4617
4836
  configurable: true
@@ -4620,35 +4839,34 @@
4620
4839
  * @param {?} event
4621
4840
  * @return {?}
4622
4841
  */
4623
- CancelledDuringNavigationInteraction.prototype.onStart = /**
4842
+ CancelledDuringNavigationInteraction.prototype.onRouterStarted = /**
4624
4843
  * @param {?} event
4625
4844
  * @return {?}
4626
4845
  */
4627
4846
  function (event) {
4628
- if (event.url === this.locationChangeTriggerUrl && !this.capturedFauxRouterStart) {
4629
- this.capturedFauxRouterStart = true;
4630
- return this.ignore(event, 'url matched back button location change');
4631
- }
4632
- else {
4633
- return this.createTransitionStateFor(event);
4634
- }
4847
+ return this.ignore(event);
4635
4848
  };
4636
4849
  /**
4637
4850
  * @param {?} event
4638
4851
  * @return {?}
4639
4852
  */
4640
- CancelledDuringNavigationInteraction.prototype.onCancel = /**
4853
+ CancelledDuringNavigationInteraction.prototype.onRouterCancelled = /**
4641
4854
  * @param {?} event
4642
4855
  * @return {?}
4643
4856
  */
4644
4857
  function (event) {
4645
- return this.ignore(event);
4858
+ // Depending on the state of the router and what was done we get a different
4859
+ // sequence of events. I.e. If they just clicked a link we'll get a cancel
4860
+ // with the locationChangeTriggerUrl as the final event. However the user
4861
+ // started the initial navigation with a pop state then we'll get one of
4862
+ // those with the locationChangeTriggerUrl but no cancel event with it.
4863
+ return this.gotPopStateWithLeavingUrl || this.locationChangeTriggerUrl === event.url ? this.createIdleState() : this.ignore(event);
4646
4864
  };
4647
4865
  /**
4648
4866
  * @param {?} event
4649
4867
  * @return {?}
4650
4868
  */
4651
- CancelledDuringNavigationInteraction.prototype.onEnd = /**
4869
+ CancelledDuringNavigationInteraction.prototype.onRouterEnd = /**
4652
4870
  * @param {?} event
4653
4871
  * @return {?}
4654
4872
  */
@@ -4659,7 +4877,7 @@
4659
4877
  * @param {?} event
4660
4878
  * @return {?}
4661
4879
  */
4662
- CancelledDuringNavigationInteraction.prototype.onError = /**
4880
+ CancelledDuringNavigationInteraction.prototype.onRouterError = /**
4663
4881
  * @param {?} event
4664
4882
  * @return {?}
4665
4883
  */
@@ -4675,7 +4893,31 @@
4675
4893
  * @return {?}
4676
4894
  */
4677
4895
  function (event) {
4678
- return this.createTransitionStateFor(event);
4896
+ this.gotPopStateWithLeavingUrl = this.gotPopStateWithLeavingUrl || event.url === this.locationChangeTriggerUrl;
4897
+ return this.ignore(event);
4898
+ };
4899
+ // @Trace()
4900
+ // @Trace()
4901
+ /**
4902
+ * @param {?} component
4903
+ * @param {?} currentUrl
4904
+ * @param {?} nextUrl
4905
+ * @return {?}
4906
+ */
4907
+ CancelledDuringNavigationInteraction.prototype.canDeactivatePlace =
4908
+ // @Trace()
4909
+ /**
4910
+ * @param {?} component
4911
+ * @param {?} currentUrl
4912
+ * @param {?} nextUrl
4913
+ * @return {?}
4914
+ */
4915
+ function (component, currentUrl, nextUrl) {
4916
+ return __awaiter(this, void 0, void 0, function () {
4917
+ return __generator(this, function (_a) {
4918
+ return [2 /*return*/, false];
4919
+ });
4920
+ });
4679
4921
  };
4680
4922
  /**
4681
4923
  * @param {?} event
@@ -4688,7 +4930,7 @@
4688
4930
  * @return {?}
4689
4931
  */
4690
4932
  function (event, reason) {
4691
- reason = reason ? " (" + reason + ")" : '';
4933
+ reason = reason ? " -> " + reason : '';
4692
4934
  pectin.Logger.get(this).info("ignoring router event" + reason + ": " + event.constructor.name + " -> " + event.url);
4693
4935
  return this;
4694
4936
  };
@@ -4699,8 +4941,14 @@
4699
4941
  * @return {?}
4700
4942
  */
4701
4943
  function () {
4702
- return this.constructor.name + "(startingUrl: " + this.startingUrl + ", locationChangeTriggerUrl:" + this.locationChangeTriggerUrl + ")";
4944
+ return this.constructor.name + "(isIdl: " + this.idle + ", startingUrl: " + this.startingUrl + ", locationChangeTriggerUrl:" + this.locationChangeTriggerUrl + ")";
4703
4945
  };
4946
+ __decorate([
4947
+ pectin.Trace(),
4948
+ __metadata("design:type", Function),
4949
+ __metadata("design:paramtypes", [router.NavigationCancel]),
4950
+ __metadata("design:returntype", NavigationState)
4951
+ ], CancelledDuringNavigationInteraction.prototype, "onRouterCancelled", null);
4704
4952
  return CancelledDuringNavigationInteraction;
4705
4953
  }(NavigationState));
4706
4954
  NavigationState.CancelledDuringNavigationInteraction = CancelledDuringNavigationInteraction;
@@ -4711,10 +4959,12 @@
4711
4959
  * @type {?}
4712
4960
  * @private
4713
4961
  */
4714
- CancelledDuringNavigationInteraction.prototype.capturedFauxRouterStart;
4962
+ CancelledDuringNavigationInteraction.prototype.gotPopStateWithLeavingUrl;
4715
4963
  /** @type {?} */
4716
4964
  CancelledDuringNavigationInteraction.prototype.startingUrl;
4717
4965
  /** @type {?} */
4966
+ CancelledDuringNavigationInteraction.prototype.startingEventWasAPopState;
4967
+ /** @type {?} */
4718
4968
  CancelledDuringNavigationInteraction.prototype.locationChangeTriggerUrl;
4719
4969
  }
4720
4970
  })(exports.NavigationState || (exports.NavigationState = {}));
@@ -4805,25 +5055,26 @@
4805
5055
  */
4806
5056
  exports.UrlSnapshot = /** @class */ (function () {
4807
5057
  // TODO: Update this accept a url Parser so it can be immutable and generate new trees on mutation using toString() are parseUrl.
4808
- function UrlSnapshot(urlSerializer, url) {
5058
+ function UrlSnapshot(urlSerializer, url, options) {
4809
5059
  this.urlSerializer = urlSerializer;
4810
5060
  this.url = url;
5061
+ this.options = options;
4811
5062
  this.urlTree = urlSerializer.parse(url);
4812
5063
  }
4813
5064
  /**
4814
- * @protected
4815
5065
  * @param {?} visit
4816
5066
  * @return {?}
4817
5067
  */
4818
- UrlSnapshot.prototype.replaceExistingVisitSegmentsWith = /**
4819
- * @protected
5068
+ UrlSnapshot.prototype.updateVisitSegments = /**
4820
5069
  * @param {?} visit
4821
5070
  * @return {?}
4822
5071
  */
4823
5072
  function (visit) {
5073
+ /** @type {?} */
5074
+ var urlTree = this.urlSerializer.parse(this.url);
4824
5075
  // Ugly, but it works for now.
4825
5076
  /** @type {?} */
4826
- var segments = __spread(this.getPrimarySegments());
5077
+ var segments = __spread(this.getPrimarySegments(urlTree));
4827
5078
  /** @type {?} */
4828
5079
  var visitSegments = this.getSegmentsFor(visit);
4829
5080
  /** @type {?} */
@@ -4834,17 +5085,20 @@
4834
5085
  function (segment) { return segment.path === visitSegments[0].path; }));
4835
5086
  // do not use the return value, it's the items that were removed!
4836
5087
  segments.splice.apply(segments, __spread([replaceAt, visitSegments.length], visitSegments));
4837
- return segments;
5088
+ urlTree.root.children.primary.segments = segments;
5089
+ return new UrlSnapshot(this.urlSerializer, urlTree.toString(), this.options);
4838
5090
  };
4839
5091
  /**
4840
5092
  * @private
5093
+ * @param {?} urlTree
4841
5094
  * @return {?}
4842
5095
  */
4843
5096
  UrlSnapshot.prototype.getPrimarySegments = /**
4844
5097
  * @private
5098
+ * @param {?} urlTree
4845
5099
  * @return {?}
4846
5100
  */
4847
- function () {
5101
+ function (urlTree) {
4848
5102
  return this.urlTree.root.children.primary.segments;
4849
5103
  };
4850
5104
  /**
@@ -4877,31 +5131,6 @@
4877
5131
  new router.UrlSegment(visit.placeDefinition.path, visit.placeDefinition.getFormattedRouteParameters(visit))
4878
5132
  ];
4879
5133
  };
4880
- /**
4881
- * @param {?} visit
4882
- * @return {?}
4883
- */
4884
- UrlSnapshot.prototype.createRedirectCommandsFor = /**
4885
- * @param {?} visit
4886
- * @return {?}
4887
- */
4888
- function (visit) {
4889
- /** @type {?} */
4890
- var segments = this.replaceExistingVisitSegmentsWith(visit);
4891
- /** @type {?} */
4892
- var commands = [];
4893
- segments.forEach((/**
4894
- * @param {?} s
4895
- * @return {?}
4896
- */
4897
- function (s) {
4898
- commands.push(s.path);
4899
- if (s.parameterMap.keys.length > 0) {
4900
- commands.push(s.parameters);
4901
- }
4902
- }));
4903
- return commands;
4904
- };
4905
5134
  /**
4906
5135
  * @param {?} placeDef
4907
5136
  * @return {?}
@@ -4911,7 +5140,7 @@
4911
5140
  * @return {?}
4912
5141
  */
4913
5142
  function (placeDef) {
4914
- return this.getPrimarySegments().find((/**
5143
+ return this.getPrimarySegments(this.urlTree).find((/**
4915
5144
  * @param {?} s
4916
5145
  * @return {?}
4917
5146
  */
@@ -4925,53 +5154,101 @@
4925
5154
  */
4926
5155
  function () {
4927
5156
  /** @type {?} */
4928
- var interactionOutlet = this.urlTree.root.children[UrlSnapshot.INTERACTION_ROUTER_OUTLET];
4929
- if (interactionOutlet) {
4930
- pectin.assert.isTruthy(interactionOutlet.segments.length === 2);
4931
- pectin.assert.isTruthy(interactionOutlet.segments[0].path === UrlSnapshot.INTERACTION_ROUTER_PATH);
4932
- return UrlSnapshot.parseInteractionIds(interactionOutlet.segments[1].path);
5157
+ var queryParam = this.urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM];
5158
+ if (queryParam) {
5159
+ return UrlSnapshot.parseInteractionIds(queryParam);
4933
5160
  }
4934
5161
  else {
4935
5162
  return [];
4936
5163
  }
4937
5164
  };
5165
+ /**
5166
+ * @return {?}
5167
+ */
5168
+ UrlSnapshot.prototype.hasInteractionIds = /**
5169
+ * @return {?}
5170
+ */
5171
+ function () {
5172
+ return this.getInteractionIds().length > 0;
5173
+ };
4938
5174
  // @Trace()
4939
5175
  // @Trace()
4940
5176
  /**
4941
5177
  * @param {?} ids
4942
5178
  * @return {?}
4943
5179
  */
4944
- UrlSnapshot.prototype.addOrReplaceInteractionIds =
5180
+ UrlSnapshot.prototype.updateInteractionIds =
4945
5181
  // @Trace()
4946
5182
  /**
4947
5183
  * @param {?} ids
4948
5184
  * @return {?}
4949
5185
  */
4950
5186
  function (ids) {
5187
+ if (ids.length === 0) {
5188
+ return this.removeInteractionIds();
5189
+ }
5190
+ else {
5191
+ /** @type {?} */
5192
+ var urlTree = this.urlSerializer.parse(this.url);
5193
+ urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM] = UrlSnapshot.createPathIdFor(ids);
5194
+ return new UrlSnapshot(this.urlSerializer, urlTree.toString(), this.options);
5195
+ }
5196
+ };
5197
+ // @Trace()
5198
+ // @Trace()
5199
+ /**
5200
+ * @return {?}
5201
+ */
5202
+ UrlSnapshot.prototype.removeInteractionIds =
5203
+ // @Trace()
5204
+ /**
5205
+ * @return {?}
5206
+ */
5207
+ function () {
4951
5208
  /** @type {?} */
4952
5209
  var urlTree = this.urlSerializer.parse(this.url);
4953
- urlTree.root.children[UrlSnapshot.INTERACTION_ROUTER_OUTLET] = new router.UrlSegmentGroup([
4954
- new router.UrlSegment(UrlSnapshot.INTERACTION_ROUTER_PATH, {}),
4955
- new router.UrlSegment(UrlSnapshot.createPathIdFor(ids), {})
4956
- ], {});
4957
- return new UrlSnapshot(this.urlSerializer, urlTree.toString());
5210
+ if (urlTree.queryParams && urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM]) {
5211
+ urlTree.queryParams = {}; //[UrlSnapshot.INTERACTION_ROUTER_OUTLET]
5212
+ }
5213
+ return new UrlSnapshot(this.urlSerializer, urlTree.toString(), this.options);
5214
+ };
5215
+ /**
5216
+ * @param {?} options
5217
+ * @return {?}
5218
+ */
5219
+ UrlSnapshot.prototype.withOptions = /**
5220
+ * @param {?} options
5221
+ * @return {?}
5222
+ */
5223
+ function (options) {
5224
+ return new UrlSnapshot(this.urlSerializer, this.url, options);
5225
+ };
5226
+ /**
5227
+ * @return {?}
5228
+ */
5229
+ UrlSnapshot.prototype.getNavigationExtras = /**
5230
+ * @return {?}
5231
+ */
5232
+ function () {
5233
+ return this.options;
4958
5234
  };
4959
5235
  return UrlSnapshot;
4960
5236
  }());
4961
5237
  if (false) {
4962
- /**
4963
- * @type {?}
4964
- * @private
4965
- */
5238
+ /** @type {?} */
4966
5239
  exports.UrlSnapshot.prototype.urlTree;
4967
5240
  /** @type {?} */
4968
5241
  exports.UrlSnapshot.prototype.urlSerializer;
4969
5242
  /** @type {?} */
4970
5243
  exports.UrlSnapshot.prototype.url;
5244
+ /**
5245
+ * @type {?}
5246
+ * @private
5247
+ */
5248
+ exports.UrlSnapshot.prototype.options;
4971
5249
  }
4972
5250
  (function (UrlSnapshot) {
4973
- UrlSnapshot.INTERACTION_ROUTER_OUTLET = 'aup-interactions';
4974
- UrlSnapshot.INTERACTION_ROUTER_PATH = 'active';
5251
+ UrlSnapshot.INTERACTION_QUERY_PARAM = 'aup-interactions';
4975
5252
  UrlSnapshot.INTERACTION_ID_SEPARATOR = '--';
4976
5253
  /**
4977
5254
  * @param {?} path
@@ -4990,13 +5267,14 @@
4990
5267
  }
4991
5268
  UrlSnapshot.createPathIdFor = createPathIdFor;
4992
5269
  /**
4993
- * @param {?} interactionIds
4994
- * @return {?}
5270
+ * @record
4995
5271
  */
4996
- function createInteractionOutletRouterCommands(interactionIds) {
4997
- return [UrlSnapshot.INTERACTION_ROUTER_PATH, createPathIdFor(interactionIds)];
5272
+ function NavigationOptions() { }
5273
+ UrlSnapshot.NavigationOptions = NavigationOptions;
5274
+ if (false) {
5275
+ /** @type {?|undefined} */
5276
+ NavigationOptions.prototype.replaceUrl;
4998
5277
  }
4999
- UrlSnapshot.createInteractionOutletRouterCommands = createInteractionOutletRouterCommands;
5000
5278
  })(exports.UrlSnapshot || (exports.UrlSnapshot = {}));
5001
5279
 
5002
5280
  /**
@@ -5043,7 +5321,6 @@
5043
5321
  // NavigationStart -> .... -> NavigationError --> navigation aborted, end session.
5044
5322
  // =======================
5045
5323
  if (event instanceof router.NavigationStart) {
5046
- console.log(event);
5047
5324
  if (event.navigationTrigger === 'popstate') {
5048
5325
  _this.runStateTransition((/**
5049
5326
  * @param {?} state
@@ -5056,7 +5333,7 @@
5056
5333
  * @param {?} state
5057
5334
  * @return {?}
5058
5335
  */
5059
- function (state) { return state.onStart(event); }));
5336
+ function (state) { return state.onRouterStarted(event); }));
5060
5337
  }
5061
5338
  }
5062
5339
  if (event instanceof router.NavigationEnd) {
@@ -5065,7 +5342,7 @@
5065
5342
  * @param {?} state
5066
5343
  * @return {?}
5067
5344
  */
5068
- function (state) { return state.onEnd(event); }));
5345
+ function (state) { return state.onRouterEnd(event); }));
5069
5346
  }
5070
5347
  if (event instanceof router.NavigationError) {
5071
5348
  console.log(event);
@@ -5073,7 +5350,7 @@
5073
5350
  * @param {?} state
5074
5351
  * @return {?}
5075
5352
  */
5076
- function (state) { return state.onError(event); }));
5353
+ function (state) { return state.onRouterError(event); }));
5077
5354
  }
5078
5355
  if (event instanceof router.NavigationCancel) {
5079
5356
  console.log(event);
@@ -5081,7 +5358,7 @@
5081
5358
  * @param {?} state
5082
5359
  * @return {?}
5083
5360
  */
5084
- function (state) { return state.onCancel(event); }));
5361
+ function (state) { return state.onRouterCancelled(event); }));
5085
5362
  }
5086
5363
  }));
5087
5364
  // Push dialog state to the url so we can capture the back button.
@@ -5110,12 +5387,11 @@
5110
5387
  var navigationState = _this._navigationStateModel.value;
5111
5388
  console.log("URLChange -> " + url, { state: navigationState });
5112
5389
  urlChanges.publish({ url: url, state: navigationState });
5113
- // We've entered a navigation transition
5114
- if (navigationState instanceof exports.NavigationState.NavigationTransition) {
5390
+ // The url has changed while we're in a transitional state
5391
+ if (navigationState.isTransitional) {
5115
5392
  /** @type {?} */
5116
5393
  var navigationInteraction = _this.navigationState.interactionContext;
5117
5394
  if (navigationInteraction && navigationInteraction.isActive()) {
5118
- pectin.Logger.get(_this).info("back button pressed during navigation session interaction promise");
5119
5395
  _this.runStateTransition((/**
5120
5396
  * @param {?} state
5121
5397
  * @return {?}
@@ -5256,9 +5532,9 @@
5256
5532
  */
5257
5533
  function (router) {
5258
5534
  /** @type {?} */
5259
- var commands = _this.parseUrl(_this.router.routerState.snapshot.url).createRedirectCommandsFor(next);
5260
- console.log('### Push Changes to route Redirect', { commands: commands });
5261
- return router.navigate(commands);
5535
+ var urlSnapshot = _this.parseUrl(_this.router.routerState.snapshot.url).updateVisitSegments(next);
5536
+ console.log('### Push Changes to route Redirect', { commands: urlSnapshot.url });
5537
+ return _this.navigateByUrl(urlSnapshot);
5262
5538
  }))];
5263
5539
  }
5264
5540
  return [2 /*return*/];
@@ -5290,7 +5566,7 @@
5290
5566
  */
5291
5567
  function (current) {
5292
5568
  /** @type {?} */
5293
- var session = new exports.NavigationState.NavigationTransition(_this._navigationSessionContext, false, _this.router.routerState.snapshot.url);
5569
+ var session = _this.navigationState.onPlaceNavigationStart(visit, _this.getCurrentRouterUrl());
5294
5570
  session.storeVisit(visit);
5295
5571
  return session;
5296
5572
  }));
@@ -5309,7 +5585,7 @@
5309
5585
  * @param {?} session
5310
5586
  * @return {?}
5311
5587
  */
5312
- function (session) { return session.onEnd(new router.NavigationEnd(-1, '', '')); }));
5588
+ function (session) { return session.onRouterEnd(new router.NavigationEnd(-1, '', '')); }));
5313
5589
  }
5314
5590
  return [7 /*endfinally*/];
5315
5591
  case 4: return [2 /*return*/];
@@ -5317,12 +5593,16 @@
5317
5593
  });
5318
5594
  });
5319
5595
  };
5596
+ // @Trace()
5597
+ // @Trace()
5320
5598
  /**
5321
5599
  * @protected
5322
5600
  * @param {?} transition
5323
5601
  * @return {?}
5324
5602
  */
5325
- PlaceRouter.prototype.runStateTransition = /**
5603
+ PlaceRouter.prototype.runStateTransition =
5604
+ // @Trace()
5605
+ /**
5326
5606
  * @protected
5327
5607
  * @param {?} transition
5328
5608
  * @return {?}
@@ -5379,7 +5659,7 @@
5379
5659
  * @return {?}
5380
5660
  */
5381
5661
  function (url) {
5382
- return new exports.UrlSnapshot(this.urlSerializer, url);
5662
+ return new exports.UrlSnapshot(this.urlSerializer, url, {});
5383
5663
  };
5384
5664
  /**
5385
5665
  * @param {?} url
@@ -5401,6 +5681,15 @@
5401
5681
  function () {
5402
5682
  return this.router.routerState ? this.router.routerState.snapshot.url : null;
5403
5683
  };
5684
+ /**
5685
+ * @return {?}
5686
+ */
5687
+ PlaceRouter.prototype.getCurrentRouteSnapshot = /**
5688
+ * @return {?}
5689
+ */
5690
+ function () {
5691
+ return this.parseUrl(this.getCurrentRouterUrl());
5692
+ };
5404
5693
  /**
5405
5694
  * @param {?} url
5406
5695
  * @return {?}
@@ -5427,14 +5716,32 @@
5427
5716
  function (url) {
5428
5717
  return this.getActiveInteractionIdsFromUrl(url).length > 0;
5429
5718
  };
5719
+ // @Trace()
5720
+ // @Trace()
5721
+ /**
5722
+ * @param {?} urlSnapshot
5723
+ * @return {?}
5724
+ */
5725
+ PlaceRouter.prototype.navigateByUrl =
5726
+ // @Trace()
5727
+ /**
5728
+ * @param {?} urlSnapshot
5729
+ * @return {?}
5730
+ */
5731
+ function (urlSnapshot) {
5732
+ this.router.navigateByUrl(urlSnapshot.urlTree, urlSnapshot.getNavigationExtras());
5733
+ };
5734
+ // @Trace()
5735
+ // @Trace()
5430
5736
  /**
5431
5737
  * @return {?}
5432
5738
  */
5433
- PlaceRouter.prototype.syncInteractionIdsWithRouter = /**
5739
+ PlaceRouter.prototype.syncInteractionIdsWithRouter =
5740
+ // @Trace()
5741
+ /**
5434
5742
  * @return {?}
5435
5743
  */
5436
5744
  function () {
5437
- var _a, _b;
5438
5745
  pectin.assert.isFalsey(this.navigationInProgress.value); // Updating interaction routes during an existing navigation breaks all the things.
5439
5746
  // Updating interaction routes during an existing navigation breaks all the things.
5440
5747
  /** @type {?} */
@@ -5444,22 +5751,12 @@
5444
5751
  }
5445
5752
  else {
5446
5753
  if (currentIds.length < 1) {
5447
- this.router.navigate(['.', {
5448
- outlets: (_a = {},
5449
- _a[exports.UrlSnapshot.INTERACTION_ROUTER_OUTLET] = null,
5450
- _a)
5451
- }], {
5452
- replaceUrl: true // remove the interaction from the history.
5453
- });
5754
+ // no more interactions to remove from history.
5755
+ this.navigateByUrl(this.getCurrentRouteSnapshot().removeInteractionIds());
5454
5756
  }
5455
5757
  else {
5456
- /** @type {?} */
5457
- var urlSnapshot = this.parseUrl(this.getCurrentRouterUrl());
5458
- this.router.navigate(['.', {
5459
- outlets: (_b = {},
5460
- _b[exports.UrlSnapshot.INTERACTION_ROUTER_OUTLET] = exports.UrlSnapshot.createInteractionOutletRouterCommands(currentIds),
5461
- _b)
5462
- }]);
5758
+ // todo was or is...
5759
+ this.navigateByUrl(this.getCurrentRouteSnapshot().updateInteractionIds(currentIds));
5463
5760
  }
5464
5761
  }
5465
5762
  };
@@ -5477,12 +5774,6 @@
5477
5774
  { type: exports.ɵv }
5478
5775
  ]; };
5479
5776
  /** @nocollapse */ PlaceRouter.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function PlaceRouter_Factory() { return new PlaceRouter(core.ɵɵinject(router.Router), core.ɵɵinject(router.UrlSerializer), core.ɵɵinject(common.Location), core.ɵɵinject(PlaceHistory), core.ɵɵinject(exports.ɵv)); }, token: PlaceRouter, providedIn: "root" });
5480
- __decorate([
5481
- pectin.Trace(),
5482
- __metadata("design:type", Function),
5483
- __metadata("design:paramtypes", []),
5484
- __metadata("design:returntype", void 0)
5485
- ], PlaceRouter.prototype, "syncInteractionIdsWithRouter", null);
5486
5777
  return PlaceRouter;
5487
5778
  }(pectin.GarbageCollector));
5488
5779
  if (false) {
@@ -7013,7 +7304,7 @@
7013
7304
  */
7014
7305
  function (target) {
7015
7306
  if (exports.PlaceComponent.isPlaceComponentConstructor(target)) {
7016
- exports.PlaceComponent.injectDefinition(target, new exports.PlaceDefinition(target, options.path, ___default.isNil(options.authenticate) ? false : options.authenticate, options.data, exports.PlaceComponent.getRouteParameters(target), (options.children || []).map((/**
7307
+ exports.PlaceComponent.injectDefinition(target, new exports.PlaceDefinition(target, options.path, ___default.isNil(options.authenticate) ? true : options.authenticate, options.data, exports.PlaceComponent.getRouteParameters(target), (options.children || []).map((/**
7017
7308
  * @param {?} c
7018
7309
  * @return {?}
7019
7310
  */
@@ -7044,103 +7335,6 @@
7044
7335
  }
7045
7336
  })(Place || (Place = {}));
7046
7337
 
7047
- /**
7048
- * @fileoverview added by tsickle
7049
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
7050
- */
7051
- var VisitSanitiser = /** @class */ (function () {
7052
- function VisitSanitiser(activatedRoute, router, placeHistory, injector) {
7053
- this.activatedRoute = activatedRoute;
7054
- this.router = router;
7055
- this.placeHistory = placeHistory;
7056
- this.injector = injector;
7057
- }
7058
- // @Trace()
7059
- // @Trace()
7060
- /**
7061
- * @param {?} visit
7062
- * @return {?}
7063
- */
7064
- VisitSanitiser.prototype.sanitise =
7065
- // @Trace()
7066
- /**
7067
- * @param {?} visit
7068
- * @return {?}
7069
- */
7070
- function (visit) {
7071
- return __awaiter(this, void 0, void 0, function () {
7072
- var placeDef, routeIdDef, routeId, sanitisedValue, parameterDefs, sanitisedVisit, i, def, value, sanitisedValue;
7073
- return __generator(this, function (_a) {
7074
- switch (_a.label) {
7075
- case 0:
7076
- placeDef = visit.placeDefinition;
7077
- if (!placeDef.hasRouteId()) return [3 /*break*/, 2];
7078
- routeIdDef = placeDef.getRouteIdParameterDef();
7079
- routeId = visit.getRouteId();
7080
- return [4 /*yield*/, routeIdDef.sanitise(routeId, visit, this.placeHistory, this.injector)];
7081
- case 1:
7082
- sanitisedValue = _a.sent();
7083
- // console.log({routeId, sanitisedValue});
7084
- // ###------- EARLY EXIT --------###
7085
- if (routeIdDef.hasChanged(routeId, sanitisedValue)) {
7086
- // if the route id has changed we redirect immediately as other
7087
- // parameter sanitisers might use it.
7088
- return [2 /*return*/, visit.replace(routeIdDef, sanitisedValue)];
7089
- }
7090
- _a.label = 2;
7091
- case 2:
7092
- // if we didn't replace the routeId we continue the url present parameters.
7093
- parameterDefs = placeDef.getVisitParameterDefs({
7094
- includeRouteParameters: true,
7095
- includeNonRouteParameters: true
7096
- });
7097
- sanitisedVisit = visit;
7098
- i = 0;
7099
- _a.label = 3;
7100
- case 3:
7101
- if (!(i < parameterDefs.length)) return [3 /*break*/, 6];
7102
- def = parameterDefs[i];
7103
- value = visit.getParameter(def.name);
7104
- return [4 /*yield*/, def.sanitise(value, sanitisedVisit, this.placeHistory, this.injector)];
7105
- case 4:
7106
- sanitisedValue = _a.sent();
7107
- if (def.hasChanged(value, sanitisedValue)) {
7108
- sanitisedVisit = sanitisedVisit.replace(def, sanitisedValue);
7109
- }
7110
- _a.label = 5;
7111
- case 5:
7112
- i++;
7113
- return [3 /*break*/, 3];
7114
- case 6: return [2 /*return*/, sanitisedVisit.hasChangedFrom(visit) ? sanitisedVisit : visit];
7115
- }
7116
- });
7117
- });
7118
- };
7119
- return VisitSanitiser;
7120
- }());
7121
- if (false) {
7122
- /**
7123
- * @type {?}
7124
- * @private
7125
- */
7126
- VisitSanitiser.prototype.activatedRoute;
7127
- /**
7128
- * @type {?}
7129
- * @private
7130
- */
7131
- VisitSanitiser.prototype.router;
7132
- /**
7133
- * @type {?}
7134
- * @private
7135
- */
7136
- VisitSanitiser.prototype.placeHistory;
7137
- /**
7138
- * @type {?}
7139
- * @private
7140
- */
7141
- VisitSanitiser.prototype.injector;
7142
- }
7143
-
7144
7338
  /**
7145
7339
  * @fileoverview added by tsickle
7146
7340
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -7303,15 +7497,151 @@
7303
7497
  * @fileoverview added by tsickle
7304
7498
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
7305
7499
  */
7500
+ var NoopAuthGuard = /** @class */ (function () {
7501
+ function NoopAuthGuard() {
7502
+ }
7503
+ /**
7504
+ * @param {?} activatedRoute
7505
+ * @param {?} state
7506
+ * @return {?}
7507
+ */
7508
+ NoopAuthGuard.prototype.canActivate = /**
7509
+ * @param {?} activatedRoute
7510
+ * @param {?} state
7511
+ * @return {?}
7512
+ */
7513
+ function (activatedRoute, state) {
7514
+ return __awaiter(this, void 0, void 0, function () {
7515
+ return __generator(this, function (_a) {
7516
+ return [2 /*return*/, true];
7517
+ });
7518
+ });
7519
+ };
7520
+ NoopAuthGuard.decorators = [
7521
+ { type: core.Injectable, args: [{
7522
+ providedIn: 'root'
7523
+ },] }
7524
+ ];
7525
+ /** @nocollapse */
7526
+ NoopAuthGuard.ctorParameters = function () { return []; };
7527
+ /** @nocollapse */ NoopAuthGuard.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function NoopAuthGuard_Factory() { return new NoopAuthGuard(); }, token: NoopAuthGuard, providedIn: "root" });
7528
+ return NoopAuthGuard;
7529
+ }());
7530
+
7306
7531
  /**
7532
+ * @fileoverview added by tsickle
7533
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
7534
+ */
7535
+ var VisitSanitiser = /** @class */ (function () {
7536
+ function VisitSanitiser(activatedRoute, router, placeHistory, injector) {
7537
+ this.activatedRoute = activatedRoute;
7538
+ this.router = router;
7539
+ this.placeHistory = placeHistory;
7540
+ this.injector = injector;
7541
+ }
7542
+ // @Trace()
7543
+ // @Trace()
7544
+ /**
7545
+ * @param {?} visit
7546
+ * @return {?}
7547
+ */
7548
+ VisitSanitiser.prototype.sanitise =
7549
+ // @Trace()
7550
+ /**
7551
+ * @param {?} visit
7552
+ * @return {?}
7553
+ */
7554
+ function (visit) {
7555
+ return __awaiter(this, void 0, void 0, function () {
7556
+ var placeDef, routeIdDef, routeId, sanitisedValue, parameterDefs, sanitisedVisit, i, def, value, sanitisedValue;
7557
+ return __generator(this, function (_a) {
7558
+ switch (_a.label) {
7559
+ case 0:
7560
+ placeDef = visit.placeDefinition;
7561
+ if (!placeDef.hasRouteId()) return [3 /*break*/, 2];
7562
+ routeIdDef = placeDef.getRouteIdParameterDef();
7563
+ routeId = visit.getRouteId();
7564
+ return [4 /*yield*/, routeIdDef.sanitise(routeId, visit, this.placeHistory, this.injector)];
7565
+ case 1:
7566
+ sanitisedValue = _a.sent();
7567
+ // console.log({routeId, sanitisedValue});
7568
+ // ###------- EARLY EXIT --------###
7569
+ if (routeIdDef.hasChanged(routeId, sanitisedValue)) {
7570
+ // if the route id has changed we redirect immediately as other
7571
+ // parameter sanitisers might use it.
7572
+ return [2 /*return*/, visit.replace(routeIdDef, sanitisedValue)];
7573
+ }
7574
+ _a.label = 2;
7575
+ case 2:
7576
+ // if we didn't replace the routeId we continue the url present parameters.
7577
+ parameterDefs = placeDef.getVisitParameterDefs({
7578
+ includeRouteParameters: true,
7579
+ includeNonRouteParameters: true
7580
+ });
7581
+ sanitisedVisit = visit;
7582
+ i = 0;
7583
+ _a.label = 3;
7584
+ case 3:
7585
+ if (!(i < parameterDefs.length)) return [3 /*break*/, 6];
7586
+ def = parameterDefs[i];
7587
+ value = visit.getParameter(def.name);
7588
+ return [4 /*yield*/, def.sanitise(value, sanitisedVisit, this.placeHistory, this.injector)];
7589
+ case 4:
7590
+ sanitisedValue = _a.sent();
7591
+ if (def.hasChanged(value, sanitisedValue)) {
7592
+ sanitisedVisit = sanitisedVisit.replace(def, sanitisedValue);
7593
+ }
7594
+ _a.label = 5;
7595
+ case 5:
7596
+ i++;
7597
+ return [3 /*break*/, 3];
7598
+ case 6: return [2 /*return*/, sanitisedVisit.hasChangedFrom(visit) ? sanitisedVisit : visit];
7599
+ }
7600
+ });
7601
+ });
7602
+ };
7603
+ return VisitSanitiser;
7604
+ }());
7605
+ if (false) {
7606
+ /**
7607
+ * @type {?}
7608
+ * @private
7609
+ */
7610
+ VisitSanitiser.prototype.activatedRoute;
7611
+ /**
7612
+ * @type {?}
7613
+ * @private
7614
+ */
7615
+ VisitSanitiser.prototype.router;
7616
+ /**
7617
+ * @type {?}
7618
+ * @private
7619
+ */
7620
+ VisitSanitiser.prototype.placeHistory;
7621
+ /**
7622
+ * @type {?}
7623
+ * @private
7624
+ */
7625
+ VisitSanitiser.prototype.injector;
7626
+ }
7627
+
7628
+ /**
7629
+ * @fileoverview added by tsickle
7630
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
7631
+ */
7632
+ /**
7633
+ * @abstract
7634
+ */
7635
+ var /**
7307
7636
  * @abstract
7308
7637
  */
7309
- var AbstractPlaceGuard = /** @class */ (function () {
7310
- function AbstractPlaceGuard(router, urlSerializer, placeRouter, placeHistory, injector) {
7638
+ PlaceGuard = /** @class */ (function () {
7639
+ function PlaceGuard(router, urlSerializer, placeRouter, placeHistory, interactionService, injector) {
7311
7640
  this.router = router;
7312
7641
  this.urlSerializer = urlSerializer;
7313
7642
  this.placeRouter = placeRouter;
7314
7643
  this.placeHistory = placeHistory;
7644
+ this.interactionService = interactionService;
7315
7645
  this.injector = injector;
7316
7646
  }
7317
7647
  // @Trace()
@@ -7321,7 +7651,7 @@
7321
7651
  * @param {?} state
7322
7652
  * @return {?}
7323
7653
  */
7324
- AbstractPlaceGuard.prototype.canActivate =
7654
+ PlaceGuard.prototype.canActivate =
7325
7655
  // @Trace()
7326
7656
  /**
7327
7657
  * @param {?} activatedRoute
@@ -7332,44 +7662,59 @@
7332
7662
  return __awaiter(this, void 0, void 0, function () {
7333
7663
  var _this = this;
7334
7664
  return __generator(this, function (_a) {
7665
+ // TODO: this is ugly now that I'm return UrlSnapshots and not UrlTrees. It'd be better if the functions
7666
+ // weren't nested or if I implemented a handler chain.
7335
7667
  return [2 /*return*/, this.authorisePlaceThen(activatedRoute, state, (/**
7336
7668
  * @param {?} placeDefinition
7337
7669
  * @return {?}
7338
7670
  */
7339
7671
  function (placeDefinition) { return __awaiter(_this, void 0, void 0, function () {
7340
- var params, parsedParams, initialVisit, sanitiser, sanitisedVisit, commands;
7672
+ var result;
7673
+ var _this = this;
7341
7674
  return __generator(this, function (_a) {
7342
7675
  switch (_a.label) {
7343
- case 0:
7344
- // Parse our route params.
7345
- params = new ConsolidatedParameterMap(activatedRoute.paramMap, activatedRoute.url);
7346
- parsedParams = placeDefinition.parseRouteParams(params);
7347
- initialVisit = this.placeRouter.navigationState.getVisitFor(placeDefinition) || new Visit(placeDefinition, parsedParams);
7348
- sanitiser = new VisitSanitiser(activatedRoute, this.router, this.placeHistory, this.injector);
7349
- return [4 /*yield*/, sanitiser.sanitise(initialVisit.mergeRouteParameters(parsedParams))];
7676
+ case 0: return [4 /*yield*/, this.cleanInteractionState(activatedRoute, state, (/**
7677
+ * @return {?}
7678
+ */
7679
+ function () { return __awaiter(_this, void 0, void 0, function () {
7680
+ var params, parsedParams, initialVisit, sanitiser, sanitisedVisit, urlSnapshot;
7681
+ return __generator(this, function (_a) {
7682
+ switch (_a.label) {
7683
+ case 0:
7684
+ // Parse our route params.
7685
+ params = new ConsolidatedParameterMap(activatedRoute.paramMap, activatedRoute.url);
7686
+ parsedParams = placeDefinition.parseRouteParams(params);
7687
+ initialVisit = this.placeRouter.navigationState.getVisitFor(placeDefinition) || new Visit(placeDefinition, parsedParams);
7688
+ sanitiser = new VisitSanitiser(activatedRoute, this.router, this.placeHistory, this.injector);
7689
+ return [4 /*yield*/, sanitiser.sanitise(initialVisit.mergeRouteParameters(parsedParams))];
7690
+ case 1:
7691
+ sanitisedVisit = _a.sent();
7692
+ // Save the visit with any updated parameters. We need to save it so we remember any non route parameters
7693
+ this.placeRouter.navigationState.storeVisit(sanitisedVisit);
7694
+ if (initialVisit.hasRoutingChangedFrom(sanitisedVisit)) {
7695
+ // Regenerate the url
7696
+ urlSnapshot = this.placeRouter.parseUrl(state.url).updateVisitSegments(sanitisedVisit);
7697
+ console.log('##### Place Guard Redirect', urlSnapshot);
7698
+ return [2 /*return*/, urlSnapshot];
7699
+ }
7700
+ else {
7701
+ return [2 /*return*/, true];
7702
+ }
7703
+ return [2 /*return*/];
7704
+ }
7705
+ });
7706
+ }); }))];
7350
7707
  case 1:
7351
- sanitisedVisit = _a.sent();
7352
- // Save the visit with any updated parameters. We need to save it so we remember any non route parameters
7353
- this.placeRouter.navigationState.storeVisit(sanitisedVisit);
7354
- if (initialVisit.hasRoutingChangedFrom(sanitisedVisit)) {
7355
- // Regenerate the url
7356
- commands = this.placeRouter.parseUrl(state.url).createRedirectCommandsFor(sanitisedVisit);
7357
- console.log('##### Place Guard Redirect', commands);
7358
- return [2 /*return*/, this.router.createUrlTree(commands, {
7359
- replaceUrl: true,
7360
- skipLocationChange: false
7361
- })];
7362
- }
7363
- else {
7364
- return [2 /*return*/, true];
7365
- }
7366
- return [2 /*return*/];
7708
+ result = _a.sent();
7709
+ return [2 /*return*/, this.handleGuardResult(result)];
7367
7710
  }
7368
7711
  });
7369
7712
  }); }))];
7370
7713
  });
7371
7714
  });
7372
7715
  };
7716
+ // @Trace()
7717
+ // @Trace()
7373
7718
  /**
7374
7719
  * @param {?} component
7375
7720
  * @param {?} currentRoute
@@ -7377,7 +7722,9 @@
7377
7722
  * @param {?=} nextState
7378
7723
  * @return {?}
7379
7724
  */
7380
- AbstractPlaceGuard.prototype.canDeactivate = /**
7725
+ PlaceGuard.prototype.canDeactivate =
7726
+ // @Trace()
7727
+ /**
7381
7728
  * @param {?} component
7382
7729
  * @param {?} currentRoute
7383
7730
  * @param {?} currentState
@@ -7386,11 +7733,38 @@
7386
7733
  */
7387
7734
  function (component, currentRoute, currentState, nextState) {
7388
7735
  return __awaiter(this, void 0, void 0, function () {
7736
+ var currentUrl, nextUrl, result;
7389
7737
  return __generator(this, function (_a) {
7390
- return [2 /*return*/, this.placeRouter.navigationState.canDeactivatePlace(component, this.placeRouter.parseUrl(nextState.url))];
7738
+ switch (_a.label) {
7739
+ case 0:
7740
+ currentUrl = this.placeRouter.parseUrl(currentState.url);
7741
+ nextUrl = this.placeRouter.parseUrl(nextState.url);
7742
+ return [4 /*yield*/, this.placeRouter.navigationState.canDeactivatePlace(component, currentUrl, nextUrl)];
7743
+ case 1:
7744
+ result = _a.sent();
7745
+ return [2 /*return*/, this.handleGuardResult(result)];
7746
+ }
7391
7747
  });
7392
7748
  });
7393
7749
  };
7750
+ /**
7751
+ * @private
7752
+ * @param {?} result
7753
+ * @return {?}
7754
+ */
7755
+ PlaceGuard.prototype.handleGuardResult = /**
7756
+ * @private
7757
+ * @param {?} result
7758
+ * @return {?}
7759
+ */
7760
+ function (result) {
7761
+ if (result instanceof exports.UrlSnapshot) {
7762
+ return result.urlTree;
7763
+ }
7764
+ else {
7765
+ return result;
7766
+ }
7767
+ };
7394
7768
  // @Trace()
7395
7769
  // @Trace()
7396
7770
  /**
@@ -7400,7 +7774,7 @@
7400
7774
  * @param {?} runPlaceGuards
7401
7775
  * @return {?}
7402
7776
  */
7403
- AbstractPlaceGuard.prototype.authorisePlaceThen =
7777
+ PlaceGuard.prototype.authorisePlaceThen =
7404
7778
  // @Trace()
7405
7779
  /**
7406
7780
  * @protected
@@ -7442,12 +7816,16 @@
7442
7816
  });
7443
7817
  });
7444
7818
  };
7819
+ // @Trace()
7820
+ // @Trace()
7445
7821
  /**
7446
7822
  * @param {?} activatedRoute
7447
7823
  * @param {?} state
7448
7824
  * @return {?}
7449
7825
  */
7450
- AbstractPlaceGuard.prototype.isAuthorised = /**
7826
+ PlaceGuard.prototype.isAuthorised =
7827
+ // @Trace()
7828
+ /**
7451
7829
  * @param {?} activatedRoute
7452
7830
  * @param {?} state
7453
7831
  * @return {?}
@@ -7461,201 +7839,79 @@
7461
7839
  });
7462
7840
  });
7463
7841
  };
7464
- __decorate([
7465
- pectin.Trace(),
7466
- __metadata("design:type", Function),
7467
- __metadata("design:paramtypes", [router.ActivatedRouteSnapshot, router.RouterStateSnapshot]),
7468
- __metadata("design:returntype", Promise)
7469
- ], AbstractPlaceGuard.prototype, "isAuthorised", null);
7470
- return AbstractPlaceGuard;
7471
- }());
7472
- if (false) {
7473
- /**
7474
- * @type {?}
7475
- * @private
7476
- */
7477
- AbstractPlaceGuard.prototype.router;
7478
- /**
7479
- * @type {?}
7480
- * @private
7481
- */
7482
- AbstractPlaceGuard.prototype.urlSerializer;
7483
- /**
7484
- * @type {?}
7485
- * @private
7486
- */
7487
- AbstractPlaceGuard.prototype.placeRouter;
7488
- /**
7489
- * @type {?}
7490
- * @private
7491
- */
7492
- AbstractPlaceGuard.prototype.placeHistory;
7493
- /**
7494
- * @type {?}
7495
- * @private
7496
- */
7497
- AbstractPlaceGuard.prototype.injector;
7498
- /**
7499
- * @abstract
7500
- * @param {?} injector
7501
- * @return {?}
7502
- */
7503
- AbstractPlaceGuard.prototype.getAuthGuard = function (injector) { };
7504
- }
7505
-
7506
- /**
7507
- * @fileoverview added by tsickle
7508
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
7509
- */
7510
- var InteractionGuard = /** @class */ (function () {
7511
- function InteractionGuard(router, injector, placeRouter, angularLocation, interactionService) {
7512
- this.router = router;
7513
- this.injector = injector;
7514
- this.placeRouter = placeRouter;
7515
- this.angularLocation = angularLocation;
7516
- this.interactionService = interactionService;
7517
- }
7842
+ // @Trace()
7843
+ // @Trace()
7518
7844
  /**
7519
7845
  * @param {?} route
7520
7846
  * @param {?} state
7847
+ * @param {?} then
7521
7848
  * @return {?}
7522
7849
  */
7523
- InteractionGuard.prototype.canActivate = /**
7850
+ PlaceGuard.prototype.cleanInteractionState =
7851
+ // @Trace()
7852
+ /**
7524
7853
  * @param {?} route
7525
7854
  * @param {?} state
7855
+ * @param {?} then
7526
7856
  * @return {?}
7527
7857
  */
7528
- function (route, state) {
7529
- /** @type {?} */
7530
- var url = this.router.parseUrl(state.url);
7531
- if (!this.interactionService.isActive() && url.root.children[exports.UrlSnapshot.INTERACTION_ROUTER_OUTLET]) {
7532
- // This happens if we reload the page or the url was pasted as the route should only be activated
7533
- // after the interaction context has become active.
7534
- delete url.root.children[exports.UrlSnapshot.INTERACTION_ROUTER_OUTLET];
7535
- return url;
7536
- }
7537
- else {
7538
- return true;
7539
- }
7540
- };
7541
- /**
7542
- * @param {?} component
7543
- * @param {?} currentRoute
7544
- * @param {?} currentState
7545
- * @param {?=} nextState
7546
- * @return {?}
7547
- */
7548
- InteractionGuard.prototype.canDeactivate = /**
7549
- * @param {?} component
7550
- * @param {?} currentRoute
7551
- * @param {?} currentState
7552
- * @param {?=} nextState
7553
- * @return {?}
7554
- */
7555
- function (component, currentRoute, currentState, nextState) {
7858
+ function (route, state, then) {
7556
7859
  return __awaiter(this, void 0, void 0, function () {
7557
- var currentIds, routeIds, activity;
7860
+ var url;
7558
7861
  return __generator(this, function (_a) {
7559
- switch (_a.label) {
7560
- case 0:
7561
- if (!this.interactionService.isActive()) return [3 /*break*/, 2];
7562
- currentIds = this.interactionService.activeInteractionContextIds.value;
7563
- routeIds = this.placeRouter.getActiveInteractionIdsFromUrl(nextState.url);
7564
- if (!!___default.isEqual(currentIds, routeIds)) return [3 /*break*/, 2];
7565
- // The activity is still active so the route change was triggered by the back button.
7566
- return [4 /*yield*/, this.interactionService.getCurrentActivity()];
7567
- case 1:
7568
- activity = _a.sent();
7569
- activity.cancel();
7570
- _a.label = 2;
7571
- case 2:
7572
- // IMPORTANT:
7573
- // We always return true, the router state engine will redirect as required. Return false
7574
- // during the guard causes all kinds of grief. It might be worth trying a redirect here
7575
- // again now that our state engine is more thorough.
7576
- return [2 /*return*/, true];
7862
+ url = this.placeRouter.parseUrl(state.url);
7863
+ if (!this.interactionService.isActive() && url.hasInteractionIds()) {
7864
+ // This happens if we reload the page or the url was pasted as the route should only be activated
7865
+ // after the interaction context has become active.
7866
+ return [2 /*return*/, url.removeInteractionIds()];
7577
7867
  }
7868
+ else {
7869
+ return [2 /*return*/, then()];
7870
+ }
7871
+ return [2 /*return*/];
7578
7872
  });
7579
7873
  });
7580
7874
  };
7581
- InteractionGuard.decorators = [
7582
- { type: core.Injectable, args: [{
7583
- providedIn: 'root'
7584
- },] }
7585
- ];
7586
- /** @nocollapse */
7587
- InteractionGuard.ctorParameters = function () { return [
7588
- { type: router.Router },
7589
- { type: core.Injector },
7590
- { type: PlaceRouter },
7591
- { type: common.Location },
7592
- { type: exports.ɵv }
7593
- ]; };
7594
- /** @nocollapse */ InteractionGuard.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function InteractionGuard_Factory() { return new InteractionGuard(core.ɵɵinject(router.Router), core.ɵɵinject(core.INJECTOR), core.ɵɵinject(PlaceRouter), core.ɵɵinject(common.Location), core.ɵɵinject(exports.ɵv)); }, token: InteractionGuard, providedIn: "root" });
7595
- return InteractionGuard;
7875
+ return PlaceGuard;
7596
7876
  }());
7597
7877
  if (false) {
7598
7878
  /**
7599
7879
  * @type {?}
7600
7880
  * @private
7601
7881
  */
7602
- InteractionGuard.prototype.router;
7882
+ PlaceGuard.prototype.router;
7603
7883
  /**
7604
7884
  * @type {?}
7605
7885
  * @private
7606
7886
  */
7607
- InteractionGuard.prototype.injector;
7887
+ PlaceGuard.prototype.urlSerializer;
7608
7888
  /**
7609
7889
  * @type {?}
7610
7890
  * @private
7611
7891
  */
7612
- InteractionGuard.prototype.placeRouter;
7892
+ PlaceGuard.prototype.placeRouter;
7613
7893
  /**
7614
7894
  * @type {?}
7615
7895
  * @private
7616
7896
  */
7617
- InteractionGuard.prototype.angularLocation;
7897
+ PlaceGuard.prototype.placeHistory;
7618
7898
  /**
7619
7899
  * @type {?}
7620
7900
  * @private
7621
7901
  */
7622
- InteractionGuard.prototype.interactionService;
7623
- }
7624
-
7625
- /**
7626
- * @fileoverview added by tsickle
7627
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
7628
- */
7629
- var NoopAuthGuard = /** @class */ (function () {
7630
- function NoopAuthGuard() {
7631
- }
7902
+ PlaceGuard.prototype.interactionService;
7632
7903
  /**
7633
- * @param {?} activatedRoute
7634
- * @param {?} state
7635
- * @return {?}
7904
+ * @type {?}
7905
+ * @private
7636
7906
  */
7637
- NoopAuthGuard.prototype.canActivate = /**
7638
- * @param {?} activatedRoute
7639
- * @param {?} state
7907
+ PlaceGuard.prototype.injector;
7908
+ /**
7909
+ * @abstract
7910
+ * @param {?} injector
7640
7911
  * @return {?}
7641
7912
  */
7642
- function (activatedRoute, state) {
7643
- return __awaiter(this, void 0, void 0, function () {
7644
- return __generator(this, function (_a) {
7645
- return [2 /*return*/, true];
7646
- });
7647
- });
7648
- };
7649
- NoopAuthGuard.decorators = [
7650
- { type: core.Injectable, args: [{
7651
- providedIn: 'root'
7652
- },] }
7653
- ];
7654
- /** @nocollapse */
7655
- NoopAuthGuard.ctorParameters = function () { return []; };
7656
- /** @nocollapse */ NoopAuthGuard.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function NoopAuthGuard_Factory() { return new NoopAuthGuard(); }, token: NoopAuthGuard, providedIn: "root" });
7657
- return NoopAuthGuard;
7658
- }());
7913
+ PlaceGuard.prototype.getAuthGuard = function (injector) { };
7914
+ }
7659
7915
 
7660
7916
  /**
7661
7917
  * @fileoverview added by tsickle
@@ -7921,7 +8177,6 @@
7921
8177
  exports.AUP_PLACE_CONFIG = AUP_PLACE_CONFIG;
7922
8178
  exports.AbstractActivity = AbstractActivity;
7923
8179
  exports.AbstractInputComponent = AbstractInputComponent;
7924
- exports.AbstractPlaceGuard = AbstractPlaceGuard;
7925
8180
  exports.AbstractPlaceNavigationComponent = AbstractPlaceNavigationComponent;
7926
8181
  exports.Activity = exports.ɵbi;
7927
8182
  exports.ActivityContainerComponent = ActivityContainerComponent;
@@ -7946,9 +8201,7 @@
7946
8201
  exports.InplaceInteractionContextComponent = InplaceInteractionContextComponent;
7947
8202
  exports.InteractionContext = InteractionContext;
7948
8203
  exports.InteractionContextBase = InteractionContextBase;
7949
- exports.InteractionGuard = InteractionGuard;
7950
8204
  exports.InteractionModule = InteractionModule;
7951
- exports.InteractionOutletComponent = InteractionOutletComponent;
7952
8205
  exports.InteractionService = exports.ɵv;
7953
8206
  exports.LEFT_RIGHT_PLACE_ANIMATION = LEFT_RIGHT_PLACE_ANIMATION;
7954
8207
  exports.ListPlaceNavComponent = ListPlaceNavComponent;
@@ -7959,6 +8212,7 @@
7959
8212
  exports.PasswordInputComponent = PasswordInputComponent;
7960
8213
  exports.Place = Place;
7961
8214
  exports.PlaceComponentDeactivationHandler = PlaceComponentDeactivationHandler;
8215
+ exports.PlaceGuard = PlaceGuard;
7962
8216
  exports.PlaceHistory = PlaceHistory;
7963
8217
  exports.PlaceModule = PlaceModule;
7964
8218
  exports.PlaceOutletComponent = PlaceOutletComponent;
@@ -7987,8 +8241,7 @@
7987
8241
  exports.ɵbg = AbstractActivity;
7988
8242
  exports.ɵbh = ACTIVITY_DATA;
7989
8243
  exports.ɵbl = AlertDialogComponent;
7990
- exports.ɵbn = InteractionOutletComponent;
7991
- exports.ɵbo = InplaceInteractionContextComponent;
8244
+ exports.ɵbn = InplaceInteractionContextComponent;
7992
8245
  exports.ɵc = FocusBindingDirective;
7993
8246
  exports.ɵd = DisposableComponent;
7994
8247
  exports.ɵe = ComponentsModule;