Skip to content

Commit c8c53ef

Browse files
committed
feat: support for AoT Angular plus added build scripts
1 parent e0b9add commit c8c53ef

File tree

7 files changed

+122
-7
lines changed

7 files changed

+122
-7
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*.log
44
*.d.ts
55
!index.d.ts
6+
!gruntfile.js
67
demo/lib
78
demo/app/*.js
89
demo/*.d.ts
@@ -18,4 +19,6 @@ demo-ng/.vscode
1819
node_modules
1920
.vscode/
2021
.idea/
21-
*.DS_Store
22+
*.DS_Store
23+
bin
24+
!webpack.*.js

.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ screens/
44
app/
55
hooks/
66
.vscode/
7+
gruntfile.js
78
*.png
89
*.log
910
*.ts
1011
!index.d.ts
1112
!BEMCheckBox.d.ts
1213
tsconfig.json
14+
tsconfig.aot.json
1315
README.md

angular/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export type CheckableView = {checked: boolean} & View;
2424
* ```
2525
*/
2626
@Directive({
27-
selector: "CheckBox[ngModel], CheckBox[formControlName], CheckBox[ngModel], CheckBox[formControlName], check-box[ngModel], check-box[formControlName]",
27+
selector: "CheckBox[ngModel], CheckBox[formControlName], checkBox[ngModel], checkBox[formControlName], check-box[ngModel], check-box[formControlName]",
2828
providers: [CHECKED_VALUE_ACCESSOR]
2929
})
3030
export class CheckedValueAccessor extends BaseValueAccessor<CheckableView> {

checkbox.android.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const textProperty = new Property<CheckBox, string>({
2727
export const fillColorProperty = new CssProperty<Style, string>({
2828
name: 'fillColor',
2929
cssName: 'fill-color',
30-
valueConverter: v => {
30+
valueConverter: (v) => {
3131
return String(v)
3232
}
3333
});
@@ -36,7 +36,7 @@ export const tintColorProperty = new CssProperty<Style, string>({
3636
name: 'tintColor',
3737
cssName: 'tint-color',
3838
defaultValue: '#0075ff',
39-
valueConverter: v => {
39+
valueConverter: (v) => {
4040
return String(v)
4141
}
4242
});
@@ -124,11 +124,12 @@ export class CheckBox extends View implements CheckBoxInterface {
124124
}
125125
set fillColor(color:string){
126126
(<any>this.style).fillColor = color;
127-
if (this._android && device.sdkVersion >= "21")
127+
if (this._android && device.sdkVersion >= "21") {
128128
this._android.setButtonTintList(android.content.res.ColorStateList.valueOf(new Color(color).android));
129+
}
129130
}
130131

131-
//There is no difference between tint and fill on the android widget
132+
// There is no difference between tint and fill on the android widget
132133
get tintColor(): string {
133134
return (<any>this.style).fillColor;
134135
}

gruntfile.js

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
module.exports = function (grunt) {
2+
var localConfig = {
3+
typeScriptDeclarations: [
4+
"**/*.d.ts",
5+
"!references.d.ts",
6+
"!node_modules/**/*.*",
7+
"!demo/**/*.*",
8+
"!demo-ng/**/*.*",
9+
"!bin/**/*.*"
10+
],
11+
outDir: "bin/dist/"
12+
}
13+
14+
grunt.initConfig({
15+
clean: {
16+
build: {
17+
src: [localConfig.outDir]
18+
}
19+
},
20+
copy: {
21+
declarations: {
22+
src: localConfig.typeScriptDeclarations,
23+
dest: localConfig.outDir
24+
},
25+
packageConfig: {
26+
src: "package.json",
27+
dest: localConfig.outDir,
28+
options: {
29+
process: function (content, srcPath) {
30+
var contentAsObject = JSON.parse(content);
31+
contentAsObject.devDependencies = undefined;
32+
return JSON.stringify(contentAsObject, null, "\t");
33+
}
34+
}
35+
},
36+
readme: {
37+
src: "README.md",
38+
dest: localConfig.outDir,
39+
options: {
40+
process: function (content, srcPath) {
41+
return content.substring(content.indexOf("\n") + 1)
42+
}
43+
}
44+
}
45+
},
46+
exec: {
47+
tsCompile: {
48+
cmd: "node ./node_modules/typescript/bin/tsc --project tsconfig.json --outDir " + localConfig.outDir
49+
},
50+
ngCompile: {
51+
cmd: "node ./node_modules/.bin/ngc --project tsconfig.aot.json --outDir " + localConfig.outDir
52+
},
53+
npm_publish: {
54+
cmd: "npm publish",
55+
cwd: localConfig.outDir
56+
}
57+
}
58+
});
59+
60+
grunt.loadNpmTasks("grunt-contrib-copy");
61+
grunt.loadNpmTasks("grunt-contrib-clean");
62+
grunt.loadNpmTasks("grunt-exec");
63+
64+
grunt.registerTask("build", [
65+
"clean:build",
66+
"exec:tsCompile",
67+
"exec:ngCompile",
68+
"copy"
69+
]);
70+
grunt.registerTask("publish", [
71+
"build",
72+
"exec:npm_publish"
73+
]);
74+
};

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-checkbox",
3-
"version": "2.1.1",
3+
"version": "2.1.2",
44
"description": "NativeScript plugin for checkbox widget.",
55
"main": "checkbox",
66
"typings": "index.d.ts",
@@ -74,6 +74,11 @@
7474
"zone.js": "~0.8.9",
7575
"nativescript-angular": "~3.0.0",
7676

77+
"grunt": "1.0.1",
78+
"grunt-contrib-copy": "1.0.0",
79+
"grunt-contrib-clean": "1.0.0",
80+
"grunt-exec": "2.0.0",
81+
7782
"tns-core-modules": "^3.0.0",
7883
"tns-platform-declarations": "^3.0.0",
7984
"typescript": "^2.2.0"

tsconfig.aot.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"compilerOptions": {
3+
"noEmitOnError": true,
4+
"noEmitHelpers": true,
5+
"sourceMap": false,
6+
"removeComments": true,
7+
"declaration": true,
8+
"experimentalDecorators": true,
9+
"target": "es5",
10+
"module": "commonjs",
11+
"outDir": "bin/dist",
12+
"lib": ["es6", "dom", "es2015.iterable"],
13+
"rootDir": ".",
14+
"baseUrl": ".",
15+
"paths": {
16+
"*": [
17+
"./node_modules/tns-core-modules/*",
18+
"./node_modules/*"
19+
]
20+
},
21+
"emitDecoratorMetadata": true,
22+
"moduleResolution": "node"
23+
},
24+
"files": [
25+
"angular/index.ts"
26+
],
27+
"angularCompilerOptions": {
28+
"skipTemplateCodegen": true
29+
}
30+
}

0 commit comments

Comments
 (0)