From 548e0743eb092ba3fa371ea4d26879ee5bf03983 Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Thu, 3 Sep 2020 19:04:53 -0700 Subject: [PATCH 1/3] feat(angular): ng 10.1 and ns 7 (#2237) --- e2e/animation-examples/app/package.json | 9 ---- e2e/animation-examples/nativescript.config.ts | 11 +++++ e2e/animation-examples/package.json | 49 ++++++++----------- e2e/tests-app-ng/package.json | 28 +++++------ e2e/tests-app-ng/references.d.ts | 2 +- nativescript-angular/index.ts | 2 +- nativescript-angular/package.json | 43 ++++++++-------- 7 files changed, 69 insertions(+), 75 deletions(-) delete mode 100644 e2e/animation-examples/app/package.json create mode 100644 e2e/animation-examples/nativescript.config.ts diff --git a/e2e/animation-examples/app/package.json b/e2e/animation-examples/app/package.json deleted file mode 100644 index 706d1a31b..000000000 --- a/e2e/animation-examples/app/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "main": "main.js", - "name": "nativescript-template-ng-tutorial", - "version": "3.1.0", - "android": { - "v8Flags": "--expose_gc", - "markingMode": "none" - } -} \ No newline at end of file diff --git a/e2e/animation-examples/nativescript.config.ts b/e2e/animation-examples/nativescript.config.ts new file mode 100644 index 000000000..d117ed3e9 --- /dev/null +++ b/e2e/animation-examples/nativescript.config.ts @@ -0,0 +1,11 @@ +import { NativeScriptConfig } from '@nativescript/core' + +export default { + id: 'org.nativescript.ng4animations', + appResourcesPath: 'app/App_Resources', + android: { + v8Flags: '--expose_gc', + markingMode: 'none', + }, + appPath: 'app', +} as NativeScriptConfig diff --git a/e2e/animation-examples/package.json b/e2e/animation-examples/package.json index d000ce3e0..db7a45c75 100644 --- a/e2e/animation-examples/package.json +++ b/e2e/animation-examples/package.json @@ -1,36 +1,30 @@ { "description": "NativeScript Application", + "main": "main.js", "license": "SEE LICENSE IN ", "readme": "NativeScript Application", "repository": "", - "nativescript": { - "id": "org.nativescript.ng4animations", - "tns-ios": { - "version": "6.5.2" - }, - "tns-android": { - "version": "latest" - } - }, "dependencies": { - "@angular/animations": "~10.0.0", - "@angular/common": "~10.0.0", - "@angular/compiler": "~10.0.0", - "@angular/core": "~10.0.0", - "@angular/forms": "~10.0.0", - "@angular/platform-browser": "~10.0.0", - "@angular/platform-browser-dynamic": "~10.0.0", - "@angular/router": "~10.0.0", + "@angular/animations": "~10.1.0", + "@angular/common": "~10.1.0", + "@angular/compiler": "~10.1.0", + "@angular/core": "~10.1.0", + "@angular/forms": "~10.1.0", + "@angular/platform-browser": "~10.1.0", + "@angular/platform-browser-dynamic": "~10.1.0", + "@angular/router": "~10.1.0", "@nativescript/angular": "file:../../dist/nativescript-angular-scoped.tgz", "nativescript-theme-core": "~1.0.2", - "reflect-metadata": "~0.1.8", - "rxjs": "~6.5.5", - "@nativescript/core": "rc", - "zone.js": "^0.10.3" + "reflect-metadata": "~0.1.13", + "rxjs": "~6.6.0", + "@nativescript/core": "~7.0.0", + "zone.js": "^0.11.1" }, "devDependencies": { - "@angular/compiler-cli": "~10.0.0", - "@ngtools/webpack": "~10.0.0", + "@angular/compiler-cli": "~10.1.0", + "@nativescript/ios": "7.0.0", + "@nativescript/webpack": "~3.0.0", + "@ngtools/webpack": "~10.1.0", "@types/chai": "~4.2.0", "@types/mocha": "~7.0.0", "@types/node": "~14.0.0", @@ -41,13 +35,12 @@ "lazy": "~1.0.11", "mocha": "~8.0.1", "mochawesome": "~6.1.1", - "node-sass": "~4.14.1", "nativescript-css-loader": "~0.26.0", - "@nativescript/webpack": "rc", + "node-sass": "~4.14.1", "typescript": "~3.9.0" }, "scripts": { - "clean": "npx rimraf hooks node_modules platforms package-lock.json", + "clean": "ns clean", "setup": "cd ../../nativescript-angular && npm run prep.apps && cd ../e2e/animation-examples && npm run clean", "ngcc": "ngcc --properties es2015 module main --first-only", "postinstall": "npm run ngcc", @@ -56,7 +49,7 @@ "e2e-watch": "tsc -p e2e --watch", "ns-verify-bundle": "ns-verify-bundle", "update-ns-webpack": "update-ns-webpack", - "ios": "tns debug ios --emulator --no-hmr", - "android": "tns debug android --emulator --no-hmr" + "ios": "ns debug ios --emulator --no-hmr", + "android": "ns debug android --emulator --no-hmr" } } diff --git a/e2e/tests-app-ng/package.json b/e2e/tests-app-ng/package.json index e9c720517..2b288597b 100644 --- a/e2e/tests-app-ng/package.json +++ b/e2e/tests-app-ng/package.json @@ -13,31 +13,31 @@ } }, "dependencies": { - "@angular/animations": "~10.0.0", - "@angular/common": "~10.0.0", - "@angular/compiler": "~10.0.0", - "@angular/core": "~10.0.0", - "@angular/forms": "~10.0.0", - "@angular/platform-browser": "~10.0.0", - "@angular/platform-browser-dynamic": "~10.0.0", - "@angular/router": "~10.0.0", + "@angular/animations": "~10.1.0", + "@angular/common": "~10.1.0", + "@angular/compiler": "~10.1.0", + "@angular/core": "~10.1.0", + "@angular/forms": "~10.1.0", + "@angular/platform-browser": "~10.1.0", + "@angular/platform-browser-dynamic": "~10.1.0", + "@angular/router": "~10.1.0", "@nativescript/angular": "file:../../dist/nativescript-angular-scoped.tgz", "nativescript-theme-core": "^1.0.4", "reflect-metadata": "~0.1.8", - "rxjs": "~6.5.5", - "@nativescript/core": "rc", - "zone.js": "^0.10.3" + "rxjs": "~6.6.0", + "@nativescript/core": "~7.0.0", + "zone.js": "^0.11.1" }, "devDependencies": { - "@angular/compiler-cli": "~10.0.0", - "@ngtools/webpack": "~10.0.0", + "@angular/compiler-cli": "~10.1.0", + "@ngtools/webpack": "~10.1.0", "babel-traverse": "6.24.1", "babel-types": "6.24.1", "babylon": "6.17.0", "codelyzer": "^5.1.0", "filewalker": "^0.1.3", "lazy": "1.0.11", - "@nativescript/webpack": "~2.1.1", + "@nativescript/webpack": "~3.0.0", "typescript": "~3.9.0" }, "scripts": { diff --git a/e2e/tests-app-ng/references.d.ts b/e2e/tests-app-ng/references.d.ts index b14f3837d..a5bb99810 100644 --- a/e2e/tests-app-ng/references.d.ts +++ b/e2e/tests-app-ng/references.d.ts @@ -1 +1 @@ -/// Needed for autocompletion and compilation. \ No newline at end of file +/// \ No newline at end of file diff --git a/nativescript-angular/index.ts b/nativescript-angular/index.ts index 6244a00e5..f0e97a09c 100644 --- a/nativescript-angular/index.ts +++ b/nativescript-angular/index.ts @@ -5,9 +5,9 @@ import '@nativescript/zone-js'; // investigate Ivy with templated-items-comp to allow standard zone below to be used instead of patched {N} zone above // import 'zone.js/dist/zone'; import './dom-adapter'; -import 'nativescript-intl'; // import "./polyfills/array"; import './polyfills/console'; +import 'nativescript-intl'; export * from './platform-common'; export * from './platform-providers'; diff --git a/nativescript-angular/package.json b/nativescript-angular/package.json index 067cdbc0f..9af5414c1 100644 --- a/nativescript-angular/package.json +++ b/nativescript-angular/package.json @@ -1,6 +1,6 @@ { "name": "@nativescript/angular", - "version": "10.0.3", + "version": "10.1.0", "description": "An Angular renderer that lets you build mobile apps with NativeScript.", "homepage": "https://www.nativescript.org/", "bugs": "https://github.com/NativeScript/nativescript-angular/issues", @@ -58,42 +58,41 @@ }, "dependencies": { "@nativescript/zone-js": "~1.0.0", - "nativescript-angular": "~10.0.0", "nativescript-intl": "^4.0.0" }, "peerDependencies": { - "@angular/common": "^10.0.0", - "@angular/compiler": "^10.0.0", - "@angular/core": "^10.0.0", - "@angular/forms": "^10.0.0", - "@angular/platform-browser": "^10.0.0", - "@angular/platform-browser-dynamic": "^10.0.0", - "@angular/router": "^10.0.0" + "@angular/common": "^10.1.0", + "@angular/compiler": "^10.1.0", + "@angular/core": "^10.1.0", + "@angular/forms": "^10.1.0", + "@angular/platform-browser": "^10.1.0", + "@angular/platform-browser-dynamic": "^10.1.0", + "@angular/router": "^10.1.0" }, "devDependencies": { - "@angular/animations": "~10.0.0", - "@angular/common": "~10.0.0", - "@angular/compiler": "~10.0.0", - "@angular/compiler-cli": "~10.0.0", - "@angular/core": "~10.0.0", - "@angular/forms": "~10.0.0", - "@angular/platform-browser": "~10.0.0", - "@angular/platform-browser-dynamic": "~10.0.0", - "@angular/router": "~10.0.0", - "@nativescript/core": "rc", + "@angular/animations": "~10.1.0", + "@angular/common": "~10.1.0", + "@angular/compiler": "~10.1.0", + "@angular/compiler-cli": "~10.1.0", + "@angular/core": "~10.1.0", + "@angular/forms": "~10.1.0", + "@angular/platform-browser": "~10.1.0", + "@angular/platform-browser-dynamic": "~10.1.0", + "@angular/router": "~10.1.0", + "@nativescript/core": "~7.0.0", "codelyzer": "^5.2.0", "conventional-changelog-cli": "^2.0.34", "husky": "^4.2.5", "lint-staged": "^10.2.11", "nativescript-typedoc-theme": "git://github.com/NativeScript/nativescript-typedoc-theme.git#master", - "ng-packagr": "~10.0.0", + "ng-packagr": "~10.1.0", "prettier": "^2.0.5", - "rxjs": "~6.5.5", + "rxjs": "~6.6.0", "tslint": "^6.1.2", "tslint-config-prettier": "^1.18.0", "typedoc": "~0.17.0", "typescript": "~3.9.0", - "zone.js": "^0.10.3" + "zone.js": "^0.11.1" }, "husky": { "hooks": { From 302afb350dea56ddbf1a0d772f6d9405413890a5 Mon Sep 17 00:00:00 2001 From: Eduardo Speroni Date: Thu, 3 Sep 2020 23:06:45 -0300 Subject: [PATCH 2/3] fix(list-view): fix crash when used with ngFor (#2121) --- nativescript-angular/directives/dialogs.ts | 34 +++++++++++-------- .../directives/list-view-comp.ts | 6 ++-- .../directives/templated-items-comp.ts | 10 +++--- 3 files changed, 28 insertions(+), 22 deletions(-) diff --git a/nativescript-angular/directives/dialogs.ts b/nativescript-angular/directives/dialogs.ts index e9280f989..7e5aa78bf 100644 --- a/nativescript-angular/directives/dialogs.ts +++ b/nativescript-angular/directives/dialogs.ts @@ -1,4 +1,4 @@ -import { ComponentFactoryResolver, ComponentRef, Injectable, Injector, NgModuleRef, Type, ViewContainerRef } from '@angular/core'; +import { ComponentFactoryResolver, ComponentRef, Injectable, Injector, NgModuleRef, NgZone, Type, ViewContainerRef } from '@angular/core'; import { Frame, View, ViewBase, ProxyViewContainer, ShowModalOptions } from '@nativescript/core'; import { NSLocationStrategy } from '../router/ns-location-strategy'; @@ -32,7 +32,7 @@ export class ModalDialogParams { @Injectable() export class ModalDialogService { - constructor(private location: NSLocationStrategy) {} + constructor(private location: NSLocationStrategy, private zone: NgZone) {} public showModal(type: Type, options: ModalDialogOptions): Promise { if (!options.viewContainerRef) { @@ -98,8 +98,10 @@ export class ModalDialogService { if (componentView) { componentView.closeModal(); this.location._closeModalNavigation(); - detachedLoaderRef.instance.detectChanges(); - detachedLoaderRef.destroy(); + this.zone.run(() => { + detachedLoaderRef.instance.detectChanges(); + detachedLoaderRef.destroy(); + }); } }); @@ -111,20 +113,22 @@ export class ModalDialogService { }); const detachedFactory = options.resolver.resolveComponentFactory(DetachedLoader); detachedLoaderRef = options.containerRef.createComponent(detachedFactory, 0, childInjector, null); - detachedLoaderRef.instance.loadComponent(options.type).then((compRef) => { - const detachedProxy = compRef.location.nativeElement; + this.zone.run(() => { + detachedLoaderRef.instance.loadComponent(options.type).then((compRef) => { + const detachedProxy = compRef.location.nativeElement; - if (detachedProxy.getChildrenCount() > 1) { - throw new Error('Modal content has more than one root view.'); - } - componentView = detachedProxy.getChildAt(0); + if (detachedProxy.getChildrenCount() > 1) { + throw new Error('Modal content has more than one root view.'); + } + componentView = detachedProxy.getChildAt(0); - if (componentView.parent) { - (componentView.parent)._ngDialogRoot = componentView; - (componentView.parent).removeChild(componentView); - } + if (componentView.parent) { + (componentView.parent)._ngDialogRoot = componentView; + (componentView.parent).removeChild(componentView); + } - options.parentView.showModal(componentView, { ...options, closeCallback }); + options.parentView.showModal(componentView, { ...options, closeCallback }); + }); }); } } diff --git a/nativescript-angular/directives/list-view-comp.ts b/nativescript-angular/directives/list-view-comp.ts index dc357d7e9..62e1eadfe 100644 --- a/nativescript-angular/directives/list-view-comp.ts +++ b/nativescript-angular/directives/list-view-comp.ts @@ -1,4 +1,4 @@ -import { ChangeDetectionStrategy, Component, ElementRef, IterableDiffers, forwardRef } from '@angular/core'; +import { ChangeDetectionStrategy, Component, ElementRef, IterableDiffers, forwardRef, NgZone } from '@angular/core'; import { ListView } from '@nativescript/core'; import { TEMPLATED_ITEMS_COMPONENT, TemplatedItemsComponent } from './templated-items-comp'; @@ -17,7 +17,7 @@ export class ListViewComponent extends TemplatedItemsComponent { protected templatedItemsView: ListView; - constructor(_elementRef: ElementRef, _iterableDiffers: IterableDiffers) { - super(_elementRef, _iterableDiffers); + constructor(_elementRef: ElementRef, _iterableDiffers: IterableDiffers, zone: NgZone) { + super(_elementRef, _iterableDiffers, zone); } } diff --git a/nativescript-angular/directives/templated-items-comp.ts b/nativescript-angular/directives/templated-items-comp.ts index 302f85377..5514ffa7b 100644 --- a/nativescript-angular/directives/templated-items-comp.ts +++ b/nativescript-angular/directives/templated-items-comp.ts @@ -1,4 +1,4 @@ -import { AfterContentInit, ContentChild, Directive, DoCheck, ElementRef, EmbeddedViewRef, EventEmitter, Host, Inject, InjectionToken, Input, IterableDiffer, IterableDiffers, OnDestroy, Output, TemplateRef, ViewChild, ViewContainerRef, ɵisListLikeIterable as isListLikeIterable, Injectable } from '@angular/core'; +import { AfterContentInit, ContentChild, Directive, DoCheck, ElementRef, EmbeddedViewRef, EventEmitter, Host, Inject, InjectionToken, Input, IterableDiffer, IterableDiffers, OnDestroy, Output, TemplateRef, ViewChild, ViewContainerRef, ɵisListLikeIterable as isListLikeIterable, Injectable, NgZone } from '@angular/core'; import { ObservableArray, View, KeyedTemplate, LayoutBase, ItemEventData, TemplatedItemsView, profile } from '@nativescript/core'; import { getSingleViewRecursive } from '../element-registry'; @@ -54,7 +54,7 @@ export abstract class TemplatedItemsComponent implements DoCheck, OnDestroy, Aft this.templatedItemsView.items = this._items; } - constructor(_elementRef: ElementRef, private _iterableDiffers: IterableDiffers) { + constructor(_elementRef: ElementRef, private _iterableDiffers: IterableDiffers, private zone: NgZone) { this.templatedItemsView = _elementRef.nativeElement; this.templatedItemsView.on('itemLoading', this.onItemLoading, this); @@ -188,8 +188,10 @@ export abstract class TemplatedItemsComponent implements DoCheck, OnDestroy, Aft NativeScriptDebug.listViewLog(`Manually detect changes in child: ${index}`); } - viewRef.markForCheck(); - viewRef.detectChanges(); + this.zone.run(() => { + viewRef.markForCheck(); + viewRef.detectChanges(); + }); } ngDoCheck() { From fa761aea2d52f8118090e359d9b2b45a7577100c Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Thu, 3 Sep 2020 20:12:31 -0700 Subject: [PATCH 3/3] chore(release): 10.1.0 --- CHANGELOG.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee258f56c..421a50d7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ +# [10.1.0](https://github.com/NativeScript/nativescript-angular/compare/10.0.3...10.1.0) (2020-09-04) + + +### Bug Fixes + +* **list-view:** fix crash when used with ngFor ([#2121](https://github.com/NativeScript/nativescript-angular/issues/2121)) ([302afb3](https://github.com/NativeScript/nativescript-angular/commit/302afb350dea56ddbf1a0d772f6d9405413890a5)) + + +### Features + +* **angular:** ng 10.1 and ns 7 ([#2237](https://github.com/NativeScript/nativescript-angular/issues/2237)) ([548e074](https://github.com/NativeScript/nativescript-angular/commit/548e0743eb092ba3fa371ea4d26879ee5bf03983)) + + + ## [10.0.3](https://github.com/NativeScript/nativescript-angular/compare/10.0.2...10.0.3) (2020-08-27)