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.2 to 3.0.0-beta.3

2

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

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

@@ -0,1 +1,21 @@

<a name="3.0.0-beta.3"></a>
# 3.0.0-beta.3 (2016-05-16)
同时发布
- leancloud-realtime-typed-messages 1.0.0-beta.2
### Bug Fixes
* **Bundle:** 修复与 AMD loaders (require.js) 一起使用报错的问题 ([8ae8093](https://github.com/leancloud/js-realtime-sdk/commit/8ae8093))
* **Realtime:** 修复了误报跨域的问题 ([#225](https://github.com/leancloud/js-realtime-sdk/issues/225)) ([1e7d0ef](https://github.com/leancloud/js-realtime-sdk/commit/1e7d0ef))
* **FileMessage:** 增强了 FileMessage 对非标准消息的兼容 ([e86d4c4](https://github.com/leancloud/js-realtime-sdk/commit/e86d4c4))
* **TypedMessages:** 修复 leancloud-realtime-typed-messages 在不支持 ES6 语法的浏览器上报错的问题 ([abcfbd7](https://github.com/leancloud/js-realtime-sdk/commit/abcfbd7))
### Features
* **Realtime:** 支持动态路由 ([9b753c6](https://github.com/leancloud/js-realtime-sdk/commit/9b753c6))
<a name="3.0.0-beta.2"></a>

@@ -2,0 +22,0 @@ # [3.0.0-beta.2](https://github.com/leancloud/js-realtime-sdk/compare/v3.0.0-beta.1...v3.0.0-beta.2) (2016-05-07)

@@ -15,3 +15,3 @@ /* eslint-disable */

return `
window.process = window.process || {};
var process = window.process || {};
process.env = process.env || {};`;

@@ -28,2 +28,3 @@ }

this;
var define = undefined;
var require = require || function(id) {throw new Error('Unexpected required ' + id)};

@@ -48,21 +49,3 @@ `;

var HINT_SRCS = [
'**/src/**/*.js',
'**/test/**/*.js',
'!gh_pages/**/*',
'!**/browser/**/*.js',
'!**/*.browser.js',
'!**/*.bundle.js',
];
grunt.initConfig({
watch: {
scripts: {
files: HINT_SRCS,
tasks: ['build-test', 'release']
},
},
eslint: {
target: HINT_SRCS
},
rollup: {

@@ -98,3 +81,2 @@ options: {

json(),
babel({ runtimeHelpers: true , exclude: 'node_modules/**' }),
nodeResolve({

@@ -108,3 +90,5 @@ jsnext: true,

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

@@ -126,4 +110,2 @@ format: 'umd',

'typed-messages/src/index.js',
'typed-messages/src/file.js',
'typed-messages/src/realtime.js',
'*.json',

@@ -152,3 +134,2 @@ ],

json(),
babel({ runtimeHelpers: true , exclude: 'node_modules/**' }),
nodeResolve({

@@ -163,2 +144,3 @@ jsnext: true,

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

@@ -175,3 +157,3 @@ ],

plugins: [
// babel({ runtimeHelpers: true , exclude: 'node_modules/**' }),
babel({ exclude: 'node_modules/**' }),
nodeResolve({

@@ -251,6 +233,5 @@ main: true,

grunt.registerTask('default', []);
grunt.registerTask('lint', ['eslint']);
grunt.registerTask('build-test', ['build', 'rollup:test', 'rollup:test-browser', 'envify:test-browser']);
grunt.registerTask('test', '', function() {
var tasks = ['build-test', /*'mocha_phantomjs',*/ 'mochaTest', 'storeCoverage'];
var tasks = ['build-test', 'validate-es5', /*'mocha_phantomjs',*/ 'mochaTest', 'storeCoverage'];
if (process.env.SAUCE_USERNAME && process.env.SAUCE_ACCESS_KEY) {

@@ -264,3 +245,2 @@ tasks = tasks.concat(['connect', 'saucelabs-mocha']);

grunt.registerTask('build', ['rollup:dist-browser', 'rollup:dist', 'uglify:browser', 'rollup:messages']);
grunt.registerTask('dev', ['build-test', 'release', 'connect', 'watch']);
grunt.registerTask('cdn', 'Upload dist to CDN.', function() {

@@ -303,2 +283,16 @@

var espree = require('espree');
grunt.registerTask('validate-es5', 'validate es5', function() {
[
'./typed-messages/dist/typed-messages.js',
'./dist/realtime.browser.js'
].forEach(file => {
grunt.log.write('validate ' + file + ' ');
var code = fs.readFileSync(file);
espree.parse(code, {
ecmaVersion: 5,
});
grunt.log.ok();
})
});
};
{
"name": "leancloud-realtime",
"version": "3.0.0-beta.2",
"version": "3.0.0-beta.3",
"description": "LeanCloud Realtime Message JavaScript SDK",

@@ -11,4 +11,4 @@ "main": "dist/realtime.js",

"scripts": {
"dev": "grunt dev",
"test": "grunt lint test --stack && npm run report",
"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",

@@ -43,4 +43,6 @@ "doc": "jsdoc src typed-messages/src README.md -r -d docs -t node_modules/docdash",

"docdash": "^0.3.0",
"eslint-config-airbnb-base": "^2.0.0",
"eslint": "^2.10.0",
"eslint-config-airbnb-base": "^3.0.1",
"eslint-plugin-import": "^1.5.0",
"espree": "^3.1.4",
"ghooks": "^1.1.0",

@@ -50,6 +52,4 @@ "grunt": "^1.0.1",

"grunt-contrib-uglify": "^1.0.0",
"grunt-contrib-watch": "^1.0.0",
"grunt-env": "^0.4.4",
"grunt-envify": "0.0.3",
"grunt-eslint": "^18.0.0",
"grunt-istanbul": "^0.7.0",

@@ -77,2 +77,3 @@ "grunt-mocha-test": "^0.12.7",

"dependencies": {
"axios": "^0.11.0",
"babel-runtime": "^6.6.1",

@@ -84,4 +85,2 @@ "debug": "^2.2.0",

"protobufjs": "^5.0.1",
"superagent": "~1.7",
"superagent-promise": "^1.1.0",
"uuid": "^2.0.1",

@@ -88,0 +87,0 @@ "ws": "^1.1.0"

@@ -128,5 +128,2 @@ LeanCloud JavaScript Realtime SDK

### 本地开发
```
grunt dev
```
更新 .proto 后请运行

@@ -136,6 +133,13 @@ ```

```
### 测试
测试
```
npm test
```
浏览器测试
```
# 在当前目录启动一个静态 server
# static . -p 8000
grunt build-test
# open http://localhost:8000/test/browser/
```
生成 dist/realtime.*

@@ -142,0 +146,0 @@ ```

@@ -0,1 +1,2 @@

// eslint-disable-next-line no-native-reassign
export default WebSocket = global.WebSocket || global.MozWebSocket;

@@ -5,4 +5,3 @@ import Connection from './connection';

import EventEmitter from 'eventemitter3';
import { default as superagentPromise } from 'superagent-promise';
import superagent from 'superagent';
import axios from 'axios';
import uuid from 'uuid';

@@ -16,5 +15,6 @@ import { tap, Cache, trim, internal } from './utils';

const agent = superagentPromise(superagent, Promise);
const debug = d('LC:Realtime');
const pushRouterCache = new Cache('push-router');
export default class Realtime extends EventEmitter {

@@ -145,29 +145,63 @@ /**

static _fetchEndpointsInfo({ appId, region, ssl, _debug }) {
debug('fetch endpoint info');
let router;
static _fetchPushRouter({ appId, region }) {
debug('fetch router');
switch (region) {
case 'cn':
router = 'router-g0-push.leancloud.cn/v1/route';
break;
case 'cn': {
const cachedPushRouter = pushRouterCache.get(appId);
if (cachedPushRouter) {
return Promise.resolve(cachedPushRouter);
}
return axios
.get('https://app-router.leancloud.cn/1/route', {
params: {
appId,
},
timeout: 20000,
})
.then(
res => res.data
)
.then(tap(debug))
.then(
route => {
const pushRouter = route.push_router_server;
if (!pushRouter) {
throw new Error('push router not exists');
}
let ttl = route.ttl;
if (typeof ttl !== 'number') {
ttl = 3600;
}
pushRouterCache.set(appId, pushRouter, ttl * 1000);
return pushRouter;
}
)
.catch(() => 'router-g0-push.leancloud.cn');
}
case 'us':
router = 'router-a0-push.leancloud.cn/v1/route';
break;
return Promise.resolve('router-a0-push.leancloud.cn');
default:
throw new Error(`Region [${region}] is not supported.`);
}
const protocol = global.location ? '//' : 'https://';
}
return agent
.get(`${protocol}${router}`)
.query({
appId,
secure: ssl,
debug: _debug,
_t: Date.now(),
})
.timeout(20000)
.then(
res => res.body
);
static _fetchEndpointsInfo({ appId, region, ssl, _debug }) {
debug('fetch endpoint info');
return this._fetchPushRouter({ appId, region })
.then(tap(debug))
.then(router =>
axios.get(`https://${router}/v1/route`, {
params: {
appId,
secure: ssl,
debug: _debug,
_t: Date.now(),
},
timeout: 20000,
})
.then(
res => res.data
)
.then(tap(debug))
);
}

@@ -174,0 +208,0 @@

@@ -12,3 +12,3 @@ import isPlainObject from 'lodash/isPlainObject';

export const tap = interceptor => value => (interceptor(value), value);
export const tap = interceptor => value => ((interceptor(value), value));

@@ -31,2 +31,3 @@ const debug = d('LC:Cache');

debug(`[${this.name}] expired: ${key}`);
delete this._map[key];
}

@@ -33,0 +34,0 @@ debug(`[${this.name}] missed: ${key}`);

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

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