@coolon/angular-ui-powerups 3.7.3 → 3.7.5
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/CHANGELOG.md +4 -0
- package/bundles/coolon-angular-ui-powerups.umd.js +10 -30
- 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.metadata.json +1 -1
- package/esm2015/lib/place/components/place-outlet/place-outlet.component.js +2 -7
- package/esm2015/lib/place/components/place-outlet/place-outlet.component.js.map +1 -1
- package/esm2015/lib/place/components/place-outlet/place-outlet.component.metadata.json +1 -1
- package/esm2015/lib/place/navigation/session/navigation-session.js +3 -3
- package/esm2015/lib/place/navigation/session/navigation-session.js.map +1 -1
- package/esm2015/lib/place/place-access-guard.js +2 -15
- package/esm2015/lib/place/place-access-guard.js.map +1 -1
- package/esm2015/lib/place/place-router.js +5 -10
- package/esm2015/lib/place/place-router.js.map +1 -1
- package/esm2015/lib/place/place-router.metadata.json +1 -1
- package/esm2015/lib/place/visit.js +1 -1
- package/esm2015/lib/place/visit.js.map +1 -1
- package/esm2015/lib/place/visit.metadata.json +1 -1
- package/fesm2015/coolon-angular-ui-powerups.js +10 -30
- package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
- package/package.json +1 -1
- package/schematics/place-add/index.js.map +1 -1
- package/schematics/utils/workspace.js.map +1 -1
- package/schematics/bootstrap-app/templates/app/auth/place-auth.service.ts.template +0 -41
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
|
2
2
|
import { Component, EventEmitter, Inject, Input, Optional, Output, SkipSelf, ViewChild } from '@angular/core';
|
|
3
3
|
import { Router, RouterOutlet } from '@angular/router';
|
|
4
|
-
import { DebugContext, Dsl, lang, ListModel, MutableValueModel, StoreInListModel, StoreInValueModel,
|
|
4
|
+
import { DebugContext, Dsl, lang, ListModel, MutableValueModel, StoreInListModel, StoreInValueModel, TrackExternal, ValueModel } from '@coolon/pectin';
|
|
5
5
|
import * as _ from 'lodash';
|
|
6
6
|
import { DisposableComponent } from '../../../components/disposable-component';
|
|
7
7
|
import { AUP_PLACE_CONFIG } from '../../place-config';
|
|
@@ -113,6 +113,7 @@ export class PlaceOutletComponent extends DisposableComponent {
|
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
|
+
// @Trace()
|
|
116
117
|
onOutletDeactivated() {
|
|
117
118
|
this.outletActivated.value = false;
|
|
118
119
|
this._activePlaceModel.value = null;
|
|
@@ -212,10 +213,4 @@ __decorate([
|
|
|
212
213
|
StoreInListModel('customPlaceAnimationOrderModel'),
|
|
213
214
|
__metadata("design:type", Array)
|
|
214
215
|
], PlaceOutletComponent.prototype, "customPlaceAnimationOrder", void 0);
|
|
215
|
-
__decorate([
|
|
216
|
-
Trace(),
|
|
217
|
-
__metadata("design:type", Function),
|
|
218
|
-
__metadata("design:paramtypes", []),
|
|
219
|
-
__metadata("design:returntype", void 0)
|
|
220
|
-
], PlaceOutletComponent.prototype, "onOutletDeactivated", null);
|
|
221
216
|
//# sourceMappingURL=place-outlet.component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"place-outlet.component.js","sourceRoot":"","sources":["../../../../../../../../libs/angular-ui-powerups/src/lib/place/components/place-outlet/place-outlet.component.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAU,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACtH,OAAO,EAAkB,MAAM,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAGL,YAAY,EACZ,GAAG,EACH,IAAI,EACJ,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EAAE,K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IACT,gBAAgB;QACd,8DAA8D;IAChE,CAAC;IAED,WAAW;IACX,aAAa;QACX,IAAI,IAAI,CAAC,sBAAsB,EAAE;YAC/B,IAAI,CAAC,sBAAsB,EAAE,CAAC;YAC9B,IAAI,CAAC,sBAAsB,GAAG,SAAS,CAAC;SACzC;IACH,CAAC;;;YA/OF,SAAS,SAAC;gBACT,QAAQ,EAAE,kBAAkB;gBAC5B,i4BAA4C;gBAE5C,UAAU,EAAE,CAAC,0BAA0B,CAAC;;aACzC;;;YAvCwB,MAAM;YAoBtB,WAAW;4CAiEL,QAAQ,YAAI,MAAM,SAAC,gBAAgB;YACE,oBAAoB,uBAAzD,QAAQ,YAAI,QAAQ;;;sBA5ChC,KAAK;2BAGL,KAAK;6CAIL,KAAK,SAAC,0BAA0B;wCAIhC,KAAK,SAAC,qBAAqB;2BAG3B,MAAM;wBAGN,SAAS,SAAC,aAAa,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;;AAhB1C;IADU,iBAAiB,CAAC,cAAc,CAAC;;qDAC1B;AAGjB;IADU,aAAa,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;8BACjC,UAAU;0DAAU;AAIlC;IADoC,aAAa,EAAE;8BACnB,SAAS;4EAAgC;AAIzE;IAD+B,gBAAgB,CAAC,gCAAgC,CAAC;;uEACtB;AAyJ3D;IADC,KAAK,EAAE;;;;+DAKP","sourcesContent":["import { Component, EventEmitter, Inject, Input, OnInit, Optional, Output, SkipSelf, ViewChild } from '@angular/core';\nimport { ActivatedRoute, Router, RouterOutlet } from '@angular/router';\nimport {\n BooleanValueModelChain,\n Constructable,\n DebugContext,\n Dsl,\n lang,\n ListModel, ListModelChain,\n MutableValueModel,\n StoreInListModel,\n StoreInValueModel, Trace,\n TrackExternal,\n ValueModel,\n ValueModelChain\n} from '@coolon/pectin';\nimport * as _ from 'lodash';\nimport { DisposableComponent } from '../../../components/disposable-component';\nimport { PlaceComponent } from '../../place-component';\nimport { AUP_PLACE_CONFIG, PlaceConfig } from '../../place-config';\nimport { PlaceDefinition } from '../../place-definition';\nimport { PlaceRouter } from '../../place-router';\n\nimport { Visit } from '../../visit';\nimport { LEFT_RIGHT_PLACE_ANIMATION } from './route-animations';\n\n// Quick hack to avoid circular references between this and PlaceComponents.\ninterface PlaceRef {\n readonly placeDefinition: PlaceDefinition\n\n initialiseBindings(param: ValueModel<Visit>): void;\n\n onPlaceReady(): void;\n}\n\n@Component({\n selector: 'aup-place-outlet',\n templateUrl: './place-outlet.component.html',\n styleUrls: ['./place-outlet.component.scss'],\n animations: [LEFT_RIGHT_PLACE_ANIMATION]\n})\nexport class PlaceOutletComponent extends DisposableComponent implements OnInit {\n\n @Input() @StoreInValueModel('animateModel')\n animate: boolean;\n\n @Input() @TrackExternal({ defaultValue: true })\n animateModel: ValueModel<boolean>;\n\n // tslint:disable-next-line:no-input-rename\n @Input('placeAnimationOrderModel') @TrackExternal()\n customPlaceAnimationOrderModel: ListModel<Constructable<PlaceComponent>>;\n\n // tslint:disable-next-line:no-input-rename\n @Input('placeAnimationOrder') @StoreInListModel('customPlaceAnimationOrderModel')\n customPlaceAnimationOrder: Constructable<PlaceComponent>[];\n\n @Output()\n readonly placeChanged = new EventEmitter<PlaceComponent>();\n\n @ViewChild('routeOutlet', { static: true })\n routerOut: RouterOutlet;\n\n private onAnimationFinishedJob: () => void;\n\n\n private outletActivated = new MutableValueModel(false);\n private readonly _activatedRouteModel = new MutableValueModel<ActivatedRoute>();\n private readonly _activePlaceModel = new MutableValueModel<PlaceComponent>();\n private readonly _activePlaceDefinition: ValueModelChain<PlaceDefinition>;\n\n private parentOutletModel: MutableValueModel<PlaceOutletComponent>;\n public readonly activePlaceAnimationPosition: ValueModelChain<number>;\n\n private initialPlaceIndex: number = null;\n private routerVisitModel: ValueModelChain<Visit>;\n private _isPushingVisitToRoute = new MutableValueModel<boolean>(false);\n private navigationInProgress: ValueModelChain<boolean>;\n\n private isVeryFirstLoad = true;\n private placesInAnimationOrder: ListModelChain<Constructable<PlaceComponent>>;\n private animationSupported: BooleanValueModelChain;\n readonly animationEnabled: BooleanValueModelChain;\n\n constructor(private readonly router: Router,\n private readonly placeRouter: PlaceRouter,\n @Optional() @Inject(AUP_PLACE_CONFIG) readonly placeConfig: PlaceConfig,\n @SkipSelf() @Optional() parentOutlet: PlaceOutletComponent) {\n super();\n const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);\n\n this.parentOutletModel = new MutableValueModel(parentOutlet);\n\n const defaultPlaceAnimationOrder = chain(this.parentOutletModel)\n .pullValueModel(o => o.activePlaceModel)\n .pluck('placeDefinition')\n .pluckList('children')\n .pluck('component');\n\n const activatePlaceType = chain(this.activePlaceModel).map(p => p.constructor as Constructable<PlaceComponent>);\n\n this.placesInAnimationOrder = chain(this.customPlaceAnimationOrderModel)\n .otherwise(defaultPlaceAnimationOrder);\n\n this.activePlaceAnimationPosition = this.placesInAnimationOrder\n .reduce((placesInOrder) => {\n let placeIndex = 0;\n if (activatePlaceType.value) {\n placeIndex = placesInOrder.indexOf(activatePlaceType.value);\n if (_.isNil(this.initialPlaceIndex)) {\n this.initialPlaceIndex = placeIndex;\n }\n }\n return _.isNil(this.initialPlaceIndex) ? 0 : placeIndex - this.initialPlaceIndex;\n }, { dependsOn: activatePlaceType });\n\n this.animationSupported = this.placesInAnimationOrder.count().isGreaterThan(0);\n this.animationEnabled = valueOf.all(\n this.animateModel,\n this.animationSupported\n ).areTruthy();\n\n // Extract our visit model from the place router.\n this._activePlaceDefinition = chain(this._activePlaceModel).pluck('placeDefinition');\n this.routerVisitModel = this._activePlaceDefinition.findIn(chain(placeRouter.activeVisitsByPlaceDefinition));\n\n this.navigationInProgress = chain(this.placeRouter.navigationInProgress);\n\n when(this.navigationInProgress).becomesFalsey(() => {\n this.checkStateAndInitialise();\n });\n when(this.outletActivated).becomesTruthy(() => {\n this.checkStateAndInitialise();\n });\n\n chain(this._activePlaceModel)\n .postponeWhile(this.navigationInProgress)\n .subscribe(place => this.placeChanged.emit(place));\n\n when(placeRouter.accessGuard).changes(guard => {\n const activePlace = this._activePlaceModel.value;\n if (activePlace && !guard.isAuthorised(activePlace.placeDefinition)) {\n const visit = placeRouter.getAuthorisationFailureRedirect(this._activatedRouteModel.value.snapshot, this.router.routerState.snapshot);\n this.placeRouter.navigate(visit)\n }\n });\n\n }\n\n // @Trace()\n ngOnInit() {\n }\n\n // @Trace()\n getAnimationOrder() {\n return this.activePlaceAnimationPosition.value;\n }\n\n get animationDuration() {\n return this.placeConfig && this.placeConfig.animationDuration ? this.placeConfig.animationDuration : '500ms';\n }\n\n // @Trace()\n navigate(visit: Visit) {\n // const place = this.placesInAnimationOrder.query().findMatching(p => visit.placeDefinition.component === p);\n // if (!place) {\n // lang.illegalState()\n // }\n this.placeRouter.navigate(visit, {\n relativeTo: this.parentOutlet ? this.parentOutlet.activatedRouteModel.value : null\n });\n }\n\n get parentOutlet(): PlaceOutletComponent {\n return this.parentOutletModel.value;\n }\n\n\n get activePlaceModel(): ValueModel<PlaceComponent> {\n return this._activePlaceModel.readonly;\n }\n\n get activatedRouteModel(): ValueModel<ActivatedRoute> {\n return this._activatedRouteModel.readonly;\n }\n\n // @Trace()\n onOutletActivated(routerOutlet: RouterOutlet, place: PlaceComponent) {\n this._activatedRouteModel.value = routerOutlet.activatedRoute;\n this._activePlaceModel.value = place;\n this.validateAnimationState(place);\n this.outletActivated.value = true;\n this.checkStateAndInitialise();\n }\n\n private validateAnimationState(place: PlaceComponent) {\n if (this.animateModel.value) {\n if (this.placesInAnimationOrder.length < 1) {\n console.error('PlaceOutlet.animate === true but placeAnimationOrder has not been set. Animation is disabled.');\n } else {\n if (!this.placesInAnimationOrder.query().includes(place.placeDefinition.component)) {\n console.error(`PlaceOutlet.animate === true but placeAnimationOrder doesn't contain ${place.placeDefinition.component.name}.`);\n }\n }\n }\n }\n\n @Trace()\n onOutletDeactivated() {\n this.outletActivated.value = false;\n this._activePlaceModel.value = null;\n this._activatedRouteModel.value = null;\n }\n\n // @Trace()\n private checkStateAndInitialise() {\n const routerVisit = this.routerVisitModel.value;\n const activePlace = this.activePlaceModel.value;\n if (routerVisit && activePlace && !activePlace.isInitialised()) {\n if (routerVisit.placeDefinition !== activePlace.placeDefinition) {\n lang.illegalState('wrong visit!!!');\n }\n this.initialisePlace(routerVisit, activePlace);\n }\n }\n\n private initialisePlace(routerVisit: Visit, activePlace: PlaceComponent) {\n const visitModel = new MutableValueModel<Visit>(routerVisit);\n DebugContext.tag(visitModel, `PlaceOutletComponent[${activePlace.constructor.name})].visitModel`);\n activePlace.initialiseVisit(routerVisit, (current, previous) => {\n this.pushVisitChangeToRoute(previous, current);\n });\n const finishPlaceLoad = () => {\n this._activePlaceModel.value._notifyActive(true);\n }\n if (!this.animationEnabled.value || this.isVeryFirstLoad) {\n // if animation is disabled or this is the very first load then\n // we won't get our animation done callback so we finish the\n // process here and now.\n this.isVeryFirstLoad = false;\n finishPlaceLoad()\n } else {\n this.onAnimationFinishedJob = finishPlaceLoad;\n }\n const { when, chain, valueOf } = Dsl.disposeWith(activePlace);\n when(this.routerVisitModel)\n .changes(visit => {\n activePlace.updateVisit(visit);\n }, {\n unless: valueOf.any(\n this._isPushingVisitToRoute,\n this.routerVisitModel.isNil()\n ).areTruthy()\n });\n }\n\n private pushVisitChangeToRoute(previous: Visit, current: Visit) {\n this._isPushingVisitToRoute.value = true;\n this.placeRouter.pushVisitChangesToRoute(previous, current).finally(() => {\n this._isPushingVisitToRoute.value = false;\n });\n }\n\n// @Trace()\n animationStarted() {\n // console.log({ activePlace: this._activePlaceModel.value });\n }\n\n // @Trace()\n animationDone() {\n if (this.onAnimationFinishedJob) {\n this.onAnimationFinishedJob();\n this.onAnimationFinishedJob = undefined;\n }\n }\n\n}\n"]}
|
|
1
|
+
{"version":3,"file":"place-outlet.component.js","sourceRoot":"","sources":["../../../../../../../../libs/angular-ui-powerups/src/lib/place/components/place-outlet/place-outlet.component.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAA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e,EAAE,OAAc;QAC5D,IAAI,CAAC,sBAAsB,CAAC,KAAK,GAAG,IAAI,CAAC;QACzC,IAAI,CAAC,WAAW,CAAC,uBAAuB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE;YACvE,IAAI,CAAC,sBAAsB,CAAC,KAAK,GAAG,KAAK,CAAC;QAC5C,CAAC,CAAC,CAAC;IACL,CAAC;IAEH,WAAW;IACT,gBAAgB;QACd,8DAA8D;IAChE,CAAC;IAED,WAAW;IACX,aAAa;QACX,IAAI,IAAI,CAAC,sBAAsB,EAAE;YAC/B,IAAI,CAAC,sBAAsB,EAAE,CAAC;YAC9B,IAAI,CAAC,sBAAsB,GAAG,SAAS,CAAC;SACzC;IACH,CAAC;;;YA/OF,SAAS,SAAC;gBACT,QAAQ,EAAE,kBAAkB;gBAC5B,i4BAA4C;gBAE5C,UAAU,EAAE,CAAC,0BAA0B,CAAC;;aACzC;;;YAvCwB,MAAM;YAoBtB,WAAW;4CAiEL,QAAQ,YAAI,MAAM,SAAC,gBAAgB;YACE,oBAAoB,uBAAzD,QAAQ,YAAI,QAAQ;;;sBA5ChC,KAAK;2BAGL,KAAK;6CAIL,KAAK,SAAC,0BAA0B;wCAIhC,KAAK,SAAC,qBAAqB;2BAG3B,MAAM;wBAGN,SAAS,SAAC,aAAa,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;;AAhB1C;IADU,iBAAiB,CAAC,cAAc,CAAC;;qDAC1B;AAGjB;IADU,aAAa,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;8BACjC,UAAU;0DAAU;AAIlC;IADoC,aAAa,EAAE;8BACnB,SAAS;4EAAgC;AAIzE;IAD+B,gBAAgB,CAAC,gCAAgC,CAAC;;uEACtB","sourcesContent":["import { Component, EventEmitter, Inject, Input, OnInit, Optional, Output, SkipSelf, ViewChild } from '@angular/core';\nimport { ActivatedRoute, Router, RouterOutlet } from '@angular/router';\nimport {\n BooleanValueModelChain,\n Constructable,\n DebugContext,\n Dsl,\n lang,\n ListModel, ListModelChain,\n MutableValueModel,\n StoreInListModel,\n StoreInValueModel, Trace,\n TrackExternal,\n ValueModel,\n ValueModelChain\n} from '@coolon/pectin';\nimport * as _ from 'lodash';\nimport { DisposableComponent } from '../../../components/disposable-component';\nimport { PlaceComponent } from '../../place-component';\nimport { AUP_PLACE_CONFIG, PlaceConfig } from '../../place-config';\nimport { PlaceDefinition } from '../../place-definition';\nimport { PlaceRouter } from '../../place-router';\n\nimport { Visit } from '../../visit';\nimport { LEFT_RIGHT_PLACE_ANIMATION } from './route-animations';\n\n// Quick hack to avoid circular references between this and PlaceComponents.\ninterface PlaceRef {\n readonly placeDefinition: PlaceDefinition\n\n initialiseBindings(param: ValueModel<Visit>): void;\n\n onPlaceReady(): void;\n}\n\n@Component({\n selector: 'aup-place-outlet',\n templateUrl: './place-outlet.component.html',\n styleUrls: ['./place-outlet.component.scss'],\n animations: [LEFT_RIGHT_PLACE_ANIMATION]\n})\nexport class PlaceOutletComponent extends DisposableComponent implements OnInit {\n\n @Input() @StoreInValueModel('animateModel')\n animate: boolean;\n\n @Input() @TrackExternal({ defaultValue: true })\n animateModel: ValueModel<boolean>;\n\n // tslint:disable-next-line:no-input-rename\n @Input('placeAnimationOrderModel') @TrackExternal()\n customPlaceAnimationOrderModel: ListModel<Constructable<PlaceComponent>>;\n\n // tslint:disable-next-line:no-input-rename\n @Input('placeAnimationOrder') @StoreInListModel('customPlaceAnimationOrderModel')\n customPlaceAnimationOrder: Constructable<PlaceComponent>[];\n\n @Output()\n readonly placeChanged = new EventEmitter<PlaceComponent>();\n\n @ViewChild('routeOutlet', { static: true })\n routerOut: RouterOutlet;\n\n private onAnimationFinishedJob: () => void;\n\n\n private outletActivated = new MutableValueModel(false);\n private readonly _activatedRouteModel = new MutableValueModel<ActivatedRoute>();\n private readonly _activePlaceModel = new MutableValueModel<PlaceComponent>();\n private readonly _activePlaceDefinition: ValueModelChain<PlaceDefinition>;\n\n private parentOutletModel: MutableValueModel<PlaceOutletComponent>;\n public readonly activePlaceAnimationPosition: ValueModelChain<number>;\n\n private initialPlaceIndex: number = null;\n private routerVisitModel: ValueModelChain<Visit>;\n private _isPushingVisitToRoute = new MutableValueModel<boolean>(false);\n private navigationInProgress: ValueModelChain<boolean>;\n\n private isVeryFirstLoad = true;\n private placesInAnimationOrder: ListModelChain<Constructable<PlaceComponent>>;\n private animationSupported: BooleanValueModelChain;\n readonly animationEnabled: BooleanValueModelChain;\n\n constructor(private readonly router: Router,\n private readonly placeRouter: PlaceRouter,\n @Optional() @Inject(AUP_PLACE_CONFIG) readonly placeConfig: PlaceConfig,\n @SkipSelf() @Optional() parentOutlet: PlaceOutletComponent) {\n super();\n const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);\n\n this.parentOutletModel = new MutableValueModel(parentOutlet);\n\n const defaultPlaceAnimationOrder = chain(this.parentOutletModel)\n .pullValueModel(o => o.activePlaceModel)\n .pluck('placeDefinition')\n .pluckList('children')\n .pluck('component');\n\n const activatePlaceType = chain(this.activePlaceModel).map(p => p.constructor as Constructable<PlaceComponent>);\n\n this.placesInAnimationOrder = chain(this.customPlaceAnimationOrderModel)\n .otherwise(defaultPlaceAnimationOrder);\n\n this.activePlaceAnimationPosition = this.placesInAnimationOrder\n .reduce((placesInOrder) => {\n let placeIndex = 0;\n if (activatePlaceType.value) {\n placeIndex = placesInOrder.indexOf(activatePlaceType.value);\n if (_.isNil(this.initialPlaceIndex)) {\n this.initialPlaceIndex = placeIndex;\n }\n }\n return _.isNil(this.initialPlaceIndex) ? 0 : placeIndex - this.initialPlaceIndex;\n }, { dependsOn: activatePlaceType });\n\n this.animationSupported = this.placesInAnimationOrder.count().isGreaterThan(0);\n this.animationEnabled = valueOf.all(\n this.animateModel,\n this.animationSupported\n ).areTruthy();\n\n // Extract our visit model from the place router.\n this._activePlaceDefinition = chain(this._activePlaceModel).pluck('placeDefinition');\n this.routerVisitModel = this._activePlaceDefinition.findIn(chain(placeRouter.activeVisitsByPlaceDefinition));\n\n this.navigationInProgress = chain(this.placeRouter.navigationInProgress);\n\n when(this.navigationInProgress).becomesFalsey(() => {\n this.checkStateAndInitialise();\n });\n when(this.outletActivated).becomesTruthy(() => {\n this.checkStateAndInitialise();\n });\n\n chain(this._activePlaceModel)\n .postponeWhile(this.navigationInProgress)\n .subscribe(place => this.placeChanged.emit(place));\n\n when(placeRouter.accessGuard).changes(guard => {\n const activePlace = this._activePlaceModel.value;\n if (activePlace && !guard.isAuthorised(activePlace.placeDefinition)) {\n const visit = placeRouter.getAuthorisationFailureRedirect(this._activatedRouteModel.value.snapshot, this.router.routerState.snapshot);\n this.placeRouter.navigate(visit)\n }\n });\n\n }\n\n // @Trace()\n ngOnInit() {\n }\n\n // @Trace()\n getAnimationOrder() {\n return this.activePlaceAnimationPosition.value;\n }\n\n get animationDuration() {\n return this.placeConfig && this.placeConfig.animationDuration ? this.placeConfig.animationDuration : '500ms';\n }\n\n // @Trace()\n navigate(visit: Visit) {\n // const place = this.placesInAnimationOrder.query().findMatching(p => visit.placeDefinition.component === p);\n // if (!place) {\n // lang.illegalState()\n // }\n this.placeRouter.navigate(visit, {\n relativeTo: this.parentOutlet ? this.parentOutlet.activatedRouteModel.value : null\n });\n }\n\n get parentOutlet(): PlaceOutletComponent {\n return this.parentOutletModel.value;\n }\n\n\n get activePlaceModel(): ValueModel<PlaceComponent> {\n return this._activePlaceModel.readonly;\n }\n\n get activatedRouteModel(): ValueModel<ActivatedRoute> {\n return this._activatedRouteModel.readonly;\n }\n\n // @Trace()\n onOutletActivated(routerOutlet: RouterOutlet, place: PlaceComponent) {\n this._activatedRouteModel.value = routerOutlet.activatedRoute;\n this._activePlaceModel.value = place;\n this.validateAnimationState(place);\n this.outletActivated.value = true;\n this.checkStateAndInitialise();\n }\n\n private validateAnimationState(place: PlaceComponent) {\n if (this.animateModel.value) {\n if (this.placesInAnimationOrder.length < 1) {\n console.error('PlaceOutlet.animate === true but placeAnimationOrder has not been set. Animation is disabled.');\n } else {\n if (!this.placesInAnimationOrder.query().includes(place.placeDefinition.component)) {\n console.error(`PlaceOutlet.animate === true but placeAnimationOrder doesn't contain ${place.placeDefinition.component.name}.`);\n }\n }\n }\n }\n\n // @Trace()\n onOutletDeactivated() {\n this.outletActivated.value = false;\n this._activePlaceModel.value = null;\n this._activatedRouteModel.value = null;\n }\n\n // @Trace()\n private checkStateAndInitialise() {\n const routerVisit = this.routerVisitModel.value;\n const activePlace = this.activePlaceModel.value;\n if (routerVisit && activePlace && !activePlace.isInitialised()) {\n if (routerVisit.placeDefinition !== activePlace.placeDefinition) {\n lang.illegalState('wrong visit!!!');\n }\n this.initialisePlace(routerVisit, activePlace);\n }\n }\n\n private initialisePlace(routerVisit: Visit, activePlace: PlaceComponent) {\n const visitModel = new MutableValueModel<Visit>(routerVisit);\n DebugContext.tag(visitModel, `PlaceOutletComponent[${activePlace.constructor.name})].visitModel`);\n activePlace.initialiseVisit(routerVisit, (current, previous) => {\n this.pushVisitChangeToRoute(previous, current);\n });\n const finishPlaceLoad = () => {\n this._activePlaceModel.value._notifyActive(true);\n }\n if (!this.animationEnabled.value || this.isVeryFirstLoad) {\n // if animation is disabled or this is the very first load then\n // we won't get our animation done callback so we finish the\n // process here and now.\n this.isVeryFirstLoad = false;\n finishPlaceLoad()\n } else {\n this.onAnimationFinishedJob = finishPlaceLoad;\n }\n const { when, chain, valueOf } = Dsl.disposeWith(activePlace);\n when(this.routerVisitModel)\n .changes(visit => {\n activePlace.updateVisit(visit);\n }, {\n unless: valueOf.any(\n this._isPushingVisitToRoute,\n this.routerVisitModel.isNil()\n ).areTruthy()\n });\n }\n\n private pushVisitChangeToRoute(previous: Visit, current: Visit) {\n this._isPushingVisitToRoute.value = true;\n this.placeRouter.pushVisitChangesToRoute(previous, current).finally(() => {\n this._isPushingVisitToRoute.value = false;\n });\n }\n\n// @Trace()\n animationStarted() {\n // console.log({ activePlace: this._activePlaceModel.value });\n }\n\n // @Trace()\n animationDone() {\n if (this.onAnimationFinishedJob) {\n this.onAnimationFinishedJob();\n this.onAnimationFinishedJob = undefined;\n }\n }\n\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"PlaceOutletComponent":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"../../../components/disposable-component","name":"DisposableComponent","line":41,"character":42},"decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component","line":35,"character":1},"arguments":[{"selector":"aup-place-outlet","animations":[{"__symbolic":"reference","module":"./route-animations","name":"LEFT_RIGHT_PLACE_ANIMATION","line":39,"character":15}],"template":"<ng-container *ngIf=\"animationEnabled.value\">\n <div class=\"router-outlet-container\" cdkScrollable\n [@routeAnimations]=\"{value: getAnimationOrder(), params:{duration: animationDuration}}\"\n (@routeAnimations.start)=\"animationStarted()\"\n (@routeAnimations.done)=\"animationDone()\"\n >\n <router-outlet #routerOutlet=\"outlet\"\n (activate)=\"onOutletActivated(routerOutlet, $event)\"\n (deactivate)=\"onOutletDeactivated()\">\n </router-outlet>\n </div>\n</ng-container>\n\n<ng-container *ngIf=\"!animationEnabled.value\">\n <div class=\"router-outlet-container\" cdkScrollable>\n <router-outlet #routerOutlet=\"outlet\"\n (activate)=\"onOutletActivated(routerOutlet, $event)\"\n (deactivate)=\"onOutletDeactivated()\">\n </router-outlet>\n </div>\n</ng-container>\n\n","styles":[":host{display:flex;flex-direction:column;min-height:0}.router-outlet-container{display:block;flex:1;min-height:0;overflow-x:hidden;overflow-y:scroll;position:relative}router-outlet{display:none}"]}]}],"members":{"animate":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":43,"character":3}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@coolon/pectin","name":"StoreInValueModel","line":43,"character":12},"arguments":["animateModel"]}]}],"animateModel":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":46,"character":3}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@coolon/pectin","name":"TrackExternal","line":46,"character":12},"arguments":[{"defaultValue":true}]}]}],"customPlaceAnimationOrderModel":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":50,"character":3},"arguments":["placeAnimationOrderModel"]},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@coolon/pectin","name":"TrackExternal","line":50,"character":38}}]}],"customPlaceAnimationOrder":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":54,"character":3},"arguments":["placeAnimationOrder"]},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@coolon/pectin","name":"StoreInListModel","line":54,"character":33},"arguments":["customPlaceAnimationOrderModel"]}]}],"placeChanged":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output","line":57,"character":3}}]}],"routerOut":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"ViewChild","line":60,"character":3},"arguments":["routeOutlet",{"static":true}]}]}],"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[null,null,[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional","line":86,"character":15}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":86,"character":27},"arguments":[{"__symbolic":"reference","module":"../../place-config","name":"AUP_PLACE_CONFIG","line":86,"character":34}]}],[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"SkipSelf","line":87,"character":15}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional","line":87,"character":27}}]],"parameters":[{"__symbolic":"reference","module":"@angular/router","name":"Router","line":84,"character":39},{"__symbolic":"reference","module":"../../place-router","name":"PlaceRouter","line":85,"character":44},{"__symbolic":"reference","module":"../../place-config","name":"PlaceConfig","line":86,"character":74},{"__symbolic":"reference","name":"PlaceOutletComponent"}]}],"ngOnInit":[{"__symbolic":"method"}],"getAnimationOrder":[{"__symbolic":"method"}],"navigate":[{"__symbolic":"method"}],"onOutletActivated":[{"__symbolic":"method"}],"validateAnimationState":[{"__symbolic":"method"}],"onOutletDeactivated":[{"__symbolic":"method"
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"PlaceOutletComponent":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"../../../components/disposable-component","name":"DisposableComponent","line":41,"character":42},"decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component","line":35,"character":1},"arguments":[{"selector":"aup-place-outlet","animations":[{"__symbolic":"reference","module":"./route-animations","name":"LEFT_RIGHT_PLACE_ANIMATION","line":39,"character":15}],"template":"<ng-container *ngIf=\"animationEnabled.value\">\n <div class=\"router-outlet-container\" cdkScrollable\n [@routeAnimations]=\"{value: getAnimationOrder(), params:{duration: animationDuration}}\"\n (@routeAnimations.start)=\"animationStarted()\"\n (@routeAnimations.done)=\"animationDone()\"\n >\n <router-outlet #routerOutlet=\"outlet\"\n (activate)=\"onOutletActivated(routerOutlet, $event)\"\n (deactivate)=\"onOutletDeactivated()\">\n </router-outlet>\n </div>\n</ng-container>\n\n<ng-container *ngIf=\"!animationEnabled.value\">\n <div class=\"router-outlet-container\" cdkScrollable>\n <router-outlet #routerOutlet=\"outlet\"\n (activate)=\"onOutletActivated(routerOutlet, $event)\"\n (deactivate)=\"onOutletDeactivated()\">\n </router-outlet>\n </div>\n</ng-container>\n\n","styles":[":host{display:flex;flex-direction:column;min-height:0}.router-outlet-container{display:block;flex:1;min-height:0;overflow-x:hidden;overflow-y:scroll;position:relative}router-outlet{display:none}"]}]}],"members":{"animate":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":43,"character":3}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@coolon/pectin","name":"StoreInValueModel","line":43,"character":12},"arguments":["animateModel"]}]}],"animateModel":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":46,"character":3}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@coolon/pectin","name":"TrackExternal","line":46,"character":12},"arguments":[{"defaultValue":true}]}]}],"customPlaceAnimationOrderModel":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":50,"character":3},"arguments":["placeAnimationOrderModel"]},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@coolon/pectin","name":"TrackExternal","line":50,"character":38}}]}],"customPlaceAnimationOrder":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":54,"character":3},"arguments":["placeAnimationOrder"]},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@coolon/pectin","name":"StoreInListModel","line":54,"character":33},"arguments":["customPlaceAnimationOrderModel"]}]}],"placeChanged":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output","line":57,"character":3}}]}],"routerOut":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"ViewChild","line":60,"character":3},"arguments":["routeOutlet",{"static":true}]}]}],"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[null,null,[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional","line":86,"character":15}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":86,"character":27},"arguments":[{"__symbolic":"reference","module":"../../place-config","name":"AUP_PLACE_CONFIG","line":86,"character":34}]}],[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"SkipSelf","line":87,"character":15}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional","line":87,"character":27}}]],"parameters":[{"__symbolic":"reference","module":"@angular/router","name":"Router","line":84,"character":39},{"__symbolic":"reference","module":"../../place-router","name":"PlaceRouter","line":85,"character":44},{"__symbolic":"reference","module":"../../place-config","name":"PlaceConfig","line":86,"character":74},{"__symbolic":"reference","name":"PlaceOutletComponent"}]}],"ngOnInit":[{"__symbolic":"method"}],"getAnimationOrder":[{"__symbolic":"method"}],"navigate":[{"__symbolic":"method"}],"onOutletActivated":[{"__symbolic":"method"}],"validateAnimationState":[{"__symbolic":"method"}],"onOutletDeactivated":[{"__symbolic":"method"}],"checkStateAndInitialise":[{"__symbolic":"method"}],"initialisePlace":[{"__symbolic":"method"}],"pushVisitChangeToRoute":[{"__symbolic":"method"}],"animationStarted":[{"__symbolic":"method"}],"animationDone":[{"__symbolic":"method"}]}}}}]
|
|
@@ -94,14 +94,14 @@ export class NavigationSession extends GarbageCollector {
|
|
|
94
94
|
// Important: I tried to perform this fix at a later point int he routing cycle but it created all kinds of
|
|
95
95
|
// strangeness.
|
|
96
96
|
Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
|
|
97
|
-
console.log(`replacing ${this.urlService.getCurrentLocationUrlSnapshot().url} with ${poppedHistoryToReplace}`);
|
|
97
|
+
// console.log(`replacing ${this.urlService.getCurrentLocationUrlSnapshot().url} with ${poppedHistoryToReplace}`);
|
|
98
98
|
this.urlService.resetBrowserLocation(poppedHistoryToReplace, { replaceCurrent: true });
|
|
99
|
-
console.log(`pushing ${activeUrl} back onto the history.`);
|
|
99
|
+
// console.log(`pushing ${activeUrl} back onto the history.`);
|
|
100
100
|
this.urlService.resetBrowserLocation(activeUrl, { replaceCurrent: false });
|
|
101
101
|
}
|
|
102
102
|
ignore(event, reason) {
|
|
103
103
|
reason = reason ? ` -> ${reason}` : '';
|
|
104
|
-
Logger.get(this).info(`Ignoring router event${reason}: ${event.constructor.name} -> ${event.url} :: ${this.toString()}`);
|
|
104
|
+
// Logger.get(this).info(`Ignoring router event${reason}: ${event.constructor.name} -> ${event.url} :: ${this.toString()}`);
|
|
105
105
|
}
|
|
106
106
|
toString() {
|
|
107
107
|
return `${this.constructor.name}(${this.debugState()})`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigation-session.js","sourceRoot":"","sources":["../../../../../../../../libs/angular-ui-powerups/src/lib/place/navigation/session/navigation-session.ts"],"names":[],"mappings":";AACA,OAAO,EAAO,gBAAgB,EAAE,IAAI,EAAE,MAAM,EAAS,MAAM,gBAAgB,CAAC;AAQ5E,OAAO,EAAE,iCAAiC,EAAE,MAAM,yCAAyC,CAAC;AAG5F;;GAEG;AACH,MAAM,OAAgB,iBAAkB,SAAQ,gBAAgB;IAU9D,YAAqB,OAA0B,EAAW,WAAmB;QAC3E,KAAK,EAAE,CAAC;QADW,YAAO,GAAP,OAAO,CAAmB;QAAW,gBAAW,GAAX,WAAW,CAAQ;QAR7E,sBAAiB,GAAa,EAAE,CAAC;QACzB,YAAO,GAAG,IAAI,GAAG,EAA0B,CAAC;QAE5C,kCAA6B,GAAG,IAAI,GAAG,EAAqD,CAAC;QAOnG,wDAAwD;QACxD,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,OAAO,CAAC,wBAAwB,CAAC,iCAAiC,EAAE,CAAC;QACrG,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE;YAClB,+FAA+F;YAC/F,8FAA8F;YAC9F,iGAAiG;YACjG,8FAA8F;YAC9F,IAAI,IAAI,CAAC,mBAAmB,EAAE;gBAC5B,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,CAAC,CAAC,yCAAyC;aAC9E;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IAC/B,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;IACjC,CAAC;IAED,IAAI,yBAAyB;QAC3B,OAAO,IAAI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QAC3C,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,mEAAmE,CAAC,CAAC;QAC3F,qGAAqG;QACrG,mBAAmB;QACnB,MAAM,+BAA+B,GAAG,IAAI,CAAC,qCAAqC,EAAE,CAAC;QACrF,uFAAuF;QACvF,uFAAuF;QACvF,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,0CAA0C,CAAC,CAAC;QAClE,+BAA+B,CAAC,oBAAoB,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;YAC/D,+BAA+B,CAAC,OAAO,EAAE,CAAC;QAC5C,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,yCAAyC,CAAC,MAAM,CAAC,CAAC;IACzD,CAAC;IAIS,+CAA+C,CAAC,GAAW;QACnE,sFAAsF;QACtF,wGAAwG;QACxG,oCAAoC;QACpC,iBAAiB;QACjB,sEAAsE;QACtE,wDAAwD;QACxD,IAAI,CAAC,oBAAoB,CAAC,GAAG,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3D,CAAC;IAES,qCAAqC;QAC7C,MAAM,OAAO,GAAG,IAAI,CAAC,mBAAmB,CAAC;QACzC,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC;QAChC,OAAO,OAAO,CAAC;IACjB,CAAC;CACF","sourcesContent":["import { NavigationCancel, NavigationEnd, NavigationError, NavigationStart, RouterEvent } from '@angular/router';\nimport { Dsl, GarbageCollector, lang, Logger, Trace } from '@coolon/pectin';\nimport { InteractionContext } from '../../../interaction/interaction-context';\nimport { InteractionServiceRoutingAdapter } from '../../../interaction/services/interaction-service-routing-adapter';\nimport { PlaceComponent } from '../../place-component';\nimport { PlaceDefinition } from '../../place-definition';\nimport { UrlService } from '../../url-service';\nimport { UrlSnapshot } from '../../url-snapshot';\nimport { Visit } from '../../visit';\nimport { PlaceComponentDeactivationHandler } from '../place-component-deactivation-handler';\nimport { NavigationContext } from './navigation-context';\n\n/**\n * Transient states\n */\nexport abstract class NavigationSession extends GarbageCollector {\n\n debugPropertyKeys: string[] = [];\n private _visits = new Map<PlaceDefinition, Visit>();\n\n private componentDeactivationHandlers = new Map<PlaceComponent, PlaceComponentDeactivationHandler>();\n abstract readonly isPopState: boolean;\n\n private _interactionContext: InteractionContext;\n\n constructor(readonly context: NavigationContext, readonly startingUrl: string) {\n super();\n // TODO: can I get away without creating one every time?\n this._interactionContext = this.context.routerInteractionAdapter.createExclusiveInteractionContext();\n this.onDispose(() => {\n // the interaction context can be detached during the back button cancellation state transition\n // as the transition is synchronous and activityCancellation isn't. Otherwise dispose will be\n // called before the context has been cancelled. It might be work having the interaction context\n // automatically cancel if the context is disposed so we don't have worry about detaching etc.\n if (this._interactionContext) {\n this._interactionContext.dispose(); // or do something like cancelAndDispose?\n }\n });\n }\n\n get name(): string {\n return this.constructor.name;\n }\n\n get urlService(): UrlService {\n return this.context.urlService;\n }\n\n get interactionServiceAdapter(): InteractionServiceRoutingAdapter {\n return this.context.routerInteractionAdapter;\n }\n\n storeVisit(visit: Visit) {\n // console.log(`Storing visit for ${visit.placeDefinition.component.name}`, {visit});\n this._visits.set(visit.placeDefinition, visit);\n }\n\n\n getVisitFor(placeDef: PlaceDefinition) {\n const visit = this._visits.get(placeDef);\n // console.log(`Getting visit for ${placeDef.component.name}`, {visit});\n return visit;\n }\n\n get canDeactivateInteractionContext(): InteractionContext {\n return this._interactionContext;\n }\n\n notifyActive() {\n // noop.\n }\n\n onRouterStarted(event: NavigationStart): void {\n // navigation sessions can have many cancel start cycles due to place guard redirects\n this.ignore(event);\n }\n\n // @Trace()\n onUrlChange(url: string) {\n // Normally we just ignore these but they are the only way of detecting if the back button\n // was clicked during a canDeactivate promise.\n // 1. a route is in progress and awaiting a canDeactivateGuard\n // 2. the user the clicks the back button.\n // So to handle that scenario we need to check if we've got a can deactivate interaction in\n // progress and the do the appropriate clean up.\n if (this.canDeactivateInteractionContext && this.canDeactivateInteractionContext.isActive()) {\n this.cancelCanDeactivateInteraction(url);\n }\n }\n\n onPopState(event: NavigationStart): void {\n return this.illegalTransition(event);\n }\n\n onRouterCancelled(event: NavigationCancel): void {\n return this.illegalTransition(event);\n }\n\n onRouterError(event: NavigationError): void {\n return this.illegalTransition(event);\n }\n\n onRouterEnd(event: NavigationEnd): void {\n return this.illegalTransition(event);\n }\n\n getVisits(): Visit[] {\n return Array.from(this._visits.values());\n }\n\n protected illegalTransition<R>(message: string | RouterEvent): R {\n return lang.illegalState(`${message.toString()} not supported by ${this.toString()}`);\n }\n\n protected currentRouterUrl(): string {\n return this.urlService.getCurrentRouterUrl();\n }\n\n resetBrowserLocation(url, options: { replaceCurrent: boolean } = { replaceCurrent: false }) {\n // console.log(`---> resetting browser location to: ${url}`);\n this.urlService.resetBrowserLocation(url, options);\n }\n\n // @Trace()\n protected repairBrowserHistoryAndUrlAfterGuardCancellation(poppedHistoryToReplace: string, activeUrl:string): void {\n // Important: I tried to perform this fix at a later point int he routing cycle but it created all kinds of\n // strangeness.\n Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');\n console.log(`replacing ${this.urlService.getCurrentLocationUrlSnapshot().url} with ${poppedHistoryToReplace}`);\n this.urlService.resetBrowserLocation(poppedHistoryToReplace, { replaceCurrent: true });\n console.log(`pushing ${activeUrl} back onto the history.`);\n this.urlService.resetBrowserLocation(activeUrl, { replaceCurrent: false });\n }\n\n\n ignore(event: RouterEvent, reason?: string): void {\n reason = reason ? ` -> ${reason}` : '';\n Logger.get(this).info(`Ignoring router event${reason}: ${event.constructor.name} -> ${event.url} :: ${this.toString()}`);\n }\n\n toString(): string {\n return `${this.constructor.name}(${this.debugState()})`;\n }\n\n protected debugState(properties?: string[]) {\n return (properties || this.debugPropertyKeys).map(p => {\n return `${p}: ${this[p]}`;\n }).join(', ');\n }\n\n async canDeactivatePlace(component: PlaceComponent, currentUrl: UrlSnapshot, nextUrl: UrlSnapshot): Promise<boolean | UrlSnapshot> {\n // console.log(`---> canDeactivatePlace(${component.placeDefinition.path}, ${currentUrl.url} -> ${nextUrl.url})`);\n // lookup the handler and create it if we've not seen it yet\n let handler = this.componentDeactivationHandlers.get(component);\n if (!handler) {\n const isPrimaryHandler = this.componentDeactivationHandlers.size === 0; // only primary handler cancels the app model interations\n handler = new PlaceComponentDeactivationHandler(component, this, isPrimaryHandler);\n this.componentDeactivationHandlers.set(component, handler);\n }\n return handler.canDeactivate(currentUrl, nextUrl).then(result => {\n // console.log(`<--- canDeactivatePlace(${component.placeDefinition.path}): ${result}`);\n return result;\n }).catch(error => {\n throw error;\n });\n }\n\n cancelCanDeactivateInteraction(newUrl: string): void {\n Logger.get(this).info(`back button pressed during navigation session interaction promise`);\n // detach the interaction from the session so it doesn't get disposed until the activity has finished\n // all it's things.\n const canDeactivateInteractionContext = this.detachCanDeactivateInteractionContext();\n // TODO: I need to make the exclusive interaction context disallow nested activities or\n // that would mess things up entirely. Or, can I do a context.abortAll().then(..)\n Logger.get(this).info('cancelling current navigation activity..');\n canDeactivateInteractionContext.cancelActiveActivity().then(() => {\n canDeactivateInteractionContext.dispose();\n });\n\n this.handleCanDeactivateCancelledEventScenario(newUrl);\n }\n\n abstract handleCanDeactivateCancelledEventScenario(newUrl: string): void\n\n protected reinstateUrlAfterAngularChangedItOnCancellation(url: string) {\n // Angular calls _this.resetUrlToCurrentUrlTree() on cancelling and fucks our history.\n // So this means that the top of the stack is the url we want to go back to, and not the one that was on\n // it before the cancel event fired.\n // So we need to:\n // - replace the just inserted url with the one that used to be there.\n // - push our actual url back onto the top of the stack.\n this.resetBrowserLocation(url, { replaceCurrent: true });\n }\n\n protected detachCanDeactivateInteractionContext(): InteractionContext {\n const context = this._interactionContext;\n this._interactionContext = null;\n return context;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"navigation-session.js","sourceRoot":"","sources":["../../../../../../../../libs/angular-ui-powerups/src/lib/place/navigation/session/navigation-session.ts"],"names":[],"mappings":";AACA,OAAO,EAAO,gBAAgB,EAAE,IA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AAoB,CAAC,GAAG,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3D,CAAC;IAES,qCAAqC;QAC7C,MAAM,OAAO,GAAG,IAAI,CAAC,mBAAmB,CAAC;QACzC,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC;QAChC,OAAO,OAAO,CAAC;IACjB,CAAC;CACF","sourcesContent":["import { NavigationCancel, NavigationEnd, NavigationError, NavigationStart, RouterEvent } from '@angular/router';\nimport { Dsl, GarbageCollector, lang, Logger, Trace } from '@coolon/pectin';\nimport { InteractionContext } from '../../../interaction/interaction-context';\nimport { InteractionServiceRoutingAdapter } from '../../../interaction/services/interaction-service-routing-adapter';\nimport { PlaceComponent } from '../../place-component';\nimport { PlaceDefinition } from '../../place-definition';\nimport { UrlService } from '../../url-service';\nimport { UrlSnapshot } from '../../url-snapshot';\nimport { Visit } from '../../visit';\nimport { PlaceComponentDeactivationHandler } from '../place-component-deactivation-handler';\nimport { NavigationContext } from './navigation-context';\n\n/**\n * Transient states\n */\nexport abstract class NavigationSession extends GarbageCollector {\n\n debugPropertyKeys: string[] = [];\n private _visits = new Map<PlaceDefinition, Visit>();\n\n private componentDeactivationHandlers = new Map<PlaceComponent, PlaceComponentDeactivationHandler>();\n abstract readonly isPopState: boolean;\n\n private _interactionContext: InteractionContext;\n\n constructor(readonly context: NavigationContext, readonly startingUrl: string) {\n super();\n // TODO: can I get away without creating one every time?\n this._interactionContext = this.context.routerInteractionAdapter.createExclusiveInteractionContext();\n this.onDispose(() => {\n // the interaction context can be detached during the back button cancellation state transition\n // as the transition is synchronous and activityCancellation isn't. Otherwise dispose will be\n // called before the context has been cancelled. It might be work having the interaction context\n // automatically cancel if the context is disposed so we don't have worry about detaching etc.\n if (this._interactionContext) {\n this._interactionContext.dispose(); // or do something like cancelAndDispose?\n }\n });\n }\n\n get name(): string {\n return this.constructor.name;\n }\n\n get urlService(): UrlService {\n return this.context.urlService;\n }\n\n get interactionServiceAdapter(): InteractionServiceRoutingAdapter {\n return this.context.routerInteractionAdapter;\n }\n\n storeVisit(visit: Visit) {\n // console.log(`Storing visit for ${visit.placeDefinition.component.name}`, {visit});\n this._visits.set(visit.placeDefinition, visit);\n }\n\n\n getVisitFor(placeDef: PlaceDefinition) {\n const visit = this._visits.get(placeDef);\n // console.log(`Getting visit for ${placeDef.component.name}`, {visit});\n return visit;\n }\n\n get canDeactivateInteractionContext(): InteractionContext {\n return this._interactionContext;\n }\n\n notifyActive() {\n // noop.\n }\n\n onRouterStarted(event: NavigationStart): void {\n // navigation sessions can have many cancel start cycles due to place guard redirects\n this.ignore(event);\n }\n\n // @Trace()\n onUrlChange(url: string) {\n // Normally we just ignore these but they are the only way of detecting if the back button\n // was clicked during a canDeactivate promise.\n // 1. a route is in progress and awaiting a canDeactivateGuard\n // 2. the user the clicks the back button.\n // So to handle that scenario we need to check if we've got a can deactivate interaction in\n // progress and the do the appropriate clean up.\n if (this.canDeactivateInteractionContext && this.canDeactivateInteractionContext.isActive()) {\n this.cancelCanDeactivateInteraction(url);\n }\n }\n\n onPopState(event: NavigationStart): void {\n return this.illegalTransition(event);\n }\n\n onRouterCancelled(event: NavigationCancel): void {\n return this.illegalTransition(event);\n }\n\n onRouterError(event: NavigationError): void {\n return this.illegalTransition(event);\n }\n\n onRouterEnd(event: NavigationEnd): void {\n return this.illegalTransition(event);\n }\n\n getVisits(): Visit[] {\n return Array.from(this._visits.values());\n }\n\n protected illegalTransition<R>(message: string | RouterEvent): R {\n return lang.illegalState(`${message.toString()} not supported by ${this.toString()}`);\n }\n\n protected currentRouterUrl(): string {\n return this.urlService.getCurrentRouterUrl();\n }\n\n resetBrowserLocation(url, options: { replaceCurrent: boolean } = { replaceCurrent: false }) {\n // console.log(`---> resetting browser location to: ${url}`);\n this.urlService.resetBrowserLocation(url, options);\n }\n\n // @Trace()\n protected repairBrowserHistoryAndUrlAfterGuardCancellation(poppedHistoryToReplace: string, activeUrl:string): void {\n // Important: I tried to perform this fix at a later point int he routing cycle but it created all kinds of\n // strangeness.\n Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');\n // console.log(`replacing ${this.urlService.getCurrentLocationUrlSnapshot().url} with ${poppedHistoryToReplace}`);\n this.urlService.resetBrowserLocation(poppedHistoryToReplace, { replaceCurrent: true });\n // console.log(`pushing ${activeUrl} back onto the history.`);\n this.urlService.resetBrowserLocation(activeUrl, { replaceCurrent: false });\n }\n\n\n ignore(event: RouterEvent, reason?: string): void {\n reason = reason ? ` -> ${reason}` : '';\n // Logger.get(this).info(`Ignoring router event${reason}: ${event.constructor.name} -> ${event.url} :: ${this.toString()}`);\n }\n\n toString(): string {\n return `${this.constructor.name}(${this.debugState()})`;\n }\n\n protected debugState(properties?: string[]) {\n return (properties || this.debugPropertyKeys).map(p => {\n return `${p}: ${this[p]}`;\n }).join(', ');\n }\n\n async canDeactivatePlace(component: PlaceComponent, currentUrl: UrlSnapshot, nextUrl: UrlSnapshot): Promise<boolean | UrlSnapshot> {\n // console.log(`---> canDeactivatePlace(${component.placeDefinition.path}, ${currentUrl.url} -> ${nextUrl.url})`);\n // lookup the handler and create it if we've not seen it yet\n let handler = this.componentDeactivationHandlers.get(component);\n if (!handler) {\n const isPrimaryHandler = this.componentDeactivationHandlers.size === 0; // only primary handler cancels the app model interations\n handler = new PlaceComponentDeactivationHandler(component, this, isPrimaryHandler);\n this.componentDeactivationHandlers.set(component, handler);\n }\n return handler.canDeactivate(currentUrl, nextUrl).then(result => {\n // console.log(`<--- canDeactivatePlace(${component.placeDefinition.path}): ${result}`);\n return result;\n }).catch(error => {\n throw error;\n });\n }\n\n cancelCanDeactivateInteraction(newUrl: string): void {\n Logger.get(this).info(`back button pressed during navigation session interaction promise`);\n // detach the interaction from the session so it doesn't get disposed until the activity has finished\n // all it's things.\n const canDeactivateInteractionContext = this.detachCanDeactivateInteractionContext();\n // TODO: I need to make the exclusive interaction context disallow nested activities or\n // that would mess things up entirely. Or, can I do a context.abortAll().then(..)\n Logger.get(this).info('cancelling current navigation activity..');\n canDeactivateInteractionContext.cancelActiveActivity().then(() => {\n canDeactivateInteractionContext.dispose();\n });\n\n this.handleCanDeactivateCancelledEventScenario(newUrl);\n }\n\n abstract handleCanDeactivateCancelledEventScenario(newUrl: string): void\n\n protected reinstateUrlAfterAngularChangedItOnCancellation(url: string) {\n // Angular calls _this.resetUrlToCurrentUrlTree() on cancelling and fucks our history.\n // So this means that the top of the stack is the url we want to go back to, and not the one that was on\n // it before the cancel event fired.\n // So we need to:\n // - replace the just inserted url with the one that used to be there.\n // - push our actual url back onto the top of the stack.\n this.resetBrowserLocation(url, { replaceCurrent: true });\n }\n\n protected detachCanDeactivateInteractionContext(): InteractionContext {\n const context = this._interactionContext;\n this._interactionContext = null;\n return context;\n }\n}\n"]}
|
|
@@ -1,28 +1,15 @@
|
|
|
1
|
-
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import { Trace } from '@coolon/pectin';
|
|
3
|
-
import { PlaceDefinition } from './place-definition';
|
|
4
1
|
export var PlaceAccessGuard;
|
|
5
2
|
(function (PlaceAccessGuard) {
|
|
6
3
|
class NoAuth {
|
|
4
|
+
// @Trace()
|
|
7
5
|
isAuthenticated() {
|
|
8
6
|
return true;
|
|
9
7
|
}
|
|
8
|
+
// @Trace()
|
|
10
9
|
isAuthorised(placeDefinition) {
|
|
11
10
|
return true;
|
|
12
11
|
}
|
|
13
12
|
}
|
|
14
|
-
__decorate([
|
|
15
|
-
Trace(),
|
|
16
|
-
__metadata("design:type", Function),
|
|
17
|
-
__metadata("design:paramtypes", []),
|
|
18
|
-
__metadata("design:returntype", Object)
|
|
19
|
-
], NoAuth.prototype, "isAuthenticated", null);
|
|
20
|
-
__decorate([
|
|
21
|
-
Trace(),
|
|
22
|
-
__metadata("design:type", Function),
|
|
23
|
-
__metadata("design:paramtypes", [PlaceDefinition]),
|
|
24
|
-
__metadata("design:returntype", Boolean)
|
|
25
|
-
], NoAuth.prototype, "isAuthorised", null);
|
|
26
13
|
PlaceAccessGuard.NoAuth = NoAuth;
|
|
27
14
|
})(PlaceAccessGuard || (PlaceAccessGuard = {}));
|
|
28
15
|
//# sourceMappingURL=place-access-guard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"place-access-guard.js","sourceRoot":"","sources":["../../../../../../libs/angular-ui-powerups/src/lib/place/place-access-guard.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"place-access-guard.js","sourceRoot":"","sources":["../../../../../../libs/angular-ui-powerups/src/lib/place/place-access-guard.ts"],"names":[],"mappings":"AAQA,MAAM,KAAW,gBAAgB,CAYhC;AAZD,WAAiB,gBAAgB;IAC/B,MAAa,MAAM;QACjB,WAAW;QACX,eAAe;YACb,OAAO,IAAI,CAAC;QACd,CAAC;QACD,WAAW;QACX,YAAY,CAAC,eAAgC;YAC3C,OAAO,IAAI,CAAC;QACd,CAAC;KAEF;IAVY,uBAAM,SAUlB,CAAA;AACH,CAAC,EAZgB,gBAAgB,KAAhB,gBAAgB,QAYhC","sourcesContent":["import { Trace } from '@coolon/pectin';\nimport { PlaceDefinition } from './place-definition';\n\nexport interface PlaceAccessGuard {\n isAuthenticated(): boolean | Promise<boolean>;\n isAuthorised(placeDefinition: PlaceDefinition): boolean;\n}\n\nexport namespace PlaceAccessGuard {\n export class NoAuth implements PlaceAccessGuard {\n // @Trace()\n isAuthenticated(): boolean | Promise<boolean> {\n return true;\n }\n // @Trace()\n isAuthorised(placeDefinition: PlaceDefinition): boolean {\n return true;\n }\n\n }\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { __awaiter
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
2
|
import { Location } from '@angular/common';
|
|
3
3
|
import { Injectable } from '@angular/core';
|
|
4
4
|
import { NavigationCancel, NavigationEnd, NavigationError, NavigationStart, Router } from '@angular/router';
|
|
5
|
-
import { assert, Binding, DebugContext, DelegatingValueModel, Dsl, GarbageCollector, lang,
|
|
5
|
+
import { assert, Binding, DebugContext, DelegatingValueModel, Dsl, GarbageCollector, lang, MutableListModel, MutableValueModel } from '@coolon/pectin';
|
|
6
6
|
import { InteractionService } from '../interaction/services/interaction.service';
|
|
7
7
|
import { NavigatingDuringInteraction } from './navigation/session/interactions/navigating-during-interaction';
|
|
8
8
|
import { PopStateDuringInteractionNavigation } from './navigation/session/interactions/pop-state-during-interaction-navigation';
|
|
@@ -96,6 +96,7 @@ export class PlaceRouter extends GarbageCollector {
|
|
|
96
96
|
get accessGuard() {
|
|
97
97
|
return this._accessGuard.readonly;
|
|
98
98
|
}
|
|
99
|
+
// @Trace()
|
|
99
100
|
configureAuth(accessGrant, redirections) {
|
|
100
101
|
// We need a shitty mutable model until setDelegate is clever enough to work with readonly models.
|
|
101
102
|
const hackyMutableModel = new MutableValueModel();
|
|
@@ -240,7 +241,7 @@ export class PlaceRouter extends GarbageCollector {
|
|
|
240
241
|
this.placeHistory.notifyNavigationStarted();
|
|
241
242
|
}
|
|
242
243
|
assert.isTruthy(next !== previous);
|
|
243
|
-
Logger.get(this).info(`### Router State Transition: ${previous ? previous.toString() : 'null'} -> ${next.toString()}`);
|
|
244
|
+
// Logger.get(this).info(`### Router State Transition: ${previous ? previous.toString() : 'null'} -> ${next.toString()}`);
|
|
244
245
|
this.navigationSessionModel.value = next;
|
|
245
246
|
if (!!previous) {
|
|
246
247
|
previous.dispose();
|
|
@@ -260,7 +261,7 @@ export class PlaceRouter extends GarbageCollector {
|
|
|
260
261
|
const session = this.currentSession;
|
|
261
262
|
session.dispose();
|
|
262
263
|
this.navigationSessionModel.value = null;
|
|
263
|
-
console.log(`### Router Session Finished (was ${session.toString()})`);
|
|
264
|
+
// console.log(`### Router Session Finished (was ${session.toString()})`);
|
|
264
265
|
this.sessionFinishedJobs.forEach(job => job());
|
|
265
266
|
this.sessionFinishedJobs = [];
|
|
266
267
|
}
|
|
@@ -315,10 +316,4 @@ PlaceRouter.ctorParameters = () => [
|
|
|
315
316
|
{ type: UrlService },
|
|
316
317
|
{ type: PlaceHistory }
|
|
317
318
|
];
|
|
318
|
-
__decorate([
|
|
319
|
-
Trace(),
|
|
320
|
-
__metadata("design:type", Function),
|
|
321
|
-
__metadata("design:paramtypes", [ValueModel, Object]),
|
|
322
|
-
__metadata("design:returntype", void 0)
|
|
323
|
-
], PlaceRouter.prototype, "configureAuth", null);
|
|
324
319
|
//# sourceMappingURL=place-router.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"place-router.js","sourceRoot":"","sources":["../../../../../../libs/angular-ui-powerups/src/lib/place/place-router.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAGL,gBAAgB,EAChB,aAAa,EACb,eAAe,EAEf,eAAe,EACf,MAAM,EAEP,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,MAAM,EACN,OAAO,EACP,YAAY,EACZ,oBAAoB,EACpB,GAAG,EACH,gBAAgB,EAChB,IAAI,EAEJ,MAAM,EAEN,gBAAgB,EAChB,iBAAiB,EAAE,KAAK,EACxB,UAAU,EAEX,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AACjF,OAAO,EAAE,2BAA2B,EAAE,MAAM,iEAAiE,CAAC;AAC9G,OAAO,EAAE,mCAAmC,EAAE,MAAM,2EAA2E,CAAC;AAChI,OAAO,EAAE,yCAAyC,EAAE,MAAM,kFAAkF,CAAC;AAC7I,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAE5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAA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Y,CAAC,WAAW,CAAC,CAAC;gBACjC,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;SACJ;aAAM;YACL,OAAO,IAAI,OAAO,CAAU,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBAC/C,0EAA0E;gBAC1E,IAAI,CAAC,8BAA8B,CAAC,OAAO,CAAC,CAAC;gBAC7C,MAAM,OAAO,GAAG,IAAI,yCAAyC,CAAC,IAAI,CAAC,iBAAiB,EAAE,IAAI,CAAC,UAAU,CAAC,mBAAmB,EAAE,EAAE,KAAK,CAAC,CAAC;gBACpI,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;YAC7B,CAAC,CAAC,CAAC,CAAC;SAEL;IACH,CAAC;IAGO,qBAAqB,CAAC,KAAY;QACxC,MAAM,GAAG,GAAG,KAAK,CAAC,eAAe,CAAC;QAClC,OAAO,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC;YACzB,CAAC,GAAG,CAAC,mBAAmB,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,2BAA2B,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAC1E,CAAC,GAAG,CAAC,2BAA2B,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7C,CAAC;;;;YAxUF,UAAU,SAAC;gBACV,UAAU,EAAE,MAAM;aACnB;;;YArCC,MAAM;YAVC,QAAQ;YA8BR,kBAAkB;YAWlB,UAAU;YADV,YAAY;;AA+GnB;IADC,KAAK,EAAE;;qCACmB,UAAU;;gDAYpC","sourcesContent":["import { Location } from '@angular/common';\nimport { Injectable } from '@angular/core';\nimport {\n ActivatedRoute,\n ActivatedRouteSnapshot,\n NavigationCancel,\n NavigationEnd,\n NavigationError,\n NavigationExtras,\n NavigationStart,\n Router,\n RouterStateSnapshot\n} from '@angular/router';\nimport {\n assert,\n Binding,\n DebugContext,\n DelegatingValueModel,\n Dsl,\n GarbageCollector,\n lang,\n ListModel,\n Logger,\n MapModelChain,\n MutableListModel,\n MutableValueModel, Trace,\n ValueModel,\n ValueModelChain\n} from '@coolon/pectin';\nimport { InteractionServiceRoutingAdapter } from '../interaction/services/interaction-service-routing-adapter';\nimport { InteractionService } from '../interaction/services/interaction.service';\nimport { NavigatingDuringInteraction } from './navigation/session/interactions/navigating-during-interaction';\nimport { PopStateDuringInteractionNavigation } from './navigation/session/interactions/pop-state-during-interaction-navigation';\nimport { SynchroniseInteractionContextIdsWithRoute } from './navigation/session/interactions/synchronise-interaction-context-ids-with-route';\nimport { Navigating } from './navigation/session/navigating';\nimport { NavigationContext } from './navigation/session/navigation-context';\nimport { NavigationSession } from './navigation/session/navigation-session';\nimport { PopStateNavigation } from './navigation/session/pop-state-navigation';\nimport { PlaceAccessGuard } from './place-access-guard';\nimport { PlaceDefinition } from './place-definition';\nimport { PlaceHistory } from './place-history';\nimport { UrlService } from './url-service';\nimport { UrlSnapshot } from './url-snapshot';\nimport { Visit } from './visit';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class PlaceRouter extends GarbageCollector {\n\n readonly navigationSessionModel = new MutableValueModel<NavigationSession>();\n readonly navigationInProgress: ValueModelChain<boolean>;\n readonly navigationSessionName: ValueModelChain<string>; // used by tests\n\n private readonly navigationContext: NavigationContext.Impl;\n\n private readonly _activeVisits = new MutableListModel<Visit>();\n readonly activeVisitsByPlaceDefinition: MapModelChain<PlaceDefinition, Visit>;\n private routerInteractionAdapter: InteractionServiceRoutingAdapter;\n private sessionFinishedJobs: (() => void)[] = [];\n\n /**\n * An observable model containing the authoriser function. This allows places to react to changes\n * in permissions when any underlying auth logic changes, e.g. a role being removed from a user.\n */\n private _accessGuard = new DelegatingValueModel<PlaceAccessGuard>().withDefault(new PlaceAccessGuard.NoAuth());\n private redirections: PlaceRouter.Redirections;\n\n constructor(private readonly angularRouter: Router,\n private readonly angularLocation: Location,\n private readonly interactionService: InteractionService,\n private readonly urlService: UrlService,\n private readonly placeHistory: PlaceHistory) {\n super();\n\n if (window['Cypress']) {\n window['aup.PlaceRouter'] = this;\n }\n\n this.routerInteractionAdapter = interactionService.registerPlaceRouter(this);\n\n // TODO: Make this an interface and use 'this' instead.\n this.navigationContext = new NavigationContext.Impl(\n this.urlService,\n this.routerInteractionAdapter,\n (urlSnapshot: UrlSnapshot, options: { replaceUrl: boolean }) => {\n return this.navigateByUrl(urlSnapshot, options);\n },\n state => {\n this.transitionTo(state);\n },\n visits => {\n this.routingSessionFinished(visits);\n });\n\n const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);\n this.navigationInProgress = chain(this.navigationSessionModel).isNotNil();\n\n const idleStateName = chain(this.interactionService.active).map(active => active ? 'IdleDuringInteraction' : 'Idle');\n this.navigationSessionName = chain(this.navigationSessionModel)\n .pluck('name')\n .otherwise(idleStateName);\n\n DebugContext.tag(this._activeVisits, 'PlaceRouter.activeVisits');\n this.activeVisitsByPlaceDefinition = chain(this._activeVisits).indexBy('placeDefinition');\n\n // TODO: make setup the callbacks in during module initiation to make this testable.\n angularRouter.events.subscribe(event => {\n // Routing event sequence\n // ======================\n // NavigationStart -> .... -> NavigationCancel --> redirect, go around again in the same session\n // NavigationStart -> .... -> NavigationEnd --> navigation complete, end session.\n // NavigationStart -> .... -> NavigationError --> navigation aborted, end session.\n // =======================\n if (event instanceof NavigationStart) {\n // console.log(`---> NavigationStart[${event.id}]: ${event.url} (${event.navigationTrigger})`);\n if (event.navigationTrigger === 'popstate') {\n this.onPopState(event);\n } else {\n this.onRouterStarted(event);\n }\n // console.log(`<--- NavigationStart[${event.id}]: ${event.url} (${event.navigationTrigger})`);\n }\n if (event instanceof NavigationEnd) {\n // console.log(`---> NavigationEnd[${event.id}]: ${event.url}`);\n this.onRouterEnd(event);\n // console.log(`<--- NavigationEnd[${event.id}]: ${event.url}`);\n }\n if (event instanceof NavigationError) {\n // console.log(`---> NavigationError[${event.id}]: ${event.url}`);\n this.onRouterError(event);\n // console.log(`<--- NavigationError[${event.id}]: ${event.url}`);\n }\n if (event instanceof NavigationCancel) {\n // console.log(`---> NavigationCancel[${event.id}]: ${event.url}`);\n this.onRouterCancelled(event);\n // console.log(`<--- NavigationCancel[${event.id}]: ${event.url}`);\n }\n });\n\n // The router needs to know about url changes and in some cases they are the only way the router can know if\n // the back button was clicked.\n angularLocation.onUrlChange(url => this.onUrlChanged(url));\n\n }\n\n get accessGuard(): ValueModel<PlaceAccessGuard> {\n return this._accessGuard.readonly;\n }\n\n @Trace()\n configureAuth(accessGrant: ValueModel<PlaceAccessGuard>, redirections: PlaceRouter.Redirections) {\n // We need a shitty mutable model until setDelegate is clever enough to work with readonly models.\n const hackyMutableModel = new MutableValueModel<PlaceAccessGuard>();\n const binding = new Binding(hackyMutableModel, accessGrant, {\n toRight(leftValue: PlaceAccessGuard) {\n return lang.illegalState('hackyMutableModel is read only');\n },\n toLeft: (rightValue: PlaceAccessGuard) => rightValue\n });\n binding.writeLeft();\n this._accessGuard.setDelegate(hackyMutableModel);\n this.redirections = redirections;\n }\n\n getAuthenticationFailureRedirect(activatedRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Visit {\n return this.redirections.onAuthenticationFailure(activatedRoute, state);\n }\n\n getAuthorisationFailureRedirect(activatedRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Visit {\n return this.redirections.onAuthorisationFailure(activatedRoute, state);\n }\n\n get navigationSession() {\n return this.navigationSessionModel.value;\n }\n\n get currentSession() {\n return this.navigationSessionModel.value;\n }\n\n isNavigating(): boolean {\n return this.navigationInProgress.value;\n }\n\n // @Trace()\n onPopState(event: NavigationStart) {\n assert.isTruthy(event.navigationTrigger === 'popstate');\n if (this.currentSession) {\n this.currentSession.onPopState(event);\n } else {\n const poppedHistoryUrl = event.url;\n const currentRouterUrl = this.urlService.getCurrentRouterUrl();\n const session = this.interactionService.isActive() ?\n new PopStateDuringInteractionNavigation(this.navigationContext, currentRouterUrl, poppedHistoryUrl) :\n new PopStateNavigation(this.navigationContext, currentRouterUrl, poppedHistoryUrl);\n this.transitionTo(session);\n }\n }\n\n // @Trace()\n onRouterStarted(event: NavigationStart) {\n assert.isFalsey(event.navigationTrigger === 'popstate');\n const inInteraction = this.interactionService.isActive();\n if (this.currentSession) {\n this.currentSession.onRouterStarted(event);\n } else {\n this.transitionTo(this.createNavigationSession(this.urlService.getCurrentRouterUrl()));\n }\n }\n\n // @Trace()\n onUrlChanged(newUrl: string) {\n // the back button can trigger a url change without a navigation session in progress so we\n // console.log(`---> Url Changed ${newUrl}`);\n if (this.currentSession) {\n this.currentSession.onUrlChange(newUrl);\n } else {\n console.log('FYI: url changed without a navigation session in progress');\n }\n // console.log(`<--- Url Changed`);\n }\n\n // @Trace()\n onRouterCancelled(event: NavigationCancel) {\n this.currentSession.onRouterCancelled(event);\n }\n\n // @Trace()\n onRouterError(event: NavigationError) {\n this.currentSession.onRouterError(event);\n }\n\n // @Trace()\n onRouterEnd(event: NavigationEnd) {\n this.currentSession.onRouterEnd(event);\n }\n\n navigate(visit: Visit, options?: { relativeTo: ActivatedRoute }) {\n return this.doNavigation(visit, async router => {\n const commands = [\n visit.placeDefinition.path,\n ...this.createRouteParameters(visit)\n ];\n await this.angularRouter.navigate(commands, {\n relativeTo: options ? options.relativeTo : null\n });\n });\n }\n\n // @Trace()\n async doNavigation(visit: Visit, runNavigationCommands: (router: Router) => any) {\n if (this.navigationInProgress.value) {\n lang.illegalState('Navigation already in progress');\n }\n const navigation = this.createNavigationSession(this.urlService.getCurrentRouterUrl());\n navigation.storeVisit(visit);\n this.transitionTo(navigation);\n try {\n await runNavigationCommands(this.angularRouter);\n } finally {\n // Check if the router has finished (in the case where no router change required) and we're still in a\n // transient state and finish of the transition.\n if (!this.angularRouter.getCurrentNavigation() && this.currentSession) {\n this.currentSession.onRouterEnd(new NavigationEnd(-1, '', ''));\n }\n }\n }\n\n navigateByUrl(urlSnapshot: UrlSnapshot, navigationExtras?: NavigationExtras) {\n // console.log(`### navigationByUrl -> ${urlSnapshot.urlTree.toString()}`);\n return this.angularRouter.navigateByUrl(urlSnapshot.urlTree, navigationExtras);\n }\n\n get activeVisits(): ListModel<Visit> {\n return this._activeVisits.readonly;\n }\n\n // @Trace()\n async pushVisitChangesToRoute(previous: Visit, next: Visit): Promise<void> {\n this.placeHistory.updateVisit(next);\n\n // FIXME: no route id -> route id duplicates route parameters\n if (next.hasRoutingChangedFrom(previous)) {\n return this.doNavigation(next, router => {\n const urlSnapshot = this.urlService.parseUrl(this.angularRouter.routerState.snapshot.url).updateVisitSegments(next);\n // console.log('### Push Changes to route Redirect', { commands: urlSnapshot.url });\n return this.navigateByUrl(urlSnapshot);\n });\n }\n }\n\n\n private createNavigationSession(currentRouterUrl: string): NavigationSession {\n const inInteraction = this.interactionService.isActive();\n return inInteraction ?\n new NavigatingDuringInteraction(this.navigationContext, currentRouterUrl) :\n new Navigating(this.navigationContext, currentRouterUrl);\n }\n\n // @Trace()\n protected transitionTo(next: NavigationSession) {\n const previous = this.navigationSessionModel.value;\n if (!previous) {\n this.placeHistory.notifyNavigationStarted();\n }\n assert.isTruthy(next !== previous);\n Logger.get(this).info(`### Router State Transition: ${previous ? previous.toString() : 'null'} -> ${next.toString()}`);\n this.navigationSessionModel.value = next;\n if (!!previous) {\n previous.dispose();\n }\n next.notifyActive();\n }\n\n // @Trace()\n private routingSessionFinished(visits: Visit[]) {\n if (visits && visits.length > 0) {\n assert.isTruthy(this.navigationInProgress.value);\n this.placeHistory.notifyNavigationFinished(visits);\n // We update the active visits before we finish the session so the\n // place outlets can ignore the incoming changes until things are\n // settled. TODO: can we removed the event'ness here and just do a push?\n this._activeVisits.value = visits;\n }\n const session = this.currentSession;\n session.dispose();\n this.navigationSessionModel.value = null;\n console.log(`### Router Session Finished (was ${session.toString()})`);\n this.sessionFinishedJobs.forEach(job => job());\n this.sessionFinishedJobs = [];\n }\n\n private runAfterRoutingSessionFinishes(func: () => void) {\n assert.isTruthy(this.navigationInProgress);\n this.sessionFinishedJobs.push(func);\n }\n\n\n /**\n * Sync's the current interaction state with the URL. We need to push something in the URL in order\n * to be able to capture the back button on the first page. If we don't then the back click will exit\n * the app directly and we don't get to ask.\n */\n // @Trace()\n syncInteractionContextIdsWithRouter(): Promise<unknown> {\n if (this.navigationSession) {\n // console.log(`Navigation active -> ${this.navigationSession.toString()}, sync delayed until finished.`);\n const session = this.navigationSession;\n return new Promise((resolve, reject) => {\n this.runAfterRoutingSessionFinishes(() => {\n this.runAfterRoutingSessionFinishes(resolve);\n const syncSession = new SynchroniseInteractionContextIdsWithRoute(this.navigationContext, this.urlService.getCurrentRouterUrl(), false);\n this.transitionTo(syncSession);\n });\n });\n } else {\n return new Promise<unknown>(((resolve, reject) => {\n // console.log(`No navigation in progress, starting synchronisation job`);\n this.runAfterRoutingSessionFinishes(resolve);\n const session = new SynchroniseInteractionContextIdsWithRoute(this.navigationContext, this.urlService.getCurrentRouterUrl(), false);\n this.transitionTo(session);\n }));\n\n }\n }\n\n\n private createRouteParameters(visit: Visit) {\n const def = visit.placeDefinition;\n return visit.hasRouteId() ?\n [def.getFormattedRouteId(visit), def.getFormattedRouteParameters(visit)] :\n [def.getFormattedRouteParameters(visit)];\n }\n\n}\n\nexport namespace PlaceRouter {\n\n export interface Redirections {\n onAuthenticationFailure(activatedRoute?: ActivatedRouteSnapshot, state?: RouterStateSnapshot): Visit;\n\n onAuthorisationFailure(activatedRoute?: ActivatedRouteSnapshot, state?: RouterStateSnapshot): Visit;\n }\n\n}\n"]}
|
|
1
|
+
{"version":3,"file":"place-router.js","sourceRoot":"","sources":["../../../../../../libs/angular-ui-powerups/src/lib/place/place-router.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAGL,gBAAgB,EAChB,aAAa,EACb,eAAe,EAEf,eAAe,EACf,MAAM,EAEP,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,MAAM,EACN,OAAO,EACP,YAAY,EACZ,oBAAoB,EACpB,GAAG,E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from '@angular/common';\nimport { Injectable } from '@angular/core';\nimport {\n ActivatedRoute,\n ActivatedRouteSnapshot,\n NavigationCancel,\n NavigationEnd,\n NavigationError,\n NavigationExtras,\n NavigationStart,\n Router,\n RouterStateSnapshot\n} from '@angular/router';\nimport {\n assert,\n Binding,\n DebugContext,\n DelegatingValueModel,\n Dsl,\n GarbageCollector,\n lang,\n ListModel,\n Logger,\n MapModelChain,\n MutableListModel,\n MutableValueModel, Trace,\n ValueModel,\n ValueModelChain\n} from '@coolon/pectin';\nimport { InteractionServiceRoutingAdapter } from '../interaction/services/interaction-service-routing-adapter';\nimport { InteractionService } from '../interaction/services/interaction.service';\nimport { NavigatingDuringInteraction } from './navigation/session/interactions/navigating-during-interaction';\nimport { PopStateDuringInteractionNavigation } from './navigation/session/interactions/pop-state-during-interaction-navigation';\nimport { SynchroniseInteractionContextIdsWithRoute } from './navigation/session/interactions/synchronise-interaction-context-ids-with-route';\nimport { Navigating } from './navigation/session/navigating';\nimport { NavigationContext } from './navigation/session/navigation-context';\nimport { NavigationSession } from './navigation/session/navigation-session';\nimport { PopStateNavigation } from './navigation/session/pop-state-navigation';\nimport { PlaceAccessGuard } from './place-access-guard';\nimport { PlaceDefinition } from './place-definition';\nimport { PlaceHistory } from './place-history';\nimport { UrlService } from './url-service';\nimport { UrlSnapshot } from './url-snapshot';\nimport { Visit } from './visit';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class PlaceRouter extends GarbageCollector {\n\n readonly navigationSessionModel = new MutableValueModel<NavigationSession>();\n readonly navigationInProgress: ValueModelChain<boolean>;\n readonly navigationSessionName: ValueModelChain<string>; // used by tests\n\n private readonly navigationContext: NavigationContext.Impl;\n\n private readonly _activeVisits = new MutableListModel<Visit>();\n readonly activeVisitsByPlaceDefinition: MapModelChain<PlaceDefinition, Visit>;\n private routerInteractionAdapter: InteractionServiceRoutingAdapter;\n private sessionFinishedJobs: (() => void)[] = [];\n\n /**\n * An observable model containing the authoriser function. This allows places to react to changes\n * in permissions when any underlying auth logic changes, e.g. a role being removed from a user.\n */\n private _accessGuard = new DelegatingValueModel<PlaceAccessGuard>().withDefault(new PlaceAccessGuard.NoAuth());\n private redirections: PlaceRouter.Redirections;\n\n constructor(private readonly angularRouter: Router,\n private readonly angularLocation: Location,\n private readonly interactionService: InteractionService,\n private readonly urlService: UrlService,\n private readonly placeHistory: PlaceHistory) {\n super();\n\n if (window['Cypress']) {\n window['aup.PlaceRouter'] = this;\n }\n\n this.routerInteractionAdapter = interactionService.registerPlaceRouter(this);\n\n // TODO: Make this an interface and use 'this' instead.\n this.navigationContext = new NavigationContext.Impl(\n this.urlService,\n this.routerInteractionAdapter,\n (urlSnapshot: UrlSnapshot, options: { replaceUrl: boolean }) => {\n return this.navigateByUrl(urlSnapshot, options);\n },\n state => {\n this.transitionTo(state);\n },\n visits => {\n this.routingSessionFinished(visits);\n });\n\n const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);\n this.navigationInProgress = chain(this.navigationSessionModel).isNotNil();\n\n const idleStateName = chain(this.interactionService.active).map(active => active ? 'IdleDuringInteraction' : 'Idle');\n this.navigationSessionName = chain(this.navigationSessionModel)\n .pluck('name')\n .otherwise(idleStateName);\n\n DebugContext.tag(this._activeVisits, 'PlaceRouter.activeVisits');\n this.activeVisitsByPlaceDefinition = chain(this._activeVisits).indexBy('placeDefinition');\n\n // TODO: make setup the callbacks in during module initiation to make this testable.\n angularRouter.events.subscribe(event => {\n // Routing event sequence\n // ======================\n // NavigationStart -> .... -> NavigationCancel --> redirect, go around again in the same session\n // NavigationStart -> .... -> NavigationEnd --> navigation complete, end session.\n // NavigationStart -> .... -> NavigationError --> navigation aborted, end session.\n // =======================\n if (event instanceof NavigationStart) {\n // console.log(`---> NavigationStart[${event.id}]: ${event.url} (${event.navigationTrigger})`);\n if (event.navigationTrigger === 'popstate') {\n this.onPopState(event);\n } else {\n this.onRouterStarted(event);\n }\n // console.log(`<--- NavigationStart[${event.id}]: ${event.url} (${event.navigationTrigger})`);\n }\n if (event instanceof NavigationEnd) {\n // console.log(`---> NavigationEnd[${event.id}]: ${event.url}`);\n this.onRouterEnd(event);\n // console.log(`<--- NavigationEnd[${event.id}]: ${event.url}`);\n }\n if (event instanceof NavigationError) {\n // console.log(`---> NavigationError[${event.id}]: ${event.url}`);\n this.onRouterError(event);\n // console.log(`<--- NavigationError[${event.id}]: ${event.url}`);\n }\n if (event instanceof NavigationCancel) {\n // console.log(`---> NavigationCancel[${event.id}]: ${event.url}`);\n this.onRouterCancelled(event);\n // console.log(`<--- NavigationCancel[${event.id}]: ${event.url}`);\n }\n });\n\n // The router needs to know about url changes and in some cases they are the only way the router can know if\n // the back button was clicked.\n angularLocation.onUrlChange(url => this.onUrlChanged(url));\n\n }\n\n get accessGuard(): ValueModel<PlaceAccessGuard> {\n return this._accessGuard.readonly;\n }\n\n // @Trace()\n configureAuth(accessGrant: ValueModel<PlaceAccessGuard>, redirections: PlaceRouter.Redirections) {\n // We need a shitty mutable model until setDelegate is clever enough to work with readonly models.\n const hackyMutableModel = new MutableValueModel<PlaceAccessGuard>();\n const binding = new Binding(hackyMutableModel, accessGrant, {\n toRight(leftValue: PlaceAccessGuard) {\n return lang.illegalState('hackyMutableModel is read only');\n },\n toLeft: (rightValue: PlaceAccessGuard) => rightValue\n });\n binding.writeLeft();\n this._accessGuard.setDelegate(hackyMutableModel);\n this.redirections = redirections;\n }\n\n getAuthenticationFailureRedirect(activatedRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Visit {\n return this.redirections.onAuthenticationFailure(activatedRoute, state);\n }\n\n getAuthorisationFailureRedirect(activatedRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Visit {\n return this.redirections.onAuthorisationFailure(activatedRoute, state);\n }\n\n get navigationSession() {\n return this.navigationSessionModel.value;\n }\n\n get currentSession() {\n return this.navigationSessionModel.value;\n }\n\n isNavigating(): boolean {\n return this.navigationInProgress.value;\n }\n\n // @Trace()\n onPopState(event: NavigationStart) {\n assert.isTruthy(event.navigationTrigger === 'popstate');\n if (this.currentSession) {\n this.currentSession.onPopState(event);\n } else {\n const poppedHistoryUrl = event.url;\n const currentRouterUrl = this.urlService.getCurrentRouterUrl();\n const session = this.interactionService.isActive() ?\n new PopStateDuringInteractionNavigation(this.navigationContext, currentRouterUrl, poppedHistoryUrl) :\n new PopStateNavigation(this.navigationContext, currentRouterUrl, poppedHistoryUrl);\n this.transitionTo(session);\n }\n }\n\n // @Trace()\n onRouterStarted(event: NavigationStart) {\n assert.isFalsey(event.navigationTrigger === 'popstate');\n const inInteraction = this.interactionService.isActive();\n if (this.currentSession) {\n this.currentSession.onRouterStarted(event);\n } else {\n this.transitionTo(this.createNavigationSession(this.urlService.getCurrentRouterUrl()));\n }\n }\n\n // @Trace()\n onUrlChanged(newUrl: string) {\n // the back button can trigger a url change without a navigation session in progress so we\n // console.log(`---> Url Changed ${newUrl}`);\n if (this.currentSession) {\n this.currentSession.onUrlChange(newUrl);\n } else {\n console.log('FYI: url changed without a navigation session in progress');\n }\n // console.log(`<--- Url Changed`);\n }\n\n // @Trace()\n onRouterCancelled(event: NavigationCancel) {\n this.currentSession.onRouterCancelled(event);\n }\n\n // @Trace()\n onRouterError(event: NavigationError) {\n this.currentSession.onRouterError(event);\n }\n\n // @Trace()\n onRouterEnd(event: NavigationEnd) {\n this.currentSession.onRouterEnd(event);\n }\n\n navigate(visit: Visit, options?: { relativeTo: ActivatedRoute }) {\n return this.doNavigation(visit, async router => {\n const commands = [\n visit.placeDefinition.path,\n ...this.createRouteParameters(visit)\n ];\n await this.angularRouter.navigate(commands, {\n relativeTo: options ? options.relativeTo : null\n });\n });\n }\n\n // @Trace()\n async doNavigation(visit: Visit, runNavigationCommands: (router: Router) => any) {\n if (this.navigationInProgress.value) {\n lang.illegalState('Navigation already in progress');\n }\n const navigation = this.createNavigationSession(this.urlService.getCurrentRouterUrl());\n navigation.storeVisit(visit);\n this.transitionTo(navigation);\n try {\n await runNavigationCommands(this.angularRouter);\n } finally {\n // Check if the router has finished (in the case where no router change required) and we're still in a\n // transient state and finish of the transition.\n if (!this.angularRouter.getCurrentNavigation() && this.currentSession) {\n this.currentSession.onRouterEnd(new NavigationEnd(-1, '', ''));\n }\n }\n }\n\n navigateByUrl(urlSnapshot: UrlSnapshot, navigationExtras?: NavigationExtras) {\n // console.log(`### navigationByUrl -> ${urlSnapshot.urlTree.toString()}`);\n return this.angularRouter.navigateByUrl(urlSnapshot.urlTree, navigationExtras);\n }\n\n get activeVisits(): ListModel<Visit> {\n return this._activeVisits.readonly;\n }\n\n // @Trace()\n async pushVisitChangesToRoute(previous: Visit, next: Visit): Promise<void> {\n this.placeHistory.updateVisit(next);\n\n // FIXME: no route id -> route id duplicates route parameters\n if (next.hasRoutingChangedFrom(previous)) {\n return this.doNavigation(next, router => {\n const urlSnapshot = this.urlService.parseUrl(this.angularRouter.routerState.snapshot.url).updateVisitSegments(next);\n // console.log('### Push Changes to route Redirect', { commands: urlSnapshot.url });\n return this.navigateByUrl(urlSnapshot);\n });\n }\n }\n\n\n private createNavigationSession(currentRouterUrl: string): NavigationSession {\n const inInteraction = this.interactionService.isActive();\n return inInteraction ?\n new NavigatingDuringInteraction(this.navigationContext, currentRouterUrl) :\n new Navigating(this.navigationContext, currentRouterUrl);\n }\n\n // @Trace()\n protected transitionTo(next: NavigationSession) {\n const previous = this.navigationSessionModel.value;\n if (!previous) {\n this.placeHistory.notifyNavigationStarted();\n }\n assert.isTruthy(next !== previous);\n // Logger.get(this).info(`### Router State Transition: ${previous ? previous.toString() : 'null'} -> ${next.toString()}`);\n this.navigationSessionModel.value = next;\n if (!!previous) {\n previous.dispose();\n }\n next.notifyActive();\n }\n\n // @Trace()\n private routingSessionFinished(visits: Visit[]) {\n if (visits && visits.length > 0) {\n assert.isTruthy(this.navigationInProgress.value);\n this.placeHistory.notifyNavigationFinished(visits);\n // We update the active visits before we finish the session so the\n // place outlets can ignore the incoming changes until things are\n // settled. TODO: can we removed the event'ness here and just do a push?\n this._activeVisits.value = visits;\n }\n const session = this.currentSession;\n session.dispose();\n this.navigationSessionModel.value = null;\n // console.log(`### Router Session Finished (was ${session.toString()})`);\n this.sessionFinishedJobs.forEach(job => job());\n this.sessionFinishedJobs = [];\n }\n\n private runAfterRoutingSessionFinishes(func: () => void) {\n assert.isTruthy(this.navigationInProgress);\n this.sessionFinishedJobs.push(func);\n }\n\n\n /**\n * Sync's the current interaction state with the URL. We need to push something in the URL in order\n * to be able to capture the back button on the first page. If we don't then the back click will exit\n * the app directly and we don't get to ask.\n */\n // @Trace()\n syncInteractionContextIdsWithRouter(): Promise<unknown> {\n if (this.navigationSession) {\n // console.log(`Navigation active -> ${this.navigationSession.toString()}, sync delayed until finished.`);\n const session = this.navigationSession;\n return new Promise((resolve, reject) => {\n this.runAfterRoutingSessionFinishes(() => {\n this.runAfterRoutingSessionFinishes(resolve);\n const syncSession = new SynchroniseInteractionContextIdsWithRoute(this.navigationContext, this.urlService.getCurrentRouterUrl(), false);\n this.transitionTo(syncSession);\n });\n });\n } else {\n return new Promise<unknown>(((resolve, reject) => {\n // console.log(`No navigation in progress, starting synchronisation job`);\n this.runAfterRoutingSessionFinishes(resolve);\n const session = new SynchroniseInteractionContextIdsWithRoute(this.navigationContext, this.urlService.getCurrentRouterUrl(), false);\n this.transitionTo(session);\n }));\n\n }\n }\n\n\n private createRouteParameters(visit: Visit) {\n const def = visit.placeDefinition;\n return visit.hasRouteId() ?\n [def.getFormattedRouteId(visit), def.getFormattedRouteParameters(visit)] :\n [def.getFormattedRouteParameters(visit)];\n }\n\n}\n\nexport namespace PlaceRouter {\n\n export interface Redirections {\n onAuthenticationFailure(activatedRoute?: ActivatedRouteSnapshot, state?: RouterStateSnapshot): Visit;\n\n onAuthorisationFailure(activatedRoute?: ActivatedRouteSnapshot, state?: RouterStateSnapshot): Visit;\n }\n\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"PlaceRouter":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"@coolon/pectin","name":"GarbageCollector","line":48,"character":33},"decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":45,"character":1},"arguments":[{"providedIn":"root"}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/router","name":"Router","line":68,"character":46},{"__symbolic":"reference","module":"@angular/common","name":"Location","line":69,"character":48},{"__symbolic":"reference","module":"../interaction/services/interaction.service","name":"InteractionService","line":70,"character":51},{"__symbolic":"reference","module":"./url-service","name":"UrlService","line":71,"character":43},{"__symbolic":"reference","module":"./place-history","name":"PlaceHistory","line":72,"character":45}]}],"configureAuth":[{"__symbolic":"method"
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"PlaceRouter":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"@coolon/pectin","name":"GarbageCollector","line":48,"character":33},"decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":45,"character":1},"arguments":[{"providedIn":"root"}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/router","name":"Router","line":68,"character":46},{"__symbolic":"reference","module":"@angular/common","name":"Location","line":69,"character":48},{"__symbolic":"reference","module":"../interaction/services/interaction.service","name":"InteractionService","line":70,"character":51},{"__symbolic":"reference","module":"./url-service","name":"UrlService","line":71,"character":43},{"__symbolic":"reference","module":"./place-history","name":"PlaceHistory","line":72,"character":45}]}],"configureAuth":[{"__symbolic":"method"}],"getAuthenticationFailureRedirect":[{"__symbolic":"method"}],"getAuthorisationFailureRedirect":[{"__symbolic":"method"}],"isNavigating":[{"__symbolic":"method"}],"onPopState":[{"__symbolic":"method"}],"onRouterStarted":[{"__symbolic":"method"}],"onUrlChanged":[{"__symbolic":"method"}],"onRouterCancelled":[{"__symbolic":"method"}],"onRouterError":[{"__symbolic":"method"}],"onRouterEnd":[{"__symbolic":"method"}],"navigate":[{"__symbolic":"method"}],"doNavigation":[{"__symbolic":"method"}],"navigateByUrl":[{"__symbolic":"method"}],"pushVisitChangesToRoute":[{"__symbolic":"method"}],"createNavigationSession":[{"__symbolic":"method"}],"transitionTo":[{"__symbolic":"method"}],"routingSessionFinished":[{"__symbolic":"method"}],"runAfterRoutingSessionFinishes":[{"__symbolic":"method"}],"syncInteractionContextIdsWithRouter":[{"__symbolic":"method"}],"createRouteParameters":[{"__symbolic":"method"}]},"statics":{"ɵprov":{}}}}}]
|
|
@@ -59,7 +59,7 @@ export class Visit {
|
|
|
59
59
|
return !sameNonRouteParameters || this.hasRoutingChangedFrom(other);
|
|
60
60
|
}
|
|
61
61
|
toDebugString() {
|
|
62
|
-
return Object.keys(this.visitParameters).map(k => `${k}=${this.visitParameters[k]}`).join(
|
|
62
|
+
return Object.keys(this.visitParameters).map(k => `${k}=${this.visitParameters[k]}`).join(',');
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
//# sourceMappingURL=visit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"visit.js","sourceRoot":"","sources":["../../../../../../libs/angular-ui-powerups/src/lib/place/visit.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"visit.js","sourceRoot":"","sources":["../../../../../../libs/angular-ui-powerups/src/lib/place/visit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAS5B,MAAM,OAAO,KAAK;IAEhB,YAAqB,eAAgC,EAAmB,kBAA0B,EAAE;QAA/E,oBAAe,GAAf,eAAe,CAAiB;QAAmB,oBAAe,GAAf,eAAe,CAAa;IACpG,CAAC;IAED,WAAW;IACX,UAAU;QACR,OAAO,IAAI,CAAC,eAAe,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IACnD,CAAC;IAED,WAAW;IACX,UAAU;QACR,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;IACrC,CAAC;IAED;;;;;O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AM,CAAC,CAAC;IACjD,CAAC;IAED,qBAAqB,CAAC,KAAY;QAChC,MAAM,SAAS,GAAG,KAAK,CAAC,eAAe,KAAK,IAAI,CAAC,eAAe,CAAC;QACjE,MAAM,mBAAmB,GAAG,CAAC,CAAC,OAAO,CACnC,IAAI,CAAC,eAAe,CAAC,2BAA2B,CAAC,IAAI,EAAE,IAAI,CAAC,EAC5D,IAAI,CAAC,eAAe,CAAC,2BAA2B,CAAC,KAAK,EAAE,IAAI,CAAC,CAC9D,CAAC;QACF,OAAO,CAAC,SAAS,IAAI,CAAC,mBAAmB,CAAC;IAC5C,CAAC;IAED,cAAc,CAAC,KAAY;QACzB,MAAM,sBAAsB,GAAG,CAAC,CAAC,OAAO,CACtC,IAAI,CAAC,eAAe,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAChD,IAAI,CAAC,eAAe,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAClD,CAAC;QACF,OAAO,CAAC,sBAAsB,IAAI,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC;IACtE,CAAC;IAED,aAAa;QACX,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACjG,CAAC;CAEF","sourcesContent":["import * as _ from 'lodash';\nimport { PlaceDefinition } from './place-definition';\nimport { ParameterDefinition } from './route/parameter-definition.class';\n\ninterface Params {\n [p: string]: any\n}\n\n\nexport class Visit {\n\n constructor(readonly placeDefinition: PlaceDefinition, private readonly visitParameters: Params = {}) {\n }\n\n // @Trace()\n getRouteId(): any {\n return this.placeDefinition.getRouteIdFrom(this);\n }\n\n // @Trace()\n hasRouteId(): boolean {\n return !_.isNil(this.getRouteId());\n }\n\n /**\n * Returns the value of the place parameter with the specified name. The parameter\n * name is taken from the `as` option, e.g. {as: 'aCustomName'} otherwise it is the\n * same as the the ValueModel property name.\n * @param parameterName the field name of the property model or the `as` option if specified.\n */\n getParameter(parameterName: string): any {\n return this.visitParameters[parameterName];\n }\n\n // @Trace()\n hasParameter(parameterName: string) {\n return Object.keys(this.visitParameters).includes(parameterName);\n }\n\n replace<S>(parameter: ParameterDefinition<any, S>, value: S): Visit {\n return new Visit(this.placeDefinition, { ...this.visitParameters, [parameter.name]: value });\n }\n\n mergeRouteParameters<S>(routeParams: { [p: string]: any }): Visit {\n // todo: whitelist parameters.\n const routeParameterKeys = Object.keys(routeParams);\n const params = {};\n this.placeDefinition.getVisitParameterDefs().forEach(def => {\n if (def.isRouteId || def.isRouteParameter) {\n if (routeParameterKeys.includes(def.name)) {\n params[def.name] = routeParams[def.name];\n }\n } else {\n // copy non route params as is, but only if they already exist otherwise we'll inject nil values and break the\n // defaults and remember sanitisation process.\n const value = this.getParameter(def.name);\n if (this.hasParameter(def.name)) {\n params[def.name] = value;\n }\n }\n });\n return new Visit(this.placeDefinition, params);\n }\n\n hasRoutingChangedFrom(other: Visit): boolean {\n const samePlace = other.placeDefinition === this.placeDefinition;\n const sameRouteParameters = _.isEqual(\n this.placeDefinition.getFormattedRouteParameters(this, true),\n this.placeDefinition.getFormattedRouteParameters(other, true)\n );\n return !samePlace || !sameRouteParameters;\n }\n\n hasChangedFrom(other: Visit) {\n const sameNonRouteParameters = _.isEqual(\n this.placeDefinition.getNonRouteParameters(this),\n this.placeDefinition.getNonRouteParameters(other)\n );\n return !sameNonRouteParameters || this.hasRoutingChangedFrom(other);\n }\n\n toDebugString() {\n return Object.keys(this.visitParameters).map(k => `${k}=${this.visitParameters[k]}`).join(',');\n }\n\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"Visit":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"./place-definition","name":"PlaceDefinition","line":
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"Visit":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"./place-definition","name":"PlaceDefinition","line":11,"character":40},{"__symbolic":"reference","name":"any"}]}],"getRouteId":[{"__symbolic":"method"}],"hasRouteId":[{"__symbolic":"method"}],"getParameter":[{"__symbolic":"method"}],"hasParameter":[{"__symbolic":"method"}],"replace":[{"__symbolic":"method"}],"mergeRouteParameters":[{"__symbolic":"method"}],"hasRoutingChangedFrom":[{"__symbolic":"method"}],"hasChangedFrom":[{"__symbolic":"method"}],"toDebugString":[{"__symbolic":"method"}]}}}}]
|