Skip to content

Commit c7661dc

Browse files
committed
Released 1.0.0-rc3
1 parent d7b68f0 commit c7661dc

File tree

9 files changed

+178
-131
lines changed

9 files changed

+178
-131
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ JavaScript SDK for [LeanCloud](http://leancloud.cn/).
44

55
## 使用方法请看 [官方文档](http://leancloud.cn/docs/js_guide.html)
66

7+
## 版本说明
8+
9+
* 0.x.y 版本,是不兼容 React Native 运行时的老版本 SDK,相对稳定,云引擎主要依赖这个分支版本。
10+
* 1.0.0-x 版本,是我们最新开发的兼容 React Native 运行时的版本,处于开放测试阶段,欢迎大家尝试。我们最终将使用这个分支替代云引擎里的 `0.x.y` 版本。
11+
712
## 贡献
813

914
* fork 这个项目

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "leancloud-jssdk.js",
3-
"version": "1.0.0-rc2",
3+
"version": "1.0.0-rc3",
44
"homepage": "https://github.com/leancloud/javascript-sdk",
55
"authors": [
66
"killme2008 <[email protected]>"

changelog.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
# 1.0.0-rc3 日期:2015 年 10 月 27 日
2+
* 修复 `AV._request` 某些情况下无法正常工作的 Bug。
3+
* 修复某些登录 API 没有更新 currentUser 的问题
4+
* 修复 localStorage 没有生效的 Bug,感谢热心用户反馈。
5+
* AV.SearchQuery 增加 hasMore 和 reset 方法。
6+
7+
# 0.6.4 日期:2015 年 10 月 27 日
8+
* 修复 localStorage 没有生效的 Bug,感谢热心用户反馈。
9+
* AV.SearchQuery 增加 hasMore 和 reset 方法。
10+
111
# 1.0.0-rc2 日期:215 年 10 月 22 日
212
* 兼容 React Native 运行环境。
313
* 修复 AV.Role 的兼容性问题。

dist/av-core-mini.js

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

dist/av-core.js

Lines changed: 76 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ if (global.localStorage) {
359359
if (localStorage.getItem(testKey) != testKey) {
360360
throw new Error();
361361
}
362-
localStorage.remove(testKey);
362+
localStorage.removeItem(testKey);
363363
} catch (e) {
364364
localStorage = require('localstorage-memory');
365365
}
@@ -436,11 +436,9 @@ module.exports = function upload(file, AV, saveOptions) {
436436

437437
var xhr = new AV.XMLHttpRequest();
438438

439-
xhr.upload.addEventListener('progress', function(e) {
440-
if (e.lengthComputable) {
441-
saveOptions.onProgress && saveOptions.onProgress(e);
442-
}
443-
}, false);
439+
if (xhr.upload) {
440+
xhr.upload.onprogress = saveOptions.onProgress;
441+
}
444442

445443
xhr.onreadystatechange = function() {
446444
if (xhr.readyState === 4) {
@@ -4184,7 +4182,7 @@ _.extend(Promise, /** @lends AV.Promise */ {
41844182
*/
41854183
as: function() {
41864184
var promise = new Promise();
4187-
if (_.isFunction(arguments[0])) {
4185+
if (arguments[0] && _.isFunction(arguments[0].then)) {
41884186
arguments[0].then(function(data) {
41894187
promise.resolve.call(promise, data);
41904188
}, function(err) {
@@ -5860,12 +5858,14 @@ module.exports = function(AV) {
58605858
if (acl === undefined) {
58615859
var defaultAcl = new AV.ACL();
58625860
defaultAcl.setPublicReadAccess(true);
5863-
acl = defaultAcl;
5864-
}
5865-
if (!(acl instanceof AV.ACL)) {
5861+
if(!this.getACL()) {
5862+
this.setACL(defaultAcl);
5863+
}
5864+
} else if (!(acl instanceof AV.ACL)) {
58665865
throw new TypeError('acl must be an instance of AV.ACL');
5866+
} else {
5867+
this.setACL(acl);
58675868
}
5868-
this.setACL(acl);
58695869
},
58705870

58715871
/**
@@ -6157,6 +6157,26 @@ module.exports = function(AV) {
61576157
return json;
61586158
},
61596159

6160+
/**
6161+
* Returns true when there are more documents can be retrieved by this
6162+
* query instance, you can call find function to get more results.
6163+
* @see AV.SearchQuery#find
6164+
* @return {Boolean}
6165+
*/
6166+
hasMore: function() {
6167+
return !this._hitEnd;
6168+
},
6169+
6170+
/**
6171+
* Reset current query instance state(such as sid, hits etc) except params
6172+
* for a new searching. After resetting, hasMore() will return true.
6173+
*/
6174+
reset: function() {
6175+
this._hitEnd = false;
6176+
this._sid = null;
6177+
this._hits = 0;
6178+
},
6179+
61606180
/**
61616181
* Retrieves a list of AVObjects that satisfy this query.
61626182
* Either options.success or options.error is called when the find
@@ -6177,6 +6197,9 @@ module.exports = function(AV) {
61776197
if(response.sid) {
61786198
self._oldSid = self._sid;
61796199
self._sid = response.sid;
6200+
} else {
6201+
self._sid = null;
6202+
self._hitEnd = true;
61806203
}
61816204
self._hits = response.hits || 0;
61826205

@@ -6727,17 +6750,12 @@ module.exports = function(AV) {
67276750
var authData = this.get('authData') || {};
67286751
authData[authType] = options.authData;
67296752
this.set('authData', authData);
6730-
6731-
// Overridden so that the user can be made the current user.
6732-
var newOptions = _.clone(options) || {};
6733-
newOptions.success = function(model) {
6734-
model._handleSaveResult(true).then(function() {
6735-
if (options.success) {
6736-
options.success.apply(this, arguments);
6737-
}
6738-
});
6739-
};
6740-
return this.save({'authData': authData}, newOptions);
6753+
return this.save({'authData': authData}, filterOutCallbacks(options))
6754+
.then(function(model) {
6755+
return model._handleSaveResult(true).then(function() {
6756+
return model;
6757+
});
6758+
})._thenRunCallbacks(options);
67416759
} else {
67426760
var self = this;
67436761
var promise = new AV.Promise();
@@ -6871,7 +6889,7 @@ module.exports = function(AV) {
68716889
return AV.Promise.error(error);
68726890
}
68736891

6874-
return this.save(attrs).then(function(model) {
6892+
return this.save(attrs, filterOutCallbacks(options)).then(function(model) {
68756893
return model._handleSaveResult(true).then(function() {
68766894
return model;
68776895
});
@@ -6925,21 +6943,17 @@ module.exports = function(AV) {
69256943
return AV.Promise.error(error);
69266944
}
69276945

6928-
// Overridden so that the user can be made the current user.
6929-
var newOptions = _.clone(options);
6946+
var newOptions = filterOutCallbacks(options);
69306947
newOptions._makeRequest = function(route, className, id, method, json) {
69316948
return AV._request('usersByMobilePhone', null, null, "POST", json);
69326949
};
6933-
newOptions.success = function(model) {
6934-
model._handleSaveResult(true).then(function() {
6935-
delete model.attributes.smsCode;
6936-
delete model._serverData.smsCode;
6937-
if (options.success) {
6938-
options.success.apply(this, arguments);
6939-
}
6950+
return this.save(attrs, newOptions).then(function(model) {
6951+
delete model.attributes.smsCode;
6952+
delete model._serverData.smsCode;
6953+
return model._handleSaveResult(true).then(function() {
6954+
return model;
69406955
});
6941-
};
6942-
return this.save(attrs, newOptions);
6956+
})._thenRunCallbacks(options);
69436957
},
69446958

69456959
/**
@@ -6985,15 +6999,13 @@ module.exports = function(AV) {
69856999
}
69867000
options = options || {};
69877001

6988-
var newOptions = _.clone(options);
6989-
newOptions.success = function(model) {
6990-
model._handleSaveResult(false).then(function() {
6991-
if (options.success) {
6992-
options.success.apply(this, arguments);
6993-
}
6994-
});
6995-
};
6996-
return AV.Object.prototype.save.call(this, attrs, newOptions);
7002+
return AV.Object.prototype.save
7003+
.call(this, attrs, filterOutCallbacks(options))
7004+
.then(function(model) {
7005+
return model._handleSaveResult(false).then(function() {
7006+
return model;
7007+
});
7008+
})._thenRunCallbacks(options);
69977009
},
69987010

69997011
/**
@@ -7066,15 +7078,12 @@ module.exports = function(AV) {
70667078
* @see AV.Object#fetch
70677079
*/
70687080
fetch: function(options) {
7069-
var newOptions = options ? _.clone(options) : {};
7070-
newOptions.success = function(model) {
7071-
model._handleSaveResult(false).then(function() {
7072-
if (options && options.success) {
7073-
options.success.apply(this, arguments);
7074-
}
7075-
});
7076-
};
7077-
return AV.Object.prototype.fetch.call(this, newOptions);
7081+
return AV.Object.prototype.fetch.call(this, filterOutCallbacks(options))
7082+
.then(function(model) {
7083+
return model._handleSaveResult(false).then(function() {
7084+
return model;
7085+
});
7086+
})._thenRunCallbacks(options);
70787087
},
70797088

70807089
/**
@@ -7652,6 +7661,13 @@ module.exports = function(AV) {
76527661
});
76537662
};
76547663

7664+
function filterOutCallbacks(options) {
7665+
var newOptions = _.clone(options) || {};
7666+
delete newOptions.success;
7667+
delete newOptions.error;
7668+
return newOptions;
7669+
}
7670+
76557671
},{"underscore":30}],25:[function(require,module,exports){
76567672
(function (process){
76577673
'use strict';
@@ -8071,14 +8087,14 @@ module.exports = function(AV) {
80718087
dataObject._MasterKey = AV.masterKey;
80728088
dataObject._ClientVersion = AV.VERSION;
80738089
// Pass the session token on every request.
8074-
var currentUser = AV.User.current();
8075-
if (currentUser && currentUser._sessionToken) {
8076-
dataObject._SessionToken = currentUser._sessionToken;
8077-
}
8078-
8079-
return AV._getInstallationId().then(function(_InstallationId) {
8090+
return AV.User.currentAsync().then(function(currentUser) {
8091+
if (currentUser && currentUser._sessionToken) {
8092+
dataObject._SessionToken = currentUser._sessionToken;
8093+
}
8094+
return AV._getInstallationId();
8095+
}).then(function(_InstallationId) {
80808096
dataObject._InstallationId = _InstallationId;
8081-
}).then(function() {
8097+
80828098
var data = JSON.stringify(dataObject);
80838099
return AV._ajax(method, url, data).then(null, function(response) {
80848100
// Transform the error into an instance of AV.Error by trying to parse
@@ -8335,7 +8351,7 @@ module.exports = function(AV) {
83358351
},{"_process":28,"underscore":30}],26:[function(require,module,exports){
83368352
'use strict';
83378353

8338-
module.exports = "js1.0.0-rc2";
8354+
module.exports = "js1.0.0-rc3";
83398355

83408356
},{}],27:[function(require,module,exports){
83418357

dist/av-mini.js

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

0 commit comments

Comments
 (0)