diff --git a/.pubnub.yml b/.pubnub.yml index 9822e6f..13daebe 100644 --- a/.pubnub.yml +++ b/.pubnub.yml @@ -1,11 +1,17 @@ name: pubnub-angular2 -version: 1.0.2 +version: 1.0.3 schema: 1 scm: github.com/pubnub/pubnub-angular2 files: - dist/pubnub-angular2.js - dist/pubnub-angular2.min.js changelog: + - version: v1.0.3 + changes: + - type: bug + text: fix issue 20 autoload history + - type: improvement + text: update for Angular4 and TS 2.3 - version: v1.0.2 changes: - type: bug diff --git a/CHANGELOG.md b/CHANGELOG.md index 09c2218..6d3d683 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +## [v1.0.3](https://github.com/pubnub/pubnub-angular2/tree/v1.0.3) + + + [Full Changelog](https://github.com/pubnub/pubnub-angular2/compare/v1.0.2...v1.0.3) + + + +- 🐛fix issue 20 autoload history +- 🌟update for Angular4 and TS 2.3 + ## [v1.0.2](https://github.com/pubnub/pubnub-angular2/tree/v1.0.2) diff --git a/dist/pubnub-angular2.js b/dist/pubnub-angular2.js index ca09964..168d68a 100644 --- a/dist/pubnub-angular2.js +++ b/dist/pubnub-angular2.js @@ -1,4 +1,4 @@ -/*! 1.0.2 */ +/*! 1.0.3 */ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); @@ -314,10 +314,12 @@ return /******/ (function(modules) { // webpackBootstrap this.autoload.getHistory(channel, callback); } - this.broadcastOn.message(channel, function (message) { - _this.outputOn.push(channel, message); - if (callback) callback(message); - }); + if (callback) { + this.broadcastOn.message(channel, function (message) { + _this.outputOn.push(channel, message); + callback(message); + }); + } return this.outputOn.get(channel); } diff --git a/dist/pubnub-angular2.min.js b/dist/pubnub-angular2.min.js index 15b7d13..3c34073 100644 --- a/dist/pubnub-angular2.min.js +++ b/dist/pubnub-angular2.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.PubNubAngular=t():e.PubNubAngular=t()}(this,function(){return function(e){function t(a){if(n[a])return n[a].exports;var r=n[a]={exports:{},id:a,loaded:!1};return e[a].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";var a=n(1);e.exports=a.PubNubAngular,e.exports.PubNubAngular=a.PubNubAngular},function(e,t,n){"use strict";function a(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0}),t.PubNubAngular=void 0;var s=function(){function e(e,t){for(var n=0;n0?(this.wrappers[e]=new o.Wrapper(e,this),u.default.attributes_to_delegate.forEach(function(n){t.wrappers[e].wrapAttribute(n),t[n]||Object.defineProperty(t,n,{get:function(){return this.getInstance(u.default.default_instance_name)[n]}})}),u.default.methods_to_delegate.forEach(function(n){t.wrappers[e].wrapMethod(n),t[n]||(t[n]=function(){var e=this.getInstance(u.default.default_instance_name);return e[n].apply(e,arguments)})}),this.wrappers[e]):n}},{key:"subscribe",value:function(e){this.getInstance(u.default.default_instance_name).subscribe(e)}},{key:"unsubscribe",value:function(e){this.getInstance(u.default.default_instance_name).unsubscribe(e)}},{key:"getMessage",value:function(e,t){return this.getInstance(u.default.default_instance_name).getMessage(e,t)}},{key:"getPresence",value:function(e,t){this.getInstance(u.default.default_instance_name).getPresence(e,t)}},{key:"getStatus",value:function(e,t){this.getInstance(u.default.default_instance_name).getStatus(e,t)}},{key:"getError",value:function(e){this.getInstance(u.default.default_instance_name).getError(e)}},{key:"clean",value:function(e){this.getInstance(u.default.default_instance_name).clean(e)}}]),e}()},function(e,t){e.exports={pubnub_prefix:"pubnub",default_instance_name:"default",attributes_to_delegate:["channelGroups","push"],methods_to_delegate:["addListener","removeListener","removeAllListeners","hereNow","whereNow","getState","setState","grant","audit","publish","fire","history","time","reconnect","stop","unsubscribeAll","getSubscribedChannels","getSubscribedChannelGroups","encrypt","decrypt","getAuthKey","setAuthKey","setCipherKey","getUUID","setUUID","getFilterExpression","setFilterExpression"],common_callbacks_to_wrap:["callback","error"],subscribe_listener_events_to_broadcast:["message","presence","status"],history_sort_attribute:"timetoken"}},function(e,t,n){"use strict";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0}),t.Wrapper=void 0;var r=function(){function e(e,t){for(var n=0;nn[t]?1:e[t]0?(this.wrappers[e]=new u.Wrapper(e,this),i.default.attributes_to_delegate.forEach(function(n){t.wrappers[e].wrapAttribute(n),t[n]||Object.defineProperty(t,n,{get:function(){return this.getInstance(i.default.default_instance_name)[n]}})}),i.default.methods_to_delegate.forEach(function(n){t.wrappers[e].wrapMethod(n),t[n]||(t[n]=function(){var e=this.getInstance(i.default.default_instance_name);return e[n].apply(e,arguments)})}),this.wrappers[e]):n}},{key:"subscribe",value:function(e){this.getInstance(i.default.default_instance_name).subscribe(e)}},{key:"unsubscribe",value:function(e){this.getInstance(i.default.default_instance_name).unsubscribe(e)}},{key:"getMessage",value:function(e,t){return this.getInstance(i.default.default_instance_name).getMessage(e,t)}},{key:"getPresence",value:function(e,t){this.getInstance(i.default.default_instance_name).getPresence(e,t)}},{key:"getStatus",value:function(e,t){this.getInstance(i.default.default_instance_name).getStatus(e,t)}},{key:"getError",value:function(e){this.getInstance(i.default.default_instance_name).getError(e)}},{key:"clean",value:function(e){this.getInstance(i.default.default_instance_name).clean(e)}}]),e}()},function(e,t){e.exports={pubnub_prefix:"pubnub",default_instance_name:"default",attributes_to_delegate:["channelGroups","push"],methods_to_delegate:["addListener","removeListener","removeAllListeners","hereNow","whereNow","getState","setState","grant","audit","publish","fire","history","time","reconnect","stop","unsubscribeAll","getSubscribedChannels","getSubscribedChannelGroups","encrypt","decrypt","getAuthKey","setAuthKey","setCipherKey","getUUID","setUUID","getFilterExpression","setFilterExpression"],common_callbacks_to_wrap:["callback","error"],subscribe_listener_events_to_broadcast:["message","presence","status"],history_sort_attribute:"timetoken"}},function(e,t,n){"use strict";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0}),t.Wrapper=void 0;var r=function(){function e(e,t){for(var n=0;nn[t]?1:e[t] {\n self.mockingInstance.disableEventsBroadcast(args);\n clearTimeout(tm);\n }, 1000);\n }\n\n /**\n * Get to receive messages from a channel or a set of channels through a callback\n *\n * @param {string|[string]} channel\n * @param callback\n */\n getMessage(channel, callback) {\n if (this.outputOn.subscribe(channel)) {\n this.autoload.getHistory(channel, callback);\n }\n\n this.broadcastOn.message(channel, (message) => {\n this.outputOn.push(channel, message);\n if (callback) callback(message);\n });\n\n return this.outputOn.get(channel);\n }\n\n /**\n * Get to receive presence information from a channel or a set of channels through a callback\n *\n * @param {string|[string]} channel\n * @param callback\n */\n getPresence(channel, callback) {\n if (this.broadcastOn) {\n this.broadcastOn.presence(channel, callback);\n }\n }\n\n /**\n * Get to receive status information from a channel or a set of channels through a callback\n *\n * @param {string|[string]} channel\n * @param callback\n */\n getStatus(channel, callback) {\n if (this.broadcastOn) {\n this.broadcastOn.status(channel, callback);\n }\n }\n\n /**\n * Get to receive error information from PubNub Service through a callback\n *\n * @param callback\n */\n getError(callback) {\n if (this.broadcastOn) {\n this.broadcastOn.error(callback);\n }\n }\n\n /**\n * Clean the stack of messages for a channel or a set of channels\n *\n * @param {string|[string]} channel\n */\n clean(channel) {\n this.outputOn.clean(channel);\n }\n\n /**\n * Get the PubNub instance wrapped or throw an exception if this is not instanced yet\n *\n * @returns {PubNub|*|null}\n */\n getOriginalInstance() {\n if (this.pubnubInstance) {\n return this.pubnubInstance;\n } else {\n throw new ReferenceError('Pubnub default instance is not initialized yet. Invoke #init() method first.');\n }\n }\n\n /**\n * Wrap a PubNub's attribute\n *\n * @param {string} attributeName\n */\n wrapAttribute(attributeName) {\n Object.defineProperty(this, attributeName, {\n get: function () {\n return this.getOriginalInstance()[attributeName];\n }\n });\n }\n\n /**\n * Wrap a PubNub's method\n *\n * @param methodName\n */\n wrapMethod(methodName) {\n this[methodName] = function () {\n return this.getOriginalInstance()[methodName].apply(this, arguments);\n };\n }\n}\n"]} \ No newline at end of file +{"version":3,"sources":["wrapper.js"],"names":["Wrapper","label","pubnubInstance","broadcastOn","outputOn","mockingInstance","autoload","initConfig","PubNub","initializeListener","initialize","args","getOriginalInstance","subscribe","enableEventsBroadcast","enableLoad","disableLoad","unsubscribe","self","tm","setTimeout","disableEventsBroadcast","clearTimeout","channel","callback","getHistory","message","push","get","presence","status","error","clean","ReferenceError","attributeName","Object","defineProperty","methodName","apply","arguments"],"mappings":";;;;;;;;;AACA;;AACA;;AACA;;AACA;;;;IAEaA,O,WAAAA,O;AACX,mBAAYC,KAAZ,EAAmB;AAAA;;AACjB,SAAKA,KAAL,GAAaA,KAAb;AACA,SAAKC,cAAL,GAAsB,IAAtB;AACA,SAAKC,WAAL,GAAmB,0BAAnB;AACA,SAAKC,QAAL,GAAgB,oBAAhB;AACA,SAAKC,eAAL,GAAuB,eAAS,KAAKF,WAAd,CAAvB;AACA,SAAKG,QAAL,GAAgB,wBAAhB;AACD;;;;yBAOIC,U,EAAY;AACf,WAAKL,cAAL,GAAsB,IAAIM,MAAJ,CAAWD,UAAX,CAAtB;AACA,WAAKF,eAAL,CAAqBI,kBAArB,CAAwC,IAAxC;AACA,WAAKH,QAAL,CAAcI,UAAd,CAAyB,IAAzB;AACD;;;+BAOU;AACT,aAAO,KAAKT,KAAZ;AACD;;;8BAOSU,I,EAAM;AACd,WAAKC,mBAAL,GAA2BC,SAA3B,CAAqCF,IAArC;AACA,WAAKN,eAAL,CAAqBS,qBAArB,CAA2CH,IAA3C;AACA,WAAKL,QAAL,CAAcS,UAAd,CAAyBJ,IAAzB;AACD;;;gCAOWA,I,EAAM;AAChB,WAAKL,QAAL,CAAcU,WAAd,CAA0BL,IAA1B;AACA,WAAKP,QAAL,CAAca,WAAd,CAA0BN,IAA1B;AACA,WAAKC,mBAA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J,CAAmB,8EAAnB,CAAN;AACD;AACF;;;kCAOaC,a,EAAe;AAC3BC,aAAOC,cAAP,CAAsB,IAAtB,EAA4BF,aAA5B,EAA2C;AACzCN,aAAK,eAAY;AACf,iBAAO,KAAKhB,mBAAL,GAA2BsB,aAA3B,CAAP;AACD;AAHwC,OAA3C;AAKD;;;+BAOUG,U,EAAY;AACrB,WAAKA,UAAL,IAAmB,YAAY;AAC7B,eAAO,KAAKzB,mBAAL,GAA2ByB,UAA3B,EAAuCC,KAAvC,CAA6C,IAA7C,EAAmDC,SAAnD,CAAP;AACD,OAFD;AAGD","file":"wrapper.js","sourcesContent":["/* global angular PUBNUB */\nimport { Mock } from './mock';\nimport { Broadcast } from './broadcast';\nimport { Output } from './output';\nimport { Autoload } from './autoload';\n\nexport class Wrapper {\n constructor(label) {\n this.label = label;\n this.pubnubInstance = null;\n this.broadcastOn = new Broadcast();\n this.outputOn = new Output();\n this.mockingInstance = new Mock(this.broadcastOn);\n this.autoload = new Autoload();\n }\n\n /**\n * Initialize the wrapper\n *\n * @param {object} initConfig\n */\n init(initConfig) {\n this.pubnubInstance = new PubNub(initConfig);\n this.mockingInstance.initializeListener(this);\n this.autoload.initialize(this);\n }\n\n /**\n * Get the name of the instance\n *\n * @returns {*|string|null|string}\n */\n getLabel() {\n return this.label;\n }\n\n /**\n * Wrap the subscribe method to enable trigger events to the broadcast\n *\n * @param {object} args\n */\n subscribe(args) {\n this.getOriginalInstance().subscribe(args);\n this.mockingInstance.enableEventsBroadcast(args);\n this.autoload.enableLoad(args);\n }\n\n /**\n * Wrap the unsubscribe method to disable the trigger events to the broadcast\n *\n * @param args\n */\n unsubscribe(args) {\n this.autoload.disableLoad(args);\n this.outputOn.unsubscribe(args);\n this.getOriginalInstance().unsubscribe(args);\n let self = this;\n let tm = setTimeout(() => {\n self.mockingInstance.disableEventsBroadcast(args);\n clearTimeout(tm);\n }, 1000);\n }\n\n /**\n * Get to receive messages from a channel or a set of channels through a callback\n *\n * @param {string|[string]} channel\n * @param callback\n */\n getMessage(channel, callback) {\n if (this.outputOn.subscribe(channel)) {\n this.autoload.getHistory(channel, callback);\n }\n\n if (callback) {\n this.broadcastOn.message(channel, (message) => {\n this.outputOn.push(channel, message);\n callback(message);\n });\n }\n\n return this.outputOn.get(channel);\n }\n\n /**\n * Get to receive presence information from a channel or a set of channels through a callback\n *\n * @param {string|[string]} channel\n * @param callback\n */\n getPresence(channel, callback) {\n if (this.broadcastOn) {\n this.broadcastOn.presence(channel, callback);\n }\n }\n\n /**\n * Get to receive status information from a channel or a set of channels through a callback\n *\n * @param {string|[string]} channel\n * @param callback\n */\n getStatus(channel, callback) {\n if (this.broadcastOn) {\n this.broadcastOn.status(channel, callback);\n }\n }\n\n /**\n * Get to receive error information from PubNub Service through a callback\n *\n * @param callback\n */\n getError(callback) {\n if (this.broadcastOn) {\n this.broadcastOn.error(callback);\n }\n }\n\n /**\n * Clean the stack of messages for a channel or a set of channels\n *\n * @param {string|[string]} channel\n */\n clean(channel) {\n this.outputOn.clean(channel);\n }\n\n /**\n * Get the PubNub instance wrapped or throw an exception if this is not instanced yet\n *\n * @returns {PubNub|*|null}\n */\n getOriginalInstance() {\n if (this.pubnubInstance) {\n return this.pubnubInstance;\n } else {\n throw new ReferenceError('Pubnub default instance is not initialized yet. Invoke #init() method first.');\n }\n }\n\n /**\n * Wrap a PubNub's attribute\n *\n * @param {string} attributeName\n */\n wrapAttribute(attributeName) {\n Object.defineProperty(this, attributeName, {\n get: function () {\n return this.getOriginalInstance()[attributeName];\n }\n });\n }\n\n /**\n * Wrap a PubNub's method\n *\n * @param methodName\n */\n wrapMethod(methodName) {\n this[methodName] = function () {\n return this.getOriginalInstance()[methodName].apply(this, arguments);\n };\n }\n}\n"]} \ No newline at end of file diff --git a/package.json b/package.json index 8448a40..8909a08 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pubnub-angular2", - "version": "1.0.2", + "version": "1.0.3", "description": "Official PubNub Angular2", "main": "dist/pubnub-angular2.min.js", "module": "lib/pubnub-angular2.js",