@coolon/angular-ui-powerups 12.4.0-alpha.37 → 12.4.0-alpha.38
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/assets/styles.scss +1 -12
- package/bundles/coolon-angular-ui-powerups.umd.js +3 -3
- package/bundles/coolon-angular-ui-powerups.umd.js.map +1 -1
- package/coolon-angular-ui-powerups.metadata.json +1 -1
- package/esm2015/lib/place/guards/consolidated-param-map.js +2 -1
- package/esm2015/lib/place/guards/consolidated-param-map.js.map +1 -1
- package/esm2015/lib/place/guards/consolidated-param-map.metadata.json +1 -1
- package/esm2015/lib/place/guards/place.guard.js +2 -1
- package/esm2015/lib/place/guards/place.guard.js.map +1 -1
- package/fesm2015/coolon-angular-ui-powerups.js +3 -2
- package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
|
2
2
|
import { Memoize } from '@typescript-plus/fast-memoize-decorator/dist/src';
|
|
3
|
+
import * as _ from 'lodash';
|
|
3
4
|
/**
|
|
4
5
|
* This a work around for the fact that an activated route with multiple segments doesn't
|
|
5
6
|
* include the segment params in the paramMap as well as each segment returns an empty
|
|
@@ -26,7 +27,7 @@ export class ConsolidatedParameterMap {
|
|
|
26
27
|
return !!this.paramMaps.find(m => m.has(name));
|
|
27
28
|
}
|
|
28
29
|
get keys() {
|
|
29
|
-
return this.paramMaps.reduce((result, params) => result.concat(params.keys), []);
|
|
30
|
+
return _.uniq(this.paramMaps.reduce((result, params) => result.concat(params.keys), []));
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
33
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consolidated-param-map.js","sourceRoot":"","sources":["../../../../../../../libs/angular-ui-powerups/src/lib/place/guards/consolidated-param-map.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,kDAAkD,CAAC;
|
|
1
|
+
{"version":3,"file":"consolidated-param-map.js","sourceRoot":"","sources":["../../../../../../../libs/angular-ui-powerups/src/lib/place/guards/consolidated-param-map.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,kDAAkD,CAAC;AAC3E,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAE5B;;;;GAIG;AACH,MAAM,OAAO,wBAAwB;IAInC,YAAY,WAAyB,EAAE,QAAmB;QAFzC,cAAS,GAAe,EAAE,CAAC;QAG1C,oGAAoG;QACpG,MAAM,aAAa,GAAG,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,eAAe,CAAC,CAAC,CAAC,UAAU,CAAC,CAAe,CAAC;QACpG,IAAI,CAAC,SAAS,GAAG,aAAa;aAC3B,MAAM,CAAC,QAAQ,CAAC;aAChB,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,4CAA4C;IACnE,CAAC;IAED,GAAG,CAAC,IAAY;QACd,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;QACvD,OAAO,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAED,MAAM,CAAC,IAAY;QACjB,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;QACvD,OAAO,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,GAAG,CAAC,IAAY;QACd,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IACjD,CAAC;IAGD,IAAI,IAAI;QACN,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IAC3F,CAAC;CACF;AAHC;IADC,OAAO,EAAE;;;oDAGT;AAGH,MAAM,eAAe;IACnB,YAA6B,MAA+B;QAA/B,WAAM,GAAN,MAAM,CAAyB;IAC5D,CAAC;IAED,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IAED,MAAM,CAAC,IAAY;QACjB,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC7B,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAChD,CAAC;IAED,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;IAED,IAAI,IAAI;QACN,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;CAEF","sourcesContent":["import { ParamMap, UrlSegment } from '@angular/router';\nimport { Memoize } from '@typescript-plus/fast-memoize-decorator/dist/src';\nimport * as _ from 'lodash';\n\n/**\n * This a work around for the fact that an activated route with multiple segments doesn't\n * include the segment params in the paramMap as well as each segment returns an empty\n * param map even when `parameter`s has content.\n */\nexport class ConsolidatedParameterMap implements ParamMap {\n\n private readonly paramMaps: ParamMap[] = [];\n\n constructor(urlSegments: UrlSegment[], paramMap?: ParamMap) {\n // TODO: can we get all our params from teh url segments? If so we can drop the paramMap altogether.\n const segmentParams = (urlSegments || []).map(s => new ParamMapAdapter(s.parameters)) as ParamMap[];\n this.paramMaps = segmentParams\n .concat(paramMap)\n .filter(m => !!m); // the activated route param map can be null\n }\n\n get(name: string): string | null {\n const paramMap = this.paramMaps.find(m => m.has(name));\n return paramMap.get(name);\n }\n\n getAll(name: string): string[] {\n const paramMap = this.paramMaps.find(m => m.has(name));\n return paramMap.getAll(name);\n }\n\n has(name: string): boolean {\n return !!this.paramMaps.find(m => m.has(name));\n }\n\n @Memoize()\n get keys(): string[] {\n return _.uniq(this.paramMaps.reduce((result, params) => result.concat(params.keys), []));\n }\n}\n\nclass ParamMapAdapter implements ParamMap {\n constructor(private readonly params: { [p: string]: string }) {\n }\n\n get(name: string): string | null {\n return this.params[name];\n }\n\n getAll(name: string): string[] {\n const value = this.get(name);\n return Array.isArray(value) ? value : [value];\n }\n\n has(name: string): boolean {\n return this.keys.includes(name);\n }\n\n get keys(): string[] {\n return Object.keys(this.params);\n }\n\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"__symbolic":"module","version":4,"metadata":{"ConsolidatedParameterMap":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"reference","module":"@angular/router","name":"UrlSegment","line":
|
|
1
|
+
[{"__symbolic":"module","version":4,"metadata":{"ConsolidatedParameterMap":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"reference","module":"@angular/router","name":"UrlSegment","line":13,"character":27}]},{"__symbolic":"reference","module":"@angular/router","name":"ParamMap","line":13,"character":52}]}],"get":[{"__symbolic":"method"}],"getAll":[{"__symbolic":"method"}],"has":[{"__symbolic":"method"}],"keys":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@typescript-plus/fast-memoize-decorator/dist/src","name":"Memoize","line":35,"character":3}}]}]}}}}]
|
|
@@ -42,10 +42,11 @@ export class PlaceGuard {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
const result = yield this.cleanInteractionState(activatedRoute, state, () => __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
const navigationSession = this.placeRouter.navigationSession;
|
|
45
46
|
// Parse our route params.
|
|
46
47
|
const params = new ConsolidatedParameterMap(activatedRoute.url, activatedRoute.paramMap);
|
|
48
|
+
// console.log("RouteParams", params)
|
|
47
49
|
const parsedParams = placeDefinition.parseRouteParams(params);
|
|
48
|
-
const navigationSession = this.placeRouter.navigationSession;
|
|
49
50
|
const initialVisit = navigationSession.getVisitFor(placeDefinition) || new Visit(placeDefinition, parsedParams);
|
|
50
51
|
const sanitiser = new VisitSanitiser(navigationSession, activatedRoute, this.router, this.placeHistory, this.injector);
|
|
51
52
|
const sanitisedVisit = yield sanitiser.sanitise(initialVisit.mergeRouteParameters(parsedParams));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"place.guard.js","sourceRoot":"","sources":["../../../../../../../libs/angular-ui-powerups/src/lib/place/guards/place.guard.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAIL,MAAM,EAGP,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAiB,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gDAAgD,CAAC;AACpF,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OA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;oBAChF,0BAA0B;oBAC1B,MAAM,MAAM,GAAG,IAAI,wBAAwB,CAAC,cAAc,CAAC,GAAG,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAC;oBACzF,MAAM,YAAY,GAAG,eAAe,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"place.guard.js","sourceRoot":"","sources":["../../../../../../../libs/angular-ui-powerups/src/lib/place/guards/place.guard.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAIL,MAAM,EAGP,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAiB,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gDAAgD,CAAC;AACpF,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;;;;;;;AAGpE,MAAM,OAAO,UAAU;IAGrB,YAA6B,MAAc,EACvB,UAAsB,EACb,WAAwB,EACxB,YAA0B,EAC1B,kBAAsC,EACtC,QAAkB;QALlB,WAAM,GAAN,MAAM,CAAQ;QACvB,eAAU,GAAV,UAAU,CAAY;QACb,gBAAW,GAAX,WAAW,CAAa;QACxB,iBAAY,GAAZ,YAAY,CAAc;QAC1B,uBAAkB,GAAlB,kBAAkB,CAAoB;QACtC,aAAQ,GAAR,QAAQ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edRouteSnapshot,\n CanActivate,\n CanDeactivate,\n Router,\n RouterStateSnapshot,\n UrlTree\n} from '@angular/router';\nimport { Constructable, lang } from '@coolon/pectin';\nimport { InteractionService } from '../../interaction/services/interaction.service';\nimport { PlaceComponent } from '../place-component';\nimport { PlaceDefinition } from '../place-definition';\nimport { PlaceHistory } from '../place-history';\nimport { PlaceRouter } from '../place-router';\nimport { VisitSanitiser } from '../route/visit-sanitiser';\nimport { UrlService } from '../url-service';\nimport { UrlSnapshot } from '../url-snapshot';\nimport { Visit } from '../visit';\nimport { ConsolidatedParameterMap } from './consolidated-param-map';\n\n@Injectable({ providedIn: 'root' })\nexport class PlaceGuard implements CanActivate, CanDeactivate<PlaceComponent> {\n\n\n constructor(private readonly router: Router,\n private urlService: UrlService,\n private readonly placeRouter: PlaceRouter,\n private readonly placeHistory: PlaceHistory,\n private readonly interactionService: InteractionService,\n private readonly injector: Injector) {\n }\n\n // @Trace()\n async canActivate(activatedRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean | UrlTree> {\n\n if (PlaceComponent.isPlaceComponentConstructor(activatedRoute.component)) {\n const placeDefinition = PlaceComponent.getDefinition(activatedRoute.component);\n\n if (placeDefinition.authenticate) {\n\n if (!await this.placeRouter.accessGuard.value.isAuthenticated()) {\n const redirectLocation = this.placeRouter.getAuthenticationFailureRedirect(activatedRoute, state);\n const nextPlaceDef = this.getPlaceDefinition(redirectLocation);\n if (nextPlaceDef.authenticate) {\n lang.illegalState(`handleNotAuthenticated hook returned place ${nextPlaceDef.component.name} that requires authentication.`);\n }\n return this.createUrlTree(redirectLocation);\n }\n }\n\n const result = await this.cleanInteractionState(activatedRoute, state, async () => {\n const navigationSession = this.placeRouter.navigationSession;\n\n // Parse our route params.\n const params = new ConsolidatedParameterMap(activatedRoute.url, activatedRoute.paramMap);\n // console.log(\"RouteParams\", params)\n const parsedParams = placeDefinition.parseRouteParams(params);\n const initialVisit = navigationSession.getVisitFor(placeDefinition) || new Visit(placeDefinition, parsedParams);\n\n const sanitiser = new VisitSanitiser(navigationSession, activatedRoute, this.router, this.placeHistory, this.injector);\n const sanitisedVisit = await sanitiser.sanitise(initialVisit.mergeRouteParameters(parsedParams));\n\n // Save the visit with any updated parameters. We need to save it so we remember any non route parameters\n navigationSession.storeVisit(sanitisedVisit);\n if (initialVisit.hasRoutingChangedFrom(sanitisedVisit)) {\n // Regenerate the url\n const urlSnapshot = this.urlService.parseUrl(state.url).updateVisitSegments(sanitisedVisit);\n // console.log('##### Place Guard Redirect', urlSnapshot);\n return urlSnapshot;\n } else {\n return true;\n }\n });\n return result instanceof UrlSnapshot ? result.urlTree : result;\n\n } else {\n return lang.illegalState(`expected component to be an instance of PlaceComponent, got ${activatedRoute.component}`);\n }\n }\n\n // @Trace()\n async canDeactivate(component: PlaceComponent, currentRoute: ActivatedRouteSnapshot, currentState: RouterStateSnapshot, nextState?: RouterStateSnapshot): Promise<boolean | UrlTree> {\n if (!component) {\n // this happens when the place wasn't authorised and the associated\n // router outlet was removed from the dom.\n return true;\n }\n const currentUrl = this.urlService.parseUrl(currentState.url);\n const nextUrl = this.urlService.parseUrl(nextState.url);\n const result = await this.placeRouter.navigationSession.canDeactivatePlace(component, currentUrl, nextUrl);\n return result instanceof UrlSnapshot ? result.urlTree : result;\n }\n\n private getPlaceDefinition(result: Constructable<PlaceComponent> | Visit): PlaceDefinition {\n return result instanceof Visit ?\n result.placeDefinition :\n PlaceComponent.getDefinition(result);\n }\n\n private createUrlTree(result: Constructable<PlaceComponent> | Visit) {\n const visit = result instanceof Visit ? result : new Visit(PlaceComponent.getDefinition(result), {});\n return this.urlService.createUrlSnapshot(visit).urlTree;\n }\n\n // @Trace()\n async cleanInteractionState(route: ActivatedRouteSnapshot, state: RouterStateSnapshot, next: () => Promise<boolean | UrlSnapshot>): Promise<boolean | UrlSnapshot> {\n const url = this.urlService.parseUrl(state.url);\n if (!this.interactionService.isActive() && url.hasInteractions()) {\n // This happens if we reload the page or the url was pasted as the route should only be activated\n // after the interaction context has become active.\n return url.removeInteractionIds();\n } else {\n return next();\n }\n }\n\n}\n"]}
|
|
@@ -7377,7 +7377,7 @@ class ConsolidatedParameterMap {
|
|
|
7377
7377
|
return !!this.paramMaps.find(m => m.has(name));
|
|
7378
7378
|
}
|
|
7379
7379
|
get keys() {
|
|
7380
|
-
return this.paramMaps.reduce((result, params) => result.concat(params.keys), []);
|
|
7380
|
+
return _.uniq(this.paramMaps.reduce((result, params) => result.concat(params.keys), []));
|
|
7381
7381
|
}
|
|
7382
7382
|
}
|
|
7383
7383
|
__decorate([
|
|
@@ -8703,10 +8703,11 @@ class PlaceGuard {
|
|
|
8703
8703
|
}
|
|
8704
8704
|
}
|
|
8705
8705
|
const result = yield this.cleanInteractionState(activatedRoute, state, () => __awaiter(this, void 0, void 0, function* () {
|
|
8706
|
+
const navigationSession = this.placeRouter.navigationSession;
|
|
8706
8707
|
// Parse our route params.
|
|
8707
8708
|
const params = new ConsolidatedParameterMap(activatedRoute.url, activatedRoute.paramMap);
|
|
8709
|
+
// console.log("RouteParams", params)
|
|
8708
8710
|
const parsedParams = placeDefinition.parseRouteParams(params);
|
|
8709
|
-
const navigationSession = this.placeRouter.navigationSession;
|
|
8710
8711
|
const initialVisit = navigationSession.getVisitFor(placeDefinition) || new Visit(placeDefinition, parsedParams);
|
|
8711
8712
|
const sanitiser = new VisitSanitiser(navigationSession, activatedRoute, this.router, this.placeHistory, this.injector);
|
|
8712
8713
|
const sanitisedVisit = yield sanitiser.sanitise(initialVisit.mergeRouteParameters(parsedParams));
|