@coolon/angular-ui-powerups 0.0.119 → 0.0.120
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/coolon-angular-ui-powerups.umd.js +65 -161
- 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/guards/navigation-state.js +43 -85
- package/esm2015/lib/place/guards/navigation-state.js.map +1 -1
- package/esm2015/lib/place/guards/navigation-state.metadata.json +1 -1
- package/esm2015/lib/place/place-router.js +9 -2
- package/esm2015/lib/place/place-router.js.map +1 -1
- package/esm2015/lib/place/place-router.metadata.json +1 -1
- package/esm5/lib/place/guards/navigation-state.js +52 -159
- package/esm5/lib/place/guards/navigation-state.js.map +1 -1
- package/esm5/lib/place/place-router.js +13 -2
- package/esm5/lib/place/place-router.js.map +1 -1
- package/fesm2015/coolon-angular-ui-powerups.js +52 -87
- package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
- package/fesm5/coolon-angular-ui-powerups.js +65 -161
- package/fesm5/coolon-angular-ui-powerups.js.map +1 -1
- package/lib/place/guards/navigation-state.d.ts +4 -1
- package/lib/place/place-router.d.ts +4 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"place-router.js","sourceRoot":"ng://@coolon/angular-ui-powerups/","sources":["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,EACN,aAAa,EACd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,MAAM,EAEN,GAAG,E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,IAAI,CAAC,uBAAuB,EAAE,CAAC,oBAAoB,CAAC,UAAU,CAAC;gBACnF,IAAI,oBAAoB,EAAE;oBACxB,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE;wBAC9B,UAAU,EAAE,IAAI;qBACjB,CAAC,CAAC,IAAI;;;oBAAC;wBACN,iFAAiF;wBACjF,yBAAyB;wBACzB,KAAI,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;oBAC9B,CAAC,EAAC,CAAC;iBACJ;qBAAM;oBACL,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE;wBAC9B,UAAU,EAAE,IAAI;qBACjB,CAAC,CAAC;iBACJ;aACF;SACF;IACH,CAAC;;gBA/PF,UAAU,SAAC;oBACV,UAAU,EAAE,MAAM;iBACnB;;;;gBA7BC,MAAM;gBACN,aAAa;gBAXN,QAAQ;gBAgCR,YAAY;gBAFZ,kBAAkB;;;sBA9B3B;CAqSC,AAhQD,CAGiC,gBAAgB,GA6PhD;SA7PY,WAAW;;;;;;IAEtB,4CAAkF;;;;;IAClF,oCAA+D;;IAE/D,2CAAmD;;IACnD,uCAAsE;;;;;IACtE,gDAA2D;;;;;IAC3D,gDAAmF;;;;;IAEvE,6BAA+B;;;;;IAC/B,oCAA6C;;;;;IAC7C,sCAA0C;;;;;IAC1C,mCAA2C;;;;;IAC3C,yCAAuD","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 UrlSerializer\n} from '@angular/router';\nimport {\n assert,\n Constructable,\n Dsl,\n GarbageCollector,\n HasOneIndexChain,\n lang,\n ListModel,\n Logger,\n MutableListModel,\n MutableStream,\n MutableValueModel,\n Trace,\n ValueModel,\n ValueModelChain\n} from '@coolon/pectin';\nimport _ from 'lodash';\nimport { InteractionService } from '../interaction/services/interaction.service';\nimport { NavigationState } from './guards/navigation-state';\nimport { PlaceHistory } from './place-history';\nimport { UrlSnapshot } from './url-snapshot';\nimport { Visit } from './visit';\n\n\n@Injectable({\n providedIn: 'root'\n})\nexport class PlaceRouter extends GarbageCollector {\n\n private readonly _navigationStateModel = new MutableValueModel<NavigationState>();\n private readonly _activeVisits = new MutableListModel<Visit>();\n\n readonly navigationInProgress: ValueModel<boolean>;\n readonly activeVisitIndex: HasOneIndexChain<'placeDefinition', Visit>;\n private _navigationSessionContext: NavigationState.Context;\n private _navigationStateTypeModel: ValueModelChain<Constructable<NavigationState>>;\n\n constructor(private readonly router: Router,\n private readonly urlSerializer: UrlSerializer,\n private readonly angularLocation: Location,\n private readonly placeHistory: PlaceHistory,\n private readonly interactionService: InteractionService) {\n super();\n const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);\n this.activeVisitIndex = chain(this._activeVisits).indexBy('placeDefinition');\n this.navigationInProgress = chain(this.navigationStateModel).pluck('isTransitional');\n this._navigationSessionContext = new NavigationState.Context(this, this.interactionService, session => {\n this.processNavigationSuccess(session);\n });\n this._navigationStateModel.value = new NavigationState.Idle(this._navigationSessionContext);\n this._navigationStateTypeModel = chain(this._navigationStateModel).map(state => state.constructor as Constructable<NavigationState>);\n\n // TODO: make setup the callbacks in during module initiation to make this testable.\n this.router.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 if (event.navigationTrigger === 'popstate') {\n this.runStateTransition(state => state.onPopState(event));\n } else {\n this.runStateTransition(state => state.onRouterStarted(event));\n }\n }\n if (event instanceof NavigationEnd) {\n console.log(event);\n this.runStateTransition(state => state.onRouterEnd(event));\n }\n if (event instanceof NavigationError) {\n console.log(event);\n this.runStateTransition(state => state.onRouterError(event));\n }\n if (event instanceof NavigationCancel) {\n console.log(event);\n this.runStateTransition(state => state.onRouterCancelled(event));\n }\n });\n\n // Push dialog state to the url so we can capture the back button.\n when.listOf(this.interactionService.activeInteractionContextIds).changes((ids, previous) => {\n this.syncInteractionIdsWithRouter(ids, previous);\n }, { unless: this.navigationInProgress }); // TODO: I think the exclusive interaction prevents interactions starting while it's active so we might not need this.\n\n const urlChanges = new MutableStream<{ url: string, state: NavigationState }>();\n\n // The angular router doesn't always fire router events when the back button is pushed while a navigation\n // session is in progress. Sometimes we only know about it from the url change.\n // IMPORTANT ORDER DEPENDENCY\n // This only works because we're notified of the change after the router has started reacting to it. This\n // we can can use our navigationState to determine things.\n angularLocation.onUrlChange(url => {\n const navigationState = this._navigationStateModel.value;\n console.log(`URLChange -> ${url}`, { state: navigationState });\n urlChanges.publish({ url, state: navigationState });\n\n // The url has changed while we're in a transitional state\n if (navigationState.isTransitional) {\n const navigationInteraction = this.navigationState.interactionContext;\n if (navigationInteraction && navigationInteraction.isActive()) {\n this.runStateTransition(state => state.onBackClickedDuringNavigationInteraction(url));\n }\n }\n });\n }\n\n private processNavigationSuccess(session: NavigationState) {\n // We need to update the visits before the session finishes. This allows the placeOutets to ignore visit\n // changes that occur while routerNavigationActive is true.\n assert.isTruthy(this.navigationInProgress.value);\n const visits = session.getVisits();\n visits.forEach(v => this.placeHistory.add(v));\n this._activeVisits.value = visits;\n }\n\n get navigationState(): NavigationState {\n return this._navigationStateModel.value;\n }\n\n get navigationStateModel(): ValueModel<NavigationState> {\n return this._navigationStateModel.readonly;\n }\n\n get activeVisits(): ListModel<Visit> {\n return this._activeVisits.readonly;\n }\n\n /**\n * placeRouter.navigate(placeDestinations.somePlace.createVisit(routeId, ...visitParams));\n * @param visit\n */\n async navigate(visit: Visit, options?: { relativeTo: ActivatedRoute }) {\n this.doNavigation(visit, async router => {\n const commands = [\n visit.placeDefinition.path,\n ...this.createRouteParameters(visit)\n ];\n await this.router.navigate(commands, {\n relativeTo: options ? options.relativeTo : null\n });\n });\n }\n\n // @Trace()\n async pushVisitChangesToRoute(activatedRoute: ActivatedRoute, previous: Visit, next: Visit) {\n // we have to push to history so our remember sanitisers don't pick up the previous value\n // when it's been cleared by the user.\n this.placeHistory.add(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.parseUrl(this.router.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 async doNavigation(visit: Visit, runNavigationCommands: (router: Router) => any) {\n if (this.navigationInProgress.value) {\n lang.illegalState('Navigation already in progress');\n }\n this.runStateTransition(current => {\n const session = this.navigationState.onPlaceNavigationStart(visit, this.getCurrentRouterUrl());\n session.storeVisit(visit);\n return session;\n });\n try {\n await runNavigationCommands(this.router);\n } finally {\n // Router has finished (since there was no router change required) so we\n // need to end the navigation session.\n if (this.navigationState.isTransitional && !this.router.getCurrentNavigation()) {\n this.runStateTransition(session => session.onRouterEnd(new NavigationEnd(-1, '', '')));\n }\n }\n }\n\n // @Trace()\n protected runStateTransition(transition: (navigationSession: NavigationState) => NavigationState) {\n const previous = this._navigationStateModel.value;\n const next = transition(this.navigationState);\n this._navigationStateModel.value = next;\n if (next !== previous) {\n previous.dispose();\n Logger.get(this).info(`Router State Transition: ${previous.toString()} -> ${next.toString()}`);\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 extractChildPath(activatedRoute: ActivatedRouteSnapshot): any[] {\n return _.flatten(activatedRoute.children.map(child => child.url));\n }\n\n parseUrl(url: string): UrlSnapshot {\n return new UrlSnapshot(this.urlSerializer, url);\n }\n\n resetBrowserLocation(url: string) {\n this.angularLocation.go(url);\n }\n\n createUrlSnapshot(...visits: Visit[]): UrlSnapshot {\n const bits = [];\n visits.forEach(v => {\n bits.push(this.parseUrl(`${v.placeDefinition.path}`).updateVisitSegments(v).url);\n });\n return this.parseUrl(bits.join(''));\n }\n\n getCurrentRouterUrl(): string {\n return this.router.routerState ? this.router.routerState.snapshot.url : null;\n }\n\n getCurrentRouteSnapshot(): UrlSnapshot {\n return this.parseUrl(this.getCurrentRouterUrl());\n }\n\n getActiveInteractionIdsFromUrl(url: string): string[] {\n return this.parseUrl(url).getInteractionIds();\n }\n\n\n // @Trace()\n hasActiveInteractionIds(url: string) {\n return this.getActiveInteractionIdsFromUrl(url).length > 0;\n }\n\n // @Trace()\n navigateByUrl(urlSnapshot: UrlSnapshot, navigationExtras?: NavigationExtras): Promise<boolean> {\n return this.router.navigateByUrl(urlSnapshot.urlTree, navigationExtras);\n }\n\n // TODO: Should this be moved to the navigation states?\n syncInteractionIdsWithRouter(currentIds: string[], previous: string[]) {\n assert.isFalsey(this.navigationInProgress.value); // Updating interaction routes during an existing navigation breaks all the things.\n console.log({\n startingActivity: currentIds.length > previous.length,\n wasBackButton: this.navigationState.isPopState\n });\n\n if (_.isEqual(currentIds, previous)) {\n console.log('activity ids were the same, skipping');\n } else {\n // OMG, this is nuts.\n const addingActivity = currentIds.length > previous.length;\n const isFirstActivity = addingActivity && previous.length < 1;\n const removingLastActivity = currentIds.length < 1;\n if (addingActivity) {// we're starting a new activity, push the change to the history and update the url\n console.log('adding activity');\n this.navigateByUrl(this.getCurrentRouteSnapshot().updateInteractionIds(currentIds), {\n replaceUrl: !isFirstActivity // we don't let the history pile up\n });\n } else {\n const urlSnapshot = this.getCurrentRouteSnapshot().updateInteractionIds(currentIds);\n if (removingLastActivity) {\n this.navigateByUrl(urlSnapshot, {\n replaceUrl: true\n }).then(() => {\n // for some reason we need to pop the last history off the stack when leaving the\n // active activity state.\n this.angularLocation.back();\n });\n } else {\n this.navigateByUrl(urlSnapshot, {\n replaceUrl: true\n });\n }\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file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AA2D;;;;;IAC3D,gDAAmF;;;;;IAEvE,6BAA+B;;;;;IAC/B,oCAA6C;;;;;IAC7C,sCAA0C;;;;;IAC1C,mCAA2C;;;;;IAC3C,yCAAuD","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 UrlSerializer\n} from '@angular/router';\nimport {\n assert,\n Constructable,\n Dsl,\n GarbageCollector,\n HasOneIndexChain,\n lang,\n ListModel,\n Logger,\n MutableListModel,\n MutableStream,\n MutableValueModel,\n ValueModel,\n ValueModelChain\n} from '@coolon/pectin';\nimport _ from 'lodash';\nimport { InteractionService } from '../interaction/services/interaction.service';\nimport { NavigationState } from './guards/navigation-state';\nimport { PlaceHistory } from './place-history';\nimport { UrlSnapshot } from './url-snapshot';\nimport { Visit } from './visit';\n\n\n@Injectable({\n providedIn: 'root'\n})\nexport class PlaceRouter extends GarbageCollector {\n\n private readonly _navigationStateModel = new MutableValueModel<NavigationState>();\n private readonly _activeVisits = new MutableListModel<Visit>();\n\n readonly navigationInProgress: ValueModel<boolean>;\n readonly activeVisitIndex: HasOneIndexChain<'placeDefinition', Visit>;\n private _navigationSessionContext: NavigationState.Context;\n private _navigationStateTypeModel: ValueModelChain<Constructable<NavigationState>>;\n\n constructor(private readonly router: Router,\n private readonly urlSerializer: UrlSerializer,\n private readonly angularLocation: Location,\n private readonly placeHistory: PlaceHistory,\n private readonly interactionService: InteractionService) {\n super();\n const { chain, valueOf, before, when, after, observe, switchOn } = Dsl.disposeWith(this);\n this.activeVisitIndex = chain(this._activeVisits).indexBy('placeDefinition');\n this.navigationInProgress = chain(this.navigationStateModel).pluck('isTransitional');\n this._navigationSessionContext = new NavigationState.Context(this, this.interactionService, session => {\n this.processNavigationSuccess(session);\n });\n this._navigationStateModel.value = new NavigationState.Idle(this._navigationSessionContext);\n this._navigationStateTypeModel = chain(this._navigationStateModel).map(state => state.constructor as Constructable<NavigationState>);\n\n // TODO: make setup the callbacks in during module initiation to make this testable.\n this.router.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 if (event.navigationTrigger === 'popstate') {\n this.runStateTransition(state => state.onPopState(event));\n } else {\n this.runStateTransition(state => state.onRouterStarted(event));\n }\n }\n if (event instanceof NavigationEnd) {\n console.log(event);\n this.runStateTransition(state => state.onRouterEnd(event));\n }\n if (event instanceof NavigationError) {\n console.log(event);\n this.runStateTransition(state => state.onRouterError(event));\n }\n if (event instanceof NavigationCancel) {\n console.log(event);\n this.runStateTransition(state => state.onRouterCancelled(event));\n }\n });\n\n // Push dialog state to the url so we can capture the back button.\n when.listOf(this.interactionService.activeInteractionContextIds).changes((ids, previous) => {\n this.syncInteractionIdsWithRouter(ids, previous);\n }, { unless: this.navigationInProgress }); // TODO: I think the exclusive interaction prevents interactions starting while it's active so we might not need this.\n\n const urlChanges = new MutableStream<{ url: string, state: NavigationState }>();\n\n // The angular router doesn't always fire router events when the back button is pushed while a navigation\n // session is in progress. Sometimes we only know about it from the url change.\n // IMPORTANT ORDER DEPENDENCY\n // This only works because we're notified of the change after the router has started reacting to it. This\n // we can can use our navigationState to determine things.\n angularLocation.onUrlChange(url => {\n const navigationState = this._navigationStateModel.value;\n console.log(`URLChange -> ${url}`, { state: navigationState });\n urlChanges.publish({ url, state: navigationState });\n\n // The url has changed while we're in a transitional state\n if (navigationState.isTransitional) {\n const navigationInteraction = this.navigationState.interactionContext;\n if (navigationInteraction && navigationInteraction.isActive()) {\n this.runStateTransition(state => state.onBackClickedDuringNavigationInteraction(url));\n }\n }\n });\n }\n\n private processNavigationSuccess(session: NavigationState) {\n // We need to update the visits before the session finishes. This allows the placeOutets to ignore visit\n // changes that occur while routerNavigationActive is true.\n assert.isTruthy(this.navigationInProgress.value);\n const visits = session.getVisits();\n visits.forEach(v => this.placeHistory.add(v));\n this._activeVisits.value = visits;\n }\n\n get navigationState(): NavigationState {\n return this._navigationStateModel.value;\n }\n\n get navigationStateModel(): ValueModel<NavigationState> {\n return this._navigationStateModel.readonly;\n }\n\n get activeVisits(): ListModel<Visit> {\n return this._activeVisits.readonly;\n }\n\n /**\n * placeRouter.navigate(placeDestinations.somePlace.createVisit(routeId, ...visitParams));\n * @param visit\n */\n async navigate(visit: Visit, options?: { relativeTo: ActivatedRoute }) {\n this.doNavigation(visit, async router => {\n const commands = [\n visit.placeDefinition.path,\n ...this.createRouteParameters(visit)\n ];\n await this.router.navigate(commands, {\n relativeTo: options ? options.relativeTo : null\n });\n });\n }\n\n // @Trace()\n async pushVisitChangesToRoute(activatedRoute: ActivatedRoute, previous: Visit, next: Visit) {\n // we have to push to history so our remember sanitisers don't pick up the previous value\n // when it's been cleared by the user.\n this.placeHistory.add(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.parseUrl(this.router.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 async doNavigation(visit: Visit, runNavigationCommands: (router: Router) => any) {\n if (this.navigationInProgress.value) {\n lang.illegalState('Navigation already in progress');\n }\n this.runStateTransition(current => {\n const session = this.navigationState.onPlaceNavigationStart(visit, this.getCurrentRouterUrl());\n session.storeVisit(visit);\n return session;\n });\n try {\n await runNavigationCommands(this.router);\n } finally {\n // Router has finished (since there was no router change required) so we\n // need to end the navigation session.\n if (this.navigationState.isTransitional && !this.router.getCurrentNavigation()) {\n this.runStateTransition(session => session.onRouterEnd(new NavigationEnd(-1, '', '')));\n }\n }\n }\n\n // @Trace()\n protected runStateTransition(transition: (navigationSession: NavigationState) => NavigationState) {\n const previous = this._navigationStateModel.value;\n const next = transition(this.navigationState);\n this._navigationStateModel.value = next;\n if (next !== previous) {\n previous.dispose();\n Logger.get(this).info(`Router State Transition: ${previous.toString()} -> ${next.toString()}`);\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 extractChildPath(activatedRoute: ActivatedRouteSnapshot): any[] {\n return _.flatten(activatedRoute.children.map(child => child.url));\n }\n\n parseUrl(url: string): UrlSnapshot {\n return new UrlSnapshot(this.urlSerializer, url);\n }\n\n resetBrowserLocation(url: string, options: { replaceCurrent: boolean }) {\n options.replaceCurrent ? this.angularLocation.replaceState(url) : this.angularLocation.go(url);\n }\n\n forward() {\n this.angularLocation.forward();\n }\n\n createUrlSnapshot(...visits: Visit[]): UrlSnapshot {\n const bits = [];\n visits.forEach(v => {\n bits.push(this.parseUrl(`${v.placeDefinition.path}`).updateVisitSegments(v).url);\n });\n return this.parseUrl(bits.join(''));\n }\n\n getCurrentRouterUrl(): string {\n return this.router.routerState ? this.router.routerState.snapshot.url : null;\n }\n\n getCurrentRouteSnapshot(): UrlSnapshot {\n return this.parseUrl(this.getCurrentRouterUrl());\n }\n\n getActiveInteractionIdsFromUrl(url: string): string[] {\n return this.parseUrl(url).getInteractionIds();\n }\n\n\n // @Trace()\n hasActiveInteractionIds(url: string) {\n return this.getActiveInteractionIdsFromUrl(url).length > 0;\n }\n\n // @Trace()\n navigateByUrl(urlSnapshot: UrlSnapshot, navigationExtras?: NavigationExtras): Promise<boolean> {\n return this.router.navigateByUrl(urlSnapshot.urlTree, navigationExtras);\n }\n\n // TODO: Should this be moved to the navigation states?\n syncInteractionIdsWithRouter(currentIds: string[], previous: string[]) {\n assert.isFalsey(this.navigationInProgress.value); // Updating interaction routes during an existing navigation breaks all the things.\n console.log({\n startingActivity: currentIds.length > previous.length,\n wasBackButton: this.navigationState.isPopState\n });\n\n if (_.isEqual(currentIds, previous)) {\n console.log('activity ids were the same, skipping');\n } else {\n // OMG, this is nuts.\n const addingActivity = currentIds.length > previous.length;\n const isFirstActivity = addingActivity && previous.length < 1;\n const removingLastActivity = currentIds.length < 1;\n if (addingActivity) {// we're starting a new activity, push the change to the history and update the url\n console.log('adding activity');\n this.navigateByUrl(this.getCurrentRouteSnapshot().updateInteractionIds(currentIds), {\n replaceUrl: !isFirstActivity // we don't let the history pile up\n });\n } else {\n const urlSnapshot = this.getCurrentRouteSnapshot().updateInteractionIds(currentIds);\n if (removingLastActivity) {\n this.navigateByUrl(urlSnapshot, {\n replaceUrl: true\n }).then(() => {\n // for some reason we need to pop the last history off the stack when leaving the\n // active activity state.\n this.angularLocation.back();\n });\n } else {\n this.navigateByUrl(urlSnapshot, {\n replaceUrl: true\n });\n }\n }\n }\n }\n}\n"]}
|
|
@@ -3220,13 +3220,13 @@ class NavigationState extends GarbageCollector {
|
|
|
3220
3220
|
new NavigationState.IdleDuringInteraction(this.context, this.currentRouterUrl()) :
|
|
3221
3221
|
new NavigationState.Idle(this.context);
|
|
3222
3222
|
}
|
|
3223
|
-
//
|
|
3224
3223
|
/**
|
|
3225
3224
|
* @param {?} url
|
|
3225
|
+
* @param {?=} options
|
|
3226
3226
|
* @return {?}
|
|
3227
3227
|
*/
|
|
3228
|
-
resetBrowserLocation(url) {
|
|
3229
|
-
this.placeRouter.resetBrowserLocation(url);
|
|
3228
|
+
resetBrowserLocation(url, options = { replaceCurrent: false }) {
|
|
3229
|
+
this.placeRouter.resetBrowserLocation(url, options);
|
|
3230
3230
|
}
|
|
3231
3231
|
/**
|
|
3232
3232
|
* @param {?} event
|
|
@@ -3258,6 +3258,20 @@ class NavigationState extends GarbageCollector {
|
|
|
3258
3258
|
return `${p}: ${this[p]}`;
|
|
3259
3259
|
})).join(', ');
|
|
3260
3260
|
}
|
|
3261
|
+
/**
|
|
3262
|
+
* @protected
|
|
3263
|
+
* @param {?} url
|
|
3264
|
+
* @return {?}
|
|
3265
|
+
*/
|
|
3266
|
+
replaceBuggeredUrlAfterAngularRouterCancelled(url) {
|
|
3267
|
+
// Angular calls _this.resetUrlToCurrentUrlTree() on cancelling and fucks our history.
|
|
3268
|
+
// 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
|
|
3269
|
+
// it before the cancel event fired.
|
|
3270
|
+
// So we need to:
|
|
3271
|
+
// - replace the just inserted url with the one that used to be there.
|
|
3272
|
+
// - push our actual url back onto the top of the stack.
|
|
3273
|
+
this.resetBrowserLocation(url, { replaceCurrent: true });
|
|
3274
|
+
}
|
|
3261
3275
|
}
|
|
3262
3276
|
if (false) {
|
|
3263
3277
|
/**
|
|
@@ -3536,11 +3550,11 @@ if (false) {
|
|
|
3536
3550
|
* @return {?}
|
|
3537
3551
|
*/
|
|
3538
3552
|
onRouterCancelled(event) {
|
|
3553
|
+
this.replaceBuggeredUrlAfterAngularRouterCancelled(this.poppedHistoryUrl);
|
|
3539
3554
|
// Angular doesn't preserve the url when a guard cancels the back button.
|
|
3540
3555
|
// See https://github.com/angular/angular/issues/13586#issuecomment-432795720
|
|
3541
3556
|
Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
|
|
3542
|
-
this.resetBrowserLocation(this.
|
|
3543
|
-
this.resetBrowserLocation(this.startingUrl); // and now put our own url back in.
|
|
3557
|
+
this.resetBrowserLocation(this.startingUrl);
|
|
3544
3558
|
return new Idle(this.context);
|
|
3545
3559
|
}
|
|
3546
3560
|
/**
|
|
@@ -3548,15 +3562,18 @@ if (false) {
|
|
|
3548
3562
|
* @return {?}
|
|
3549
3563
|
*/
|
|
3550
3564
|
onRouterError(event) {
|
|
3551
|
-
// navigation was aborted.
|
|
3552
|
-
if (this.currentRouterUrl() !== this.startingUrl) {
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3565
|
+
// // navigation was aborted.
|
|
3566
|
+
// if (this.currentRouterUrl() !== this.startingUrl) {
|
|
3567
|
+
// // Angular doesn't preserve the url when a guard cancels the back button.
|
|
3568
|
+
// // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
|
|
3569
|
+
// Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
|
|
3570
|
+
// this.restoreHistory([
|
|
3571
|
+
// this.poppedHistoryUrl,
|
|
3572
|
+
// this.startingUrl
|
|
3573
|
+
// ]);
|
|
3574
|
+
// }
|
|
3575
|
+
// return new Idle(this.context);
|
|
3576
|
+
return this.illegalTransition("when do I get this???");
|
|
3560
3577
|
}
|
|
3561
3578
|
/**
|
|
3562
3579
|
* @param {?} locationTriggerUrl
|
|
@@ -3668,6 +3685,7 @@ if (false) {
|
|
|
3668
3685
|
* @return {?}
|
|
3669
3686
|
*/
|
|
3670
3687
|
onRouterCancelled(event) {
|
|
3688
|
+
// TODO: this.replaceBuggeredUrlAfterAngularRouterCancells(...);???
|
|
3671
3689
|
if (this.context.interactionService.isActive()) {
|
|
3672
3690
|
/** @type {?} */
|
|
3673
3691
|
const interactionIds = this.interactionService.activeInteractionContextIds.value;
|
|
@@ -3760,6 +3778,7 @@ if (false) {
|
|
|
3760
3778
|
this.resetBrowserLocation(this.placeRouter.parseUrl(this.startingUrl).updateInteractionIds(interactionIds).url);
|
|
3761
3779
|
}
|
|
3762
3780
|
else {
|
|
3781
|
+
// this.replaceBuggeredUrlAfterAngularRouterCancells(this.start)
|
|
3763
3782
|
this.resetBrowserLocation(this.startingUrl); // and now put our own url back in.
|
|
3764
3783
|
}
|
|
3765
3784
|
return this.createIdleState();
|
|
@@ -3834,6 +3853,7 @@ if (false) {
|
|
|
3834
3853
|
* @return {?}
|
|
3835
3854
|
*/
|
|
3836
3855
|
onRouterCancelled(event) {
|
|
3856
|
+
// TODO: this.replaceBuggeredUrlAfterAngularRouterCancells(...);???
|
|
3837
3857
|
if (this.interactionService.isActive()) {
|
|
3838
3858
|
/** @type {?} */
|
|
3839
3859
|
const interactionIds = this.interactionService.activeInteractionContextIds.value;
|
|
@@ -3861,7 +3881,7 @@ if (false) {
|
|
|
3861
3881
|
* @return {?}
|
|
3862
3882
|
*/
|
|
3863
3883
|
createNavigationInteractionCancelledState(newUrl) {
|
|
3864
|
-
return this.illegalTransition(
|
|
3884
|
+
return this.illegalTransition('Leaving interaction after pop-state should\'t block so should never see a back button click');
|
|
3865
3885
|
}
|
|
3866
3886
|
}
|
|
3867
3887
|
NavigationState.LeavingInteractionAfterPopStateTransition = LeavingInteractionAfterPopStateTransition;
|
|
@@ -3871,74 +3891,6 @@ if (false) {
|
|
|
3871
3891
|
/** @type {?} */
|
|
3872
3892
|
LeavingInteractionAfterPopStateTransition.prototype.poppedHistoryUrl;
|
|
3873
3893
|
}
|
|
3874
|
-
// See LeavingInteractionAfterPopStateTransition.createNavigationInteractionCancelledState(...) above.
|
|
3875
|
-
//
|
|
3876
|
-
// export class LeavingInteractionAfterPopStateCancelled extends NavigationState {
|
|
3877
|
-
//
|
|
3878
|
-
// readonly isPopState = false;
|
|
3879
|
-
// firstCancelHandled = false;
|
|
3880
|
-
// popStateHandled = false;
|
|
3881
|
-
// popStateEventUrl: string;
|
|
3882
|
-
// debugPropertyKeys = ['idle', 'startingUrl', 'poppedHistoryUrl', 'locationChangeTriggerUrl', 'popStateEventUrl', 'firstCancelHandled', 'popStateHandled'];
|
|
3883
|
-
//
|
|
3884
|
-
// constructor(context: Context,
|
|
3885
|
-
// readonly startingUrl: string,
|
|
3886
|
-
// readonly locationChangeTriggerUrl: string,
|
|
3887
|
-
// readonly poppedHistoryUrl: string) {
|
|
3888
|
-
// super(context);
|
|
3889
|
-
// }
|
|
3890
|
-
//
|
|
3891
|
-
// get isTransitional() {
|
|
3892
|
-
// return true;
|
|
3893
|
-
// }
|
|
3894
|
-
//
|
|
3895
|
-
// onRouterStarted(event: NavigationStart): NavigationState {
|
|
3896
|
-
// return this.ignore(event);
|
|
3897
|
-
// }
|
|
3898
|
-
//
|
|
3899
|
-
//
|
|
3900
|
-
// onRouterCancelled(event: NavigationCancel): NavigationState {
|
|
3901
|
-
//
|
|
3902
|
-
// // if (this.firstCancelHandled && this.popStateHandled) {
|
|
3903
|
-
// // // Angular doesn't preserve the url when a guard cancels the back button.
|
|
3904
|
-
// // // See https://github.com/angular/angular/issues/13586#issuecomment-432795720
|
|
3905
|
-
// // Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
|
|
3906
|
-
// // this.resetBrowserLocation(this.locationChangeTriggerUrl); // put the second back click one back in.
|
|
3907
|
-
// // this.resetBrowserLocation(this.poppedHistoryUrl); // put the first back click one back in.
|
|
3908
|
-
// // if (this.interactionService.isActive()) {
|
|
3909
|
-
// // const interactionIds = this.interactionService.activeInteractionContextIds.value;
|
|
3910
|
-
// // this.resetBrowserLocation(this.placeRouter.parseUrl(this.startingUrl).updateInteractionIds(interactionIds).url);
|
|
3911
|
-
// // } else {
|
|
3912
|
-
// // this.resetBrowserLocation(this.startingUrl); // and now put our own url back in.
|
|
3913
|
-
// // }
|
|
3914
|
-
// // return this.createIdleState();
|
|
3915
|
-
// // } else {
|
|
3916
|
-
// // this.firstCancelHandled = true;
|
|
3917
|
-
// return this.ignore(event);
|
|
3918
|
-
// // }
|
|
3919
|
-
// }
|
|
3920
|
-
//
|
|
3921
|
-
//
|
|
3922
|
-
// onRouterEnd(event: NavigationEnd): NavigationState {
|
|
3923
|
-
// return this.ignore(event);
|
|
3924
|
-
// }
|
|
3925
|
-
//
|
|
3926
|
-
//
|
|
3927
|
-
// onRouterError(event: NavigationError): NavigationState {
|
|
3928
|
-
// return this.ignore(event);
|
|
3929
|
-
// }
|
|
3930
|
-
//
|
|
3931
|
-
//
|
|
3932
|
-
// onPopState(event: NavigationStart): NavigationState {
|
|
3933
|
-
// // this.popStateHandled = true;
|
|
3934
|
-
// // this.popStateEventUrl = event.url;
|
|
3935
|
-
// return this.ignore(event);
|
|
3936
|
-
// }
|
|
3937
|
-
//
|
|
3938
|
-
// async canDeactivatePlace(component: PlaceComponent, currentUrl: UrlSnapshot, nextUrl: UrlSnapshot): Promise<boolean | UrlSnapshot> {
|
|
3939
|
-
// return false;
|
|
3940
|
-
// }
|
|
3941
|
-
// }
|
|
3942
3894
|
/**
|
|
3943
3895
|
* This state handles the scenario where a link navigation triggered an interaction and the user clicked back a to cancel it.
|
|
3944
3896
|
* The routing event sequence is different depending on the link that was clicked.
|
|
@@ -4038,7 +3990,7 @@ if (false) {
|
|
|
4038
3990
|
*/
|
|
4039
3991
|
finaliseRouting() {
|
|
4040
3992
|
Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
|
|
4041
|
-
this.
|
|
3993
|
+
this.replaceBuggeredUrlAfterAngularRouterCancelled(this.clickedLinkUrl); // put the back click one back in.
|
|
4042
3994
|
if (this.interactionService.isActive()) {
|
|
4043
3995
|
/** @type {?} */
|
|
4044
3996
|
const interactionIds = this.interactionService.activeInteractionContextIds.value;
|
|
@@ -4130,7 +4082,13 @@ if (false) {
|
|
|
4130
4082
|
// Angular doesn't preserve the url when a guard cancels the back button.
|
|
4131
4083
|
// See https://github.com/angular/angular/issues/13586#issuecomment-432795720
|
|
4132
4084
|
Logger.get(this).info('WORK-AROUND: Updating browser location after pop state - see angular issue #13586');
|
|
4133
|
-
//
|
|
4085
|
+
// Angular calls _this.resetUrlToCurrentUrlTree() on cancelling and fucks our history.
|
|
4086
|
+
// 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
|
|
4087
|
+
// it before the cancel event fired.
|
|
4088
|
+
// So we need to:
|
|
4089
|
+
// - replace the just inserted url with the one that used to be there.
|
|
4090
|
+
// - push our actual url back onto the top of the stack.
|
|
4091
|
+
this.replaceBuggeredUrlAfterAngularRouterCancelled(this.locationChangeTriggerUrl);
|
|
4134
4092
|
this.resetBrowserLocation(this.poppedHistoryUrl); // put the first back click one back in.
|
|
4135
4093
|
if (this.interactionService.isActive()) {
|
|
4136
4094
|
/** @type {?} */
|
|
@@ -4730,10 +4688,17 @@ class PlaceRouter extends GarbageCollector {
|
|
|
4730
4688
|
}
|
|
4731
4689
|
/**
|
|
4732
4690
|
* @param {?} url
|
|
4691
|
+
* @param {?} options
|
|
4692
|
+
* @return {?}
|
|
4693
|
+
*/
|
|
4694
|
+
resetBrowserLocation(url, options) {
|
|
4695
|
+
options.replaceCurrent ? this.angularLocation.replaceState(url) : this.angularLocation.go(url);
|
|
4696
|
+
}
|
|
4697
|
+
/**
|
|
4733
4698
|
* @return {?}
|
|
4734
4699
|
*/
|
|
4735
|
-
|
|
4736
|
-
this.angularLocation.
|
|
4700
|
+
forward() {
|
|
4701
|
+
this.angularLocation.forward();
|
|
4737
4702
|
}
|
|
4738
4703
|
/**
|
|
4739
4704
|
* @param {...?} visits
|