Skip to content

Commit af32ad7

Browse files
authored
feat: Angular 14 (#72)
1 parent a786b65 commit af32ad7

File tree

15 files changed

+85
-55
lines changed

15 files changed

+85
-55
lines changed

apps/nativescript-demo-ng/project.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
23
"sourceRoot": "apps/nativescript-demo-ng/src",
34
"projectType": "application",
45
"prefix": "nativescript",

apps/nativescript-demo-ng/tsconfig.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,8 @@
1212
{
1313
"path": "./tsconfig.editor.json"
1414
}
15-
]
15+
],
16+
"compilerOptions": {
17+
"target": "es2020"
18+
}
1619
}

nx.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,5 @@
3838
}
3939
]
4040
},
41-
"cli": {
42-
"defaultCollection": "@nstudio/xplat"
43-
}
41+
"$schema": "./node_modules/nx/schemas/nx-schema.json"
4442
}

package.json

+33-33
Original file line numberDiff line numberDiff line change
@@ -35,49 +35,49 @@
3535
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s"
3636
},
3737
"dependencies": {
38-
"@angular/animations": "13.3.10",
39-
"@angular/common": "13.3.10",
40-
"@angular/compiler": "13.3.10",
41-
"@angular/core": "13.3.10",
42-
"@angular/forms": "13.3.10",
43-
"@angular/platform-browser": "13.3.10",
44-
"@angular/platform-browser-dynamic": "13.3.10",
45-
"@angular/router": "13.3.10",
46-
"@nativescript/core": "~8.1.0",
38+
"@angular/animations": "14.0.1",
39+
"@angular/common": "14.0.1",
40+
"@angular/compiler": "14.0.1",
41+
"@angular/core": "14.0.1",
42+
"@angular/forms": "14.0.1",
43+
"@angular/platform-browser": "14.0.1",
44+
"@angular/platform-browser-dynamic": "14.0.1",
45+
"@angular/router": "14.0.1",
46+
"@nativescript/core": "~8.2.0",
4747
"@nativescript/theme": "~3.0.0",
4848
"@ngx-translate/core": "~14.0.0",
4949
"nativescript-ngx-fonticon": "~7.0.0",
5050
"rxjs": "^7.5.0",
51-
"zone.js": "~0.11.4"
51+
"zone.js": "~0.11.5"
5252
},
5353
"devDependencies": {
54-
"@angular-devkit/build-angular": "13.3.7",
55-
"@angular-eslint/eslint-plugin": "13.0.1",
56-
"@angular-eslint/eslint-plugin-template": "13.0.1",
57-
"@angular-eslint/template-parser": "13.0.1",
58-
"@angular/compiler-cli": "13.3.10",
54+
"@angular-devkit/build-angular": "14.0.1",
55+
"@angular-eslint/eslint-plugin": "13.2.1",
56+
"@angular-eslint/eslint-plugin-template": "13.2.1",
57+
"@angular-eslint/template-parser": "13.2.1",
58+
"@angular/compiler-cli": "14.0.1",
5959
"@jsdevtools/coverage-istanbul-loader": "3.0.5",
6060
"@nativescript/types": "~8.2.0",
6161
"@nativescript/unit-test-runner": "^3.0.2",
6262
"@nativescript/webpack": "~5.0.0",
63-
"@ngtools/webpack": "13.3.7",
64-
"@nrwl/angular": "14.1.9",
65-
"@nrwl/cli": "14.1.9",
66-
"@nrwl/eslint-plugin-nx": "14.1.9",
67-
"@nrwl/jest": "14.1.9",
68-
"@nrwl/js": "14.1.9",
69-
"@nrwl/node": "14.1.9",
70-
"@nrwl/workspace": "14.1.9",
63+
"@ngtools/webpack": "14.0.1",
64+
"@nrwl/angular": "14.2.4",
65+
"@nrwl/cli": "14.2.4",
66+
"@nrwl/eslint-plugin-nx": "14.2.4",
67+
"@nrwl/jest": "14.2.4",
68+
"@nrwl/js": "14.2.4",
69+
"@nrwl/node": "14.2.4",
70+
"@nrwl/workspace": "14.2.4",
7171
"@nstudio/angular": "14.0.1",
7272
"@nstudio/nativescript": "14.0.1",
7373
"@nstudio/nativescript-angular": "14.0.1",
7474
"@nstudio/xplat": "14.0.1",
75-
"@types/jasmine": "^3.7.2",
75+
"@types/jasmine": "4.0.3",
7676
"@types/jest": "27.4.1",
77-
"@types/node": "14.14.33",
77+
"@types/node": "17.0.41",
7878
"@types/sinon": "^10.0.2",
79-
"@typescript-eslint/eslint-plugin": "4.19.0",
80-
"@typescript-eslint/parser": "4.19.0",
79+
"@typescript-eslint/eslint-plugin": "~5.24.0",
80+
"@typescript-eslint/parser": "~5.24.0",
8181
"conventional-changelog-cli": "^2.1.1",
8282
"dotenv": "10.0.0",
8383
"eslint": "7.22.0",
@@ -87,25 +87,25 @@
8787
"jest": "27.5.1",
8888
"karma": "6.3.20",
8989
"karma-coverage": "2.0.3",
90-
"karma-jasmine": "4.0.1",
90+
"karma-jasmine": "5.0.1",
9191
"karma-mocha-reporter": "^2.2.5",
9292
"karma-nativescript-launcher": "0.4.0",
9393
"karma-sinon": "^1.0.5",
9494
"lint-staged": "^11.0.0",
95-
"ng-packagr": "13.3.1",
96-
"nx": "14.1.9",
95+
"ng-packagr": "14.0.1",
96+
"nx": "14.2.4",
9797
"nyc": "15.1.0",
9898
"postcss": "^8.3.9",
9999
"postcss-import": "14.1.0",
100100
"postcss-preset-env": "7.5.0",
101101
"postcss-url": "10.1.3",
102-
"prettier": "2.5.1",
102+
"prettier": "2.6.2",
103103
"sass": "^1.32.0",
104104
"sinon": "^11.1.1",
105105
"ts-jest": "27.1.4",
106-
"ts-node": "9.1.1",
106+
"ts-node": "10.8.1",
107107
"tslib": "^2.1.0",
108-
"typescript": "4.6.4"
108+
"typescript": "4.7.3"
109109
},
110110
"xplat": {
111111
"prefix": "nativescript",

packages/angular/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nativescript/angular",
3-
"version": "13.0.4",
3+
"version": "14.0.0-rc.0",
44
"homepage": "https://nativescript.org/",
55
"repository": {
66
"type": "git",

packages/angular/project.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
23
"sourceRoot": "packages/angular/src",
34
"projectType": "library",
45
"generators": {},

packages/angular/src/lib/animations/animation-driver.ts

+4
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ class Selector {
6363
export class NativeScriptAnimationDriver implements AnimationDriver {
6464
private static validProperties = [...CssAnimationProperty._getPropertyNames(), 'transform'];
6565

66+
getParentElement(element: NgView): NgView {
67+
return element?.parent as NgView;
68+
}
69+
6670
validateStyleProperty(property: string): boolean {
6771
NativeScriptDebug.animationsLog(`CssAnimationProperty.validateStyleProperty: ${property}`);
6872
return NativeScriptAnimationDriver.validProperties.indexOf(property) !== -1;

packages/angular/src/lib/animations/utils.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import { KeyframeAnimation, KeyframeAnimationInfo, KeyframeDeclaration, KeyframeInfo, parseKeyframeDeclarations, animationTimingFunctionConverter } from '@nativescript/core';
22

3-
export interface Keyframe {
4-
[key: string]: string | number;
5-
offset: number;
6-
}
3+
export type Keyframe = Map<string, string | number> & { offset: number };
74

85
const DASH_CASE_REGEXP = /-+([a-z0-9])/g;
96
export function dashCaseToCamelCase(input: string): string {

packages/angular/src/lib/legacy/router/ns-location-strategy.ts

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ export class NSLocationStrategy extends LocationStrategy {
2828
}
2929
}
3030

31+
getState(): unknown {
32+
return this.currentOutlet && this.currentOutlet.peekState();
33+
}
34+
3135
path(): string {
3236
if (!this.currentUrlTree) {
3337
return this.startPath || '/';

packages/angular/src/lib/legacy/router/page-router-outlet.ts

+28-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Attribute, ChangeDetectorRef, ComponentFactory, ComponentFactoryResolver, ComponentRef, Directive, Inject, InjectionToken, Injector, OnDestroy, EventEmitter, Output, Type, ViewContainerRef, ElementRef, InjectFlags, NgZone } from '@angular/core';
2-
import { ActivatedRoute, ActivatedRouteSnapshot, ChildrenOutletContexts, PRIMARY_OUTLET } from '@angular/router';
1+
import { Attribute, ChangeDetectorRef, ComponentFactory, ComponentFactoryResolver, ComponentRef, Directive, Inject, InjectionToken, Injector, OnDestroy, EventEmitter, Output, Type, ViewContainerRef, ElementRef, InjectFlags, NgZone, EnvironmentInjector } from '@angular/core';
2+
import { ActivatedRoute, ActivatedRouteSnapshot, ChildrenOutletContexts, Data, PRIMARY_OUTLET, RouterOutletContract } from '@angular/router';
33

44
import { Frame, Page, NavigatedData, profile, NavigationEntry } from '@nativescript/core';
55

@@ -54,7 +54,7 @@ registerElement('page-router-outlet', () => Frame);
5454
// eslint-disable-next-line @angular-eslint/directive-selector
5555
@Directive({ selector: 'page-router-outlet' }) // tslint:disable-line:directive-selector
5656
// eslint-disable-next-line @angular-eslint/directive-class-suffix
57-
export class PageRouterOutlet implements OnDestroy {
57+
export class PageRouterOutlet implements OnDestroy, RouterOutletContract {
5858
// tslint:disable-line:directive-class-suffix
5959
private activated: ComponentRef<any> | null = null;
6060
private _activatedRoute: ActivatedRoute | null = null;
@@ -66,6 +66,9 @@ export class PageRouterOutlet implements OnDestroy {
6666
private viewUtil: ViewUtil;
6767
private frame: Frame;
6868

69+
attachEvents: EventEmitter<unknown> = new EventEmitter();
70+
detachEvents: EventEmitter<unknown> = new EventEmitter();
71+
6972
// eslint-disable-next-line @angular-eslint/no-output-rename
7073
@Output('activate') activateEvents = new EventEmitter<any>(); // tslint:disable-line:no-output-rename
7174
// eslint-disable-next-line @angular-eslint/no-output-rename
@@ -105,6 +108,13 @@ export class PageRouterOutlet implements OnDestroy {
105108
return this._activatedRoute;
106109
}
107110

111+
get activatedRouteData(): Data {
112+
if (this._activatedRoute) {
113+
return this._activatedRoute.snapshot.data;
114+
}
115+
return {};
116+
}
117+
108118
constructor(
109119
private parentContexts: ChildrenOutletContexts,
110120
private location: ViewContainerRef,
@@ -222,6 +232,7 @@ export class PageRouterOutlet implements OnDestroy {
222232
const component = this.activated;
223233
this.activated = null;
224234
this._activatedRoute = null;
235+
this.detachEvents.emit(component.instance);
225236
return component;
226237
}
227238

@@ -245,6 +256,7 @@ export class PageRouterOutlet implements OnDestroy {
245256
if (this.isFinalPageRouterOutlet()) {
246257
this.locationStrategy._finishBackPageNavigation(this.frame);
247258
}
259+
this.attachEvents.emit(ref.instance);
248260
}
249261

250262
private isFinalPageRouterOutlet() {
@@ -267,7 +279,7 @@ export class PageRouterOutlet implements OnDestroy {
267279
* This method in turn is responsible for calling the `routerOnActivate` hook of its child.
268280
*/
269281
@profile
270-
activateWith(activatedRoute: ActivatedRoute, resolver: ComponentFactoryResolver | null): void {
282+
activateWith(activatedRoute: ActivatedRoute, resolver: ComponentFactoryResolver | EnvironmentInjector | null): void {
271283
this.outlet = this.outlet || this.getOutlet(activatedRoute.snapshot);
272284
if (!this.outlet) {
273285
if (NativeScriptDebug.isLogEnabled()) {
@@ -302,12 +314,21 @@ export class PageRouterOutlet implements OnDestroy {
302314
this.activateEvents.emit(this.activated.instance);
303315
}
304316

305-
private activateOnGoForward(activatedRoute: ActivatedRoute, loadedResolver: ComponentFactoryResolver): void {
317+
private activateOnGoForward(activatedRoute: ActivatedRoute, loadedResolver: ComponentFactoryResolver | EnvironmentInjector): void {
306318
if (NativeScriptDebug.isLogEnabled()) {
307319
NativeScriptDebug.routerLog('PageRouterOutlet.activate() forward navigation - ' + 'create detached loader in the loader container');
308320
}
309321

310-
const factory = this.getComponentFactory(activatedRoute, loadedResolver);
322+
let resolver: ComponentFactoryResolver;
323+
let ourInjector = this.location.injector;
324+
if (!(loadedResolver instanceof ComponentFactoryResolver)) {
325+
ourInjector = loadedResolver;
326+
resolver = loadedResolver?.get(ComponentFactoryResolver);
327+
} else {
328+
resolver = loadedResolver;
329+
}
330+
331+
const factory = this.getComponentFactory(activatedRoute, resolver);
311332
const page = this.pageFactory({
312333
isNavigation: true,
313334
componentType: factory.componentType,
@@ -323,7 +344,7 @@ export class PageRouterOutlet implements OnDestroy {
323344
{ provide: ChildrenOutletContexts, useValue: this.parentContexts.getOrCreateContext(this.name).children },
324345
{ provide: PageService, useClass: PageService },
325346
],
326-
parent: this.location.injector,
347+
parent: ourInjector,
327348
});
328349

329350
const childInjector = new DestructibleInjector(destructables, injector);

packages/angular/src/lib/legacy/router/router.module.ts

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export function provideLocationStrategy(locationStrategy: NSLocationStrategy, fr
2828

2929
@NgModule({
3030
declarations: [NSRouterLink, NSRouterLinkActive, PageRouterOutlet, NSEmptyOutletComponent],
31-
entryComponents: [NSEmptyOutletComponent],
3231
imports: [RouterModule, NativeScriptCommonModule],
3332
exports: [RouterModule, NSRouterLink, NSRouterLinkActive, PageRouterOutlet, NSEmptyOutletComponent],
3433
schemas: [NO_ERRORS_SCHEMA],

packages/angular/src/lib/router/router.module.ts

-3
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,6 @@ export function provideLocationInitialized(startpath: string | Promise<string>)
131131
declarations: [
132132
/* NSRouterLink, NSRouterLinkActive, PageRouterOutlet, NSEmptyOutletComponent */
133133
],
134-
entryComponents: [
135-
/* NSEmptyOutletComponent */
136-
],
137134
imports: [RouterModule, NativeScriptCommonModule],
138135
exports: [RouterModule /* NSRouterLink, NSRouterLinkActive, PageRouterOutlet, NSEmptyOutletComponent */],
139136
schemas: [NO_ERRORS_SCHEMA],

packages/angular/tsconfig.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,8 @@
99
{
1010
"path": "./tsconfig.spec.json"
1111
}
12-
]
12+
],
13+
"compilerOptions": {
14+
"target": "es2020"
15+
}
1316
}

packages/zone-js/project.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
23
"sourceRoot": "packages/zone-js/src",
34
"projectType": "library",
45
"targets": {

workspace.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
"angular": "packages/angular",
55
"nativescript-demo-ng": "apps/nativescript-demo-ng",
66
"zone-js": "packages/zone-js"
7-
}
7+
},
8+
"$schema": "./node_modules/nx/schemas/workspace-schema.json"
89
}

0 commit comments

Comments
 (0)