Skip to content

Commit f549b94

Browse files
Merge remote-tracking branch 'origin/master' into merge-release-in-master
2 parents ddff719 + 06bbcae commit f549b94

File tree

5 files changed

+176
-22
lines changed

5 files changed

+176
-22
lines changed

build-docs.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
set -e
2+
3+
ENV="${ENV:-dev}"
4+
DIST_DIR="nativescript-angular/bin/dist"
5+
APIREF_DIR="$DIST_DIR/ng-api-reference"
6+
rm -rf "$APIREF_DIR"
7+
cd "nativescript-angular"
8+
npm install
9+
npm run typedoc

nativescript-angular/package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-angular",
3-
"version": "7.2.3",
3+
"version": "7.3.0",
44
"description": "An Angular renderer that lets you build mobile apps with NativeScript.",
55
"homepage": "https://www.nativescript.org/",
66
"bugs": "https://github.com/NativeScript/nativescript-angular/issues",
@@ -34,7 +34,8 @@
3434
"tsc-w": "tsc -p tsconfig.json -w",
3535
"ngc": "ngc -p tsconfig.json",
3636
"prepare": "npm run ngc",
37-
"version": "rm -rf package-lock.json && conventional-changelog -p angular -i ../CHANGELOG.md -s && git add ../CHANGELOG.md"
37+
"version": "rm -rf package-lock.json && conventional-changelog -p angular -i ../CHANGELOG.md -s && git add ../CHANGELOG.md",
38+
"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\""
3839
},
3940
"bin": {
4041
"update-app-ng-deps": "./bin/update-app-ng-deps"
@@ -73,6 +74,8 @@
7374
"tns-core-modules": "next",
7475
"tslint": "^5.5.0",
7576
"typescript": "~3.1.1",
76-
"zone.js": "^0.8.4"
77+
"zone.js": "^0.8.4",
78+
"nativescript-typedoc-theme": "git://github.com/NativeScript/nativescript-typedoc-theme.git#master",
79+
"typedoc": "^0.13.0"
7780
}
7881
}

nativescript-angular/router/router.module.ts

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,39 @@ export { NSEmptyOutletComponent } from "./ns-empty-outlet.component";
1919

2020
export type LocationState = LocationState;
2121

22+
const ROUTER_DIRECTIVES = [NSRouterLink, NSRouterLinkActive, PageRouterOutlet, NSEmptyOutletComponent];
23+
24+
const NS_ROUTER_PROVIDERS = [
25+
{
26+
provide: NSLocationStrategy,
27+
useFactory: provideLocationStrategy,
28+
deps: [[NSLocationStrategy, new Optional(), new SkipSelf()], FrameService],
29+
},
30+
{ provide: LocationStrategy, useExisting: NSLocationStrategy },
31+
NativescriptPlatformLocation,
32+
{ provide: PlatformLocation, useClass: NativescriptPlatformLocation },
33+
RouterExtensions,
34+
NSRouteReuseStrategy,
35+
{ provide: RouteReuseStrategy, useExisting: NSRouteReuseStrategy },
36+
];
37+
2238
@NgModule({
23-
declarations: [NSRouterLink, NSRouterLinkActive, PageRouterOutlet, NSEmptyOutletComponent],
24-
providers: [
25-
{
26-
provide: NSLocationStrategy,
27-
useFactory: provideLocationStrategy,
28-
deps: [[NSLocationStrategy, new Optional(), new SkipSelf()], FrameService],
29-
},
30-
{ provide: LocationStrategy, useExisting: NSLocationStrategy },
31-
NativescriptPlatformLocation,
32-
{ provide: PlatformLocation, useClass: NativescriptPlatformLocation },
33-
RouterExtensions,
34-
NSRouteReuseStrategy,
35-
{ provide: RouteReuseStrategy, useExisting: NSRouteReuseStrategy },
36-
],
39+
declarations: ROUTER_DIRECTIVES,
40+
entryComponents: [NSEmptyOutletComponent],
3741
imports: [RouterModule, NativeScriptCommonModule],
38-
exports: [RouterModule, NSRouterLink, NSRouterLinkActive, PageRouterOutlet, NSEmptyOutletComponent],
42+
exports: [RouterModule, ...ROUTER_DIRECTIVES],
3943
schemas: [NO_ERRORS_SCHEMA],
4044
})
4145
export class NativeScriptRouterModule {
42-
static forRoot(routes: Routes, config?: ExtraOptions): ModuleWithProviders {
43-
return RouterModule.forRoot(routes, config);
46+
static forRoot(routes: Routes, config?: ExtraOptions): ModuleWithProviders<NativeScriptRouterModule> {
47+
return {
48+
ngModule: NativeScriptRouterModule,
49+
providers: [...RouterModule.forRoot(routes, config).providers, ...NS_ROUTER_PROVIDERS]
50+
};
4451
}
4552

46-
static forChild(routes: Routes): ModuleWithProviders {
47-
return RouterModule.forChild(routes);
53+
static forChild(routes: Routes): ModuleWithProviders<NativeScriptRouterModule> {
54+
return { ngModule: NativeScriptRouterModule, providers: RouterModule.forChild(routes).providers };
4855
}
4956
}
5057

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{"compilerOptions": {
2+
"target": "es5",
3+
"module": "commonjs",
4+
"moduleResolution": "node",
5+
"sourceMap": true,
6+
"emitDecoratorMetadata": true,
7+
"experimentalDecorators": true,
8+
"noImplicitUseStrict": true,
9+
"noEmitHelpers": true,
10+
"declaration": true,
11+
"removeComments": false,
12+
"noEmitOnError": true,
13+
"noImplicitAny": false,
14+
"lib": [
15+
"dom",
16+
"es6",
17+
"es2015.iterable"
18+
],
19+
"baseUrl": ".",
20+
"paths": {
21+
"*": [
22+
"./node_modules/tns-core-modules/*",
23+
"./node_modules/*"
24+
]
25+
}
26+
},
27+
"angularCompilerOptions": {
28+
"genDir": ".",
29+
"skipMetadataEmit": false,
30+
"skipTemplateCodegen": true,
31+
"strictMetadataEmit": true
32+
},
33+
"exclude": [
34+
"./node_modules",
35+
"tns-core-modules/references.d.ts",
36+
"tns-core-modules/node_modules",
37+
"tns-core-modules/ui/frame/transition-definitions.android.d.ts",
38+
"./zone-js",
39+
"./index.ts",
40+
"./bin",
41+
"./index.d.ts",
42+
"./testing",
43+
"./animations/index.ts",
44+
"./animations/utils.ts",
45+
"./app-host-view.ts",
46+
"./common/utils.ts",
47+
"./dom-adapter.ts",
48+
"./file-system",
49+
"./forms/index.ts",
50+
"./forms/value-accessors/index.ts",
51+
"./lang-facade.ts",
52+
"./polyfills",
53+
"./router/private-imports",
54+
"./schema-registry.ts",
55+
"./http-client/index.ts",
56+
"./http/index.ts",
57+
"./router/index.ts",
58+
""
59+
60+
]
61+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// make sure you import mocha-config before @angular/core
2+
import { Component, ViewChild } from "@angular/core";
3+
import { nsTestBedAfterEach, nsTestBedBeforeEach, nsTestBedRender } from "nativescript-angular/testing";
4+
import { NativeScriptRouterModule, RouterExtensions } from "nativescript-angular/router";
5+
import { NSRouterLink } from "nativescript-angular/router/ns-router-link";
6+
import { NSLocationStrategy } from "nativescript-angular/router/ns-location-strategy";
7+
import { assert } from "~/tests/test-config";
8+
import { ActivatedRoute, Router, RouteReuseStrategy } from "@angular/router";
9+
import { LocationStrategy, PlatformLocation } from "@angular/common";
10+
import { NSRouteReuseStrategy } from "nativescript-angular/router/ns-route-reuse-strategy";
11+
12+
@Component({
13+
template: `<StackLayout><Label nsRouterLink text="COMPONENT"></Label></StackLayout>`
14+
})
15+
class RouterTestComponent {
16+
@ViewChild(NSRouterLink)
17+
nsRouterLink: NSRouterLink;
18+
}
19+
20+
describe("NativeScriptRouterModule.forRoot", () => {
21+
beforeEach(nsTestBedBeforeEach(
22+
[RouterTestComponent],
23+
[],
24+
[NativeScriptRouterModule.forRoot([])],
25+
[]));
26+
27+
afterEach(nsTestBedAfterEach());
28+
29+
it("should provide nativescript routing services", () => {
30+
return nsTestBedRender(RouterTestComponent).then((fixture) => {
31+
const injector = fixture.componentRef.injector
32+
33+
assert.instanceOf(injector.get(LocationStrategy, null), NSLocationStrategy);
34+
assert.instanceOf(injector.get(RouterExtensions, null), RouterExtensions);
35+
assert.instanceOf(injector.get(RouteReuseStrategy, null), NSRouteReuseStrategy);
36+
});
37+
});
38+
39+
it("should provide nativescript routing directives", () => {
40+
return nsTestBedRender(RouterTestComponent).then((fixture) => {
41+
const linkDirective = fixture.componentRef.instance.nsRouterLink;
42+
assert.instanceOf(linkDirective, NSRouterLink);
43+
});
44+
});
45+
});
46+
47+
describe("NativeScriptRouterModule.forChild", () => {
48+
beforeEach(nsTestBedBeforeEach(
49+
[RouterTestComponent],
50+
[
51+
{ provide: Router, useValue: {} },
52+
{ provide: RouterExtensions, useValue: {} },
53+
{ provide: ActivatedRoute, useValue: {} },
54+
],
55+
[NativeScriptRouterModule.forChild([])],
56+
[]));
57+
afterEach(nsTestBedAfterEach());
58+
59+
it("should not provide nativescript routing services", () => {
60+
return nsTestBedRender(RouterTestComponent).then((fixture) => {
61+
const injector = fixture.componentRef.injector
62+
assert.isNull(injector.get(LocationStrategy, null));
63+
assert.isNull(injector.get(RouteReuseStrategy, null));
64+
});
65+
});
66+
67+
it("should provide nativescript routing directives", () => {
68+
return nsTestBedRender(RouterTestComponent).then((fixture) => {
69+
const linkDirective = fixture.componentRef.instance.nsRouterLink;
70+
assert.instanceOf(linkDirective, NSRouterLink);
71+
});
72+
});
73+
});
74+

0 commit comments

Comments
 (0)