Skip to content

Commit c7e2884

Browse files
author
Nedyalko Nikolov
committed
Make nativescript-angular modules es6.
1 parent 12cfa30 commit c7e2884

21 files changed

+294
-190
lines changed

Diff for: .gitignore

+10-6
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ tags
66

77
/hooks
88

9-
nativescript-angular/**/*.d.ts
10-
!nativescript-angular/global.d.ts
11-
nativescript-angular/**/*.js
12-
!nativescript-angular/postinstall.js
13-
!nativescript-angular/hooks/**/*.js
14-
!nativescript-angular/gulpfile.js
9+
/nativescript-angular/**/*.d.ts
10+
/nativescript-angular/**/*.js
11+
12+
!/nativescript-angular/global.d.ts
13+
!/nativescript-angular/postinstall.js
14+
!/nativescript-angular/initial-imports.js
15+
!/nativescript-angular/hooks/**/*.js
16+
!/nativescript-angular/gulpfile.js
17+
!/nativescript-angular/rollup.config.js
18+
!/nativescript-angular/zone-js/**/*.js
1519

1620
.tscache
1721
.nvm

Diff for: nativescript-angular/animation-player.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { View } from "ui/core/view";
1010
import { AnimationCurve } from "ui/enums";
1111
import { ValueSource } from "ui/core/dependency-observable";
1212
import { isString } from "utils/types";
13-
import * as styleProperty from "ui/styling/style-property";
13+
import { getPropertyByCssName, KeyValuePair, Property } from "ui/styling/style-property";
1414

1515
export class NativeScriptAnimationPlayer implements AnimationPlayer {
1616

@@ -60,7 +60,7 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
6060
for (let style of keyframe.styles.styles) {
6161
for (let substyle in style) {
6262
let value = style[substyle];
63-
let property = styleProperty.getPropertyByCssName(substyle);
63+
let property = getPropertyByCssName(substyle);
6464
if (property) {
6565
if (typeof value === "string" && property.valueConverter) {
6666
value = property.valueConverter(<string>value);
@@ -218,7 +218,7 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
218218

219219
static parseTransform(value: string, animationInfo: KeyframeInfo) {
220220
let newTransform = NativeScriptAnimationPlayer.transformConverter(value);
221-
let array = new Array<styleProperty.KeyValuePair<styleProperty.Property, any>>();
221+
let array = new Array<KeyValuePair<Property, any>>();
222222
let values = undefined;
223223
for (let transform in newTransform) {
224224
switch (transform) {

Diff for: nativescript-angular/common/detached-loader.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import {
22
ComponentRef, ComponentFactory, ViewContainerRef,
33
Component, Type, ComponentFactoryResolver, ChangeDetectorRef
44
} from "@angular/core";
5-
import * as trace from "trace";
5+
import { write } from "trace";
66

77
export const CATEGORY = "detached-loader";
88
function log(message: string) {
9-
trace.write(message, CATEGORY);
9+
write(message, CATEGORY);
1010
}
1111

1212

Diff for: nativescript-angular/directives/tab-view.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ElementRef, Directive, Input, TemplateRef, ViewContainerRef } from "@angular/core";
22
import { TabView, TabViewItem } from "ui/tab-view";
3-
import * as utils from "../common/utils";
3+
import { convertToInt } from "../common/utils";
44
import { rendererLog } from "../trace";
55
import { isBlank } from "../lang-facade";
66

@@ -18,7 +18,7 @@ export class TabViewDirective {
1818
}
1919

2020
set selectedIndex(value) {
21-
this._selectedIndex = utils.convertToInt(value);
21+
this._selectedIndex = convertToInt(value);
2222
if (this.viewInitialized) {
2323
this.tabView.selectedIndex = this._selectedIndex;
2424
}

Diff for: nativescript-angular/global.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
/// <reference path="./node_modules/tns-core-modules/tns-core-modules.d.ts" />
1+
/// <reference path="./node_modules/tns-core-modules/tns-core-modules.es6.d.ts" />

Diff for: nativescript-angular/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
export * from "./platform";
2+
export * from "./platform-common";
23
export * from "./platform-static";
34
export * from "./router";
45
export * from "./forms";
56
export * from "./http";
67
export * from "./directives";
78
export * from "./common/detached-loader";
9+
export * from "./trace";
10+
export * from "./platform-providers";

Diff for: nativescript-angular/initial-imports.js

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// always import application at first place in order to fix some cycle dependency hell in ios.
2+
import "application";

Diff for: nativescript-angular/nativescript.module.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import "globals";
2-
import "./zone.js/dist/zone-nativescript";
2+
import "./zone-js/dist/zone-nativescript";
33

44
import "reflect-metadata";
55
import "./polyfills/array";

Diff for: nativescript-angular/package.json

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
{
22
"private": true,
33
"name": "nativescript-angular",
4+
"main": "bundle.all.js",
5+
"module": "index.js",
6+
"typings": "index.d.ts",
47
"version": "1.2.0",
58
"description": "An Angular 2 renderer that lets you build mobile apps with NativeScript.",
69
"homepage": "http://www.telerik.com",
@@ -18,10 +21,10 @@
1821
"postinstall": "node postinstall.js",
1922
"ngc": "ngc -p tsconfig.json",
2023
"tsc": "tsc -p tsconfig.json",
21-
"prepublish": "npm run tsc && npm run ngc"
24+
"prepublish": "npm run tsc && rollup -c && npm run ngc"
2225
},
2326
"dependencies": {
24-
"nativescript-intl": "~0.0.4",
27+
"nativescript-intl": "~0.0.5",
2528
"@angular/core": "~2.2.1",
2629
"@angular/common": "~2.2.1",
2730
"@angular/compiler": "~2.2.1",
@@ -35,14 +38,17 @@
3538
"parse5": "1.3.2",
3639
"punycode": "1.3.2",
3740
"querystring": "0.2.0",
41+
"rxjs": "5.0.0-beta.12",
3842
"url": "0.10.3"
3943
},
4044
"devDependencies": {
4145
"tns-core-modules": ">=2.4.0 || >=2.4.0-2016",
4246
"zone.js": "^0.6.21",
4347
"typescript": "^2.0.2",
4448
"tslint": "~4.0.1",
45-
"@angular/compiler-cli": "~2.2.1"
49+
"@angular/compiler-cli": "~2.2.1",
50+
"rollup": "^0.36.3",
51+
"rollup-plugin-multi-entry": "^2.0.1"
4652
},
4753
"nativescript": {}
4854
}

Diff for: nativescript-angular/platform-common.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Initial imports and polyfills
22
import "globals";
3-
import "./zone.js/dist/zone-nativescript";
3+
import "./zone-js/dist/zone-nativescript";
44
import "reflect-metadata";
55
import "./polyfills/array";
66
import "./polyfills/console";
@@ -28,7 +28,7 @@ if (global.___TS_UNUSED) {
2828
import { rendererLog, rendererError } from "./trace";
2929
import { PAGE_FACTORY, PageFactory, defaultPageFactoryProvider } from "./platform-providers";
3030

31-
import * as application from "application";
31+
import { start } from "application";
3232
import { topmost, NavigationEntry } from "ui/frame";
3333
import { Page } from "ui/page";
3434
import { TextView } from "ui/text-view";
@@ -91,7 +91,7 @@ export class NativeScriptPlatformRef extends PlatformRef {
9191

9292
const mainPageEntry = this.createNavigationEntry(this._bootstrapper);
9393

94-
application.start(mainPageEntry);
94+
start(mainPageEntry);
9595
}
9696

9797
livesyncModule(): void {

Diff for: nativescript-angular/renderer.ts

+21-30
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,34 @@
11
import {
22
Inject, Injectable, Optional, NgZone,
3-
Renderer, RootRenderer, RenderComponentType,
3+
Renderer, RootRenderer, RenderComponentType,AnimationPlayer
44
} from "@angular/core";
5-
import { AnimationPlayer } from "@angular/core";
65
import { AnimationStyles, AnimationKeyframe } from "./private_import_core";
7-
import {APP_ROOT_VIEW, DEVICE} from "./platform-providers";
8-
import {isBlank} from "./lang-facade";
9-
import {View} from "ui/core/view";
10-
import * as application from "application";
11-
import {topmost} from "ui/frame";
12-
import {Page} from "ui/page";
13-
import {ViewUtil, NgView} from "./view-util";
14-
import {rendererLog as traceLog} from "./trace";
15-
import {escapeRegexSymbols} from "utils/utils";
6+
import { APP_ROOT_VIEW, DEVICE } from "./platform-providers";
7+
import { isBlank } from "./lang-facade";
8+
import { View } from "ui/core/view";
9+
import { addCss } from "application";
10+
import { topmost } from "ui/frame";
11+
import { Page } from "ui/page";
12+
import { ViewUtil, NgView } from "./view-util";
13+
import { rendererLog as traceLog } from "./trace";
14+
import { escapeRegexSymbols } from "utils/utils";
1615
import { Device } from "platform";
1716

18-
import * as nsAnimationDriver from "./animation-driver";
19-
let nsAnimationDriverModule: typeof nsAnimationDriver;
17+
import { NativeScriptAnimationDriver } from "./animation-driver";
2018

21-
function ensureAnimationDriverModule() {
22-
if (!nsAnimationDriverModule) {
23-
nsAnimationDriverModule = require("./animation-driver");
24-
}
25-
}
26-
27-
// CONTENT_ATTR not exported from dom_renderer - we need it for styles application.
19+
//CONTENT_ATTR not exported from dom_renderer - we need it for styles application.
2820
export const COMPONENT_VARIABLE = "%COMP%";
2921
export const CONTENT_ATTR = `_ngcontent-${COMPONENT_VARIABLE}`;
3022

3123

3224
@Injectable()
3325
export class NativeScriptRootRenderer implements RootRenderer {
3426
private _viewUtil: ViewUtil;
35-
private _animationDriver: nsAnimationDriver.NativeScriptAnimationDriver;
27+
private _animationDriver: NativeScriptAnimationDriver;
3628

37-
protected get animationDriver(): nsAnimationDriver.NativeScriptAnimationDriver {
29+
protected get animationDriver(): NativeScriptAnimationDriver {
3830
if (!this._animationDriver) {
39-
ensureAnimationDriverModule();
40-
this._animationDriver = new nsAnimationDriverModule.NativeScriptAnimationDriver();
31+
this._animationDriver = new NativeScriptAnimationDriver();
4132
}
4233
return this._animationDriver;
4334
}
@@ -89,18 +80,18 @@ export class NativeScriptRenderer extends Renderer {
8980

9081
constructor(
9182
private rootRenderer: NativeScriptRootRenderer,
92-
componentProto: RenderComponentType,
93-
private animationDriver: nsAnimationDriver.NativeScriptAnimationDriver,
83+
private componentProto: RenderComponentType,
84+
private animationDriver: NativeScriptAnimationDriver,
9485
private zone: NgZone) {
9586

9687
super();
97-
let stylesLength = componentProto.styles.length;
98-
this.componentProtoId = componentProto.id;
88+
let stylesLength = this.componentProto.styles.length;
89+
this.componentProtoId = this.componentProto.id;
9990
for (let i = 0; i < stylesLength; i++) {
10091
this.hasComponentStyles = true;
101-
let cssString = componentProto.styles[i] + "";
92+
let cssString = this.componentProto.styles[i] + "";
10293
const realCSS = this.replaceNgAttribute(cssString, this.componentProtoId);
103-
application.addCss(realCSS);
94+
addCss(realCSS);
10495
}
10596
traceLog("NativeScriptRenderer created");
10697
}

Diff for: nativescript-angular/rollup.config.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import multiEntry from "rollup-plugin-multi-entry";
2+
3+
let entryPoint = require("./rollup_entry.json");
4+
5+
class DebugInfoRoll {
6+
constructor(options){
7+
this.options = options;
8+
}
9+
resolveId(id, from){
10+
console.log(id, from);
11+
}
12+
}
13+
14+
const debugInfoRoll = (config) => new DebugInfoRoll(config);
15+
16+
export default {
17+
entry: {
18+
include: entryPoint.include,
19+
//exclude: [
20+
//"rollup.config.js",
21+
//"bundle.all.js",
22+
//"postinstall.js",
23+
//"hooks/**/*.js",
24+
//"node_modules/**/*.js"
25+
//]
26+
},
27+
dest: "bundle.all.js",
28+
format: "cjs",
29+
sourceMap: "inline",
30+
external: ["@angular"],
31+
treeshake: false,
32+
plugins: [
33+
//debugInfoRoll(),
34+
multiEntry()
35+
]
36+
}

Diff for: nativescript-angular/rollup_entry.json

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"include": [
3+
"initial-imports.js",
4+
"platform-common.js",
5+
"platform-providers.js",
6+
"platform-static.js",
7+
"platform.js",
8+
"animation-driver.js",
9+
"animation-player.js",
10+
"collection-facade.js",
11+
"common/detached-loader.js",
12+
"common/utils.js",
13+
"directives.js",
14+
"directives/action-bar.js",
15+
"directives/dialogs.js",
16+
"directives/list-view-comp.js",
17+
"directives/platform-filters.js",
18+
"directives/tab-view.js",
19+
"dom-adapter.js",
20+
"element-registry.js",
21+
"file-system/ns-file-system.js",
22+
"forms.js",
23+
"http.js",
24+
"http/ns-http.js",
25+
"lang-facade.js",
26+
"modal-dialog.js",
27+
"nativescript.module.js",
28+
"parse5_adapter.js",
29+
"polyfills/array.js",
30+
"polyfills/console.js",
31+
"private_import_core.js",
32+
"private_import_platform-browser.js",
33+
"renderer.js",
34+
"resource-loader.js",
35+
"router-url-tree.js",
36+
"router.js",
37+
"router/ns-location-strategy.js",
38+
"router/ns-platform-location.js",
39+
"router/ns-router-link-active.js",
40+
"router/ns-router-link.js",
41+
"router/page-router-outlet.js",
42+
"router/router-extensions.js",
43+
"trace.js",
44+
"value-accessors/base-value-accessor.js",
45+
"value-accessors/checked-value-accessor.js",
46+
"value-accessors/date-value-accessor.js",
47+
"value-accessors/number-value-accessor.js",
48+
"value-accessors/selectedIndex-value-accessor.js",
49+
"value-accessors/text-value-accessor.js",
50+
"value-accessors/time-value-accessor.js",
51+
"view-util.js",
52+
"zone.js/dist/zone-nativescript.js"
53+
]
54+
}

Diff for: nativescript-angular/router.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import { PageRouterOutlet } from "./router/page-router-outlet";
77
import { NSLocationStrategy } from "./router/ns-location-strategy";
88
import { NativescriptPlatformLocation } from "./router/ns-platform-location";
99
import { RouterExtensions } from "./router/router-extensions";
10-
export { routerTraceCategory } from "./trace";
10+
import { NativeScriptModule } from "./nativescript.module";
11+
1112
export { PageRoute } from "./router/page-router-outlet";
1213
export { RouterExtensions } from "./router/router-extensions";
13-
import { NativeScriptModule } from "./nativescript.module";
1414

1515
@NgModule({
1616
declarations: [

Diff for: nativescript-angular/tsconfig.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"compilerOptions": {
3-
"target": "es5",
4-
"module": "commonjs",
3+
"target": "es6",
4+
"module": "es6",
5+
"moduleResolution": "node",
56
"sourceMap": true,
67
"emitDecoratorMetadata": true,
78
"experimentalDecorators": true,

Diff for: nativescript-angular/value-accessors/selectedIndex-value-accessor.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import {Directive, ElementRef, forwardRef } from "@angular/core";
2-
import {NG_VALUE_ACCESSOR} from "@angular/forms";
3-
import {BaseValueAccessor} from "./base-value-accessor";
4-
import {View} from "ui/core/view";
5-
import * as utils from "../common/utils";
1+
import { Directive, ElementRef, forwardRef } from "@angular/core";
2+
import { NG_VALUE_ACCESSOR } from "@angular/forms";
3+
import { BaseValueAccessor } from "./base-value-accessor";
4+
import { View } from "ui/core/view";
5+
import { convertToInt } from "../common/utils";
66

77
const SELECTED_INDEX_VALUE_ACCESSOR = {provide: NG_VALUE_ACCESSOR,
88
useExisting: forwardRef(() => SelectedIndexValueAccessor), multi: true};
@@ -35,7 +35,7 @@ export class SelectedIndexValueAccessor extends BaseValueAccessor<SelectableView
3535
private viewInitialized: boolean;
3636

3737
writeValue(value: any): void {
38-
this._normalizedValue = utils.convertToInt(value);
38+
this._normalizedValue = convertToInt(value);
3939
if (this.viewInitialized) {
4040
this.view.selectedIndex = this._normalizedValue;
4141
}

0 commit comments

Comments
 (0)