Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

leancloud-realtime

Package Overview
Dependencies
Maintainers
2
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

leancloud-realtime - npm Package Compare versions

Comparing version 3.0.0-beta.3 to 3.0.0-beta.4

.jsdocrc.json

2

bower.json
{
"name": "leancloud-realtime",
"version": "3.0.0-beta.3",
"version": "3.0.0-beta.4",
"homepage": "https://github.com/leancloud/js-realtime-sdk/",

@@ -5,0 +5,0 @@ "description": "LeanCloud JavaScript Realtime SDK",

@@ -0,1 +1,19 @@

<a name="3.0.0-beta.4"></a>
# 3.0.0-beta.4 (2016-05-30)
同时发布
- leancloud-realtime-typed-messages 1.0.0-beta.3
### Bug Fixes
* **Conversation:** 修复缓存中的 `Conversation` 有时被错误地更新为 `undefined` 的问题 ([91ae143](https://github.com/leancloud/js-realtime-sdk/commit/91ae143)),感谢 [@dangyuluo](https://github.com/dangyuluo)
* **ConversationQuery:** 废弃 `withLastMessages` 方法,请使用 `withLastMassagesRefreshed` 代替,两个 API 没有区别,重命名是为了避免误解 ([6afbd43](https://github.com/leancloud/js-realtime-sdk/commit/6afbd43))
* **FileMessage:** 修复 FileMessage 使用 avoscloud-sdk@^1.0.0-rc9 时的兼容性问题([6a2fd12](https://github.com/leancloud/js-realtime-sdk/commit/6a2fd12))
* **MessageIterator:** 修复对某次查询结果数据进行操作会影响下次查询结果的问题 ([ff899e0](https://github.com/leancloud/js-realtime-sdk/commit/ff899e0)),感谢 [@dangyuluo](https://github.com/dangyuluo)
* **Realtime:** 修复了在收到某些消息时抛出 `unhandled promise rejection` 异常的问题 ([e68e87d](https://github.com/leancloud/js-realtime-sdk/commit/e68e87d)),感谢 [@han4wluc](https://github.com/han4wluc)
* **TypedMessages:** 修复了 leancloud-realtime-typed-messages 不支持 AMD loaders 的问题 ([dd82fb8](https://github.com/leancloud/js-realtime-sdk/commit/dd82fb8))
* **WebSocketPlus:** 当连接不可用时,调用部分 API 抛出更加有指导意义的异常与提示 ([4b3c841](https://github.com/leancloud/js-realtime-sdk/commit/4b3c841)),感谢 [@han4wluc](https://github.com/han4wluc)
<a name="3.0.0-beta.3"></a>

@@ -2,0 +20,0 @@ # 3.0.0-beta.3 (2016-05-16)

/* eslint-disable */
var path = require('path');
var fs = require('fs');
module.exports = function(grunt) {

@@ -8,3 +11,2 @@ require('load-grunt-tasks')(grunt);

var commonjs = require('rollup-plugin-commonjs');
var istanbul = require('rollup-plugin-istanbul');

@@ -37,4 +39,3 @@ var env = function () {

// browserName: 'firefox',
// version: 'beta'
//}, {
// }, {
browserName: 'iPhone',

@@ -49,2 +50,10 @@ version: '8.0'

var babelrc = JSON.parse(fs.readFileSync('./.babelrc'));
var babelConfigs = Object.assign(babelrc, {
plugins: babelrc.plugins,
presets: [ 'es2015-rollup' ],
babelrc: false,
runtimeHelpers: true,
});
grunt.initConfig({

@@ -61,10 +70,6 @@ rollup: {

json(),
babel({ runtimeHelpers: true , exclude: 'node_modules/**' }),
//nodeResolve({
// jsnext: true,
// main: true,
// skip: ['memcpy'],
//}),
babel(Object.assign({}, babelConfigs, {
exclude: 'node_modules/**',
})),
commonjs({
//include: ['node_modules/**', 'proto/**'],
include: ['proto/**'],

@@ -83,3 +88,2 @@ })

nodeResolve({
jsnext: true,
main: true,

@@ -92,37 +96,12 @@ browser: true

}),
babel({ runtimeHelpers: true , include: ['src/**', 'test/**', 'proto/**', 'node_modules/axios/**'] }),
babel(Object.assign({}, babelConfigs, {
include: ['src/**', 'test/**', 'proto/**', 'node_modules/axios/**'],
})),
env(),
],
format: 'umd',
moduleName: 'AV'
moduleName: 'AV',
moduleId: 'leancloud-realtime',
}
},
test: {
dest: 'test/index.bundle.js',
src: 'test/index-with-typed-messages.js',
options: {
plugins: [
istanbul({
exclude: [
'test/*.js',
'proto/*.js',
'typed-messages/test/*.js',
'typed-messages/src/index.js',
'*.json',
],
instrumenter: require('istanbul'),
instrumenterConfig: {
esModules: true,
noCompact: true,
}
}),
json(),
babel({ runtimeHelpers: true , exclude: 'node_modules/**' }),
commonjs({
include: ['proto/**'],
}),
],
format: 'cjs'
}
},
'test-browser': {

@@ -135,3 +114,2 @@ dest: 'test/browser/index.js',

nodeResolve({
jsnext: true,
main: true,

@@ -144,3 +122,5 @@ browser: true

}),
babel({ runtimeHelpers: true , include: ['src/**', 'test/**', 'proto/**', 'node_modules/axios/**'] }),
babel(Object.assign({}, babelConfigs, {
include: ['src/**', 'test/**', 'proto/**', 'node_modules/axios/**'],
})),
env()

@@ -157,3 +137,7 @@ ],

plugins: [
babel({ exclude: 'node_modules/**' }),
babel({
presets: [ 'es2015-rollup' ],
babelrc: false,
exclude: 'node_modules/**',
}),
nodeResolve({

@@ -167,3 +151,9 @@ main: true,

format: 'umd',
moduleName: 'AV'
moduleName: 'AV',
moduleId: 'typed-messages',
external: ['leancloud-realtime', 'avoscloud-sdk'],
globals: {
'leancloud-realtime': 'AV',
'avoscloud-sdk': 'AV',
},
}

@@ -190,13 +180,2 @@ }

},
mochaTest: {
options: {
timeout: 30000,
},
src: ['test/index.bundle.js']
},
storeCoverage: {
options: {
dir: 'coverage'
}
},
connect: {

@@ -210,11 +189,2 @@ server: {

},
'mocha_phantomjs': {
all: {
options: {
urls: [
'http://localhost:8000/test/browser/'
]
}
}
},
'saucelabs-mocha': {

@@ -236,13 +206,14 @@ all: {

grunt.registerTask('default', []);
grunt.registerTask('build-test', ['build', 'rollup:test', 'rollup:test-browser', 'envify:test-browser']);
grunt.registerTask('test', '', function() {
var tasks = ['build-test', 'validate-es5', /*'mocha_phantomjs',*/ 'mochaTest', 'storeCoverage'];
grunt.registerTask('build-test', ['rollup:test-browser', 'envify:test-browser']);
grunt.registerTask('test-browser', '', function() {
var tasks = ['build-test'];
if (process.env.SAUCE_USERNAME && process.env.SAUCE_ACCESS_KEY) {
tasks = tasks.concat(['connect', 'saucelabs-mocha']);
} else {
grunt.log.writeln('Skip saucelabs test, set SAUCE_USERNAME and SAUCE_ACCESS_KEY to start it.');
grunt.log.writeln('Saucelabs test skipped, set SAUCE_USERNAME and SAUCE_ACCESS_KEY to start it.');
grunt.log.writeln('To run browser tests locally, start a static server then run ./test/browser/');
}
grunt.task.run(tasks);
});
grunt.registerTask('build', ['rollup:dist-browser', 'rollup:dist', 'uglify:browser', 'rollup:messages']);
grunt.registerTask('build', ['rollup:dist-browser', 'rollup:dist', 'uglify:browser', 'rollup:messages', 'validate-es5']);
grunt.registerTask('cdn', 'Upload dist to CDN.', function() {

@@ -260,4 +231,2 @@

var qiniu = require('qiniu');
var path = require('path');
var fs = require('fs');

@@ -264,0 +233,0 @@ qiniu.conf.ACCESS_KEY = process.env.CDN_QINIU_KEY;

{
"name": "leancloud-realtime",
"version": "3.0.0-beta.3",
"version": "3.0.0-beta.4",
"description": "LeanCloud Realtime Message JavaScript SDK",

@@ -12,5 +12,6 @@ "main": "dist/realtime.js",

"lint": "eslint --ignore-path .gitignore src test typed-messages",
"test": "npm run lint && grunt test --stack && npm run report",
"report": "istanbul report --include coverage/coverage.json --print text lcovonly",
"doc": "jsdoc src typed-messages/src README.md -r -d docs -t node_modules/docdash",
"test": "npm run lint && npm run build && npm run doc && npm run test:node && npm run test:browser",
"test:node": "babel-node ./node_modules/isparta/bin/isparta cover --include 'src/**' --include 'typed-messages/src/**' --report text ./node_modules/mocha/bin/_mocha -- test/index.js typed-messages/test/index.js --timeout 30000",
"test:browser": "grunt test-browser --stack",
"doc": "jsdoc src typed-messages/src README.md -r -d docs -c .jsdocrc.json",
"build": "grunt build --stack",

@@ -35,3 +36,4 @@ "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",

"devDependencies": {
"avoscloud-sdk": "1.0.0-rc8",
"avoscloud-sdk": "1.0.0-rc9",
"babel-cli": "^6.9.0",
"babel-eslint": "^6.0.0",

@@ -41,2 +43,3 @@ "babel-plugin-transform-decorators-legacy": "^1.3.4",

"babel-plugin-transform-runtime": "^6.6.0",
"babel-preset-es2015": "^6.9.0",
"babel-preset-es2015-rollup": "^1.1.1",

@@ -53,11 +56,9 @@ "conventional-changelog-cli": "^1.1.1",

"grunt-contrib-uglify": "^1.0.0",
"grunt-env": "^0.4.4",
"grunt-envify": "0.0.3",
"grunt-istanbul": "^0.7.0",
"grunt-mocha-test": "^0.12.7",
"grunt-rollup": "^0.7.0",
"grunt-saucelabs": "^8.6.1",
"inherit": "^2.2.3",
"istanbul": "git+https://github.com/Victorystick/istanbul.git#es-modules-support",
"isparta": "^4.0.0",
"jsdoc": "^3.4.0",
"jsdoc-ignore-future": "^1.1.0",
"load-grunt-tasks": "^3.4.1",

@@ -69,3 +70,2 @@ "mocha": "^2.3.4",

"rollup-plugin-commonjs": "^2.2.1",
"rollup-plugin-istanbul": "^1.0.0",
"rollup-plugin-json": "^2.0.0",

@@ -72,0 +72,0 @@ "rollup-plugin-node-resolve": "^1.4.0",

@@ -134,3 +134,3 @@ LeanCloud JavaScript Realtime SDK

```
npm test
npm run test:node -- --grep KEYWORDS
```

@@ -141,3 +141,3 @@ 浏览器测试

# static . -p 8000
grunt build-test
npm run test:browser
# open http://localhost:8000/test/browser/

@@ -144,0 +144,0 @@ ```

@@ -21,3 +21,3 @@ import { default as d } from 'debug';

return [
'withLastMessages',
'withLastMessagesRefreshed',
'compact',

@@ -327,8 +327,8 @@ ].reduce(

/**
* 设置返回的 conversations 带上最后一条消息
* @param {Boolean} enabled
* 设置返回的 conversations 刷新最后一条消息
* @param {Boolean} [enabled=true]
* @return {ConversationQuery} self
*/
withLastMessages(enabled) {
this._extraOptions.withLastMessages = enabled;
withLastMessagesRefreshed(enabled = true) {
this._extraOptions.withLastMessagesRefreshed = enabled;
return this;

@@ -338,7 +338,18 @@ }

/**
* @deprecated 请替换为 {@link ConversationQuery#withLastMessagesRefreshed}
* @param {Boolean} [enabled=true]
* @return {ConversationQuery} self
*/
withLastMessages(enabled) {
console.warn('DEPRECATION ConversationQuery#withLastMessages: ' +
'Use ConversationQuery#withLastMessagesRefreshed instead.');
return this.withLastMessagesRefreshed(enabled);
}
/**
* 设置返回的 conversations 为精简模式,即不含成员列表
* @param {Boolean} enabled
* @param {Boolean} [enabled=true]
* @return {ConversationQuery} self
*/
compact(enabled) {
compact(enabled = true) {
this._extraOptions.compact = enabled;

@@ -345,0 +356,0 @@ return this;

@@ -579,3 +579,3 @@ import EventEmitter from 'eventemitter3';

return promise.then(value => ({
value,
value: Array.from(value),
done: value.length === 0 || value.length < limit,

@@ -582,0 +582,0 @@ }));

@@ -121,23 +121,27 @@ import Client from './client';

const convs = message.unreadMessage.convs;
convs.forEach(conv => this.getConversation(conv.cid).then(conversation => {
let timestamp;
if (conv.timestamp) {
timestamp = new Date(conv.timestamp.toNumber());
}
conversation.unreadMessagesCount = conv.unread; // eslint-disable-line no-param-reassign
/**
* 未读消息数目更新
* @event IMClient#unreadmessages
* @param {Object} payload
* @param {Number} payload.count 未读消息数
* @param {String} [payload.lastMessageId] 最新一条未读消息 id
* @param {String} [payload.lastMessageTimestamp] 最新一条未读消息时间戳
* @param {Conversation} conversation 未读消息数目有更新的对话
*/
this.emit('unreadmessages', {
count: conv.unread,
lastMessageId: conv.mid,
lastMessageTimestamp: timestamp,
}, conversation);
}));
return Promise.all(convs.map(
conv => this
.getConversation(conv.cid)
.then(conversation => {
let timestamp;
if (conv.timestamp) {
timestamp = new Date(conv.timestamp.toNumber());
}
conversation.unreadMessagesCount = conv.unread; // eslint-disable-line no-param-reassign
/**
* 未读消息数目更新
* @event IMClient#unreadmessages
* @param {Object} payload
* @param {Number} payload.count 未读消息数
* @param {String} [payload.lastMessageId] 最新一条未读消息 id
* @param {String} [payload.lastMessageTimestamp] 最新一条未读消息时间戳
* @param {Conversation} conversation 未读消息数目有更新的对话
*/
this.emit('unreadmessages', {
count: conv.unread,
lastMessageId: conv.mid,
lastMessageTimestamp: timestamp,
}, conversation);
})
));
}

@@ -510,3 +514,3 @@

const value = fetchedConversation[key];
if (value !== null) conversation[key] = value;
if (value !== undefined) conversation[key] = value;
});

@@ -513,0 +517,0 @@ delete conversation._pendingAttributes;

import TypedMessage from './typed-message';
import { messageType } from './helpers';
// jsdoc-ignore-start
@messageType(-1)
// jsdoc-ignore-end
export default class TextMessage extends TypedMessage {

@@ -27,2 +30,1 @@ /**

*/
messageType(-1)(TextMessage);
import Message from './message';
import { messageField } from './helpers';
// jsdoc-ignore-start
@messageField(['_lctext', '_lcattrs'])
// jsdoc-ignore-end
export default class TypedMessage extends Message {

@@ -113,3 +116,1 @@ /**

}
messageField(['_lctext', '_lcattrs'])(TypedMessage);

@@ -18,2 +18,17 @@ // WebSocket with auto reconnecting feature, backup endpoint and EventEmitter interface.

const requireConnected = (target, name, descriptor) =>
Object.assign({}, descriptor, {
value: function requireConnectedWrapper(...args) {
if (!this.is('connected')) {
const currentState = this.current;
console.warn(`${name} should not be called when the connection is ${currentState}`);
if (this.is('offline') || this.is('reconnecting')) {
console.warn('disconnect and reconnect event should be handled to avoid such calls.');
}
throw new Error('Connection unavailable');
}
return descriptor.value.call(this, ...args);
},
});
class WebSocketPlus extends EventEmitter {

@@ -122,3 +137,5 @@ constructor(getUrls, protocol) {

debug('close');
this._ws.close();
if (this._ws) {
this._ws.close();
}
}

@@ -130,2 +147,13 @@ onerror(event, from, to, error) {

// jsdoc-ignore-start
@requireConnected
// jsdoc-ignore-end
_ping() {
debug('ping');
try {
this.ping();
} catch (error) {
console.warn(`websocket ping error: ${error.message}`);
}
}
ping() {

@@ -143,6 +171,3 @@ if (this._ws.ping) {

this._clearTimers();
this._heartbeatTimer = setInterval(() => {
debug('ping');
this.ping();
}, HEARTBEAT_TIME);
this._heartbeatTimer = setInterval(this._ping.bind(this), HEARTBEAT_TIME);
this._timeoutTimer = setTimeout(() => {

@@ -186,2 +211,5 @@ debug('timeout');

// jsdoc-ignore-start
@requireConnected
// jsdoc-ignore-end
send(data) {

@@ -188,0 +216,0 @@ debug('send', data);

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc