@coolon/angular-ui-powerups 0.0.101 → 0.0.103
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/coolon-angular-ui-powerups.umd.js +885 -632
- package/bundles/coolon-angular-ui-powerups.umd.js.map +1 -1
- package/bundles/coolon-angular-ui-powerups.umd.min.js +1 -1
- package/bundles/coolon-angular-ui-powerups.umd.min.js.map +1 -1
- package/coolon-angular-ui-powerups.d.ts +1 -2
- package/coolon-angular-ui-powerups.metadata.json +1 -1
- package/esm2015/coolon-angular-ui-powerups.js +3 -4
- package/esm2015/index.js +2 -2
- package/esm2015/lib/interaction/components/activity-container/activity-container.component.js +2 -1
- package/esm2015/lib/interaction/index.js +1 -2
- package/esm2015/lib/interaction/interaction-context-base.js +21 -8
- package/esm2015/lib/interaction/interaction-context.js +56 -3
- package/esm2015/lib/interaction/interaction.module.js +1 -4
- package/esm2015/lib/interaction/services/interaction.service.js +11 -7
- package/esm2015/lib/place/guards/navigation-state.js +216 -135
- package/esm2015/lib/place/guards/place-component-deactivation-handler.js +63 -28
- package/esm2015/lib/place/guards/place.guard.js +215 -0
- package/esm2015/lib/place/index.js +2 -3
- package/esm2015/lib/place/place-router.js +34 -36
- package/esm2015/lib/place/place.decorator.js +2 -2
- package/esm2015/lib/place/url-snapshot.js +69 -53
- package/esm2015/public_api.js +3 -3
- package/esm5/coolon-angular-ui-powerups.js +3 -4
- package/esm5/index.js +2 -2
- package/esm5/lib/interaction/components/activity-container/activity-container.component.js +2 -1
- package/esm5/lib/interaction/index.js +1 -2
- package/esm5/lib/interaction/interaction-context-base.js +25 -8
- package/esm5/lib/interaction/interaction-context.js +88 -10
- package/esm5/lib/interaction/interaction.module.js +1 -4
- package/esm5/lib/interaction/services/interaction.service.js +17 -8
- package/esm5/lib/place/guards/navigation-state.js +280 -162
- package/esm5/lib/place/guards/place-component-deactivation-handler.js +73 -27
- package/esm5/lib/place/guards/place.guard.js +300 -0
- package/esm5/lib/place/index.js +2 -3
- package/esm5/lib/place/place-router.js +52 -39
- package/esm5/lib/place/place.decorator.js +2 -2
- package/esm5/lib/place/url-snapshot.js +85 -58
- package/esm5/public_api.js +3 -3
- package/fesm2015/coolon-angular-ui-powerups.js +661 -539
- package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
- package/fesm5/coolon-angular-ui-powerups.js +884 -628
- package/fesm5/coolon-angular-ui-powerups.js.map +1 -1
- package/lib/interaction/index.d.ts +0 -1
- package/lib/interaction/interaction-context-base.d.ts +3 -1
- package/lib/interaction/interaction-context.d.ts +9 -2
- package/lib/interaction/services/interaction.service.d.ts +2 -2
- package/lib/place/guards/navigation-state.d.ts +44 -38
- package/lib/place/guards/place-component-deactivation-handler.d.ts +7 -4
- package/lib/place/guards/{abstract-place.guard.d.ts → place.guard.d.ts} +8 -3
- package/lib/place/index.d.ts +1 -2
- package/lib/place/place-router.d.ts +2 -0
- package/lib/place/url-snapshot.d.ts +14 -9
- package/package.json +1 -1
- package/schematics/place-routes/place-def.js +1 -0
- package/schematics/place-routes/place-def.js.map +1 -1
- package/schematics/place-routes/templates/place-routes.ts.template +10 -11
- package/esm2015/lib/interaction/components/interaction-outlet/interaction-outlet.component.js +0 -19
- package/esm2015/lib/place/guards/abstract-place.guard.js +0 -166
- package/esm2015/lib/place/guards/interaction.guard.js +0 -121
- package/esm5/lib/interaction/components/interaction-outlet/interaction-outlet.component.js +0 -21
- package/esm5/lib/place/guards/abstract-place.guard.js +0 -213
- package/esm5/lib/place/guards/interaction.guard.js +0 -133
- package/lib/interaction/components/interaction-outlet/interaction-outlet.component.d.ts +0 -3
- package/lib/place/guards/interaction.guard.d.ts +0 -17
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { DOCUMENT, CommonModule, Location } from '@angular/common';
|
|
2
|
-
import { Directive, ElementRef, Inject, Input, HostListener, NgZone, NgModule, EventEmitter, Output, Component, InjectionToken, Injector, ComponentFactoryResolver, ViewContainerRef, ViewChild, ViewChildren, Injectable, ɵɵdefineInjectable, ɵɵinject, Optional, SkipSelf, HostBinding
|
|
2
|
+
import { Directive, ElementRef, Inject, Input, HostListener, NgZone, NgModule, EventEmitter, Output, Component, InjectionToken, Injector, ComponentFactoryResolver, ViewContainerRef, ViewChild, ViewChildren, Injectable, ɵɵdefineInjectable, ɵɵinject, Optional, SkipSelf, HostBinding } from '@angular/core';
|
|
3
3
|
import { FormsModule } from '@angular/forms';
|
|
4
4
|
import { MatInputModule, MatFormFieldModule, MatSelectModule, MatButtonModule, MatDialogModule, MatTabsModule as MatTabsModule$1, MatProgressSpinnerModule, MatDialog } from '@angular/material';
|
|
5
5
|
import { MatTabsModule } from '@angular/material/tabs';
|
|
6
6
|
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
|
7
|
-
import { GarbageCollector, DelegatingValueModel, assert, UnaryCommand, lang, Dsl, Logger, DelegatingFormValueModel, UseDelegate, ValueModel, ListModel, StoreInListModel, DelegatingListModel, Deferred, MutableStream, MutableValueModel, MutableListModel, Binding,
|
|
7
|
+
import { GarbageCollector, DelegatingValueModel, assert, UnaryCommand, lang, Dsl, Logger, DelegatingFormValueModel, UseDelegate, ValueModel, ListModel, StoreInListModel, Trace, DelegatingListModel, Deferred, MutableStream, MutableValueModel, MutableListModel, Binding, Guard, StoreInValueModel, Command, OptionsHelper, ValueHolder } from '@coolon/pectin';
|
|
8
8
|
import { __decorate, __metadata, __awaiter } from 'tslib';
|
|
9
9
|
import { PortalModule } from '@angular/cdk/portal';
|
|
10
|
-
import { RouterModule,
|
|
11
|
-
import ___default, { last, isNil, isEqual } from 'lodash';
|
|
10
|
+
import { RouterModule, NavigationStart, NavigationCancel, UrlSegment, NavigationEnd, NavigationError, Router, UrlSerializer } from '@angular/router';
|
|
12
11
|
import { assert as assert$1, Opts, Klass } from '@coolon/typescript-utilities';
|
|
13
12
|
import { MatIconModule } from '@angular/material/icon';
|
|
14
13
|
import { MatListModule } from '@angular/material/list';
|
|
@@ -16,6 +15,7 @@ import { MatTooltipModule } from '@angular/material/tooltip';
|
|
|
16
15
|
import { Memoize } from '@typescript-plus/fast-memoize-decorator/dist/src';
|
|
17
16
|
import { Memoize as Memoize$1 } from '@typescript-plus/fast-memoize-decorator';
|
|
18
17
|
import 'reflect-metadata';
|
|
18
|
+
import ___default, { isNil, isEqual } from 'lodash';
|
|
19
19
|
import { style, query, group, animate, trigger, transition } from '@angular/animations';
|
|
20
20
|
import ResizeObserver from 'resize-observer-polyfill';
|
|
21
21
|
import { MatDialogConfig, MAT_DIALOG_DEFAULT_OPTIONS, MatDialog as MatDialog$1 } from '@angular/material/dialog';
|
|
@@ -912,16 +912,68 @@ class InteractionContext extends GarbageCollector {
|
|
|
912
912
|
assert.isFalsey(this.isActive());
|
|
913
913
|
super.dispose();
|
|
914
914
|
}
|
|
915
|
+
/**
|
|
916
|
+
* Cancels the current activity and returns true the context is no longer active, false if
|
|
917
|
+
* there is still another activity running.
|
|
918
|
+
* @return {?}
|
|
919
|
+
*/
|
|
920
|
+
cancelCurrentActivity() {
|
|
921
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
922
|
+
const { when } = Dsl.disposeWith(this);
|
|
923
|
+
/** @type {?} */
|
|
924
|
+
const activity = yield this.getCurrentActivity();
|
|
925
|
+
return new Promise((/**
|
|
926
|
+
* @param {?} resolve
|
|
927
|
+
* @return {?}
|
|
928
|
+
*/
|
|
929
|
+
resolve => {
|
|
930
|
+
when.valueOf(this.activeActivity)
|
|
931
|
+
.changes((/**
|
|
932
|
+
* @param {?} nextActivity
|
|
933
|
+
* @return {?}
|
|
934
|
+
*/
|
|
935
|
+
nextActivity => {
|
|
936
|
+
resolve(!nextActivity);
|
|
937
|
+
}), { once: true });
|
|
938
|
+
activity.cancel();
|
|
939
|
+
}));
|
|
940
|
+
});
|
|
941
|
+
}
|
|
942
|
+
/**
|
|
943
|
+
* @return {?}
|
|
944
|
+
*/
|
|
945
|
+
abort() {
|
|
946
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
947
|
+
assert.isTruthy(this.isActive());
|
|
948
|
+
/** @type {?} */
|
|
949
|
+
let count = 1;
|
|
950
|
+
yield this.cancelCurrentActivity();
|
|
951
|
+
console.log(`aborted -> ${count++}`);
|
|
952
|
+
while (this.isActive()) {
|
|
953
|
+
yield this.cancelCurrentActivity();
|
|
954
|
+
console.log(`aborted -> ${count++}`);
|
|
955
|
+
}
|
|
956
|
+
});
|
|
957
|
+
}
|
|
915
958
|
}
|
|
959
|
+
__decorate([
|
|
960
|
+
Trace(),
|
|
961
|
+
__metadata("design:type", Function),
|
|
962
|
+
__metadata("design:paramtypes", []),
|
|
963
|
+
__metadata("design:returntype", Promise)
|
|
964
|
+
], InteractionContext.prototype, "abort", null);
|
|
916
965
|
if (false) {
|
|
966
|
+
/** @type {?} */
|
|
967
|
+
InteractionContext.prototype.active;
|
|
917
968
|
/** @type {?} */
|
|
918
969
|
InteractionContext.prototype.activityList;
|
|
919
970
|
/** @type {?} */
|
|
920
|
-
InteractionContext.prototype.
|
|
971
|
+
InteractionContext.prototype.activeActivity;
|
|
921
972
|
/**
|
|
922
973
|
* Returns the activity that is currently active.
|
|
923
974
|
* This model is only updated in the next tick after the view has been updated.
|
|
924
975
|
* @abstract
|
|
976
|
+
* @protected
|
|
925
977
|
* @return {?}
|
|
926
978
|
*/
|
|
927
979
|
InteractionContext.prototype.getCurrentActivity = function () { };
|
|
@@ -1110,13 +1162,14 @@ class InteractionContextBase extends InteractionContext {
|
|
|
1110
1162
|
*/
|
|
1111
1163
|
this._activityListDelegate = new DelegatingListModel();
|
|
1112
1164
|
const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);
|
|
1113
|
-
|
|
1114
|
-
|
|
1165
|
+
this._currentActivity = chain(this.activityList).last();
|
|
1166
|
+
when.valueOf(this._currentActivity).becomesTruthy((/**
|
|
1167
|
+
* @param {?} activity
|
|
1115
1168
|
* @return {?}
|
|
1116
1169
|
*/
|
|
1117
|
-
(
|
|
1170
|
+
(activity) => {
|
|
1118
1171
|
if (this.deferredGetCurrentActivity) {
|
|
1119
|
-
this.deferredGetCurrentActivity.resolve(
|
|
1172
|
+
this.deferredGetCurrentActivity.resolve(activity);
|
|
1120
1173
|
this.deferredGetCurrentActivity = null;
|
|
1121
1174
|
}
|
|
1122
1175
|
}));
|
|
@@ -1135,6 +1188,12 @@ class InteractionContextBase extends InteractionContext {
|
|
|
1135
1188
|
get activityList() {
|
|
1136
1189
|
return this._activityListDelegate.readonly;
|
|
1137
1190
|
}
|
|
1191
|
+
/**
|
|
1192
|
+
* @return {?}
|
|
1193
|
+
*/
|
|
1194
|
+
get activeActivity() {
|
|
1195
|
+
return this._currentActivity;
|
|
1196
|
+
}
|
|
1138
1197
|
/**
|
|
1139
1198
|
* Returns the activity that is currently active.
|
|
1140
1199
|
* This model is only updated in the next tick after the view has been updated.
|
|
@@ -1151,12 +1210,14 @@ class InteractionContextBase extends InteractionContext {
|
|
|
1151
1210
|
return this.deferredGetCurrentActivity.promise;
|
|
1152
1211
|
}
|
|
1153
1212
|
else {
|
|
1154
|
-
if (this.
|
|
1213
|
+
if (!this._currentActivity.value) {
|
|
1214
|
+
// we'be been asked before we've got any activities, create a deferred promise
|
|
1215
|
+
// that we resolve when the list populates.
|
|
1155
1216
|
this.deferredGetCurrentActivity = Deferred.defer();
|
|
1156
1217
|
return this.deferredGetCurrentActivity.promise;
|
|
1157
1218
|
}
|
|
1158
1219
|
else {
|
|
1159
|
-
return
|
|
1220
|
+
return this._currentActivity.value;
|
|
1160
1221
|
}
|
|
1161
1222
|
}
|
|
1162
1223
|
}
|
|
@@ -1230,6 +1291,11 @@ if (false) {
|
|
|
1230
1291
|
* @private
|
|
1231
1292
|
*/
|
|
1232
1293
|
InteractionContextBase.prototype.deferredGetCurrentActivity;
|
|
1294
|
+
/**
|
|
1295
|
+
* @type {?}
|
|
1296
|
+
* @private
|
|
1297
|
+
*/
|
|
1298
|
+
InteractionContextBase.prototype._currentActivity;
|
|
1233
1299
|
/**
|
|
1234
1300
|
* @abstract
|
|
1235
1301
|
* @protected
|
|
@@ -1589,6 +1655,7 @@ class ActivityContainerComponent extends InteractionContextBase {
|
|
|
1589
1655
|
* @return {?}
|
|
1590
1656
|
*/
|
|
1591
1657
|
finishInitialActivity() {
|
|
1658
|
+
this.updateActivityList();
|
|
1592
1659
|
this._initialActivityOutletContext.value = null;
|
|
1593
1660
|
this.initialActivityOutletContextEvent.emit(null);
|
|
1594
1661
|
}
|
|
@@ -1778,6 +1845,12 @@ class InteractionService {
|
|
|
1778
1845
|
isActive() {
|
|
1779
1846
|
return this.active.value;
|
|
1780
1847
|
}
|
|
1848
|
+
/**
|
|
1849
|
+
* @return {?}
|
|
1850
|
+
*/
|
|
1851
|
+
isModalActive() {
|
|
1852
|
+
return this.modelInteractionActive.value;
|
|
1853
|
+
}
|
|
1781
1854
|
/**
|
|
1782
1855
|
* @param {?} disposable
|
|
1783
1856
|
* @return {?}
|
|
@@ -1795,14 +1868,13 @@ class InteractionService {
|
|
|
1795
1868
|
_registerInplaceInteractionContext(interactionContext) {
|
|
1796
1869
|
interactionContext.registerDisposable(new InteractionService.Monitor(`ip${++inplaceMonitorCount}`, interactionContext, this._activeInlineInteractionContextModel, this.exclusiveContext));
|
|
1797
1870
|
}
|
|
1871
|
+
// @Trace()
|
|
1798
1872
|
/**
|
|
1799
1873
|
* @return {?}
|
|
1800
1874
|
*/
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
return this._activeInteractionContext.value.getCurrentActivity();
|
|
1805
|
-
});
|
|
1875
|
+
getActiveContext() {
|
|
1876
|
+
assert$1.isTruthy(this.isActive());
|
|
1877
|
+
return this._activeInteractionContext.value;
|
|
1806
1878
|
}
|
|
1807
1879
|
/**
|
|
1808
1880
|
* Creates an interaction context that will prevent any other contexts from starting an
|
|
@@ -2060,24 +2132,6 @@ if (false) {
|
|
|
2060
2132
|
InplaceInteractionContextComponent.prototype.interactionService;
|
|
2061
2133
|
}
|
|
2062
2134
|
|
|
2063
|
-
/**
|
|
2064
|
-
* @fileoverview added by tsickle
|
|
2065
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2066
|
-
*/
|
|
2067
|
-
class InteractionOutletComponent {
|
|
2068
|
-
constructor() {
|
|
2069
|
-
}
|
|
2070
|
-
}
|
|
2071
|
-
InteractionOutletComponent.decorators = [
|
|
2072
|
-
{ type: Component, args: [{
|
|
2073
|
-
selector: 'aup-interaction-outlet',
|
|
2074
|
-
template: "<router-outlet name=\"interaction-context\"></router-outlet>\n",
|
|
2075
|
-
styles: [":host{display:block}"]
|
|
2076
|
-
}] }
|
|
2077
|
-
];
|
|
2078
|
-
/** @nocollapse */
|
|
2079
|
-
InteractionOutletComponent.ctorParameters = () => [];
|
|
2080
|
-
|
|
2081
2135
|
/**
|
|
2082
2136
|
* @fileoverview added by tsickle
|
|
2083
2137
|
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
@@ -2100,13 +2154,11 @@ InteractionModule.decorators = [
|
|
|
2100
2154
|
ConfirmThenDialogComponent,
|
|
2101
2155
|
AlertDialogComponent,
|
|
2102
2156
|
ActivityOutletComponent,
|
|
2103
|
-
InteractionOutletComponent,
|
|
2104
2157
|
InplaceInteractionContextComponent
|
|
2105
2158
|
],
|
|
2106
2159
|
exports: [
|
|
2107
2160
|
ActivityContainerComponent,
|
|
2108
2161
|
ActivityOutletComponent,
|
|
2109
|
-
InteractionOutletComponent,
|
|
2110
2162
|
InplaceInteractionContextComponent
|
|
2111
2163
|
],
|
|
2112
2164
|
entryComponents: [
|
|
@@ -2894,57 +2946,89 @@ if (false) {
|
|
|
2894
2946
|
class PlaceComponentDeactivationHandler {
|
|
2895
2947
|
/**
|
|
2896
2948
|
* @param {?} component
|
|
2897
|
-
* @param {?}
|
|
2949
|
+
* @param {?} navigationState
|
|
2950
|
+
* @param {?} isPrimaryComponent
|
|
2898
2951
|
*/
|
|
2899
|
-
constructor(component,
|
|
2952
|
+
constructor(component, navigationState, isPrimaryComponent) {
|
|
2900
2953
|
this.component = component;
|
|
2901
|
-
this.
|
|
2954
|
+
this.navigationState = navigationState;
|
|
2955
|
+
this.isPrimaryComponent = isPrimaryComponent;
|
|
2956
|
+
}
|
|
2957
|
+
/**
|
|
2958
|
+
* @return {?}
|
|
2959
|
+
*/
|
|
2960
|
+
get interactionService() {
|
|
2961
|
+
return this.navigationState.interactionService;
|
|
2902
2962
|
}
|
|
2903
2963
|
/**
|
|
2964
|
+
* @return {?}
|
|
2965
|
+
*/
|
|
2966
|
+
get placeRouter() {
|
|
2967
|
+
return this.navigationState.placeRouter;
|
|
2968
|
+
}
|
|
2969
|
+
/**
|
|
2970
|
+
* @param {?} currentUrl
|
|
2904
2971
|
* @param {?} nextState
|
|
2905
2972
|
* @return {?}
|
|
2906
2973
|
*/
|
|
2907
|
-
canDeactivate(nextState) {
|
|
2974
|
+
canDeactivate(currentUrl, nextState) {
|
|
2908
2975
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2909
2976
|
// We'll get called multiple times if there's any parameter sanitisation so
|
|
2910
2977
|
// we always return true if we accepted promise from a previous cycle of the current
|
|
2911
2978
|
// navigation session.
|
|
2912
2979
|
if (!this.canDeactivatePromise) {
|
|
2913
|
-
|
|
2980
|
+
console.log(`creating deactivate promise for -> ${this.component.constructor.name}`);
|
|
2981
|
+
this.canDeactivatePromise = this.canDeactivateComponent(currentUrl, nextState);
|
|
2914
2982
|
}
|
|
2915
2983
|
return this.canDeactivatePromise;
|
|
2916
2984
|
});
|
|
2917
2985
|
}
|
|
2986
|
+
// @Trace()
|
|
2918
2987
|
/**
|
|
2919
2988
|
* @protected
|
|
2989
|
+
* @param {?} currentUrl
|
|
2920
2990
|
* @param {?} nextState
|
|
2921
2991
|
* @return {?}
|
|
2922
2992
|
*/
|
|
2923
|
-
canDeactivateComponent(nextState) {
|
|
2993
|
+
canDeactivateComponent(currentUrl, nextState) {
|
|
2924
2994
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2995
|
+
console.log(this.navigationState.toString());
|
|
2925
2996
|
// Automatically cancel any active activities if the navigation session was triggered by the back button.
|
|
2926
|
-
//
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2997
|
+
// If we handled more than just the pop state then it leads to the UI ignoring clicks and just cancelling things which is deeply disconcerting.
|
|
2998
|
+
if (this.navigationState.isPopState) {
|
|
2999
|
+
if (this.isPrimaryComponent && this.interactionService.isModalActive()) {
|
|
3000
|
+
/** @type {?} */
|
|
3001
|
+
const routeIds = this.placeRouter.getActiveInteractionIdsFromUrl(nextState.url);
|
|
3002
|
+
/** @type {?} */
|
|
3003
|
+
const currentIds = this.interactionService.activeInteractionContextIds.value;
|
|
3004
|
+
if (!isEqual(currentIds, routeIds)) {
|
|
3005
|
+
yield this.interactionService.getActiveContext().cancelCurrentActivity();
|
|
3006
|
+
return currentUrl.updateInteractionIds(this.interactionService.activeInteractionContextIds.value);
|
|
3007
|
+
}
|
|
3008
|
+
}
|
|
3009
|
+
else {
|
|
3010
|
+
// check if the component has an in place interaction
|
|
3011
|
+
if (this.component.interactionContext && this.component.interactionContext.isActive()) {
|
|
3012
|
+
yield this.component.interactionContext.cancelCurrentActivity();
|
|
3013
|
+
return currentUrl
|
|
3014
|
+
.updateInteractionIds(this.interactionService.activeInteractionContextIds.value);
|
|
3015
|
+
}
|
|
3016
|
+
}
|
|
2941
3017
|
}
|
|
2942
3018
|
// Ok, so now we're really leaving, so we ask the component if we should.;
|
|
2943
|
-
if (this.isNotJustAChangeInRouteId(nextState)
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
3019
|
+
if (this.isNotJustAChangeInRouteId(nextState)) {
|
|
3020
|
+
if (this.component.canDeactivate) {
|
|
3021
|
+
// No interaction in progress, so ask the component .
|
|
3022
|
+
// This may start an interaction, hence checking the interaction context before now. I.e. if the place pops up the dialog, and
|
|
3023
|
+
// the user clicks back again, we'll re-enter here and go bang when the component tries to open another dialog.
|
|
3024
|
+
return this.component.canDeactivate(this.navigationState.interactionContext);
|
|
3025
|
+
}
|
|
3026
|
+
// The component has an active interaction but no deactivation hook. Rather than guessing what to do
|
|
3027
|
+
// we'll just cancel the navigation and print a warning.
|
|
3028
|
+
if (this.component.interactionContext && this.component.interactionContext.isActive()) {
|
|
3029
|
+
console.warn('Route changed while component has active interaction, cancelling navigation');
|
|
3030
|
+
return false;
|
|
3031
|
+
}
|
|
2948
3032
|
}
|
|
2949
3033
|
return true;
|
|
2950
3034
|
});
|
|
@@ -2970,7 +3054,9 @@ if (false) {
|
|
|
2970
3054
|
/** @type {?} */
|
|
2971
3055
|
PlaceComponentDeactivationHandler.prototype.component;
|
|
2972
3056
|
/** @type {?} */
|
|
2973
|
-
PlaceComponentDeactivationHandler.prototype.
|
|
3057
|
+
PlaceComponentDeactivationHandler.prototype.navigationState;
|
|
3058
|
+
/** @type {?} */
|
|
3059
|
+
PlaceComponentDeactivationHandler.prototype.isPrimaryComponent;
|
|
2974
3060
|
}
|
|
2975
3061
|
|
|
2976
3062
|
/**
|
|
@@ -2989,6 +3075,12 @@ class NavigationState extends GarbageCollector {
|
|
|
2989
3075
|
this.context = context;
|
|
2990
3076
|
this._visits = new Map();
|
|
2991
3077
|
}
|
|
3078
|
+
/**
|
|
3079
|
+
* @return {?}
|
|
3080
|
+
*/
|
|
3081
|
+
get name() {
|
|
3082
|
+
return this.constructor.name;
|
|
3083
|
+
}
|
|
2992
3084
|
/**
|
|
2993
3085
|
* @return {?}
|
|
2994
3086
|
*/
|
|
@@ -3027,6 +3119,14 @@ class NavigationState extends GarbageCollector {
|
|
|
3027
3119
|
getVisitFor(placeDef) {
|
|
3028
3120
|
return this._visits.get(placeDef);
|
|
3029
3121
|
}
|
|
3122
|
+
/**
|
|
3123
|
+
* @param {?} visit
|
|
3124
|
+
* @param {?} initialUrl
|
|
3125
|
+
* @return {?}
|
|
3126
|
+
*/
|
|
3127
|
+
onPlaceNavigationStart(visit, initialUrl) {
|
|
3128
|
+
return this.illegalTransition('onPlaceNavigationStart');
|
|
3129
|
+
}
|
|
3030
3130
|
/**
|
|
3031
3131
|
* @param {?} event
|
|
3032
3132
|
* @return {?}
|
|
@@ -3038,28 +3138,28 @@ class NavigationState extends GarbageCollector {
|
|
|
3038
3138
|
* @param {?} event
|
|
3039
3139
|
* @return {?}
|
|
3040
3140
|
*/
|
|
3041
|
-
|
|
3141
|
+
onRouterStarted(event) {
|
|
3042
3142
|
return this.illegalTransition(event);
|
|
3043
3143
|
}
|
|
3044
3144
|
/**
|
|
3045
3145
|
* @param {?} event
|
|
3046
3146
|
* @return {?}
|
|
3047
3147
|
*/
|
|
3048
|
-
|
|
3148
|
+
onRouterCancelled(event) {
|
|
3049
3149
|
return this.illegalTransition(event);
|
|
3050
3150
|
}
|
|
3051
3151
|
/**
|
|
3052
3152
|
* @param {?} event
|
|
3053
3153
|
* @return {?}
|
|
3054
3154
|
*/
|
|
3055
|
-
|
|
3155
|
+
onRouterError(event) {
|
|
3056
3156
|
return this.illegalTransition(event);
|
|
3057
3157
|
}
|
|
3058
3158
|
/**
|
|
3059
3159
|
* @param {?} event
|
|
3060
3160
|
* @return {?}
|
|
3061
3161
|
*/
|
|
3062
|
-
|
|
3162
|
+
onRouterEnd(event) {
|
|
3063
3163
|
return this.illegalTransition(event);
|
|
3064
3164
|
}
|
|
3065
3165
|
/**
|
|
@@ -3071,10 +3171,11 @@ class NavigationState extends GarbageCollector {
|
|
|
3071
3171
|
}
|
|
3072
3172
|
/**
|
|
3073
3173
|
* @param {?} component
|
|
3074
|
-
* @param {?}
|
|
3174
|
+
* @param {?} currentUrl
|
|
3175
|
+
* @param {?} nextUrl
|
|
3075
3176
|
* @return {?}
|
|
3076
3177
|
*/
|
|
3077
|
-
canDeactivatePlace(component,
|
|
3178
|
+
canDeactivatePlace(component, currentUrl, nextUrl) {
|
|
3078
3179
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3079
3180
|
return this.illegalTransition('canDeactivatePlace');
|
|
3080
3181
|
});
|
|
@@ -3107,23 +3208,32 @@ class NavigationState extends GarbageCollector {
|
|
|
3107
3208
|
* @return {?}
|
|
3108
3209
|
*/
|
|
3109
3210
|
createTransitionStateFor(event) {
|
|
3110
|
-
// TODO: check if the event is purely for interaction context changes.
|
|
3111
3211
|
/** @type {?} */
|
|
3112
3212
|
const popstate = event.navigationTrigger === 'popstate';
|
|
3113
3213
|
return popstate ?
|
|
3114
|
-
|
|
3115
|
-
|
|
3214
|
+
this.interactionService.isActive() ?
|
|
3215
|
+
new NavigationState.InteractionPopStateTransition(this.context, this.currentRouterUrl()) :
|
|
3216
|
+
new NavigationState.PopStateTransition(this.context, this.currentRouterUrl())
|
|
3217
|
+
:
|
|
3218
|
+
this.interactionService.isActive() ?
|
|
3219
|
+
new NavigationState.InteractionTransition(this.context, this.currentRouterUrl()) :
|
|
3220
|
+
new NavigationState.NavigationTransition(this.context, this.currentRouterUrl());
|
|
3221
|
+
}
|
|
3222
|
+
/**
|
|
3223
|
+
* @protected
|
|
3224
|
+
* @return {?}
|
|
3225
|
+
*/
|
|
3226
|
+
createIdleState() {
|
|
3227
|
+
return this.interactionService.isActive() ?
|
|
3228
|
+
new NavigationState.IdleDuringInteraction(this.context, this.currentRouterUrl()) :
|
|
3229
|
+
new NavigationState.Idle(this.context);
|
|
3116
3230
|
}
|
|
3117
3231
|
/**
|
|
3118
3232
|
* @param {?} url
|
|
3119
3233
|
* @return {?}
|
|
3120
3234
|
*/
|
|
3121
3235
|
resetBrowserLocation(url) {
|
|
3122
|
-
|
|
3123
|
-
setTimeout((/**
|
|
3124
|
-
* @return {?}
|
|
3125
|
-
*/
|
|
3126
|
-
() => this.placeRouter.resetBrowserLocation(url)));
|
|
3236
|
+
this.placeRouter.resetBrowserLocation(url);
|
|
3127
3237
|
}
|
|
3128
3238
|
/**
|
|
3129
3239
|
* @return {?}
|
|
@@ -3182,11 +3292,22 @@ if (false) {
|
|
|
3182
3292
|
this.startingUrl = null;
|
|
3183
3293
|
this.isPopState = false;
|
|
3184
3294
|
}
|
|
3295
|
+
/**
|
|
3296
|
+
* @param {?} visit
|
|
3297
|
+
* @param {?} initialUrl
|
|
3298
|
+
* @return {?}
|
|
3299
|
+
*/
|
|
3300
|
+
onPlaceNavigationStart(visit, initialUrl) {
|
|
3301
|
+
/** @type {?} */
|
|
3302
|
+
const navigationTransition = new NavigationTransition(this.context, initialUrl);
|
|
3303
|
+
navigationTransition.storeVisit(visit);
|
|
3304
|
+
return navigationTransition;
|
|
3305
|
+
}
|
|
3185
3306
|
/**
|
|
3186
3307
|
* @param {?} event
|
|
3187
3308
|
* @return {?}
|
|
3188
3309
|
*/
|
|
3189
|
-
|
|
3310
|
+
onRouterStarted(event) {
|
|
3190
3311
|
// calling angularLocation.go() to clear back state can trigger router cycles to the current url if we don't ignore them
|
|
3191
3312
|
if (event.url === this.currentRouterUrl()) {
|
|
3192
3313
|
Logger.get(this).info(`navigation started to same url -> ${event.url}`);
|
|
@@ -3223,12 +3344,10 @@ if (false) {
|
|
|
3223
3344
|
class AbstractNavigationTransition extends NavigationState {
|
|
3224
3345
|
/**
|
|
3225
3346
|
* @param {?} context
|
|
3226
|
-
* @param {?} isPopState
|
|
3227
3347
|
* @param {?} startingUrl
|
|
3228
3348
|
*/
|
|
3229
|
-
constructor(context,
|
|
3349
|
+
constructor(context, startingUrl) {
|
|
3230
3350
|
super(context);
|
|
3231
|
-
this.isPopState = isPopState;
|
|
3232
3351
|
this.startingUrl = startingUrl;
|
|
3233
3352
|
this.isTransitional = true;
|
|
3234
3353
|
this.componentDeactivationHandlers = new Map();
|
|
@@ -3256,7 +3375,7 @@ if (false) {
|
|
|
3256
3375
|
* @param {?} event
|
|
3257
3376
|
* @return {?}
|
|
3258
3377
|
*/
|
|
3259
|
-
|
|
3378
|
+
onRouterStarted(event) {
|
|
3260
3379
|
// active sessions can have many cancel start cycles due
|
|
3261
3380
|
// to place guard redirects
|
|
3262
3381
|
return this;
|
|
@@ -3265,7 +3384,7 @@ if (false) {
|
|
|
3265
3384
|
* @param {?} event
|
|
3266
3385
|
* @return {?}
|
|
3267
3386
|
*/
|
|
3268
|
-
|
|
3387
|
+
onRouterEnd(event) {
|
|
3269
3388
|
// navigation succeeded
|
|
3270
3389
|
this.context.notifySuccess(this);
|
|
3271
3390
|
return new Idle(this.context);
|
|
@@ -3275,32 +3394,29 @@ if (false) {
|
|
|
3275
3394
|
* @return {?}
|
|
3276
3395
|
*/
|
|
3277
3396
|
onBackClickedDuringNavigationInteraction(locationTriggerUrl) {
|
|
3278
|
-
|
|
3279
|
-
// has completed.
|
|
3397
|
+
Logger.get(this).info(`back button pressed during navigation session interaction promise`);
|
|
3398
|
+
// detach the interaction from the session so it doesn't get disposed until the activity has completed.
|
|
3280
3399
|
/** @type {?} */
|
|
3281
|
-
const
|
|
3282
|
-
const { when } = Dsl.disposeWith(
|
|
3400
|
+
const navigationInteraction = this.detachInteractionContext();
|
|
3401
|
+
const { when } = Dsl.disposeWith(navigationInteraction);
|
|
3283
3402
|
// TODO: I need to make the exclusive interaction context disallow nested activities or
|
|
3284
|
-
// that would mess things up entirely.
|
|
3285
|
-
|
|
3286
|
-
* @param {?} activity
|
|
3403
|
+
// that would mess things up entirely. Or, can I do a context.abortAll().then(..)
|
|
3404
|
+
navigationInteraction.cancelCurrentActivity().then((/**
|
|
3287
3405
|
* @return {?}
|
|
3288
3406
|
*/
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
* @return {?}
|
|
3292
|
-
*/
|
|
3293
|
-
() => context.dispose()), { once: true });
|
|
3294
|
-
activity.cancel(null);
|
|
3407
|
+
() => {
|
|
3408
|
+
navigationInteraction.dispose();
|
|
3295
3409
|
}));
|
|
3296
|
-
return new CancelledDuringNavigationInteraction(this.context, this.startingUrl, locationTriggerUrl);
|
|
3410
|
+
return new CancelledDuringNavigationInteraction(this.context, this.startingUrl, this.isPopState, locationTriggerUrl);
|
|
3297
3411
|
}
|
|
3412
|
+
// @Trace()
|
|
3298
3413
|
/**
|
|
3299
3414
|
* @param {?} component
|
|
3300
|
-
* @param {?}
|
|
3415
|
+
* @param {?} currentUrl
|
|
3416
|
+
* @param {?} nextUrl
|
|
3301
3417
|
* @return {?}
|
|
3302
3418
|
*/
|
|
3303
|
-
canDeactivatePlace(component,
|
|
3419
|
+
canDeactivatePlace(component, currentUrl, nextUrl) {
|
|
3304
3420
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3305
3421
|
// lookup the handler and create it if we've not seen it yet
|
|
3306
3422
|
/** @type {?} */
|
|
@@ -3308,10 +3424,10 @@ if (false) {
|
|
|
3308
3424
|
if (!handler) {
|
|
3309
3425
|
/** @type {?} */
|
|
3310
3426
|
const isPrimaryHandler = this.componentDeactivationHandlers.size === 0;
|
|
3311
|
-
handler = new PlaceComponentDeactivationHandler(component, this);
|
|
3427
|
+
handler = new PlaceComponentDeactivationHandler(component, this, isPrimaryHandler);
|
|
3312
3428
|
this.componentDeactivationHandlers.set(component, handler);
|
|
3313
3429
|
}
|
|
3314
|
-
return handler.canDeactivate(
|
|
3430
|
+
return handler.canDeactivate(currentUrl, nextUrl);
|
|
3315
3431
|
});
|
|
3316
3432
|
}
|
|
3317
3433
|
/**
|
|
@@ -3340,8 +3456,6 @@ if (false) {
|
|
|
3340
3456
|
*/
|
|
3341
3457
|
AbstractNavigationTransition.prototype._interactionContext;
|
|
3342
3458
|
/** @type {?} */
|
|
3343
|
-
AbstractNavigationTransition.prototype.isPopState;
|
|
3344
|
-
/** @type {?} */
|
|
3345
3459
|
AbstractNavigationTransition.prototype.startingUrl;
|
|
3346
3460
|
}
|
|
3347
3461
|
class NavigationTransition extends AbstractNavigationTransition {
|
|
@@ -3353,32 +3467,14 @@ if (false) {
|
|
|
3353
3467
|
* @param {?} event
|
|
3354
3468
|
* @return {?}
|
|
3355
3469
|
*/
|
|
3356
|
-
|
|
3357
|
-
// active sessions can have many cancel start cycles due
|
|
3358
|
-
// to place guard redirects
|
|
3470
|
+
onRouterCancelled(event) {
|
|
3359
3471
|
return this;
|
|
3360
3472
|
}
|
|
3361
3473
|
/**
|
|
3362
3474
|
* @param {?} event
|
|
3363
3475
|
* @return {?}
|
|
3364
3476
|
*/
|
|
3365
|
-
|
|
3366
|
-
// navigation succeeded
|
|
3367
|
-
this.context.notifySuccess(this);
|
|
3368
|
-
return new Idle(this.context);
|
|
3369
|
-
}
|
|
3370
|
-
/**
|
|
3371
|
-
* @param {?} event
|
|
3372
|
-
* @return {?}
|
|
3373
|
-
*/
|
|
3374
|
-
onCancel(event) {
|
|
3375
|
-
return new Idle(this.context);
|
|
3376
|
-
}
|
|
3377
|
-
/**
|
|
3378
|
-
* @param {?} event
|
|
3379
|
-
* @return {?}
|
|
3380
|
-
*/
|
|
3381
|
-
onError(event) {
|
|
3477
|
+
onRouterError(event) {
|
|
3382
3478
|
// navigation was aborted.
|
|
3383
3479
|
return new Idle(this.context);
|
|
3384
3480
|
}
|
|
@@ -3394,7 +3490,7 @@ if (false) {
|
|
|
3394
3490
|
/** @type {?} */
|
|
3395
3491
|
NavigationTransition.prototype.isPopState;
|
|
3396
3492
|
}
|
|
3397
|
-
class
|
|
3493
|
+
class PopStateTransition extends AbstractNavigationTransition {
|
|
3398
3494
|
constructor() {
|
|
3399
3495
|
super(...arguments);
|
|
3400
3496
|
this.isPopState = true;
|
|
@@ -3403,7 +3499,7 @@ if (false) {
|
|
|
3403
3499
|
* @param {?} event
|
|
3404
3500
|
* @return {?}
|
|
3405
3501
|
*/
|
|
3406
|
-
|
|
3502
|
+
onRouterCancelled(event) {
|
|
3407
3503
|
// Angular doesn't preserve the url when a guard cancels the back button.
|
|
3408
3504
|
// See https://github.com/angular/angular/issues/13586#issuecomment-432795720
|
|
3409
3505
|
Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
|
|
@@ -3414,7 +3510,7 @@ if (false) {
|
|
|
3414
3510
|
* @param {?} event
|
|
3415
3511
|
* @return {?}
|
|
3416
3512
|
*/
|
|
3417
|
-
|
|
3513
|
+
onRouterError(event) {
|
|
3418
3514
|
// navigation was aborted.
|
|
3419
3515
|
if (this.currentRouterUrl() !== this.startingUrl) {
|
|
3420
3516
|
// Angular doesn't preserve the url when a guard cancels the back button.
|
|
@@ -3425,15 +3521,12 @@ if (false) {
|
|
|
3425
3521
|
return new Idle(this.context);
|
|
3426
3522
|
}
|
|
3427
3523
|
}
|
|
3428
|
-
NavigationState.
|
|
3524
|
+
NavigationState.PopStateTransition = PopStateTransition;
|
|
3429
3525
|
if (false) {
|
|
3430
3526
|
/** @type {?} */
|
|
3431
|
-
|
|
3527
|
+
PopStateTransition.prototype.isPopState;
|
|
3432
3528
|
}
|
|
3433
|
-
|
|
3434
|
-
* @abstract
|
|
3435
|
-
*/
|
|
3436
|
-
class AbstractInteractionTransition extends NavigationState {
|
|
3529
|
+
class IdleDuringInteraction extends NavigationState {
|
|
3437
3530
|
/**
|
|
3438
3531
|
* @param {?} context
|
|
3439
3532
|
* @param {?} startingUrl
|
|
@@ -3441,18 +3534,68 @@ if (false) {
|
|
|
3441
3534
|
constructor(context, startingUrl) {
|
|
3442
3535
|
super(context);
|
|
3443
3536
|
this.startingUrl = startingUrl;
|
|
3444
|
-
this.isTransitional =
|
|
3537
|
+
this.isTransitional = false;
|
|
3538
|
+
this.isPopState = false;
|
|
3445
3539
|
}
|
|
3446
3540
|
/**
|
|
3447
|
-
* @
|
|
3541
|
+
* @param {?} visit
|
|
3542
|
+
* @param {?} initialUrl
|
|
3448
3543
|
* @return {?}
|
|
3449
3544
|
*/
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3545
|
+
onPlaceNavigationStart(visit, initialUrl) {
|
|
3546
|
+
/** @type {?} */
|
|
3547
|
+
const navigationTransition = new InteractionTransition(this.context, initialUrl);
|
|
3548
|
+
navigationTransition.storeVisit(visit);
|
|
3549
|
+
return navigationTransition;
|
|
3550
|
+
}
|
|
3551
|
+
/**
|
|
3552
|
+
* @param {?} event
|
|
3553
|
+
* @return {?}
|
|
3554
|
+
*/
|
|
3555
|
+
onRouterStarted(event) {
|
|
3556
|
+
return new InteractionTransition(this.context, event.url);
|
|
3557
|
+
}
|
|
3558
|
+
/**
|
|
3559
|
+
* @param {?} event
|
|
3560
|
+
* @return {?}
|
|
3561
|
+
*/
|
|
3562
|
+
onPopState(event) {
|
|
3563
|
+
return new InteractionPopStateTransition(this.context, event.url);
|
|
3564
|
+
}
|
|
3565
|
+
}
|
|
3566
|
+
__decorate([
|
|
3567
|
+
Trace(),
|
|
3568
|
+
__metadata("design:type", Function),
|
|
3569
|
+
__metadata("design:paramtypes", [NavigationStart]),
|
|
3570
|
+
__metadata("design:returntype", NavigationState)
|
|
3571
|
+
], IdleDuringInteraction.prototype, "onRouterStarted", null);
|
|
3572
|
+
__decorate([
|
|
3573
|
+
Trace(),
|
|
3574
|
+
__metadata("design:type", Function),
|
|
3575
|
+
__metadata("design:paramtypes", [NavigationStart]),
|
|
3576
|
+
__metadata("design:returntype", NavigationState)
|
|
3577
|
+
], IdleDuringInteraction.prototype, "onPopState", null);
|
|
3578
|
+
NavigationState.IdleDuringInteraction = IdleDuringInteraction;
|
|
3579
|
+
if (false) {
|
|
3580
|
+
/** @type {?} */
|
|
3581
|
+
IdleDuringInteraction.prototype.isTransitional;
|
|
3582
|
+
/** @type {?} */
|
|
3583
|
+
IdleDuringInteraction.prototype.isPopState;
|
|
3584
|
+
/** @type {?} */
|
|
3585
|
+
IdleDuringInteraction.prototype.startingUrl;
|
|
3586
|
+
}
|
|
3587
|
+
/**
|
|
3588
|
+
* @abstract
|
|
3589
|
+
*/
|
|
3590
|
+
class AbstractInteractionTransition extends AbstractNavigationTransition {
|
|
3591
|
+
/**
|
|
3592
|
+
* @param {?} context
|
|
3593
|
+
* @param {?} startingUrl
|
|
3594
|
+
*/
|
|
3595
|
+
constructor(context, startingUrl) {
|
|
3596
|
+
super(context, startingUrl);
|
|
3597
|
+
this.startingUrl = startingUrl;
|
|
3598
|
+
this.isTransitional = true;
|
|
3456
3599
|
}
|
|
3457
3600
|
}
|
|
3458
3601
|
NavigationState.AbstractInteractionTransition = AbstractInteractionTransition;
|
|
@@ -3475,9 +3618,31 @@ if (false) {
|
|
|
3475
3618
|
* @param {?} event
|
|
3476
3619
|
* @return {?}
|
|
3477
3620
|
*/
|
|
3478
|
-
|
|
3621
|
+
onRouterCancelled(event) {
|
|
3622
|
+
if (this.context.interactionService.isActive()) {
|
|
3623
|
+
/** @type {?} */
|
|
3624
|
+
const interactionIds = this.interactionService.activeInteractionContextIds.value;
|
|
3625
|
+
this.resetBrowserLocation(this.placeRouter.parseUrl(this.startingUrl).updateInteractionIds(interactionIds).url);
|
|
3626
|
+
return new IdleDuringInteraction(this.context, this.startingUrl);
|
|
3627
|
+
}
|
|
3628
|
+
else {
|
|
3629
|
+
return new Idle(this.context);
|
|
3630
|
+
}
|
|
3631
|
+
}
|
|
3632
|
+
/**
|
|
3633
|
+
* @param {?} event
|
|
3634
|
+
* @return {?}
|
|
3635
|
+
*/
|
|
3636
|
+
onRouterError(event) {
|
|
3637
|
+
// navigation was aborted.
|
|
3638
|
+
return new IdleDuringInteraction(this.context, this.startingUrl);
|
|
3639
|
+
}
|
|
3640
|
+
/**
|
|
3641
|
+
* @param {?} event
|
|
3642
|
+
* @return {?}
|
|
3643
|
+
*/
|
|
3644
|
+
onRouterEnd(event) {
|
|
3479
3645
|
if (this.context.interactionService.isActive()) {
|
|
3480
|
-
this.reinstateInteractionRoute();
|
|
3481
3646
|
return new IdleDuringInteraction(this.context, this.startingUrl);
|
|
3482
3647
|
}
|
|
3483
3648
|
else {
|
|
@@ -3494,7 +3659,7 @@ if (false) {
|
|
|
3494
3659
|
* This state exists to handle all events while any kind of navigation is in progress. That way all other states can
|
|
3495
3660
|
* happily ignore interaction contexts.
|
|
3496
3661
|
*/
|
|
3497
|
-
class
|
|
3662
|
+
class InteractionPopStateTransition extends AbstractInteractionTransition {
|
|
3498
3663
|
constructor() {
|
|
3499
3664
|
super(...arguments);
|
|
3500
3665
|
this.isPopState = true;
|
|
@@ -3503,107 +3668,87 @@ if (false) {
|
|
|
3503
3668
|
* @param {?} event
|
|
3504
3669
|
* @return {?}
|
|
3505
3670
|
*/
|
|
3506
|
-
|
|
3671
|
+
onRouterCancelled(event) {
|
|
3507
3672
|
if (this.interactionService.isActive()) {
|
|
3508
|
-
|
|
3673
|
+
/** @type {?} */
|
|
3674
|
+
const interactionIds = this.interactionService.activeInteractionContextIds.value;
|
|
3675
|
+
this.resetBrowserLocation(this.placeRouter.parseUrl(this.startingUrl).updateInteractionIds(interactionIds).url);
|
|
3509
3676
|
return new IdleDuringInteraction(this.context, this.startingUrl);
|
|
3510
3677
|
}
|
|
3511
3678
|
else {
|
|
3512
3679
|
return new Idle(this.context);
|
|
3513
3680
|
}
|
|
3514
3681
|
}
|
|
3515
|
-
}
|
|
3516
|
-
NavigationState.InteractionBackTransition = InteractionBackTransition;
|
|
3517
|
-
if (false) {
|
|
3518
|
-
/** @type {?} */
|
|
3519
|
-
InteractionBackTransition.prototype.isPopState;
|
|
3520
|
-
}
|
|
3521
|
-
class IdleDuringInteraction extends NavigationState {
|
|
3522
|
-
/**
|
|
3523
|
-
* @param {?} context
|
|
3524
|
-
* @param {?} startingUrl
|
|
3525
|
-
*/
|
|
3526
|
-
constructor(context, startingUrl) {
|
|
3527
|
-
super(context);
|
|
3528
|
-
this.startingUrl = startingUrl;
|
|
3529
|
-
this.isTransitional = false;
|
|
3530
|
-
this.isPopState = false;
|
|
3531
|
-
}
|
|
3532
|
-
/**
|
|
3533
|
-
* @param {?} event
|
|
3534
|
-
* @return {?}
|
|
3535
|
-
*/
|
|
3536
|
-
onStart(event) {
|
|
3537
|
-
return new InteractionTransition(this.context, event.url);
|
|
3538
|
-
}
|
|
3539
3682
|
/**
|
|
3540
3683
|
* @param {?} event
|
|
3541
3684
|
* @return {?}
|
|
3542
3685
|
*/
|
|
3543
|
-
|
|
3544
|
-
|
|
3686
|
+
onRouterEnd(event) {
|
|
3687
|
+
if (this.context.interactionService.isActive()) {
|
|
3688
|
+
return new IdleDuringInteraction(this.context, this.startingUrl);
|
|
3689
|
+
}
|
|
3690
|
+
else {
|
|
3691
|
+
return new Idle(this.context);
|
|
3692
|
+
}
|
|
3545
3693
|
}
|
|
3546
3694
|
}
|
|
3547
|
-
NavigationState.
|
|
3695
|
+
NavigationState.InteractionPopStateTransition = InteractionPopStateTransition;
|
|
3548
3696
|
if (false) {
|
|
3549
3697
|
/** @type {?} */
|
|
3550
|
-
|
|
3551
|
-
/** @type {?} */
|
|
3552
|
-
IdleDuringInteraction.prototype.isPopState;
|
|
3553
|
-
/** @type {?} */
|
|
3554
|
-
IdleDuringInteraction.prototype.startingUrl;
|
|
3698
|
+
InteractionPopStateTransition.prototype.isPopState;
|
|
3555
3699
|
}
|
|
3556
3700
|
class CancelledDuringNavigationInteraction extends NavigationState {
|
|
3557
3701
|
/**
|
|
3558
3702
|
* @param {?} context
|
|
3559
3703
|
* @param {?} startingUrl
|
|
3704
|
+
* @param {?} startingEventWasAPopState
|
|
3560
3705
|
* @param {?} locationChangeTriggerUrl
|
|
3561
3706
|
*/
|
|
3562
|
-
constructor(context, startingUrl, locationChangeTriggerUrl) {
|
|
3707
|
+
constructor(context, startingUrl, startingEventWasAPopState, locationChangeTriggerUrl) {
|
|
3563
3708
|
super(context);
|
|
3564
3709
|
this.startingUrl = startingUrl;
|
|
3710
|
+
this.startingEventWasAPopState = startingEventWasAPopState;
|
|
3565
3711
|
this.locationChangeTriggerUrl = locationChangeTriggerUrl;
|
|
3566
3712
|
this.isPopState = false;
|
|
3567
|
-
this.
|
|
3713
|
+
this.gotPopStateWithLeavingUrl = false;
|
|
3568
3714
|
}
|
|
3569
3715
|
/**
|
|
3570
3716
|
* @return {?}
|
|
3571
3717
|
*/
|
|
3572
3718
|
get isTransitional() {
|
|
3573
|
-
return
|
|
3719
|
+
return true;
|
|
3574
3720
|
}
|
|
3575
3721
|
/**
|
|
3576
3722
|
* @param {?} event
|
|
3577
3723
|
* @return {?}
|
|
3578
3724
|
*/
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
this.capturedFauxRouterStart = true;
|
|
3582
|
-
return this.ignore(event, 'url matched back button location change');
|
|
3583
|
-
}
|
|
3584
|
-
else {
|
|
3585
|
-
return this.createTransitionStateFor(event);
|
|
3586
|
-
}
|
|
3725
|
+
onRouterStarted(event) {
|
|
3726
|
+
return this.ignore(event);
|
|
3587
3727
|
}
|
|
3588
3728
|
/**
|
|
3589
3729
|
* @param {?} event
|
|
3590
3730
|
* @return {?}
|
|
3591
3731
|
*/
|
|
3592
|
-
|
|
3593
|
-
|
|
3732
|
+
onRouterCancelled(event) {
|
|
3733
|
+
// Depending on the state of the router and what was done we get a different
|
|
3734
|
+
// sequence of events. I.e. If they just clicked a link we'll get a cancel
|
|
3735
|
+
// with the locationChangeTriggerUrl as the final event. However the user
|
|
3736
|
+
// started the initial navigation with a pop state then we'll get one of
|
|
3737
|
+
// those with the locationChangeTriggerUrl but no cancel event with it.
|
|
3738
|
+
return this.gotPopStateWithLeavingUrl || this.locationChangeTriggerUrl === event.url ? this.createIdleState() : this.ignore(event);
|
|
3594
3739
|
}
|
|
3595
3740
|
/**
|
|
3596
3741
|
* @param {?} event
|
|
3597
3742
|
* @return {?}
|
|
3598
3743
|
*/
|
|
3599
|
-
|
|
3744
|
+
onRouterEnd(event) {
|
|
3600
3745
|
return this.ignore(event);
|
|
3601
3746
|
}
|
|
3602
3747
|
/**
|
|
3603
3748
|
* @param {?} event
|
|
3604
3749
|
* @return {?}
|
|
3605
3750
|
*/
|
|
3606
|
-
|
|
3751
|
+
onRouterError(event) {
|
|
3607
3752
|
return this.ignore(event);
|
|
3608
3753
|
}
|
|
3609
3754
|
/**
|
|
@@ -3611,7 +3756,20 @@ if (false) {
|
|
|
3611
3756
|
* @return {?}
|
|
3612
3757
|
*/
|
|
3613
3758
|
onPopState(event) {
|
|
3614
|
-
|
|
3759
|
+
this.gotPopStateWithLeavingUrl = this.gotPopStateWithLeavingUrl || event.url === this.locationChangeTriggerUrl;
|
|
3760
|
+
return this.ignore(event);
|
|
3761
|
+
}
|
|
3762
|
+
// @Trace()
|
|
3763
|
+
/**
|
|
3764
|
+
* @param {?} component
|
|
3765
|
+
* @param {?} currentUrl
|
|
3766
|
+
* @param {?} nextUrl
|
|
3767
|
+
* @return {?}
|
|
3768
|
+
*/
|
|
3769
|
+
canDeactivatePlace(component, currentUrl, nextUrl) {
|
|
3770
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3771
|
+
return false;
|
|
3772
|
+
});
|
|
3615
3773
|
}
|
|
3616
3774
|
/**
|
|
3617
3775
|
* @param {?} event
|
|
@@ -3619,7 +3777,7 @@ if (false) {
|
|
|
3619
3777
|
* @return {?}
|
|
3620
3778
|
*/
|
|
3621
3779
|
ignore(event, reason) {
|
|
3622
|
-
reason = reason ? `
|
|
3780
|
+
reason = reason ? ` -> ${reason}` : '';
|
|
3623
3781
|
Logger.get(this).info(`ignoring router event${reason}: ${event.constructor.name} -> ${event.url}`);
|
|
3624
3782
|
return this;
|
|
3625
3783
|
}
|
|
@@ -3627,9 +3785,15 @@ if (false) {
|
|
|
3627
3785
|
* @return {?}
|
|
3628
3786
|
*/
|
|
3629
3787
|
toString() {
|
|
3630
|
-
return `${this.constructor.name}(startingUrl: ${this.startingUrl}, locationChangeTriggerUrl:${this.locationChangeTriggerUrl})`;
|
|
3788
|
+
return `${this.constructor.name}(isIdl: ${this.idle}, startingUrl: ${this.startingUrl}, locationChangeTriggerUrl:${this.locationChangeTriggerUrl})`;
|
|
3631
3789
|
}
|
|
3632
3790
|
}
|
|
3791
|
+
__decorate([
|
|
3792
|
+
Trace(),
|
|
3793
|
+
__metadata("design:type", Function),
|
|
3794
|
+
__metadata("design:paramtypes", [NavigationCancel]),
|
|
3795
|
+
__metadata("design:returntype", NavigationState)
|
|
3796
|
+
], CancelledDuringNavigationInteraction.prototype, "onRouterCancelled", null);
|
|
3633
3797
|
NavigationState.CancelledDuringNavigationInteraction = CancelledDuringNavigationInteraction;
|
|
3634
3798
|
if (false) {
|
|
3635
3799
|
/** @type {?} */
|
|
@@ -3638,10 +3802,12 @@ if (false) {
|
|
|
3638
3802
|
* @type {?}
|
|
3639
3803
|
* @private
|
|
3640
3804
|
*/
|
|
3641
|
-
CancelledDuringNavigationInteraction.prototype.
|
|
3805
|
+
CancelledDuringNavigationInteraction.prototype.gotPopStateWithLeavingUrl;
|
|
3642
3806
|
/** @type {?} */
|
|
3643
3807
|
CancelledDuringNavigationInteraction.prototype.startingUrl;
|
|
3644
3808
|
/** @type {?} */
|
|
3809
|
+
CancelledDuringNavigationInteraction.prototype.startingEventWasAPopState;
|
|
3810
|
+
/** @type {?} */
|
|
3645
3811
|
CancelledDuringNavigationInteraction.prototype.locationChangeTriggerUrl;
|
|
3646
3812
|
}
|
|
3647
3813
|
})(NavigationState || (NavigationState = {}));
|
|
@@ -3717,21 +3883,24 @@ class UrlSnapshot {
|
|
|
3717
3883
|
/**
|
|
3718
3884
|
* @param {?} urlSerializer
|
|
3719
3885
|
* @param {?} url
|
|
3886
|
+
* @param {?} options
|
|
3720
3887
|
*/
|
|
3721
|
-
constructor(urlSerializer, url) {
|
|
3888
|
+
constructor(urlSerializer, url, options) {
|
|
3722
3889
|
this.urlSerializer = urlSerializer;
|
|
3723
3890
|
this.url = url;
|
|
3891
|
+
this.options = options;
|
|
3724
3892
|
this.urlTree = urlSerializer.parse(url);
|
|
3725
3893
|
}
|
|
3726
3894
|
/**
|
|
3727
|
-
* @protected
|
|
3728
3895
|
* @param {?} visit
|
|
3729
3896
|
* @return {?}
|
|
3730
3897
|
*/
|
|
3731
|
-
|
|
3898
|
+
updateVisitSegments(visit) {
|
|
3899
|
+
/** @type {?} */
|
|
3900
|
+
const urlTree = this.urlSerializer.parse(this.url);
|
|
3732
3901
|
// Ugly, but it works for now.
|
|
3733
3902
|
/** @type {?} */
|
|
3734
|
-
const segments = [...this.getPrimarySegments()];
|
|
3903
|
+
const segments = [...this.getPrimarySegments(urlTree)];
|
|
3735
3904
|
/** @type {?} */
|
|
3736
3905
|
const visitSegments = this.getSegmentsFor(visit);
|
|
3737
3906
|
/** @type {?} */
|
|
@@ -3742,13 +3911,15 @@ class UrlSnapshot {
|
|
|
3742
3911
|
segment => segment.path === visitSegments[0].path));
|
|
3743
3912
|
// do not use the return value, it's the items that were removed!
|
|
3744
3913
|
segments.splice(replaceAt, visitSegments.length, ...visitSegments);
|
|
3745
|
-
|
|
3914
|
+
urlTree.root.children.primary.segments = segments;
|
|
3915
|
+
return new UrlSnapshot(this.urlSerializer, urlTree.toString(), this.options);
|
|
3746
3916
|
}
|
|
3747
3917
|
/**
|
|
3748
3918
|
* @private
|
|
3919
|
+
* @param {?} urlTree
|
|
3749
3920
|
* @return {?}
|
|
3750
3921
|
*/
|
|
3751
|
-
getPrimarySegments() {
|
|
3922
|
+
getPrimarySegments(urlTree) {
|
|
3752
3923
|
return this.urlTree.root.children.primary.segments;
|
|
3753
3924
|
}
|
|
3754
3925
|
/**
|
|
@@ -3772,81 +3943,92 @@ class UrlSnapshot {
|
|
|
3772
3943
|
];
|
|
3773
3944
|
}
|
|
3774
3945
|
/**
|
|
3775
|
-
* @param {?}
|
|
3946
|
+
* @param {?} placeDef
|
|
3776
3947
|
* @return {?}
|
|
3777
3948
|
*/
|
|
3778
|
-
|
|
3779
|
-
/**
|
|
3780
|
-
const segments = this.replaceExistingVisitSegmentsWith(visit);
|
|
3781
|
-
/** @type {?} */
|
|
3782
|
-
const commands = [];
|
|
3783
|
-
segments.forEach((/**
|
|
3949
|
+
includesPathOf(placeDef) {
|
|
3950
|
+
return this.getPrimarySegments(this.urlTree).find((/**
|
|
3784
3951
|
* @param {?} s
|
|
3785
3952
|
* @return {?}
|
|
3786
3953
|
*/
|
|
3787
|
-
s =>
|
|
3788
|
-
commands.push(s.path);
|
|
3789
|
-
if (s.parameterMap.keys.length > 0) {
|
|
3790
|
-
commands.push(s.parameters);
|
|
3791
|
-
}
|
|
3792
|
-
}));
|
|
3793
|
-
return commands;
|
|
3794
|
-
}
|
|
3795
|
-
/**
|
|
3796
|
-
* @param {?} placeDef
|
|
3797
|
-
* @return {?}
|
|
3798
|
-
*/
|
|
3799
|
-
includesPathOf(placeDef) {
|
|
3800
|
-
return this.getPrimarySegments().find((/**
|
|
3801
|
-
* @param {?} s
|
|
3802
|
-
* @return {?}
|
|
3803
|
-
*/
|
|
3804
|
-
s => s.path === placeDef.path));
|
|
3954
|
+
s => s.path === placeDef.path));
|
|
3805
3955
|
}
|
|
3806
3956
|
/**
|
|
3807
3957
|
* @return {?}
|
|
3808
3958
|
*/
|
|
3809
3959
|
getInteractionIds() {
|
|
3810
3960
|
/** @type {?} */
|
|
3811
|
-
const
|
|
3812
|
-
if (
|
|
3813
|
-
|
|
3814
|
-
assert.isTruthy(interactionOutlet.segments[0].path === UrlSnapshot.INTERACTION_ROUTER_PATH);
|
|
3815
|
-
return UrlSnapshot.parseInteractionIds(interactionOutlet.segments[1].path);
|
|
3961
|
+
const queryParam = this.urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM];
|
|
3962
|
+
if (queryParam) {
|
|
3963
|
+
return UrlSnapshot.parseInteractionIds(queryParam);
|
|
3816
3964
|
}
|
|
3817
3965
|
else {
|
|
3818
3966
|
return [];
|
|
3819
3967
|
}
|
|
3820
3968
|
}
|
|
3969
|
+
/**
|
|
3970
|
+
* @return {?}
|
|
3971
|
+
*/
|
|
3972
|
+
hasInteractionIds() {
|
|
3973
|
+
return this.getInteractionIds().length > 0;
|
|
3974
|
+
}
|
|
3821
3975
|
// @Trace()
|
|
3822
3976
|
/**
|
|
3823
3977
|
* @param {?} ids
|
|
3824
3978
|
* @return {?}
|
|
3825
3979
|
*/
|
|
3826
|
-
|
|
3980
|
+
updateInteractionIds(ids) {
|
|
3981
|
+
if (ids.length === 0) {
|
|
3982
|
+
return this.removeInteractionIds();
|
|
3983
|
+
}
|
|
3984
|
+
else {
|
|
3985
|
+
/** @type {?} */
|
|
3986
|
+
const urlTree = this.urlSerializer.parse(this.url);
|
|
3987
|
+
urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM] = UrlSnapshot.createPathIdFor(ids);
|
|
3988
|
+
return new UrlSnapshot(this.urlSerializer, urlTree.toString(), this.options);
|
|
3989
|
+
}
|
|
3990
|
+
}
|
|
3991
|
+
// @Trace()
|
|
3992
|
+
/**
|
|
3993
|
+
* @return {?}
|
|
3994
|
+
*/
|
|
3995
|
+
removeInteractionIds() {
|
|
3827
3996
|
/** @type {?} */
|
|
3828
3997
|
const urlTree = this.urlSerializer.parse(this.url);
|
|
3829
|
-
urlTree.
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
return new UrlSnapshot(this.urlSerializer, urlTree.toString());
|
|
3998
|
+
if (urlTree.queryParams && urlTree.queryParams[UrlSnapshot.INTERACTION_QUERY_PARAM]) {
|
|
3999
|
+
urlTree.queryParams = {}; //[UrlSnapshot.INTERACTION_ROUTER_OUTLET]
|
|
4000
|
+
}
|
|
4001
|
+
return new UrlSnapshot(this.urlSerializer, urlTree.toString(), this.options);
|
|
3834
4002
|
}
|
|
3835
|
-
}
|
|
3836
|
-
if (false) {
|
|
3837
4003
|
/**
|
|
3838
|
-
* @
|
|
3839
|
-
* @
|
|
4004
|
+
* @param {?} options
|
|
4005
|
+
* @return {?}
|
|
3840
4006
|
*/
|
|
4007
|
+
withOptions(options) {
|
|
4008
|
+
return new UrlSnapshot(this.urlSerializer, this.url, options);
|
|
4009
|
+
}
|
|
4010
|
+
/**
|
|
4011
|
+
* @return {?}
|
|
4012
|
+
*/
|
|
4013
|
+
getNavigationExtras() {
|
|
4014
|
+
return this.options;
|
|
4015
|
+
}
|
|
4016
|
+
}
|
|
4017
|
+
if (false) {
|
|
4018
|
+
/** @type {?} */
|
|
3841
4019
|
UrlSnapshot.prototype.urlTree;
|
|
3842
4020
|
/** @type {?} */
|
|
3843
4021
|
UrlSnapshot.prototype.urlSerializer;
|
|
3844
4022
|
/** @type {?} */
|
|
3845
4023
|
UrlSnapshot.prototype.url;
|
|
4024
|
+
/**
|
|
4025
|
+
* @type {?}
|
|
4026
|
+
* @private
|
|
4027
|
+
*/
|
|
4028
|
+
UrlSnapshot.prototype.options;
|
|
3846
4029
|
}
|
|
3847
4030
|
(function (UrlSnapshot) {
|
|
3848
|
-
UrlSnapshot.
|
|
3849
|
-
UrlSnapshot.INTERACTION_ROUTER_PATH = 'active';
|
|
4031
|
+
UrlSnapshot.INTERACTION_QUERY_PARAM = 'aup-interactions';
|
|
3850
4032
|
UrlSnapshot.INTERACTION_ID_SEPARATOR = '--';
|
|
3851
4033
|
/**
|
|
3852
4034
|
* @param {?} path
|
|
@@ -3865,13 +4047,14 @@ if (false) {
|
|
|
3865
4047
|
}
|
|
3866
4048
|
UrlSnapshot.createPathIdFor = createPathIdFor;
|
|
3867
4049
|
/**
|
|
3868
|
-
* @
|
|
3869
|
-
* @return {?}
|
|
4050
|
+
* @record
|
|
3870
4051
|
*/
|
|
3871
|
-
function
|
|
3872
|
-
|
|
4052
|
+
function NavigationOptions() { }
|
|
4053
|
+
UrlSnapshot.NavigationOptions = NavigationOptions;
|
|
4054
|
+
if (false) {
|
|
4055
|
+
/** @type {?|undefined} */
|
|
4056
|
+
NavigationOptions.prototype.replaceUrl;
|
|
3873
4057
|
}
|
|
3874
|
-
UrlSnapshot.createInteractionOutletRouterCommands = createInteractionOutletRouterCommands;
|
|
3875
4058
|
})(UrlSnapshot || (UrlSnapshot = {}));
|
|
3876
4059
|
|
|
3877
4060
|
/**
|
|
@@ -3924,7 +4107,6 @@ class PlaceRouter extends GarbageCollector {
|
|
|
3924
4107
|
// NavigationStart -> .... -> NavigationError --> navigation aborted, end session.
|
|
3925
4108
|
// =======================
|
|
3926
4109
|
if (event instanceof NavigationStart) {
|
|
3927
|
-
console.log(event);
|
|
3928
4110
|
if (event.navigationTrigger === 'popstate') {
|
|
3929
4111
|
this.runStateTransition((/**
|
|
3930
4112
|
* @param {?} state
|
|
@@ -3937,7 +4119,7 @@ class PlaceRouter extends GarbageCollector {
|
|
|
3937
4119
|
* @param {?} state
|
|
3938
4120
|
* @return {?}
|
|
3939
4121
|
*/
|
|
3940
|
-
state => state.
|
|
4122
|
+
state => state.onRouterStarted(event)));
|
|
3941
4123
|
}
|
|
3942
4124
|
}
|
|
3943
4125
|
if (event instanceof NavigationEnd) {
|
|
@@ -3946,7 +4128,7 @@ class PlaceRouter extends GarbageCollector {
|
|
|
3946
4128
|
* @param {?} state
|
|
3947
4129
|
* @return {?}
|
|
3948
4130
|
*/
|
|
3949
|
-
state => state.
|
|
4131
|
+
state => state.onRouterEnd(event)));
|
|
3950
4132
|
}
|
|
3951
4133
|
if (event instanceof NavigationError) {
|
|
3952
4134
|
console.log(event);
|
|
@@ -3954,7 +4136,7 @@ class PlaceRouter extends GarbageCollector {
|
|
|
3954
4136
|
* @param {?} state
|
|
3955
4137
|
* @return {?}
|
|
3956
4138
|
*/
|
|
3957
|
-
state => state.
|
|
4139
|
+
state => state.onRouterError(event)));
|
|
3958
4140
|
}
|
|
3959
4141
|
if (event instanceof NavigationCancel) {
|
|
3960
4142
|
console.log(event);
|
|
@@ -3962,7 +4144,7 @@ class PlaceRouter extends GarbageCollector {
|
|
|
3962
4144
|
* @param {?} state
|
|
3963
4145
|
* @return {?}
|
|
3964
4146
|
*/
|
|
3965
|
-
state => state.
|
|
4147
|
+
state => state.onRouterCancelled(event)));
|
|
3966
4148
|
}
|
|
3967
4149
|
}));
|
|
3968
4150
|
// Push dialog state to the url so we can capture the back button.
|
|
@@ -3991,12 +4173,11 @@ class PlaceRouter extends GarbageCollector {
|
|
|
3991
4173
|
const navigationState = this._navigationStateModel.value;
|
|
3992
4174
|
console.log(`URLChange -> ${url}`, { state: navigationState });
|
|
3993
4175
|
urlChanges.publish({ url, state: navigationState });
|
|
3994
|
-
//
|
|
3995
|
-
if (navigationState
|
|
4176
|
+
// The url has changed while we're in a transitional state
|
|
4177
|
+
if (navigationState.isTransitional) {
|
|
3996
4178
|
/** @type {?} */
|
|
3997
4179
|
const navigationInteraction = this.navigationState.interactionContext;
|
|
3998
4180
|
if (navigationInteraction && navigationInteraction.isActive()) {
|
|
3999
|
-
Logger.get(this).info(`back button pressed during navigation session interaction promise`);
|
|
4000
4181
|
this.runStateTransition((/**
|
|
4001
4182
|
* @param {?} state
|
|
4002
4183
|
* @return {?}
|
|
@@ -4086,9 +4267,9 @@ class PlaceRouter extends GarbageCollector {
|
|
|
4086
4267
|
*/
|
|
4087
4268
|
router => {
|
|
4088
4269
|
/** @type {?} */
|
|
4089
|
-
const
|
|
4090
|
-
console.log('### Push Changes to route Redirect', { commands });
|
|
4091
|
-
return
|
|
4270
|
+
const urlSnapshot = this.parseUrl(this.router.routerState.snapshot.url).updateVisitSegments(next);
|
|
4271
|
+
console.log('### Push Changes to route Redirect', { commands: urlSnapshot.url });
|
|
4272
|
+
return this.navigateByUrl(urlSnapshot);
|
|
4092
4273
|
}));
|
|
4093
4274
|
}
|
|
4094
4275
|
});
|
|
@@ -4109,7 +4290,7 @@ class PlaceRouter extends GarbageCollector {
|
|
|
4109
4290
|
*/
|
|
4110
4291
|
current => {
|
|
4111
4292
|
/** @type {?} */
|
|
4112
|
-
const session =
|
|
4293
|
+
const session = this.navigationState.onPlaceNavigationStart(visit, this.getCurrentRouterUrl());
|
|
4113
4294
|
session.storeVisit(visit);
|
|
4114
4295
|
return session;
|
|
4115
4296
|
}));
|
|
@@ -4124,11 +4305,12 @@ class PlaceRouter extends GarbageCollector {
|
|
|
4124
4305
|
* @param {?} session
|
|
4125
4306
|
* @return {?}
|
|
4126
4307
|
*/
|
|
4127
|
-
session => session.
|
|
4308
|
+
session => session.onRouterEnd(new NavigationEnd(-1, '', ''))));
|
|
4128
4309
|
}
|
|
4129
4310
|
}
|
|
4130
4311
|
});
|
|
4131
4312
|
}
|
|
4313
|
+
// @Trace()
|
|
4132
4314
|
/**
|
|
4133
4315
|
* @protected
|
|
4134
4316
|
* @param {?} transition
|
|
@@ -4173,7 +4355,7 @@ class PlaceRouter extends GarbageCollector {
|
|
|
4173
4355
|
* @return {?}
|
|
4174
4356
|
*/
|
|
4175
4357
|
parseUrl(url) {
|
|
4176
|
-
return new UrlSnapshot(this.urlSerializer, url);
|
|
4358
|
+
return new UrlSnapshot(this.urlSerializer, url, {});
|
|
4177
4359
|
}
|
|
4178
4360
|
/**
|
|
4179
4361
|
* @param {?} url
|
|
@@ -4188,6 +4370,12 @@ class PlaceRouter extends GarbageCollector {
|
|
|
4188
4370
|
getCurrentRouterUrl() {
|
|
4189
4371
|
return this.router.routerState ? this.router.routerState.snapshot.url : null;
|
|
4190
4372
|
}
|
|
4373
|
+
/**
|
|
4374
|
+
* @return {?}
|
|
4375
|
+
*/
|
|
4376
|
+
getCurrentRouteSnapshot() {
|
|
4377
|
+
return this.parseUrl(this.getCurrentRouterUrl());
|
|
4378
|
+
}
|
|
4191
4379
|
/**
|
|
4192
4380
|
* @param {?} url
|
|
4193
4381
|
* @return {?}
|
|
@@ -4203,6 +4391,15 @@ class PlaceRouter extends GarbageCollector {
|
|
|
4203
4391
|
hasActiveInteractionIds(url) {
|
|
4204
4392
|
return this.getActiveInteractionIdsFromUrl(url).length > 0;
|
|
4205
4393
|
}
|
|
4394
|
+
// @Trace()
|
|
4395
|
+
/**
|
|
4396
|
+
* @param {?} urlSnapshot
|
|
4397
|
+
* @return {?}
|
|
4398
|
+
*/
|
|
4399
|
+
navigateByUrl(urlSnapshot) {
|
|
4400
|
+
this.router.navigateByUrl(urlSnapshot.urlTree, urlSnapshot.getNavigationExtras());
|
|
4401
|
+
}
|
|
4402
|
+
// @Trace()
|
|
4206
4403
|
/**
|
|
4207
4404
|
* @return {?}
|
|
4208
4405
|
*/
|
|
@@ -4216,22 +4413,12 @@ class PlaceRouter extends GarbageCollector {
|
|
|
4216
4413
|
}
|
|
4217
4414
|
else {
|
|
4218
4415
|
if (currentIds.length < 1) {
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
[UrlSnapshot.INTERACTION_ROUTER_OUTLET]: null
|
|
4222
|
-
}
|
|
4223
|
-
}], {
|
|
4224
|
-
replaceUrl: true // remove the interaction from the history.
|
|
4225
|
-
});
|
|
4416
|
+
// no more interactions to remove from history.
|
|
4417
|
+
this.navigateByUrl(this.getCurrentRouteSnapshot().removeInteractionIds());
|
|
4226
4418
|
}
|
|
4227
4419
|
else {
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
this.router.navigate(['.', {
|
|
4231
|
-
outlets: {
|
|
4232
|
-
[UrlSnapshot.INTERACTION_ROUTER_OUTLET]: UrlSnapshot.createInteractionOutletRouterCommands(currentIds)
|
|
4233
|
-
}
|
|
4234
|
-
}]);
|
|
4420
|
+
// todo was or is...
|
|
4421
|
+
this.navigateByUrl(this.getCurrentRouteSnapshot().updateInteractionIds(currentIds));
|
|
4235
4422
|
}
|
|
4236
4423
|
}
|
|
4237
4424
|
}
|
|
@@ -4250,12 +4437,6 @@ PlaceRouter.ctorParameters = () => [
|
|
|
4250
4437
|
{ type: InteractionService }
|
|
4251
4438
|
];
|
|
4252
4439
|
/** @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" });
|
|
4253
|
-
__decorate([
|
|
4254
|
-
Trace(),
|
|
4255
|
-
__metadata("design:type", Function),
|
|
4256
|
-
__metadata("design:paramtypes", []),
|
|
4257
|
-
__metadata("design:returntype", void 0)
|
|
4258
|
-
], PlaceRouter.prototype, "syncInteractionIdsWithRouter", null);
|
|
4259
4440
|
if (false) {
|
|
4260
4441
|
/**
|
|
4261
4442
|
* @type {?}
|
|
@@ -5623,7 +5804,7 @@ function Place(options) {
|
|
|
5623
5804
|
*/
|
|
5624
5805
|
(target) => {
|
|
5625
5806
|
if (PlaceComponent.isPlaceComponentConstructor(target)) {
|
|
5626
|
-
PlaceComponent.injectDefinition(target, new PlaceDefinition(target, options.path, isNil(options.authenticate) ?
|
|
5807
|
+
PlaceComponent.injectDefinition(target, new PlaceDefinition(target, options.path, isNil(options.authenticate) ? true : options.authenticate, options.data, PlaceComponent.getRouteParameters(target), (options.children || []).map((/**
|
|
5627
5808
|
* @param {?} c
|
|
5628
5809
|
* @return {?}
|
|
5629
5810
|
*/
|
|
@@ -5654,93 +5835,6 @@ function Place(options) {
|
|
|
5654
5835
|
}
|
|
5655
5836
|
})(Place || (Place = {}));
|
|
5656
5837
|
|
|
5657
|
-
/**
|
|
5658
|
-
* @fileoverview added by tsickle
|
|
5659
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
5660
|
-
*/
|
|
5661
|
-
class VisitSanitiser {
|
|
5662
|
-
/**
|
|
5663
|
-
* @param {?} activatedRoute
|
|
5664
|
-
* @param {?} router
|
|
5665
|
-
* @param {?} placeHistory
|
|
5666
|
-
* @param {?} injector
|
|
5667
|
-
*/
|
|
5668
|
-
constructor(activatedRoute, router, placeHistory, injector) {
|
|
5669
|
-
this.activatedRoute = activatedRoute;
|
|
5670
|
-
this.router = router;
|
|
5671
|
-
this.placeHistory = placeHistory;
|
|
5672
|
-
this.injector = injector;
|
|
5673
|
-
}
|
|
5674
|
-
// @Trace()
|
|
5675
|
-
/**
|
|
5676
|
-
* @param {?} visit
|
|
5677
|
-
* @return {?}
|
|
5678
|
-
*/
|
|
5679
|
-
sanitise(visit) {
|
|
5680
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
5681
|
-
/** @type {?} */
|
|
5682
|
-
const placeDef = visit.placeDefinition;
|
|
5683
|
-
if (placeDef.hasRouteId()) {
|
|
5684
|
-
/** @type {?} */
|
|
5685
|
-
const routeIdDef = placeDef.getRouteIdParameterDef();
|
|
5686
|
-
/** @type {?} */
|
|
5687
|
-
const routeId = visit.getRouteId();
|
|
5688
|
-
/** @type {?} */
|
|
5689
|
-
const sanitisedValue = yield routeIdDef.sanitise(routeId, visit, this.placeHistory, this.injector);
|
|
5690
|
-
// console.log({routeId, sanitisedValue});
|
|
5691
|
-
// ###------- EARLY EXIT --------###
|
|
5692
|
-
if (routeIdDef.hasChanged(routeId, sanitisedValue)) {
|
|
5693
|
-
// if the route id has changed we redirect immediately as other
|
|
5694
|
-
// parameter sanitisers might use it.
|
|
5695
|
-
return visit.replace(routeIdDef, sanitisedValue);
|
|
5696
|
-
}
|
|
5697
|
-
}
|
|
5698
|
-
// if we didn't replace the routeId we continue the url present parameters.
|
|
5699
|
-
/** @type {?} */
|
|
5700
|
-
const parameterDefs = placeDef.getVisitParameterDefs({
|
|
5701
|
-
includeRouteParameters: true,
|
|
5702
|
-
includeNonRouteParameters: true
|
|
5703
|
-
});
|
|
5704
|
-
/** @type {?} */
|
|
5705
|
-
let sanitisedVisit = visit;
|
|
5706
|
-
for (let i = 0; i < parameterDefs.length; i++) {
|
|
5707
|
-
/** @type {?} */
|
|
5708
|
-
const def = parameterDefs[i];
|
|
5709
|
-
/** @type {?} */
|
|
5710
|
-
const value = visit.getParameter(def.name);
|
|
5711
|
-
/** @type {?} */
|
|
5712
|
-
const sanitisedValue = yield def.sanitise(value, sanitisedVisit, this.placeHistory, this.injector);
|
|
5713
|
-
if (def.hasChanged(value, sanitisedValue)) {
|
|
5714
|
-
sanitisedVisit = sanitisedVisit.replace(def, sanitisedValue);
|
|
5715
|
-
}
|
|
5716
|
-
}
|
|
5717
|
-
return sanitisedVisit.hasChangedFrom(visit) ? sanitisedVisit : visit;
|
|
5718
|
-
});
|
|
5719
|
-
}
|
|
5720
|
-
}
|
|
5721
|
-
if (false) {
|
|
5722
|
-
/**
|
|
5723
|
-
* @type {?}
|
|
5724
|
-
* @private
|
|
5725
|
-
*/
|
|
5726
|
-
VisitSanitiser.prototype.activatedRoute;
|
|
5727
|
-
/**
|
|
5728
|
-
* @type {?}
|
|
5729
|
-
* @private
|
|
5730
|
-
*/
|
|
5731
|
-
VisitSanitiser.prototype.router;
|
|
5732
|
-
/**
|
|
5733
|
-
* @type {?}
|
|
5734
|
-
* @private
|
|
5735
|
-
*/
|
|
5736
|
-
VisitSanitiser.prototype.placeHistory;
|
|
5737
|
-
/**
|
|
5738
|
-
* @type {?}
|
|
5739
|
-
* @private
|
|
5740
|
-
*/
|
|
5741
|
-
VisitSanitiser.prototype.injector;
|
|
5742
|
-
}
|
|
5743
|
-
|
|
5744
5838
|
/**
|
|
5745
5839
|
* @fileoverview added by tsickle
|
|
5746
5840
|
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
@@ -5872,6 +5966,120 @@ if (false) {
|
|
|
5872
5966
|
ParamMapAdapter.prototype.params;
|
|
5873
5967
|
}
|
|
5874
5968
|
|
|
5969
|
+
/**
|
|
5970
|
+
* @fileoverview added by tsickle
|
|
5971
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
5972
|
+
*/
|
|
5973
|
+
class NoopAuthGuard {
|
|
5974
|
+
constructor() {
|
|
5975
|
+
}
|
|
5976
|
+
/**
|
|
5977
|
+
* @param {?} activatedRoute
|
|
5978
|
+
* @param {?} state
|
|
5979
|
+
* @return {?}
|
|
5980
|
+
*/
|
|
5981
|
+
canActivate(activatedRoute, state) {
|
|
5982
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
5983
|
+
return true;
|
|
5984
|
+
});
|
|
5985
|
+
}
|
|
5986
|
+
}
|
|
5987
|
+
NoopAuthGuard.decorators = [
|
|
5988
|
+
{ type: Injectable, args: [{
|
|
5989
|
+
providedIn: 'root'
|
|
5990
|
+
},] }
|
|
5991
|
+
];
|
|
5992
|
+
/** @nocollapse */
|
|
5993
|
+
NoopAuthGuard.ctorParameters = () => [];
|
|
5994
|
+
/** @nocollapse */ NoopAuthGuard.ngInjectableDef = ɵɵdefineInjectable({ factory: function NoopAuthGuard_Factory() { return new NoopAuthGuard(); }, token: NoopAuthGuard, providedIn: "root" });
|
|
5995
|
+
|
|
5996
|
+
/**
|
|
5997
|
+
* @fileoverview added by tsickle
|
|
5998
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
5999
|
+
*/
|
|
6000
|
+
class VisitSanitiser {
|
|
6001
|
+
/**
|
|
6002
|
+
* @param {?} activatedRoute
|
|
6003
|
+
* @param {?} router
|
|
6004
|
+
* @param {?} placeHistory
|
|
6005
|
+
* @param {?} injector
|
|
6006
|
+
*/
|
|
6007
|
+
constructor(activatedRoute, router, placeHistory, injector) {
|
|
6008
|
+
this.activatedRoute = activatedRoute;
|
|
6009
|
+
this.router = router;
|
|
6010
|
+
this.placeHistory = placeHistory;
|
|
6011
|
+
this.injector = injector;
|
|
6012
|
+
}
|
|
6013
|
+
// @Trace()
|
|
6014
|
+
/**
|
|
6015
|
+
* @param {?} visit
|
|
6016
|
+
* @return {?}
|
|
6017
|
+
*/
|
|
6018
|
+
sanitise(visit) {
|
|
6019
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6020
|
+
/** @type {?} */
|
|
6021
|
+
const placeDef = visit.placeDefinition;
|
|
6022
|
+
if (placeDef.hasRouteId()) {
|
|
6023
|
+
/** @type {?} */
|
|
6024
|
+
const routeIdDef = placeDef.getRouteIdParameterDef();
|
|
6025
|
+
/** @type {?} */
|
|
6026
|
+
const routeId = visit.getRouteId();
|
|
6027
|
+
/** @type {?} */
|
|
6028
|
+
const sanitisedValue = yield routeIdDef.sanitise(routeId, visit, this.placeHistory, this.injector);
|
|
6029
|
+
// console.log({routeId, sanitisedValue});
|
|
6030
|
+
// ###------- EARLY EXIT --------###
|
|
6031
|
+
if (routeIdDef.hasChanged(routeId, sanitisedValue)) {
|
|
6032
|
+
// if the route id has changed we redirect immediately as other
|
|
6033
|
+
// parameter sanitisers might use it.
|
|
6034
|
+
return visit.replace(routeIdDef, sanitisedValue);
|
|
6035
|
+
}
|
|
6036
|
+
}
|
|
6037
|
+
// if we didn't replace the routeId we continue the url present parameters.
|
|
6038
|
+
/** @type {?} */
|
|
6039
|
+
const parameterDefs = placeDef.getVisitParameterDefs({
|
|
6040
|
+
includeRouteParameters: true,
|
|
6041
|
+
includeNonRouteParameters: true
|
|
6042
|
+
});
|
|
6043
|
+
/** @type {?} */
|
|
6044
|
+
let sanitisedVisit = visit;
|
|
6045
|
+
for (let i = 0; i < parameterDefs.length; i++) {
|
|
6046
|
+
/** @type {?} */
|
|
6047
|
+
const def = parameterDefs[i];
|
|
6048
|
+
/** @type {?} */
|
|
6049
|
+
const value = visit.getParameter(def.name);
|
|
6050
|
+
/** @type {?} */
|
|
6051
|
+
const sanitisedValue = yield def.sanitise(value, sanitisedVisit, this.placeHistory, this.injector);
|
|
6052
|
+
if (def.hasChanged(value, sanitisedValue)) {
|
|
6053
|
+
sanitisedVisit = sanitisedVisit.replace(def, sanitisedValue);
|
|
6054
|
+
}
|
|
6055
|
+
}
|
|
6056
|
+
return sanitisedVisit.hasChangedFrom(visit) ? sanitisedVisit : visit;
|
|
6057
|
+
});
|
|
6058
|
+
}
|
|
6059
|
+
}
|
|
6060
|
+
if (false) {
|
|
6061
|
+
/**
|
|
6062
|
+
* @type {?}
|
|
6063
|
+
* @private
|
|
6064
|
+
*/
|
|
6065
|
+
VisitSanitiser.prototype.activatedRoute;
|
|
6066
|
+
/**
|
|
6067
|
+
* @type {?}
|
|
6068
|
+
* @private
|
|
6069
|
+
*/
|
|
6070
|
+
VisitSanitiser.prototype.router;
|
|
6071
|
+
/**
|
|
6072
|
+
* @type {?}
|
|
6073
|
+
* @private
|
|
6074
|
+
*/
|
|
6075
|
+
VisitSanitiser.prototype.placeHistory;
|
|
6076
|
+
/**
|
|
6077
|
+
* @type {?}
|
|
6078
|
+
* @private
|
|
6079
|
+
*/
|
|
6080
|
+
VisitSanitiser.prototype.injector;
|
|
6081
|
+
}
|
|
6082
|
+
|
|
5875
6083
|
/**
|
|
5876
6084
|
* @fileoverview added by tsickle
|
|
5877
6085
|
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
@@ -5879,19 +6087,21 @@ if (false) {
|
|
|
5879
6087
|
/**
|
|
5880
6088
|
* @abstract
|
|
5881
6089
|
*/
|
|
5882
|
-
class
|
|
6090
|
+
class PlaceGuard {
|
|
5883
6091
|
/**
|
|
5884
6092
|
* @param {?} router
|
|
5885
6093
|
* @param {?} urlSerializer
|
|
5886
6094
|
* @param {?} placeRouter
|
|
5887
6095
|
* @param {?} placeHistory
|
|
6096
|
+
* @param {?} interactionService
|
|
5888
6097
|
* @param {?} injector
|
|
5889
6098
|
*/
|
|
5890
|
-
constructor(router, urlSerializer, placeRouter, placeHistory, injector) {
|
|
6099
|
+
constructor(router, urlSerializer, placeRouter, placeHistory, interactionService, injector) {
|
|
5891
6100
|
this.router = router;
|
|
5892
6101
|
this.urlSerializer = urlSerializer;
|
|
5893
6102
|
this.placeRouter = placeRouter;
|
|
5894
6103
|
this.placeHistory = placeHistory;
|
|
6104
|
+
this.interactionService = interactionService;
|
|
5895
6105
|
this.injector = injector;
|
|
5896
6106
|
}
|
|
5897
6107
|
// @Trace()
|
|
@@ -5902,40 +6112,47 @@ class AbstractPlaceGuard {
|
|
|
5902
6112
|
*/
|
|
5903
6113
|
canActivate(activatedRoute, state) {
|
|
5904
6114
|
return __awaiter(this, void 0, void 0, function* () {
|
|
6115
|
+
// TODO: this is ugly now that I'm return UrlSnapshots and not UrlTrees. It'd be better if the functions
|
|
6116
|
+
// weren't nested or if I implemented a handler chain.
|
|
5905
6117
|
return this.authorisePlaceThen(activatedRoute, state, (/**
|
|
5906
6118
|
* @param {?} placeDefinition
|
|
5907
6119
|
* @return {?}
|
|
5908
6120
|
*/
|
|
5909
6121
|
(placeDefinition) => __awaiter(this, void 0, void 0, function* () {
|
|
5910
|
-
// Parse our route params.
|
|
5911
|
-
/** @type {?} */
|
|
5912
|
-
const params = new ConsolidatedParameterMap(activatedRoute.paramMap, activatedRoute.url);
|
|
5913
|
-
/** @type {?} */
|
|
5914
|
-
const parsedParams = placeDefinition.parseRouteParams(params);
|
|
5915
|
-
/** @type {?} */
|
|
5916
|
-
const initialVisit = this.placeRouter.navigationState.getVisitFor(placeDefinition) || new Visit(placeDefinition, parsedParams);
|
|
5917
6122
|
/** @type {?} */
|
|
5918
|
-
const
|
|
5919
|
-
|
|
5920
|
-
|
|
5921
|
-
|
|
5922
|
-
|
|
5923
|
-
if (initialVisit.hasRoutingChangedFrom(sanitisedVisit)) {
|
|
5924
|
-
// Regenerate the url
|
|
6123
|
+
const result = yield this.cleanInteractionState(activatedRoute, state, (/**
|
|
6124
|
+
* @return {?}
|
|
6125
|
+
*/
|
|
6126
|
+
() => __awaiter(this, void 0, void 0, function* () {
|
|
6127
|
+
// Parse our route params.
|
|
5925
6128
|
/** @type {?} */
|
|
5926
|
-
const
|
|
5927
|
-
|
|
5928
|
-
|
|
5929
|
-
|
|
5930
|
-
|
|
5931
|
-
}
|
|
5932
|
-
|
|
5933
|
-
|
|
5934
|
-
|
|
5935
|
-
|
|
6129
|
+
const params = new ConsolidatedParameterMap(activatedRoute.paramMap, activatedRoute.url);
|
|
6130
|
+
/** @type {?} */
|
|
6131
|
+
const parsedParams = placeDefinition.parseRouteParams(params);
|
|
6132
|
+
/** @type {?} */
|
|
6133
|
+
const initialVisit = this.placeRouter.navigationState.getVisitFor(placeDefinition) || new Visit(placeDefinition, parsedParams);
|
|
6134
|
+
/** @type {?} */
|
|
6135
|
+
const sanitiser = new VisitSanitiser(activatedRoute, this.router, this.placeHistory, this.injector);
|
|
6136
|
+
/** @type {?} */
|
|
6137
|
+
const sanitisedVisit = yield sanitiser.sanitise(initialVisit.mergeRouteParameters(parsedParams));
|
|
6138
|
+
// Save the visit with any updated parameters. We need to save it so we remember any non route parameters
|
|
6139
|
+
this.placeRouter.navigationState.storeVisit(sanitisedVisit);
|
|
6140
|
+
if (initialVisit.hasRoutingChangedFrom(sanitisedVisit)) {
|
|
6141
|
+
// Regenerate the url
|
|
6142
|
+
/** @type {?} */
|
|
6143
|
+
const urlSnapshot = this.placeRouter.parseUrl(state.url).updateVisitSegments(sanitisedVisit);
|
|
6144
|
+
console.log('##### Place Guard Redirect', urlSnapshot);
|
|
6145
|
+
return urlSnapshot;
|
|
6146
|
+
}
|
|
6147
|
+
else {
|
|
6148
|
+
return true;
|
|
6149
|
+
}
|
|
6150
|
+
})));
|
|
6151
|
+
return this.handleGuardResult(result);
|
|
5936
6152
|
})));
|
|
5937
6153
|
});
|
|
5938
6154
|
}
|
|
6155
|
+
// @Trace()
|
|
5939
6156
|
/**
|
|
5940
6157
|
* @param {?} component
|
|
5941
6158
|
* @param {?} currentRoute
|
|
@@ -5945,9 +6162,28 @@ class AbstractPlaceGuard {
|
|
|
5945
6162
|
*/
|
|
5946
6163
|
canDeactivate(component, currentRoute, currentState, nextState) {
|
|
5947
6164
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5948
|
-
|
|
6165
|
+
/** @type {?} */
|
|
6166
|
+
const currentUrl = this.placeRouter.parseUrl(currentState.url);
|
|
6167
|
+
/** @type {?} */
|
|
6168
|
+
const nextUrl = this.placeRouter.parseUrl(nextState.url);
|
|
6169
|
+
/** @type {?} */
|
|
6170
|
+
const result = yield this.placeRouter.navigationState.canDeactivatePlace(component, currentUrl, nextUrl);
|
|
6171
|
+
return this.handleGuardResult(result);
|
|
5949
6172
|
});
|
|
5950
6173
|
}
|
|
6174
|
+
/**
|
|
6175
|
+
* @private
|
|
6176
|
+
* @param {?} result
|
|
6177
|
+
* @return {?}
|
|
6178
|
+
*/
|
|
6179
|
+
handleGuardResult(result) {
|
|
6180
|
+
if (result instanceof UrlSnapshot) {
|
|
6181
|
+
return result.urlTree;
|
|
6182
|
+
}
|
|
6183
|
+
else {
|
|
6184
|
+
return result;
|
|
6185
|
+
}
|
|
6186
|
+
}
|
|
5951
6187
|
// @Trace()
|
|
5952
6188
|
/**
|
|
5953
6189
|
* @protected
|
|
@@ -5977,6 +6213,7 @@ class AbstractPlaceGuard {
|
|
|
5977
6213
|
}
|
|
5978
6214
|
});
|
|
5979
6215
|
}
|
|
6216
|
+
// @Trace()
|
|
5980
6217
|
/**
|
|
5981
6218
|
* @param {?} activatedRoute
|
|
5982
6219
|
* @param {?} state
|
|
@@ -5989,181 +6226,66 @@ class AbstractPlaceGuard {
|
|
|
5989
6226
|
return (authorised instanceof Observable) ? authorised.toPromise() : authorised;
|
|
5990
6227
|
});
|
|
5991
6228
|
}
|
|
5992
|
-
|
|
5993
|
-
__decorate([
|
|
5994
|
-
Trace(),
|
|
5995
|
-
__metadata("design:type", Function),
|
|
5996
|
-
__metadata("design:paramtypes", [ActivatedRouteSnapshot, RouterStateSnapshot]),
|
|
5997
|
-
__metadata("design:returntype", Promise)
|
|
5998
|
-
], AbstractPlaceGuard.prototype, "isAuthorised", null);
|
|
5999
|
-
if (false) {
|
|
6000
|
-
/**
|
|
6001
|
-
* @type {?}
|
|
6002
|
-
* @private
|
|
6003
|
-
*/
|
|
6004
|
-
AbstractPlaceGuard.prototype.router;
|
|
6005
|
-
/**
|
|
6006
|
-
* @type {?}
|
|
6007
|
-
* @private
|
|
6008
|
-
*/
|
|
6009
|
-
AbstractPlaceGuard.prototype.urlSerializer;
|
|
6010
|
-
/**
|
|
6011
|
-
* @type {?}
|
|
6012
|
-
* @private
|
|
6013
|
-
*/
|
|
6014
|
-
AbstractPlaceGuard.prototype.placeRouter;
|
|
6015
|
-
/**
|
|
6016
|
-
* @type {?}
|
|
6017
|
-
* @private
|
|
6018
|
-
*/
|
|
6019
|
-
AbstractPlaceGuard.prototype.placeHistory;
|
|
6020
|
-
/**
|
|
6021
|
-
* @type {?}
|
|
6022
|
-
* @private
|
|
6023
|
-
*/
|
|
6024
|
-
AbstractPlaceGuard.prototype.injector;
|
|
6025
|
-
/**
|
|
6026
|
-
* @abstract
|
|
6027
|
-
* @param {?} injector
|
|
6028
|
-
* @return {?}
|
|
6029
|
-
*/
|
|
6030
|
-
AbstractPlaceGuard.prototype.getAuthGuard = function (injector) { };
|
|
6031
|
-
}
|
|
6032
|
-
|
|
6033
|
-
/**
|
|
6034
|
-
* @fileoverview added by tsickle
|
|
6035
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
6036
|
-
*/
|
|
6037
|
-
class InteractionGuard {
|
|
6038
|
-
/**
|
|
6039
|
-
* @param {?} router
|
|
6040
|
-
* @param {?} injector
|
|
6041
|
-
* @param {?} placeRouter
|
|
6042
|
-
* @param {?} angularLocation
|
|
6043
|
-
* @param {?} interactionService
|
|
6044
|
-
*/
|
|
6045
|
-
constructor(router, injector, placeRouter, angularLocation, interactionService) {
|
|
6046
|
-
this.router = router;
|
|
6047
|
-
this.injector = injector;
|
|
6048
|
-
this.placeRouter = placeRouter;
|
|
6049
|
-
this.angularLocation = angularLocation;
|
|
6050
|
-
this.interactionService = interactionService;
|
|
6051
|
-
}
|
|
6229
|
+
// @Trace()
|
|
6052
6230
|
/**
|
|
6053
6231
|
* @param {?} route
|
|
6054
6232
|
* @param {?} state
|
|
6233
|
+
* @param {?} then
|
|
6055
6234
|
* @return {?}
|
|
6056
6235
|
*/
|
|
6057
|
-
|
|
6058
|
-
/** @type {?} */
|
|
6059
|
-
const url = this.router.parseUrl(state.url);
|
|
6060
|
-
if (!this.interactionService.isActive() && url.root.children[UrlSnapshot.INTERACTION_ROUTER_OUTLET]) {
|
|
6061
|
-
// This happens if we reload the page or the url was pasted as the route should only be activated
|
|
6062
|
-
// after the interaction context has become active.
|
|
6063
|
-
delete url.root.children[UrlSnapshot.INTERACTION_ROUTER_OUTLET];
|
|
6064
|
-
return url;
|
|
6065
|
-
}
|
|
6066
|
-
else {
|
|
6067
|
-
return true;
|
|
6068
|
-
}
|
|
6069
|
-
}
|
|
6070
|
-
/**
|
|
6071
|
-
* @param {?} component
|
|
6072
|
-
* @param {?} currentRoute
|
|
6073
|
-
* @param {?} currentState
|
|
6074
|
-
* @param {?=} nextState
|
|
6075
|
-
* @return {?}
|
|
6076
|
-
*/
|
|
6077
|
-
canDeactivate(component, currentRoute, currentState, nextState) {
|
|
6236
|
+
cleanInteractionState(route, state, then) {
|
|
6078
6237
|
return __awaiter(this, void 0, void 0, function* () {
|
|
6079
|
-
|
|
6080
|
-
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
|
|
6087
|
-
|
|
6088
|
-
activity.cancel();
|
|
6089
|
-
}
|
|
6238
|
+
/** @type {?} */
|
|
6239
|
+
const url = this.placeRouter.parseUrl(state.url);
|
|
6240
|
+
if (!this.interactionService.isActive() && url.hasInteractionIds()) {
|
|
6241
|
+
// This happens if we reload the page or the url was pasted as the route should only be activated
|
|
6242
|
+
// after the interaction context has become active.
|
|
6243
|
+
return url.removeInteractionIds();
|
|
6244
|
+
}
|
|
6245
|
+
else {
|
|
6246
|
+
return then();
|
|
6090
6247
|
}
|
|
6091
|
-
// IMPORTANT:
|
|
6092
|
-
// We always return true, the router state engine will redirect as required. Return false
|
|
6093
|
-
// during the guard causes all kinds of grief. It might be worth trying a redirect here
|
|
6094
|
-
// again now that our state engine is more thorough.
|
|
6095
|
-
return true;
|
|
6096
6248
|
});
|
|
6097
6249
|
}
|
|
6098
6250
|
}
|
|
6099
|
-
InteractionGuard.decorators = [
|
|
6100
|
-
{ type: Injectable, args: [{
|
|
6101
|
-
providedIn: 'root'
|
|
6102
|
-
},] }
|
|
6103
|
-
];
|
|
6104
|
-
/** @nocollapse */
|
|
6105
|
-
InteractionGuard.ctorParameters = () => [
|
|
6106
|
-
{ type: Router },
|
|
6107
|
-
{ type: Injector },
|
|
6108
|
-
{ type: PlaceRouter },
|
|
6109
|
-
{ type: Location },
|
|
6110
|
-
{ type: InteractionService }
|
|
6111
|
-
];
|
|
6112
|
-
/** @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" });
|
|
6113
6251
|
if (false) {
|
|
6114
6252
|
/**
|
|
6115
6253
|
* @type {?}
|
|
6116
6254
|
* @private
|
|
6117
6255
|
*/
|
|
6118
|
-
|
|
6256
|
+
PlaceGuard.prototype.router;
|
|
6119
6257
|
/**
|
|
6120
6258
|
* @type {?}
|
|
6121
6259
|
* @private
|
|
6122
6260
|
*/
|
|
6123
|
-
|
|
6261
|
+
PlaceGuard.prototype.urlSerializer;
|
|
6124
6262
|
/**
|
|
6125
6263
|
* @type {?}
|
|
6126
6264
|
* @private
|
|
6127
6265
|
*/
|
|
6128
|
-
|
|
6266
|
+
PlaceGuard.prototype.placeRouter;
|
|
6129
6267
|
/**
|
|
6130
6268
|
* @type {?}
|
|
6131
6269
|
* @private
|
|
6132
6270
|
*/
|
|
6133
|
-
|
|
6271
|
+
PlaceGuard.prototype.placeHistory;
|
|
6134
6272
|
/**
|
|
6135
6273
|
* @type {?}
|
|
6136
6274
|
* @private
|
|
6137
6275
|
*/
|
|
6138
|
-
|
|
6139
|
-
}
|
|
6140
|
-
|
|
6141
|
-
/**
|
|
6142
|
-
* @fileoverview added by tsickle
|
|
6143
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
6144
|
-
*/
|
|
6145
|
-
class NoopAuthGuard {
|
|
6146
|
-
constructor() {
|
|
6147
|
-
}
|
|
6276
|
+
PlaceGuard.prototype.interactionService;
|
|
6148
6277
|
/**
|
|
6149
|
-
* @
|
|
6150
|
-
* @
|
|
6278
|
+
* @type {?}
|
|
6279
|
+
* @private
|
|
6280
|
+
*/
|
|
6281
|
+
PlaceGuard.prototype.injector;
|
|
6282
|
+
/**
|
|
6283
|
+
* @abstract
|
|
6284
|
+
* @param {?} injector
|
|
6151
6285
|
* @return {?}
|
|
6152
6286
|
*/
|
|
6153
|
-
|
|
6154
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
6155
|
-
return true;
|
|
6156
|
-
});
|
|
6157
|
-
}
|
|
6287
|
+
PlaceGuard.prototype.getAuthGuard = function (injector) { };
|
|
6158
6288
|
}
|
|
6159
|
-
NoopAuthGuard.decorators = [
|
|
6160
|
-
{ type: Injectable, args: [{
|
|
6161
|
-
providedIn: 'root'
|
|
6162
|
-
},] }
|
|
6163
|
-
];
|
|
6164
|
-
/** @nocollapse */
|
|
6165
|
-
NoopAuthGuard.ctorParameters = () => [];
|
|
6166
|
-
/** @nocollapse */ NoopAuthGuard.ngInjectableDef = ɵɵdefineInjectable({ factory: function NoopAuthGuard_Factory() { return new NoopAuthGuard(); }, token: NoopAuthGuard, providedIn: "root" });
|
|
6167
6289
|
|
|
6168
6290
|
/**
|
|
6169
6291
|
* @fileoverview added by tsickle
|
|
@@ -6412,5 +6534,5 @@ if (false) {
|
|
|
6412
6534
|
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
6413
6535
|
*/
|
|
6414
6536
|
|
|
6415
|
-
export { ACTIVITY_DATA, AUP_PLACE_CONFIG, AbstractActivity, AbstractInputComponent,
|
|
6537
|
+
export { ACTIVITY_DATA, AUP_PLACE_CONFIG, AbstractActivity, AbstractInputComponent, AbstractPlaceNavigationComponent, Activity, ActivityContainerComponent, ActivityOutletComponent, AlertDialogComponent, AngularUiPowerupsModule, Bounds, BusyOverlayComponent, CommandDirective, ComponentsModule, ConfirmThenDialogComponent, ConfirmationDialogComponent, ConsolidatedParameterMap, DEFINITION_META_DATA_KEY, DIALOG_INTERACTION_SERVICE_DEFAULTS, DialogInteractionContext, DialogInteractionContextFactory, Dimension, DirectivesModule, DisposableComponent, EmptyStateComponent, FocusBindingDirective, Formatter, InplaceInteractionContextComponent, InteractionContext, InteractionContextBase, InteractionModule, InteractionService, LEFT_RIGHT_PLACE_ANIMATION, ListPlaceNavComponent, ModalInteractionContextFactory, NavigationState, NoopAuthGuard, NoopComponent, NumberInputComponent, ParameterDefinition, PasswordInputComponent, Place, PlaceComponent, PlaceComponentDeactivationHandler, PlaceDefinition, PlaceGuard, PlaceHistory, PlaceModule, PlaceOutletComponent, PlaceRouter, Point, ROUTE_PARAMETER_LIST_KEY, ResizeAwareComponent, RouteId, SelectInputComponent, StringInputComponent, TabbedPlaceNavigationComponent, UrlSnapshot, Visit, VisitParameter, VisitParameterList, VisitSanitiser, leftRightPlaceAnimation, slideDownAndUpAnimation, DirectivesModule as ɵa, CommandDirective as ɵb, InteractionModule as ɵba, ActivityContainerComponent as ɵbb, InteractionContextBase as ɵbc, InteractionContext as ɵbd, ActivityOutletComponent as ɵbe, ConfirmationDialogComponent as ɵbf, AbstractActivity as ɵbg, ACTIVITY_DATA as ɵbh, Activity as ɵbi, ConfirmThenDialogComponent as ɵbk, AlertDialogComponent as ɵbl, InplaceInteractionContextComponent as ɵbn, 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 };
|
|
6416
6538
|
//# sourceMappingURL=coolon-angular-ui-powerups.js.map
|