Skip to content

Commit 80a1776

Browse files
committed
Bumped version to 3.4.2
1 parent e7b1509 commit 80a1776

File tree

9 files changed

+183
-144
lines changed

9 files changed

+183
-144
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# v3.4.2 (22-12-2015)
2+
3+
- **Errors**: Added `code` and `moreInfo` and removed `message` and `type` to/from EVT.js errors.
4+
- **Callback API**: Added deprecation when callbacks are executed
5+
16
# v3.4.1 (14-12-2015)
27

38
## Changes

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ See [Usage](#usage) below for more details.
3434

3535
Add the script tag into your HTML page:
3636

37-
<script src="//cdn.evrythng.net/toolkit/evrythng-js-sdk/evrythng-3.4.1.min.js"></script>
37+
<script src="//cdn.evrythng.net/toolkit/evrythng-js-sdk/evrythng-3.4.2.min.js"></script>
3838

3939
Or always get the last release:
4040

@@ -43,7 +43,7 @@ Or always get the last release:
4343

4444
For HTTPS you need to use:
4545

46-
<script src="//d10ka0m22z5ju5.cloudfront.net/toolkit/evrythng-js-sdk/evrythng-3.4.1.min.js"></script>
46+
<script src="//d10ka0m22z5ju5.cloudfront.net/toolkit/evrythng-js-sdk/evrythng-3.4.2.min.js"></script>
4747
<script src="//d10ka0m22z5ju5.cloudfront.net/toolkit/evrythng-js-sdk/evrythng.js"></script>
4848
<script src="//d10ka0m22z5ju5.cloudfront.net/toolkit/evrythng-js-sdk/evrythng.min.js"></script>
4949

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "evrythng",
3-
"version": "3.4.1",
3+
"version": "3.4.2",
44
"main": "dist/evrythng.js",
55
"ignore": [
66
"**/.*",

dist/evrythng.js

Lines changed: 81 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// EVRYTHNG JS SDK v3.4.1
1+
// EVRYTHNG JS SDK v3.4.2
22
// (c) 2012-2015 EVRYTHNG Ltd. London / New York / San Francisco.
33
// Released under the Apache Software License, Version 2.0.
44
// For all details and usage:
@@ -990,7 +990,7 @@ define('core',[
990990
'use strict';
991991

992992
// Version is updated from package.json using `grunt-version` on build.
993-
var version = '3.4.1';
993+
var version = '3.4.2';
994994

995995

996996
// Setup default settings:
@@ -1090,24 +1090,30 @@ define('core',[
10901090
// that prefixes EvrythngJS's logs with a custom header.**
10911091

10921092
define('logger',[
1093-
'core'],
1094-
function (EVT) {
1093+
'core'
1094+
], function (EVT) {
10951095
'use strict';
10961096

10971097
var header = 'EvrythngJS';
10981098

10991099
return {
11001100

1101-
error: function(data){
1102-
if (EVT.settings.quiet === false){
1101+
error: function (data) {
1102+
if (EVT.settings.quiet === false) {
11031103
console.error(header + ' Error:', data);
11041104
}
11051105
},
11061106

1107-
info: function(data){
1108-
if (EVT.settings.quiet === false){
1107+
info: function (data) {
1108+
if (EVT.settings.quiet === false) {
11091109
console.info(header + ' Info:', data);
11101110
}
1111+
},
1112+
1113+
// TODO remove when callbacks deprecated
1114+
warnCallbackDeprecation: function () {
1115+
console.warn(header + ' Warning: Callbacks are deprecated, and are scheduled to be ' +
1116+
'removed in the next major release of the library. Please, use the Promise API instead.');
11111117
}
11121118

11131119
};
@@ -1141,10 +1147,10 @@ define('network/cors',[
11411147
// return *null*.
11421148
function _buildResponse(xhr, fullResponse) {
11431149
// XMLHttpRequest returns a not very usable single big string with all headers
1144-
var _parseHeaders = function(headers) {
1150+
var _parseHeaders = function (headers) {
11451151
var parsed = {};
11461152

1147-
if(headers){
1153+
if (headers) {
11481154
headers = headers.trim().split("\n");
11491155
for (var h in headers) {
11501156
var header = headers[h].toLowerCase().match(/([^:]+):(.*)/);
@@ -1188,23 +1194,13 @@ define('network/cors',[
11881194
return response;
11891195
}
11901196

1191-
// Helper method that builds a custom Error object providing some extra
1192-
// information on a request error.
1197+
// Forward EVRYTHNG API error and extend with URL and Method.
11931198
function _buildError(xhr, url, method, response) {
1194-
var errorData = {
1195-
status: xhr.status,
1196-
type: 'cors',
1197-
message: 'Server responded with an error for the CORS request',
1198-
url: url,
1199-
method: method
1200-
};
1199+
var errorData = response || {};
12011200

1202-
// Evrythng's API return an array of errors in the response. Add them
1203-
// if available.
1204-
if (response) {
1205-
errorData.errors = response.errors;
1206-
errorData.moreInfo = response.moreInfo;
1207-
}
1201+
errorData.status = xhr.status;
1202+
errorData.url = url;
1203+
errorData.method = method;
12081204

12091205
return errorData;
12101206
}
@@ -1217,8 +1213,8 @@ define('network/cors',[
12171213
xhr.open(method, url);
12181214

12191215
// Setup headers, including the *Authorization* that holds the Api Key.
1220-
for(var header in options.headers){
1221-
if(options.headers.hasOwnProperty(header)){
1216+
for (var header in options.headers) {
1217+
if (options.headers.hasOwnProperty(header)) {
12221218
xhr.setRequestHeader(header, options.headers[header]);
12231219
}
12241220
}
@@ -1252,36 +1248,20 @@ define('network/cors',[
12521248
// are callbacks execute them as well before resolving the promise.
12531249
return new Promise(function (resolve, reject) {
12541250

1255-
// Set protocol error handler.
1256-
xhr.onerror = function () {
1257-
// Could not execute request at all (destination unreachable, offline, ...?)
1258-
var ex = new Error('Network error.');
1259-
ex.name = 'CorsError';
1260-
reject(ex);
1261-
};
1262-
12631251
// Define internal error handler.
1264-
var errorHandler = function (response) {
1252+
function errorHandler(response) {
12651253
if (response) {
12661254
var errorData = _buildError(xhr, url, method, response);
12671255
Logger.error(errorData);
12681256

12691257
if (errorCallback) {
1258+
Logger.warnCallbackDeprecation();
12701259
errorCallback(errorData);
12711260
}
12721261
reject(errorData);
12731262
}
1274-
};
1275-
1276-
// Set timeout handler if needed.
1277-
if (options.timeout > 0) {
1278-
xhr.ontimeout = function () {
1279-
var timeoutResponse = {errors: ['Request timed out.']};
1280-
errorHandler(timeoutResponse);
1281-
};
12821263
}
12831264

1284-
12851265
// Define the response handler.
12861266
function handler() {
12871267
try {
@@ -1294,6 +1274,7 @@ define('network/cors',[
12941274
if (this.status >= 200 && this.status < 300) {
12951275

12961276
if (successCallback) {
1277+
Logger.warnCallbackDeprecation();
12971278
successCallback(response);
12981279
}
12991280
resolve(response);
@@ -1307,11 +1288,24 @@ define('network/cors',[
13071288
}
13081289
}
13091290

1291+
// Set timeout handler if needed.
1292+
if (options.timeout > 0) {
1293+
xhr.ontimeout = function () {
1294+
var timeoutErrResponse = {errors: ['Request timed out.']};
1295+
errorHandler(timeoutErrResponse);
1296+
};
1297+
}
1298+
1299+
// Could not execute request at all (destination unreachable, offline, ...?)
1300+
xhr.onerror = function () {
1301+
var networkErrResponse = {errors: ['Network error.']};
1302+
errorHandler(networkErrResponse);
1303+
};
1304+
13101305
// Send the request and wait for the response in the handler.
13111306
xhr.onreadystatechange = handler;
13121307

13131308
xhr.send(data);
1314-
13151309
});
13161310
}
13171311

@@ -1338,21 +1332,13 @@ define('network/jsonp',[
13381332
// Counter defines uniquely identified callbacks.
13391333
var counter = 0, head;
13401334

1341-
// Helper method that builds a custom Error object providing some extra
1342-
// information on a request error.
1343-
function _buildError(url, status, method, response){
1344-
var errorData = {
1345-
status: status,
1346-
type: 'jsonp',
1347-
message: 'Server responded with an error for the JSONP request',
1348-
url: url,
1349-
method: method
1350-
};
1335+
// Forward EVRYTHNG API error and extend with URL and Method.
1336+
function _buildError(url, status, method, response) {
1337+
var errorData = response || {};
13511338

1352-
if (response) {
1353-
errorData.errors = response.errors;
1354-
errorData.moreInfo = response.moreInfo;
1355-
}
1339+
errorData.status = status;
1340+
errorData.url = url;
1341+
errorData.method = method;
13561342

13571343
return errorData;
13581344
}
@@ -1423,12 +1409,18 @@ define('network/jsonp',[
14231409
var errorData = _buildError(url, response.status, params.method, response);
14241410
Logger.error(errorData);
14251411

1426-
if(errorCallback) { errorCallback(errorData); }
1412+
if(errorCallback) {
1413+
Logger.warnCallbackDeprecation();
1414+
errorCallback(errorData);
1415+
}
14271416
reject(errorData);
14281417

14291418
}else {
14301419

1431-
if(successCallback) { successCallback(response); }
1420+
if(successCallback) {
1421+
Logger.warnCallbackDeprecation();
1422+
successCallback(response);
1423+
}
14321424

14331425
try {
14341426
response = JSON.parse(response);
@@ -2867,8 +2859,9 @@ define('authentication',[
28672859
'core',
28682860
'promise',
28692861
'social/facebook',
2870-
'utils'
2871-
], function (EVT, Promise, Facebook, Utils) {
2862+
'utils',
2863+
'logger'
2864+
], function (EVT, Promise, Facebook, Utils, Logger) {
28722865
'use strict';
28732866

28742867
// Login into Evryhtng. This method is attached to the `EVT.App` API methods.
@@ -2963,7 +2956,10 @@ define('authentication',[
29632956
// In this case, we add Evrythng access data to this already wrapped response.
29642957
authFacebook.call($this, userResponse).then(function (fullResponse) {
29652958

2966-
if (successCallback) { successCallback(fullResponse);}
2959+
if (successCallback) {
2960+
Logger.warnCallbackDeprecation();
2961+
successCallback(fullResponse);
2962+
}
29672963
resolve(fullResponse);
29682964

29692965
});
@@ -2972,7 +2968,10 @@ define('authentication',[
29722968

29732969
// Login was not successful, apply *errorCb* and reject promise. Response
29742970
// has Facebook's *authResponse* and *status* objects.
2975-
if (errorCallback) { errorCallback(response); }
2971+
if (errorCallback) {
2972+
Logger.warnCallbackDeprecation();
2973+
errorCallback(response);
2974+
}
29762975
reject(response);
29772976

29782977
});
@@ -2995,13 +2994,19 @@ define('authentication',[
29952994

29962995
// Login was successful, apply callback and propagate response to the
29972996
// next promise handler.
2998-
if(successCallback) { successCallback(userResponse); }
2997+
if(successCallback) {
2998+
Logger.warnCallbackDeprecation();
2999+
successCallback(userResponse);
3000+
}
29993001
return userResponse;
30003002

30013003
}, function (response) {
30023004

30033005
// Login was not successful, call error callback and re-throw error.
3004-
if(errorCallback) { errorCallback(response); }
3006+
if(errorCallback) {
3007+
Logger.warnCallbackDeprecation();
3008+
errorCallback(response);
3009+
}
30053010
throw response;
30063011

30073012
});
@@ -3125,14 +3130,20 @@ define('authentication',[
31253130

31263131
}).then(function (response) {
31273132

3128-
if(successCallback) { successCallback(response); }
3133+
if(successCallback) {
3134+
Logger.warnCallbackDeprecation();
3135+
successCallback(response);
3136+
}
31293137
return response;
31303138

31313139
}, function (err) {
31323140

31333141
// If the logout from Evrythng fails, by some reason, throw error
31343142
// which would go to the promise error handler of the caller.
3135-
if(errorCallback) { errorCallback(err); }
3143+
if(errorCallback) {
3144+
Logger.warnCallbackDeprecation();
3145+
errorCallback(err);
3146+
}
31363147
throw err;
31373148

31383149
});

dist/evrythng.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/evrythng.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)