From 3c3c10ea9671a56e545953e685f392b4951cf713 Mon Sep 17 00:00:00 2001 From: SvetoslavTsenov Date: Fri, 8 Feb 2019 18:16:59 +0200 Subject: [PATCH 01/20] chore: bump package versino tp 7.3.0 --- nativescript-angular/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nativescript-angular/package.json b/nativescript-angular/package.json index ea4257c6d..f622d58c2 100644 --- a/nativescript-angular/package.json +++ b/nativescript-angular/package.json @@ -1,6 +1,6 @@ { "name": "nativescript-angular", - "version": "7.2.0", + "version": "7.3.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", From a21454f1e1b9f823dfa71c8f6a8fc9f1ff2174c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Anton=20Bach=20Sj=C3=B8gren?= Date: Tue, 12 Feb 2019 14:19:28 +0100 Subject: [PATCH 02/20] chor(NativeScriptPlatformRef): Destroy lastModuleRef on exitEvent --- nativescript-angular/platform-common.ts | 10 ++++++++++ nativescript-angular/router/page-router-outlet.ts | 15 ++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/nativescript-angular/platform-common.ts b/nativescript-angular/platform-common.ts index 2f7e958cd..4eb5d7900 100644 --- a/nativescript-angular/platform-common.ts +++ b/nativescript-angular/platform-common.ts @@ -33,6 +33,7 @@ import { on, launchEvent, LaunchEventData, + exitEvent, } from "tns-core-modules/application"; import { TextView } from "tns-core-modules/ui/text-view"; @@ -255,7 +256,16 @@ export class NativeScriptPlatformRef extends PlatformRef { args.root = rootContent; } ); + const exitCallback = profile( + "nativescript-angular/platform-common.exitCallback",() => { + const lastModuleRef = lastBootstrappedModule ? lastBootstrappedModule.get() : null; + if (lastModuleRef) { + lastModuleRef.destroy(); + } + } + ); on(launchEvent, launchCallback); + on(exitEvent, exitCallback); applicationRun(); } diff --git a/nativescript-angular/router/page-router-outlet.ts b/nativescript-angular/router/page-router-outlet.ts index 381ff52bd..6ad425c65 100644 --- a/nativescript-angular/router/page-router-outlet.ts +++ b/nativescript-angular/router/page-router-outlet.ts @@ -352,12 +352,19 @@ export class PageRouterOutlet implements OnDestroy { // tslint:disable-line:dire // Add it to the new page page.content = componentView; - page.on(Page.navigatedFromEvent, (global).Zone.current.wrap((args: NavigatedData) => { + const navigatedFromCallback = (global).Zone.current.wrap((args: NavigatedData) => { if (args.isBackNavigation) { this.locationStrategy._beginBackPageNavigation(this.frame); this.locationStrategy.back(null, this.frame); } - })); + }); + page.on(Page.navigatedFromEvent, navigatedFromCallback); + componentRef.onDestroy(() => { + if (page) { + page.off(Page.navigatedFromEvent, navigatedFromCallback); + page = null; + } + }); const navOptions = this.locationStrategy._beginPageNavigation(this.frame); @@ -374,7 +381,9 @@ export class PageRouterOutlet implements OnDestroy { // tslint:disable-line:dire } this.frame.navigate({ - create: () => { return page; }, + create() { + return page; + }, clearHistory: navOptions.clearHistory, animated: navOptions.animated, transition: navOptions.transition From a4ee021fb0f3b74cf2ee3b0b9ec5ca06e8b1ec61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Anton=20Bach=20Sj=C3=B8gren?= Date: Tue, 12 Feb 2019 14:34:11 +0100 Subject: [PATCH 03/20] fix(tslint): missing whitespace --- nativescript-angular/platform-common.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nativescript-angular/platform-common.ts b/nativescript-angular/platform-common.ts index 4eb5d7900..12958d1ae 100644 --- a/nativescript-angular/platform-common.ts +++ b/nativescript-angular/platform-common.ts @@ -257,7 +257,7 @@ export class NativeScriptPlatformRef extends PlatformRef { } ); const exitCallback = profile( - "nativescript-angular/platform-common.exitCallback",() => { + "nativescript-angular/platform-common.exitCallback", () => { const lastModuleRef = lastBootstrappedModule ? lastBootstrappedModule.get() : null; if (lastModuleRef) { lastModuleRef.destroy(); From 0f6a975b8aa1d4e90474c76efe7bb7002dedc63b Mon Sep 17 00:00:00 2001 From: Alexander Vakrilov Date: Tue, 19 Feb 2019 11:51:29 +0200 Subject: [PATCH 04/20] fix(router): routing services should be provided in forRoot only (#1729) * fix(router): routing services should be provided in forRoot only * refactor: remove logs * refactor: use single return statment in forRoot/Child --- nativescript-angular/router/router.module.ts | 45 +++++++----- tests/app/tests/router-module-tests.ts | 74 ++++++++++++++++++++ tests/package.json | 2 +- 3 files changed, 101 insertions(+), 20 deletions(-) create mode 100644 tests/app/tests/router-module-tests.ts diff --git a/nativescript-angular/router/router.module.ts b/nativescript-angular/router/router.module.ts index 385b4fe1f..95610d6aa 100644 --- a/nativescript-angular/router/router.module.ts +++ b/nativescript-angular/router/router.module.ts @@ -19,32 +19,39 @@ export { NSEmptyOutletComponent } from "./ns-empty-outlet.component"; export type LocationState = LocationState; +const ROUTER_DIRECTIVES = [NSRouterLink, NSRouterLinkActive, PageRouterOutlet, NSEmptyOutletComponent]; + +const NS_ROUTER_PROVIDERS = [ + { + provide: NSLocationStrategy, + useFactory: provideLocationStrategy, + deps: [[NSLocationStrategy, new Optional(), new SkipSelf()], FrameService], + }, + { provide: LocationStrategy, useExisting: NSLocationStrategy }, + NativescriptPlatformLocation, + { provide: PlatformLocation, useClass: NativescriptPlatformLocation }, + RouterExtensions, + NSRouteReuseStrategy, + { provide: RouteReuseStrategy, useExisting: NSRouteReuseStrategy }, +]; + @NgModule({ - declarations: [NSRouterLink, NSRouterLinkActive, PageRouterOutlet, NSEmptyOutletComponent], - providers: [ - { - provide: NSLocationStrategy, - useFactory: provideLocationStrategy, - deps: [[NSLocationStrategy, new Optional(), new SkipSelf()], FrameService], - }, - { provide: LocationStrategy, useExisting: NSLocationStrategy }, - NativescriptPlatformLocation, - { provide: PlatformLocation, useClass: NativescriptPlatformLocation }, - RouterExtensions, - NSRouteReuseStrategy, - { provide: RouteReuseStrategy, useExisting: NSRouteReuseStrategy }, - ], + declarations: ROUTER_DIRECTIVES, + entryComponents: [NSEmptyOutletComponent], imports: [RouterModule, NativeScriptCommonModule], - exports: [RouterModule, NSRouterLink, NSRouterLinkActive, PageRouterOutlet, NSEmptyOutletComponent], + exports: [RouterModule, ...ROUTER_DIRECTIVES], schemas: [NO_ERRORS_SCHEMA], }) export class NativeScriptRouterModule { - static forRoot(routes: Routes, config?: ExtraOptions): ModuleWithProviders { - return RouterModule.forRoot(routes, config); + static forRoot(routes: Routes, config?: ExtraOptions): ModuleWithProviders { + return { + ngModule: NativeScriptRouterModule, + providers: [...RouterModule.forRoot(routes, config).providers, ...NS_ROUTER_PROVIDERS] + }; } - static forChild(routes: Routes): ModuleWithProviders { - return RouterModule.forChild(routes); + static forChild(routes: Routes): ModuleWithProviders { + return { ngModule: NativeScriptRouterModule, providers: RouterModule.forChild(routes).providers }; } } diff --git a/tests/app/tests/router-module-tests.ts b/tests/app/tests/router-module-tests.ts new file mode 100644 index 000000000..7bce3f7ef --- /dev/null +++ b/tests/app/tests/router-module-tests.ts @@ -0,0 +1,74 @@ +// make sure you import mocha-config before @angular/core +import { Component, ViewChild } from "@angular/core"; +import { nsTestBedAfterEach, nsTestBedBeforeEach, nsTestBedRender } from "nativescript-angular/testing"; +import { NativeScriptRouterModule, RouterExtensions } from "nativescript-angular/router"; +import { NSRouterLink } from "nativescript-angular/router/ns-router-link"; +import { NSLocationStrategy } from "nativescript-angular/router/ns-location-strategy"; +import { assert } from "~/tests/test-config"; +import { ActivatedRoute, Router, RouteReuseStrategy } from "@angular/router"; +import { LocationStrategy, PlatformLocation } from "@angular/common"; +import { NSRouteReuseStrategy } from "nativescript-angular/router/ns-route-reuse-strategy"; + +@Component({ + template: `` +}) +class RouterTestComponent { + @ViewChild(NSRouterLink) + nsRouterLink: NSRouterLink; +} + +describe("NativeScriptRouterModule.forRoot", () => { + beforeEach(nsTestBedBeforeEach( + [RouterTestComponent], + [], + [NativeScriptRouterModule.forRoot([])], + [])); + + afterEach(nsTestBedAfterEach()); + + it("should provide nativescript routing services", () => { + return nsTestBedRender(RouterTestComponent).then((fixture) => { + const injector = fixture.componentRef.injector + + assert.instanceOf(injector.get(LocationStrategy, null), NSLocationStrategy); + assert.instanceOf(injector.get(RouterExtensions, null), RouterExtensions); + assert.instanceOf(injector.get(RouteReuseStrategy, null), NSRouteReuseStrategy); + }); + }); + + it("should provide nativescript routing directives", () => { + return nsTestBedRender(RouterTestComponent).then((fixture) => { + const linkDirective = fixture.componentRef.instance.nsRouterLink; + assert.instanceOf(linkDirective, NSRouterLink); + }); + }); +}); + +describe("NativeScriptRouterModule.forChild", () => { + beforeEach(nsTestBedBeforeEach( + [RouterTestComponent], + [ + { provide: Router, useValue: {} }, + { provide: RouterExtensions, useValue: {} }, + { provide: ActivatedRoute, useValue: {} }, + ], + [NativeScriptRouterModule.forChild([])], + [])); + afterEach(nsTestBedAfterEach()); + + it("should not provide nativescript routing services", () => { + return nsTestBedRender(RouterTestComponent).then((fixture) => { + const injector = fixture.componentRef.injector + assert.isNull(injector.get(LocationStrategy, null)); + assert.isNull(injector.get(RouteReuseStrategy, null)); + }); + }); + + it("should provide nativescript routing directives", () => { + return nsTestBedRender(RouterTestComponent).then((fixture) => { + const linkDirective = fixture.componentRef.instance.nsRouterLink; + assert.instanceOf(linkDirective, NSRouterLink); + }); + }); +}); + diff --git a/tests/package.json b/tests/package.json index 29bede509..7375973e3 100644 --- a/tests/package.json +++ b/tests/package.json @@ -35,7 +35,7 @@ "@angular/platform-browser": "~7.2.0", "@angular/platform-browser-dynamic": "~7.2.0", "@angular/router": "~7.2.0", - "nativescript-angular": "../nativescript-angular", + "nativescript-angular": "file:../nativescript-angular/nativescript-angular-7.3.0.tgz", "nativescript-unit-test-runner": "^0.3.4", "rxjs": "~6.3.3", "tns-core-modules": "next", From 14e787fb160d2a6f8e8ebbbaff88e745eee8ac1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Anton=20Bach=20Sj=C3=B8gren?= Date: Thu, 21 Feb 2019 14:26:00 +0100 Subject: [PATCH 05/20] fix: remove rootContent on exit --- nativescript-angular/platform-common.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nativescript-angular/platform-common.ts b/nativescript-angular/platform-common.ts index 12958d1ae..2ef914c98 100644 --- a/nativescript-angular/platform-common.ts +++ b/nativescript-angular/platform-common.ts @@ -262,6 +262,10 @@ export class NativeScriptPlatformRef extends PlatformRef { if (lastModuleRef) { lastModuleRef.destroy(); } + + if (!autoCreateFrame) { + rootContent = null; + } } ); on(launchEvent, launchCallback); From ea66985a9cc94a69fc40d7d8731b4a2f1262b8ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Anton=20Bach=20Sj=C3=B8gren?= Date: Fri, 22 Feb 2019 11:40:38 +0100 Subject: [PATCH 06/20] fix: page might be null'ed before clearHistory's navigatedToEvent --- nativescript-angular/router/page-router-outlet.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nativescript-angular/router/page-router-outlet.ts b/nativescript-angular/router/page-router-outlet.ts index 6ad425c65..cc9d07cc2 100644 --- a/nativescript-angular/router/page-router-outlet.ts +++ b/nativescript-angular/router/page-router-outlet.ts @@ -374,10 +374,9 @@ export class PageRouterOutlet implements OnDestroy { // tslint:disable-line:dire if (this.outlet) { this.routeReuseStrategy.clearCache(this.outlet.outletKeys[0]); } - page.off(Page.navigatedToEvent, clearCallback); }); - page.on(Page.navigatedToEvent, clearCallback); + page.once(Page.navigatedToEvent, clearCallback); } this.frame.navigate({ From ed6954a40c38c8c300ccbb59412b65fe1eafe55c Mon Sep 17 00:00:00 2001 From: vakrilov Date: Thu, 28 Feb 2019 15:08:54 +0200 Subject: [PATCH 07/20] refactor: minor changes after review --- nativescript-angular/router/ns-platform-location.ts | 12 ++++++------ nativescript-angular/router/router.module.ts | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/nativescript-angular/router/ns-platform-location.ts b/nativescript-angular/router/ns-platform-location.ts index 311faa5b8..ebd86f067 100644 --- a/nativescript-angular/router/ns-platform-location.ts +++ b/nativescript-angular/router/ns-platform-location.ts @@ -6,7 +6,7 @@ import { routerLog, isLogEnabled } from "../trace"; @Injectable() export class NativescriptPlatformLocation extends PlatformLocation { - constructor(private locationStartegy: NSLocationStrategy) { + constructor(private locationStrategy: NSLocationStrategy) { super(); if (isLogEnabled()) { routerLog("NativescriptPlatformLocation.constructor()"); @@ -18,7 +18,7 @@ export class NativescriptPlatformLocation extends PlatformLocation { } onPopState(fn: LocationChangeListener): void { - this.locationStartegy.onPopState(fn); + this.locationStrategy.onPopState(fn); } onHashChange(_fn: LocationChangeListener): void { @@ -31,18 +31,18 @@ export class NativescriptPlatformLocation extends PlatformLocation { return ""; } get pathname(): string { - return this.locationStartegy.path(); + return this.locationStrategy.path(); } set pathname(_newPath: string) { throw new Error("NativescriptPlatformLocation set pathname - not implemented"); } pushState(state: any, title: string, url: string): void { - this.locationStartegy.pushState(state, title, url, null); + this.locationStrategy.pushState(state, title, url, null); } replaceState(state: any, title: string, url: string): void { - this.locationStartegy.replaceState(state, title, url, null); + this.locationStrategy.replaceState(state, title, url, null); } forward(): void { @@ -50,6 +50,6 @@ export class NativescriptPlatformLocation extends PlatformLocation { } back(): void { - this.locationStartegy.back(); + this.locationStrategy.back(); } } diff --git a/nativescript-angular/router/router.module.ts b/nativescript-angular/router/router.module.ts index 95610d6aa..5246eeea0 100644 --- a/nativescript-angular/router/router.module.ts +++ b/nativescript-angular/router/router.module.ts @@ -29,7 +29,7 @@ const NS_ROUTER_PROVIDERS = [ }, { provide: LocationStrategy, useExisting: NSLocationStrategy }, NativescriptPlatformLocation, - { provide: PlatformLocation, useClass: NativescriptPlatformLocation }, + { provide: PlatformLocation, useExisting: NativescriptPlatformLocation }, RouterExtensions, NSRouteReuseStrategy, { provide: RouteReuseStrategy, useExisting: NSRouteReuseStrategy }, From 5e13263389ae0c97cd4f92693a11ba38884fc5a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Anton=20Bach=20Sj=C3=B8gren?= Date: Fri, 8 Mar 2019 15:39:51 +0100 Subject: [PATCH 08/20] fix: on destroy remove the lastBootstrappedModule If exit event was triggered twice we would try to destroy an already destroy module ref. --- nativescript-angular/platform-common.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nativescript-angular/platform-common.ts b/nativescript-angular/platform-common.ts index 2ef914c98..8c1c342b6 100644 --- a/nativescript-angular/platform-common.ts +++ b/nativescript-angular/platform-common.ts @@ -260,6 +260,8 @@ export class NativeScriptPlatformRef extends PlatformRef { "nativescript-angular/platform-common.exitCallback", () => { const lastModuleRef = lastBootstrappedModule ? lastBootstrappedModule.get() : null; if (lastModuleRef) { + lastBootstrappedModule = null; + lastModuleRef.destroy(); } From 9fc172c2c2ebddc91d59f6d2578bff813eafa4fb Mon Sep 17 00:00:00 2001 From: sis0k0 Date: Mon, 11 Mar 2019 09:33:18 +0200 Subject: [PATCH 09/20] chore(tsconfig): remove path resolution for short imports (`ui/page`) The usage of short imports, e.g, `import * as Page from "ui/page"` instead of `import * as Page from "tns-core-modules/ui/page"` is *deprecated* since {N} 5.2. --- nativescript-angular/tsconfig.json | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/nativescript-angular/tsconfig.json b/nativescript-angular/tsconfig.json index e05ddfed9..e8a09f283 100644 --- a/nativescript-angular/tsconfig.json +++ b/nativescript-angular/tsconfig.json @@ -16,14 +16,7 @@ "dom", "es6", "es2015.iterable" - ], - "baseUrl": ".", - "paths": { - "*": [ - "./node_modules/tns-core-modules/*", - "./node_modules/*" - ] - } + ] }, "angularCompilerOptions": { "genDir": ".", From 3dffbd512f31856c48dc9f9dcea754f0bca7a03c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Anton=20Bach=20Sj=C3=B8gren?= Date: Mon, 11 Mar 2019 13:41:23 +0100 Subject: [PATCH 10/20] fix: the exit event is triggered on restart Don't destroy the angular module on restart --- nativescript-angular/platform-common.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/nativescript-angular/platform-common.ts b/nativescript-angular/platform-common.ts index 8c1c342b6..d6a4c557f 100644 --- a/nativescript-angular/platform-common.ts +++ b/nativescript-angular/platform-common.ts @@ -34,6 +34,7 @@ import { launchEvent, LaunchEventData, exitEvent, + ApplicationEventData, } from "tns-core-modules/application"; import { TextView } from "tns-core-modules/ui/text-view"; @@ -257,9 +258,16 @@ export class NativeScriptPlatformRef extends PlatformRef { } ); const exitCallback = profile( - "nativescript-angular/platform-common.exitCallback", () => { + "nativescript-angular/platform-common.exitCallback", (args: ApplicationEventData) => { + const androidActivity = args.android; + if (androidActivity && !androidActivity.isFinishing()) { + // Exit event was triggered as a part of a restart of the app. + return; + } + const lastModuleRef = lastBootstrappedModule ? lastBootstrappedModule.get() : null; if (lastModuleRef) { + // Make sure the module is only destroyed once lastBootstrappedModule = null; lastModuleRef.destroy(); From 9ba7fca7af7dceb2eb3fbe3eb217d4f49d29f672 Mon Sep 17 00:00:00 2001 From: tsonevn Date: Tue, 12 Mar 2019 09:58:54 +0200 Subject: [PATCH 11/20] NS Angular api ref build script --- build-docs.sh | 9 +++++ nativescript-angular/package.json | 7 +++- nativescript-angular/tsconfig.typedoc.json | 44 ++++++++++++++++++++++ 3 files changed, 58 insertions(+), 2 deletions(-) create mode 100755 build-docs.sh create mode 100644 nativescript-angular/tsconfig.typedoc.json diff --git a/build-docs.sh b/build-docs.sh new file mode 100755 index 000000000..a0f39ec85 --- /dev/null +++ b/build-docs.sh @@ -0,0 +1,9 @@ +set -e + +ENV="${ENV:-dev}" +DIST_DIR="nativescript-angular/bin/dist" +APIREF_DIR="$DIST_DIR/ng-api-reference" +rm -rf "$APIREF_DIR" +cd "nativescript-angular" +npm install +npm run typedoc diff --git a/nativescript-angular/package.json b/nativescript-angular/package.json index f622d58c2..062189aaa 100644 --- a/nativescript-angular/package.json +++ b/nativescript-angular/package.json @@ -34,7 +34,8 @@ "tsc-w": "tsc -p tsconfig.json -w", "ngc": "ngc -p tsconfig.json", "prepare": "npm run ngc", - "version": "rm -rf package-lock.json && conventional-changelog -p angular -i ../CHANGELOG.md -s && git add ../CHANGELOG.md" + "version": "rm -rf package-lock.json && conventional-changelog -p angular -i ../CHANGELOG.md -s && git add ../CHANGELOG.md", + "typedoc": "typedoc --tsconfig \"./tsconfig.typedoc.json\" --out ./bin/dist/ng-api-reference --includeDeclarations --name \"NativeScript Angular\" --theme ./node_modules/nativescript-typedoc-theme --excludeExternals --externalPattern \"**/+(tns-core-modules|module|declarations).d.ts\"" }, "bin": { "update-app-ng-deps": "./bin/update-app-ng-deps" @@ -73,6 +74,8 @@ "tns-core-modules": "next", "tslint": "^5.5.0", "typescript": "~3.1.1", - "zone.js": "^0.8.4" + "zone.js": "^0.8.4", + "nativescript-typedoc-theme": "git://github.com/NativeScript/nativescript-typedoc-theme.git#master", + "typedoc": "^0.13.0" } } diff --git a/nativescript-angular/tsconfig.typedoc.json b/nativescript-angular/tsconfig.typedoc.json new file mode 100644 index 000000000..4faa0da11 --- /dev/null +++ b/nativescript-angular/tsconfig.typedoc.json @@ -0,0 +1,44 @@ +{"compilerOptions": { + "target": "es5", + "module": "commonjs", + "moduleResolution": "node", + "sourceMap": true, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "noImplicitUseStrict": true, + "noEmitHelpers": true, + "declaration": true, + "removeComments": false, + "noEmitOnError": true, + "noImplicitAny": false, + "lib": [ + "dom", + "es6", + "es2015.iterable" + ], + "baseUrl": ".", + "paths": { + "*": [ + "./node_modules/tns-core-modules/*", + "./node_modules/*" + ] + } + }, + "angularCompilerOptions": { + "genDir": ".", + "skipMetadataEmit": false, + "skipTemplateCodegen": true, + "strictMetadataEmit": true + }, +"exclude": [ + "./node_modules", + "tns-core-modules/references.d.ts", + "tns-core-modules/node_modules", + "tns-core-modules/ui/frame/transition-definitions.android.d.ts", + "./zone-js", + "./index.ts", + "./bin", + "./index.d.ts", + "./testing" + ] +} \ No newline at end of file From b1c4340aa6859f32c9f69f0f15e5c122274535e4 Mon Sep 17 00:00:00 2001 From: tsonevn Date: Tue, 12 Mar 2019 11:55:16 +0200 Subject: [PATCH 12/20] exclude files from api ref build --- nativescript-angular/tsconfig.typedoc.json | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/nativescript-angular/tsconfig.typedoc.json b/nativescript-angular/tsconfig.typedoc.json index 4faa0da11..3074c04b8 100644 --- a/nativescript-angular/tsconfig.typedoc.json +++ b/nativescript-angular/tsconfig.typedoc.json @@ -39,6 +39,23 @@ "./index.ts", "./bin", "./index.d.ts", - "./testing" + "./testing", + "./animations/index.ts", + "./animations/utils.ts", + "./app-host-view.ts", + "./common/utils.ts", + "./dom-adapter.ts", + "./file-system", + "./forms/index.ts", + "./forms/value-accessors/index.ts", + "./lang-facade.ts", + "./polyfills", + "./router/private-imports", + "./schema-registry.ts", + "./http-client/index.ts", + "./http/index.ts", + "./router/index.ts", + "" + ] } \ No newline at end of file From 9cfa127d46427a0286d5b0840b51627289675203 Mon Sep 17 00:00:00 2001 From: Marcus Williams Date: Fri, 1 Feb 2019 19:35:52 +0000 Subject: [PATCH 13/20] =?UTF-8?q?feat(modal):=20add=20=E2=80=98ios=20prese?= =?UTF-8?q?ntationStyle=E2=80=99=20option=20to=20ModalDialogParams=20feat(?= =?UTF-8?q?modal):=20expose=20current/future=20core=20options=20via=20Moda?= =?UTF-8?q?lDialogParams?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nativescript-angular/directives/dialogs.ts | 67 +++++++++------------- 1 file changed, 28 insertions(+), 39 deletions(-) diff --git a/nativescript-angular/directives/dialogs.ts b/nativescript-angular/directives/dialogs.ts index 7c8b45739..3c700777d 100644 --- a/nativescript-angular/directives/dialogs.ts +++ b/nativescript-angular/directives/dialogs.ts @@ -7,6 +7,7 @@ import { ReflectiveInjector, Type, ViewContainerRef, + ElementRef, } from "@angular/core"; import { NSLocationStrategy } from "../router/ns-location-strategy"; @@ -17,15 +18,15 @@ import { AppHostView } from "../app-host-view"; import { DetachedLoader } from "../common/detached-loader"; import { PageFactory, PAGE_FACTORY } from "../platform-providers"; import { once } from "../common/utils"; -import { topmost, Frame } from "tns-core-modules/ui/frame"; +import { topmost, Frame, ShowModalOptions } from "tns-core-modules/ui/frame"; -export interface ModalDialogOptions { +export type BaseShowModalOptions = Pick>; + +export interface ModalDialogOptions extends BaseShowModalOptions { context?: any; - fullscreen?: boolean; - animated?: boolean; - stretched?: boolean; viewContainerRef?: ViewContainerRef; moduleRef?: NgModuleRef; + sourceView?: ElementRef; } export class ModalDialogParams { @@ -35,13 +36,10 @@ export class ModalDialogParams { } } -interface ShowDialogOptions { +interface ShowDialogOptions extends BaseShowModalOptions { containerRef: ViewContainerRef; context: any; doneCallback; - fullscreen: boolean; - animated: boolean; - stretched: boolean; pageFactory: PageFactory; parentView: ViewBase; resolver: ComponentFactoryResolver; @@ -54,16 +52,19 @@ export class ModalDialogService { } public showModal(type: Type, - { viewContainerRef, moduleRef, context, fullscreen, animated, stretched }: ModalDialogOptions + options: ModalDialogOptions ): Promise { - if (!viewContainerRef) { + if (!options.viewContainerRef) { throw new Error( "No viewContainerRef: " + "Make sure you pass viewContainerRef in ModalDialogOptions." ); } - let parentView = viewContainerRef.element.nativeElement; + let parentView = options.viewContainerRef.element.nativeElement; + if (options.sourceView) { + parentView = options.sourceView.nativeElement; + } if (parentView instanceof AppHostView && parentView.ngAppRoot) { parentView = parentView.ngAppRoot; } @@ -75,11 +76,11 @@ export class ModalDialogService { parentView = parentView._ngDialogRoot; } - const pageFactory: PageFactory = viewContainerRef.injector.get(PAGE_FACTORY); + const pageFactory: PageFactory = options.viewContainerRef.injector.get(PAGE_FACTORY); // resolve from particular module (moduleRef) // or from same module as parentView (viewContainerRef) - const componentContainer = moduleRef || viewContainerRef; + const componentContainer = options.moduleRef || options.viewContainerRef; const resolver = componentContainer.injector.get(ComponentFactoryResolver); let frame = parentView; @@ -93,16 +94,14 @@ export class ModalDialogService { setTimeout(() => { try { this._showDialog({ - containerRef: viewContainerRef, - context, + ...options, + containerRef: options.viewContainerRef, + context: options.context, doneCallback: resolve, - fullscreen, - animated, - stretched, pageFactory, parentView, resolver, - type, + type }); } catch (err) { reject(err); @@ -111,23 +110,12 @@ export class ModalDialogService { }); } - private _showDialog({ - containerRef, - context, - doneCallback, - fullscreen, - animated, - stretched, - pageFactory, - parentView, - resolver, - type, - }: ShowDialogOptions): void { + private _showDialog(options: ShowDialogOptions): void { let componentView: View; let detachedLoaderRef: ComponentRef; const closeCallback = once((...args) => { - doneCallback.apply(undefined, args); + options.doneCallback.apply(undefined, args); if (componentView) { componentView.closeModal(); this.location._closeModalNavigation(); @@ -136,15 +124,15 @@ export class ModalDialogService { } }); - const modalParams = new ModalDialogParams(context, closeCallback); + const modalParams = new ModalDialogParams(options.context, closeCallback); const providers = ReflectiveInjector.resolve([ { provide: ModalDialogParams, useValue: modalParams }, ]); - const childInjector = ReflectiveInjector.fromResolvedProviders(providers, containerRef.parentInjector); - const detachedFactory = resolver.resolveComponentFactory(DetachedLoader); - detachedLoaderRef = containerRef.createComponent(detachedFactory, -1, childInjector, null); - detachedLoaderRef.instance.loadComponent(type).then((compRef) => { + const childInjector = ReflectiveInjector.fromResolvedProviders(providers, options.containerRef.parentInjector); + const detachedFactory = options.resolver.resolveComponentFactory(DetachedLoader); + detachedLoaderRef = options.containerRef.createComponent(detachedFactory, -1, childInjector, null); + detachedLoaderRef.instance.loadComponent(options.type).then((compRef) => { const detachedProxy = compRef.location.nativeElement; if (detachedProxy.getChildrenCount() > 1) { @@ -157,9 +145,10 @@ export class ModalDialogService { (componentView.parent).removeChild(componentView); } + // TODO: remove cast after https://github.com/NativeScript/NativeScript/pull/5734 // is in a published version of tns-core-modules. - (parentView).showModal(componentView, context, closeCallback, fullscreen, animated, stretched); + (options.parentView).showModal(componentView, { ...options, closeCallback }); }); } } From a4282ffb8dd7f332f465cacbe8c36182489e61fe Mon Sep 17 00:00:00 2001 From: VladimirAmiorkov Date: Mon, 25 Mar 2019 10:03:47 +0200 Subject: [PATCH 14/20] chore: remove object cast as it is not needed --- nativescript-angular/directives/dialogs.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nativescript-angular/directives/dialogs.ts b/nativescript-angular/directives/dialogs.ts index 3c700777d..fbdecb34d 100644 --- a/nativescript-angular/directives/dialogs.ts +++ b/nativescript-angular/directives/dialogs.ts @@ -148,7 +148,7 @@ export class ModalDialogService { // TODO: remove cast after https://github.com/NativeScript/NativeScript/pull/5734 // is in a published version of tns-core-modules. - (options.parentView).showModal(componentView, { ...options, closeCallback }); + options.parentView.showModal(componentView, { ...options, closeCallback }); }); } } From c9dc82681bb16631fc9c41f2ea4515fa2b82c44b Mon Sep 17 00:00:00 2001 From: VladimirAmiorkov Date: Mon, 25 Mar 2019 10:17:38 +0200 Subject: [PATCH 15/20] chore: add example that shows "popover" mode for modal service --- .../navigation/basic.navigation.component.ts | 38 +++++++++++++------ e2e/modal-navigation-ng/package.json | 1 + e2e/modal-navigation-ng/references.d.ts | 1 + 3 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 e2e/modal-navigation-ng/references.d.ts diff --git a/e2e/modal-navigation-ng/app/navigation/basic.navigation.component.ts b/e2e/modal-navigation-ng/app/navigation/basic.navigation.component.ts index 54c818612..64e2f6070 100644 --- a/e2e/modal-navigation-ng/app/navigation/basic.navigation.component.ts +++ b/e2e/modal-navigation-ng/app/navigation/basic.navigation.component.ts @@ -1,4 +1,4 @@ -import { Component, ViewContainerRef, Input } from "@angular/core"; +import { Component, ViewContainerRef, Input, ViewChild } from "@angular/core"; import { Router, NavigationEnd } from "@angular/router"; import { ModalDialogService, ModalDialogOptions } from "nativescript-angular/directives/dialogs"; import { ModalComponent } from "../modal/modal.component"; @@ -16,12 +16,14 @@ import { ModalViewComponent } from "~/modal-shared/modal-view.component"; - + + ` }) export class BasicsNavigationComponent { + @ViewChild("popoverButtonComp") popoverButtonComp; @Input() col: number; constructor( private modal: ModalDialogService, @@ -29,7 +31,7 @@ export class BasicsNavigationComponent { private vcf: ViewContainerRef, private viewContainerRefService: ViewContainerRefService) { } - + onModalNoFrame() { const options: ModalDialogOptions = { context: { @@ -74,14 +76,28 @@ export class BasicsNavigationComponent { onRootModalTap(): void { const options: ModalDialogOptions = { - viewContainerRef: this.viewContainerRefService.root, - context: {}, - fullscreen: true + viewContainerRef: this.viewContainerRefService.root, + context: {}, + fullscreen: true }; - + this.modal.showModal(ModalViewComponent, options) - .then((result: string) => { - console.log(result); - }); - } + .then((result: string) => { + console.log(result); + }); + } + + onPopoverModal() { + const options: ModalDialogOptions = { + viewContainerRef: this.viewContainerRefService.root, + context: {}, + ios: { + presentationStyle: UIModalPresentationStyle.Popover + }, + sourceView: this.popoverButtonComp + }; + + this.modal.showModal(ModalViewComponent, options) + .then((result: string) => { console.log(result);}); + } } diff --git a/e2e/modal-navigation-ng/package.json b/e2e/modal-navigation-ng/package.json index 444d4b4ee..fc6209dc9 100644 --- a/e2e/modal-navigation-ng/package.json +++ b/e2e/modal-navigation-ng/package.json @@ -46,6 +46,7 @@ "nativescript-dev-appium": "next", "nativescript-dev-typescript": "next", "nativescript-dev-webpack": "next", + "tns-platform-declarations": "next", "typescript": "~3.1.1" }, "scripts": { diff --git a/e2e/modal-navigation-ng/references.d.ts b/e2e/modal-navigation-ng/references.d.ts new file mode 100644 index 000000000..b945d69c5 --- /dev/null +++ b/e2e/modal-navigation-ng/references.d.ts @@ -0,0 +1 @@ +/// \ No newline at end of file From 0e90cc382ac5a67f61a23ac4eef936eb007d0f66 Mon Sep 17 00:00:00 2001 From: VladimirAmiorkov Date: Tue, 26 Mar 2019 11:10:44 +0200 Subject: [PATCH 16/20] chore: remove old todo comment --- nativescript-angular/directives/dialogs.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/nativescript-angular/directives/dialogs.ts b/nativescript-angular/directives/dialogs.ts index fbdecb34d..17ad11289 100644 --- a/nativescript-angular/directives/dialogs.ts +++ b/nativescript-angular/directives/dialogs.ts @@ -145,9 +145,6 @@ export class ModalDialogService { (componentView.parent).removeChild(componentView); } - - // TODO: remove cast after https://github.com/NativeScript/NativeScript/pull/5734 - // is in a published version of tns-core-modules. options.parentView.showModal(componentView, { ...options, closeCallback }); }); } From 2ce80074937b9b73e999fdf08fe0d9c2cd7370e1 Mon Sep 17 00:00:00 2001 From: VladimirAmiorkov Date: Wed, 27 Mar 2019 15:44:01 +0200 Subject: [PATCH 17/20] chore(list-view): change the import to be from the base module chore(list-view): rename the new options API and change its type --- nativescript-angular/directives/dialogs.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/nativescript-angular/directives/dialogs.ts b/nativescript-angular/directives/dialogs.ts index 17ad11289..f5905f059 100644 --- a/nativescript-angular/directives/dialogs.ts +++ b/nativescript-angular/directives/dialogs.ts @@ -18,7 +18,8 @@ import { AppHostView } from "../app-host-view"; import { DetachedLoader } from "../common/detached-loader"; import { PageFactory, PAGE_FACTORY } from "../platform-providers"; import { once } from "../common/utils"; -import { topmost, Frame, ShowModalOptions } from "tns-core-modules/ui/frame"; +import { topmost, Frame } from "tns-core-modules/ui/frame"; +import { ShowModalOptions } from "tns-core-modules/ui/core/view"; export type BaseShowModalOptions = Pick>; @@ -26,7 +27,7 @@ export interface ModalDialogOptions extends BaseShowModalOptions { context?: any; viewContainerRef?: ViewContainerRef; moduleRef?: NgModuleRef; - sourceView?: ElementRef; + target?: View; } export class ModalDialogParams { @@ -62,9 +63,10 @@ export class ModalDialogService { } let parentView = options.viewContainerRef.element.nativeElement; - if (options.sourceView) { - parentView = options.sourceView.nativeElement; + if (options.target) { + parentView = options.target; } + if (parentView instanceof AppHostView && parentView.ngAppRoot) { parentView = parentView.ngAppRoot; } From cb7da864ead226c777d85c6652862f329e7d3893 Mon Sep 17 00:00:00 2001 From: VladimirAmiorkov Date: Wed, 27 Mar 2019 16:00:53 +0200 Subject: [PATCH 18/20] chore: update "pop over modal" example with new API --- .../app/navigation/basic.navigation.component.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/e2e/modal-navigation-ng/app/navigation/basic.navigation.component.ts b/e2e/modal-navigation-ng/app/navigation/basic.navigation.component.ts index 64e2f6070..ad0cd0031 100644 --- a/e2e/modal-navigation-ng/app/navigation/basic.navigation.component.ts +++ b/e2e/modal-navigation-ng/app/navigation/basic.navigation.component.ts @@ -1,4 +1,4 @@ -import { Component, ViewContainerRef, Input, ViewChild } from "@angular/core"; +import { Component, ViewContainerRef, Input, ViewChild, ElementRef } from "@angular/core"; import { Router, NavigationEnd } from "@angular/router"; import { ModalDialogService, ModalDialogOptions } from "nativescript-angular/directives/dialogs"; import { ModalComponent } from "../modal/modal.component"; @@ -16,14 +16,14 @@ import { ModalViewComponent } from "~/modal-shared/modal-view.component"; - - + + ` }) export class BasicsNavigationComponent { - @ViewChild("popoverButtonComp") popoverButtonComp; + @ViewChild("popoverButtonComp") popoverButtonComp: ElementRef; @Input() col: number; constructor( private modal: ModalDialogService, @@ -94,7 +94,7 @@ export class BasicsNavigationComponent { ios: { presentationStyle: UIModalPresentationStyle.Popover }, - sourceView: this.popoverButtonComp + target: this.popoverButtonComp.nativeElement }; this.modal.showModal(ModalViewComponent, options) From 3feada8485161dfef3ef301f88c2718b0fe88cd4 Mon Sep 17 00:00:00 2001 From: VladimirAmiorkov Date: Wed, 27 Mar 2019 16:04:24 +0200 Subject: [PATCH 19/20] chore: fix tslint error --- nativescript-angular/directives/dialogs.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nativescript-angular/directives/dialogs.ts b/nativescript-angular/directives/dialogs.ts index f5905f059..51363c032 100644 --- a/nativescript-angular/directives/dialogs.ts +++ b/nativescript-angular/directives/dialogs.ts @@ -6,8 +6,7 @@ import { NgModuleRef, ReflectiveInjector, Type, - ViewContainerRef, - ElementRef, + ViewContainerRef } from "@angular/core"; import { NSLocationStrategy } from "../router/ns-location-strategy"; From 210e71b7927d33b26a87b2a725cf0373ab109fa1 Mon Sep 17 00:00:00 2001 From: SvetoslavTsenov Date: Tue, 23 Apr 2019 11:47:46 +0300 Subject: [PATCH 20/20] release: cut the 7.2.4 release --- CHANGELOG.md | 19 +++++++++++++++++++ nativescript-angular/package.json | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a955ef1f..b5501235f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,22 @@ + +## [7.2.4](https://github.com/NativeScript/nativescript-angular/compare/7.2.3...7.2.4) (2019-04-23) + + +### Bug Fixes + +* **router:** routing services should be provided in forRoot only ([#1729](https://github.com/NativeScript/nativescript-angular/issues/1729)) ([0f6a975](https://github.com/NativeScript/nativescript-angular/commit/0f6a975)) +* on destroy remove the lastBootstrappedModule ([5e13263](https://github.com/NativeScript/nativescript-angular/commit/5e13263)) +* page might be null'ed before clearHistory's navigatedToEvent ([ea66985](https://github.com/NativeScript/nativescript-angular/commit/ea66985)) +* remove rootContent on exit ([14e787f](https://github.com/NativeScript/nativescript-angular/commit/14e787f)) +* the exit event is triggered on restart ([3dffbd5](https://github.com/NativeScript/nativescript-angular/commit/3dffbd5)) + + +### Features + +* **modal:** add ‘ios presentationStyle’ option to ModalDialogParams ([9cfa127](https://github.com/NativeScript/nativescript-angular/commit/9cfa127)) + + + ## [7.2.3](https://github.com/NativeScript/nativescript-angular/compare/7.2.2...7.2.3) (2019-03-14) diff --git a/nativescript-angular/package.json b/nativescript-angular/package.json index 062189aaa..b185a77f9 100644 --- a/nativescript-angular/package.json +++ b/nativescript-angular/package.json @@ -1,6 +1,6 @@ { "name": "nativescript-angular", - "version": "7.3.0", + "version": "7.2.4", "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",