Comparing version 4.0.6 to 4.0.7
{ | ||
"name": "pubnub", | ||
"version": "4.0.6", | ||
"version": "4.0.7", | ||
"main": "dist/web/pubnub.min.js", | ||
@@ -5,0 +5,0 @@ "license": "https://github.com/pubnub/javascript/blob/master/LICENSE", |
## [v4.0.7](https://github.com/pubnub/javascript/tree/v4.0.7) | ||
[Full Changelog](https://github.com/pubnub/javascript/compare/v4.0.6...v4.0.7) | ||
- ⭐Dependency upgrades | ||
- ⭐try..catch wrapped around localStorage for iframe compliance | ||
## [v4.0.6](https://github.com/pubnub/javascript/tree/v4.0.6) | ||
@@ -3,0 +17,0 @@ |
@@ -37,2 +37,7 @@ 'use strict'; | ||
}, { | ||
key: 'removeAllListeners', | ||
value: function removeAllListeners() { | ||
this._listeners = []; | ||
} | ||
}, { | ||
key: 'announcePresence', | ||
@@ -39,0 +44,0 @@ value: function announcePresence(announce) { |
@@ -159,2 +159,17 @@ 'use strict'; | ||
}, { | ||
key: 'unsubscribeAll', | ||
value: function unsubscribeAll() { | ||
this.adaptUnsubscribeChange({ channels: this.getSubscribedChannels(), channelGroups: this.getSubscribedChannelGroups() }); | ||
} | ||
}, { | ||
key: 'getSubscribedChannels', | ||
value: function getSubscribedChannels() { | ||
return Object.keys(this._channels); | ||
} | ||
}, { | ||
key: 'getSubscribedChannelGroups', | ||
value: function getSubscribedChannelGroups() { | ||
return Object.keys(this._channelGroups); | ||
} | ||
}, { | ||
key: 'reconnect', | ||
@@ -161,0 +176,0 @@ value: function reconnect() { |
@@ -167,2 +167,3 @@ 'use strict'; | ||
this.removeListener = listenerManager.removeListener.bind(listenerManager); | ||
this.removeAllListeners = listenerManager.removeAllListeners.bind(listenerManager); | ||
@@ -207,4 +208,12 @@ this.channelGroups = { | ||
this.reconnect = subscriptionManager.reconnect.bind(subscriptionManager); | ||
this.stop = subscriptionManager.disconnect.bind(subscriptionManager); | ||
this.stop = function () { | ||
subscriptionManager.unsubscribeAll(); | ||
subscriptionManager.disconnect(); | ||
}; | ||
this.unsubscribeAll = subscriptionManager.unsubscribeAll.bind(subscriptionManager); | ||
this.getSubscribedChannels = subscriptionManager.getSubscribedChannels.bind(subscriptionManager); | ||
this.getSubscribedChannelGroups = subscriptionManager.getSubscribedChannelGroups.bind(subscriptionManager); | ||
this.getAuthKey = modules.config.getAuthKey.bind(modules.config); | ||
@@ -211,0 +220,0 @@ this.setAuthKey = modules.config.setAuthKey.bind(modules.config); |
@@ -53,3 +53,3 @@ 'use strict'; | ||
setup.sdkFamily = 'Nodejs'; | ||
return _possibleConstructorReturn(this, Object.getPrototypeOf(_class2).call(this, setup)); | ||
return _possibleConstructorReturn(this, (_class2.__proto__ || Object.getPrototypeOf(_class2)).call(this, setup)); | ||
} | ||
@@ -56,0 +56,0 @@ |
@@ -23,6 +23,14 @@ 'use strict'; | ||
get: function get(key) { | ||
return localStorage.getItem(key); | ||
try { | ||
return localStorage.getItem(key); | ||
} catch (e) { | ||
return null; | ||
} | ||
}, | ||
set: function set(key, data) { | ||
return localStorage.setItem(key, data); | ||
try { | ||
return localStorage.setItem(key, data); | ||
} catch (e) { | ||
return null; | ||
} | ||
} | ||
@@ -49,7 +57,7 @@ }; | ||
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(_class).call(this, setup)); | ||
var _this = _possibleConstructorReturn(this, (_class.__proto__ || Object.getPrototypeOf(_class)).call(this, setup)); | ||
window.addEventListener('offline', function () { | ||
_this._listenerManager.announceNetworkDown(); | ||
_this.stop.bind(_this); | ||
_this.stop(); | ||
}); | ||
@@ -59,3 +67,3 @@ | ||
_this._listenerManager.announceNetworkUp(); | ||
_this.reconnect.bind(_this); | ||
_this.reconnect(); | ||
}); | ||
@@ -62,0 +70,0 @@ return _this; |
{ | ||
"name": "pubnub", | ||
"preferGlobal": false, | ||
"version": "4.0.6", | ||
"version": "4.0.7", | ||
"author": "PubNub <support@pubnub.com>", | ||
@@ -48,3 +48,3 @@ "description": "Publish & Subscribe Real-time Messaging with PubNub", | ||
"eslint-plugin-react": "5.2.2", | ||
"flow-bin": "^0.29.0", | ||
"flow-bin": "^0.31.1", | ||
"gulp": "^3.9.1", | ||
@@ -57,7 +57,7 @@ "gulp-babel": "^6.1.2", | ||
"gulp-gzip": "^1.4.0", | ||
"gulp-istanbul": "^1.0.0", | ||
"gulp-istanbul": "^1.1.1", | ||
"gulp-mocha": "^2.2.0", | ||
"gulp-rename": "^1.2.2", | ||
"gulp-sourcemaps": "^1.6.0", | ||
"gulp-uglify": "^1.5.4", | ||
"gulp-uglify": "^2.0.0", | ||
"imports-loader": "0.6.5", | ||
@@ -75,3 +75,3 @@ "isparta": "^4.0.0", | ||
"nock": "^8.0.0", | ||
"phantomjs-prebuilt": "2.1.7", | ||
"phantomjs-prebuilt": "2.1.12", | ||
"remap-istanbul": "^0.6.4", | ||
@@ -84,3 +84,3 @@ "run-sequence": "^1.2.1", | ||
"webpack": "^1.13.1", | ||
"webpack-dev-server": "1.14.1", | ||
"webpack-dev-server": "1.15.0", | ||
"webpack-stream": "^3.2.0" | ||
@@ -87,0 +87,0 @@ }, |
@@ -20,3 +20,3 @@ # PubNub JavaScript SDK (V4) | ||
## CDN Links | ||
* https://cdn.pubnub.com/sdk/javascript/pubnub.4.0.6.min.js | ||
* https://cdn.pubnub.com/sdk/javascript/pubnub.4.0.6.js | ||
* https://cdn.pubnub.com/sdk/javascript/pubnub.4.0.7.min.js | ||
* https://cdn.pubnub.com/sdk/javascript/pubnub.4.0.7.js |
@@ -26,2 +26,6 @@ /* @flow */ | ||
removeAllListeners() { | ||
this._listeners = []; | ||
} | ||
announcePresence(announce: PresenceAnnouncement) { | ||
@@ -28,0 +32,0 @@ this._listeners.forEach((listener) => { |
@@ -141,2 +141,14 @@ | ||
unsubscribeAll() { | ||
this.adaptUnsubscribeChange({ channels: this.getSubscribedChannels(), channelGroups: this.getSubscribedChannelGroups() }); | ||
} | ||
getSubscribedChannels() { | ||
return Object.keys(this._channels); | ||
} | ||
getSubscribedChannelGroups() { | ||
return Object.keys(this._channelGroups); | ||
} | ||
reconnect() { | ||
@@ -143,0 +155,0 @@ this._startSubscribeLoop(); |
@@ -68,7 +68,12 @@ /* @flow */ | ||
unsubscribe: Function; | ||
unsubscribeAll: Function; | ||
reconnect: Function; | ||
stop: Function; | ||
getSubscribedChannels: Function; | ||
getSubscribedChannelGroups: Function; | ||
addListener: Function; | ||
removeListener: Function; | ||
removeAllListeners: Function; | ||
@@ -115,2 +120,3 @@ getAuthKey: Function; | ||
this.removeListener = listenerManager.removeListener.bind(listenerManager); | ||
this.removeAllListeners = listenerManager.removeAllListeners.bind(listenerManager); | ||
@@ -157,4 +163,12 @@ /** channel groups **/ | ||
this.reconnect = subscriptionManager.reconnect.bind(subscriptionManager); | ||
this.stop = subscriptionManager.disconnect.bind(subscriptionManager); | ||
this.stop = () => { | ||
subscriptionManager.unsubscribeAll(); | ||
subscriptionManager.disconnect(); | ||
}; | ||
this.unsubscribeAll = subscriptionManager.unsubscribeAll.bind(subscriptionManager); | ||
this.getSubscribedChannels = subscriptionManager.getSubscribedChannels.bind(subscriptionManager); | ||
this.getSubscribedChannelGroups = subscriptionManager.getSubscribedChannelGroups.bind(subscriptionManager); | ||
/** config **/ | ||
@@ -161,0 +175,0 @@ this.getAuthKey = modules.config.getAuthKey.bind(modules.config); |
@@ -11,7 +11,17 @@ /* @flow */ | ||
get(key: string) { | ||
return localStorage.getItem(key); | ||
// try catch for operating within iframes which disable localStorage | ||
try { | ||
return localStorage.getItem(key); | ||
} catch (e) { | ||
return null; | ||
} | ||
}, | ||
set(key: string, data: any) { | ||
return localStorage.setItem(key, data); | ||
// try catch for operating within iframes which disable localStorage | ||
try { | ||
return localStorage.setItem(key, data); | ||
} catch (e) { | ||
return null; | ||
} | ||
} | ||
@@ -41,3 +51,3 @@ }; | ||
this._listenerManager.announceNetworkDown(); | ||
this.stop.bind(this); | ||
this.stop(); | ||
}); | ||
@@ -47,3 +57,3 @@ | ||
this._listenerManager.announceNetworkUp(); | ||
this.reconnect.bind(this); | ||
this.reconnect(); | ||
}); | ||
@@ -50,0 +60,0 @@ } |
@@ -49,2 +49,3 @@ /* global describe, beforeEach, it, before, afterEach, after */ | ||
status(statusPayload) { | ||
if (statusPayload.operation !== 'PNSubscribeOperation') return; | ||
let statusWithoutError = _.omit(statusPayload, 'errorData'); | ||
@@ -51,0 +52,0 @@ assert.deepEqual({ |
@@ -145,2 +145,3 @@ /* global describe, beforeEach, it, before, afterEach, after */ | ||
status(statusPayload) { | ||
if (statusPayload.operation !== 'PNHeartbeatOperation') return; | ||
let statusWithoutError = _.omit(statusPayload, 'errorData'); | ||
@@ -166,2 +167,3 @@ assert.deepEqual({ | ||
status(statusPayload) { | ||
if (statusPayload.operation !== 'PNHeartbeatOperation') return; | ||
let statusWithoutError = _.omit(statusPayload, 'errorData'); | ||
@@ -168,0 +170,0 @@ assert.equal(scope.isDone(), true); |
@@ -75,2 +75,3 @@ /* global describe, beforeEach, it, before, afterEach, after */ | ||
assert.equal(scope.isDone(), true); | ||
assert.deepEqual(['cg1', 'cg2'], pubnub.getSubscribedChannelGroups()); | ||
done(); | ||
@@ -93,2 +94,3 @@ } | ||
assert.equal(scope.isDone(), true); | ||
assert.deepEqual(['coolChannel', 'coolChannel2'], pubnubWithFiltering.getSubscribedChannels()); | ||
done(); | ||
@@ -95,0 +97,0 @@ } |
@@ -26,2 +26,3 @@ /* global describe, beforeEach, it, before, afterEach, after */ | ||
afterEach(() => { | ||
pubnub.removeAllListeners(); | ||
pubnub.stop(); | ||
@@ -28,0 +29,0 @@ }); |
@@ -26,2 +26,3 @@ /* global describe, beforeEach, it, before, afterEach, after */ | ||
afterEach(() => { | ||
pubnub.removeAllListeners(); | ||
pubnub.stop(); | ||
@@ -95,2 +96,22 @@ }); | ||
}); | ||
describe('#unsubscribeAll', () => { | ||
it('supports leaving channels / channel groups', (done) => { | ||
const scope = utils.createNock().get('/v2/presence/sub-key/mySubscribeKey/channel/ch1%2Cch2/leave') | ||
.query({ pnsdk: 'PubNub-JS-Nodejs/' + pubnub.getVersion(), uuid: 'myUUID', 'channel-group': 'cg1,cg2' }) | ||
.reply(200, '{ "status": 200, "message": "OK", "service": "Presence"}'); | ||
pubnub.addListener({ | ||
status(status) { | ||
if (status.operation !== 'PNUnsubscribeOperation') return; | ||
assert.equal(status.error, false); | ||
assert.equal(scope.isDone(), true); | ||
done(); | ||
} | ||
}); | ||
pubnub.subscribe({ channels: ['ch1', 'ch2'], channelGroups: ['cg1', 'cg2'] }); | ||
pubnub.unsubscribeAll(); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
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 too big to display
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 not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1169477
11761