@coolon/angular-ui-powerups 3.6.0 → 3.7.0-alpha.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 +7 -0
- package/bundles/coolon-angular-ui-powerups-cypress.umd.js +41 -1
- package/bundles/coolon-angular-ui-powerups-cypress.umd.js.map +1 -1
- package/bundles/coolon-angular-ui-powerups-cypress.umd.min.js +1 -1
- package/bundles/coolon-angular-ui-powerups-cypress.umd.min.js.map +1 -1
- package/bundles/coolon-angular-ui-powerups.umd.js +228 -184
- package/bundles/coolon-angular-ui-powerups.umd.js.map +1 -1
- package/bundles/coolon-angular-ui-powerups.umd.min.js +1 -1
- package/bundles/coolon-angular-ui-powerups.umd.min.js.map +1 -1
- package/coolon-angular-ui-powerups.metadata.json +1 -1
- package/cypress/components/aup-navigation.d.ts +9 -0
- package/cypress/coolon-angular-ui-powerups-cypress.metadata.json +1 -1
- package/cypress/exports.d.ts +1 -0
- package/cypress/package.json +2 -1
- package/cypress/page.d.ts +3 -0
- package/cypress/section.d.ts +5 -0
- package/esm2015/cypress/components/aup-navigation.js +21 -0
- package/esm2015/cypress/components/aup-navigation.js.map +1 -0
- package/esm2015/cypress/components/aup-navigation.metadata.json +1 -0
- package/esm2015/cypress/exports.js +1 -0
- package/esm2015/cypress/exports.js.map +1 -1
- package/esm2015/cypress/exports.metadata.json +1 -1
- package/esm2015/cypress/page.js +10 -1
- package/esm2015/cypress/page.js.map +1 -1
- package/esm2015/cypress/page.metadata.json +1 -1
- package/esm2015/cypress/section.js +7 -0
- package/esm2015/cypress/section.js.map +1 -1
- package/esm2015/lib/place/components/abstract-place-navigation.component.js +7 -5
- 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/list-place-nav/list-place-nav.component.js +6 -6
- package/esm2015/lib/place/components/list-place-nav/list-place-nav.component.js.map +1 -1
- package/esm2015/lib/place/components/list-place-nav/list-place-nav.component.metadata.json +1 -1
- package/esm2015/lib/place/components/side-place-navigation/side-place-navigation.component.js +5 -5
- package/esm2015/lib/place/components/side-place-navigation/side-place-navigation.component.js.map +1 -1
- package/esm2015/lib/place/components/side-place-navigation/side-place-navigation.component.metadata.json +1 -1
- package/esm2015/lib/place/components/tabbed-place-navigation/tabbed-place-navigation.component.js +5 -5
- package/esm2015/lib/place/components/tabbed-place-navigation/tabbed-place-navigation.component.js.map +1 -1
- package/esm2015/lib/place/components/tabbed-place-navigation/tabbed-place-navigation.component.metadata.json +1 -1
- package/esm2015/lib/place/exports.js +1 -0
- package/esm2015/lib/place/exports.js.map +1 -1
- package/esm2015/lib/place/exports.metadata.json +1 -1
- package/esm2015/lib/place/guards/place.guard.js +94 -43
- package/esm2015/lib/place/guards/place.guard.js.map +1 -1
- package/esm2015/lib/place/guards/place.guard.metadata.json +1 -1
- package/esm2015/lib/place/guards/place.guard.ngfactory.js.map +1 -0
- package/esm2015/lib/place/place-auth-service.js +3 -0
- package/esm2015/lib/place/place-auth-service.js.map +1 -0
- package/esm2015/lib/place/place-auth-service.metadata.json +1 -0
- package/esm2015/lib/place/place-component.js +12 -2
- package/esm2015/lib/place/place-component.js.map +1 -1
- package/esm2015/lib/place/place-component.metadata.json +1 -1
- package/esm2015/lib/place/place-definition.js +2 -1
- package/esm2015/lib/place/place-definition.js.map +1 -1
- package/esm2015/lib/place/place-definition.metadata.json +1 -1
- package/esm2015/lib/place/place-router.js +6 -0
- package/esm2015/lib/place/place-router.js.map +1 -1
- package/esm2015/lib/place/place-router.metadata.json +1 -1
- package/esm2015/lib/place/place.decorator.js +1 -1
- package/esm2015/lib/place/place.decorator.js.map +1 -1
- package/fesm2015/coolon-angular-ui-powerups-cypress.js +36 -2
- package/fesm2015/coolon-angular-ui-powerups-cypress.js.map +1 -1
- package/fesm2015/coolon-angular-ui-powerups.js +185 -128
- package/fesm2015/coolon-angular-ui-powerups.js.map +1 -1
- package/lib/place/components/abstract-place-navigation.component.d.ts +2 -2
- package/lib/place/components/list-place-nav/list-place-nav.component.d.ts +2 -2
- package/lib/place/components/side-place-navigation/side-place-navigation.component.d.ts +2 -2
- package/lib/place/components/tabbed-place-navigation/tabbed-place-navigation.component.d.ts +2 -2
- package/lib/place/exports.d.ts +1 -0
- package/lib/place/guards/place.guard.d.ts +5 -7
- package/lib/place/place-auth-service.d.ts +36 -0
- package/lib/place/place-component.d.ts +2 -1
- package/lib/place/place-definition.d.ts +2 -1
- package/lib/place/place-router.d.ts +1 -0
- package/lib/place/place.decorator.d.ts +1 -0
- package/package.json +1 -1
- package/schematics/bootstrap-app/index.js +4 -0
- package/schematics/bootstrap-app/index.js.map +1 -1
- package/schematics/bootstrap-app/templates/app/app.module.ts.template +4 -2
- package/schematics/bootstrap-app/templates/app/auth/place-auth.service.ts.template +41 -0
- package/schematics/collection.json +5 -0
- package/schematics/ng-add/index.js +1 -1
- package/schematics/ng-add/index.js.map +1 -1
- package/schematics/place-add/index.js +2 -1
- package/schematics/place-add/index.js.map +1 -1
- package/schematics/place-add/templates/component/__name@dasherize__.component.scss.template +1 -0
- package/schematics/place-bootstrap/index.d.ts +3 -0
- package/schematics/place-bootstrap/index.js +21 -0
- package/schematics/place-bootstrap/index.js.map +1 -0
- package/schematics/place-bootstrap/schema.d.ts +4 -0
- package/schematics/place-bootstrap/schema.js +3 -0
- package/schematics/place-bootstrap/schema.js.map +1 -0
- package/schematics/place-bootstrap/schema.json +28 -0
- package/schematics/place-routes/place-builder.d.ts +0 -1
- package/schematics/place-routes/place-builder.js +34 -24
- package/schematics/place-routes/place-builder.js.map +1 -1
- package/schematics/place-routes/place-class-scanner.js +2 -1
- package/schematics/place-routes/place-class-scanner.js.map +1 -1
- package/schematics/place-routes/place-def.d.ts +1 -0
- package/schematics/place-routes/place-def.js +2 -2
- package/schematics/place-routes/place-def.js.map +1 -1
- package/schematics/place-routes/schema.d.ts +1 -4
- package/schematics/place-routes/schema.json +9 -1
- package/schematics/place-routes/templates/place-destinations.ts.template +1 -9
- package/schematics/place-routes/templates/place-routes.ts.template +3 -39
- package/schematics/place-routes/templates/place-visits.ts.template +1 -10
- package/schematics/bootstrap-app/templates/app/auth/auth.guard.ts.template +0 -23
- package/schematics/bootstrap-app/templates/app/auth/auth.module.ts.template +0 -13
- package/schematics/bootstrap-app/templates/app/auth/auth.service.ts.template +0 -13
- package/schematics/bootstrap-app/templates/app/places/places.json5.template +0 -3
- /package/schematics/{bootstrap-app/templates/app/places → place-bootstrap/templates/__name@dasherize__}/place-routes.ts.template +0 -0
- /package/schematics/{bootstrap-app/templates/app/places → place-bootstrap/templates/__name@dasherize__}/places.module.ts.template +0 -0
|
@@ -2,9 +2,9 @@ import { OnInit } from '@angular/core';
|
|
|
2
2
|
import { Command, Constructable, DelegatingValueModel, ListModel, ListModelChain, ValueModel } from '@coolon/pectin';
|
|
3
3
|
import { CommandFace } from '../../components/commands/command-face';
|
|
4
4
|
import { DisposableComponent } from '../../components/disposable-component';
|
|
5
|
+
import { PlaceAuthService } from '../place-auth-service';
|
|
5
6
|
import { PlaceComponent } from '../place-component';
|
|
6
7
|
import { PlaceDefinition } from '../place-definition';
|
|
7
|
-
import { PlaceRouter } from '../place-router';
|
|
8
8
|
import { PlaceOutletComponent } from './place-outlet/place-outlet.component';
|
|
9
9
|
export declare class AbstractPlaceNavigationComponent extends DisposableComponent implements OnInit {
|
|
10
10
|
places: Constructable<PlaceComponent>[];
|
|
@@ -15,7 +15,7 @@ export declare class AbstractPlaceNavigationComponent extends DisposableComponen
|
|
|
15
15
|
readonly commandFactory: Command.Factory<PlaceDefinition, void>;
|
|
16
16
|
readonly _activePlaceComponent: DelegatingValueModel<PlaceComponent>;
|
|
17
17
|
private activePlaceDefinition;
|
|
18
|
-
constructor(
|
|
18
|
+
constructor(authService: PlaceAuthService);
|
|
19
19
|
getNavigationFace(placeDef: PlaceDefinition): CommandFace;
|
|
20
20
|
isActive(place: PlaceDefinition): boolean;
|
|
21
21
|
ngOnInit(): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PlaceAuthService } from '../../place-auth-service';
|
|
2
2
|
import { AbstractPlaceNavigationComponent } from '../abstract-place-navigation.component';
|
|
3
3
|
export declare class ListPlaceNavComponent extends AbstractPlaceNavigationComponent {
|
|
4
|
-
constructor(
|
|
4
|
+
constructor(authService: PlaceAuthService);
|
|
5
5
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TemplateRef } from '@angular/core';
|
|
2
2
|
import { Router } from '@angular/router';
|
|
3
|
-
import {
|
|
3
|
+
import { PlaceAuthService } from '../../place-auth-service';
|
|
4
4
|
import { AbstractPlaceNavigationComponent } from '../abstract-place-navigation.component';
|
|
5
5
|
/**
|
|
6
6
|
* @example
|
|
@@ -48,7 +48,7 @@ export declare class SidePlaceNavigationComponent extends AbstractPlaceNavigatio
|
|
|
48
48
|
readonly router: Router;
|
|
49
49
|
expanded: boolean;
|
|
50
50
|
navEndTemplate: TemplateRef<any>;
|
|
51
|
-
constructor(router: Router,
|
|
51
|
+
constructor(router: Router, authService: PlaceAuthService);
|
|
52
52
|
expandMenu(): void;
|
|
53
53
|
collapseMenu(): void;
|
|
54
54
|
toggleMenu(): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PlaceAuthService } from '../../place-auth-service';
|
|
2
2
|
import { AbstractPlaceNavigationComponent } from '../abstract-place-navigation.component';
|
|
3
3
|
export declare class TabbedPlaceNavigationComponent extends AbstractPlaceNavigationComponent {
|
|
4
|
-
constructor(
|
|
4
|
+
constructor(authService: PlaceAuthService);
|
|
5
5
|
}
|
package/lib/place/exports.d.ts
CHANGED
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
import { Injector } from '@angular/core';
|
|
2
2
|
import { ActivatedRouteSnapshot, CanActivate, CanDeactivate, Router, RouterStateSnapshot, UrlTree } from '@angular/router';
|
|
3
3
|
import { InteractionService } from '../../interaction/services/interaction.service';
|
|
4
|
+
import { PlaceAuthService } from '../place-auth-service';
|
|
4
5
|
import { PlaceComponent } from '../place-component';
|
|
5
|
-
import { PlaceDefinition } from '../place-definition';
|
|
6
6
|
import { PlaceHistory } from '../place-history';
|
|
7
7
|
import { PlaceRouter } from '../place-router';
|
|
8
8
|
import { UrlService } from '../url-service';
|
|
9
9
|
import { UrlSnapshot } from '../url-snapshot';
|
|
10
|
-
export declare
|
|
10
|
+
export declare class PlaceGuard implements CanActivate, CanDeactivate<PlaceComponent> {
|
|
11
11
|
private readonly router;
|
|
12
12
|
private urlService;
|
|
13
13
|
private readonly placeRouter;
|
|
14
14
|
private readonly placeHistory;
|
|
15
|
+
private readonly placeAuthService;
|
|
15
16
|
private readonly interactionService;
|
|
16
17
|
private readonly injector;
|
|
17
|
-
constructor(router: Router, urlService: UrlService, placeRouter: PlaceRouter, placeHistory: PlaceHistory, interactionService: InteractionService, injector: Injector);
|
|
18
|
+
constructor(router: Router, urlService: UrlService, placeRouter: PlaceRouter, placeHistory: PlaceHistory, placeAuthService: PlaceAuthService, interactionService: InteractionService, injector: Injector);
|
|
18
19
|
canActivate(activatedRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean | UrlTree>;
|
|
19
20
|
canDeactivate(component: PlaceComponent, currentRoute: ActivatedRouteSnapshot, currentState: RouterStateSnapshot, nextState?: RouterStateSnapshot): Promise<boolean | UrlTree>;
|
|
20
21
|
private handleGuardResult;
|
|
21
|
-
|
|
22
|
-
isAuthorised(activatedRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean | UrlTree>;
|
|
23
|
-
abstract getAuthGuard(injector: Injector): CanActivate;
|
|
24
|
-
cleanInteractionState(route: ActivatedRouteSnapshot, state: RouterStateSnapshot, then: () => Promise<boolean | UrlSnapshot>): Promise<boolean | UrlSnapshot>;
|
|
22
|
+
cleanInteractionState(route: ActivatedRouteSnapshot, state: RouterStateSnapshot, next: () => Promise<boolean | UrlSnapshot>): Promise<boolean | UrlSnapshot>;
|
|
25
23
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
|
|
3
|
+
import { ValueModel } from '@coolon/pectin';
|
|
4
|
+
import { PlaceDefinition } from './place-definition';
|
|
5
|
+
import { UrlSnapshot } from './url-snapshot';
|
|
6
|
+
import { Visit } from './visit';
|
|
7
|
+
export declare const PLACE_AUTH_SERVICE: InjectionToken<PlaceAuthService>;
|
|
8
|
+
/**
|
|
9
|
+
* This interface provides auth services to the routing layer and splits authn and authz into two
|
|
10
|
+
* separate calls so that authentication can be promised based where as authorisation is not. This
|
|
11
|
+
* allows components to check authorisation without having to deal with the promised based nature
|
|
12
|
+
* of authentication.
|
|
13
|
+
*/
|
|
14
|
+
export interface PlaceAuthService {
|
|
15
|
+
/**
|
|
16
|
+
* An observable model containing the authoriser function. This allows places to react to changes
|
|
17
|
+
* in permissions when any underlying auth logic changes, e.g. a role being removed from a user.
|
|
18
|
+
*/
|
|
19
|
+
readonly authoriserModel: ValueModel<PlaceAuthService.AuthoriserCallback>;
|
|
20
|
+
/**
|
|
21
|
+
* Checks if the current user is authenticated. If true the router will proceed to
|
|
22
|
+
* check if the user is authorised. Otherwise it will invoke #handleAuthenticatedFailure.
|
|
23
|
+
*/
|
|
24
|
+
isAuthenticated(): boolean | Promise<boolean>;
|
|
25
|
+
/**
|
|
26
|
+
* Checks if the current user is authorised. If true the router will proceed to route sanitisation
|
|
27
|
+
* and view loading, otherwise it will invoke #handleAuthorisationFailure.
|
|
28
|
+
* @param placeDefinition
|
|
29
|
+
*/
|
|
30
|
+
isAuthorised(placeDefinition: PlaceDefinition): boolean;
|
|
31
|
+
handleNotAuthenticated(activatedRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): UrlSnapshot | Visit;
|
|
32
|
+
handleNotAuthorisation(activatedRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): UrlSnapshot | Visit;
|
|
33
|
+
}
|
|
34
|
+
export declare namespace PlaceAuthService {
|
|
35
|
+
type AuthoriserCallback = (placeDef: PlaceDefinition) => boolean;
|
|
36
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ActivatedRouteSnapshot } from '@angular/router';
|
|
1
2
|
import { Constructable } from '@coolon/pectin';
|
|
2
3
|
import 'reflect-metadata';
|
|
3
4
|
import { DisposableComponent } from '../components/disposable-component';
|
|
@@ -30,6 +31,6 @@ export declare class PlaceComponent extends DisposableComponent {
|
|
|
30
31
|
export declare namespace PlaceComponent {
|
|
31
32
|
function isPlaceComponentConstructor(target: any): target is Constructable<PlaceComponent>;
|
|
32
33
|
function getRouteParameters(klass: Constructable<PlaceComponent>): ParameterDefinition<any>[];
|
|
33
|
-
function getDefinition(
|
|
34
|
+
function getDefinition(snapshotOrConstructor: ActivatedRouteSnapshot | Constructable<PlaceComponent>): PlaceDefinition;
|
|
34
35
|
function injectDefinition(klass: Constructable<PlaceComponent>, definition: PlaceDefinition): void;
|
|
35
36
|
}
|
|
@@ -7,12 +7,13 @@ export declare class PlaceDefinition {
|
|
|
7
7
|
readonly component: Constructable<PlaceComponent>;
|
|
8
8
|
readonly path: string;
|
|
9
9
|
readonly authenticate: boolean;
|
|
10
|
+
readonly roles: string[];
|
|
10
11
|
readonly data: {
|
|
11
12
|
[key: string]: any;
|
|
12
13
|
};
|
|
13
14
|
readonly routeParameters: ParameterDefinition<any>[];
|
|
14
15
|
readonly children: PlaceDefinition[];
|
|
15
|
-
constructor(component: Constructable<PlaceComponent>, path: string, authenticate: boolean, data: {
|
|
16
|
+
constructor(component: Constructable<PlaceComponent>, path: string, authenticate: boolean, roles: string[], data: {
|
|
16
17
|
[key: string]: any;
|
|
17
18
|
}, routeParameters: ParameterDefinition<any>[], children: PlaceDefinition[]);
|
|
18
19
|
hasRouteId(): boolean;
|
|
@@ -25,6 +25,7 @@ export declare class PlaceRouter extends GarbageCollector {
|
|
|
25
25
|
constructor(angularRouter: Router, angularLocation: Location, interactionService: InteractionService, urlService: UrlService, placeHistory: PlaceHistory);
|
|
26
26
|
get navigationSession(): NavigationSession;
|
|
27
27
|
get currentSession(): NavigationSession;
|
|
28
|
+
isNavigating(): boolean;
|
|
28
29
|
onPopState(event: NavigationStart): void;
|
|
29
30
|
onRouterStarted(event: NavigationStart): void;
|
|
30
31
|
onUrlChanged(newUrl: string): void;
|
package/package.json
CHANGED
|
@@ -19,6 +19,10 @@ function bootstrapApp(_options) {
|
|
|
19
19
|
schematics_1.externalSchematic('@coolon/angular-ui-powerups', 'aup-i18n', {
|
|
20
20
|
project: _options.project
|
|
21
21
|
}),
|
|
22
|
+
schematics_1.externalSchematic('@coolon/angular-ui-powerups', 'place-bootstrap', {
|
|
23
|
+
project: _options.project,
|
|
24
|
+
path: "places"
|
|
25
|
+
}),
|
|
22
26
|
updatePackageJsonScripts(buildContext)
|
|
23
27
|
];
|
|
24
28
|
// if (_options.initialPlaceName) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/angular-ui-powerups/schematics/bootstrap-app/index.ts"],"names":[],"mappings":";;;AAAA,+CAA6D;AAC7D,2DAaoC;AACpC,kDAAoD;AAEpD,kDAA+C;AAG/C,yFAAyF;AAEzF,SAAgB,YAAY,CAAC,QAAgB;IAE3C,OAAO,CAAC,IAAU,EAAE,QAA0B,EAAE,EAAE;QAEhD,MAAM,SAAS,GAAG,qBAAS,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACjD,MAAM,YAAY,GAAG,SAAS,CAAC,uBAAuB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;QAExE,MAAM,cAAc,GAAG,kBAAkB,CACvC,gBAAG,CAAC,aAAa,CAAC,EAAE;YAClB,2BAAc,iCAAM,QAAQ,GAAK,cAAO,EAAG;YAC3C,iBAAI,CAAC,YAAY,CAAC,UA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+13,14 @@ import {
|
|
|
13
13
|
DIALOG_INTERACTION_SERVICE_DEFAULTS,
|
|
14
14
|
DialogInteractionContextFactory,
|
|
15
15
|
ModalInteractionContextFactory,
|
|
16
|
-
PlaceModule
|
|
16
|
+
PlaceModule,
|
|
17
|
+
PLACE_AUTH_SERVICE
|
|
17
18
|
} from "@coolon/angular-ui-powerups";
|
|
18
19
|
import {Logger} from "@coolon/pectin";
|
|
19
20
|
import {setAutoFreeze} from "immer";
|
|
20
21
|
import {environment} from "../environments/environment";
|
|
21
22
|
import {AppRoutingModule} from "./app-routing.module";
|
|
22
|
-
|
|
23
|
+
import {PlaceAuthService} from './auth/place-auth.service';
|
|
23
24
|
import {AppComponent} from "./app.component";
|
|
24
25
|
|
|
25
26
|
@NgModule({
|
|
@@ -35,6 +36,7 @@ import {AppComponent} from "./app.component";
|
|
|
35
36
|
MatToolbarModule
|
|
36
37
|
],
|
|
37
38
|
providers: [
|
|
39
|
+
{provide: PLACE_AUTH_SERVICE, useClass: PlaceAuthService},
|
|
38
40
|
{provide: DIALOG_INTERACTION_SERVICE_DEFAULTS, useValue: {restoreFocus: true}},
|
|
39
41
|
{provide: ModalInteractionContextFactory, useClass: DialogInteractionContextFactory},
|
|
40
42
|
{provide: LOCALE_ID, useValue: 'en-AU'},
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
|
|
3
|
+
import { PlaceAuthService as IPlaceAuthService, PlaceDefinition, Visit } from '@coolon/angular-ui-powerups';
|
|
4
|
+
import { lang, GarbageCollector, MutableValueModel, ValueModel } from '@coolon/pectin';
|
|
5
|
+
|
|
6
|
+
@Injectable({
|
|
7
|
+
providedIn: 'root'
|
|
8
|
+
})
|
|
9
|
+
export class PlaceAuthService extends GarbageCollector implements IPlaceAuthService {
|
|
10
|
+
|
|
11
|
+
private readonly _authoriserModel = new MutableValueModel<IPlaceAuthService.AuthoriserCallback>();
|
|
12
|
+
|
|
13
|
+
constructor() {
|
|
14
|
+
super()
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
get authoriserModel(): ValueModel<IPlaceAuthService.AuthoriserCallback> {
|
|
18
|
+
return this._authoriserModel.readonly;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
isAuthenticated(): boolean | Promise<boolean> {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
isAuthorised(placeDefinition: PlaceDefinition): boolean {
|
|
26
|
+
return this._authoriserModel.value(placeDefinition);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
handleNotAuthenticated(next: ActivatedRouteSnapshot, state: RouterStateSnapshot): Visit {
|
|
30
|
+
// Note: the the router.navigateByUrl(returnUrl) fails if there's no forward slash in the url.
|
|
31
|
+
// const returnUrl = !next.url.toString().includes('login') ? `/${next.url}` : '/';
|
|
32
|
+
// return placeDestinations.loginPlace.createVisit({ returnUrl })
|
|
33
|
+
return lang.notImplemented();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
handleNotAuthorisation(activatedRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Visit {
|
|
37
|
+
// return placeDestinations.home.createVisit();
|
|
38
|
+
return lang.notImplemented();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
}
|
|
@@ -19,6 +19,11 @@
|
|
|
19
19
|
"factory": "./aup-i18n/index#run",
|
|
20
20
|
"schema": "./aup-i18n/schema.json"
|
|
21
21
|
},
|
|
22
|
+
"place-bootstrap": {
|
|
23
|
+
"description": "Initialises a new folder with place module and empty routes file.",
|
|
24
|
+
"factory": "./place-bootstrap/index#bootstrapPlaces",
|
|
25
|
+
"schema": "./place-bootstrap/schema.json"
|
|
26
|
+
},
|
|
22
27
|
"place-routes": {
|
|
23
28
|
"description": "Scans your source for place components and generates the place routes file",
|
|
24
29
|
"factory": "./place-routes/index#generateRoutes",
|
|
@@ -20,7 +20,7 @@ function installDependencies(_options) {
|
|
|
20
20
|
return package_util_1.updatePackageJson(tree, draft => {
|
|
21
21
|
draft.scripts = Object.assign(Object.assign({}, draft.scripts), { "place-routes": "run-s place-routes:**", "i18n": "run-s i18n:**", "watch": "npm-watch" });
|
|
22
22
|
draft.dependencies = Object.assign(Object.assign({}, draft.dependencies), { "@coolon/pectin": "^3.2.5", '@coolon/typescript-utilities': '^2.0.2', 'roboto-fontface': '^0.10.0', "@fortawesome/angular-fontawesome": "^0.7.0", "@fortawesome/fontawesome-free": "5.15.1", "@fortawesome/fontawesome-svg-core": "^1.2.32", "@fortawesome/free-solid-svg-icons": "^5.15.1", "@js-joda/core": "^3.2.0", "@js-joda/locale": "^3.2.0", "@js-joda/timezone": "^2.3.0", 'cldr-data': '^36.0.0', 'cldrjs': '^0.5.4', 'immer': '^7.0.5', 'reflect-metadata': '^0.1.13', 'resize-observer-polyfill': '^1.5.1', 'typescript-string-enums': '^1.0.0', "format-message-interpret": "^6.2.3", "@angular/material-moment-adapter": "^10.2.1", 'moment': '2.27.0' });
|
|
23
|
-
draft.devDependencies = Object.assign(Object.assign({}, draft.devDependencies), { 'husky': '^4.2.0', '@coolon/i18n-resource-generator': '^2.0.13', 'barrelsby': '^2.1.1', 'dotenv': '6.2.0', 'cz-conventional-changelog': '^3.1.0', "@commitlint/cli": "^8.3.5", 'git-is-clean': '^3.0.1', 'shx': '^0.3.2', 'standard-version': '^8.0.0', "npm-watch": "^0.7.0" });
|
|
23
|
+
draft.devDependencies = Object.assign(Object.assign({}, draft.devDependencies), { 'husky': '^4.2.0', '@coolon/i18n-resource-generator': '^2.0.13', "cypress-wait-until": "^1.6.1", 'barrelsby': '^2.1.1', 'dotenv': '6.2.0', 'cz-conventional-changelog': '^3.1.0', "@commitlint/cli": "^8.3.5", 'git-is-clean': '^3.0.1', 'shx': '^0.3.2', 'standard-version': '^8.0.0', "npm-watch": "^0.7.0" });
|
|
24
24
|
draft.watch = Object.assign({}, draft.watch);
|
|
25
25
|
draft.config = Object.assign(Object.assign({}, draft.config), { commitizen: {
|
|
26
26
|
path: './node_modules/cz-conventional-changelog'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/angular-ui-powerups/schematics/ng-add/index.ts"],"names":[],"mappings":";;;AAAA,2DAAiF;AACjF,4DAA0E;AAC1E,kDAAoD;AAEpD,uBAAuB;AACvB,SAAgB,KAAK,CAAC,QAAa;IACjC,OAAO,kBAAK,CAAC;QACX,CAAC,IAAU,EAAE,QAA0B,EAAE,EAAE;YACzC,QAAQ,CAAC,OAAO,CAAC,IAAI,8BAAsB,EAAE,CAAC,CAAC;YAC/C,OAAO,IAAI,CAAC;QACd,CAAC;QACD,mBAAmB,CAAC,QAAQ,CAAC;KAC9B,CAAC,CAAC;AACL,CAAC;AARD,sBAQC;AAED,SAAgB,mBAAmB,CAAC,QAAa;IAC/C,OAAO,CAAC,IAAU,EAAE,CAAmB,EAAQ,EAAE;QAC/C,OAAO,gCAAiB,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE;YACrC,KAAK,CAAC,OAAO,mCACR,KAAK,CAAC,OAAO,KAChB,cAAc,EAAE,uBAAuB,EACvC,MAAM,EAAE,eAAe,EACvB,OAAO,EAAE,WAAW,GACrB,CAAC;YAEF,KAAK,CAAC,YAAY,mCACb,KAAK,CAAC,YAAY,KACrB,gBAAgB,EAAE,QAAQ,EAC1B,8BAA8B,EAAE,QAAQ,EACxC,iBAAiB,EAAE,SAAS,EAC5B,kCAAkC,EAAE,QAAQ,EAC5C,+BAA+B,EAAE,QAAQ,EACzC,mCAAmC,EAAE,SAAS,EAC9C,mCAAmC,EAAE,SAAS,EAC9C,eAAe,EAAE,QAAQ,EACzB,iBAAiB,EAAE,QAAQ,EAC3B,mBAAmB,EAAE,QAAQ,EAC7B,WAAW,EAAE,SAAS,EACtB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,QAAQ,EACjB,kBAAkB,EAAE,SAAS,EA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KAAK,CAAC,KAAK,CACf,CAAA;YAED,KAAK,CAAC,MAAM,mCACP,KAAK,CAAC,MAAM,KACf,UAAU,EAAE;oBACV,IAAI,EAAE,0CAA0C;iBACjD,GACF,CAAC;YAEF,KAAK,CAAC,KAAK,GAAG;gBACZ,OAAO,EAAE;oBACP,YAAY,EAAE,gCAAgC;iBAC/C;aACF,CAAC;QAEJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAnED,kDAmEC"}
|
|
@@ -14,7 +14,7 @@ function addPlace(_options) {
|
|
|
14
14
|
const pathToSourceRoot = [buildContext.sourceCodeRoot].concat(componentPathParts);
|
|
15
15
|
const placeModulePath = buildContext.findFileInAncestorPath(pathToSourceRoot, 'places.module.ts');
|
|
16
16
|
if (!placeModulePath) {
|
|
17
|
-
throw new Error(`Places must be created in a directory containing a 'places.module.ts'
|
|
17
|
+
throw new Error(`Places must be created in or under a directory containing a 'places.module.ts'. I couldn't find one in ${pathToSourceRoot.join('/')} or in any ancestor of it. You can run ng g @coolon/angular-ui-powerups:place-bootstrap --dir=<directory> to initialise one`);
|
|
18
18
|
}
|
|
19
19
|
const placeModule = buildContext.getSourceFile(placeModulePath);
|
|
20
20
|
const newPlaceModuleContent = updatePlaceModule(placeModule);
|
|
@@ -31,6 +31,7 @@ function addPlace(_options) {
|
|
|
31
31
|
}
|
|
32
32
|
exports.addPlace = addPlace;
|
|
33
33
|
function updatePlaceModule(placeModule) {
|
|
34
|
+
// TODO: Make this work.
|
|
34
35
|
// const imports = placeModule.getImportDeclarations();
|
|
35
36
|
const moduleClass = placeModule.findClassWithDecorator('@NgModule');
|
|
36
37
|
const decorator = moduleClass.getClassDecoratorNode('@NgModule');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/angular-ui-powerups/schematics/place-add/index.ts"],"names":[],"mappings":";;;AAAA,2DAAiF;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","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AC,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;SACtD,EACD,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,aAAa,EAAE,CACnD,CAAC;QAGF,MAAM,eAAe,GAAG,gDAA2B,CACjD,IAAI,EACJ,iBAAiB,EACjB;YACE,IAAI,EAAE,aAAa;SACpB,EACD,YAAY,CAAC,UAAU,CAAC,CAAC;QAE3B,OAAO,kBAAK,CAAC,CAAC,cAAc,EAAE,eAAe,CAAC,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAEjE,CAAC,CAAC;AAEJ,CAAC;AA1CD,4BA0CC;AAED,SAAS,iBAAiB,CAAC,WAAgC;IAEzD,wBAAwB;IAExB,uDAAuD;IACvD,MAAM,WAAW,GAAG,WAAW,CAAC,sBAAsB,CAAC,WAAW,CAAC,CAAC;IACpE,MAAM,SAAS,GAAG,WAAW,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC;IAEjE,OAAO,WAAW,CAAC,WAAW,EAAE,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bootstrapPlaces = void 0;
|
|
4
|
+
const template_utilities_1 = require("../utils/template-utilities");
|
|
5
|
+
const workspace_1 = require("../utils/workspace");
|
|
6
|
+
function bootstrapPlaces(_options) {
|
|
7
|
+
return (tree, context) => {
|
|
8
|
+
const workspace = workspace_1.Workspace.load(tree, context);
|
|
9
|
+
const buildContext = workspace.getApplication(_options.project);
|
|
10
|
+
const nameParts = _options.path.split('/');
|
|
11
|
+
const directoryName = nameParts[nameParts.length - 1];
|
|
12
|
+
const componentPathParts = nameParts.slice(0, nameParts.length - 1);
|
|
13
|
+
const pathToSourceRoot = [buildContext.sourceCodeRoot].concat(componentPathParts);
|
|
14
|
+
return template_utilities_1.applyTemplatesWithOverwrite(tree, 'templates', {
|
|
15
|
+
name: directoryName
|
|
16
|
+
}, `${(pathToSourceRoot.join('/'))}`);
|
|
17
|
+
// return chain([placeModuleFiles])(tree, context);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
exports.bootstrapPlaces = bootstrapPlaces;
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/angular-ui-powerups/schematics/place-bootstrap/index.ts"],"names":[],"mappings":";;;AACA,oEAA0E;AAC1E,kDAA+C;AAI/C,SAAgB,eAAe,CAAC,QAAgB;IAE9C,OAAO,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE;QAE/C,MAAM,SAAS,GAAG,qBAAS,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAChD,MAAM,YAAY,GAAG,SAAS,CAAC,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAEhE,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC3C,MAAM,aAAa,GAAG,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACtD,MAAM,kBAAkB,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACpE,MAAM,gBAAgB,GAAG,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;QAElF,OAAO,gDAA2B,CAChC,IAAI,EACJ,WAAW,EACX;YACE,IAAI,EAAE,aAAa;SACpB,EACD,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAClC,CAAC;QAEF,mDAAmD;IACrD,CAAC,CAAC;AAEJ,CAAC;AAxBD,0CAwBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../../libs/angular-ui-powerups/schematics/place-bootstrap/schema.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"id": "AddPlaceSchematic",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"description": "Add a new place component",
|
|
6
|
+
"properties": {
|
|
7
|
+
"project": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "The name of the project.",
|
|
10
|
+
"$default": {
|
|
11
|
+
"$source": "projectName"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"path": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "The directory path to bootstrap relative to <project-root>/src/app.",
|
|
17
|
+
"$default": {
|
|
18
|
+
"$source": "argv",
|
|
19
|
+
"index": 0
|
|
20
|
+
},
|
|
21
|
+
"x-prompt": "What is the path to the place root directory?"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"required": [
|
|
25
|
+
"project",
|
|
26
|
+
"path"
|
|
27
|
+
]
|
|
28
|
+
}
|
|
@@ -3,9 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.PlaceBuilder = void 0;
|
|
4
4
|
const core_1 = require("@angular-devkit/core");
|
|
5
5
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
6
|
-
const
|
|
6
|
+
const path = require("path");
|
|
7
7
|
const ts_morph_1 = require("ts-morph");
|
|
8
8
|
const place_def_1 = require("./place-def");
|
|
9
|
+
// interface Config {
|
|
10
|
+
// authGuard: ClassImport;
|
|
11
|
+
// }
|
|
12
|
+
// interface PlaceRoot {
|
|
13
|
+
// dir: string,
|
|
14
|
+
// }
|
|
15
|
+
const noopRule = (tree, context) => tree;
|
|
9
16
|
class PlaceBuilder {
|
|
10
17
|
constructor(options, workspace, context) {
|
|
11
18
|
this.options = options;
|
|
@@ -36,15 +43,16 @@ class PlaceBuilder {
|
|
|
36
43
|
}
|
|
37
44
|
process(tree) {
|
|
38
45
|
const placeRoots = [];
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
46
|
+
placeRoots.push(this.options.dir); // todo support multiple place roots on a single run.
|
|
47
|
+
const rules = placeRoots.map(r => path.join(this.sourceRoot, r)).map(placeRoot => {
|
|
48
|
+
const placeDefs = this.extractPlaceDefinitions(tree, placeRoot);
|
|
49
|
+
if (placeDefs.length < 1) {
|
|
50
|
+
this.context.logger.info(`No places found in ${placeRoot}`);
|
|
51
|
+
return noopRule;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
return this.renderTemplates(placeRoot, placeDefs, tree);
|
|
43
55
|
}
|
|
44
|
-
});
|
|
45
|
-
const rules = placeRoots.map(placeRoot => {
|
|
46
|
-
const placeDefs = this.extractPlaceDefinitions(tree, placeRoot.dir);
|
|
47
|
-
return this.renderTemplates(placeRoot, placeDefs, tree);
|
|
48
56
|
});
|
|
49
57
|
return schematics_1.chain(rules);
|
|
50
58
|
}
|
|
@@ -52,8 +60,8 @@ class PlaceBuilder {
|
|
|
52
60
|
// this.context.logger.info(`${this.workspaceProject.sourceRoot}/${this.projectType}`);
|
|
53
61
|
// this.context.logger.info(placeRoot.dir);
|
|
54
62
|
const files = schematics_1.apply(schematics_1.url('./templates'), [
|
|
55
|
-
schematics_1.applyTemplates(Object.assign(Object.assign(Object.assign({}, this.options), {
|
|
56
|
-
schematics_1.move(`${placeRoot
|
|
63
|
+
schematics_1.applyTemplates(Object.assign(Object.assign(Object.assign({}, this.options), { placeDefs }), core_1.strings)),
|
|
64
|
+
schematics_1.move(`${placeRoot}`),
|
|
57
65
|
// @see https://github.com/angular/angular-cli/issues/11337#issuecomment-448259549
|
|
58
66
|
schematics_1.forEach((fileEntry) => {
|
|
59
67
|
this.context.logger.info(fileEntry.path);
|
|
@@ -65,19 +73,21 @@ class PlaceBuilder {
|
|
|
65
73
|
]);
|
|
66
74
|
return schematics_1.mergeWith(files);
|
|
67
75
|
}
|
|
68
|
-
parseConfig(configString) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
// private parseConfig(configString: string): Config {
|
|
77
|
+
// const rawConfig = JSON5.parse(configString);
|
|
78
|
+
// const config:Config = {
|
|
79
|
+
// authGuard: {
|
|
80
|
+
// className: 'NoopAuthGuard', importPath: '@coolon/angular-ui-powerups', ...rawConfig.authGuard
|
|
81
|
+
// }
|
|
82
|
+
// };
|
|
83
|
+
// this.context.logger.info(`config: ${JSON5.stringify(config)}`);
|
|
84
|
+
// return config;
|
|
85
|
+
// }
|
|
86
|
+
extractPlaceDefinitions(tree, placeRootPath) {
|
|
78
87
|
const placeDefs = [];
|
|
79
|
-
this.context.logger.info(`Scanning sources in -> ${
|
|
80
|
-
tree.getDir(
|
|
88
|
+
this.context.logger.info(`Scanning sources in -> ${placeRootPath}`);
|
|
89
|
+
const placeRootDir = tree.getDir(placeRootPath);
|
|
90
|
+
placeRootDir.visit(filePath => {
|
|
81
91
|
if (!filePath.endsWith('.ts') || filePath.endsWith('.spec.ts')) {
|
|
82
92
|
return;
|
|
83
93
|
}
|
|
@@ -93,7 +103,7 @@ class PlaceBuilder {
|
|
|
93
103
|
const imports = sourceFile.getImportDeclarations();
|
|
94
104
|
sourceFile.getClasses().forEach((classDecl) => {
|
|
95
105
|
place_def_1.PlaceDef.scan(sourceFile, classDecl, this.context).onMatch(result => {
|
|
96
|
-
const moduleImportPath = `.${filePath.substr(
|
|
106
|
+
const moduleImportPath = `.${filePath.substr(placeRootDir.path.length, filePath.length - placeRootDir.path.length - '.ts'.length)}`;
|
|
97
107
|
const definition = result.createDefinition(moduleImportPath);
|
|
98
108
|
this.context.logger.info(`${classDecl.getName()}(route: /${definition.fullPath}) -> ${moduleImportPath}`);
|
|
99
109
|
placeDefs.push(definition);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"place-builder.js","sourceRoot":"","sources":["../../../../../libs/angular-ui-powerups/schematics/place-routes/place-builder.ts"],"names":[],"mappings":";;;AAAA,+CAA6D;AAC7D,2DAYoC;AACpC
|
|
1
|
+
{"version":3,"file":"place-builder.js","sourceRoot":"","sources":["../../../../../libs/angular-ui-powerups/schematics/place-routes/place-builder.ts"],"names":[],"mappings":";;;AAAA,+CAA6D;AAC7D,2DAYoC;AACpC,6BAA6B;AAC7B,uCAAqD;AACrD,2CAAuC;AAQvC,qBAAqB;AACrB,4BAA4B;AAC5B,IAAI;AAEJ,wBAAwB;AACxB,iBAAiB;AACjB,IAAI;AAEJ,MAAM,QAAQ,GAAG,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE,CAAC,IAAI,CAAC;AAEjE,MAAa,YAAY;IAUvB,YAAqB,OAAe,EAAE,SAAiD,EAAW,OAAyB;QAAtG,YAAO,GAAP,OAAO,CAAQ;QAA8D,YAAO,GAAP,OAAO,CAAkB;QACzH,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,OAAiB,CAAC;QAC7C,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC7D,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,gBAAgB,CAAC,WAAW,KAAK,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;QACvF,IAAI,CAAC,UAAU,GAAG,GAAG,IAAI,CAAC,gBAAgB,CAAC,UAAU,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;QAC5E,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;QAC3E,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAEtD,IAAI,CAAC,OAAO,CAAC,MAA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