@coolon/angular-ui-powerups 1.0.1 → 1.1.0
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 +18 -0
- package/bundles/coolon-angular-ui-powerups.umd.js +446 -169
- package/bundles/coolon-angular-ui-powerups.umd.js.map +1 -1
- package/bundles/coolon-angular-ui-powerups.umd.min.js +1 -1
- package/bundles/coolon-angular-ui-powerups.umd.min.js.map +1 -1
- package/coolon-angular-ui-powerups.d.ts +26 -25
- package/coolon-angular-ui-powerups.metadata.json +1 -1
- package/esm2015/coolon-angular-ui-powerups.js +24 -23
- package/esm2015/coolon-angular-ui-powerups.js.map +1 -1
- package/esm2015/coolon-angular-ui-powerups.metadata.json +1 -1
- package/esm2015/lib/angular-ui-powerups.module.ngfactory.js.map +1 -1
- package/esm2015/lib/components/components.module.js +9 -2
- package/esm2015/lib/components/components.module.js.map +1 -1
- package/esm2015/lib/components/components.module.metadata.json +1 -1
- package/esm2015/lib/components/components.module.ngfactory.js.map +1 -1
- package/esm2015/lib/components/forms/abstract-input.component.js +12 -1
- package/esm2015/lib/components/forms/abstract-input.component.js.map +1 -1
- package/esm2015/lib/components/forms/abstract-input.component.metadata.json +1 -1
- package/esm2015/lib/components/forms/number-input/number-input.component.js +2 -2
- package/esm2015/lib/components/forms/number-input/number-input.component.js.map +1 -1
- package/esm2015/lib/components/forms/number-input/number-input.component.metadata.json +1 -1
- package/esm2015/lib/components/forms/password-input/password-input.component.js +2 -2
- package/esm2015/lib/components/forms/password-input/password-input.component.js.map +1 -1
- package/esm2015/lib/components/forms/password-input/password-input.component.metadata.json +1 -1
- package/esm2015/lib/components/forms/select-input/select-input.component.js +3 -3
- package/esm2015/lib/components/forms/select-input/select-input.component.js.map +1 -1
- package/esm2015/lib/components/forms/select-input/select-input.component.metadata.json +1 -1
- package/esm2015/lib/components/forms/string-input/string-input.component.js +3 -3
- package/esm2015/lib/components/forms/string-input/string-input.component.js.map +1 -1
- package/esm2015/lib/components/forms/string-input/string-input.component.metadata.json +1 -1
- package/esm2015/lib/components/index.js +1 -0
- package/esm2015/lib/components/index.js.map +1 -1
- package/esm2015/lib/components/index.metadata.json +1 -1
- package/esm2015/lib/components/switch-case/switch-case.component.js +124 -0
- package/esm2015/lib/components/switch-case/switch-case.component.js.map +1 -0
- package/esm2015/lib/components/switch-case/switch-case.component.metadata.json +1 -0
- package/esm2015/lib/components/switch-case/switch-case.component.ngfactory.js.map +1 -0
- package/esm2015/lib/components/switch-case/switch-case.component.scss.shim.ngstyle.js.map +1 -0
- package/esm2015/lib/directives/command.directive.js +4 -4
- package/esm2015/lib/directives/command.directive.js.map +1 -1
- package/esm2015/lib/directives/focus-binding.directive.js +3 -3
- package/esm2015/lib/directives/focus-binding.directive.js.map +1 -1
- package/esm2015/lib/interaction/components/alert-dialog/alert-dialog.component.js +1 -1
- package/esm2015/lib/interaction/components/alert-dialog/alert-dialog.component.metadata.json +1 -1
- package/esm2015/lib/interaction/components/confirm-then-dialog/confirm-then-dialog.component.js +1 -1
- package/esm2015/lib/interaction/components/confirm-then-dialog/confirm-then-dialog.component.metadata.json +1 -1
- package/esm2015/lib/interaction/components/confirmation-dialog/confirmation-dialog.component.js +1 -1
- package/esm2015/lib/interaction/components/confirmation-dialog/confirmation-dialog.component.metadata.json +1 -1
- package/esm2015/lib/place/components/abstract-place-navigation.component.js +3 -3
- package/esm2015/lib/place/components/abstract-place-navigation.component.js.map +1 -1
- package/esm2015/lib/place/components/abstract-place-navigation.component.metadata.json +1 -1
- package/esm2015/lib/place/components/busy-overlay/busy-overlay.component.js +2 -2
- package/esm2015/lib/place/components/busy-overlay/busy-overlay.component.js.map +1 -1
- package/esm2015/lib/place/components/busy-overlay/busy-overlay.component.metadata.json +1 -1
- package/esm2015/lib/place/components/place-outlet/place-outlet.component.js +3 -3
- 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/guards/place.guard.js +4 -3
- package/esm2015/lib/place/guards/place.guard.js.map +1 -1
- package/esm2015/lib/place/place-component.js +2 -2
- package/esm2015/lib/place/place-component.js.map +1 -1
- package/esm2015/lib/place/place-history.js +116 -13
- package/esm2015/lib/place/place-history.js.map +1 -1
- package/esm2015/lib/place/place-history.metadata.json +1 -1
- package/esm2015/lib/place/place-router.js +13 -6
- package/esm2015/lib/place/place-router.js.map +1 -1
- package/esm2015/lib/place/place-router.metadata.json +1 -1
- package/esm2015/lib/place/route/parameter-decorators.js.map +1 -1
- package/esm2015/lib/place/route/parameter-definition.class.js +10 -9
- package/esm2015/lib/place/route/parameter-definition.class.js.map +1 -1
- package/esm2015/lib/place/route/visit-sanitiser.js +14 -6
- package/esm2015/lib/place/route/visit-sanitiser.js.map +1 -1
- package/esm2015/lib/place/route/visit-sanitiser.metadata.json +1 -1
- package/esm5/coolon-angular-ui-powerups.js +24 -23
- package/esm5/coolon-angular-ui-powerups.js.map +1 -1
- package/esm5/lib/angular-ui-powerups.module.ngfactory.js.map +1 -1
- package/esm5/lib/components/components.module.js +9 -2
- package/esm5/lib/components/components.module.js.map +1 -1
- package/esm5/lib/components/components.module.ngfactory.js.map +1 -1
- package/esm5/lib/components/forms/abstract-input.component.js +12 -1
- package/esm5/lib/components/forms/abstract-input.component.js.map +1 -1
- package/esm5/lib/components/forms/number-input/number-input.component.js +2 -2
- package/esm5/lib/components/forms/number-input/number-input.component.js.map +1 -1
- package/esm5/lib/components/forms/password-input/password-input.component.js +2 -2
- package/esm5/lib/components/forms/password-input/password-input.component.js.map +1 -1
- package/esm5/lib/components/forms/select-input/select-input.component.js +3 -3
- package/esm5/lib/components/forms/select-input/select-input.component.js.map +1 -1
- package/esm5/lib/components/forms/string-input/string-input.component.js +3 -3
- package/esm5/lib/components/forms/string-input/string-input.component.js.map +1 -1
- package/esm5/lib/components/index.js +1 -0
- package/esm5/lib/components/index.js.map +1 -1
- package/esm5/lib/components/switch-case/switch-case.component.js +144 -0
- package/esm5/lib/components/switch-case/switch-case.component.js.map +1 -0
- package/esm5/lib/components/switch-case/switch-case.component.ngfactory.js.map +1 -0
- package/esm5/lib/components/switch-case/switch-case.component.scss.shim.ngstyle.js.map +1 -0
- package/esm5/lib/directives/command.directive.js +4 -4
- package/esm5/lib/directives/command.directive.js.map +1 -1
- package/esm5/lib/directives/focus-binding.directive.js +3 -3
- package/esm5/lib/directives/focus-binding.directive.js.map +1 -1
- package/esm5/lib/interaction/components/alert-dialog/alert-dialog.component.js +1 -1
- package/esm5/lib/interaction/components/confirm-then-dialog/confirm-then-dialog.component.js +1 -1
- package/esm5/lib/interaction/components/confirmation-dialog/confirmation-dialog.component.js +1 -1
- package/esm5/lib/place/components/abstract-place-navigation.component.js +3 -3
- package/esm5/lib/place/components/abstract-place-navigation.component.js.map +1 -1
- package/esm5/lib/place/components/busy-overlay/busy-overlay.component.js +2 -2
- package/esm5/lib/place/components/busy-overlay/busy-overlay.component.js.map +1 -1
- package/esm5/lib/place/components/place-outlet/place-outlet.component.js +3 -3
- package/esm5/lib/place/components/place-outlet/place-outlet.component.js.map +1 -1
- package/esm5/lib/place/guards/place.guard.js +5 -4
- package/esm5/lib/place/guards/place.guard.js.map +1 -1
- package/esm5/lib/place/place-component.js +2 -2
- package/esm5/lib/place/place-component.js.map +1 -1
- package/esm5/lib/place/place-history.js +117 -11
- package/esm5/lib/place/place-history.js.map +1 -1
- package/esm5/lib/place/place-router.js +13 -7
- package/esm5/lib/place/place-router.js.map +1 -1
- package/esm5/lib/place/route/parameter-decorators.js.map +1 -1
- package/esm5/lib/place/route/parameter-definition.class.js +11 -11
- package/esm5/lib/place/route/parameter-definition.class.js.map +1 -1
- package/esm5/lib/place/route/visit-sanitiser.js +14 -6
- package/esm5/lib/place/route/visit-sanitiser.js.map +1 -1
- package/fesm2015/coolon-angular-ui-powerups.js +377 -127
- package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
- package/fesm5/coolon-angular-ui-powerups.js +405 -135
- package/fesm5/coolon-angular-ui-powerups.js.map +1 -1
- package/lib/components/forms/abstract-input.component.d.ts +11 -1
- package/lib/components/index.d.ts +1 -0
- package/lib/components/switch-case/switch-case.component.d.ts +32 -0
- package/lib/place/place-history.d.ts +17 -3
- package/lib/place/route/parameter-definition.class.d.ts +1 -1
- package/lib/place/route/visit-sanitiser.d.ts +3 -1
- package/package.json +2 -2
|
@@ -2,7 +2,7 @@ import { __awaiter, __decorate, __extends, __generator, __metadata, __read, __sp
|
|
|
2
2
|
import { Location } from '@angular/common';
|
|
3
3
|
import { Injectable } from '@angular/core';
|
|
4
4
|
import { ActivatedRoute, NavigationCancel, NavigationEnd, NavigationError, NavigationExtras, NavigationStart, Router } from '@angular/router';
|
|
5
|
-
import { assert, DebugContext, Dsl, GarbageCollector, lang, Logger, MutableListModel, MutableValueModel } from '@coolon/pectin';
|
|
5
|
+
import { assert, DebugContext, Dsl, GarbageCollector, lang, Logger, MutableListModel, MutableValueModel, Trace } 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';
|
|
@@ -12,6 +12,7 @@ import { NavigationContext } from './navigation/session/navigation-context';
|
|
|
12
12
|
import { PopStateNavigation } from './navigation/session/pop-state-navigation';
|
|
13
13
|
import { PlaceHistory } from './place-history';
|
|
14
14
|
import { UrlService } from './url-service';
|
|
15
|
+
import { Visit } from './visit';
|
|
15
16
|
import * as i0 from "@angular/core";
|
|
16
17
|
import * as i1 from "@angular/router";
|
|
17
18
|
import * as i2 from "@angular/common";
|
|
@@ -213,14 +214,11 @@ var PlaceRouter = /** @class */ (function (_super) {
|
|
|
213
214
|
enumerable: true,
|
|
214
215
|
configurable: true
|
|
215
216
|
});
|
|
216
|
-
// @Trace()
|
|
217
217
|
PlaceRouter.prototype.pushVisitChangesToRoute = function (previous, next) {
|
|
218
218
|
return __awaiter(this, void 0, void 0, function () {
|
|
219
219
|
var _this = this;
|
|
220
220
|
return __generator(this, function (_a) {
|
|
221
|
-
|
|
222
|
-
// when it's been cleared by the user.
|
|
223
|
-
this.placeHistory.add(next);
|
|
221
|
+
this.placeHistory.updateVisit(next);
|
|
224
222
|
// FIXME: no route id -> route id duplicates route parameters
|
|
225
223
|
if (next.hasRoutingChangedFrom(previous)) {
|
|
226
224
|
return [2 /*return*/, this.doNavigation(next, function (router) {
|
|
@@ -242,6 +240,9 @@ var PlaceRouter = /** @class */ (function (_super) {
|
|
|
242
240
|
// @Trace()
|
|
243
241
|
PlaceRouter.prototype.transitionTo = function (next) {
|
|
244
242
|
var previous = this.navigationSessionModel.value;
|
|
243
|
+
if (!previous) {
|
|
244
|
+
this.placeHistory.notifyNavigationStarted();
|
|
245
|
+
}
|
|
245
246
|
assert.isTruthy(next !== previous);
|
|
246
247
|
Logger.get(this).info("### Router State Transition: " + (previous ? previous.toString() : 'null') + " -> " + next.toString());
|
|
247
248
|
this.navigationSessionModel.value = next;
|
|
@@ -252,10 +253,9 @@ var PlaceRouter = /** @class */ (function (_super) {
|
|
|
252
253
|
};
|
|
253
254
|
// @Trace()
|
|
254
255
|
PlaceRouter.prototype.routingSessionFinished = function (visits) {
|
|
255
|
-
var _this = this;
|
|
256
256
|
if (visits && visits.length > 0) {
|
|
257
257
|
assert.isTruthy(this.navigationInProgress.value);
|
|
258
|
-
|
|
258
|
+
this.placeHistory.notifyNavigationFinished(visits);
|
|
259
259
|
// We update the active visits before we finish the session so the
|
|
260
260
|
// place outlets can ignore the incoming changes until things are
|
|
261
261
|
// settled. TODO: can we removed the event'ness here and just do a push?
|
|
@@ -314,6 +314,12 @@ var PlaceRouter = /** @class */ (function (_super) {
|
|
|
314
314
|
{ type: PlaceHistory }
|
|
315
315
|
]; };
|
|
316
316
|
PlaceRouter.ɵprov = i0.ɵɵdefineInjectable({ factory: function PlaceRouter_Factory() { return new PlaceRouter(i0.ɵɵinject(i1.Router), i0.ɵɵinject(i2.Location), i0.ɵɵinject(i3.InteractionService), i0.ɵɵinject(i4.UrlService), i0.ɵɵinject(i5.PlaceHistory)); }, token: PlaceRouter, providedIn: "root" });
|
|
317
|
+
__decorate([
|
|
318
|
+
Trace(),
|
|
319
|
+
__metadata("design:type", Function),
|
|
320
|
+
__metadata("design:paramtypes", [Visit, Visit]),
|
|
321
|
+
__metadata("design:returntype", Promise)
|
|
322
|
+
], PlaceRouter.prototype, "pushVisitChangesToRoute", null);
|
|
317
323
|
PlaceRouter = __decorate([
|
|
318
324
|
Injectable({
|
|
319
325
|
providedIn: 'root'
|
|
@@ -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;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,MAAM,EACP,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,MAAM,EAAE,YAAY,EACpB,GAAG,EACH,gBAAgB,EAEhB,IAAI,EAEJ,MAAM,EACN,gBAAgB,EAChB,iBAAiB,EAGlB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAEjF,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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;YACV,UAAU,EAAE,MAAM;SACnB,CAAC;yCAc4C,MAAM;YACJ,QAAQ;YACL,kBAAkB;YAC1B,UAAU;YACR,YAAY;OAjB5C,WAAW,CA2RvB;sBArUD;CAqUC,AA3RD,CAAiC,gBAAgB,GA2RhD;SA3RY,WAAW","sourcesContent":["import { Location } from '@angular/common';\nimport { DEBUG } from '@angular/compiler-cli/ngcc/src/logging/console_logger';\nimport { Injectable } from '@angular/core';\nimport {\n ActivatedRoute,\n NavigationCancel,\n NavigationEnd,\n NavigationError,\n NavigationExtras,\n NavigationStart,\n Router\n} from '@angular/router';\nimport {\n assert, DebugContext,\n Dsl,\n GarbageCollector,\n HasOneIndexChain,\n lang,\n ListModel,\n Logger,\n MutableListModel,\n MutableValueModel,\n Trace, TransactionObserver,\n ValueModelChain\n} from '@coolon/pectin';\nimport { InteractionService } from '../interaction/services/interaction.service';\nimport { InteractionServiceRoutingAdapter } from '../interaction/services/interaction-service-routing-adapter';\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 { 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: HasOneIndexChain<'placeDefinition', Visit>;\n private routerInteractionAdapter: InteractionServiceRoutingAdapter;\n private sessionFinishedJobs: (() => void)[] = [];\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 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 navigationSession() {\n return this.navigationSessionModel.value;\n }\n\n get currentSession() {\n return this.navigationSessionModel.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 // 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 // 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 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 visits.forEach(v => this.placeHistory.add(v));\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 NavigationStateMachine {\n export type VisitsUpdatedCallback = (visits: Visit[]) => void;\n}\n"]}
|
|
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;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,MAAM,EACP,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,MAAM,EAAE,YAAY,EACpB,GAAG,EACH,gBAAgB,EAEhB,IAAI,EAEJ,MAAM,EACN,gBAAgB,EAChB,iBAAiB,EACjB,KAAK,EAEN,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAEjF,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,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,eAA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ACL,kBAAkB;YAC1B,UAAU;YACR,YAAY;OAjB5C,WAAW,CA6RvB;sBAvUD;CAuUC,AA7RD,CAAiC,gBAAgB,GA6RhD;SA7RY,WAAW","sourcesContent":["import { Location } from '@angular/common';\nimport { DEBUG } from '@angular/compiler-cli/ngcc/src/logging/console_logger';\nimport { Injectable } from '@angular/core';\nimport {\n ActivatedRoute,\n NavigationCancel,\n NavigationEnd,\n NavigationError,\n NavigationExtras,\n NavigationStart,\n Router\n} from '@angular/router';\nimport {\n assert, DebugContext,\n Dsl,\n GarbageCollector,\n HasOneIndexChain,\n lang,\n ListModel,\n Logger,\n MutableListModel,\n MutableValueModel,\n Trace, TransactionObserver,\n ValueModelChain\n} from '@coolon/pectin';\nimport { InteractionService } from '../interaction/services/interaction.service';\nimport { InteractionServiceRoutingAdapter } from '../interaction/services/interaction-service-routing-adapter';\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 { 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: HasOneIndexChain<'placeDefinition', Visit>;\n private routerInteractionAdapter: InteractionServiceRoutingAdapter;\n private sessionFinishedJobs: (() => void)[] = [];\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 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 navigationSession() {\n return this.navigationSessionModel.value;\n }\n\n get currentSession() {\n return this.navigationSessionModel.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 NavigationStateMachine {\n export type VisitsUpdatedCallback = (visits: Visit[]) => void;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parameter-decorators.js","sourceRoot":"ng://@coolon/angular-ui-powerups/","sources":["lib/place/route/parameter-decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,YAAY,EAEZ,MAAM,EACN,gBAAgB,EAChB,iBAAiB,EAElB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AA8BnE,SAAS,gBAAgB,CAA0B,SAAiB,EAAE,WAA4B,EAAE,YAAe,EAAE,SAAiB,EAAE,OAA6B;IACnK,IAAM,SAAS,GAAG;QAChB,YAAY,EAAE,YAAY;QAC1B,OAAO,EAAE,IAAyB;KACnC,CAAC;IACF,IAAM,GAAG,GAAM,SAAS,SAAI,SAAS,CAAC,WAAW,CAAC,IAAI,SAAI,WAAW,CAAC,QAAQ,EAAE,MAAG,CAAC;IACpF,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAClD,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5C,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,WAAW,EAAE;QAC5C,GAAG,EAAE;YACH,OAAO,SAAS,CAAC,YAAY,CAAC;QAChC,CAAC;QACD,GAAG,EAAE,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AC3E,gBAAgB,CAAC,SAAS,EAAE,WAAW,EAAE,IAAI,iBAAiB,EAAK,EAAE,iBAAiB,EAAE,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,EAAjB,CAAiB,CAAC,CAAC;IAClH,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAI,OAAsC;IAC1E,IAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC/B,OAAO,UAAC,SAAiB,EAAE,WAA4B;QACrD,IAAM,KAAK,GAAG,IAAI,mBAAmB,CAAC,cAAc,CAAC,WAAW,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC;QAC5H,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,oBAAoB,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;QAC3E,gBAAgB,CAAC,SAAS,EAAE,WAAW,EAAE,IAAI,gBAAgB,EAAK,EAAE,qBAAqB,EAAE,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,KAAK,EAAE,CAAC,OAAO,EAAE,EAAnB,CAAmB,CAAC,CAAC;IACvH,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {\n Binding,\n DebugContext,\n HasValue,\n Logger,\n MutableListModel,\n MutableValueModel,\n TrackExternal\n} from '@coolon/pectin';\nimport { Klass, Opts } from '@coolon/typescript-utilities';\nimport { ROUTE_PARAMETER_LIST_KEY } from '../place-component';\nimport { Formatter } from './formatter';\nimport { ParameterDefinition } from './parameter-definition.class';\n\n\nexport interface RouteIdOptions<T> {\n as?: string;\n optional?: boolean;\n remember?: boolean;\n defaultValue?: T;\n // sanitiser?: Constructable<ParameterSanitiser<T>> | ParameterSanitiser<T>;\n}\n\nexport interface RouteParameterOptions<T> {\n as?: string;\n optional?: boolean;\n remember?: boolean;\n defaultValue?: T;\n storeInUrl?: Formatter<T>\n // sanitiser?: Constructable<ParameterSanitiser<T>> | ParameterSanitiser<T>;\n}\n\nexport interface RouteListParameterOptions<T> {\n as?: string;\n optional?: boolean;\n remember?: boolean;\n defaultValue?: T[];\n storeInUrl?: Formatter<T>\n // sanitiser?: Constructable<ParameterSanitiser<T[]>> | ParameterSanitiser<T[]>;\n}\n\n\nfunction installMechanics<M extends HasValue<any>>(prototype: Object, propertyKey: string | symbol, backingModel: M, tagPrefix: string, isEmpty: (mode: M) => boolean) {\n const mechanics = {\n backingModel: backingModel,\n binding: null as Binding<any, any>\n };\n const tag = `${tagPrefix}(${prototype.constructor.name}.${propertyKey.toString()})`;\n DebugContext.get(mechanics.backingModel).tag(tag);\n Logger.get(mechanics.backingModel).tag(tag);\n Object.defineProperty(prototype, propertyKey, {\n get: function() {\n return mechanics.backingModel;\n },\n set: function(userModel: M) {\n // This handles the scenario where we want to push an existing value model (such as a form model)\n // to and from the route.\n if (mechanics.binding) {\n mechanics.binding.dispose();\n }\n if (userModel) {\n mechanics.binding = new Binding(mechanics.backingModel, userModel);\n if (isEmpty(userModel)) {\n // console.log(`Push visit to model for ${tag}`, {value: mechanics.backingModel.value});\n mechanics.binding.writeRight(); // push the visit into the user model;\n } else {\n if (!isEmpty(mechanics.backingModel)) {\n console.warn('Assigning a visit model with an existing value to a visit parameter with an existing value. Visit parameter will be overridden');\n }\n mechanics.binding.writeLeft(); // push the user model into the visit\n }\n }\n }\n });\n}\n\nexport function RouteId<T extends string | number>(type: Formatter<T>, options?: RouteIdOptions<T>): PropertyDecorator {\n return (prototype: Object, propertyKey: string | symbol) => {\n const param = new ParameterDefinition.RouteId(propertyKey.toString(), options, type);\n Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);\n installMechanics(prototype, propertyKey, new MutableValueModel<T>(), \"@RouteId\", m => m.query().isNil());\n };\n}\n\nexport function VisitParameter<T>(options?: RouteParameterOptions<T>): PropertyDecorator {\n const opts = Opts.get(options);\n return (prototype: Object, propertyKey: string | symbol) => {\n const param = new ParameterDefinition.ValueParameter(propertyKey.toString(), options, opts.getOptional('storeInUrl', null));\n Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);\n installMechanics(prototype, propertyKey, new MutableValueModel<T>(), \"@VisitParameter\", m => m.query().isNil());\n };\n}\n\nexport function VisitParameterList<E>(options?: RouteListParameterOptions<E>): PropertyDecorator {\n const opts = Opts.get(options);\n return (prototype: Object, propertyKey: string | symbol) => {\n const param = new ParameterDefinition.ArrayParameter(propertyKey.toString(), options, opts.getOptional('storeInUrl', null));\n Klass.get(prototype).addToOwnMetadataList(ROUTE_PARAMETER_LIST_KEY, param);\n installMechanics(prototype, propertyKey, new MutableListModel<E>(), \"@VisitParameterList\", m => m.query().isEmpty());\n };\n}\n"]}
|
|
@@ -28,22 +28,22 @@ var ParameterDefinition = /** @class */ (function () {
|
|
|
28
28
|
return this.options.getOptional(key, null);
|
|
29
29
|
};
|
|
30
30
|
// @Trace()
|
|
31
|
-
ParameterDefinition.prototype.sanitise = function (value, visit, placeHistory, injector) {
|
|
31
|
+
ParameterDefinition.prototype.sanitise = function (value, visit, placeHistory, injector, isPopState) {
|
|
32
32
|
return __awaiter(this, void 0, void 0, function () {
|
|
33
|
-
var
|
|
33
|
+
var returningFromSomewhereElse, lastKnownVisit;
|
|
34
34
|
return __generator(this, function (_a) {
|
|
35
35
|
if (this.isMissingFrom(visit)) {
|
|
36
|
-
|
|
37
|
-
if (
|
|
38
|
-
|
|
36
|
+
returningFromSomewhereElse = !placeHistory.lastVisitIncluded(visit.placeDefinition);
|
|
37
|
+
if (returningFromSomewhereElse) {
|
|
38
|
+
lastKnownVisit = placeHistory.getMostRecentVisitFor(visit.placeDefinition);
|
|
39
|
+
if (this.remember && lastKnownVisit) {
|
|
40
|
+
value = lastKnownVisit.getParameter(this.name);
|
|
41
|
+
}
|
|
42
|
+
return [2 /*return*/, this.isEmptyValue(value) ? this.defaultValue : value];
|
|
39
43
|
}
|
|
40
|
-
return [2 /*return*/, this.isEmptyValue(value) ? this.defaultValue : value];
|
|
41
44
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return [2 /*return*/, value];
|
|
45
|
-
}
|
|
46
|
-
return [2 /*return*/];
|
|
45
|
+
// todo: add custom sanitiser
|
|
46
|
+
return [2 /*return*/, value];
|
|
47
47
|
});
|
|
48
48
|
});
|
|
49
49
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parameter-definition.class.js","sourceRoot":"ng://@coolon/angular-ui-powerups/","sources":["lib/place/route/parameter-definition.class.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AACpD,OAAO,CAAC,MAAM,QAAQ,CAAC;AAKvB;IASE,6BAAqB,YAAoB,EAAE,OAAuC,EAAW,SAAwB;QAAhG,iBAAY,GAAZ,YAAY,CAAQ;QAAoD,cAAS,GAAT,SAAS,CAAe;QACnH,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QAC5D,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;IACrE,CAAC;IAED,sBAAI,qCAAI;aAAR;YACE,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC3D,CAAC;;;OAAA;IAGD,sBAAI,iDAAgB;QADpB,WAAW;aACX;YACE,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC;QAC1B,CAAC;;;OAAA;IAMS,4CAAc,GAAxB,UAAyE,GAAM;QAC7E,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAC7C,CAAC;IAED,WAAW;IACL,sCAAQ,GAAd,UAAe,KAAO,EAAE,KAAY,EAAE,YAA0B,EAAE,QAAkB;;;;
|
|
1
|
+
{"version":3,"file":"parameter-definition.class.js","sourceRoot":"ng://@coolon/angular-ui-powerups/","sources":["lib/place/route/parameter-definition.class.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AACpD,OAAO,CAAC,MAAM,QAAQ,CAAC;AAKvB;IASE,6BAAqB,YAAoB,EAAE,OAAuC,EAAW,SAAwB;QAAhG,iBAAY,GAAZ,YAAY,CAAQ;QAAoD,cAAS,GAAT,SAAS,CAAe;QACnH,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QAC5D,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;IACrE,CAAC;IAED,sBAAI,qCAAI;aAAR;YACE,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC3D,CAAC;;;OAAA;IAGD,sBAAI,iDAAgB;QADpB,WAAW;aACX;YACE,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC;QAC1B,CAAC;;;OAAA;IAMS,4CAAc,GAAxB,UAAyE,GAAM;QAC7E,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAC7C,CAAC;IAED,WAAW;IACL,sCAAQ,GAAd,UAAe,KAAO,EAAE,KAAY,EAAE,YAA0B,EAAE,QAAkB,EAAE,UAAmB;;;;gBACvG,IAAI,IAAI,CAAC,aAAa,CAAC,KAAK,CA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,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACxB,CAAC;QAED,mCAAU,GAAV,UAAW,CAAM,EAAE,CAAM;YACvB,OAAO,CAAC,KAAK,CAAC,CAAC;QACjB,CAAC;QACH,qBAAC;IAAD,CAAC,AAXD,CAAuC,mBAAmB,GAWzD;IAXY,kCAAc,iBAW1B,CAAA;IAED;QAAuC,kCAA2B;QAIhE,wBAAY,aAAqB,EAAE,OAAqB,EAAE,SAAuB;YAAjF,YACE,kBAAM,aAAa,EAAE,OAAO,EAAE,SAAS,CAAC,SACzC;YALQ,eAAS,GAAG,KAAK,CAAC;YAClB,aAAO,GAAG,IAAI,CAAC;;QAIxB,CAAC;QAED,qCAAY,GAAZ,UAAa,KAAU;YACrB,OAAO,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;QAC5C,CAAC;QAED,mCAAU,GAAV,UAAW,CAAM,EAAE,CAAM;YACvB,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC1B,CAAC;QAEH,qBAAC;IAAD,CAAC,AAhBD,CAAuC,mBAAmB,GAgBzD;IAhBY,kCAAc,iBAgB1B,CAAA;AACH,CAAC,EArDgB,mBAAmB,KAAnB,mBAAmB,QAqDnC","sourcesContent":["import { Injector } from '@angular/core';\nimport { Trace } from '@coolon/pectin';\nimport { Opts } from '@coolon/typescript-utilities';\nimport _ from 'lodash';\nimport { PlaceHistory } from '../place-history';\nimport { Visit } from '../visit';\nimport { Formatter } from './formatter';\n\nexport abstract class ParameterDefinition<T, E = T> {\n\n abstract readonly isRouteId: boolean;\n abstract readonly isArray: boolean;\n\n readonly remember: boolean;\n readonly defaultValue: T;\n private options: Opts<ParameterDefinition.Options<T>>;\n\n constructor(readonly propertyName: string, options: ParameterDefinition.Options<T>, readonly urlFormat?: Formatter<E>) {\n this.options = Opts.get(options);\n this.remember = this.options.getOptional('remember', false);\n this.defaultValue = this.options.getOptional('defaultValue', null);\n }\n\n get name() {\n return this.options.getOptional('as', this.propertyName);\n }\n\n // @Trace()\n get isRouteParameter(): boolean {\n return !!this.urlFormat;\n }\n\n abstract isEmptyValue(value: T): boolean;\n\n abstract hasChanged(a: any, b: any): boolean;\n\n protected getOptionValue<K extends keyof ParameterDefinition.Options<T>>(key: K): ParameterDefinition.Options<T>[K] {\n return this.options.getOptional(key, null);\n }\n\n // @Trace()\n async sanitise(value:T, visit: Visit, placeHistory: PlaceHistory, injector: Injector, isPopState: boolean) {\n if (this.isMissingFrom(visit)) {\n const returningFromSomewhereElse = !placeHistory.lastVisitIncluded(visit.placeDefinition);\n if (returningFromSomewhereElse) {\n const lastKnownVisit = placeHistory.getMostRecentVisitFor(visit.placeDefinition);\n if (this.remember && lastKnownVisit) {\n value = lastKnownVisit.getParameter(this.name);\n }\n return this.isEmptyValue(value) ? this.defaultValue : value;\n }\n }\n // todo: add custom sanitiser\n return value;\n }\n\n private isMissingFrom(visit: Visit) {\n return !visit.hasParameter(this.name);\n }\n}\n\nexport namespace ParameterDefinition {\n\n export interface Options<T> {\n as?: string;\n optional?: boolean;\n remember?: boolean;\n defaultValue?: T;\n // sanitiser?: Constructable<ParameterSanitiser<T>> | ParameterSanitiser.Options<T>;\n }\n\n export class RouteId<T> extends ParameterDefinition<T> {\n readonly isRouteId = true;\n readonly isArray = false;\n\n isEmptyValue(value: T): boolean {\n return _.isNil(value);\n }\n\n hasChanged(a: any, b: any): boolean {\n return a !== b;\n }\n }\n\n export class ValueParameter<T> extends ParameterDefinition<T> {\n readonly isRouteId = false;\n readonly isArray = false;\n\n isEmptyValue(value: T): boolean {\n return _.isNil(value);\n }\n\n hasChanged(a: any, b: any): boolean {\n return a !== b;\n }\n }\n\n export class ArrayParameter<T> extends ParameterDefinition<T[], T> {\n readonly isRouteId = false;\n readonly isArray = true;\n\n constructor(parameterName: string, options: Options<T[]>, urlFormat: Formatter<T>) {\n super(parameterName, options, urlFormat);\n }\n\n isEmptyValue(value: T[]): boolean {\n return _.isNil(value) || value.length < 1;\n }\n\n hasChanged(a: T[], b: T[]): boolean {\n return !_.isEqual(a, b);\n }\n\n }\n}\n"]}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { __awaiter, __generator } from "tslib";
|
|
1
|
+
import { __awaiter, __decorate, __generator, __metadata } from "tslib";
|
|
2
|
+
import { Trace } from '@coolon/pectin';
|
|
3
|
+
import { Visit } from '../visit';
|
|
2
4
|
var VisitSanitiser = /** @class */ (function () {
|
|
3
|
-
function VisitSanitiser(activatedRoute, router, placeHistory, injector) {
|
|
5
|
+
function VisitSanitiser(navigationSession, activatedRoute, router, placeHistory, injector) {
|
|
6
|
+
this.navigationSession = navigationSession;
|
|
4
7
|
this.activatedRoute = activatedRoute;
|
|
5
8
|
this.router = router;
|
|
6
9
|
this.placeHistory = placeHistory;
|
|
7
10
|
this.injector = injector;
|
|
8
11
|
}
|
|
9
|
-
// @Trace()
|
|
10
12
|
VisitSanitiser.prototype.sanitise = function (visit) {
|
|
11
13
|
return __awaiter(this, void 0, void 0, function () {
|
|
12
14
|
var placeDef, routeIdDef, routeId, sanitisedValue, parameterDefs, sanitisedVisit, i, def, value, sanitisedValue;
|
|
@@ -17,10 +19,10 @@ var VisitSanitiser = /** @class */ (function () {
|
|
|
17
19
|
if (!placeDef.hasRouteId()) return [3 /*break*/, 2];
|
|
18
20
|
routeIdDef = placeDef.getRouteIdParameterDef();
|
|
19
21
|
routeId = visit.getRouteId();
|
|
20
|
-
return [4 /*yield*/, routeIdDef.sanitise(routeId, visit, this.placeHistory, this.injector)];
|
|
22
|
+
return [4 /*yield*/, routeIdDef.sanitise(routeId, visit, this.placeHistory, this.injector, this.navigationSession.isPopState)];
|
|
21
23
|
case 1:
|
|
22
24
|
sanitisedValue = _a.sent();
|
|
23
|
-
|
|
25
|
+
console.log({ routeId: routeId, sanitisedValue: sanitisedValue });
|
|
24
26
|
// ###------- EARLY EXIT --------###
|
|
25
27
|
if (routeIdDef.hasChanged(routeId, sanitisedValue)) {
|
|
26
28
|
// if the route id has changed we redirect immediately as other
|
|
@@ -40,7 +42,7 @@ var VisitSanitiser = /** @class */ (function () {
|
|
|
40
42
|
if (!(i < parameterDefs.length)) return [3 /*break*/, 6];
|
|
41
43
|
def = parameterDefs[i];
|
|
42
44
|
value = visit.getParameter(def.name);
|
|
43
|
-
return [4 /*yield*/, def.sanitise(value, sanitisedVisit, this.placeHistory, this.injector)];
|
|
45
|
+
return [4 /*yield*/, def.sanitise(value, sanitisedVisit, this.placeHistory, this.injector, this.navigationSession.isPopState)];
|
|
44
46
|
case 4:
|
|
45
47
|
sanitisedValue = _a.sent();
|
|
46
48
|
if (def.hasChanged(value, sanitisedValue)) {
|
|
@@ -55,6 +57,12 @@ var VisitSanitiser = /** @class */ (function () {
|
|
|
55
57
|
});
|
|
56
58
|
});
|
|
57
59
|
};
|
|
60
|
+
__decorate([
|
|
61
|
+
Trace(),
|
|
62
|
+
__metadata("design:type", Function),
|
|
63
|
+
__metadata("design:paramtypes", [Visit]),
|
|
64
|
+
__metadata("design:returntype", Promise)
|
|
65
|
+
], VisitSanitiser.prototype, "sanitise", null);
|
|
58
66
|
return VisitSanitiser;
|
|
59
67
|
}());
|
|
60
68
|
export { VisitSanitiser };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"visit-sanitiser.js","sourceRoot":"ng://@coolon/angular-ui-powerups/","sources":["lib/place/route/visit-sanitiser.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"visit-sanitiser.js","sourceRoot":"ng://@coolon/angular-ui-powerups/","sources":["lib/place/route/visit-sanitiser.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGvC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC;IACE,wBAAoB,iBAAoC,EAAU,cAAsC,EAAU,MAAc,EAAU,YAA0B,EAAU,QAAkB;QAA5K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B,qBAAM,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,cAAc,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,EAAA;;wBAA/H,cAAc,GAAG,SAA8G;wBACrI,IAAI,GAAG,CAAC,UAAU,CAAC,KAAK,EAAE,cAAc,CAAC,EAAE;4BACzC,cAAc,GAAG,cAAc,CAAC,OAAO,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;yBAC9D;;;wBANuC,CAAC,EAAE,CAAA;;4BAS7C,sBAAO,cAAc,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,KAAK,EAAC;;;;KACtE;IA/BD;QADC,KAAK,EAAE;;yCACc,KAAK;;kDA+B1B;IAEH,qBAAC;CAAA,AAvCD,IAuCC;SAvCY,cAAc","sourcesContent":["import { Injector } from '@angular/core';\nimport { ActivatedRouteSnapshot, Router } from '@angular/router';\nimport { Trace } from '@coolon/pectin';\nimport { NavigationSession } from '../navigation/session/navigation-session';\nimport { PlaceHistory } from '../place-history';\nimport { Visit } from '../visit';\n\nexport class VisitSanitiser {\n constructor(private navigationSession: NavigationSession, private activatedRoute: ActivatedRouteSnapshot, private router: Router, private placeHistory: PlaceHistory, private injector: Injector) {\n\n }\n\n @Trace()\n async sanitise(visit: Visit): Promise<Visit> {\n const placeDef = visit.placeDefinition;\n if (placeDef.hasRouteId()) {\n const routeIdDef = placeDef.getRouteIdParameterDef();\n const routeId = visit.getRouteId();\n const sanitisedValue = await routeIdDef.sanitise(routeId, visit, this.placeHistory, this.injector, this.navigationSession.isPopState);\n console.log({routeId, sanitisedValue});\n // ###------- EARLY EXIT --------###\n if (routeIdDef.hasChanged(routeId, sanitisedValue)) {\n // if the route id has changed we redirect immediately as other\n // parameter sanitisers might use it.\n return visit.replace(routeIdDef, sanitisedValue);\n }\n }\n\n // if we didn't replace the routeId we continue the url present parameters.\n const parameterDefs = placeDef.getVisitParameterDefs({\n includeRouteParameters: true,\n includeNonRouteParameters: true\n });\n let sanitisedVisit: Visit = visit;\n for (let i = 0; i < parameterDefs.length; i++) {\n const def = parameterDefs[i];\n const value = visit.getParameter(def.name);\n const sanitisedValue = await def.sanitise(value, sanitisedVisit, this.placeHistory, this.injector, this.navigationSession.isPopState);\n if (def.hasChanged(value, sanitisedValue)) {\n sanitisedVisit = sanitisedVisit.replace(def, sanitisedValue);\n }\n }\n\n return sanitisedVisit.hasChangedFrom(visit) ? sanitisedVisit : visit;\n }\n\n}\n"]}
|