@coolon/angular-ui-powerups 0.0.26 → 0.0.28
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 +3930 -0
- package/bundles/coolon-angular-ui-powerups.umd.js.map +1 -0
- package/bundles/coolon-angular-ui-powerups.umd.min.js +2 -0
- package/bundles/coolon-angular-ui-powerups.umd.min.js.map +1 -0
- package/coolon-angular-ui-powerups.d.ts +30 -0
- package/coolon-angular-ui-powerups.metadata.json +1 -0
- package/esm2015/coolon-angular-ui-powerups.js +33 -0
- package/esm2015/index.js +6 -0
- package/esm2015/lib/angular-ui-powerups.module.js +54 -0
- package/esm2015/lib/animations/index.js +9 -0
- package/esm2015/lib/animations/slideDownAndUpAnimation.js +30 -0
- package/esm2015/lib/components/disposable-component.js +14 -0
- package/esm2015/lib/components/forms/abstract-input.component.js +183 -0
- package/esm2015/lib/components/forms/number-input/number-input.component.js +26 -0
- package/esm2015/lib/components/forms/password-input/password-input.component.js +26 -0
- package/esm2015/lib/components/forms/select-input/select-input.component.js +60 -0
- package/esm2015/lib/components/forms/string-input/string-input.component.js +26 -0
- package/esm2015/lib/components/index.js +18 -0
- package/esm2015/lib/components/resize-aware.component.js +96 -0
- package/esm2015/lib/components/types/bounds.class.js +56 -0
- package/esm2015/lib/components/types/dimension.class.js +21 -0
- package/esm2015/lib/components/types/point.class.js +36 -0
- package/esm2015/lib/directives/command.directive.js +135 -0
- package/esm2015/lib/directives/focus-binding.directive.js +179 -0
- package/esm2015/lib/directives/index.js +10 -0
- package/esm2015/lib/interaction/abstract-activity.js +129 -0
- package/esm2015/lib/interaction/activity.js +27 -0
- package/esm2015/lib/interaction/alert.js +23 -0
- package/esm2015/lib/interaction/components/activity-container/activity-container.component.js +144 -0
- package/esm2015/lib/interaction/components/activity-outlet/activity-outlet-context.js +22 -0
- package/esm2015/lib/interaction/components/activity-outlet/activity-outlet.component.js +169 -0
- package/esm2015/lib/interaction/components/alert-dialog/alert-dialog.component.js +37 -0
- package/esm2015/lib/interaction/components/confirmation-dialog/confirmation-dialog.component.js +46 -0
- package/esm2015/lib/interaction/confirm.js +17 -0
- package/esm2015/lib/interaction/index.js +21 -0
- package/esm2015/lib/interaction/interaction-context.js +35 -0
- package/esm2015/lib/interaction/interaction.module.js +41 -0
- package/esm2015/lib/interaction/result.js +24 -0
- package/esm2015/lib/interaction/services/dialog-interaction.service.js +114 -0
- package/esm2015/lib/place/abstract-place-component.js +59 -0
- package/esm2015/lib/place/components/busy-overlay/busy-overlay.component.js +44 -0
- package/esm2015/lib/place/components/empty-state/empty-state.component.js +28 -0
- package/esm2015/lib/place/components/place-outlet/place-outlet.component.js +67 -0
- package/esm2015/lib/place/components/place-outlet/route-animations.js +35 -0
- package/esm2015/lib/place/components/tabbed-place-navigation/tabbed-place-navigation.component.js +50 -0
- package/esm2015/lib/place/guards/leave-place.guard.js +52 -0
- package/esm2015/lib/place/guards/place-route.guard.js +74 -0
- package/esm2015/lib/place/index.js +27 -0
- package/esm2015/lib/place/place-component.js +17 -0
- package/esm2015/lib/place/place.decorator.js +72 -0
- package/esm2015/lib/place/place.module.js +49 -0
- package/esm2015/lib/place/place.service.js +61 -0
- package/esm2015/lib/place/route/json-types.js +13 -0
- package/esm2015/lib/place/route/parameter-decorators.js +182 -0
- package/esm2015/lib/place/route/parameter-definition.class.js +24 -0
- package/esm2015/lib/place/route/parameter-sanitiser.js +17 -0
- package/esm2015/lib/place/route/parameter-type.js +43 -0
- package/esm2015/lib/place/route/route-parameter-bindings.js +294 -0
- package/esm2015/lib/place/route/route-parameter-sanitiser.js +280 -0
- package/esm2015/public_api.js +11 -0
- package/esm5/coolon-angular-ui-powerups.js +33 -0
- package/esm5/index.js +6 -0
- package/esm5/lib/angular-ui-powerups.module.js +58 -0
- package/esm5/lib/animations/index.js +9 -0
- package/esm5/lib/animations/slideDownAndUpAnimation.js +30 -0
- package/esm5/lib/components/disposable-component.js +24 -0
- package/esm5/lib/components/forms/abstract-input.component.js +232 -0
- package/esm5/lib/components/forms/number-input/number-input.component.js +33 -0
- package/esm5/lib/components/forms/password-input/password-input.component.js +33 -0
- package/esm5/lib/components/forms/select-input/select-input.component.js +67 -0
- package/esm5/lib/components/forms/string-input/string-input.component.js +33 -0
- package/esm5/lib/components/index.js +18 -0
- package/esm5/lib/components/resize-aware.component.js +124 -0
- package/esm5/lib/components/types/bounds.class.js +59 -0
- package/esm5/lib/components/types/dimension.class.js +19 -0
- package/esm5/lib/components/types/point.class.js +43 -0
- package/esm5/lib/directives/command.directive.js +155 -0
- package/esm5/lib/directives/focus-binding.directive.js +231 -0
- package/esm5/lib/directives/index.js +10 -0
- package/esm5/lib/interaction/abstract-activity.js +173 -0
- package/esm5/lib/interaction/activity.js +27 -0
- package/esm5/lib/interaction/alert.js +23 -0
- package/esm5/lib/interaction/components/activity-container/activity-container.component.js +181 -0
- package/esm5/lib/interaction/components/activity-outlet/activity-outlet-context.js +22 -0
- package/esm5/lib/interaction/components/activity-outlet/activity-outlet.component.js +206 -0
- package/esm5/lib/interaction/components/alert-dialog/alert-dialog.component.js +42 -0
- package/esm5/lib/interaction/components/confirmation-dialog/confirmation-dialog.component.js +54 -0
- package/esm5/lib/interaction/confirm.js +17 -0
- package/esm5/lib/interaction/index.js +21 -0
- package/esm5/lib/interaction/interaction-context.js +45 -0
- package/esm5/lib/interaction/interaction.module.js +45 -0
- package/esm5/lib/interaction/result.js +24 -0
- package/esm5/lib/interaction/services/dialog-interaction.service.js +140 -0
- package/esm5/lib/place/abstract-place-component.js +66 -0
- package/esm5/lib/place/components/busy-overlay/busy-overlay.component.js +49 -0
- package/esm5/lib/place/components/empty-state/empty-state.component.js +29 -0
- package/esm5/lib/place/components/place-outlet/place-outlet.component.js +81 -0
- package/esm5/lib/place/components/place-outlet/route-animations.js +35 -0
- package/esm5/lib/place/components/tabbed-place-navigation/tabbed-place-navigation.component.js +57 -0
- package/esm5/lib/place/guards/leave-place.guard.js +57 -0
- package/esm5/lib/place/guards/place-route.guard.js +78 -0
- package/esm5/lib/place/index.js +27 -0
- package/esm5/lib/place/place-component.js +17 -0
- package/esm5/lib/place/place.decorator.js +69 -0
- package/esm5/lib/place/place.module.js +53 -0
- package/esm5/lib/place/place.service.js +75 -0
- package/esm5/lib/place/route/json-types.js +13 -0
- package/esm5/lib/place/route/parameter-decorators.js +182 -0
- package/esm5/lib/place/route/parameter-definition.class.js +24 -0
- package/esm5/lib/place/route/parameter-sanitiser.js +17 -0
- package/esm5/lib/place/route/parameter-type.js +65 -0
- package/esm5/lib/place/route/route-parameter-bindings.js +339 -0
- package/esm5/lib/place/route/route-parameter-sanitiser.js +395 -0
- package/esm5/public_api.js +11 -0
- package/fesm2015/coolon-angular-ui-powerups.js +3149 -0
- package/fesm2015/coolon-angular-ui-powerups.js.map +1 -0
- package/fesm5/coolon-angular-ui-powerups.js +3703 -0
- package/fesm5/coolon-angular-ui-powerups.js.map +1 -0
- package/lib/angular-ui-powerups.module.d.ts +2 -0
- package/{src/lib/animations/index.ts → lib/animations/index.d.ts} +0 -1
- package/lib/animations/slideDownAndUpAnimation.d.ts +5 -0
- package/lib/components/disposable-component.d.ts +5 -0
- package/lib/components/forms/abstract-input.component.d.ts +35 -0
- package/lib/components/forms/number-input/number-input.component.d.ts +6 -0
- package/lib/components/forms/password-input/password-input.component.d.ts +6 -0
- package/lib/components/forms/select-input/select-input.component.d.ts +11 -0
- package/lib/components/forms/string-input/string-input.component.d.ts +6 -0
- package/{src/lib/components/index.ts → lib/components/index.d.ts} +0 -1
- package/lib/components/resize-aware.component.d.ts +22 -0
- package/lib/components/types/bounds.class.d.ts +16 -0
- package/lib/components/types/dimension.class.d.ts +5 -0
- package/lib/components/types/point.class.d.ts +10 -0
- package/lib/directives/command.directive.d.ts +14 -0
- package/lib/directives/focus-binding.directive.d.ts +22 -0
- package/{src/lib/directives/index.ts → lib/directives/index.d.ts} +0 -1
- package/lib/interaction/abstract-activity.d.ts +17 -0
- package/lib/interaction/activity.d.ts +11 -0
- package/lib/interaction/alert.d.ts +5 -0
- package/lib/interaction/components/activity-container/activity-container.component.d.ts +32 -0
- package/{src/lib/interaction/components/activity-outlet/activity-outlet-context.ts → lib/interaction/components/activity-outlet/activity-outlet-context.d.ts} +5 -7
- package/lib/interaction/components/activity-outlet/activity-outlet.component.d.ts +30 -0
- package/lib/interaction/components/alert-dialog/alert-dialog.component.d.ts +8 -0
- package/lib/interaction/components/confirmation-dialog/confirmation-dialog.component.d.ts +9 -0
- package/{src/lib/interaction/confirm.ts → lib/interaction/confirm.d.ts} +2 -3
- package/{src/lib/interaction/index.ts → lib/interaction/index.d.ts} +0 -1
- package/lib/interaction/interaction-context.d.ts +11 -0
- package/lib/interaction/interaction.module.d.ts +2 -0
- package/lib/interaction/result.d.ts +8 -0
- package/lib/interaction/services/dialog-interaction.service.d.ts +14 -0
- package/lib/place/abstract-place-component.d.ts +13 -0
- package/lib/place/components/busy-overlay/busy-overlay.component.d.ts +8 -0
- package/lib/place/components/empty-state/empty-state.component.d.ts +5 -0
- package/lib/place/components/place-outlet/place-outlet.component.d.ts +13 -0
- package/lib/place/components/place-outlet/route-animations.d.ts +1 -0
- package/lib/place/components/tabbed-place-navigation/tabbed-place-navigation.component.d.ts +11 -0
- package/lib/place/guards/leave-place.guard.d.ts +10 -0
- package/lib/place/guards/place-route.guard.d.ts +9 -0
- package/{src/lib/place/index.ts → lib/place/index.d.ts} +0 -1
- package/lib/place/place-component.d.ts +5 -0
- package/lib/place/place.decorator.d.ts +20 -0
- package/lib/place/place.module.d.ts +2 -0
- package/lib/place/place.service.d.ts +8 -0
- package/lib/place/route/json-types.d.ts +7 -0
- package/lib/place/route/parameter-decorators.d.ts +28 -0
- package/lib/place/route/parameter-definition.class.d.ts +11 -0
- package/{src/lib/place/route/parameter-sanitiser.ts → lib/place/route/parameter-sanitiser.d.ts} +1 -1
- package/lib/place/route/parameter-type.d.ts +16 -0
- package/lib/place/route/route-parameter-bindings.d.ts +18 -0
- package/lib/place/route/route-parameter-sanitiser.d.ts +42 -0
- package/package.json +14 -12
- package/schematics/ng-add/index.d.ts +2 -0
- package/schematics/ng-add/index.js +12 -0
- package/schematics/ng-add/index.js.map +1 -0
- package/schematics/place-routes/index.d.ts +3 -0
- package/schematics/place-routes/index.js +114 -0
- package/schematics/place-routes/index.js.map +1 -0
- package/schematics/place-routes/place-def.d.ts +37 -0
- package/schematics/place-routes/place-def.js +108 -0
- package/schematics/place-routes/place-def.js.map +1 -0
- package/schematics/place-routes/scanner.d.ts +38 -0
- package/schematics/place-routes/scanner.js +169 -0
- package/schematics/place-routes/scanner.js.map +1 -0
- package/schematics/place-routes/schema.d.ts +7 -0
- package/schematics/place-routes/schema.js +3 -0
- package/schematics/place-routes/schema.js.map +1 -0
- package/schematics/place-routes/templates/{services/place-router.service.ts.template → place-router.ts.template} +13 -18
- package/CHANGELOG.md +0 -7
- package/jest.config.js +0 -9
- package/ng-package.json +0 -13
- package/schematics/ng-add/index.ts +0 -10
- package/schematics/place-routes/index.ts +0 -152
- package/schematics/place-routes/place-def.ts +0 -93
- package/schematics/place-routes/scanner.ts +0 -145
- package/schematics/place-routes/schema.ts +0 -7
- package/src/lib/angular-ui-powerups.module.spec.ts +0 -14
- package/src/lib/angular-ui-powerups.module.ts +0 -49
- package/src/lib/animations/slideDownAndUpAnimation.ts +0 -39
- package/src/lib/components/disposable-component.ts +0 -9
- package/src/lib/components/forms/abstract-input.component.ts +0 -108
- package/src/lib/components/forms/number-input/number-input.component.html +0 -15
- package/src/lib/components/forms/number-input/number-input.component.scss +0 -3
- package/src/lib/components/forms/number-input/number-input.component.spec.ts +0 -25
- package/src/lib/components/forms/number-input/number-input.component.ts +0 -19
- package/src/lib/components/forms/password-input/password-input.component.html +0 -16
- package/src/lib/components/forms/password-input/password-input.component.scss +0 -3
- package/src/lib/components/forms/password-input/password-input.component.spec.ts +0 -25
- package/src/lib/components/forms/password-input/password-input.component.ts +0 -18
- package/src/lib/components/forms/scss/mixins.scss +0 -16
- package/src/lib/components/forms/select-input/select-input.component.html +0 -16
- package/src/lib/components/forms/select-input/select-input.component.scss +0 -7
- package/src/lib/components/forms/select-input/select-input.component.spec.ts +0 -25
- package/src/lib/components/forms/select-input/select-input.component.ts +0 -31
- package/src/lib/components/forms/string-input/string-input.component.html +0 -15
- package/src/lib/components/forms/string-input/string-input.component.scss +0 -3
- package/src/lib/components/forms/string-input/string-input.component.spec.ts +0 -25
- package/src/lib/components/forms/string-input/string-input.component.ts +0 -18
- package/src/lib/components/resize-aware.component.ts +0 -52
- package/src/lib/components/types/bounds.class.ts +0 -25
- package/src/lib/components/types/dimension.class.ts +0 -3
- package/src/lib/components/types/point.class.ts +0 -13
- package/src/lib/directives/command.directive.spec.ts +0 -73
- package/src/lib/directives/command.directive.ts +0 -81
- package/src/lib/directives/focus-binding.directive.spec.ts +0 -8
- package/src/lib/directives/focus-binding.directive.ts +0 -108
- package/src/lib/interaction/abstract-activity.ts +0 -57
- package/src/lib/interaction/activity.ts +0 -17
- package/src/lib/interaction/alert.ts +0 -6
- package/src/lib/interaction/components/activity-container/activity-container.component.html +0 -8
- package/src/lib/interaction/components/activity-container/activity-container.component.scss +0 -3
- package/src/lib/interaction/components/activity-container/activity-container.component.spec.ts +0 -25
- package/src/lib/interaction/components/activity-container/activity-container.component.ts +0 -93
- package/src/lib/interaction/components/activity-outlet/activity-outlet.component.scss +0 -3
- package/src/lib/interaction/components/activity-outlet/activity-outlet.component.spec.ts +0 -25
- package/src/lib/interaction/components/activity-outlet/activity-outlet.component.ts +0 -96
- package/src/lib/interaction/components/alert-dialog/alert-dialog.component.html +0 -7
- package/src/lib/interaction/components/alert-dialog/alert-dialog.component.scss +0 -7
- package/src/lib/interaction/components/alert-dialog/alert-dialog.component.spec.ts +0 -25
- package/src/lib/interaction/components/alert-dialog/alert-dialog.component.ts +0 -20
- package/src/lib/interaction/components/confirmation-dialog/confirmation-dialog.component.html +0 -9
- package/src/lib/interaction/components/confirmation-dialog/confirmation-dialog.component.scss +0 -8
- package/src/lib/interaction/components/confirmation-dialog/confirmation-dialog.component.spec.ts +0 -25
- package/src/lib/interaction/components/confirmation-dialog/confirmation-dialog.component.ts +0 -26
- package/src/lib/interaction/interaction-context.ts +0 -16
- package/src/lib/interaction/interaction.module.ts +0 -35
- package/src/lib/interaction/result.ts +0 -16
- package/src/lib/interaction/services/dialog-interaction.service.scss +0 -11
- package/src/lib/interaction/services/dialog-interaction.service.spec.ts +0 -12
- package/src/lib/interaction/services/dialog-interaction.service.ts +0 -63
- package/src/lib/place/abstract-place-component.ts +0 -33
- package/src/lib/place/components/busy-overlay/busy-overlay.component.html +0 -4
- package/src/lib/place/components/busy-overlay/busy-overlay.component.scss +0 -27
- package/src/lib/place/components/busy-overlay/busy-overlay.component.spec.ts +0 -25
- package/src/lib/place/components/busy-overlay/busy-overlay.component.ts +0 -23
- package/src/lib/place/components/empty-state/empty-state.component.scss +0 -15
- package/src/lib/place/components/empty-state/empty-state.component.spec.ts +0 -25
- package/src/lib/place/components/empty-state/empty-state.component.ts +0 -19
- package/src/lib/place/components/place-outlet/place-outlet.component.html +0 -7
- package/src/lib/place/components/place-outlet/place-outlet.component.scss +0 -12
- package/src/lib/place/components/place-outlet/place-outlet.component.spec.ts +0 -25
- package/src/lib/place/components/place-outlet/place-outlet.component.ts +0 -37
- package/src/lib/place/components/place-outlet/route-animations.ts +0 -30
- package/src/lib/place/components/tabbed-place-navigation/tabbed-place-navigation.component.html +0 -7
- package/src/lib/place/components/tabbed-place-navigation/tabbed-place-navigation.component.scss +0 -100
- package/src/lib/place/components/tabbed-place-navigation/tabbed-place-navigation.component.spec.ts +0 -25
- package/src/lib/place/components/tabbed-place-navigation/tabbed-place-navigation.component.ts +0 -30
- package/src/lib/place/guards/leave-place.guard.spec.ts +0 -15
- package/src/lib/place/guards/leave-place.guard.ts +0 -18
- package/src/lib/place/guards/place-route.guard.ts +0 -37
- package/src/lib/place/place-component.ts +0 -6
- package/src/lib/place/place.decorator.ts +0 -40
- package/src/lib/place/place.module.ts +0 -44
- package/src/lib/place/place.service.spec.ts +0 -12
- package/src/lib/place/place.service.ts +0 -29
- package/src/lib/place/route/json-types.ts +0 -5
- package/src/lib/place/route/parameter-decorators.ts +0 -99
- package/src/lib/place/route/parameter-definition.class.ts +0 -12
- package/src/lib/place/route/parameter-type.ts +0 -31
- package/src/lib/place/route/route-parameter-bindings.ts +0 -140
- package/src/lib/place/route/route-parameter-sanitiser.ts +0 -135
- package/src/test-setup.ts +0 -1
- package/tsconfig.json +0 -7
- package/tsconfig.lib.json +0 -20
- package/tsconfig.schematics.json +0 -35
- package/tsconfig.spec.json +0 -10
- package/tslint.json +0 -7
- /package/{src/index.ts → index.d.ts} +0 -0
- /package/{src/public_api.ts → public_api.d.ts} +0 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
const src_1 = require("@typescript-plus/fast-memoize-decorator/dist/src");
|
|
10
|
+
const scanner_1 = require("./scanner");
|
|
11
|
+
class PlaceDef {
|
|
12
|
+
constructor(importPath, componentClass, properties, routeDef, routeParameters) {
|
|
13
|
+
this.importPath = importPath;
|
|
14
|
+
this.componentClass = componentClass;
|
|
15
|
+
this.properties = properties;
|
|
16
|
+
this.routeDef = routeDef;
|
|
17
|
+
this.routeParameters = routeParameters;
|
|
18
|
+
}
|
|
19
|
+
get path() {
|
|
20
|
+
return PlaceDef.stripEnclosingQuotes(this.properties.path);
|
|
21
|
+
}
|
|
22
|
+
get routeIdentifier() {
|
|
23
|
+
return this.routeDef;
|
|
24
|
+
}
|
|
25
|
+
get fullPath() {
|
|
26
|
+
return !!this.routeIdentifier ?
|
|
27
|
+
`${this.path}/:${this.routeIdentifier.parameterName}` :
|
|
28
|
+
this.path;
|
|
29
|
+
}
|
|
30
|
+
getPlaceRouterGoArgs() {
|
|
31
|
+
const bits = [];
|
|
32
|
+
if (this.routeIdentifier) {
|
|
33
|
+
bits.push(`${this.routeIdentifier.modelName}:${this.routeIdentifier.typeName}`);
|
|
34
|
+
}
|
|
35
|
+
if (this.routeParameters && this.routeParameters.length > 0) {
|
|
36
|
+
const properties = this.routeParameters.map(p => `${p.parameterName}?: ${p.typeName}`);
|
|
37
|
+
bits.push(`routeParameters?: { ${properties.join(', ')} }`);
|
|
38
|
+
}
|
|
39
|
+
return bits.join(', ');
|
|
40
|
+
}
|
|
41
|
+
getPlaceRouterGoRouteParams() {
|
|
42
|
+
const bits = [`"${this.path}"`];
|
|
43
|
+
if (this.routeIdentifier) {
|
|
44
|
+
bits.push(`${this.routeIdentifier.modelName}`);
|
|
45
|
+
}
|
|
46
|
+
if (this.routeParameters && this.routeParameters.length > 0) {
|
|
47
|
+
const mandatory = bits.join(', ');
|
|
48
|
+
bits.push(`routeParameters`);
|
|
49
|
+
const all = bits.join(', ');
|
|
50
|
+
return `routeParameters ? [${all}] : [${mandatory}]`;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
return `[${bits.join(', ')}]`;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
get placeName() {
|
|
57
|
+
const s = this.componentClass.replace(/Component$/, 'Place');
|
|
58
|
+
return s.charAt(0).toLowerCase() + s.slice(1);
|
|
59
|
+
}
|
|
60
|
+
get order() {
|
|
61
|
+
return this.properties.order;
|
|
62
|
+
}
|
|
63
|
+
get activateGuardNames() {
|
|
64
|
+
const activateGuards = [];
|
|
65
|
+
if (this.authenticate) {
|
|
66
|
+
activateGuards.push('AuthGuard');
|
|
67
|
+
}
|
|
68
|
+
if (this.requiresRouteGuard()) {
|
|
69
|
+
activateGuards.push('PlaceRouteGuard');
|
|
70
|
+
}
|
|
71
|
+
return activateGuards;
|
|
72
|
+
}
|
|
73
|
+
requiresRouteGuard() {
|
|
74
|
+
return this.routeIdentifier || this.routeParameters.length > 0;
|
|
75
|
+
}
|
|
76
|
+
get routeModelName() {
|
|
77
|
+
return this.routeDef ? this.routeDef.modelName : null;
|
|
78
|
+
}
|
|
79
|
+
get authenticate() {
|
|
80
|
+
return this.properties.authenticate === 'true';
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
__decorate([
|
|
84
|
+
src_1.Memoize()
|
|
85
|
+
], PlaceDef.prototype, "path", null);
|
|
86
|
+
__decorate([
|
|
87
|
+
src_1.Memoize()
|
|
88
|
+
], PlaceDef.prototype, "placeName", null);
|
|
89
|
+
__decorate([
|
|
90
|
+
src_1.Memoize()
|
|
91
|
+
], PlaceDef.prototype, "activateGuardNames", null);
|
|
92
|
+
__decorate([
|
|
93
|
+
src_1.Memoize()
|
|
94
|
+
], PlaceDef.prototype, "routeModelName", null);
|
|
95
|
+
exports.PlaceDef = PlaceDef;
|
|
96
|
+
(function (PlaceDef) {
|
|
97
|
+
function scan(classDecl, context) {
|
|
98
|
+
return new scanner_1.Scanner(classDecl, context);
|
|
99
|
+
}
|
|
100
|
+
PlaceDef.scan = scan;
|
|
101
|
+
function stripEnclosingQuotes(value) {
|
|
102
|
+
const cooked = value.replace(/(^["'])|(["']$)/g, '');
|
|
103
|
+
// console.log({ raw: value, cooked: cooked });
|
|
104
|
+
return cooked;
|
|
105
|
+
}
|
|
106
|
+
PlaceDef.stripEnclosingQuotes = stripEnclosingQuotes;
|
|
107
|
+
})(PlaceDef = exports.PlaceDef || (exports.PlaceDef = {}));
|
|
108
|
+
//# sourceMappingURL=place-def.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"place-def.js","sourceRoot":"","sources":["../../../../../libs/angular-ui-powerups/schematics/place-routes/place-def.ts"],"names":[],"mappings":";;;;;;;;AACA,0EAA2E;AAE3E,uCAAoC;AAEpC,MAAa,QAAQ;IAGnB,YACW,UAAkB,EAClB,cAAsB,EACtB,UAA4B,EAC5B,QAA4B,EAC5B,eAAqC;QAJrC,eAAU,GAAV,UAAU,CAAQ;QAClB,mBAAc,GAAd,cAAc,CAAQ;QACtB,eAAU,GAAV,UAAU,CAAkB;QAC5B,aAAQ,GAAR,QAAQ,CAAoB;QAC5B,oBAAe,GAAf,eAAe,CAAsB;IAEhD,CAAC;IAGD,IAAI,IAAI;QACN,OAAO,QAAQ,CAAC,oBAAoB,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAC7D,CAAC;IAED,IAAI,eAAe;QACjB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YAC7B,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,eAAe,CAAC,aAAa,EAAE,CAAC,CAAC;YACvD,IAAI,CAAC,IAAI,CAAC;IACd,CAAC;IAED,oBAAoB;QAClB,MAAM,IAAI,GAAa,EAAE,CAAC;QAC1B,IAAI,IAAI,CAAC,eAAe,EAAE;YACxB,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,SAAS,IAAI,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE,CAAC,CAAC;SACjF;QACD,IAAI,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE;YAC3D,MAAM,UAAU,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,aAAa,MAAM,CAAC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YACrB,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;SAClC;QACD,IAAI,IAAI,CAAC,kBAAkB,EAAE,EAAE;YAC7B,cAAc,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;SACxC;QACD,OAAO,cAAc,CAAC;IACxB,CAAC;IAEO,kBAAkB;QACxB,OAAO,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC;IACjE,CAAC;IAGD,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;IACxD,CAAC;IAED,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,UAAU,CAAC,YAAY,KAAK,MAAM,CAAC;IACjD,CAAC;CAEF;AA9EC;IADC,aAAO,EAAE;oCAGT;AA0CD;IADC,aAAO,EAAE;yCAIT;AAOD;IADC,aAAO,EAAE;kDAUT;AAOD;IADC,aAAO,EAAE;8CAGT;AArFH,4BA2FC;AAED,WAAiB,QAAQ;IAevB,SAAgB,IAAI,CAAC,SAA2B,EAAE,OAAyB;QACzE,OAAO,IAAI,iBAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC;IAFe,aAAI,OAEnB,CAAA;IAED,SAAgB,oBAAoB,CAAC,KAAa;QAChD,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC;QACrD,+CAA+C;QAC/C,OAAO,MAAM,CAAC;IAChB,CAAC;IAJe,6BAAoB,uBAInC,CAAA;AAGH,CAAC,EA1BgB,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QA0BxB"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { SchematicContext } from '@angular-devkit/schematics';
|
|
2
|
+
import { ClassDeclaration, Decorator, ObjectLiteralExpression, PropertyDeclaration } from 'ts-morph';
|
|
3
|
+
import { PlaceDef } from './place-def';
|
|
4
|
+
export declare class Scanner {
|
|
5
|
+
private readonly classDecl;
|
|
6
|
+
readonly context: SchematicContext;
|
|
7
|
+
private placeAnnotation;
|
|
8
|
+
constructor(classDecl: ClassDeclaration, context: SchematicContext);
|
|
9
|
+
isPlace(): boolean;
|
|
10
|
+
onMatch(callback: (scan: Scanner) => void): void;
|
|
11
|
+
createDefinition(moduleImportPath: string): PlaceDef;
|
|
12
|
+
protected getPlaceOptions(): PlaceDef.Options;
|
|
13
|
+
protected getRouteIdParameter(): Scanner.RouteParameterInfo;
|
|
14
|
+
protected getRouteParameters(): PlaceDef.Parameter[];
|
|
15
|
+
private getValueModelRouteProperties;
|
|
16
|
+
private getListModelRouteProperties;
|
|
17
|
+
protected getDecoratedProperties(annotation: string): {
|
|
18
|
+
decorator: Decorator;
|
|
19
|
+
property: PropertyDeclaration;
|
|
20
|
+
}[];
|
|
21
|
+
}
|
|
22
|
+
export declare namespace Scanner {
|
|
23
|
+
function getObjectLiteralArgument(annotation: Decorator, position: number): ObjectLiteralExpression;
|
|
24
|
+
function getOptionsArg<T extends {}>(annotation: Decorator, defaults: T, options?: {
|
|
25
|
+
position: number;
|
|
26
|
+
required: boolean;
|
|
27
|
+
}): T;
|
|
28
|
+
class RouteParameterInfo implements PlaceDef.Parameter {
|
|
29
|
+
private readonly as;
|
|
30
|
+
readonly property: PropertyDeclaration;
|
|
31
|
+
readonly isArray: boolean;
|
|
32
|
+
readonly baseTypeName: string;
|
|
33
|
+
constructor(as: string, property: PropertyDeclaration);
|
|
34
|
+
readonly parameterName: string;
|
|
35
|
+
readonly modelName: string;
|
|
36
|
+
readonly typeName: string;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
const src_1 = require("@typescript-plus/fast-memoize-decorator/dist/src");
|
|
10
|
+
const ts_morph_1 = require("ts-morph");
|
|
11
|
+
const place_def_1 = require("./place-def");
|
|
12
|
+
function isDecoratorNode(node, name) {
|
|
13
|
+
return node.getKind() === ts_morph_1.SyntaxKind.Decorator && node.getText().startsWith(`${name}(`); // NOTE: I'm only supporting the @Decorator(...) style of usage (i.e. decorator factories).
|
|
14
|
+
}
|
|
15
|
+
const ROUTE_PROPERTY_REGEX = /.*(ListModel|ValueModel)<(.*)>/;
|
|
16
|
+
class Scanner {
|
|
17
|
+
constructor(classDecl, context) {
|
|
18
|
+
this.classDecl = classDecl;
|
|
19
|
+
this.context = context;
|
|
20
|
+
classDecl.forEachChild((node) => {
|
|
21
|
+
if (isDecoratorNode(node, '@Place')) {
|
|
22
|
+
this.placeAnnotation = node;
|
|
23
|
+
// stop iterating when the node is a class declaration
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
isPlace() {
|
|
29
|
+
return !!this.placeAnnotation;
|
|
30
|
+
}
|
|
31
|
+
onMatch(callback) {
|
|
32
|
+
if (this.isPlace()) {
|
|
33
|
+
callback(this);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
createDefinition(moduleImportPath) {
|
|
37
|
+
this.getRouteIdParameter();
|
|
38
|
+
return new place_def_1.PlaceDef(moduleImportPath, this.classDecl.getName(), this.getPlaceOptions(), this.getRouteIdParameter(), this.getRouteParameters());
|
|
39
|
+
}
|
|
40
|
+
getPlaceOptions() {
|
|
41
|
+
// const args = this.placeAnnotation.getArguments();
|
|
42
|
+
// if (args.length !== 1) {
|
|
43
|
+
// console.error('@Place() accepts a single Options argument. got', args);
|
|
44
|
+
// }
|
|
45
|
+
return Scanner.getOptionsArg(this.placeAnnotation, {
|
|
46
|
+
title: '',
|
|
47
|
+
path: '',
|
|
48
|
+
order: -1,
|
|
49
|
+
authenticate: 'true'
|
|
50
|
+
}, {
|
|
51
|
+
position: 0,
|
|
52
|
+
required: true
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
getRouteIdParameter() {
|
|
56
|
+
const routeProperties = this.getDecoratedProperties('@RouteId');
|
|
57
|
+
if (routeProperties.length === 1) {
|
|
58
|
+
const route = routeProperties[0];
|
|
59
|
+
const routeOptions = Scanner.getOptionsArg(route.decorator, { as: '' }, {
|
|
60
|
+
position: 1,
|
|
61
|
+
required: false
|
|
62
|
+
});
|
|
63
|
+
return new Scanner.RouteParameterInfo(routeOptions.as, route.property);
|
|
64
|
+
}
|
|
65
|
+
else if (routeProperties.length > 1) {
|
|
66
|
+
this.context.logger.error(`There an only be one @RouteId(), got ${routeProperties.length}`);
|
|
67
|
+
}
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
getRouteParameters() {
|
|
71
|
+
return this.getValueModelRouteProperties().concat(this.getListModelRouteProperties());
|
|
72
|
+
}
|
|
73
|
+
getValueModelRouteProperties() {
|
|
74
|
+
return this.getDecoratedProperties('@RouteParameter')
|
|
75
|
+
.map(p => {
|
|
76
|
+
const routeOptions = Scanner.getOptionsArg(p.decorator, { as: p.property.getName() }, {
|
|
77
|
+
position: 1,
|
|
78
|
+
required: false
|
|
79
|
+
});
|
|
80
|
+
return new Scanner.RouteParameterInfo(routeOptions.as, p.property);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
getListModelRouteProperties() {
|
|
84
|
+
return this.getDecoratedProperties('@RouteParameterList')
|
|
85
|
+
.map(p => {
|
|
86
|
+
const routeOptions = Scanner.getOptionsArg(p.decorator, { as: p.property.getName() }, {
|
|
87
|
+
position: 1,
|
|
88
|
+
required: false
|
|
89
|
+
});
|
|
90
|
+
return new Scanner.RouteParameterInfo(routeOptions.as, p.property);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
getDecoratedProperties(annotation) {
|
|
94
|
+
return this.classDecl.getProperties().map(p => {
|
|
95
|
+
let result = null;
|
|
96
|
+
p.forEachChild((child) => {
|
|
97
|
+
if (isDecoratorNode(child, annotation)) {
|
|
98
|
+
result = {
|
|
99
|
+
decorator: child,
|
|
100
|
+
property: p
|
|
101
|
+
};
|
|
102
|
+
// stop traversal
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
return result;
|
|
107
|
+
}).filter(r => !!r);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
exports.Scanner = Scanner;
|
|
111
|
+
(function (Scanner) {
|
|
112
|
+
function getObjectLiteralArgument(annotation, position) {
|
|
113
|
+
const args = annotation.getArguments();
|
|
114
|
+
if (args.length > position && args[position] instanceof ts_morph_1.ObjectLiteralExpression) {
|
|
115
|
+
return args[position];
|
|
116
|
+
}
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
Scanner.getObjectLiteralArgument = getObjectLiteralArgument;
|
|
120
|
+
function getOptionsArg(annotation, defaults, options = {
|
|
121
|
+
position: 0,
|
|
122
|
+
required: true
|
|
123
|
+
}) {
|
|
124
|
+
const objectLiteralArgument = getObjectLiteralArgument(annotation, options.position);
|
|
125
|
+
if (!objectLiteralArgument) {
|
|
126
|
+
if (options.required) {
|
|
127
|
+
console.error(`expected object literal arg at position ${options.position}`, { expectedType: defaults });
|
|
128
|
+
}
|
|
129
|
+
return defaults;
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
return objectLiteralArgument.getProperties().reduce((result, p) => {
|
|
133
|
+
const structure = p.getStructure();
|
|
134
|
+
return Object.assign({}, result, { [structure.name]: structure.initializer });
|
|
135
|
+
}, Object.assign({}, defaults));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
Scanner.getOptionsArg = getOptionsArg;
|
|
139
|
+
class RouteParameterInfo {
|
|
140
|
+
constructor(as, property) {
|
|
141
|
+
this.as = as;
|
|
142
|
+
this.property = property;
|
|
143
|
+
const type = property.getStructure().type;
|
|
144
|
+
const match = ROUTE_PROPERTY_REGEX.exec(type);
|
|
145
|
+
if (!match) {
|
|
146
|
+
throw new Error(`expected ${property.getName()} to be a ListModel or ValueModel, got: ${type}`);
|
|
147
|
+
}
|
|
148
|
+
this.isArray = match[1] === 'ListModel';
|
|
149
|
+
this.baseTypeName = match[2];
|
|
150
|
+
}
|
|
151
|
+
get parameterName() {
|
|
152
|
+
return this.as.length > 0 ? place_def_1.PlaceDef.stripEnclosingQuotes(this.as) : this.modelName;
|
|
153
|
+
}
|
|
154
|
+
get modelName() {
|
|
155
|
+
return place_def_1.PlaceDef.stripEnclosingQuotes(this.property.getName());
|
|
156
|
+
}
|
|
157
|
+
get typeName() {
|
|
158
|
+
return this.isArray ? `${this.baseTypeName}[]` : this.baseTypeName;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
__decorate([
|
|
162
|
+
src_1.Memoize()
|
|
163
|
+
], RouteParameterInfo.prototype, "parameterName", null);
|
|
164
|
+
__decorate([
|
|
165
|
+
src_1.Memoize()
|
|
166
|
+
], RouteParameterInfo.prototype, "modelName", null);
|
|
167
|
+
Scanner.RouteParameterInfo = RouteParameterInfo;
|
|
168
|
+
})(Scanner = exports.Scanner || (exports.Scanner = {}));
|
|
169
|
+
//# sourceMappingURL=scanner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scanner.js","sourceRoot":"","sources":["../../../../../libs/angular-ui-powerups/schematics/place-routes/scanner.ts"],"names":[],"mappings":";;;;;;;;AACA,0EAA2E;AAC3E,uCAQkB;AAClB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C,IAAI,CAAC,CAAC;YAC9C,IAAI,CAAC,KAAK,EAAE;gBACV,MAAM,IAAI,KAAK,CAAC,YAAY,QAAQ,CAAC,OAAO,EAAE,0CAA0C,IAAI,EAAE,CAAC,CAAC;aACjG;YACD,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,WAAW,CAAC;YACxC,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QAC/B,CAAC;QAGD,IAAI,aAAa;YACf,OAAO,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,oBAAQ,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC;QACtF,CAAC;QAGD,IAAI,SAAS;YACX,OAAO,oBAAQ,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;QAChE,CAAC;QAED,IAAI,QAAQ;YACV,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,YAAY,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC;QACrE,CAAC;KACF;IAZC;QADC,aAAO,EAAE;2DAGT;IAGD;QADC,aAAO,EAAE;uDAGT;IAvBU,0BAAkB,qBA4B9B,CAAA;AACH,CAAC,EAzDgB,OAAO,GAAP,eAAO,KAAP,eAAO,QAyDvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../../libs/angular-ui-powerups/schematics/place-routes/schema.ts"],"names":[],"mappings":""}
|
|
@@ -12,27 +12,22 @@
|
|
|
12
12
|
import { Injectable } from '@angular/core';
|
|
13
13
|
import { Router } from '@angular/router';
|
|
14
14
|
|
|
15
|
-
<% placeDefs.forEach(def => { %>import {<%= def.componentClass %>} from "<%= def.importPath %>";
|
|
16
|
-
<% }); %>
|
|
17
|
-
|
|
18
15
|
@Injectable({
|
|
19
16
|
providedIn: 'root'
|
|
20
17
|
})
|
|
21
|
-
export class
|
|
18
|
+
export class PlaceRouter {
|
|
22
19
|
constructor(private readonly router:Router) {
|
|
23
20
|
}
|
|
24
|
-
}
|
|
25
21
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
//
|
|
22
|
+
<% placeDefs.forEach(def => { %>
|
|
23
|
+
get <%= def.placeName %>() {
|
|
24
|
+
const self = this;
|
|
25
|
+
return {
|
|
26
|
+
go(<%=def.getPlaceRouterGoArgs()%>) {
|
|
27
|
+
const params = <%=def.getPlaceRouterGoRouteParams()%>;
|
|
28
|
+
return self.router.navigate(params);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
<% }) %>
|
|
33
|
+
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
|
-
|
|
5
|
-
### [0.0.26](https://bitbucket.org/coolon/angular-ui-powerups/compare/v0.0.25...v0.0.26) (2019-09-09)
|
|
6
|
-
|
|
7
|
-
### 0.0.25 (2019-09-09)
|
package/jest.config.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
name: 'angular-ui-powerups',
|
|
3
|
-
preset: '../../jest.config.js',
|
|
4
|
-
coverageDirectory: '../../coverage/libs/angular-ui-powerups',
|
|
5
|
-
snapshotSerializers: [
|
|
6
|
-
'jest-preset-angular/AngularSnapshotSerializer.js',
|
|
7
|
-
'jest-preset-angular/HTMLCommentSerializer.js'
|
|
8
|
-
]
|
|
9
|
-
};
|
package/ng-package.json
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
|
|
3
|
-
"dest": "../../dist/libs/angular-ui-powerups",
|
|
4
|
-
"lib": {
|
|
5
|
-
"entryFile": "src/index.ts"
|
|
6
|
-
},
|
|
7
|
-
"whitelistedNonPeerDependencies": [
|
|
8
|
-
"ts-morph",
|
|
9
|
-
"@typescript-plus/fast-memoize-decorator",
|
|
10
|
-
"@coolon/typescript-utilities",
|
|
11
|
-
"json5"
|
|
12
|
-
]
|
|
13
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
|
|
2
|
-
import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';
|
|
3
|
-
|
|
4
|
-
// Just return the tree
|
|
5
|
-
export function ngAdd(_options: any): Rule {
|
|
6
|
-
return (tree: Tree, _context: SchematicContext) => {
|
|
7
|
-
_context.addTask(new NodePackageInstallTask());
|
|
8
|
-
return tree;
|
|
9
|
-
};
|
|
10
|
-
}
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { experimental, strings } from '@angular-devkit/core';
|
|
2
|
-
import {
|
|
3
|
-
apply,
|
|
4
|
-
applyTemplates,
|
|
5
|
-
FileEntry,
|
|
6
|
-
forEach,
|
|
7
|
-
mergeWith,
|
|
8
|
-
Rule,
|
|
9
|
-
SchematicContext,
|
|
10
|
-
Tree,
|
|
11
|
-
url,
|
|
12
|
-
move
|
|
13
|
-
} from '@angular-devkit/schematics';
|
|
14
|
-
import { scanForRouteEntryPoints } from '@angular/compiler-cli/src/ngtsc/routing/src/lazy';
|
|
15
|
-
import { fileExists } from '@nrwl/workspace/src/utils/fileutils';
|
|
16
|
-
import * as JSON5 from 'json5';
|
|
17
|
-
import { ClassDeclaration, Project } from 'ts-morph';
|
|
18
|
-
import { PlaceDef } from './place-def';
|
|
19
|
-
import { Schema } from './schema';
|
|
20
|
-
|
|
21
|
-
const PLACE_ANNOTATION = /@Place\({([^})]*)}\)/m;
|
|
22
|
-
|
|
23
|
-
export function generateRoutes(options: Schema): Rule {
|
|
24
|
-
|
|
25
|
-
return (tree: Tree, context: SchematicContext) => {
|
|
26
|
-
|
|
27
|
-
const workspaceConfig = tree.read('/angular.json');
|
|
28
|
-
if (!workspaceConfig) {
|
|
29
|
-
throw new Error('Could not find Angular workspace configuration');
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// convert workspace to string
|
|
33
|
-
const workspaceContent = workspaceConfig.toString();
|
|
34
|
-
|
|
35
|
-
// parse workspace string into JSON object
|
|
36
|
-
const workspace: experimental.workspace.WorkspaceSchema = JSON.parse(workspaceContent);
|
|
37
|
-
|
|
38
|
-
if (!options.project) {
|
|
39
|
-
options.project = workspace.defaultProject;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const projectName = options.project as string;
|
|
43
|
-
const project = workspace.projects[projectName];
|
|
44
|
-
const config = loadConfig(project, tree, context);
|
|
45
|
-
const placeDefs = extractPlaces(project, options, tree, context);
|
|
46
|
-
const projectType = project.projectType === 'application' ? 'app' : 'lib';
|
|
47
|
-
|
|
48
|
-
const files = apply(
|
|
49
|
-
url('./templates'),
|
|
50
|
-
[
|
|
51
|
-
applyTemplates({
|
|
52
|
-
...options,
|
|
53
|
-
placeDefs,
|
|
54
|
-
config,
|
|
55
|
-
...strings
|
|
56
|
-
}),
|
|
57
|
-
move(`${project.sourceRoot}/${projectType}`),
|
|
58
|
-
// @see https://github.com/angular/angular-cli/issues/11337#issuecomment-448259549
|
|
59
|
-
forEach((fileEntry: FileEntry) => {
|
|
60
|
-
if (tree.exists(fileEntry.path)) {
|
|
61
|
-
tree.overwrite(fileEntry.path, fileEntry.content);
|
|
62
|
-
}
|
|
63
|
-
return fileEntry;
|
|
64
|
-
})
|
|
65
|
-
]);
|
|
66
|
-
|
|
67
|
-
return mergeWith(files);
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
// function applyWithOverwrite(source: Source, rules: Rule[]): Rule {
|
|
75
|
-
// return (tree: Tree, _context: SchematicContext) => {
|
|
76
|
-
// const rule = mergeWith(
|
|
77
|
-
// apply(source, [
|
|
78
|
-
// ...rules,
|
|
79
|
-
// forEach((fileEntry) => {
|
|
80
|
-
// if (tree.exists(fileEntry.path)) {
|
|
81
|
-
// tree.overwrite(fileEntry.path, fileEntry.content);
|
|
82
|
-
// return null;
|
|
83
|
-
// }
|
|
84
|
-
// return fileEntry;
|
|
85
|
-
// })
|
|
86
|
-
// ])
|
|
87
|
-
// );
|
|
88
|
-
//
|
|
89
|
-
// return rule(tree, _context);
|
|
90
|
-
// };
|
|
91
|
-
// }
|
|
92
|
-
|
|
93
|
-
function createProject(project: any, context: SchematicContext) {
|
|
94
|
-
const tsConfigPath = project.architect.build.options.tsConfig;
|
|
95
|
-
context.logger.info(`loading tsConfig from -> ${tsConfigPath}`);
|
|
96
|
-
try {
|
|
97
|
-
return new Project({
|
|
98
|
-
tsConfigFilePath: `./${tsConfigPath}`
|
|
99
|
-
});
|
|
100
|
-
} catch (error) {
|
|
101
|
-
context.logger.fatal(`Failed to load typescript project form: ${project.root} You probably need to specify the --project option?`);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function loadConfig(project: any, tree: Tree, context: SchematicContext) {
|
|
106
|
-
context.logger.info(`loading places config from -> ${project.root}/places.json (or places.json5)`);
|
|
107
|
-
const fileEntry = tree.get(`${project.root}/places.json5`) || tree.get(`${project.root}/places.json5`);
|
|
108
|
-
if (!fileEntry) {
|
|
109
|
-
throw new Error(`Unable to find config file at '${project.root}/places.json' or '${project.root}/places.json5'`);
|
|
110
|
-
}
|
|
111
|
-
const config = JSON5.parse(fileEntry.content.toString('utf-8'));
|
|
112
|
-
return config;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function extractPlaces(project: any, schema: Schema, tree: Tree, context: SchematicContext): PlaceDef[] {
|
|
116
|
-
const projectType = project.projectType === 'application' ? 'app' : 'lib';
|
|
117
|
-
const projectRoot = `${project.root}`;
|
|
118
|
-
const sourceRoot = `${project.sourceRoot}/${projectType}`;
|
|
119
|
-
const importPrefix = `./${sourceRoot}`;
|
|
120
|
-
const tsProject = createProject(project, context);
|
|
121
|
-
const placeDefs: PlaceDef[] = [];
|
|
122
|
-
context.logger.info(`Scanning sources in -> ${sourceRoot}`);
|
|
123
|
-
tree.getDir(sourceRoot).visit(filePath => {
|
|
124
|
-
if (!filePath.endsWith('.ts')) {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
const content = tree.read(filePath);
|
|
129
|
-
if (!content) {
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
const sourceText = content.toString('utf-8');
|
|
133
|
-
|
|
134
|
-
if (sourceText.match(PLACE_ANNOTATION)) {
|
|
135
|
-
|
|
136
|
-
const sourceFile = tsProject.getSourceFileOrThrow(`./${filePath}`);
|
|
137
|
-
|
|
138
|
-
sourceFile.getClasses().forEach((classDecl: ClassDeclaration) => {
|
|
139
|
-
|
|
140
|
-
PlaceDef.scan(classDecl, context).onMatch(result => {
|
|
141
|
-
// context.logger.info(`filePath=${filePath}`);
|
|
142
|
-
const moduleImportPath = `./${filePath.substr(importPrefix.length, filePath.length - importPrefix.length - '.ts'.length)}`;
|
|
143
|
-
const definition = result.createDefinition(moduleImportPath);
|
|
144
|
-
context.logger.info(`${moduleImportPath} -> ${classDecl.getName()}(route: /${definition.fullPath})`);
|
|
145
|
-
placeDefs.push(definition);
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
return placeDefs;
|
|
152
|
-
}
|