@coolon/angular-ui-powerups 0.0.97 → 0.0.101

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 (79) hide show
  1. package/bundles/coolon-angular-ui-powerups.umd.js +1405 -1305
  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 +19 -19
  6. package/coolon-angular-ui-powerups.metadata.json +1 -1
  7. package/esm2015/coolon-angular-ui-powerups.js +19 -19
  8. package/esm2015/index.js +2 -2
  9. package/esm2015/lib/interaction/components/activity-container/activity-container.component.js +20 -6
  10. package/esm2015/lib/interaction/components/inplace-interaction-context/inplace-interaction-context.component.js +18 -7
  11. package/esm2015/lib/interaction/index.js +5 -4
  12. package/esm2015/lib/interaction/interaction-context.js +7 -53
  13. package/esm2015/lib/interaction/interaction.module.js +3 -3
  14. package/esm2015/lib/interaction/services/interaction.service.js +228 -0
  15. package/esm2015/lib/interaction/services/mat-dialog-interaction/dialog-interaction-context-factory.js +62 -0
  16. package/esm2015/lib/interaction/services/mat-dialog-interaction/dialog-interaction-context.js +145 -0
  17. package/esm2015/lib/interaction/services/modal-interaction-context.factory.js +17 -0
  18. package/esm2015/lib/place/components/place-outlet/place-outlet.component.js +3 -3
  19. package/esm2015/lib/place/guards/abstract-place.guard.js +13 -12
  20. package/esm2015/lib/place/guards/interaction.guard.js +27 -19
  21. package/esm2015/lib/place/guards/navigation-state.js +676 -0
  22. package/esm2015/lib/place/guards/place-component-deactivation-handler.js +14 -37
  23. package/esm2015/lib/place/index.js +2 -2
  24. package/esm2015/lib/place/place-router.js +163 -161
  25. package/esm2015/lib/place/url-snapshot.js +91 -19
  26. package/esm2015/public_api.js +3 -3
  27. package/esm5/coolon-angular-ui-powerups.js +19 -19
  28. package/esm5/index.js +2 -2
  29. package/esm5/lib/interaction/components/activity-container/activity-container.component.js +24 -15
  30. package/esm5/lib/interaction/components/inplace-interaction-context/inplace-interaction-context.component.js +15 -7
  31. package/esm5/lib/interaction/index.js +5 -4
  32. package/esm5/lib/interaction/interaction-context.js +8 -61
  33. package/esm5/lib/interaction/interaction.module.js +3 -3
  34. package/esm5/lib/interaction/services/interaction.service.js +271 -0
  35. package/esm5/lib/interaction/services/mat-dialog-interaction/dialog-interaction-context-factory.js +65 -0
  36. package/esm5/lib/interaction/services/mat-dialog-interaction/dialog-interaction-context.js +170 -0
  37. package/esm5/lib/interaction/services/modal-interaction-context.factory.js +27 -0
  38. package/esm5/lib/place/components/place-outlet/place-outlet.component.js +3 -3
  39. package/esm5/lib/place/guards/abstract-place.guard.js +15 -14
  40. package/esm5/lib/place/guards/interaction.guard.js +25 -17
  41. package/esm5/lib/place/guards/navigation-state.js +894 -0
  42. package/esm5/lib/place/guards/place-component-deactivation-handler.js +21 -55
  43. package/esm5/lib/place/index.js +2 -2
  44. package/esm5/lib/place/place-router.js +186 -269
  45. package/esm5/lib/place/url-snapshot.js +105 -21
  46. package/esm5/public_api.js +3 -3
  47. package/fesm2015/coolon-angular-ui-powerups.js +1142 -990
  48. package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
  49. package/fesm5/coolon-angular-ui-powerups.js +1350 -1250
  50. package/fesm5/coolon-angular-ui-powerups.js.map +1 -1
  51. package/lib/interaction/components/activity-container/activity-container.component.d.ts +2 -1
  52. package/lib/interaction/components/inplace-interaction-context/inplace-interaction-context.component.d.ts +3 -1
  53. package/lib/interaction/index.d.ts +4 -3
  54. package/lib/interaction/interaction-context.d.ts +2 -11
  55. package/lib/interaction/services/interaction.service.d.ts +46 -0
  56. package/lib/interaction/services/mat-dialog-interaction/dialog-interaction-context-factory.d.ts +15 -0
  57. package/lib/interaction/services/{dialog-interaction-context.d.ts → mat-dialog-interaction/dialog-interaction-context.d.ts} +2 -2
  58. package/lib/interaction/services/modal-interaction-context.factory.d.ts +4 -0
  59. package/lib/place/guards/abstract-place.guard.d.ts +1 -1
  60. package/lib/place/guards/interaction.guard.d.ts +3 -3
  61. package/lib/place/guards/navigation-state.d.ts +124 -0
  62. package/lib/place/guards/place-component-deactivation-handler.d.ts +3 -5
  63. package/lib/place/index.d.ts +1 -1
  64. package/lib/place/place-router.d.ts +17 -24
  65. package/lib/place/url-snapshot.d.ts +18 -6
  66. package/package.json +1 -1
  67. package/schematics/place-routes/templates/place-routes.ts.template +3 -3
  68. package/styles/styles.scss +1 -1
  69. package/esm2015/lib/interaction/services/dialog-interaction-context.js +0 -163
  70. package/esm2015/lib/interaction/services/dialog-interaction.service.js +0 -151
  71. package/esm2015/lib/interaction/services/modal-interaction.service.js +0 -109
  72. package/esm2015/lib/place/guards/navigation-session.js +0 -590
  73. package/esm5/lib/interaction/services/dialog-interaction-context.js +0 -188
  74. package/esm5/lib/interaction/services/dialog-interaction.service.js +0 -179
  75. package/esm5/lib/interaction/services/modal-interaction.service.js +0 -153
  76. package/esm5/lib/place/guards/navigation-session.js +0 -741
  77. package/lib/interaction/services/dialog-interaction.service.d.ts +0 -24
  78. package/lib/interaction/services/modal-interaction.service.d.ts +0 -15
  79. package/lib/place/guards/navigation-session.d.ts +0 -96
@@ -1,16 +1,15 @@
1
1
  import { DOCUMENT, CommonModule, Location } from '@angular/common';
2
2
  import { Directive, ElementRef, Inject, Input, HostListener, NgZone, NgModule, EventEmitter, Output, Component, InjectionToken, Injector, ComponentFactoryResolver, ViewContainerRef, ViewChild, ViewChildren, Injectable, ɵɵdefineInjectable, ɵɵinject, Optional, SkipSelf, HostBinding, INJECTOR } from '@angular/core';
3
3
  import { FormsModule } from '@angular/forms';
4
- import { MatInputModule, MatFormFieldModule, MatSelectModule, MatDialog, MatButtonModule, MatDialogModule, MatTabsModule as MatTabsModule$1, MatProgressSpinnerModule } from '@angular/material';
4
+ import { MatInputModule, MatFormFieldModule, MatSelectModule, MatButtonModule, MatDialogModule, MatTabsModule as MatTabsModule$1, MatProgressSpinnerModule, MatDialog } from '@angular/material';
5
5
  import { MatTabsModule } from '@angular/material/tabs';
6
6
  import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
7
7
  import { __extends, __decorate, __metadata, __awaiter, __generator, __assign, __spread } from 'tslib';
8
- import { DelegatingValueModel, assert, UnaryCommand, lang, Dsl, GarbageCollector, Logger, DelegatingFormValueModel, UseDelegate, ValueModel, ListModel, StoreInListModel, EventListenerList, DelegatingListModel, Deferred, MutableStream, MutableValueModel, MutableListModel, Binding, Trace, Guard as Guard$1, StoreInValueModel, Command, OptionsHelper, ValueHolder } from '@coolon/pectin';
8
+ import { DelegatingValueModel, assert, UnaryCommand, lang, Dsl, GarbageCollector, Logger, DelegatingFormValueModel, UseDelegate, ValueModel, ListModel, StoreInListModel, DelegatingListModel, Deferred, MutableStream, MutableValueModel, MutableListModel, Binding, Trace, Guard, StoreInValueModel, Command, OptionsHelper, ValueHolder } from '@coolon/pectin';
9
9
  import { PortalModule } from '@angular/cdk/portal';
10
- import { RouterModule, NavigationStart, NavigationCancel, NavigationEnd, UrlSegment, NavigationError, Router, UrlSerializer, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
10
+ import { RouterModule, UrlSegment, UrlSegmentGroup, NavigationStart, NavigationEnd, NavigationError, NavigationCancel, Router, UrlSerializer, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
11
11
  import ___default, { last, isNil, isEqual } from 'lodash';
12
12
  import { assert as assert$1, Opts, Klass } from '@coolon/typescript-utilities';
13
- import { MatDialogConfig, MatDialog as MatDialog$1, MAT_DIALOG_DEFAULT_OPTIONS } from '@angular/material/dialog';
14
13
  import { MatIconModule } from '@angular/material/icon';
15
14
  import { MatListModule } from '@angular/material/list';
16
15
  import { MatTooltipModule } from '@angular/material/tooltip';
@@ -19,6 +18,7 @@ import { Memoize as Memoize$1 } from '@typescript-plus/fast-memoize-decorator';
19
18
  import 'reflect-metadata';
20
19
  import { style, query, group, animate, trigger, transition } from '@angular/animations';
21
20
  import ResizeObserver from 'resize-observer-polyfill';
21
+ import { MatDialogConfig, MAT_DIALOG_DEFAULT_OPTIONS, MatDialog as MatDialog$1 } from '@angular/material/dialog';
22
22
  import { Observable } from 'rxjs';
23
23
 
24
24
  /**
@@ -1106,9 +1106,7 @@ var /**
1106
1106
  InteractionContext = /** @class */ (function (_super) {
1107
1107
  __extends(InteractionContext, _super);
1108
1108
  function InteractionContext() {
1109
- var _this = _super !== null && _super.apply(this, arguments) || this;
1110
- _this.activityListeners = new EventListenerList();
1111
- return _this;
1109
+ return _super !== null && _super.apply(this, arguments) || this;
1112
1110
  }
1113
1111
  /**
1114
1112
  * Returns true if an activity is currently running.
@@ -1125,54 +1123,20 @@ InteractionContext = /** @class */ (function (_super) {
1125
1123
  return this.active.value;
1126
1124
  };
1127
1125
  /**
1128
- * @param {?} listener
1129
- * @return {?}
1130
- */
1131
- InteractionContext.prototype.addActivityListener = /**
1132
- * @param {?} listener
1133
- * @return {?}
1134
- */
1135
- function (listener) {
1136
- return this.activityListeners.add(listener);
1137
- };
1138
- /**
1139
- * @protected
1140
- * @return {?}
1141
- */
1142
- InteractionContext.prototype.notifyActivityStarted = /**
1143
- * @protected
1144
- * @return {?}
1145
- */
1146
- function () {
1147
- this.activityListeners.fire((/**
1148
- * @param {?} l
1149
- * @return {?}
1150
- */
1151
- function (l) { return l.onActivityStarted(); }));
1152
- };
1153
- /**
1154
- * @protected
1155
1126
  * @return {?}
1156
1127
  */
1157
- InteractionContext.prototype.notifyActivityFinished = /**
1158
- * @protected
1128
+ InteractionContext.prototype.dispose = /**
1159
1129
  * @return {?}
1160
1130
  */
1161
1131
  function () {
1162
- this.activityListeners.fire((/**
1163
- * @param {?} l
1164
- * @return {?}
1165
- */
1166
- function (l) { return l.onActivityFinished(); }));
1132
+ // TODO: think about auto cancelling any outstanding activity on dispose.
1133
+ // See NavigationState.Navigating for a use-case.
1134
+ assert.isFalsey(this.isActive());
1135
+ _super.prototype.dispose.call(this);
1167
1136
  };
1168
1137
  return InteractionContext;
1169
1138
  }(GarbageCollector));
1170
1139
  if (false) {
1171
- /**
1172
- * @type {?}
1173
- * @private
1174
- */
1175
- InteractionContext.prototype.activityListeners;
1176
1140
  /** @type {?} */
1177
1141
  InteractionContext.prototype.activityList;
1178
1142
  /** @type {?} */
@@ -1221,23 +1185,6 @@ if (false) {
1221
1185
  */
1222
1186
  InteractionContext.prototype.confirmThen = function (confirm, activityType, data) { };
1223
1187
  }
1224
- (function (InteractionContext) {
1225
- /**
1226
- * @record
1227
- */
1228
- function Listener() { }
1229
- InteractionContext.Listener = Listener;
1230
- if (false) {
1231
- /**
1232
- * @return {?}
1233
- */
1234
- Listener.prototype.onActivityStarted = function () { };
1235
- /**
1236
- * @return {?}
1237
- */
1238
- Listener.prototype.onActivityFinished = function () { };
1239
- }
1240
- })(InteractionContext || (InteractionContext = {}));
1241
1188
 
1242
1189
  /**
1243
1190
  * @fileoverview added by tsickle
@@ -1817,6 +1764,15 @@ TabContext = /** @class */ (function () {
1817
1764
  this._complete = true;
1818
1765
  this.activityCallbacks.onCancel(error);
1819
1766
  };
1767
+ /**
1768
+ * @return {?}
1769
+ */
1770
+ TabContext.prototype.dispose = /**
1771
+ * @return {?}
1772
+ */
1773
+ function () {
1774
+ this.component.dispose();
1775
+ };
1820
1776
  return TabContext;
1821
1777
  }());
1822
1778
  if (false) {
@@ -1906,20 +1862,10 @@ var ActivityContainerComponent = /** @class */ (function (_super) {
1906
1862
  enumerable: true,
1907
1863
  configurable: true
1908
1864
  });
1909
- // get isFinished() {
1910
- // return !this._initialActivityOutletContext;
1911
- // }
1912
- // get isFinished() {
1913
- // return !this._initialActivityOutletContext;
1914
- // }
1915
1865
  /**
1916
1866
  * @return {?}
1917
1867
  */
1918
- ActivityContainerComponent.prototype.ngOnInit =
1919
- // get isFinished() {
1920
- // return !this._initialActivityOutletContext;
1921
- // }
1922
- /**
1868
+ ActivityContainerComponent.prototype.ngOnInit = /**
1923
1869
  * @return {?}
1924
1870
  */
1925
1871
  function () {
@@ -2001,7 +1947,7 @@ var ActivityContainerComponent = /** @class */ (function (_super) {
2001
1947
  * @return {?}
2002
1948
  */
2003
1949
  function () {
2004
- this._initialActivityOutletContext = null;
1950
+ this._initialActivityOutletContext.value = null;
2005
1951
  this.initialActivityOutletContextEvent.emit(null);
2006
1952
  };
2007
1953
  // @Trace()
@@ -2033,14 +1979,24 @@ var ActivityContainerComponent = /** @class */ (function (_super) {
2033
1979
  * @return {?}
2034
1980
  */
2035
1981
  function () {
2036
- var _this = this;
2037
1982
  if (this.tabs.selectedIndex < this.activityTabs.length - 1) {
1983
+ /** @type {?} */
1984
+ var tabs = this.activityTabs.value;
1985
+ /** @type {?} */
1986
+ var remainingActivities_1 = tabs.slice(0, 1 + this.tabs.selectedIndex);
1987
+ /** @type {?} */
1988
+ var finishedActivityTabs = tabs.slice(1 + this.tabs.selectedIndex);
1989
+ finishedActivityTabs.forEach((/**
1990
+ * @param {?} a
1991
+ * @return {?}
1992
+ */
1993
+ function (a) { return a.dispose(); }));
2038
1994
  this.activityTabs.runInTransaction((/**
2039
1995
  * @param {?} draft
2040
1996
  * @return {?}
2041
1997
  */
2042
1998
  function (draft) {
2043
- draft.value = draft.value.slice(0, 1 + _this.tabs.selectedIndex);
1999
+ draft.value = remainingActivities_1;
2044
2000
  }));
2045
2001
  }
2046
2002
  };
@@ -2167,6 +2123,292 @@ if (false) {
2167
2123
  ActivityContainerComponent.prototype._activityList;
2168
2124
  }
2169
2125
 
2126
+ /**
2127
+ * @fileoverview added by tsickle
2128
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2129
+ */
2130
+ /**
2131
+ * @abstract
2132
+ */
2133
+ var /**
2134
+ * @abstract
2135
+ */
2136
+ ModalInteractionContextFactory = /** @class */ (function () {
2137
+ function ModalInteractionContextFactory() {
2138
+ }
2139
+ return ModalInteractionContextFactory;
2140
+ }());
2141
+ if (false) {
2142
+ /**
2143
+ * @abstract
2144
+ * @return {?}
2145
+ */
2146
+ ModalInteractionContextFactory.prototype.createInteractionContext = function () { };
2147
+ }
2148
+
2149
+ /**
2150
+ * @fileoverview added by tsickle
2151
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2152
+ */
2153
+ /** @type {?} */
2154
+ var inplaceMonitorCount = 0;
2155
+ var InteractionService = /** @class */ (function () {
2156
+ function InteractionService(modelInteractionContextFactory) {
2157
+ this.modelInteractionContextFactory = modelInteractionContextFactory;
2158
+ this.garbage = new GarbageCollector();
2159
+ this.exclusiveContext = new MutableValueModel();
2160
+ this._activeModalInteractionContextModel = new MutableValueModel();
2161
+ this._activeInlineInteractionContextModel = new MutableValueModel();
2162
+ var _a = Dsl.disposeWith(this.garbage), chain = _a.chain, valueOf = _a.valueOf, before = _a.before, when = _a.when, after = _a.after, observe = _a.observe, switchOn = _a.switchOn;
2163
+ this._activeInteractionContext = chain(this._activeModalInteractionContextModel)
2164
+ .otherwise(this._activeInlineInteractionContextModel)
2165
+ .pluck('interactionContext');
2166
+ this.active = chain(this._activeInteractionContext).isNotNil();
2167
+ this.modelInteractionActive = chain(this._activeModalInteractionContextModel).isNotNil();
2168
+ this.inlineInteractionActive = chain(this._activeInlineInteractionContextModel).isNotNil();
2169
+ // TODO: chain.concat(listOrValueModels) would be nice.
2170
+ this.activeInteractionContextIds = chain(new MutableListModel())
2171
+ .append(this._activeInlineInteractionContextModel)
2172
+ .append(this._activeModalInteractionContextModel)
2173
+ .rejectNil()
2174
+ .pluck('id');
2175
+ }
2176
+ /**
2177
+ * @return {?}
2178
+ */
2179
+ InteractionService.prototype.isActive = /**
2180
+ * @return {?}
2181
+ */
2182
+ function () {
2183
+ return this.active.value;
2184
+ };
2185
+ /**
2186
+ * @param {?} disposable
2187
+ * @return {?}
2188
+ */
2189
+ InteractionService.prototype.createModalInteractionContextFor = /**
2190
+ * @param {?} disposable
2191
+ * @return {?}
2192
+ */
2193
+ function (disposable) {
2194
+ /** @type {?} */
2195
+ var context = this.modelInteractionContextFactory.createInteractionContext();
2196
+ disposable.registerDisposable(new InteractionService.Monitor('modal', context, this._activeModalInteractionContextModel, this.exclusiveContext));
2197
+ return context;
2198
+ };
2199
+ /**
2200
+ * @param {?} interactionContext
2201
+ * @return {?}
2202
+ */
2203
+ InteractionService.prototype._registerInplaceInteractionContext = /**
2204
+ * @param {?} interactionContext
2205
+ * @return {?}
2206
+ */
2207
+ function (interactionContext) {
2208
+ interactionContext.registerDisposable(new InteractionService.Monitor("ip" + ++inplaceMonitorCount, interactionContext, this._activeInlineInteractionContextModel, this.exclusiveContext));
2209
+ };
2210
+ /**
2211
+ * @return {?}
2212
+ */
2213
+ InteractionService.prototype.getCurrentActivity = /**
2214
+ * @return {?}
2215
+ */
2216
+ function () {
2217
+ return __awaiter(this, void 0, void 0, function () {
2218
+ return __generator(this, function (_a) {
2219
+ assert$1.isTruthy(this.isActive());
2220
+ return [2 /*return*/, this._activeInteractionContext.value.getCurrentActivity()];
2221
+ });
2222
+ });
2223
+ };
2224
+ /**
2225
+ * Creates an interaction context that will prevent any other contexts from starting an
2226
+ * activity until it is disposed. This is intended for use by the router for passing
2227
+ * to PlaceComponent.canDeactivate(interactionContext). This ensures components don't
2228
+ * try and interact in a way that we can't track and synchronise with the browser back
2229
+ * button.
2230
+ */
2231
+ /**
2232
+ * Creates an interaction context that will prevent any other contexts from starting an
2233
+ * activity until it is disposed. This is intended for use by the router for passing
2234
+ * to PlaceComponent.canDeactivate(interactionContext). This ensures components don't
2235
+ * try and interact in a way that we can't track and synchronise with the browser back
2236
+ * button.
2237
+ * @return {?}
2238
+ */
2239
+ InteractionService.prototype._createExclusiveModalInteractionContext = /**
2240
+ * Creates an interaction context that will prevent any other contexts from starting an
2241
+ * activity until it is disposed. This is intended for use by the router for passing
2242
+ * to PlaceComponent.canDeactivate(interactionContext). This ensures components don't
2243
+ * try and interact in a way that we can't track and synchronise with the browser back
2244
+ * button.
2245
+ * @return {?}
2246
+ */
2247
+ function () {
2248
+ this.exclusiveContext.value = this.modelInteractionContextFactory.createInteractionContext();
2249
+ /** @type {?} */
2250
+ var self = this;
2251
+ this.exclusiveContext.value.registerDisposable({
2252
+ dispose: /**
2253
+ * @return {?}
2254
+ */
2255
+ function () {
2256
+ self.exclusiveContext.value = null;
2257
+ }
2258
+ });
2259
+ return this.exclusiveContext.value;
2260
+ };
2261
+ InteractionService.decorators = [
2262
+ { type: Injectable, args: [{
2263
+ providedIn: 'root'
2264
+ },] }
2265
+ ];
2266
+ /** @nocollapse */
2267
+ InteractionService.ctorParameters = function () { return [
2268
+ { type: ModalInteractionContextFactory }
2269
+ ]; };
2270
+ /** @nocollapse */ InteractionService.ngInjectableDef = ɵɵdefineInjectable({ factory: function InteractionService_Factory() { return new InteractionService(ɵɵinject(ModalInteractionContextFactory)); }, token: InteractionService, providedIn: "root" });
2271
+ return InteractionService;
2272
+ }());
2273
+ if (false) {
2274
+ /**
2275
+ * @type {?}
2276
+ * @private
2277
+ */
2278
+ InteractionService.prototype.garbage;
2279
+ /** @type {?} */
2280
+ InteractionService.prototype.active;
2281
+ /**
2282
+ * @type {?}
2283
+ * @private
2284
+ */
2285
+ InteractionService.prototype.exclusiveContext;
2286
+ /**
2287
+ * @type {?}
2288
+ * @private
2289
+ */
2290
+ InteractionService.prototype._activeModalInteractionContextModel;
2291
+ /**
2292
+ * @type {?}
2293
+ * @private
2294
+ */
2295
+ InteractionService.prototype._activeInlineInteractionContextModel;
2296
+ /**
2297
+ * @type {?}
2298
+ * @private
2299
+ */
2300
+ InteractionService.prototype._activeInteractionContext;
2301
+ /** @type {?} */
2302
+ InteractionService.prototype.activeInteractionContextIds;
2303
+ /** @type {?} */
2304
+ InteractionService.prototype.modelInteractionActive;
2305
+ /** @type {?} */
2306
+ InteractionService.prototype.inlineInteractionActive;
2307
+ /** @type {?} */
2308
+ InteractionService.prototype.modelInteractionContextFactory;
2309
+ }
2310
+ (function (InteractionService) {
2311
+ /**
2312
+ * @record
2313
+ */
2314
+ function Callback() { }
2315
+ InteractionService.Callback = Callback;
2316
+ if (false) {
2317
+ /**
2318
+ * @param {?} monitor
2319
+ * @return {?}
2320
+ */
2321
+ Callback.prototype.onStarted = function (monitor) { };
2322
+ /**
2323
+ * @param {?} monitor
2324
+ * @return {?}
2325
+ */
2326
+ Callback.prototype.onFinished = function (monitor) { };
2327
+ }
2328
+ var Monitor = /** @class */ (function (_super) {
2329
+ __extends(Monitor, _super);
2330
+ function Monitor(id, interactionContext, currentActiveMonitor, exclusiveContext) {
2331
+ var _this = _super.call(this) || this;
2332
+ _this.id = id;
2333
+ _this.interactionContext = interactionContext;
2334
+ _this.currentActiveMonitor = currentActiveMonitor;
2335
+ _this.exclusiveContext = exclusiveContext;
2336
+ var _a = Dsl.disposeWith(_this), chain = _a.chain, valueOf = _a.valueOf, before = _a.before, when = _a.when, after = _a.after, observe = _a.observe, switchOn = _a.switchOn;
2337
+ when.valueOf(interactionContext.active).becomesTruthy((/**
2338
+ * @return {?}
2339
+ */
2340
+ function () { return _this.onStarted(); }));
2341
+ when.valueOf(interactionContext.active).becomesFalsey((/**
2342
+ * @return {?}
2343
+ */
2344
+ function () { return _this.onFinished(); }));
2345
+ interactionContext.registerDisposable(_this);
2346
+ return _this;
2347
+ }
2348
+ /**
2349
+ * @protected
2350
+ * @return {?}
2351
+ */
2352
+ Monitor.prototype.onStarted = /**
2353
+ * @protected
2354
+ * @return {?}
2355
+ */
2356
+ function () {
2357
+ this.assertCanStart();
2358
+ this.currentActiveMonitor.value = this;
2359
+ };
2360
+ /**
2361
+ * @private
2362
+ * @return {?}
2363
+ */
2364
+ Monitor.prototype.assertCanStart = /**
2365
+ * @private
2366
+ * @return {?}
2367
+ */
2368
+ function () {
2369
+ assert$1.isFalsey(this.currentActiveMonitor.value);
2370
+ if (this.exclusiveContext.value && this.interactionContext !== this.exclusiveContext.value) {
2371
+ lang.illegalState('Interaction started while exclusive lock active. This is usually because you using a different context during place.canDeactivate(interactionContext)');
2372
+ }
2373
+ };
2374
+ /**
2375
+ * @protected
2376
+ * @return {?}
2377
+ */
2378
+ Monitor.prototype.onFinished = /**
2379
+ * @protected
2380
+ * @return {?}
2381
+ */
2382
+ function () {
2383
+ this.assertCurrentlyActive();
2384
+ this.currentActiveMonitor.value = null;
2385
+ };
2386
+ /**
2387
+ * @private
2388
+ * @return {?}
2389
+ */
2390
+ Monitor.prototype.assertCurrentlyActive = /**
2391
+ * @private
2392
+ * @return {?}
2393
+ */
2394
+ function () {
2395
+ assert$1.isTruthy(this.currentActiveMonitor.value === this);
2396
+ };
2397
+ return Monitor;
2398
+ }(GarbageCollector));
2399
+ InteractionService.Monitor = Monitor;
2400
+ if (false) {
2401
+ /** @type {?} */
2402
+ Monitor.prototype.id;
2403
+ /** @type {?} */
2404
+ Monitor.prototype.interactionContext;
2405
+ /** @type {?} */
2406
+ Monitor.prototype.currentActiveMonitor;
2407
+ /** @type {?} */
2408
+ Monitor.prototype.exclusiveContext;
2409
+ }
2410
+ })(InteractionService || (InteractionService = {}));
2411
+
2170
2412
  /**
2171
2413
  * @fileoverview added by tsickle
2172
2414
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -2176,10 +2418,11 @@ if (false) {
2176
2418
  */
2177
2419
  var InplaceInteractionContextComponent = /** @class */ (function (_super) {
2178
2420
  __extends(InplaceInteractionContextComponent, _super);
2179
- function InplaceInteractionContextComponent() {
2421
+ function InplaceInteractionContextComponent(interactionService) {
2180
2422
  var _this = _super.call(this) || this;
2181
- _this._active = new DelegatingValueModel().withDefault(false);
2182
- var _a = Dsl.disposeWith(_this), chain = _a.chain, valueOf = _a.valueOf, before = _a.before, when = _a.when, after = _a.after, observe = _a.observe, switchOn = _a.switchOn;
2423
+ _this.interactionService = interactionService;
2424
+ _this._active = new MutableValueModel(false);
2425
+ _this.interactionService._registerInplaceInteractionContext(_this);
2183
2426
  return _this;
2184
2427
  }
2185
2428
  /**
@@ -2190,7 +2433,6 @@ var InplaceInteractionContextComponent = /** @class */ (function (_super) {
2190
2433
  */
2191
2434
  function () {
2192
2435
  this.setActivityList(this.interactionContext.activityList);
2193
- this._active.setDelegate(this.interactionContext.active);
2194
2436
  };
2195
2437
  Object.defineProperty(InplaceInteractionContextComponent.prototype, "active", {
2196
2438
  get: /**
@@ -2218,6 +2460,7 @@ var InplaceInteractionContextComponent = /** @class */ (function (_super) {
2218
2460
  */
2219
2461
  function (activityType, data) {
2220
2462
  var _this = this;
2463
+ this._active.value = true;
2221
2464
  /** @type {?} */
2222
2465
  var self = this;
2223
2466
  return new Promise((/**
@@ -2234,6 +2477,7 @@ var InplaceInteractionContextComponent = /** @class */ (function (_super) {
2234
2477
  * @return {?}
2235
2478
  */
2236
2479
  function (result) {
2480
+ self._active.value = false;
2237
2481
  resolve(result);
2238
2482
  },
2239
2483
  onCancel: /**
@@ -2241,6 +2485,7 @@ var InplaceInteractionContextComponent = /** @class */ (function (_super) {
2241
2485
  * @return {?}
2242
2486
  */
2243
2487
  function (error) {
2488
+ self._active.value = false;
2244
2489
  reject(error);
2245
2490
  }
2246
2491
  };
@@ -2254,7 +2499,9 @@ var InplaceInteractionContextComponent = /** @class */ (function (_super) {
2254
2499
  }] }
2255
2500
  ];
2256
2501
  /** @nocollapse */
2257
- InplaceInteractionContextComponent.ctorParameters = function () { return []; };
2502
+ InplaceInteractionContextComponent.ctorParameters = function () { return [
2503
+ { type: InteractionService }
2504
+ ]; };
2258
2505
  InplaceInteractionContextComponent.propDecorators = {
2259
2506
  interactionContext: [{ type: ViewChild, args: ['activityContainer', { static: true },] }]
2260
2507
  };
@@ -2270,6 +2517,8 @@ if (false) {
2270
2517
  * @private
2271
2518
  */
2272
2519
  InplaceInteractionContextComponent.prototype._active;
2520
+ /** @type {?} */
2521
+ InplaceInteractionContextComponent.prototype.interactionService;
2273
2522
  }
2274
2523
 
2275
2524
  /**
@@ -2295,500 +2544,8 @@ var InteractionOutletComponent = /** @class */ (function () {
2295
2544
  * @fileoverview added by tsickle
2296
2545
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2297
2546
  */
2298
- var DialogInteractionContext = /** @class */ (function (_super) {
2299
- __extends(DialogInteractionContext, _super);
2300
- function DialogInteractionContext(dialogService, config) {
2301
- var _this = _super.call(this) || this;
2302
- _this.dialogService = dialogService;
2303
- _this.config = config;
2304
- _this._activeModel = new MutableValueModel(false);
2305
- assert$1.notNil(dialogService);
2306
- _this.onDispose((/**
2307
- * @return {?}
2308
- */
2309
- function () {
2310
- if (_this.isActive()) {
2311
- lang.illegalState('Dispose called while active.');
2312
- }
2313
- }));
2314
- return _this;
2315
- }
2316
- Object.defineProperty(DialogInteractionContext.prototype, "active", {
2317
- get: /**
2318
- * @return {?}
2319
- */
2320
- function () {
2321
- return this._activeModel.readonly;
2322
- },
2323
- enumerable: true,
2324
- configurable: true
2325
- });
2326
- /**
2327
- * @protected
2328
- * @template D, R, E
2329
- * @param {?} activityType
2330
- * @param {?} data
2331
- * @param {?=} disableClose
2332
- * @return {?}
2333
- */
2334
- DialogInteractionContext.prototype._startActivity = /**
2335
- * @protected
2336
- * @template D, R, E
2337
- * @param {?} activityType
2338
- * @param {?} data
2339
- * @param {?=} disableClose
2340
- * @return {?}
2341
- */
2342
- function (activityType, data, disableClose) {
2343
- var _this = this;
2344
- if (disableClose === void 0) { disableClose = true; }
2345
- if (this.isActive()) {
2346
- lang.illegalState("Activity already in progress: " + this.activityList.value.map((/**
2347
- * @param {?} a
2348
- * @return {?}
2349
- */
2350
- function (a) { return a.constructor.name; })).join(', '));
2351
- }
2352
- this._activeModel.value = true;
2353
- this.notifyActivityStarted();
2354
- /** @type {?} */
2355
- var config = __assign({}, this.config, {
2356
- data: data,
2357
- disableClose: disableClose,
2358
- panelClass: 'dialog-interaction-service'
2359
- });
2360
- /** @type {?} */
2361
- var self = this;
2362
- /** @type {?} */
2363
- var matDialogRef = (/** @type {?} */ (this.dialogService.open(ActivityContainerComponent, config)));
2364
- return new Promise((/**
2365
- * @param {?} resolve
2366
- * @param {?} reject
2367
- * @return {?}
2368
- */
2369
- function (resolve, reject) {
2370
- /** @type {?} */
2371
- var activityContainer = matDialogRef.componentInstance;
2372
- self.safelyUpdateActivityListDelegate(activityContainer.activityList);
2373
- activityContainer.initialActivityOutletContext = {
2374
- activityClass: activityType,
2375
- activityData: data,
2376
- onDone: /**
2377
- * @param {?} result
2378
- * @return {?}
2379
- */
2380
- function (result) {
2381
- resolve(result);
2382
- matDialogRef.close(true); // return true to let the after close listener know we've already handled it.
2383
- },
2384
- onCancel: /**
2385
- * @param {?} error
2386
- * @return {?}
2387
- */
2388
- function (error) {
2389
- reject(error);
2390
- matDialogRef.close(true); // return true to let the after close listener know we've already handled it.
2391
- }
2392
- };
2393
- // we need to check if our onDone/onCancel methods above we called or if we were
2394
- // closed by the user clicking the backdrop. If the later then we need to reject
2395
- // our promise.
2396
- matDialogRef.afterClosed().subscribe((/**
2397
- * @param {?} promiseAlreadyFinished
2398
- * @return {?}
2399
- */
2400
- function (promiseAlreadyFinished) {
2401
- if (!promiseAlreadyFinished) {
2402
- reject('auto-closed');
2403
- }
2404
- }));
2405
- matDialogRef.updateSize();
2406
- matDialogRef.afterOpened().subscribe((/**
2407
- * @param {?} promiseAlreadyFinished
2408
- * @return {?}
2409
- */
2410
- function (promiseAlreadyFinished) {
2411
- matDialogRef.updateSize();
2412
- }));
2413
- })).finally((/**
2414
- * @return {?}
2415
- */
2416
- function () {
2417
- _this._activeModel.value = false;
2418
- _this.notifyActivityFinished();
2419
- self.safelyUpdateActivityListDelegate(null);
2420
- }));
2421
- };
2422
- /**
2423
- * Updates teh delegate on the next tick to avoid modifying state during the current change detection cycle.
2424
- * @param delegate
2425
- */
2426
- /**
2427
- * Updates teh delegate on the next tick to avoid modifying state during the current change detection cycle.
2428
- * @param {?} delegate
2429
- * @return {?}
2430
- */
2431
- DialogInteractionContext.prototype.safelyUpdateActivityListDelegate = /**
2432
- * Updates teh delegate on the next tick to avoid modifying state during the current change detection cycle.
2433
- * @param {?} delegate
2434
- * @return {?}
2435
- */
2436
- function (delegate) {
2437
- var _this = this;
2438
- setTimeout((/**
2439
- * @return {?}
2440
- */
2441
- function () { return _this.setActivityList(delegate); }));
2442
- };
2443
- DialogInteractionContext.decorators = [
2444
- { type: Injectable, args: [{
2445
- providedIn: 'root'
2446
- },] }
2447
- ];
2448
- /** @nocollapse */
2449
- DialogInteractionContext.ctorParameters = function () { return [
2450
- { type: MatDialog },
2451
- { type: MatDialogConfig }
2452
- ]; };
2453
- /** @nocollapse */ DialogInteractionContext.ngInjectableDef = ɵɵdefineInjectable({ factory: function DialogInteractionContext_Factory() { return new DialogInteractionContext(ɵɵinject(MatDialog$1), ɵɵinject(MatDialogConfig)); }, token: DialogInteractionContext, providedIn: "root" });
2454
- return DialogInteractionContext;
2455
- }(InteractionContextBase));
2456
- if (false) {
2457
- /**
2458
- * @type {?}
2459
- * @private
2460
- */
2461
- DialogInteractionContext.prototype._activeModel;
2462
- /**
2463
- * @type {?}
2464
- * @private
2465
- */
2466
- DialogInteractionContext.prototype.dialogService;
2467
- /** @type {?} */
2468
- DialogInteractionContext.prototype.config;
2469
- }
2470
-
2471
- /**
2472
- * @fileoverview added by tsickle
2473
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2474
- */
2475
- var Guard = /** @class */ (function (_super) {
2476
- __extends(Guard, _super);
2477
- function Guard() {
2478
- return _super.call(this, { initialValue: false }) || this;
2479
- }
2480
- Object.defineProperty(Guard.prototype, "value", {
2481
- get: /**
2482
- * @return {?}
2483
- */
2484
- function () {
2485
- return this.store.read();
2486
- },
2487
- enumerable: true,
2488
- configurable: true
2489
- });
2490
- /**
2491
- * @template R
2492
- * @param {?} fun
2493
- * @return {?}
2494
- */
2495
- Guard.prototype.whileTrue = /**
2496
- * @template R
2497
- * @param {?} fun
2498
- * @return {?}
2499
- */
2500
- function (fun) {
2501
- this.startTransaction().commit(true);
2502
- try {
2503
- return fun();
2504
- }
2505
- finally {
2506
- this.startTransaction().commit(false);
2507
- }
2508
- };
2509
- /**
2510
- * @template R
2511
- * @param {?} fun
2512
- * @param {?=} defaultValue
2513
- * @return {?}
2514
- */
2515
- Guard.prototype.runIfFalse = /**
2516
- * @template R
2517
- * @param {?} fun
2518
- * @param {?=} defaultValue
2519
- * @return {?}
2520
- */
2521
- function (fun, defaultValue) {
2522
- if (defaultValue === void 0) { defaultValue = null; }
2523
- return !this.value ? fun() : defaultValue;
2524
- };
2525
- return Guard;
2526
- }(ValueModel));
2527
- /**
2528
- * @abstract
2529
- */
2530
- var /**
2531
- * @abstract
2532
- */
2533
- ModalInteractionService = /** @class */ (function (_super) {
2534
- __extends(ModalInteractionService, _super);
2535
- function ModalInteractionService() {
2536
- var _this = _super.call(this) || this;
2537
- _this._activityListeners = new EventListenerList();
2538
- return _this;
2539
- }
2540
- /**
2541
- * @return {?}
2542
- */
2543
- ModalInteractionService.prototype.isActive = /**
2544
- * @return {?}
2545
- */
2546
- function () {
2547
- return this.active.value;
2548
- };
2549
- /**
2550
- * @param {?} listener
2551
- * @return {?}
2552
- */
2553
- ModalInteractionService.prototype.addActivityListener = /**
2554
- * @param {?} listener
2555
- * @return {?}
2556
- */
2557
- function (listener) {
2558
- return this._activityListeners.add(listener);
2559
- };
2560
- /**
2561
- * @protected
2562
- * @return {?}
2563
- */
2564
- ModalInteractionService.prototype.notifyActivityStarted = /**
2565
- * @protected
2566
- * @return {?}
2567
- */
2568
- function () {
2569
- this._activityListeners.fire((/**
2570
- * @param {?} l
2571
- * @return {?}
2572
- */
2573
- function (l) { return l.onActivityStarted(); }));
2574
- };
2575
- /**
2576
- * @protected
2577
- * @return {?}
2578
- */
2579
- ModalInteractionService.prototype.notifyActivityFinished = /**
2580
- * @protected
2581
- * @return {?}
2582
- */
2583
- function () {
2584
- this._activityListeners.fire((/**
2585
- * @param {?} l
2586
- * @return {?}
2587
- */
2588
- function (l) { return l.onActivityFinished(); }));
2589
- };
2590
- return ModalInteractionService;
2591
- }(GarbageCollector));
2592
- if (false) {
2593
- /**
2594
- * @type {?}
2595
- * @private
2596
- */
2597
- ModalInteractionService.prototype._activityListeners;
2598
- /** @type {?} */
2599
- ModalInteractionService.prototype.active;
2600
- /**
2601
- * @abstract
2602
- * @param {?} disposable
2603
- * @return {?}
2604
- */
2605
- ModalInteractionService.prototype.createInteractionContextFor = function (disposable) { };
2606
- /**
2607
- * @abstract
2608
- * @return {?}
2609
- */
2610
- ModalInteractionService.prototype.createExclusiveInteractionContext = function () { };
2611
- /**
2612
- * @abstract
2613
- * @return {?}
2614
- */
2615
- ModalInteractionService.prototype.getCurrentActivity = function () { };
2616
- }
2617
-
2618
- /**
2619
- * @fileoverview added by tsickle
2620
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2621
- */
2622
- /** @type {?} */
2623
- var DIALOG_INTERACTION_SERVICE_DEFAULTS = new InjectionToken('DIALOG_INTERACTION_SERVICE_DEFAULTS');
2624
- var DialogInteractionService = /** @class */ (function (_super) {
2625
- __extends(DialogInteractionService, _super);
2626
- function DialogInteractionService(dialogService, dialogServiceDefaults, matDialogDefaultConfig) {
2627
- var _this = _super.call(this) || this;
2628
- _this.dialogService = dialogService;
2629
- _this.dialogServiceDefaults = dialogServiceDefaults;
2630
- _this.matDialogDefaultConfig = matDialogDefaultConfig;
2631
- _this._activeInteractionContextModel = new MutableValueModel();
2632
- assert$1.notNil(dialogService);
2633
- var _a = Dsl.disposeWith(_this), chain = _a.chain, valueOf = _a.valueOf, before = _a.before, when = _a.when, after = _a.after, observe = _a.observe, switchOn = _a.switchOn;
2634
- _this.active = chain(_this._activeInteractionContextModel).isNotNil();
2635
- return _this;
2636
- }
2637
- /**
2638
- * @param {?} disposable
2639
- * @return {?}
2640
- */
2641
- DialogInteractionService.prototype.createInteractionContextFor = /**
2642
- * @param {?} disposable
2643
- * @return {?}
2644
- */
2645
- function (disposable) {
2646
- return disposable.registerDisposable(this._createInteractionContext());
2647
- };
2648
- /**
2649
- * @return {?}
2650
- */
2651
- DialogInteractionService.prototype._createInteractionContext = /**
2652
- * @return {?}
2653
- */
2654
- function () {
2655
- /** @type {?} */
2656
- var config = __assign({ autoFocus: false, hasBackdrop: true, closeOnNavigation: false }, this.matDialogDefaultConfig, this.dialogServiceDefaults);
2657
- /** @type {?} */
2658
- var self = this;
2659
- /** @type {?} */
2660
- var dialogInteractionContext = new DialogInteractionContext(this.dialogService, config);
2661
- dialogInteractionContext.registerDisposable(dialogInteractionContext.addActivityListener({
2662
- onActivityStarted: /**
2663
- * @return {?}
2664
- */
2665
- function () {
2666
- self.onActivityStarted(dialogInteractionContext);
2667
- },
2668
- onActivityFinished: /**
2669
- * @return {?}
2670
- */
2671
- function () {
2672
- self.onActivityFinished(dialogInteractionContext);
2673
- }
2674
- }));
2675
- return dialogInteractionContext;
2676
- };
2677
- /**
2678
- * @return {?}
2679
- */
2680
- DialogInteractionService.prototype.createExclusiveInteractionContext = /**
2681
- * @return {?}
2682
- */
2683
- function () {
2684
- this.exclusiveContext = this._createInteractionContext();
2685
- /** @type {?} */
2686
- var self = this;
2687
- this.exclusiveContext.registerDisposable({
2688
- dispose: /**
2689
- * @return {?}
2690
- */
2691
- function () {
2692
- self.exclusiveContext = null;
2693
- }
2694
- });
2695
- return this.exclusiveContext;
2696
- };
2697
- // @Trace()
2698
- // @Trace()
2699
- /**
2700
- * @param {?} dialogInteractionContext
2701
- * @return {?}
2702
- */
2703
- DialogInteractionService.prototype.onActivityStarted =
2704
- // @Trace()
2705
- /**
2706
- * @param {?} dialogInteractionContext
2707
- * @return {?}
2708
- */
2709
- function (dialogInteractionContext) {
2710
- assert$1.isFalsey(this.isActive());
2711
- if (this.exclusiveContext && dialogInteractionContext !== this.exclusiveContext) {
2712
- lang.illegalState("Interaction started while exclusive lock active. This is usually because you using a different context during place.canDeactivate(interactionContext)");
2713
- }
2714
- this._activeInteractionContextModel.value = dialogInteractionContext;
2715
- this.notifyActivityStarted();
2716
- };
2717
- // @Trace()
2718
- // @Trace()
2719
- /**
2720
- * @param {?} dialogInteractionContext
2721
- * @return {?}
2722
- */
2723
- DialogInteractionService.prototype.onActivityFinished =
2724
- // @Trace()
2725
- /**
2726
- * @param {?} dialogInteractionContext
2727
- * @return {?}
2728
- */
2729
- function (dialogInteractionContext) {
2730
- assert$1.isTruthy(this._activeInteractionContextModel.value === dialogInteractionContext);
2731
- this._activeInteractionContextModel.value = null;
2732
- this.notifyActivityFinished();
2733
- };
2734
- /**
2735
- * @return {?}
2736
- */
2737
- DialogInteractionService.prototype.getCurrentActivity = /**
2738
- * @return {?}
2739
- */
2740
- function () {
2741
- return __awaiter(this, void 0, void 0, function () {
2742
- return __generator(this, function (_a) {
2743
- assert$1.isTruthy(this.isActive());
2744
- return [2 /*return*/, this._activeInteractionContextModel.value.getCurrentActivity()];
2745
- });
2746
- });
2747
- };
2748
- DialogInteractionService.decorators = [
2749
- { type: Injectable, args: [{
2750
- providedIn: 'root'
2751
- },] }
2752
- ];
2753
- /** @nocollapse */
2754
- DialogInteractionService.ctorParameters = function () { return [
2755
- { type: MatDialog },
2756
- { type: MatDialogConfig, decorators: [{ type: Optional }, { type: Inject, args: [DIALOG_INTERACTION_SERVICE_DEFAULTS,] }] },
2757
- { type: MatDialogConfig, decorators: [{ type: Optional }, { type: Inject, args: [MAT_DIALOG_DEFAULT_OPTIONS,] }] }
2758
- ]; };
2759
- /** @nocollapse */ DialogInteractionService.ngInjectableDef = ɵɵdefineInjectable({ factory: function DialogInteractionService_Factory() { return new DialogInteractionService(ɵɵinject(MatDialog$1), ɵɵinject(DIALOG_INTERACTION_SERVICE_DEFAULTS, 8), ɵɵinject(MAT_DIALOG_DEFAULT_OPTIONS, 8)); }, token: DialogInteractionService, providedIn: "root" });
2760
- return DialogInteractionService;
2761
- }(ModalInteractionService));
2762
- if (false) {
2763
- /**
2764
- * @type {?}
2765
- * @private
2766
- */
2767
- DialogInteractionService.prototype._activeInteractionContextModel;
2768
- /** @type {?} */
2769
- DialogInteractionService.prototype.active;
2770
- /**
2771
- * @type {?}
2772
- * @private
2773
- */
2774
- DialogInteractionService.prototype.exclusiveContext;
2775
- /**
2776
- * @type {?}
2777
- * @private
2778
- */
2779
- DialogInteractionService.prototype.dialogService;
2780
- /** @type {?} */
2781
- DialogInteractionService.prototype.dialogServiceDefaults;
2782
- /** @type {?} */
2783
- DialogInteractionService.prototype.matDialogDefaultConfig;
2784
- }
2785
-
2786
- /**
2787
- * @fileoverview added by tsickle
2788
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2789
- */
2790
- var InteractionModule = /** @class */ (function () {
2791
- function InteractionModule() {
2547
+ var InteractionModule = /** @class */ (function () {
2548
+ function InteractionModule() {
2792
2549
  }
2793
2550
  InteractionModule.decorators = [
2794
2551
  { type: NgModule, args: [{
@@ -2822,7 +2579,7 @@ var InteractionModule = /** @class */ (function () {
2822
2579
  AlertDialogComponent
2823
2580
  ],
2824
2581
  providers: [
2825
- DialogInteractionService,
2582
+ InteractionService,
2826
2583
  ]
2827
2584
  },] }
2828
2585
  ];
@@ -3831,67 +3588,33 @@ var PlaceComponentDeactivationHandler = /** @class */ (function () {
3831
3588
  * @return {?}
3832
3589
  */
3833
3590
  function (nextState) {
3834
- return __awaiter(this, void 0, void 0, function () {
3835
- return __generator(this, function (_a) {
3836
- // Automatically cancel any active activities if the navigation session was triggered
3837
- // by the back button.
3838
- if (this.navigationSession.isPopState && this.component.interactionContext && this.component.interactionContext.isActive()) {
3839
- // Note: any modal interactions run in a different router outlet so we should never get place deactivated while
3840
- // one is active. This is because:
3841
- // 1. the user can't click anything to navigate away
3842
- // 2. clicking the back button will only change the outlet route and will leave the component route alone. This
3843
- // is all handled by the InteractionGuard and so the component guards will never run.
3844
- // TODO: how will I handle this now??
3845
- // BUT: activities could call navigate while they're still active.. but we'll barf and tell them
3846
- // to call activity.done(newVisitToNavigateTo) and let the caller do the navigate after the
3847
- // dialog has closed.
3848
- // Can I capture this in placeRouter.navigate(..) ? i.e. navigationSession && navigationSession.interactionContext.isActive()
3849
- // Or can I just ignore it altogether?
3850
- // 1. I no longer have a singleton dialog interaction that can be returned from any component in the deactivation cycle.
3851
- // 2. We only ever check the component once per nav cycle
3852
- // 3. The navigation session interaction context will barf if multiple components try and use it at once.
3853
- // if (this.component.interactionContext instanceof DialogInteractionContext) {
3854
- // // BUT: activities could call navigate while they're still active.. but we'll barf and tell them
3855
- // // to call activity.done(newVisitToNavigateTo) and let the caller do the navigate after the
3856
- // // dialog has closed.
3857
- // lang.illegalState('Navigation started from an activity in a modal dialog. Have your activity return a Visit instead and navigate after the activity has finished');
3858
- // }
3859
- // Now we just cancel the current activity and stay where we are
3860
- this.cancelCurrentActivityOf(this.component.interactionContext);
3861
- return [2 /*return*/, false];
3862
- }
3863
- // Ok, so now we're really leaving, so we ask the component if we should.;
3864
- if (this.isNotJustAChangeInRouteId(nextState) && this.component.canDeactivate) {
3865
- // No interaction in progress, so ask the component .
3866
- // This may start an interaction, hence checking the interaction context before now. I.e. if the place pops up the dialog, and
3867
- // the user clicks back again, we'll re-enter here and go bang when the component tries to open another dialog.
3868
- return [2 /*return*/, this.component.canDeactivate(this.navigationSession.interactionContext)];
3869
- }
3870
- return [2 /*return*/, true];
3871
- });
3872
- });
3873
- };
3874
- /**
3875
- * @protected
3876
- * @param {?} interactionContext
3877
- * @return {?}
3878
- */
3879
- PlaceComponentDeactivationHandler.prototype.cancelCurrentActivityOf = /**
3880
- * @protected
3881
- * @param {?} interactionContext
3882
- * @return {?}
3883
- */
3884
- function (interactionContext) {
3885
3591
  return __awaiter(this, void 0, void 0, function () {
3886
3592
  var activity;
3887
3593
  return __generator(this, function (_a) {
3888
3594
  switch (_a.label) {
3889
- case 0: return [4 /*yield*/, interactionContext.getCurrentActivity()];
3595
+ case 0:
3596
+ if (!(this.navigationSession.isPopState && this.component.interactionContext && this.component.interactionContext.isActive())) return [3 /*break*/, 2];
3597
+ // Note: Modal interactions are run in a different router outlet so we never get place deactivating while
3598
+ // a model interaction is active. This is because:
3599
+ // 1. the user can't click anything to navigate away
3600
+ // 2. clicking the back button will only change the outlet route portion of the URL. This
3601
+ // is all handled by the InteractionGuard and so the component guards will never run.
3602
+ //
3603
+ // Now we just cancel the current activity...
3604
+ return [4 /*yield*/, this.component.interactionContext.getCurrentActivity()];
3890
3605
  case 1:
3891
3606
  activity = _a.sent();
3892
- console.log('cancelling', { activity: activity });
3893
3607
  activity.cancel(null);
3894
- return [2 /*return*/];
3608
+ return [2 /*return*/, false]; // ..and stay where we are.
3609
+ case 2:
3610
+ // Ok, so now we're really leaving, so we ask the component if we should.;
3611
+ if (this.isNotJustAChangeInRouteId(nextState) && this.component.canDeactivate) {
3612
+ // No interaction in progress, so ask the component .
3613
+ // This may start an interaction, hence checking the interaction context before now. I.e. if the place pops up the dialog, and
3614
+ // the user clicks back again, we'll re-enter here and go bang when the component tries to open another dialog.
3615
+ return [2 /*return*/, this.component.canDeactivate(this.navigationSession.interactionContext)];
3616
+ }
3617
+ return [2 /*return*/, true];
3895
3618
  }
3896
3619
  });
3897
3620
  });
@@ -3933,15 +3656,48 @@ if (false) {
3933
3656
  /**
3934
3657
  * @abstract
3935
3658
  */
3936
- var NavigationSession = /** @class */ (function (_super) {
3937
- __extends(NavigationSession, _super);
3938
- function NavigationSession(context) {
3659
+ var /**
3660
+ * @abstract
3661
+ */
3662
+ NavigationState = /** @class */ (function (_super) {
3663
+ __extends(NavigationState, _super);
3664
+ function NavigationState(context) {
3939
3665
  var _this = _super.call(this) || this;
3940
3666
  _this.context = context;
3941
3667
  _this._visits = new Map();
3942
3668
  return _this;
3943
3669
  }
3944
- Object.defineProperty(NavigationSession.prototype, "interactionContext", {
3670
+ Object.defineProperty(NavigationState.prototype, "idle", {
3671
+ get: /**
3672
+ * @return {?}
3673
+ */
3674
+ function () {
3675
+ return !this.isTransitional;
3676
+ },
3677
+ enumerable: true,
3678
+ configurable: true
3679
+ });
3680
+ Object.defineProperty(NavigationState.prototype, "placeRouter", {
3681
+ get: /**
3682
+ * @return {?}
3683
+ */
3684
+ function () {
3685
+ return this.context.placeRouter;
3686
+ },
3687
+ enumerable: true,
3688
+ configurable: true
3689
+ });
3690
+ Object.defineProperty(NavigationState.prototype, "interactionService", {
3691
+ get: /**
3692
+ * @return {?}
3693
+ */
3694
+ function () {
3695
+ return this.context.interactionService;
3696
+ },
3697
+ enumerable: true,
3698
+ configurable: true
3699
+ });
3700
+ Object.defineProperty(NavigationState.prototype, "interactionContext", {
3945
3701
  get: /**
3946
3702
  * @return {?}
3947
3703
  */
@@ -3955,7 +3711,7 @@ var NavigationSession = /** @class */ (function (_super) {
3955
3711
  * @param {?} visit
3956
3712
  * @return {?}
3957
3713
  */
3958
- NavigationSession.prototype.storeVisit = /**
3714
+ NavigationState.prototype.storeVisit = /**
3959
3715
  * @param {?} visit
3960
3716
  * @return {?}
3961
3717
  */
@@ -3966,28 +3722,100 @@ var NavigationSession = /** @class */ (function (_super) {
3966
3722
  * @param {?} placeDef
3967
3723
  * @return {?}
3968
3724
  */
3969
- NavigationSession.prototype.getVisitFor = /**
3970
- * @param {?} placeDef
3725
+ NavigationState.prototype.getVisitFor = /**
3726
+ * @param {?} placeDef
3727
+ * @return {?}
3728
+ */
3729
+ function (placeDef) {
3730
+ return this._visits.get(placeDef);
3731
+ };
3732
+ /**
3733
+ * @param {?} event
3734
+ * @return {?}
3735
+ */
3736
+ NavigationState.prototype.onPopState = /**
3737
+ * @param {?} event
3738
+ * @return {?}
3739
+ */
3740
+ function (event) {
3741
+ return this.illegalTransition(event);
3742
+ };
3743
+ /**
3744
+ * @param {?} event
3745
+ * @return {?}
3746
+ */
3747
+ NavigationState.prototype.onStart = /**
3748
+ * @param {?} event
3749
+ * @return {?}
3750
+ */
3751
+ function (event) {
3752
+ return this.illegalTransition(event);
3753
+ };
3754
+ /**
3755
+ * @param {?} event
3756
+ * @return {?}
3757
+ */
3758
+ NavigationState.prototype.onCancel = /**
3759
+ * @param {?} event
3760
+ * @return {?}
3761
+ */
3762
+ function (event) {
3763
+ return this.illegalTransition(event);
3764
+ };
3765
+ /**
3766
+ * @param {?} event
3767
+ * @return {?}
3768
+ */
3769
+ NavigationState.prototype.onError = /**
3770
+ * @param {?} event
3771
+ * @return {?}
3772
+ */
3773
+ function (event) {
3774
+ return this.illegalTransition(event);
3775
+ };
3776
+ /**
3777
+ * @param {?} event
3778
+ * @return {?}
3779
+ */
3780
+ NavigationState.prototype.onEnd = /**
3781
+ * @param {?} event
3971
3782
  * @return {?}
3972
3783
  */
3973
- function (placeDef) {
3974
- return this._visits.get(placeDef);
3784
+ function (event) {
3785
+ return this.illegalTransition(event);
3975
3786
  };
3976
3787
  /**
3977
3788
  * @param {?} newUrl
3978
3789
  * @return {?}
3979
3790
  */
3980
- NavigationSession.prototype.onBackClickedDuringNavigationInteraction = /**
3791
+ NavigationState.prototype.onBackClickedDuringNavigationInteraction = /**
3981
3792
  * @param {?} newUrl
3982
3793
  * @return {?}
3983
3794
  */
3984
3795
  function (newUrl) {
3985
3796
  return this.illegalTransition('onBackClickedDuringNavigationInteraction');
3986
3797
  };
3798
+ /**
3799
+ * @param {?} component
3800
+ * @param {?} nextState
3801
+ * @return {?}
3802
+ */
3803
+ NavigationState.prototype.canDeactivatePlace = /**
3804
+ * @param {?} component
3805
+ * @param {?} nextState
3806
+ * @return {?}
3807
+ */
3808
+ function (component, nextState) {
3809
+ return __awaiter(this, void 0, void 0, function () {
3810
+ return __generator(this, function (_a) {
3811
+ return [2 /*return*/, this.illegalTransition('canDeactivatePlace')];
3812
+ });
3813
+ });
3814
+ };
3987
3815
  /**
3988
3816
  * @return {?}
3989
3817
  */
3990
- NavigationSession.prototype.getVisits = /**
3818
+ NavigationState.prototype.getVisits = /**
3991
3819
  * @return {?}
3992
3820
  */
3993
3821
  function () {
@@ -3999,7 +3827,7 @@ var NavigationSession = /** @class */ (function (_super) {
3999
3827
  * @param {?} message
4000
3828
  * @return {?}
4001
3829
  */
4002
- NavigationSession.prototype.illegalTransition = /**
3830
+ NavigationState.prototype.illegalTransition = /**
4003
3831
  * @protected
4004
3832
  * @template R
4005
3833
  * @param {?} message
@@ -4012,124 +3840,91 @@ var NavigationSession = /** @class */ (function (_super) {
4012
3840
  * @protected
4013
3841
  * @return {?}
4014
3842
  */
4015
- NavigationSession.prototype.currentRouterUrl = /**
3843
+ NavigationState.prototype.currentRouterUrl = /**
4016
3844
  * @protected
4017
3845
  * @return {?}
4018
3846
  */
4019
3847
  function () {
4020
- return this.context.router.routerState ? this.context.router.routerState.snapshot.url : null;
3848
+ return this.placeRouter.getCurrentRouterUrl();
4021
3849
  };
4022
3850
  /**
4023
3851
  * @protected
4024
3852
  * @param {?} event
4025
3853
  * @return {?}
4026
3854
  */
4027
- NavigationSession.prototype.createActiveSession = /**
3855
+ NavigationState.prototype.createTransitionStateFor = /**
4028
3856
  * @protected
4029
3857
  * @param {?} event
4030
3858
  * @return {?}
4031
3859
  */
4032
3860
  function (event) {
4033
3861
  // TODO: check if the event is purely for interaction context changes.
4034
- return new NavigationSession.Active(this.context, event.navigationTrigger === 'popstate', this.currentRouterUrl());
3862
+ /** @type {?} */
3863
+ var popstate = event.navigationTrigger === 'popstate';
3864
+ return popstate ?
3865
+ new NavigationState.NavigationBackTransition(this.context, popstate, this.currentRouterUrl()) :
3866
+ new NavigationState.NavigationTransition(this.context, popstate, this.currentRouterUrl());
4035
3867
  };
4036
3868
  /**
4037
- * @protected
4038
3869
  * @param {?} url
4039
3870
  * @return {?}
4040
3871
  */
4041
- NavigationSession.prototype.updateLocation = /**
4042
- * @protected
3872
+ NavigationState.prototype.resetBrowserLocation = /**
4043
3873
  * @param {?} url
4044
3874
  * @return {?}
4045
3875
  */
4046
3876
  function (url) {
4047
- this.context.angularLocation.go(url);
3877
+ var _this = this;
3878
+ // TODO: Should this be a navigate operation to avoid confusing the router...??
3879
+ setTimeout((/**
3880
+ * @return {?}
3881
+ */
3882
+ function () { return _this.placeRouter.resetBrowserLocation(url); }));
4048
3883
  };
4049
3884
  /**
4050
3885
  * @return {?}
4051
3886
  */
4052
- NavigationSession.prototype.toString = /**
3887
+ NavigationState.prototype.toString = /**
4053
3888
  * @return {?}
4054
3889
  */
4055
3890
  function () {
4056
3891
  return this.constructor.name;
4057
3892
  };
4058
- __decorate([
4059
- Trace(),
4060
- __metadata("design:type", Function),
4061
- __metadata("design:paramtypes", [Object]),
4062
- __metadata("design:returntype", void 0)
4063
- ], NavigationSession.prototype, "updateLocation", null);
4064
- return NavigationSession;
3893
+ return NavigationState;
4065
3894
  }(GarbageCollector));
4066
3895
  if (false) {
4067
3896
  /**
4068
3897
  * @type {?}
4069
3898
  * @private
4070
3899
  */
4071
- NavigationSession.prototype._visits;
3900
+ NavigationState.prototype._visits;
4072
3901
  /** @type {?} */
4073
- NavigationSession.prototype.isPopState;
3902
+ NavigationState.prototype.isTransitional;
4074
3903
  /** @type {?} */
4075
- NavigationSession.prototype.active;
3904
+ NavigationState.prototype.startingUrl;
4076
3905
  /** @type {?} */
4077
- NavigationSession.prototype.startingUrl;
3906
+ NavigationState.prototype.isPopState;
4078
3907
  /**
4079
3908
  * @type {?}
4080
3909
  * @protected
4081
3910
  */
4082
- NavigationSession.prototype.context;
4083
- /**
4084
- * @abstract
4085
- * @param {?} event
4086
- * @return {?}
4087
- */
4088
- NavigationSession.prototype.onStart = function (event) { };
4089
- /**
4090
- * @abstract
4091
- * @param {?} event
4092
- * @return {?}
4093
- */
4094
- NavigationSession.prototype.onCancel = function (event) { };
4095
- /**
4096
- * @abstract
4097
- * @param {?} event
4098
- * @return {?}
4099
- */
4100
- NavigationSession.prototype.onError = function (event) { };
4101
- /**
4102
- * @abstract
4103
- * @param {?} event
4104
- * @return {?}
4105
- */
4106
- NavigationSession.prototype.onEnd = function (event) { };
4107
- /**
4108
- * @abstract
4109
- * @param {?} component
4110
- * @param {?} nextState
4111
- * @return {?}
4112
- */
4113
- NavigationSession.prototype.canDeactivatePlace = function (component, nextState) { };
3911
+ NavigationState.prototype.context;
4114
3912
  }
4115
- (function (NavigationSession) {
3913
+ (function (NavigationState) {
4116
3914
  var Context = /** @class */ (function () {
4117
- function Context(router, modalInteractionService, angularLocation, notifySuccess) {
4118
- this.router = router;
4119
- this.modalInteractionService = modalInteractionService;
4120
- this.angularLocation = angularLocation;
3915
+ function Context(placeRouter, interactionService, notifySuccess) {
3916
+ this.placeRouter = placeRouter;
3917
+ this.interactionService = interactionService;
4121
3918
  this.notifySuccess = notifySuccess;
4122
3919
  }
4123
3920
  return Context;
4124
3921
  }());
4125
- NavigationSession.Context = Context;
3922
+ NavigationState.Context = Context;
4126
3923
  if (false) {
4127
3924
  /** @type {?} */
4128
- Context.prototype.router;
4129
- /** @type {?} */
4130
- Context.prototype.modalInteractionService;
3925
+ Context.prototype.placeRouter;
4131
3926
  /** @type {?} */
4132
- Context.prototype.angularLocation;
3927
+ Context.prototype.interactionService;
4133
3928
  /** @type {?} */
4134
3929
  Context.prototype.notifySuccess;
4135
3930
  }
@@ -4137,27 +3932,11 @@ if (false) {
4137
3932
  __extends(Idle, _super);
4138
3933
  function Idle(context) {
4139
3934
  var _this = _super.call(this, context) || this;
4140
- _this.active = false;
3935
+ _this.isTransitional = false;
4141
3936
  _this.startingUrl = null;
3937
+ _this.isPopState = false;
4142
3938
  return _this;
4143
3939
  }
4144
- /**
4145
- * @param {?} component
4146
- * @param {?} nextState
4147
- * @return {?}
4148
- */
4149
- Idle.prototype.canDeactivatePlace = /**
4150
- * @param {?} component
4151
- * @param {?} nextState
4152
- * @return {?}
4153
- */
4154
- function (component, nextState) {
4155
- return __awaiter(this, void 0, void 0, function () {
4156
- return __generator(this, function (_a) {
4157
- return [2 /*return*/, this.illegalTransition('canDeactivatePlace')];
4158
- });
4159
- });
4160
- };
4161
3940
  /**
4162
3941
  * @param {?} event
4163
3942
  * @return {?}
@@ -4172,65 +3951,51 @@ if (false) {
4172
3951
  Logger.get(this).info("navigation started to same url -> " + event.url);
4173
3952
  return this;
4174
3953
  }
4175
- if (event.url === (this.currentRouterUrl() + "(aup-interaction:modal)")) {
3954
+ if (this.placeRouter.hasActiveInteractionIds(event.url)) {
4176
3955
  Logger.get(this).info("navigation started with interaction outlet -> " + event.url);
4177
- return new ModalInteractionSession(this.context, event.url);
3956
+ return new InteractionTransition(this.context, event.url);
3957
+ }
3958
+ else {
3959
+ return this.createTransitionStateFor(event);
4178
3960
  }
4179
- return this.createActiveSession(event);
4180
- };
4181
- /**
4182
- * @param {?} event
4183
- * @return {?}
4184
- */
4185
- Idle.prototype.onCancel = /**
4186
- * @param {?} event
4187
- * @return {?}
4188
- */
4189
- function (event) {
4190
- return this.illegalTransition(event);
4191
- };
4192
- /**
4193
- * @param {?} event
4194
- * @return {?}
4195
- */
4196
- Idle.prototype.onEnd = /**
4197
- * @param {?} event
4198
- * @return {?}
4199
- */
4200
- function (event) {
4201
- return this.illegalTransition(event);
4202
3961
  };
4203
3962
  /**
4204
3963
  * @param {?} event
4205
3964
  * @return {?}
4206
3965
  */
4207
- Idle.prototype.onError = /**
3966
+ Idle.prototype.onPopState = /**
4208
3967
  * @param {?} event
4209
3968
  * @return {?}
4210
3969
  */
4211
3970
  function (event) {
4212
- return this.illegalTransition(event);
3971
+ return this.createTransitionStateFor(event);
4213
3972
  };
4214
3973
  return Idle;
4215
- }(NavigationSession));
4216
- NavigationSession.Idle = Idle;
3974
+ }(NavigationState));
3975
+ NavigationState.Idle = Idle;
4217
3976
  if (false) {
4218
3977
  /** @type {?} */
4219
- Idle.prototype.isPopState;
4220
- /** @type {?} */
4221
- Idle.prototype.active;
3978
+ Idle.prototype.isTransitional;
4222
3979
  /** @type {?} */
4223
3980
  Idle.prototype.startingUrl;
3981
+ /** @type {?} */
3982
+ Idle.prototype.isPopState;
4224
3983
  }
4225
- var Active = /** @class */ (function (_super) {
4226
- __extends(Active, _super);
4227
- function Active(context, isPopState, startingUrl) {
3984
+ /**
3985
+ * @abstract
3986
+ */
3987
+ var /**
3988
+ * @abstract
3989
+ */
3990
+ AbstractNavigationTransition = /** @class */ (function (_super) {
3991
+ __extends(AbstractNavigationTransition, _super);
3992
+ function AbstractNavigationTransition(context, isPopState, startingUrl) {
4228
3993
  var _this = _super.call(this, context) || this;
4229
3994
  _this.isPopState = isPopState;
4230
3995
  _this.startingUrl = startingUrl;
4231
- _this.active = true;
3996
+ _this.isTransitional = true;
4232
3997
  _this.componentDeactivationHandlers = new Map();
4233
- _this._interactionContext = _this.context.modalInteractionService.createExclusiveInteractionContext();
3998
+ _this._interactionContext = _this.interactionService._createExclusiveModalInteractionContext();
4234
3999
  _this.onDispose((/**
4235
4000
  * @return {?}
4236
4001
  */
@@ -4238,14 +4003,14 @@ if (false) {
4238
4003
  // the interaction context can be detached during the back button cancellation state transition
4239
4004
  // as the transition is synchronous and activityCancellation isn't. Otherwise dispose will be
4240
4005
  // called before the context has been cancelled. It might be work having the interaction context
4241
- // automatically cancel if the context is disposed.
4006
+ // automatically cancel if the context is disposed so we don't have worry about detaching etc.
4242
4007
  if (_this._interactionContext) {
4243
- _this._interactionContext.dispose();
4008
+ _this._interactionContext.dispose(); // or do something like cancelAndDispose?
4244
4009
  }
4245
4010
  }));
4246
4011
  return _this;
4247
4012
  }
4248
- Object.defineProperty(Active.prototype, "interactionContext", {
4013
+ Object.defineProperty(AbstractNavigationTransition.prototype, "interactionContext", {
4249
4014
  get: /**
4250
4015
  * @return {?}
4251
4016
  */
@@ -4259,19 +4024,20 @@ if (false) {
4259
4024
  * @param {?} event
4260
4025
  * @return {?}
4261
4026
  */
4262
- Active.prototype.onStart = /**
4027
+ AbstractNavigationTransition.prototype.onStart = /**
4263
4028
  * @param {?} event
4264
4029
  * @return {?}
4265
4030
  */
4266
4031
  function (event) {
4267
- // active sessions can have many cancel start cycles.
4032
+ // active sessions can have many cancel start cycles due
4033
+ // to place guard redirects
4268
4034
  return this;
4269
4035
  };
4270
4036
  /**
4271
4037
  * @param {?} event
4272
4038
  * @return {?}
4273
4039
  */
4274
- Active.prototype.onEnd = /**
4040
+ AbstractNavigationTransition.prototype.onEnd = /**
4275
4041
  * @param {?} event
4276
4042
  * @return {?}
4277
4043
  */
@@ -4280,65 +4046,31 @@ if (false) {
4280
4046
  this.context.notifySuccess(this);
4281
4047
  return new Idle(this.context);
4282
4048
  };
4283
- /**
4284
- * @param {?} event
4285
- * @return {?}
4286
- */
4287
- Active.prototype.onCancel = /**
4288
- * @param {?} event
4289
- * @return {?}
4290
- */
4291
- function (event) {
4292
- // active sessions can have many cancel start cycles.
4293
- return this;
4294
- };
4295
- /**
4296
- * @param {?} event
4297
- * @return {?}
4298
- */
4299
- Active.prototype.onError = /**
4300
- * @param {?} event
4301
- * @return {?}
4302
- */
4303
- function (event) {
4304
- // navigation was aborted.
4305
- if (this.isPopState && this.currentRouterUrl() !== this.startingUrl) {
4306
- // Angular doesn't preserve the url when a guard cancels the back button.
4307
- // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
4308
- Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
4309
- this.updateLocation(this.startingUrl);
4310
- }
4311
- return new Idle(this.context);
4312
- };
4313
4049
  /**
4314
4050
  * @param {?} locationTriggerUrl
4315
4051
  * @return {?}
4316
4052
  */
4317
- Active.prototype.onBackClickedDuringNavigationInteraction = /**
4053
+ AbstractNavigationTransition.prototype.onBackClickedDuringNavigationInteraction = /**
4318
4054
  * @param {?} locationTriggerUrl
4319
4055
  * @return {?}
4320
4056
  */
4321
4057
  function (locationTriggerUrl) {
4058
+ // detach the interactoin from the session so it doesn't get disposed until the activity
4059
+ // has completed.
4322
4060
  /** @type {?} */
4323
4061
  var context = this.detachInteractionContext();
4062
+ var when = Dsl.disposeWith(context).when;
4063
+ // TODO: I need to make the exclusive interaction context disallow nested activities or
4064
+ // that would mess things up entirely.
4324
4065
  context.getCurrentActivity().then((/**
4325
4066
  * @param {?} activity
4326
4067
  * @return {?}
4327
4068
  */
4328
4069
  function (activity) {
4329
- context.addActivityListener({
4330
- onActivityFinished: /**
4331
- * @return {?}
4332
- */
4333
- function () {
4334
- context.dispose();
4335
- },
4336
- onActivityStarted: /**
4337
- * @return {?}
4338
- */
4339
- function () {
4340
- }
4341
- });
4070
+ when.valueOf(context.active).becomesFalsey((/**
4071
+ * @return {?}
4072
+ */
4073
+ function () { return context.dispose(); }), { once: true });
4342
4074
  activity.cancel(null);
4343
4075
  }));
4344
4076
  return new CancelledDuringNavigationInteraction(this.context, this.startingUrl, locationTriggerUrl);
@@ -4348,7 +4080,7 @@ if (false) {
4348
4080
  * @param {?} nextState
4349
4081
  * @return {?}
4350
4082
  */
4351
- Active.prototype.canDeactivatePlace = /**
4083
+ AbstractNavigationTransition.prototype.canDeactivatePlace = /**
4352
4084
  * @param {?} component
4353
4085
  * @param {?} nextState
4354
4086
  * @return {?}
@@ -4372,7 +4104,7 @@ if (false) {
4372
4104
  * @private
4373
4105
  * @return {?}
4374
4106
  */
4375
- Active.prototype.detachInteractionContext = /**
4107
+ AbstractNavigationTransition.prototype.detachInteractionContext = /**
4376
4108
  * @private
4377
4109
  * @return {?}
4378
4110
  */
@@ -4382,162 +4114,304 @@ if (false) {
4382
4114
  this._interactionContext = null;
4383
4115
  return context;
4384
4116
  };
4117
+ return AbstractNavigationTransition;
4118
+ }(NavigationState));
4119
+ NavigationState.AbstractNavigationTransition = AbstractNavigationTransition;
4120
+ if (false) {
4121
+ /** @type {?} */
4122
+ AbstractNavigationTransition.prototype.isTransitional;
4123
+ /**
4124
+ * @type {?}
4125
+ * @private
4126
+ */
4127
+ AbstractNavigationTransition.prototype.componentDeactivationHandlers;
4128
+ /**
4129
+ * @type {?}
4130
+ * @private
4131
+ */
4132
+ AbstractNavigationTransition.prototype._interactionContext;
4133
+ /** @type {?} */
4134
+ AbstractNavigationTransition.prototype.isPopState;
4135
+ /** @type {?} */
4136
+ AbstractNavigationTransition.prototype.startingUrl;
4137
+ }
4138
+ var NavigationTransition = /** @class */ (function (_super) {
4139
+ __extends(NavigationTransition, _super);
4140
+ function NavigationTransition() {
4141
+ var _this = _super !== null && _super.apply(this, arguments) || this;
4142
+ _this.isPopState = false;
4143
+ return _this;
4144
+ }
4145
+ /**
4146
+ * @param {?} event
4147
+ * @return {?}
4148
+ */
4149
+ NavigationTransition.prototype.onStart = /**
4150
+ * @param {?} event
4151
+ * @return {?}
4152
+ */
4153
+ function (event) {
4154
+ // active sessions can have many cancel start cycles due
4155
+ // to place guard redirects
4156
+ return this;
4157
+ };
4158
+ /**
4159
+ * @param {?} event
4160
+ * @return {?}
4161
+ */
4162
+ NavigationTransition.prototype.onEnd = /**
4163
+ * @param {?} event
4164
+ * @return {?}
4165
+ */
4166
+ function (event) {
4167
+ // navigation succeeded
4168
+ this.context.notifySuccess(this);
4169
+ return new Idle(this.context);
4170
+ };
4171
+ /**
4172
+ * @param {?} event
4173
+ * @return {?}
4174
+ */
4175
+ NavigationTransition.prototype.onCancel = /**
4176
+ * @param {?} event
4177
+ * @return {?}
4178
+ */
4179
+ function (event) {
4180
+ return new Idle(this.context);
4181
+ };
4182
+ /**
4183
+ * @param {?} event
4184
+ * @return {?}
4185
+ */
4186
+ NavigationTransition.prototype.onError = /**
4187
+ * @param {?} event
4188
+ * @return {?}
4189
+ */
4190
+ function (event) {
4191
+ // navigation was aborted.
4192
+ return new Idle(this.context);
4193
+ };
4385
4194
  /**
4386
4195
  * @return {?}
4387
4196
  */
4388
- Active.prototype.toString = /**
4197
+ NavigationTransition.prototype.toString = /**
4389
4198
  * @return {?}
4390
4199
  */
4391
4200
  function () {
4392
- return this.constructor.name + "(startingUrl: " + this.startingUrl + ", isPopState:" + this.isPopState + ")";
4201
+ return this.constructor.name + "(startingUrl: " + this.startingUrl + ")";
4393
4202
  };
4394
- return Active;
4395
- }(NavigationSession));
4396
- NavigationSession.Active = Active;
4203
+ return NavigationTransition;
4204
+ }(AbstractNavigationTransition));
4205
+ NavigationState.NavigationTransition = NavigationTransition;
4397
4206
  if (false) {
4398
4207
  /** @type {?} */
4399
- Active.prototype.active;
4208
+ NavigationTransition.prototype.isPopState;
4209
+ }
4210
+ var NavigationBackTransition = /** @class */ (function (_super) {
4211
+ __extends(NavigationBackTransition, _super);
4212
+ function NavigationBackTransition() {
4213
+ var _this = _super !== null && _super.apply(this, arguments) || this;
4214
+ _this.isPopState = true;
4215
+ return _this;
4216
+ }
4400
4217
  /**
4401
- * @type {?}
4402
- * @private
4218
+ * @param {?} event
4219
+ * @return {?}
4220
+ */
4221
+ NavigationBackTransition.prototype.onCancel = /**
4222
+ * @param {?} event
4223
+ * @return {?}
4403
4224
  */
4404
- Active.prototype.componentDeactivationHandlers;
4225
+ function (event) {
4226
+ // Angular doesn't preserve the url when a guard cancels the back button.
4227
+ // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
4228
+ Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
4229
+ this.resetBrowserLocation(this.startingUrl);
4230
+ return new Idle(this.context);
4231
+ };
4405
4232
  /**
4406
- * @type {?}
4407
- * @private
4233
+ * @param {?} event
4234
+ * @return {?}
4408
4235
  */
4409
- Active.prototype._interactionContext;
4410
- /** @type {?} */
4411
- Active.prototype.isPopState;
4236
+ NavigationBackTransition.prototype.onError = /**
4237
+ * @param {?} event
4238
+ * @return {?}
4239
+ */
4240
+ function (event) {
4241
+ // navigation was aborted.
4242
+ if (this.currentRouterUrl() !== this.startingUrl) {
4243
+ // Angular doesn't preserve the url when a guard cancels the back button.
4244
+ // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
4245
+ Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
4246
+ this.resetBrowserLocation(this.startingUrl);
4247
+ }
4248
+ return new Idle(this.context);
4249
+ };
4250
+ return NavigationBackTransition;
4251
+ }(AbstractNavigationTransition));
4252
+ NavigationState.NavigationBackTransition = NavigationBackTransition;
4253
+ if (false) {
4412
4254
  /** @type {?} */
4413
- Active.prototype.startingUrl;
4255
+ NavigationBackTransition.prototype.isPopState;
4414
4256
  }
4415
- var ModalInteractionSession = /** @class */ (function (_super) {
4416
- __extends(ModalInteractionSession, _super);
4417
- function ModalInteractionSession(context, startingUrl) {
4257
+ /**
4258
+ * @abstract
4259
+ */
4260
+ var /**
4261
+ * @abstract
4262
+ */
4263
+ AbstractInteractionTransition = /** @class */ (function (_super) {
4264
+ __extends(AbstractInteractionTransition, _super);
4265
+ function AbstractInteractionTransition(context, startingUrl) {
4418
4266
  var _this = _super.call(this, context) || this;
4419
4267
  _this.startingUrl = startingUrl;
4420
- _this.active = false;
4268
+ _this.isTransitional = true;
4269
+ return _this;
4270
+ }
4271
+ /**
4272
+ * @protected
4273
+ * @return {?}
4274
+ */
4275
+ AbstractInteractionTransition.prototype.reinstateInteractionRoute = /**
4276
+ * @protected
4277
+ * @return {?}
4278
+ */
4279
+ function () {
4280
+ var _this = this;
4281
+ console.log(this.startingUrl);
4282
+ setTimeout((/**
4283
+ * @return {?}
4284
+ */
4285
+ function () { return _this.placeRouter.syncInteractionIdsWithRouter(); }));
4286
+ };
4287
+ return AbstractInteractionTransition;
4288
+ }(NavigationState));
4289
+ NavigationState.AbstractInteractionTransition = AbstractInteractionTransition;
4290
+ if (false) {
4291
+ /** @type {?} */
4292
+ AbstractInteractionTransition.prototype.isTransitional;
4293
+ /** @type {?} */
4294
+ AbstractInteractionTransition.prototype.startingUrl;
4295
+ }
4296
+ /**
4297
+ * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4298
+ * happily ignore interaction contexts.
4299
+ */
4300
+ var /**
4301
+ * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4302
+ * happily ignore interaction contexts.
4303
+ */
4304
+ InteractionTransition = /** @class */ (function (_super) {
4305
+ __extends(InteractionTransition, _super);
4306
+ function InteractionTransition() {
4307
+ var _this = _super !== null && _super.apply(this, arguments) || this;
4421
4308
  _this.isPopState = false;
4422
4309
  return _this;
4423
4310
  }
4424
- /**
4425
- * @param {?} url
4426
- * @return {?}
4427
- */
4428
- ModalInteractionSession.hasInteraction = /**
4429
- * @param {?} url
4430
- * @return {?}
4431
- */
4432
- function (url) {
4433
- return url.endsWith('(aup-interaction:modal)');
4434
- };
4435
4311
  /**
4436
4312
  * @param {?} event
4437
4313
  * @return {?}
4438
4314
  */
4439
- ModalInteractionSession.prototype.onStart = /**
4315
+ InteractionTransition.prototype.onEnd = /**
4440
4316
  * @param {?} event
4441
4317
  * @return {?}
4442
4318
  */
4443
4319
  function (event) {
4444
- // VERY VERY IMPORTANT BACK BUTTON NOTE:
4445
- // When the back button is clicked we'll enter here first, and push the url
4446
- // back to the browser. Angular seems to ignore it from a routing perspective
4447
- // and then the InteractionGuard will cancel the navigation. This process seems
4448
- // to keep the brower history in a sane state.
4449
- if (this.context.modalInteractionService.isActive()) {
4450
- if (!ModalInteractionSession.hasInteraction(event.url)) {
4451
- // this capture the case where
4452
- this.updateLocation(this.startingUrl);
4453
- }
4320
+ if (this.context.interactionService.isActive()) {
4321
+ this.reinstateInteractionRoute();
4322
+ return new IdleDuringInteraction(this.context, this.startingUrl);
4323
+ }
4324
+ else {
4325
+ return new Idle(this.context);
4454
4326
  }
4455
- return this;
4456
- };
4457
- /**
4458
- * @param {?} event
4459
- * @return {?}
4460
- */
4461
- ModalInteractionSession.prototype.onCancel = /**
4462
- * @param {?} event
4463
- * @return {?}
4464
- */
4465
- function (event) {
4466
- // this.updateLocation(this.startingUrl);
4467
- return this;
4468
4327
  };
4328
+ return InteractionTransition;
4329
+ }(AbstractInteractionTransition));
4330
+ NavigationState.InteractionTransition = InteractionTransition;
4331
+ if (false) {
4332
+ /** @type {?} */
4333
+ InteractionTransition.prototype.isPopState;
4334
+ }
4335
+ /**
4336
+ * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4337
+ * happily ignore interaction contexts.
4338
+ */
4339
+ var /**
4340
+ * This state exists to handle all events while any kind of navigation is in progress. That way all other states can
4341
+ * happily ignore interaction contexts.
4342
+ */
4343
+ InteractionBackTransition = /** @class */ (function (_super) {
4344
+ __extends(InteractionBackTransition, _super);
4345
+ function InteractionBackTransition() {
4346
+ var _this = _super !== null && _super.apply(this, arguments) || this;
4347
+ _this.isPopState = true;
4348
+ return _this;
4349
+ }
4469
4350
  /**
4470
4351
  * @param {?} event
4471
4352
  * @return {?}
4472
4353
  */
4473
- ModalInteractionSession.prototype.onEnd = /**
4354
+ InteractionBackTransition.prototype.onEnd = /**
4474
4355
  * @param {?} event
4475
4356
  * @return {?}
4476
4357
  */
4477
4358
  function (event) {
4478
- if (this.context.modalInteractionService.isActive()) {
4479
- return this;
4359
+ if (this.interactionService.isActive()) {
4360
+ this.reinstateInteractionRoute();
4361
+ return new IdleDuringInteraction(this.context, this.startingUrl);
4480
4362
  }
4481
4363
  else {
4482
4364
  return new Idle(this.context);
4483
4365
  }
4484
4366
  };
4367
+ return InteractionBackTransition;
4368
+ }(AbstractInteractionTransition));
4369
+ NavigationState.InteractionBackTransition = InteractionBackTransition;
4370
+ if (false) {
4371
+ /** @type {?} */
4372
+ InteractionBackTransition.prototype.isPopState;
4373
+ }
4374
+ var IdleDuringInteraction = /** @class */ (function (_super) {
4375
+ __extends(IdleDuringInteraction, _super);
4376
+ function IdleDuringInteraction(context, startingUrl) {
4377
+ var _this = _super.call(this, context) || this;
4378
+ _this.startingUrl = startingUrl;
4379
+ _this.isTransitional = false;
4380
+ _this.isPopState = false;
4381
+ return _this;
4382
+ }
4485
4383
  /**
4486
4384
  * @param {?} event
4487
4385
  * @return {?}
4488
4386
  */
4489
- ModalInteractionSession.prototype.onError = /**
4387
+ IdleDuringInteraction.prototype.onStart = /**
4490
4388
  * @param {?} event
4491
4389
  * @return {?}
4492
4390
  */
4493
4391
  function (event) {
4494
- return this.illegalTransition(event);
4392
+ return new InteractionTransition(this.context, event.url);
4495
4393
  };
4496
4394
  /**
4497
- * @param {?} component
4498
- * @param {?} nextState
4395
+ * @param {?} event
4499
4396
  * @return {?}
4500
4397
  */
4501
- ModalInteractionSession.prototype.canDeactivatePlace = /**
4502
- * @param {?} component
4503
- * @param {?} nextState
4398
+ IdleDuringInteraction.prototype.onPopState = /**
4399
+ * @param {?} event
4504
4400
  * @return {?}
4505
4401
  */
4506
- function (component, nextState) {
4507
- return __awaiter(this, void 0, void 0, function () {
4508
- return __generator(this, function (_a) {
4509
- return [2 /*return*/, true];
4510
- });
4511
- });
4402
+ function (event) {
4403
+ return new InteractionBackTransition(this.context, event.url);
4512
4404
  };
4513
- __decorate([
4514
- Trace(),
4515
- __metadata("design:type", Function),
4516
- __metadata("design:paramtypes", [NavigationStart]),
4517
- __metadata("design:returntype", NavigationSession)
4518
- ], ModalInteractionSession.prototype, "onStart", null);
4519
- __decorate([
4520
- Trace(),
4521
- __metadata("design:type", Function),
4522
- __metadata("design:paramtypes", [NavigationCancel]),
4523
- __metadata("design:returntype", NavigationSession)
4524
- ], ModalInteractionSession.prototype, "onCancel", null);
4525
- __decorate([
4526
- Trace(),
4527
- __metadata("design:type", Function),
4528
- __metadata("design:paramtypes", [NavigationEnd]),
4529
- __metadata("design:returntype", NavigationSession)
4530
- ], ModalInteractionSession.prototype, "onEnd", null);
4531
- return ModalInteractionSession;
4532
- }(NavigationSession));
4533
- NavigationSession.ModalInteractionSession = ModalInteractionSession;
4405
+ return IdleDuringInteraction;
4406
+ }(NavigationState));
4407
+ NavigationState.IdleDuringInteraction = IdleDuringInteraction;
4534
4408
  if (false) {
4535
4409
  /** @type {?} */
4536
- ModalInteractionSession.prototype.active;
4410
+ IdleDuringInteraction.prototype.isTransitional;
4537
4411
  /** @type {?} */
4538
- ModalInteractionSession.prototype.isPopState;
4412
+ IdleDuringInteraction.prototype.isPopState;
4539
4413
  /** @type {?} */
4540
- ModalInteractionSession.prototype.startingUrl;
4414
+ IdleDuringInteraction.prototype.startingUrl;
4541
4415
  }
4542
4416
  var CancelledDuringNavigationInteraction = /** @class */ (function (_super) {
4543
4417
  __extends(CancelledDuringNavigationInteraction, _super);
@@ -4545,28 +4419,36 @@ if (false) {
4545
4419
  var _this = _super.call(this, context) || this;
4546
4420
  _this.startingUrl = startingUrl;
4547
4421
  _this.locationChangeTriggerUrl = locationChangeTriggerUrl;
4548
- _this.active = false;
4422
+ _this.isPopState = false;
4549
4423
  _this.capturedFauxRouterStart = false;
4550
4424
  return _this;
4551
- // This will trigger a return to the route we originally started with.
4552
- // this.angularLocation.go(this.startingUrl);
4553
4425
  }
4426
+ Object.defineProperty(CancelledDuringNavigationInteraction.prototype, "isTransitional", {
4427
+ get: /**
4428
+ * @return {?}
4429
+ */
4430
+ function () {
4431
+ return !this.capturedFauxRouterStart;
4432
+ },
4433
+ enumerable: true,
4434
+ configurable: true
4435
+ });
4554
4436
  /**
4555
- * @param {?} component
4556
- * @param {?} nextState
4437
+ * @param {?} event
4557
4438
  * @return {?}
4558
4439
  */
4559
- CancelledDuringNavigationInteraction.prototype.canDeactivatePlace = /**
4560
- * @param {?} component
4561
- * @param {?} nextState
4440
+ CancelledDuringNavigationInteraction.prototype.onStart = /**
4441
+ * @param {?} event
4562
4442
  * @return {?}
4563
4443
  */
4564
- function (component, nextState) {
4565
- return __awaiter(this, void 0, void 0, function () {
4566
- return __generator(this, function (_a) {
4567
- return [2 /*return*/, false];
4568
- });
4569
- });
4444
+ function (event) {
4445
+ if (event.url === this.locationChangeTriggerUrl && !this.capturedFauxRouterStart) {
4446
+ this.capturedFauxRouterStart = true;
4447
+ return this.ignore(event, 'url matched back button location change');
4448
+ }
4449
+ else {
4450
+ return this.createTransitionStateFor(event);
4451
+ }
4570
4452
  };
4571
4453
  /**
4572
4454
  * @param {?} event
@@ -4605,18 +4487,12 @@ if (false) {
4605
4487
  * @param {?} event
4606
4488
  * @return {?}
4607
4489
  */
4608
- CancelledDuringNavigationInteraction.prototype.onStart = /**
4490
+ CancelledDuringNavigationInteraction.prototype.onPopState = /**
4609
4491
  * @param {?} event
4610
4492
  * @return {?}
4611
4493
  */
4612
4494
  function (event) {
4613
- if (event.url === this.locationChangeTriggerUrl && !this.capturedFauxRouterStart) {
4614
- this.capturedFauxRouterStart = true;
4615
- return this.ignore(event, 'url matched back button location change');
4616
- }
4617
- else {
4618
- return this.createActiveSession(event);
4619
- }
4495
+ return this.createTransitionStateFor(event);
4620
4496
  };
4621
4497
  /**
4622
4498
  * @param {?} event
@@ -4643,11 +4519,9 @@ if (false) {
4643
4519
  return this.constructor.name + "(startingUrl: " + this.startingUrl + ", locationChangeTriggerUrl:" + this.locationChangeTriggerUrl + ")";
4644
4520
  };
4645
4521
  return CancelledDuringNavigationInteraction;
4646
- }(NavigationSession));
4647
- NavigationSession.CancelledDuringNavigationInteraction = CancelledDuringNavigationInteraction;
4522
+ }(NavigationState));
4523
+ NavigationState.CancelledDuringNavigationInteraction = CancelledDuringNavigationInteraction;
4648
4524
  if (false) {
4649
- /** @type {?} */
4650
- CancelledDuringNavigationInteraction.prototype.active;
4651
4525
  /** @type {?} */
4652
4526
  CancelledDuringNavigationInteraction.prototype.isPopState;
4653
4527
  /**
@@ -4660,7 +4534,7 @@ if (false) {
4660
4534
  /** @type {?} */
4661
4535
  CancelledDuringNavigationInteraction.prototype.locationChangeTriggerUrl;
4662
4536
  }
4663
- })(NavigationSession || (NavigationSession = {}));
4537
+ })(NavigationState || (NavigationState = {}));
4664
4538
 
4665
4539
  /**
4666
4540
  * @fileoverview added by tsickle
@@ -4747,33 +4621,28 @@ if (false) {
4747
4621
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4748
4622
  */
4749
4623
  var UrlSnapshot = /** @class */ (function () {
4750
- function UrlSnapshot(urlTree) {
4751
- this.urlTree = urlTree;
4752
- // console.log({ segments: this.urlTree.root.children.primary.segments });
4624
+ // TODO: Update this accept a url Parser so it can be immutable and generate new trees on mutation using toString() are parseUrl.
4625
+ function UrlSnapshot(urlSerializer, url) {
4626
+ this.urlSerializer = urlSerializer;
4627
+ this.url = url;
4628
+ this.urlTree = urlSerializer.parse(url);
4753
4629
  }
4754
4630
  /**
4755
- * @return {?}
4756
- */
4757
- UrlSnapshot.prototype.cloneUrlSegmentList = /**
4758
- * @return {?}
4759
- */
4760
- function () {
4761
- return __spread(this.urlTree.root.children.primary.segments);
4762
- };
4763
- /**
4631
+ * @protected
4764
4632
  * @param {?} visit
4765
4633
  * @return {?}
4766
4634
  */
4767
- UrlSnapshot.prototype.updateVisitSegments = /**
4635
+ UrlSnapshot.prototype.replaceExistingVisitSegmentsWith = /**
4636
+ * @protected
4768
4637
  * @param {?} visit
4769
4638
  * @return {?}
4770
4639
  */
4771
4640
  function (visit) {
4772
4641
  // Ugly, but it works for now.
4773
4642
  /** @type {?} */
4774
- var segments = this.cloneUrlSegmentList();
4643
+ var segments = __spread(this.getPrimarySegments());
4775
4644
  /** @type {?} */
4776
- var visitSegments = this.convertToUrlSegments(visit);
4645
+ var visitSegments = this.getSegmentsFor(visit);
4777
4646
  /** @type {?} */
4778
4647
  var replaceAt = segments.findIndex((/**
4779
4648
  * @param {?} segment
@@ -4784,17 +4653,30 @@ var UrlSnapshot = /** @class */ (function () {
4784
4653
  segments.splice.apply(segments, __spread([replaceAt, visitSegments.length], visitSegments));
4785
4654
  return segments;
4786
4655
  };
4656
+ /**
4657
+ * @private
4658
+ * @return {?}
4659
+ */
4660
+ UrlSnapshot.prototype.getPrimarySegments = /**
4661
+ * @private
4662
+ * @return {?}
4663
+ */
4664
+ function () {
4665
+ return this.urlTree.root.children.primary.segments;
4666
+ };
4787
4667
  /**
4788
4668
  * Converts the visit into segments. Please not that these segments are not e
4789
4669
  * @param visit
4790
4670
  */
4791
4671
  /**
4792
4672
  * Converts the visit into segments. Please not that these segments are not e
4673
+ * @protected
4793
4674
  * @param {?} visit
4794
4675
  * @return {?}
4795
4676
  */
4796
- UrlSnapshot.prototype.convertToUrlSegments = /**
4677
+ UrlSnapshot.prototype.getSegmentsFor = /**
4797
4678
  * Converts the visit into segments. Please not that these segments are not e
4679
+ * @protected
4798
4680
  * @param {?} visit
4799
4681
  * @return {?}
4800
4682
  */
@@ -4822,7 +4704,7 @@ var UrlSnapshot = /** @class */ (function () {
4822
4704
  */
4823
4705
  function (visit) {
4824
4706
  /** @type {?} */
4825
- var segments = this.updateVisitSegments(visit);
4707
+ var segments = this.replaceExistingVisitSegmentsWith(visit);
4826
4708
  /** @type {?} */
4827
4709
  var commands = [];
4828
4710
  segments.forEach((/**
@@ -4846,18 +4728,93 @@ var UrlSnapshot = /** @class */ (function () {
4846
4728
  * @return {?}
4847
4729
  */
4848
4730
  function (placeDef) {
4849
- return this.cloneUrlSegmentList().find((/**
4731
+ return this.getPrimarySegments().find((/**
4850
4732
  * @param {?} s
4851
4733
  * @return {?}
4852
4734
  */
4853
4735
  function (s) { return s.path === placeDef.path; }));
4854
4736
  };
4737
+ /**
4738
+ * @return {?}
4739
+ */
4740
+ UrlSnapshot.prototype.getInteractionIds = /**
4741
+ * @return {?}
4742
+ */
4743
+ function () {
4744
+ /** @type {?} */
4745
+ var interactionOutlet = this.urlTree.root.children[UrlSnapshot.INTERACTION_ROUTER_OUTLET];
4746
+ if (interactionOutlet) {
4747
+ assert.isTruthy(interactionOutlet.segments.length === 2);
4748
+ assert.isTruthy(interactionOutlet.segments[0].path === UrlSnapshot.INTERACTION_ROUTER_PATH);
4749
+ return UrlSnapshot.parseInteractionIds(interactionOutlet.segments[1].path);
4750
+ }
4751
+ else {
4752
+ return [];
4753
+ }
4754
+ };
4755
+ // @Trace()
4756
+ // @Trace()
4757
+ /**
4758
+ * @param {?} ids
4759
+ * @return {?}
4760
+ */
4761
+ UrlSnapshot.prototype.addOrReplaceInteractionIds =
4762
+ // @Trace()
4763
+ /**
4764
+ * @param {?} ids
4765
+ * @return {?}
4766
+ */
4767
+ function (ids) {
4768
+ /** @type {?} */
4769
+ var urlTree = this.urlSerializer.parse(this.url);
4770
+ urlTree.root.children[UrlSnapshot.INTERACTION_ROUTER_OUTLET] = new UrlSegmentGroup([
4771
+ new UrlSegment(UrlSnapshot.INTERACTION_ROUTER_PATH, {}),
4772
+ new UrlSegment(UrlSnapshot.createPathIdFor(ids), {})
4773
+ ], {});
4774
+ return new UrlSnapshot(this.urlSerializer, urlTree.toString());
4775
+ };
4855
4776
  return UrlSnapshot;
4856
4777
  }());
4857
4778
  if (false) {
4858
- /** @type {?} */
4779
+ /**
4780
+ * @type {?}
4781
+ * @private
4782
+ */
4859
4783
  UrlSnapshot.prototype.urlTree;
4784
+ /** @type {?} */
4785
+ UrlSnapshot.prototype.urlSerializer;
4786
+ /** @type {?} */
4787
+ UrlSnapshot.prototype.url;
4860
4788
  }
4789
+ (function (UrlSnapshot) {
4790
+ UrlSnapshot.INTERACTION_ROUTER_OUTLET = 'aup-interactions';
4791
+ UrlSnapshot.INTERACTION_ROUTER_PATH = 'active';
4792
+ UrlSnapshot.INTERACTION_ID_SEPARATOR = '--';
4793
+ /**
4794
+ * @param {?} path
4795
+ * @return {?}
4796
+ */
4797
+ function parseInteractionIds(path) {
4798
+ return path.split(UrlSnapshot.INTERACTION_ID_SEPARATOR);
4799
+ }
4800
+ UrlSnapshot.parseInteractionIds = parseInteractionIds;
4801
+ /**
4802
+ * @param {?} interactionIds
4803
+ * @return {?}
4804
+ */
4805
+ function createPathIdFor(interactionIds) {
4806
+ return interactionIds.join(UrlSnapshot.INTERACTION_ID_SEPARATOR);
4807
+ }
4808
+ UrlSnapshot.createPathIdFor = createPathIdFor;
4809
+ /**
4810
+ * @param {?} interactionIds
4811
+ * @return {?}
4812
+ */
4813
+ function createInteractionOutletRouterCommands(interactionIds) {
4814
+ return [UrlSnapshot.INTERACTION_ROUTER_PATH, createPathIdFor(interactionIds)];
4815
+ }
4816
+ UrlSnapshot.createInteractionOutletRouterCommands = createInteractionOutletRouterCommands;
4817
+ })(UrlSnapshot || (UrlSnapshot = {}));
4861
4818
 
4862
4819
  /**
4863
4820
  * @fileoverview added by tsickle
@@ -4865,27 +4822,31 @@ if (false) {
4865
4822
  */
4866
4823
  var PlaceRouter = /** @class */ (function (_super) {
4867
4824
  __extends(PlaceRouter, _super);
4868
- function PlaceRouter(router, urlSerializer, angularLocation, placeHistory, modalInteractionService) {
4825
+ function PlaceRouter(router, urlSerializer, angularLocation, placeHistory, interactionService) {
4869
4826
  var _this = _super.call(this) || this;
4870
4827
  _this.router = router;
4871
4828
  _this.urlSerializer = urlSerializer;
4872
4829
  _this.angularLocation = angularLocation;
4873
4830
  _this.placeHistory = placeHistory;
4874
- _this.modalInteractionService = modalInteractionService;
4875
- _this.firstRoute = true;
4876
- _this._navigationSessionModel = new MutableValueModel();
4831
+ _this.interactionService = interactionService;
4832
+ _this._navigationStateModel = new MutableValueModel();
4877
4833
  _this._activeVisits = new MutableListModel();
4878
4834
  var _a = Dsl.disposeWith(_this), chain = _a.chain, valueOf = _a.valueOf, before = _a.before, when = _a.when, after = _a.after, observe = _a.observe, switchOn = _a.switchOn;
4879
4835
  _this.activeVisitIndex = chain(_this._activeVisits).indexBy('placeDefinition');
4880
- _this.navigationSessionActive = chain(_this.navigationSessionModel).pluck('active');
4881
- _this._navigationSessionContext = new NavigationSession.Context(_this.router, _this.modalInteractionService, _this.angularLocation, (/**
4836
+ _this.navigationInProgress = chain(_this.navigationStateModel).pluck('isTransitional');
4837
+ _this._navigationSessionContext = new NavigationState.Context(_this, _this.interactionService, (/**
4882
4838
  * @param {?} session
4883
4839
  * @return {?}
4884
4840
  */
4885
4841
  function (session) {
4886
4842
  _this.processNavigationSuccess(session);
4887
4843
  }));
4888
- _this._navigationSessionModel.value = new NavigationSession.Idle(_this._navigationSessionContext);
4844
+ _this._navigationStateModel.value = new NavigationState.Idle(_this._navigationSessionContext);
4845
+ _this._navigationStateTypeModel = chain(_this._navigationStateModel).map((/**
4846
+ * @param {?} state
4847
+ * @return {?}
4848
+ */
4849
+ function (state) { return (/** @type {?} */ (state.constructor)); }));
4889
4850
  // TODO: make setup the callbacks in during module initiation to make this testable.
4890
4851
  _this.router.events.subscribe((/**
4891
4852
  * @param {?} event
@@ -4899,53 +4860,85 @@ var PlaceRouter = /** @class */ (function (_super) {
4899
4860
  // NavigationStart -> .... -> NavigationError --> navigation aborted, end session.
4900
4861
  // =======================
4901
4862
  if (event instanceof NavigationStart) {
4902
- _this.runStateTransition((/**
4903
- * @param {?} session
4904
- * @return {?}
4905
- */
4906
- function (session) { return session.onStart(event); }));
4863
+ console.log(event);
4864
+ if (event.navigationTrigger === 'popstate') {
4865
+ _this.runStateTransition((/**
4866
+ * @param {?} state
4867
+ * @return {?}
4868
+ */
4869
+ function (state) { return state.onPopState(event); }));
4870
+ }
4871
+ else {
4872
+ _this.runStateTransition((/**
4873
+ * @param {?} state
4874
+ * @return {?}
4875
+ */
4876
+ function (state) { return state.onStart(event); }));
4877
+ }
4907
4878
  }
4908
4879
  if (event instanceof NavigationEnd) {
4880
+ console.log(event);
4909
4881
  _this.runStateTransition((/**
4910
- * @param {?} session
4882
+ * @param {?} state
4911
4883
  * @return {?}
4912
4884
  */
4913
- function (session) { return session.onEnd(event); }));
4885
+ function (state) { return state.onEnd(event); }));
4914
4886
  }
4915
4887
  if (event instanceof NavigationError) {
4888
+ console.log(event);
4916
4889
  _this.runStateTransition((/**
4917
- * @param {?} session
4890
+ * @param {?} state
4918
4891
  * @return {?}
4919
4892
  */
4920
- function (session) { return session.onError(event); }));
4893
+ function (state) { return state.onError(event); }));
4921
4894
  }
4922
4895
  if (event instanceof NavigationCancel) {
4896
+ console.log(event);
4923
4897
  _this.runStateTransition((/**
4924
- * @param {?} session
4898
+ * @param {?} state
4925
4899
  * @return {?}
4926
4900
  */
4927
- function (session) { return session.onCancel(event); }));
4901
+ function (state) { return state.onCancel(event); }));
4928
4902
  }
4929
4903
  }));
4930
4904
  // Push dialog state to the url so we can capture the back button.
4931
- _this.modalInteractionService.addActivityListener(new PlaceRouter.InteractionRouteMediator(_this.navigationSessionActive, _this.router));
4905
+ when.listOf(_this.interactionService.activeInteractionContextIds).changes((/**
4906
+ * @param {?} ids
4907
+ * @param {?} previous
4908
+ * @return {?}
4909
+ */
4910
+ function (ids, previous) {
4911
+ _this.syncInteractionIdsWithRouter();
4912
+ }), { unless: _this.navigationInProgress }); // TODO: I think the exclusive interaction prevents interactions starting while it's active so we might not need this.
4913
+ // TODO: I think the exclusive interaction prevents interactions starting while it's active so we might not need this.
4914
+ /** @type {?} */
4915
+ var urlChanges = new MutableStream();
4932
4916
  // The angular router doesn't always fire router events when the back button is pushed while a navigation
4933
4917
  // session is in progress. Sometimes we only know about it from the url change.
4918
+ // IMPORTANT ORDER DEPENDENCY
4919
+ // This only works because we're notified of the change after the router has started reacting to it. This
4920
+ // we can can use our navigationState to determine things.
4934
4921
  angularLocation.onUrlChange((/**
4935
4922
  * @param {?} url
4936
4923
  * @return {?}
4937
4924
  */
4938
4925
  function (url) {
4939
- console.log("#### url changed -> " + url);
4940
4926
  /** @type {?} */
4941
- var interactionContext = _this.navigationSessionActive.value && _this.navigationSession.interactionContext;
4942
- if (interactionContext && interactionContext.isActive()) {
4943
- Logger.get(_this).info("back button pressed during navigation session interaction");
4944
- _this.runStateTransition((/**
4945
- * @param {?} navigationSession
4946
- * @return {?}
4947
- */
4948
- function (navigationSession) { return navigationSession.onBackClickedDuringNavigationInteraction(url); }));
4927
+ var navigationState = _this._navigationStateModel.value;
4928
+ console.log("URLChange -> " + url, { state: navigationState });
4929
+ urlChanges.publish({ url: url, state: navigationState });
4930
+ // We've entered a navigation transition
4931
+ if (navigationState instanceof NavigationState.NavigationTransition) {
4932
+ /** @type {?} */
4933
+ var navigationInteraction = _this.navigationState.interactionContext;
4934
+ if (navigationInteraction && navigationInteraction.isActive()) {
4935
+ Logger.get(_this).info("back button pressed during navigation session interaction promise");
4936
+ _this.runStateTransition((/**
4937
+ * @param {?} state
4938
+ * @return {?}
4939
+ */
4940
+ function (state) { return state.onBackClickedDuringNavigationInteraction(url); }));
4941
+ }
4949
4942
  }
4950
4943
  }));
4951
4944
  return _this;
@@ -4962,6 +4955,9 @@ var PlaceRouter = /** @class */ (function (_super) {
4962
4955
  */
4963
4956
  function (session) {
4964
4957
  var _this = this;
4958
+ // We need to update the visits before the session finishes. This allows the placeOutets to ignore visit
4959
+ // changes that occur while routerNavigationActive is true.
4960
+ assert.isTruthy(this.navigationInProgress.value);
4965
4961
  /** @type {?} */
4966
4962
  var visits = session.getVisits();
4967
4963
  visits.forEach((/**
@@ -4969,26 +4965,24 @@ var PlaceRouter = /** @class */ (function (_super) {
4969
4965
  * @return {?}
4970
4966
  */
4971
4967
  function (v) { return _this.placeHistory.add(v); }));
4972
- // Update visits before we end the navigation session. This allows the placeOutets to
4973
- // ignore visit changes that occur while the navigation is in progress
4974
4968
  this._activeVisits.value = visits;
4975
4969
  };
4976
- Object.defineProperty(PlaceRouter.prototype, "navigationSession", {
4970
+ Object.defineProperty(PlaceRouter.prototype, "navigationState", {
4977
4971
  get: /**
4978
4972
  * @return {?}
4979
4973
  */
4980
4974
  function () {
4981
- return this._navigationSessionModel.value;
4975
+ return this._navigationStateModel.value;
4982
4976
  },
4983
4977
  enumerable: true,
4984
4978
  configurable: true
4985
4979
  });
4986
- Object.defineProperty(PlaceRouter.prototype, "navigationSessionModel", {
4980
+ Object.defineProperty(PlaceRouter.prototype, "navigationStateModel", {
4987
4981
  get: /**
4988
4982
  * @return {?}
4989
4983
  */
4990
4984
  function () {
4991
- return this._navigationSessionModel.readonly;
4985
+ return this._navigationStateModel.readonly;
4992
4986
  },
4993
4987
  enumerable: true,
4994
4988
  configurable: true
@@ -5079,7 +5073,7 @@ var PlaceRouter = /** @class */ (function (_super) {
5079
5073
  */
5080
5074
  function (router) {
5081
5075
  /** @type {?} */
5082
- var commands = _this.parseUrl(_this.router.routerState.snapshot).createRedirectCommandsFor(next);
5076
+ var commands = _this.parseUrl(_this.router.routerState.snapshot.url).createRedirectCommandsFor(next);
5083
5077
  console.log('### Push Changes to route Redirect', { commands: commands });
5084
5078
  return router.navigate(commands);
5085
5079
  }))];
@@ -5104,7 +5098,7 @@ var PlaceRouter = /** @class */ (function (_super) {
5104
5098
  return __generator(this, function (_a) {
5105
5099
  switch (_a.label) {
5106
5100
  case 0:
5107
- if (this.navigationSessionActive.value) {
5101
+ if (this.navigationInProgress.value) {
5108
5102
  lang.illegalState('Navigation already in progress');
5109
5103
  }
5110
5104
  this.runStateTransition((/**
@@ -5113,7 +5107,7 @@ var PlaceRouter = /** @class */ (function (_super) {
5113
5107
  */
5114
5108
  function (current) {
5115
5109
  /** @type {?} */
5116
- var session = new NavigationSession.Active(_this._navigationSessionContext, false, _this.router.routerState.snapshot.url);
5110
+ var session = new NavigationState.NavigationTransition(_this._navigationSessionContext, false, _this.router.routerState.snapshot.url);
5117
5111
  session.storeVisit(visit);
5118
5112
  return session;
5119
5113
  }));
@@ -5127,7 +5121,7 @@ var PlaceRouter = /** @class */ (function (_super) {
5127
5121
  case 3:
5128
5122
  // Router has finished (since there was no router change required) so we
5129
5123
  // need to end the navigation session.
5130
- if (this.navigationSession.active && !this.router.getCurrentNavigation()) {
5124
+ if (this.navigationState.isTransitional && !this.router.getCurrentNavigation()) {
5131
5125
  this.runStateTransition((/**
5132
5126
  * @param {?} session
5133
5127
  * @return {?}
@@ -5152,10 +5146,10 @@ var PlaceRouter = /** @class */ (function (_super) {
5152
5146
  */
5153
5147
  function (transition) {
5154
5148
  /** @type {?} */
5155
- var previous = this._navigationSessionModel.value;
5149
+ var previous = this._navigationStateModel.value;
5156
5150
  /** @type {?} */
5157
- var next = transition(this.navigationSession);
5158
- this._navigationSessionModel.value = next;
5151
+ var next = transition(this.navigationState);
5152
+ this._navigationStateModel.value = next;
5159
5153
  if (next !== previous) {
5160
5154
  previous.dispose();
5161
5155
  Logger.get(this).info("Router State Transition: " + previous.toString() + " -> " + next.toString());
@@ -5178,144 +5172,11 @@ var PlaceRouter = /** @class */ (function (_super) {
5178
5172
  [def.getFormattedRouteId(visit), def.getFormattedRouteParameters(visit)] :
5179
5173
  [def.getFormattedRouteParameters(visit)];
5180
5174
  };
5181
- // private onAngularRouterStarted(event: NavigationStart) {
5182
- // if (!this.navigationSession) {
5183
- // // We been activated by an external route rather than placeRouter.go(visit)
5184
- // this._navigationSessionModel.value = this.createExternalNavigationSession(event);
5185
- // }
5186
- // this.firstRoute = false;
5187
- // }
5188
- //
5189
- // private createExternalNavigationSession(event: NavigationStart) {
5190
- // return new NavigationSession.Active(
5191
- // this.modalInteractionService,
5192
- // this.angularLocation,
5193
- // // event.url,
5194
- // event.navigationTrigger === 'popstate'
5195
- // );
5196
- // }
5197
- // private onAngularRouterFinished(cancelled: boolean) {
5198
- // const session = this._navigationSessionModel.value;
5199
- // if (session.backClickedDuringCanDeactivateInteraction) {
5200
- // // we swallow this finished event but keep the session alive as we're going to
5201
- // // get another route started event, which will trigger anohter canDeactivate dialog
5202
- // // if we start a new session.
5203
- // // session.resetInteractionSession()
5204
- // } else {
5205
- // if (!cancelled) {
5206
- // const visits = session.getVisits();
5207
- // visits.forEach(v => this.placeHistory.add(v));
5208
- // // Update visits before we end the navigation session. This allows the placeOutets to
5209
- // // ignore visit changes that occur while the navigation is in progress
5210
- // this._activeVisits.value = visits;
5211
- // } else {
5212
- // // TODO: move this to the navigation session
5213
- // // Angular doesn't preserve the url when a guard cancels the back button.
5214
- // // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
5215
- // // session.rememberPopStateReturnUrl(this.router.routerState.snapshot.url);
5216
- // if (session.isPopState) {
5217
- // console.log('cancelled during popstate');
5218
- // // this.angularLocation.go(session.previousUrl);
5219
- // }
5220
- // }
5221
- // session.dispose();
5222
- // this._navigationSessionModel.value = null;
5223
- // }
5224
- // }
5225
- // private onAngularRouterStarted(event: NavigationStart) {
5226
- // if (!this.navigationSession) {
5227
- // // We been activated by an external route rather than placeRouter.go(visit)
5228
- // this._navigationSessionModel.value = this.createExternalNavigationSession(event);
5229
- // }
5230
- // this.firstRoute = false;
5231
- // }
5232
- //
5233
- // private createExternalNavigationSession(event: NavigationStart) {
5234
- // return new NavigationSession.Active(
5235
- // this.modalInteractionService,
5236
- // this.angularLocation,
5237
- // // event.url,
5238
- // event.navigationTrigger === 'popstate'
5239
- // );
5240
- // }
5241
- // private onAngularRouterFinished(cancelled: boolean) {
5242
- // const session = this._navigationSessionModel.value;
5243
- // if (session.backClickedDuringCanDeactivateInteraction) {
5244
- // // we swallow this finished event but keep the session alive as we're going to
5245
- // // get another route started event, which will trigger anohter canDeactivate dialog
5246
- // // if we start a new session.
5247
- // // session.resetInteractionSession()
5248
- // } else {
5249
- // if (!cancelled) {
5250
- // const visits = session.getVisits();
5251
- // visits.forEach(v => this.placeHistory.add(v));
5252
- // // Update visits before we end the navigation session. This allows the placeOutets to
5253
- // // ignore visit changes that occur while the navigation is in progress
5254
- // this._activeVisits.value = visits;
5255
- // } else {
5256
- // // TODO: move this to the navigation session
5257
- // // Angular doesn't preserve the url when a guard cancels the back button.
5258
- // // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
5259
- // // session.rememberPopStateReturnUrl(this.router.routerState.snapshot.url);
5260
- // if (session.isPopState) {
5261
- // console.log('cancelled during popstate');
5262
- // // this.angularLocation.go(session.previousUrl);
5263
- // }
5264
- // }
5265
- // session.dispose();
5266
- // this._navigationSessionModel.value = null;
5267
- // }
5268
- // }
5269
5175
  /**
5270
5176
  * @param {?} activatedRoute
5271
5177
  * @return {?}
5272
5178
  */
5273
- PlaceRouter.prototype.extractChildPath =
5274
- // private onAngularRouterStarted(event: NavigationStart) {
5275
- // if (!this.navigationSession) {
5276
- // // We been activated by an external route rather than placeRouter.go(visit)
5277
- // this._navigationSessionModel.value = this.createExternalNavigationSession(event);
5278
- // }
5279
- // this.firstRoute = false;
5280
- // }
5281
- //
5282
- // private createExternalNavigationSession(event: NavigationStart) {
5283
- // return new NavigationSession.Active(
5284
- // this.modalInteractionService,
5285
- // this.angularLocation,
5286
- // // event.url,
5287
- // event.navigationTrigger === 'popstate'
5288
- // );
5289
- // }
5290
- // private onAngularRouterFinished(cancelled: boolean) {
5291
- // const session = this._navigationSessionModel.value;
5292
- // if (session.backClickedDuringCanDeactivateInteraction) {
5293
- // // we swallow this finished event but keep the session alive as we're going to
5294
- // // get another route started event, which will trigger anohter canDeactivate dialog
5295
- // // if we start a new session.
5296
- // // session.resetInteractionSession()
5297
- // } else {
5298
- // if (!cancelled) {
5299
- // const visits = session.getVisits();
5300
- // visits.forEach(v => this.placeHistory.add(v));
5301
- // // Update visits before we end the navigation session. This allows the placeOutets to
5302
- // // ignore visit changes that occur while the navigation is in progress
5303
- // this._activeVisits.value = visits;
5304
- // } else {
5305
- // // TODO: move this to the navigation session
5306
- // // Angular doesn't preserve the url when a guard cancels the back button.
5307
- // // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
5308
- // // session.rememberPopStateReturnUrl(this.router.routerState.snapshot.url);
5309
- // if (session.isPopState) {
5310
- // console.log('cancelled during popstate');
5311
- // // this.angularLocation.go(session.previousUrl);
5312
- // }
5313
- // }
5314
- // session.dispose();
5315
- // this._navigationSessionModel.value = null;
5316
- // }
5317
- // }
5318
- /**
5179
+ PlaceRouter.prototype.extractChildPath = /**
5319
5180
  * @param {?} activatedRoute
5320
5181
  * @return {?}
5321
5182
  */
@@ -5327,15 +5188,97 @@ var PlaceRouter = /** @class */ (function (_super) {
5327
5188
  function (child) { return child.url; })));
5328
5189
  };
5329
5190
  /**
5330
- * @param {?} snapshot
5191
+ * @param {?} url
5331
5192
  * @return {?}
5332
5193
  */
5333
5194
  PlaceRouter.prototype.parseUrl = /**
5334
- * @param {?} snapshot
5195
+ * @param {?} url
5196
+ * @return {?}
5197
+ */
5198
+ function (url) {
5199
+ return new UrlSnapshot(this.urlSerializer, url);
5200
+ };
5201
+ /**
5202
+ * @param {?} url
5203
+ * @return {?}
5204
+ */
5205
+ PlaceRouter.prototype.resetBrowserLocation = /**
5206
+ * @param {?} url
5207
+ * @return {?}
5208
+ */
5209
+ function (url) {
5210
+ this.angularLocation.go(url);
5211
+ };
5212
+ /**
5213
+ * @return {?}
5214
+ */
5215
+ PlaceRouter.prototype.getCurrentRouterUrl = /**
5216
+ * @return {?}
5217
+ */
5218
+ function () {
5219
+ return this.router.routerState ? this.router.routerState.snapshot.url : null;
5220
+ };
5221
+ /**
5222
+ * @param {?} url
5223
+ * @return {?}
5224
+ */
5225
+ PlaceRouter.prototype.getActiveInteractionIdsFromUrl = /**
5226
+ * @param {?} url
5227
+ * @return {?}
5228
+ */
5229
+ function (url) {
5230
+ return this.parseUrl(url).getInteractionIds();
5231
+ };
5232
+ // @Trace()
5233
+ // @Trace()
5234
+ /**
5235
+ * @param {?} url
5236
+ * @return {?}
5237
+ */
5238
+ PlaceRouter.prototype.hasActiveInteractionIds =
5239
+ // @Trace()
5240
+ /**
5241
+ * @param {?} url
5242
+ * @return {?}
5243
+ */
5244
+ function (url) {
5245
+ return this.getActiveInteractionIdsFromUrl(url).length > 0;
5246
+ };
5247
+ /**
5335
5248
  * @return {?}
5336
5249
  */
5337
- function (snapshot) {
5338
- return new UrlSnapshot(this.urlSerializer.parse(snapshot.url));
5250
+ PlaceRouter.prototype.syncInteractionIdsWithRouter = /**
5251
+ * @return {?}
5252
+ */
5253
+ function () {
5254
+ var _a, _b;
5255
+ assert.isFalsey(this.navigationInProgress.value); // Updating interaction routes during an existing navigation breaks all the things.
5256
+ // Updating interaction routes during an existing navigation breaks all the things.
5257
+ /** @type {?} */
5258
+ var currentIds = this.interactionService.activeInteractionContextIds.value;
5259
+ if (___default.isEqual(currentIds, this.getActiveInteractionIdsFromUrl(this.getCurrentRouterUrl()))) {
5260
+ console.log('activity ids were the same, skipping');
5261
+ }
5262
+ else {
5263
+ if (currentIds.length < 1) {
5264
+ this.router.navigate(['.', {
5265
+ outlets: (_a = {},
5266
+ _a[UrlSnapshot.INTERACTION_ROUTER_OUTLET] = null,
5267
+ _a)
5268
+ }], {
5269
+ replaceUrl: true // remove the interaction from the history.
5270
+ });
5271
+ }
5272
+ else {
5273
+ /** @type {?} */
5274
+ var urlSnapshot = this.parseUrl(this.getCurrentRouterUrl());
5275
+ this.router.navigate(['.', {
5276
+ outlets: (_b = {},
5277
+ _b[UrlSnapshot.INTERACTION_ROUTER_OUTLET] = UrlSnapshot.createInteractionOutletRouterCommands(currentIds),
5278
+ _b)
5279
+ }]);
5280
+ }
5281
+ }
5339
5282
  };
5340
5283
  PlaceRouter.decorators = [
5341
5284
  { type: Injectable, args: [{
@@ -5348,9 +5291,15 @@ var PlaceRouter = /** @class */ (function (_super) {
5348
5291
  { type: UrlSerializer },
5349
5292
  { type: Location },
5350
5293
  { type: PlaceHistory },
5351
- { type: ModalInteractionService }
5294
+ { type: InteractionService }
5352
5295
  ]; };
5353
- /** @nocollapse */ PlaceRouter.ngInjectableDef = ɵɵdefineInjectable({ factory: function PlaceRouter_Factory() { return new PlaceRouter(ɵɵinject(Router), ɵɵinject(UrlSerializer), ɵɵinject(Location), ɵɵinject(PlaceHistory), ɵɵinject(ModalInteractionService)); }, token: PlaceRouter, providedIn: "root" });
5296
+ /** @nocollapse */ PlaceRouter.ngInjectableDef = ɵɵdefineInjectable({ factory: function PlaceRouter_Factory() { return new PlaceRouter(ɵɵinject(Router), ɵɵinject(UrlSerializer), ɵɵinject(Location), ɵɵinject(PlaceHistory), ɵɵinject(InteractionService)); }, token: PlaceRouter, providedIn: "root" });
5297
+ __decorate([
5298
+ Trace(),
5299
+ __metadata("design:type", Function),
5300
+ __metadata("design:paramtypes", []),
5301
+ __metadata("design:returntype", void 0)
5302
+ ], PlaceRouter.prototype, "syncInteractionIdsWithRouter", null);
5354
5303
  return PlaceRouter;
5355
5304
  }(GarbageCollector));
5356
5305
  if (false) {
@@ -5358,26 +5307,26 @@ if (false) {
5358
5307
  * @type {?}
5359
5308
  * @private
5360
5309
  */
5361
- PlaceRouter.prototype.firstRoute;
5362
- /**
5363
- * @type {?}
5364
- * @private
5365
- */
5366
- PlaceRouter.prototype._navigationSessionModel;
5310
+ PlaceRouter.prototype._navigationStateModel;
5367
5311
  /**
5368
5312
  * @type {?}
5369
5313
  * @private
5370
5314
  */
5371
5315
  PlaceRouter.prototype._activeVisits;
5372
5316
  /** @type {?} */
5373
- PlaceRouter.prototype.navigationSessionActive;
5317
+ PlaceRouter.prototype.navigationInProgress;
5374
5318
  /** @type {?} */
5375
5319
  PlaceRouter.prototype.activeVisitIndex;
5376
5320
  /**
5377
5321
  * @type {?}
5378
5322
  * @private
5379
5323
  */
5380
- PlaceRouter.prototype._navigationSessionContext;
5324
+ PlaceRouter.prototype._navigationSessionContext;
5325
+ /**
5326
+ * @type {?}
5327
+ * @private
5328
+ */
5329
+ PlaceRouter.prototype._navigationStateTypeModel;
5381
5330
  /**
5382
5331
  * @type {?}
5383
5332
  * @private
@@ -5402,83 +5351,8 @@ if (false) {
5402
5351
  * @type {?}
5403
5352
  * @private
5404
5353
  */
5405
- PlaceRouter.prototype.modalInteractionService;
5354
+ PlaceRouter.prototype.interactionService;
5406
5355
  }
5407
- (function (PlaceRouter) {
5408
- PlaceRouter.INTERACTION_ROUTER_OUTLET = 'aup-interaction';
5409
- var InteractionRouteMediator = /** @class */ (function () {
5410
- function InteractionRouteMediator(navigationSessionModelActive, router) {
5411
- this.navigationSessionModelActive = navigationSessionModelActive;
5412
- this.router = router;
5413
- }
5414
- Object.defineProperty(InteractionRouteMediator.prototype, "isNavigating", {
5415
- get: /**
5416
- * @return {?}
5417
- */
5418
- function () {
5419
- return this.navigationSessionModelActive.value;
5420
- },
5421
- enumerable: true,
5422
- configurable: true
5423
- });
5424
- // If we're not in a navigation we push
5425
- // @Trace()
5426
- // If we're not in a navigation we push
5427
- // @Trace()
5428
- /**
5429
- * @return {?}
5430
- */
5431
- InteractionRouteMediator.prototype.onActivityStarted =
5432
- // If we're not in a navigation we push
5433
- // @Trace()
5434
- /**
5435
- * @return {?}
5436
- */
5437
- function () {
5438
- var _a;
5439
- if (!this.isNavigating) {
5440
- this.router.navigate(['.', {
5441
- outlets: (_a = {},
5442
- _a[PlaceRouter.INTERACTION_ROUTER_OUTLET] = ['modal'] // "open" must be a valid route for this outlet.
5443
- ,
5444
- _a)
5445
- }], {
5446
- replaceUrl: false,
5447
- });
5448
- }
5449
- };
5450
- // @Trace()
5451
- // @Trace()
5452
- /**
5453
- * @return {?}
5454
- */
5455
- InteractionRouteMediator.prototype.onActivityFinished =
5456
- // @Trace()
5457
- /**
5458
- * @return {?}
5459
- */
5460
- function () {
5461
- var _a;
5462
- if (!this.isNavigating) {
5463
- this.router.navigate(['.', {
5464
- outlets: (_a = {},
5465
- _a[PlaceRouter.INTERACTION_ROUTER_OUTLET] = null,
5466
- _a)
5467
- }], {
5468
- replaceUrl: true // remove the interaction from the history.
5469
- });
5470
- }
5471
- };
5472
- return InteractionRouteMediator;
5473
- }());
5474
- PlaceRouter.InteractionRouteMediator = InteractionRouteMediator;
5475
- if (false) {
5476
- /** @type {?} */
5477
- InteractionRouteMediator.prototype.navigationSessionModelActive;
5478
- /** @type {?} */
5479
- InteractionRouteMediator.prototype.router;
5480
- }
5481
- })(PlaceRouter || (PlaceRouter = {}));
5482
5356
 
5483
5357
  /**
5484
5358
  * @fileoverview added by tsickle
@@ -5567,9 +5441,9 @@ var PlaceOutletComponent = /** @class */ (function (_super) {
5567
5441
  _this.placeChanged = new EventEmitter();
5568
5442
  _this._activePlace = new MutableValueModel();
5569
5443
  _this._activePlaceVisitModel = new DelegatingValueModel();
5570
- _this._inOutletActivation = new Guard$1();
5571
- _this._inOutletDeactivation = new Guard$1();
5572
- _this._inRouteVisitUpdate = new Guard$1();
5444
+ _this._inOutletActivation = new Guard();
5445
+ _this._inOutletDeactivation = new Guard();
5446
+ _this._inRouteVisitUpdate = new Guard();
5573
5447
  _this._activatedRouteModel = new MutableValueModel();
5574
5448
  _this._placeDefinition = new MutableValueModel();
5575
5449
  _this.initialPlaceIndex = null;
@@ -5629,10 +5503,10 @@ var PlaceOutletComponent = /** @class */ (function (_super) {
5629
5503
  function (next, previous) {
5630
5504
  _this.pushVisitChangesToRoute(next, previous);
5631
5505
  }), {
5632
- unless: _this.placeRouter.navigationSessionActive
5506
+ unless: _this.placeRouter.navigationInProgress
5633
5507
  });
5634
5508
  chain(_this._activePlace)
5635
- .postponeWhile(placeRouter.navigationSessionActive)
5509
+ .postponeWhile(placeRouter.navigationInProgress)
5636
5510
  .subscribe((/**
5637
5511
  * @param {?} place
5638
5512
  * @return {?}
@@ -6694,6 +6568,225 @@ if (false) {
6694
6568
  ActivityOutletContext.prototype.componentReady = function (component) { };
6695
6569
  }
6696
6570
 
6571
+ /**
6572
+ * @fileoverview added by tsickle
6573
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
6574
+ */
6575
+ var DialogInteractionContext = /** @class */ (function (_super) {
6576
+ __extends(DialogInteractionContext, _super);
6577
+ function DialogInteractionContext(dialogService, config) {
6578
+ var _this = _super.call(this) || this;
6579
+ _this.dialogService = dialogService;
6580
+ _this.config = config;
6581
+ _this._activeModel = new MutableValueModel(false);
6582
+ assert$1.notNil(dialogService);
6583
+ _this.onDispose((/**
6584
+ * @return {?}
6585
+ */
6586
+ function () {
6587
+ if (_this.isActive()) {
6588
+ lang.illegalState('Dispose called while active.');
6589
+ }
6590
+ }));
6591
+ return _this;
6592
+ }
6593
+ Object.defineProperty(DialogInteractionContext.prototype, "active", {
6594
+ get: /**
6595
+ * @return {?}
6596
+ */
6597
+ function () {
6598
+ return this._activeModel.readonly;
6599
+ },
6600
+ enumerable: true,
6601
+ configurable: true
6602
+ });
6603
+ /**
6604
+ * @protected
6605
+ * @template D, R, E
6606
+ * @param {?} activityType
6607
+ * @param {?} data
6608
+ * @param {?=} disableClose
6609
+ * @return {?}
6610
+ */
6611
+ DialogInteractionContext.prototype._startActivity = /**
6612
+ * @protected
6613
+ * @template D, R, E
6614
+ * @param {?} activityType
6615
+ * @param {?} data
6616
+ * @param {?=} disableClose
6617
+ * @return {?}
6618
+ */
6619
+ function (activityType, data, disableClose) {
6620
+ var _this = this;
6621
+ if (disableClose === void 0) { disableClose = true; }
6622
+ if (this.isActive()) {
6623
+ lang.illegalState("Activity already in progress: " + this.activityList.value.map((/**
6624
+ * @param {?} a
6625
+ * @return {?}
6626
+ */
6627
+ function (a) { return a.constructor.name; })).join(', '));
6628
+ }
6629
+ this._activeModel.value = true;
6630
+ /** @type {?} */
6631
+ var config = __assign({}, this.config, {
6632
+ data: data,
6633
+ disableClose: disableClose,
6634
+ panelClass: 'dialog-interaction-context'
6635
+ });
6636
+ /** @type {?} */
6637
+ var self = this;
6638
+ /** @type {?} */
6639
+ var matDialogRef = (/** @type {?} */ (this.dialogService.open(ActivityContainerComponent, config)));
6640
+ return new Promise((/**
6641
+ * @param {?} resolve
6642
+ * @param {?} reject
6643
+ * @return {?}
6644
+ */
6645
+ function (resolve, reject) {
6646
+ /** @type {?} */
6647
+ var activityContainer = matDialogRef.componentInstance;
6648
+ self.safelyUpdateActivityListDelegate(activityContainer.activityList);
6649
+ activityContainer.initialActivityOutletContext = {
6650
+ activityClass: activityType,
6651
+ activityData: data,
6652
+ onDone: /**
6653
+ * @param {?} result
6654
+ * @return {?}
6655
+ */
6656
+ function (result) {
6657
+ resolve(result);
6658
+ matDialogRef.close(true); // return true to let the after close listener know we've already handled it.
6659
+ },
6660
+ onCancel: /**
6661
+ * @param {?} error
6662
+ * @return {?}
6663
+ */
6664
+ function (error) {
6665
+ reject(error);
6666
+ matDialogRef.close(true); // return true to let the after close listener know we've already handled it.
6667
+ }
6668
+ };
6669
+ // we need to check if our onDone/onCancel methods above we called or if we were
6670
+ // closed by the user clicking the backdrop. If the later then we need to reject
6671
+ // our promise.
6672
+ matDialogRef.afterClosed().subscribe((/**
6673
+ * @param {?} promiseAlreadyFinished
6674
+ * @return {?}
6675
+ */
6676
+ function (promiseAlreadyFinished) {
6677
+ if (!promiseAlreadyFinished) {
6678
+ reject('auto-closed');
6679
+ }
6680
+ }));
6681
+ matDialogRef.updateSize();
6682
+ matDialogRef.afterOpened().subscribe((/**
6683
+ * @param {?} promiseAlreadyFinished
6684
+ * @return {?}
6685
+ */
6686
+ function (promiseAlreadyFinished) {
6687
+ matDialogRef.updateSize();
6688
+ }));
6689
+ })).finally((/**
6690
+ * @return {?}
6691
+ */
6692
+ function () {
6693
+ self.safelyUpdateActivityListDelegate(null);
6694
+ _this._activeModel.value = false;
6695
+ }));
6696
+ };
6697
+ /**
6698
+ * Updates teh delegate on the next tick to avoid modifying state during the current change detection cycle.
6699
+ * @param delegate
6700
+ */
6701
+ /**
6702
+ * Updates teh delegate on the next tick to avoid modifying state during the current change detection cycle.
6703
+ * @param {?} delegate
6704
+ * @return {?}
6705
+ */
6706
+ DialogInteractionContext.prototype.safelyUpdateActivityListDelegate = /**
6707
+ * Updates teh delegate on the next tick to avoid modifying state during the current change detection cycle.
6708
+ * @param {?} delegate
6709
+ * @return {?}
6710
+ */
6711
+ function (delegate) {
6712
+ var _this = this;
6713
+ setTimeout((/**
6714
+ * @return {?}
6715
+ */
6716
+ function () { return _this.setActivityList(delegate); }));
6717
+ };
6718
+ return DialogInteractionContext;
6719
+ }(InteractionContextBase));
6720
+ if (false) {
6721
+ /**
6722
+ * @type {?}
6723
+ * @private
6724
+ */
6725
+ DialogInteractionContext.prototype._activeModel;
6726
+ /**
6727
+ * @type {?}
6728
+ * @private
6729
+ */
6730
+ DialogInteractionContext.prototype.dialogService;
6731
+ /** @type {?} */
6732
+ DialogInteractionContext.prototype.config;
6733
+ }
6734
+
6735
+ /**
6736
+ * @fileoverview added by tsickle
6737
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
6738
+ */
6739
+ /** @type {?} */
6740
+ var DIALOG_INTERACTION_SERVICE_DEFAULTS = new InjectionToken('DIALOG_INTERACTION_SERVICE_DEFAULTS');
6741
+ var DialogInteractionContextFactory = /** @class */ (function (_super) {
6742
+ __extends(DialogInteractionContextFactory, _super);
6743
+ function DialogInteractionContextFactory(dialogService, dialogServiceDefaults, matDialogDefaultConfig) {
6744
+ var _this = _super.call(this) || this;
6745
+ _this.dialogService = dialogService;
6746
+ _this.dialogServiceDefaults = dialogServiceDefaults;
6747
+ _this.matDialogDefaultConfig = matDialogDefaultConfig;
6748
+ assert$1.notNil(dialogService);
6749
+ return _this;
6750
+ }
6751
+ /**
6752
+ * @return {?}
6753
+ */
6754
+ DialogInteractionContextFactory.prototype.createInteractionContext = /**
6755
+ * @return {?}
6756
+ */
6757
+ function () {
6758
+ /** @type {?} */
6759
+ var config = __assign({ autoFocus: false, hasBackdrop: true, closeOnNavigation: false }, this.matDialogDefaultConfig, this.dialogServiceDefaults);
6760
+ return new DialogInteractionContext(this.dialogService, config);
6761
+ };
6762
+ DialogInteractionContextFactory.decorators = [
6763
+ { type: Injectable, args: [{
6764
+ providedIn: 'root'
6765
+ },] }
6766
+ ];
6767
+ /** @nocollapse */
6768
+ DialogInteractionContextFactory.ctorParameters = function () { return [
6769
+ { type: MatDialog },
6770
+ { type: MatDialogConfig, decorators: [{ type: Optional }, { type: Inject, args: [DIALOG_INTERACTION_SERVICE_DEFAULTS,] }] },
6771
+ { type: MatDialogConfig, decorators: [{ type: Optional }, { type: Inject, args: [MAT_DIALOG_DEFAULT_OPTIONS,] }] }
6772
+ ]; };
6773
+ /** @nocollapse */ DialogInteractionContextFactory.ngInjectableDef = ɵɵdefineInjectable({ factory: function DialogInteractionContextFactory_Factory() { return new DialogInteractionContextFactory(ɵɵinject(MatDialog$1), ɵɵinject(DIALOG_INTERACTION_SERVICE_DEFAULTS, 8), ɵɵinject(MAT_DIALOG_DEFAULT_OPTIONS, 8)); }, token: DialogInteractionContextFactory, providedIn: "root" });
6774
+ return DialogInteractionContextFactory;
6775
+ }(ModalInteractionContextFactory));
6776
+ if (false) {
6777
+ /** @type {?} */
6778
+ DialogInteractionContextFactory.prototype.active;
6779
+ /**
6780
+ * @type {?}
6781
+ * @private
6782
+ */
6783
+ DialogInteractionContextFactory.prototype.dialogService;
6784
+ /** @type {?} */
6785
+ DialogInteractionContextFactory.prototype.dialogServiceDefaults;
6786
+ /** @type {?} */
6787
+ DialogInteractionContextFactory.prototype.matDialogDefaultConfig;
6788
+ }
6789
+
6697
6790
  /**
6698
6791
  * @fileoverview added by tsickle
6699
6792
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -7068,16 +7161,16 @@ var AbstractPlaceGuard = /** @class */ (function () {
7068
7161
  // Parse our route params.
7069
7162
  params = new ConsolidatedParameterMap(activatedRoute.paramMap, activatedRoute.url);
7070
7163
  parsedParams = placeDefinition.parseRouteParams(params);
7071
- initialVisit = this.placeRouter.navigationSession.getVisitFor(placeDefinition) || new Visit(placeDefinition, parsedParams);
7164
+ initialVisit = this.placeRouter.navigationState.getVisitFor(placeDefinition) || new Visit(placeDefinition, parsedParams);
7072
7165
  sanitiser = new VisitSanitiser(activatedRoute, this.router, this.placeHistory, this.injector);
7073
7166
  return [4 /*yield*/, sanitiser.sanitise(initialVisit.mergeRouteParameters(parsedParams))];
7074
7167
  case 1:
7075
7168
  sanitisedVisit = _a.sent();
7076
7169
  // Save the visit with any updated parameters. We need to save it so we remember any non route parameters
7077
- this.placeRouter.navigationSession.storeVisit(sanitisedVisit);
7170
+ this.placeRouter.navigationState.storeVisit(sanitisedVisit);
7078
7171
  if (initialVisit.hasRoutingChangedFrom(sanitisedVisit)) {
7079
7172
  // Regenerate the url
7080
- commands = this.placeRouter.parseUrl(state).createRedirectCommandsFor(sanitisedVisit);
7173
+ commands = this.placeRouter.parseUrl(state.url).createRedirectCommandsFor(sanitisedVisit);
7081
7174
  console.log('##### Place Guard Redirect', commands);
7082
7175
  return [2 /*return*/, this.router.createUrlTree(commands, {
7083
7176
  replaceUrl: true,
@@ -7111,7 +7204,7 @@ var AbstractPlaceGuard = /** @class */ (function () {
7111
7204
  function (component, currentRoute, currentState, nextState) {
7112
7205
  return __awaiter(this, void 0, void 0, function () {
7113
7206
  return __generator(this, function (_a) {
7114
- return [2 /*return*/, this.placeRouter.navigationSession.canDeactivatePlace(component, this.placeRouter.parseUrl(nextState))];
7207
+ return [2 /*return*/, this.placeRouter.navigationState.canDeactivatePlace(component, this.placeRouter.parseUrl(nextState.url))];
7115
7208
  });
7116
7209
  });
7117
7210
  };
@@ -7121,7 +7214,7 @@ var AbstractPlaceGuard = /** @class */ (function () {
7121
7214
  * @protected
7122
7215
  * @param {?} activatedRoute
7123
7216
  * @param {?} state
7124
- * @param {?} canActivate
7217
+ * @param {?} runPlaceGuards
7125
7218
  * @return {?}
7126
7219
  */
7127
7220
  AbstractPlaceGuard.prototype.authorisePlaceThen =
@@ -7130,12 +7223,12 @@ var AbstractPlaceGuard = /** @class */ (function () {
7130
7223
  * @protected
7131
7224
  * @param {?} activatedRoute
7132
7225
  * @param {?} state
7133
- * @param {?} canActivate
7226
+ * @param {?} runPlaceGuards
7134
7227
  * @return {?}
7135
7228
  */
7136
- function (activatedRoute, state, canActivate) {
7229
+ function (activatedRoute, state, runPlaceGuards) {
7137
7230
  return __awaiter(this, void 0, void 0, function () {
7138
- var placeDefinition, authorised, _a;
7231
+ var placeDefinition, authoriseResult, _a;
7139
7232
  return __generator(this, function (_b) {
7140
7233
  switch (_b.label) {
7141
7234
  case 0:
@@ -7150,13 +7243,14 @@ var AbstractPlaceGuard = /** @class */ (function () {
7150
7243
  _a = true;
7151
7244
  _b.label = 3;
7152
7245
  case 3:
7153
- authorised = _a;
7154
- if (authorised === true) {
7155
- return [2 /*return*/, canActivate(placeDefinition)];
7246
+ authoriseResult = _a;
7247
+ if (authoriseResult === true) {
7248
+ // we're authorised, now run the place guards.
7249
+ return [2 /*return*/, runPlaceGuards(placeDefinition)];
7156
7250
  }
7157
7251
  else {
7158
- console.log('not authorised result', authorised);
7159
- return [2 /*return*/, authorised];
7252
+ console.log('not authorised result', authoriseResult);
7253
+ return [2 /*return*/, authoriseResult];
7160
7254
  }
7161
7255
  return [3 /*break*/, 5];
7162
7256
  case 4: return [2 /*return*/, lang.illegalState("expected component to be an instance of PlaceComponent, got " + activatedRoute.component)];
@@ -7231,12 +7325,12 @@ if (false) {
7231
7325
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
7232
7326
  */
7233
7327
  var InteractionGuard = /** @class */ (function () {
7234
- function InteractionGuard(router, injector, placeRouter, angularLocation, modalInteractionService) {
7328
+ function InteractionGuard(router, injector, placeRouter, angularLocation, interactionService) {
7235
7329
  this.router = router;
7236
7330
  this.injector = injector;
7237
7331
  this.placeRouter = placeRouter;
7238
7332
  this.angularLocation = angularLocation;
7239
- this.modalInteractionService = modalInteractionService;
7333
+ this.interactionService = interactionService;
7240
7334
  }
7241
7335
  /**
7242
7336
  * @param {?} route
@@ -7251,10 +7345,10 @@ var InteractionGuard = /** @class */ (function () {
7251
7345
  function (route, state) {
7252
7346
  /** @type {?} */
7253
7347
  var url = this.router.parseUrl(state.url);
7254
- if (!this.modalInteractionService.isActive() && url.root.children[PlaceRouter.INTERACTION_ROUTER_OUTLET]) {
7348
+ if (!this.interactionService.isActive() && url.root.children[UrlSnapshot.INTERACTION_ROUTER_OUTLET]) {
7255
7349
  // This happens if we reload the page or the url was pasted as the route should only be activated
7256
7350
  // after the interaction context has become active.
7257
- delete url.root.children[PlaceRouter.INTERACTION_ROUTER_OUTLET];
7351
+ delete url.root.children[UrlSnapshot.INTERACTION_ROUTER_OUTLET];
7258
7352
  return url;
7259
7353
  }
7260
7354
  else {
@@ -7277,20 +7371,26 @@ var InteractionGuard = /** @class */ (function () {
7277
7371
  */
7278
7372
  function (component, currentRoute, currentState, nextState) {
7279
7373
  return __awaiter(this, void 0, void 0, function () {
7280
- var popstateReturnUrl, activity;
7374
+ var currentIds, routeIds, activity;
7281
7375
  return __generator(this, function (_a) {
7282
7376
  switch (_a.label) {
7283
7377
  case 0:
7284
- popstateReturnUrl = this.placeRouter.navigationSession.startingUrl;
7285
- if (!this.modalInteractionService.isActive()) return [3 /*break*/, 2];
7378
+ if (!this.interactionService.isActive()) return [3 /*break*/, 2];
7379
+ currentIds = this.interactionService.activeInteractionContextIds.value;
7380
+ routeIds = this.placeRouter.getActiveInteractionIdsFromUrl(nextState.url);
7381
+ if (!!isEqual(currentIds, routeIds)) return [3 /*break*/, 2];
7286
7382
  // The activity is still active so the route change was triggered by the back button.
7287
- return [4 /*yield*/, this.modalInteractionService.getCurrentActivity()];
7383
+ return [4 /*yield*/, this.interactionService.getCurrentActivity()];
7288
7384
  case 1:
7289
7385
  activity = _a.sent();
7290
7386
  activity.cancel();
7291
- // See ModalInteractionSession#onStart() for the url updating.
7292
- return [2 /*return*/, false];
7293
- case 2: return [2 /*return*/, true];
7387
+ _a.label = 2;
7388
+ case 2:
7389
+ // IMPORTANT:
7390
+ // We always return true, the router state engine will redirect as required. Return false
7391
+ // during the guard causes all kinds of grief. It might be worth trying a redirect here
7392
+ // again now that our state engine is more thorough.
7393
+ return [2 /*return*/, true];
7294
7394
  }
7295
7395
  });
7296
7396
  });
@@ -7306,9 +7406,9 @@ var InteractionGuard = /** @class */ (function () {
7306
7406
  { type: Injector },
7307
7407
  { type: PlaceRouter },
7308
7408
  { type: Location },
7309
- { type: ModalInteractionService }
7409
+ { type: InteractionService }
7310
7410
  ]; };
7311
- /** @nocollapse */ InteractionGuard.ngInjectableDef = ɵɵdefineInjectable({ factory: function InteractionGuard_Factory() { return new InteractionGuard(ɵɵinject(Router), ɵɵinject(INJECTOR), ɵɵinject(PlaceRouter), ɵɵinject(Location), ɵɵinject(ModalInteractionService)); }, token: InteractionGuard, providedIn: "root" });
7411
+ /** @nocollapse */ InteractionGuard.ngInjectableDef = ɵɵdefineInjectable({ factory: function InteractionGuard_Factory() { return new InteractionGuard(ɵɵinject(Router), ɵɵinject(INJECTOR), ɵɵinject(PlaceRouter), ɵɵinject(Location), ɵɵinject(InteractionService)); }, token: InteractionGuard, providedIn: "root" });
7312
7412
  return InteractionGuard;
7313
7413
  }());
7314
7414
  if (false) {
@@ -7336,7 +7436,7 @@ if (false) {
7336
7436
  * @type {?}
7337
7437
  * @private
7338
7438
  */
7339
- InteractionGuard.prototype.modalInteractionService;
7439
+ InteractionGuard.prototype.interactionService;
7340
7440
  }
7341
7441
 
7342
7442
  /**
@@ -7654,5 +7754,5 @@ if (false) {
7654
7754
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
7655
7755
  */
7656
7756
 
7657
- export { ACTIVITY_DATA, AUP_PLACE_CONFIG, AbstractActivity, AbstractInputComponent, AbstractPlaceGuard, AbstractPlaceNavigationComponent, Activity, ActivityContainerComponent, ActivityOutletComponent, AlertDialogComponent, AngularUiPowerupsModule, Bounds, BusyOverlayComponent, CommandDirective, ComponentsModule, ConfirmThenDialogComponent, ConfirmationDialogComponent, ConsolidatedParameterMap, DEFINITION_META_DATA_KEY, DIALOG_INTERACTION_SERVICE_DEFAULTS, DialogInteractionContext, DialogInteractionService, Dimension, DirectivesModule, DisposableComponent, EmptyStateComponent, FocusBindingDirective, Formatter, InplaceInteractionContextComponent, InteractionContext, InteractionContextBase, InteractionGuard, InteractionModule, InteractionOutletComponent, LEFT_RIGHT_PLACE_ANIMATION, ListPlaceNavComponent, ModalInteractionService, NavigationSession, NoopAuthGuard, NoopComponent, NumberInputComponent, ParameterDefinition, PasswordInputComponent, Place, PlaceComponent, PlaceComponentDeactivationHandler, PlaceDefinition, PlaceHistory, PlaceModule, PlaceOutletComponent, PlaceRouter, Point, ROUTE_PARAMETER_LIST_KEY, ResizeAwareComponent, RouteId, SelectInputComponent, StringInputComponent, TabbedPlaceNavigationComponent, UrlSnapshot, Visit, VisitParameter, VisitParameterList, VisitSanitiser, leftRightPlaceAnimation, slideDownAndUpAnimation, DirectivesModule as ɵa, CommandDirective as ɵb, ActivityContainerComponent as ɵba, InteractionContextBase as ɵbb, InteractionContext as ɵbc, ActivityOutletComponent as ɵbd, ConfirmationDialogComponent as ɵbe, AbstractActivity as ɵbf, ACTIVITY_DATA as ɵbg, Activity as ɵbh, ConfirmThenDialogComponent as ɵbj, AlertDialogComponent as ɵbk, InteractionOutletComponent as ɵbm, InplaceInteractionContextComponent as ɵbn, DIALOG_INTERACTION_SERVICE_DEFAULTS as ɵbo, DialogInteractionService as ɵbp, FocusBindingDirective as ɵc, DisposableComponent as ɵd, ComponentsModule as ɵe, NumberInputComponent as ɵf, AbstractInputComponent as ɵg, StringInputComponent as ɵh, PasswordInputComponent as ɵi, SelectInputComponent as ɵj, NoopComponent as ɵk, PlaceModule as ɵl, EmptyStateComponent as ɵm, BusyOverlayComponent as ɵn, PlaceOutletComponent as ɵo, leftRightPlaceAnimation as ɵp, LEFT_RIGHT_PLACE_ANIMATION as ɵq, AUP_PLACE_CONFIG as ɵr, PlaceRouter as ɵt, PlaceHistory as ɵu, ModalInteractionService as ɵv, TabbedPlaceNavigationComponent as ɵw, AbstractPlaceNavigationComponent as ɵx, ListPlaceNavComponent as ɵy, InteractionModule as ɵz };
7757
+ export { ACTIVITY_DATA, AUP_PLACE_CONFIG, AbstractActivity, AbstractInputComponent, AbstractPlaceGuard, AbstractPlaceNavigationComponent, Activity, ActivityContainerComponent, ActivityOutletComponent, AlertDialogComponent, AngularUiPowerupsModule, Bounds, BusyOverlayComponent, CommandDirective, ComponentsModule, ConfirmThenDialogComponent, ConfirmationDialogComponent, ConsolidatedParameterMap, DEFINITION_META_DATA_KEY, DIALOG_INTERACTION_SERVICE_DEFAULTS, DialogInteractionContext, DialogInteractionContextFactory, Dimension, DirectivesModule, DisposableComponent, EmptyStateComponent, FocusBindingDirective, Formatter, InplaceInteractionContextComponent, InteractionContext, InteractionContextBase, InteractionGuard, InteractionModule, InteractionOutletComponent, InteractionService, LEFT_RIGHT_PLACE_ANIMATION, ListPlaceNavComponent, ModalInteractionContextFactory, NavigationState, NoopAuthGuard, NoopComponent, NumberInputComponent, ParameterDefinition, PasswordInputComponent, Place, PlaceComponent, PlaceComponentDeactivationHandler, PlaceDefinition, PlaceHistory, PlaceModule, PlaceOutletComponent, PlaceRouter, Point, ROUTE_PARAMETER_LIST_KEY, ResizeAwareComponent, RouteId, SelectInputComponent, StringInputComponent, TabbedPlaceNavigationComponent, UrlSnapshot, Visit, VisitParameter, VisitParameterList, VisitSanitiser, leftRightPlaceAnimation, slideDownAndUpAnimation, DirectivesModule as ɵa, CommandDirective as ɵb, InteractionModule as ɵba, ActivityContainerComponent as ɵbb, InteractionContextBase as ɵbc, InteractionContext as ɵbd, ActivityOutletComponent as ɵbe, ConfirmationDialogComponent as ɵbf, AbstractActivity as ɵbg, ACTIVITY_DATA as ɵbh, Activity as ɵbi, ConfirmThenDialogComponent as ɵbk, AlertDialogComponent as ɵbl, InteractionOutletComponent as ɵbn, InplaceInteractionContextComponent as ɵbo, FocusBindingDirective as ɵc, DisposableComponent as ɵd, ComponentsModule as ɵe, NumberInputComponent as ɵf, AbstractInputComponent as ɵg, StringInputComponent as ɵh, PasswordInputComponent as ɵi, SelectInputComponent as ɵj, NoopComponent as ɵk, PlaceModule as ɵl, EmptyStateComponent as ɵm, BusyOverlayComponent as ɵn, PlaceOutletComponent as ɵo, leftRightPlaceAnimation as ɵp, LEFT_RIGHT_PLACE_ANIMATION as ɵq, AUP_PLACE_CONFIG as ɵr, PlaceRouter as ɵt, PlaceHistory as ɵu, InteractionService as ɵv, ModalInteractionContextFactory as ɵw, TabbedPlaceNavigationComponent as ɵx, AbstractPlaceNavigationComponent as ɵy, ListPlaceNavComponent as ɵz };
7658
7758
  //# sourceMappingURL=coolon-angular-ui-powerups.js.map