Skip to content

Commit 6d43c88

Browse files
Dimitar TachevDimitar Tachev
authored andcommitted
fix: fix rebase conflicts and issues
1 parent b43c7d5 commit 6d43c88

File tree

11 files changed

+68
-61
lines changed

11 files changed

+68
-61
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ demo/node_modules
2525
demo-angular/node_modules
2626

2727
demo-angular/*.d.ts
28+
!demo-angular/references.d.ts
2829
demo-angular/platforms/
2930
demo-angular/hooks
3031

.travis.yml

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ matrix:
44
language: node_js
55
os: linux
66
node_js: "6"
7-
script: cd src && npm run ci.tslint && cd ../demo && npm run ci.tslint
7+
script: cd src && npm run ci.tslint && cd ../demo && npm run ci.tslint && cd ../demo-angular && npm run ci.tslint
88
- stage: "WebPack, Build and Test"
99
os: osx
1010
env:
@@ -13,22 +13,22 @@ matrix:
1313
language: node_js
1414
node_js: "6"
1515
jdk: oraclejdk8
16-
script: cd demo && npm run build.plugin && npm i && tns build ios --bundle --env.uglify
16+
script: cd demo && npm run build.plugin && npm i && tns build ios --bundle --env.uglify && cd ../demo-angular && npm i && tns build ios --bundle --env.uglify
1717
- language: android
1818
os: linux
1919
env:
2020
- WebPack="Android"
2121
jdk: oraclejdk8
2222
before_install: nvm install 6.10.3
23-
script: cd demo && npm run build.plugin && npm i && tns build android --bundle --env.uglify --env.snapshot
23+
script: cd demo && npm run build.plugin && npm i && tns build android --bundle --env.uglify --env.snapshot && cd ../demo-angular && tns build android --bundle --env.uglify --env.snapshot
2424
- language: android
2525
env:
2626
- BuildAndroid="26"
2727
os: linux
2828
jdk: oraclejdk8
2929
before_install: nvm install stable
3030
script:
31-
- cd src && npm i && npm run tsc && cd ../demo && tns build android
31+
- cd src && npm i && npm run tsc && cd ../demo && tns build android && cd ../demo-angular && tns build android
3232
- os: osx
3333
env:
3434
- BuildiOS="11"
@@ -38,25 +38,7 @@ matrix:
3838
node_js: "6"
3939
jdk: oraclejdk8
4040
script:
41-
- cd src && npm i && npm run tsc && cd ../demo && tns build ios
42-
- os: linux
43-
language: android
44-
dist: precise
45-
sudo: required
46-
jdk: oraclejdk8
47-
before_script:
48-
- echo no | android create avd --force -n test -t android-21 -b armeabi-v7a
49-
- emulator -avd test -no-audio -no-window &
50-
- android-wait-for-emulator
51-
before_install:
52-
- nvm install 6
53-
script: cd src && npm run test.android
54-
- os: osx
55-
language: node_js
56-
node_js: "6"
57-
jdk: oraclejdk8
58-
osx_image: xcode9.2
59-
script: cd src && npm run test.ios
41+
- cd src && npm i && npm run tsc && cd ../demo && tns build ios && cd ../demo-angular && tns build ios
6042

6143
android:
6244
components:

demo-angular/app/home/home.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export class HomeComponent {
6565
let task: bgHttp.Task;
6666
let lastEvent = "";
6767
if (isMulti) {
68-
var params = [
68+
const params = [
6969
{ name: "test", value: "value" },
7070
{ name: "fileToUpload", filename: this.file, mimeType: 'image/jpeg' }
7171
];

demo-angular/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
"version": "4.0.1"
1313
}
1414
},
15+
"scripts": {
16+
"build.plugin": "cd ../src && npm run build",
17+
"ci.tslint": "npm i && tslint --config '../tslint.json' 'app/**/*.ts' --exclude '**/node_modules/**'"
18+
},
1519
"dependencies": {
1620
"@angular/animations": "~5.2.0",
1721
"@angular/common": "~5.2.0",
@@ -28,6 +32,7 @@
2832
"reflect-metadata": "~0.1.10",
2933
"rxjs": "~5.5.5",
3034
"tns-core-modules": "4.0.0",
35+
"tns-platform-declarations": "^4.0.0",
3136
"zone.js": "~0.8.18"
3237
},
3338
"devDependencies": {
@@ -50,6 +55,7 @@
5055
"uglifyjs-webpack-plugin": "~1.1.6",
5156
"webpack": "~3.10.0",
5257
"webpack-bundle-analyzer": "^2.9.1",
58+
"tslint": "^5.0.0",
5359
"webpack-sources": "~1.1.0"
5460
}
5561
}

demo-angular/references.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/// <reference path="../src/node_modules/tns-platform-declarations/ios.d.ts" />
2+
/// <reference path="../src/node_modules/tns-platform-declarations/android.d.ts" />
3+
/// <reference path="../src/typings/java!uploadservice-3.4.2.ts" />

demo/app/home/home-view-model.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class HomeViewModel extends Observable {
1919
this.tasks = new ObservableArray<bghttp.Task>();
2020
this.events = new ObservableArray();
2121
this.counter = 0;
22-
this.file = fs.path.normalize(fs.knownFolders.currentApp().path + "/home/bigpic.jpg");;
22+
this.file = fs.path.normalize(fs.knownFolders.currentApp().path + "/home/bigpic.jpg");
2323
if (isIOS) {
2424
// NOTE: This works for emulator. Real device will need other address.
2525
this.url = "http://localhost:8080";
@@ -65,7 +65,7 @@ export class HomeViewModel extends Observable {
6565
let task: bghttp.Task;
6666
let lastEvent = "";
6767
if (isMulti) {
68-
var params = [
68+
const params = [
6969
{ name: "test", value: "value" },
7070
{ name: "fileToUpload", filename: this.file, mimeType: 'image/jpeg' }
7171
];

demo/package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,15 @@
1212
"version": "4.0.1"
1313
}
1414
},
15+
"scripts": {
16+
"build.plugin": "cd ../src && npm run build",
17+
"ci.tslint": "npm i && tslint --config '../tslint.json' 'app/**/*.ts' --exclude '**/node_modules/**'"
18+
},
1519
"dependencies": {
1620
"nativescript-background-http": "../src",
1721
"nativescript-theme-core": "~1.0.4",
18-
"tns-core-modules": "4.0.0"
22+
"tns-core-modules": "4.0.0",
23+
"tns-platform-declarations": "^4.0.0"
1924
},
2025
"devDependencies": {
2126
"awesome-typescript-loader": "~3.1.3",
@@ -36,6 +41,7 @@
3641
"uglifyjs-webpack-plugin": "~1.1.6",
3742
"webpack": "~3.10.0",
3843
"webpack-bundle-analyzer": "^2.9.1",
44+
"tslint": "^5.0.0",
3945
"webpack-sources": "~1.1.0"
4046
}
4147
}

demo/references.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/// <reference path="./node_modules/tns-platform-declarations/ios.d.ts" />
2+
/// <reference path="./node_modules/tns-platform-declarations/android.d.ts" />
3+
/// <reference path="../src/typings/java!uploadservice-3.4.2.ts" />

src/background-http.ios.ts

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ function onProgress(nsSession, nsTask, sent, expectedTotal) {
1111
const task = Task.getTask(nsSession, nsTask);
1212
task.notifyPropertyChange("upload", task.upload);
1313
task.notifyPropertyChange("totalUpload", task.totalUpload);
14-
task.notify({ eventName: "progress", object: task, currentBytes: sent, totalBytes: expectedTotal });
14+
task.notify(<common.ProgressEventData>{
15+
eventName: "progress",
16+
object: task,
17+
currentBytes: sent,
18+
totalBytes: expectedTotal
19+
});
1520
}
1621

1722
function onError(session, nsTask, error) {
@@ -22,12 +27,27 @@ function onError(session, nsTask, error) {
2227
}
2328
if (error) {
2429
task.notifyPropertyChange("status", task.status);
25-
task.notify({ eventName: "error", object: task, error: error });
30+
task.notify(<common.ErrorEventData>{
31+
eventName: "error",
32+
object: task,
33+
error,
34+
responseCode: nsTask && nsTask.response ? (<NSHTTPURLResponse>nsTask.response).statusCode : -1
35+
});
2636
} else {
2737
task.notifyPropertyChange("upload", task.upload);
2838
task.notifyPropertyChange("totalUpload", task.totalUpload);
29-
task.notify({ eventName: "progress", object: task, currentBytes: nsTask.countOfBytesSent, totalBytes: nsTask.countOfBytesExpectedToSend });
30-
task.notify({ eventName: "complete", object: task });
39+
task.notify(<common.ProgressEventData>{
40+
eventName: "progress",
41+
object: task,
42+
currentBytes: nsTask.countOfBytesSent,
43+
totalBytes: nsTask.countOfBytesExpectedToSend
44+
});
45+
task.notify(<common.CompleteEventData>{
46+
eventName: "complete",
47+
object: task,
48+
responseCode: nsTask && nsTask.response ? (<NSHTTPURLResponse>nsTask.response).statusCode : -1
49+
});
50+
3151
Task._tasks.delete(nsTask);
3252
}
3353
}
@@ -55,26 +75,9 @@ class BackgroundUploadDelegate extends NSObject implements NSURLSessionDelegate,
5575
}
5676

5777
// NSURLSessionTaskDelegate
58-
URLSessionTaskDidCompleteWithError(session, nsTask, error) {
78+
URLSessionTaskDidCompleteWithError(session: NSURLSession, nsTask: NSURLSessionTask, error: NSError) {
5979
dispatch_async(main_queue, () => {
6080
zonedOnError(session, nsTask, error);
61-
task.notify(<common.ErrorEventData>{
62-
eventName: "error",
63-
object: task,
64-
error,
65-
responseCode: nsTask && nsTask.response ? (<NSHTTPURLResponse>nsTask.response).statusCode : -1
66-
});
67-
task.notify(<common.ProgressEventData>{
68-
eventName: "progress",
69-
object: task,
70-
currentBytes: nsTask.countOfBytesSent,
71-
totalBytes: nsTask.countOfBytesExpectedToSend
72-
});
73-
task.notify(<common.CompleteEventData>{
74-
eventName: "complete",
75-
object: task,
76-
responseCode: nsTask && nsTask.response ? (<NSHTTPURLResponse>nsTask.response).statusCode : -1
77-
});
7881
});
7982
}
8083

@@ -88,12 +91,6 @@ class BackgroundUploadDelegate extends NSObject implements NSURLSessionDelegate,
8891
URLSessionTaskDidSendBodyDataTotalBytesSentTotalBytesExpectedToSend(nsSession: NSURLSession, nsTask: NSURLSessionTask, data, sent: number, expectedTotal: number) {
8992
dispatch_async(main_queue, () => {
9093
zonedOnProgress(nsSession, nsTask, sent, expectedTotal);
91-
task.notify(<common.ProgressEventData>{
92-
eventName: "progress",
93-
object: task,
94-
currentBytes: sent,
95-
totalBytes: expectedTotal
96-
});
9794
});
9895
}
9996

@@ -125,10 +122,10 @@ class BackgroundUploadDelegate extends NSObject implements NSURLSessionDelegate,
125122
const jsonString = NSString.alloc().initWithDataEncoding(data, NSUTF8StringEncoding);
126123

127124
jsTask.notify(<common.ResultEventData>{
128-
eventName: "responded",
129-
object: jsTask,
130-
data: jsonString.toString(),
131-
responseCode: dataTask && dataTask.response ? (<NSHTTPURLResponse>dataTask.response).statusCode : -1
125+
eventName: "responded",
126+
object: jsTask,
127+
data: jsonString.toString(),
128+
responseCode: dataTask && dataTask.response ? (<NSHTTPURLResponse>dataTask.response).statusCode : -1
132129
});
133130
});
134131
}
@@ -253,7 +250,7 @@ class Task extends Observable {
253250
public _fileToCleanup: string;
254251
private _task: NSURLSessionTask;
255252
private _session: NSURLSession;
256-
public testProp = 0;
253+
257254
constructor(nsSession: NSURLSession, nsTask: NSURLSessionTask) {
258255
super();
259256
this._task = nsTask;

src/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-background-http",
3-
"version": "3.2.5",
3+
"version": "3.2.5",
44
"main": "background-http",
55
"typings": "index.d.ts",
66
"nativescript": {

0 commit comments

Comments
 (0)