New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

action-cable-react

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

action-cable-react - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

2

dist/action_cable_react.js

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

!function(t){function e(i){if(n[i])return n[i].exports;var o=n[i]={exports:{},id:i,loaded:!1};return t[i].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){window.ActionCableReact={ActionCable:n(1),Cable:n(9),CableMixin:n(10),ChannelMixin:n(11)}},function(t,e,n){var i,o;o=n(2),i={createConsumer:function(t){return new o(this.createWebSocketURL(t))},createWebSocketURL:function(t){var e;return t&&!/^wss?:/i.test(t)?(e=document.createElement("a"),e.href=t,e.href=e.href,e.protocol=e.protocol.replace("http","ws"),e.href):t}},t.exports=i},function(t,e,n){var i,o,r,s,c;i=n(3),o=n(5),c=n(6),s=n(7),r=function(){function t(t){this.url=t,this.subscriptions=new c(this),this.connection=new i(this),this.connectionMonitor=new o(this)}return t.prototype.send=function(t){return this.connection.send(t)},t.prototype.inspect=function(){return JSON.stringify(this,null,2)},t.prototype.toJSON=function(){return{url:this.url,subscriptions:this.subscriptions,connection:this.connection,connectionMonitor:this.connectionMonitor}},t}(),t.exports=r},function(t,e,n){var i,o,r=function(t,e){return function(){return t.apply(e,arguments)}},s=[].slice,c=[].indexOf||function(t){for(var e=0,n=this.length;n>e;e++)if(e in this&&this[e]===t)return e;return-1};o=n(4).message_types,i=function(){function t(t){this.consumer=t,this.open=r(this.open,this),this.open()}return t.reopenDelay=500,t.prototype.send=function(t){return this.isOpen()?(this.webSocket.send(JSON.stringify(t)),!0):!1},t.prototype.open=function(){if(this.webSocket&&!this.isState("closed"))throw new Error("Existing connection must be closed before opening");return this.webSocket=new WebSocket(this.consumer.url),this.installEventHandlers(),!0},t.prototype.close=function(){var t;return null!=(t=this.webSocket)?t.close():void 0},t.prototype.reopen=function(){if(this.isState("closed"))return this.open();try{return this.close()}finally{setTimeout(this.open,this.constructor.reopenDelay)}},t.prototype.isOpen=function(){return this.isState("open")},t.prototype.isState=function(){var t,e;return e=1<=arguments.length?s.call(arguments,0):[],t=this.getState(),c.call(e,t)>=0},t.prototype.getState=function(){var t,e,n;for(e in WebSocket)if(n=WebSocket[e],n===(null!=(t=this.webSocket)?t.readyState:void 0))return e.toLowerCase();return null},t.prototype.installEventHandlers=function(){var t,e;for(t in this.events)e=this.events[t].bind(this),this.webSocket["on"+t]=e},t.prototype.events={message:function(t){var e,n,i,r;switch(i=JSON.parse(t.data),e=i.identifier,n=i.message,r=i.type,r){case o.confirmation:return this.consumer.subscriptions.notify(e,"connected");case o.rejection:return this.consumer.subscriptions.reject(e);default:return this.consumer.subscriptions.notify(e,"received",n)}},open:function(){return this.disconnected=!1,this.consumer.subscriptions.reload()},close:function(){return this.disconnect()},error:function(){return this.disconnect()}},t.prototype.disconnect=function(){return this.disconnected?void 0:(this.disconnected=!0,this.consumer.subscriptions.notifyAll("disconnected"))},t.prototype.toJSON=function(){return{state:this.getState()}},t}(),t.exports=i},function(t,e){t.exports={identifiers:{ping:"_ping"},message_types:{confirmation:"confirm_subscription",rejection:"reject_subscription"}}},function(t,e,n){var i,o,r=function(t,e){return function(){return t.apply(e,arguments)}};o=n(4),i=function(){function t(t){this.consumer=t,this.visibilityDidChange=r(this.visibilityDidChange,this),this.consumer.subscriptions.add(this),this.start()}var e,n,i;return t.pollInterval={min:3,max:30},t.staleThreshold=6,t.prototype.identifier=o.identifiers.ping,t.prototype.connected=function(){return this.reset(),this.pingedAt=n(),delete this.disconnectedAt},t.prototype.disconnected=function(){return this.disconnectedAt=n()},t.prototype.received=function(){return this.pingedAt=n()},t.prototype.reset=function(){return this.reconnectAttempts=0},t.prototype.start=function(){return this.reset(),delete this.stoppedAt,this.startedAt=n(),this.poll(),document.addEventListener("visibilitychange",this.visibilityDidChange)},t.prototype.stop=function(){return this.stoppedAt=n(),document.removeEventListener("visibilitychange",this.visibilityDidChange)},t.prototype.poll=function(){return setTimeout(function(t){return function(){return t.stoppedAt?void 0:(t.reconnectIfStale(),t.poll())}}(this),this.getInterval())},t.prototype.getInterval=function(){var t,n,i,o;return o=this.constructor.pollInterval,i=o.min,n=o.max,t=5*Math.log(this.reconnectAttempts+1),1e3*e(t,i,n)},t.prototype.reconnectIfStale=function(){return this.connectionIsStale()&&(this.reconnectAttempts++,!this.disconnectedRecently())?this.consumer.connection.reopen():void 0},t.prototype.connectionIsStale=function(){var t;return i(null!=(t=this.pingedAt)?t:this.startedAt)>this.constructor.staleThreshold},t.prototype.disconnectedRecently=function(){return this.disconnectedAt&&i(this.disconnectedAt)<this.constructor.staleThreshold},t.prototype.visibilityDidChange=function(){return"visible"===document.visibilityState?setTimeout(function(t){return function(){return t.connectionIsStale()||!t.consumer.connection.isOpen()?t.consumer.connection.reopen():void 0}}(this),200):void 0},t.prototype.toJSON=function(){var t,e;return e=this.getInterval(),t=this.connectionIsStale(),{startedAt:this.startedAt,stoppedAt:this.stoppedAt,pingedAt:this.pingedAt,reconnectAttempts:this.reconnectAttempts,connectionIsStale:t,interval:e}},n=function(){return(new Date).getTime()},i=function(t){return(n()-t)/1e3},e=function(t,e,n){return Math.max(e,Math.min(n,t))},t}(),t.exports=i},function(t,e,n){var i,o,r,s=[].slice;i=n(4),o=n(7),r=function(){function t(t){this.consumer=t,this.subscriptions=[],this.history=[]}return t.prototype.create=function(t,e){var n,i;return n=t,i="object"==typeof n?n:{channel:n},new o(this,i,e)},t.prototype.add=function(t){return this.subscriptions.push(t),this.notify(t,"initialized"),this.sendCommand(t,"subscribe")},t.prototype.remove=function(t){return this.forget(t),this.findAll(t.identifier).length?void 0:this.sendCommand(t,"unsubscribe")},t.prototype.reject=function(t){var e,n,i,o,r;for(i=this.findAll(t),o=[],e=0,n=i.length;n>e;e++)r=i[e],this.forget(r),o.push(this.notify(r,"rejected"));return o},t.prototype.forget=function(t){var e;return this.subscriptions=function(){var n,i,o,r;for(o=this.subscriptions,r=[],n=0,i=o.length;i>n;n++)e=o[n],e!==t&&r.push(e);return r}.call(this)},t.prototype.findAll=function(t){var e,n,i,o,r;for(i=this.subscriptions,o=[],e=0,n=i.length;n>e;e++)r=i[e],r.identifier===t&&o.push(r);return o},t.prototype.reload=function(){var t,e,n,i,o;for(n=this.subscriptions,i=[],t=0,e=n.length;e>t;t++)o=n[t],i.push(this.sendCommand(o,"subscribe"));return i},t.prototype.notifyAll=function(){var t,e,n,i,o,r,c;for(e=arguments[0],t=2<=arguments.length?s.call(arguments,1):[],o=this.subscriptions,r=[],n=0,i=o.length;i>n;n++)c=o[n],r.push(this.notify.apply(this,[c,e].concat(s.call(t))));return r},t.prototype.notify=function(){var t,e,n,i,o,r,c,u;for(c=arguments[0],e=arguments[1],t=3<=arguments.length?s.call(arguments,2):[],u="string"==typeof c?this.findAll(c):[c],r=[],n=0,o=u.length;o>n;n++)c=u[n],"function"==typeof c[e]&&c[e].apply(c,t),"initialized"===e||"connected"===e||"disconnected"===e||"rejected"===e?(i=c.identifier,r.push(this.record({notification:{identifier:i,callbackName:e,args:t}}))):r.push(void 0);return r},t.prototype.sendCommand=function(t,e){var n;return n=t.identifier,n===i.identifiers.ping?this.consumer.connection.isOpen():this.consumer.send({command:e,identifier:n})},t.prototype.record=function(t){return t.time=new Date,this.history=this.history.slice(-19),this.history.push(t)},t.prototype.toJSON=function(){var t;return{history:this.history,identifiers:function(){var e,n,i,o;for(i=this.subscriptions,o=[],e=0,n=i.length;n>e;e++)t=i[e],o.push(t.identifier);return o}.call(this)}},t}(),t.exports=r},function(t,e,n){var i,o,r=function(t,e){function n(){this.constructor=t}for(var i in e)s.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},s={}.hasOwnProperty,c=[].indexOf||function(t){for(var e=0,n=this.length;n>e;e++)if(e in this&&this[e]===t)return e;return-1};i=n(8),o=function(t){function e(t,e,n){this.subscriptions=t,null==e&&(e={}),this.actions=null!=n?n:[],this.identifier=JSON.stringify(e),this.subscriptions.add(this),this.consumer=this.subscriptions.consumer}return r(e,t),e.prototype.perform=function(t,e){return null==e&&(e={}),e.action=t,this.send(e)},e.prototype.send=function(t){return this.consumer.send({command:"message",identifier:this.identifier,data:JSON.stringify(t)})},e.prototype.unsubscribe=function(){return this.subscriptions.remove(this)},e.prototype.connected=function(){return this.emit("connected")},e.prototype.disconnected=function(){return this.emit("disconnected")},e.prototype.rejected=function(){return this.emit("rejected")},e.prototype.received=function(t){var e;return e=t.action,c.call(this.actions,e)>=0?this.emit(t.action,t):this.emit("received",t)},e}(i),t.exports=o},function(t,e,n){"use strict";function i(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(){}var r="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(t,e){var n=r?r+t:t,i=this._events&&this._events[n];if(e)return!!i;if(!i)return[];if(i.fn)return[i.fn];for(var o=0,s=i.length,c=new Array(s);s>o;o++)c[o]=i[o].fn;return c},o.prototype.emit=function(t,e,n,i,o,s){var c=r?r+t:t;if(!this._events||!this._events[c])return!1;var u,h,a=this._events[c],p=arguments.length;if("function"==typeof a.fn){switch(a.once&&this.removeListener(t,a.fn,void 0,!0),p){case 1:return a.fn.call(a.context),!0;case 2:return a.fn.call(a.context,e),!0;case 3:return a.fn.call(a.context,e,n),!0;case 4:return a.fn.call(a.context,e,n,i),!0;case 5:return a.fn.call(a.context,e,n,i,o),!0;case 6:return a.fn.call(a.context,e,n,i,o,s),!0}for(h=1,u=new Array(p-1);p>h;h++)u[h-1]=arguments[h];a.fn.apply(a.context,u)}else{var l,f=a.length;for(h=0;f>h;h++)switch(a[h].once&&this.removeListener(t,a[h].fn,void 0,!0),p){case 1:a[h].fn.call(a[h].context);break;case 2:a[h].fn.call(a[h].context,e);break;case 3:a[h].fn.call(a[h].context,e,n);break;default:if(!u)for(l=1,u=new Array(p-1);p>l;l++)u[l-1]=arguments[l];a[h].fn.apply(a[h].context,u)}}return!0},o.prototype.on=function(t,e,n){var o=new i(e,n||this),s=r?r+t:t;return this._events||(this._events=r?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(t,e,n){var o=new i(e,n||this,!0),s=r?r+t:t;return this._events||(this._events=r?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(t,e,n,i){var o=r?r+t:t;if(!this._events||!this._events[o])return this;var s=this._events[o],c=[];if(e)if(s.fn)(s.fn!==e||i&&!s.once||n&&s.context!==n)&&c.push(s);else for(var u=0,h=s.length;h>u;u++)(s[u].fn!==e||i&&!s[u].once||n&&s[u].context!==n)&&c.push(s[u]);return c.length?this._events[o]=1===c.length?c[0]:c:delete this._events[o],this},o.prototype.removeAllListeners=function(t){return this._events?(t?delete this._events[r?r+t:t]:this._events=r?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=r,t.exports=o},function(t,e){var n;n=function(){function t(t){this.channels=t}return t.prototype.channel=function(t){return this.channels[t]},t}(),t.exports=n},function(t,e){var n;n=function(t){return{componentWillMount:function(){var t;if(!(this.props.cable||this.context&&this.context.cable))throw t=this.constructor.displayName?" of "+this.constructor.displayName:"",new Error("Could not find cable on this.props or this.context"+t)},childContextTypes:{cable:t.PropTypes.object},contextTypes:{cable:t.PropTypes.object},getChildContext:function(){return{cable:this.getCable()}},getCable:function(){return this.props.cable||this.context&&this.context.cable}}},n.componentWillMount=function(){throw new Error("ActionCableReact.CableMixin is a function that takes React as a parameter and returns the mixin, e.g.: mixins: [ActionCableReact.CableMixin(React)]")},t.exports=n},function(t,e,n){var i,o;o=n(12),i=function(){var t;return t=Array.prototype.slice.call(arguments),{componentDidMount:function(){var e,n,i,r,s,c,u;for(i=this.props.cable||this.context.cable,this.mounted=!0,u=[],s=0,c=t.length;c>s;s++)r=t[s],null!=this.handleConnected&&i.channel(r).on("connected",this.handleConnected),null!=this.handleDisconnected&&i.channel(r).on("disconnected",this.handleDisconnected),null!=this.handleDisconnected&&i.channel(r).on("rejected",this.handleDisconnected),null!=this.handleReceived&&i.channel(r).on("received",this.handleReceived),u.push(function(){var t,s,c,u;for(c=i.channel(r).actions,u=[],t=0,s=c.length;s>t;t++)e=c[t],n="handle"+o(e),null!=this[n]?u.push(i.channel(r).on(e,this[n])):u.push(void 0);return u}.call(this));return u},componentWillUnmount:function(){var e,n,i,r,s,c,u;for(i=this.props.cable||this.context.cable,this.mounted=!1,u=[],s=0,c=t.length;c>s;s++)r=t[s],null!=this.handleConnected&&i.channel(r).removeListener("connected",this.handleConnected),null!=this.handleDisconnected&&i.channel(r).removeListener("disconnected",this.handleDisconnected),null!=this.handleDisconnected&&i.channel(r).removeListener("rejected",this.handleDisconnected),null!=this.handleReceived&&i.channel(r).removeListener("received",this.handleReceived),u.push(function(){var t,s,c,u;for(c=i.channel(r).actions,u=[],t=0,s=c.length;s>t;t++)e=c[t],n="handle"+o(e),null!=this[n]?u.push(i.channel(r).removeListener(e,this[n])):u.push(void 0);return u}.call(this));return u},perform:function(t,e,n){var i;return null==n&&(n={}),i=this.props.cable||this.context.cable,i.channel(t).perform(e,n)}}},i.componentWillMount=function(){throw new Error('ActionCableReact.ChannelMixin is a function that takes one or more store names as parameters and returns the mixin, e.g.: mixins: [ActionCableReact.ChannelMixin("Channel1", "Channel2")]')},t.exports=i},function(t,e,n){function i(t){return t=o(t),t&&t.charAt(0).toUpperCase()+t.slice(1)}var o=n(13);t.exports=i},function(t,e){function n(t){return null==t?"":t+""}t.exports=n}]);
!function(t){function e(i){if(n[i])return n[i].exports;var o=n[i]={exports:{},id:i,loaded:!1};return t[i].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){window.ActionCableReact={ActionCable:n(1),Cable:n(9),CableMixin:n(10),ChannelMixin:n(11),version:n(14)}},function(t,e,n){var i,o;o=n(2),i={createConsumer:function(t){return new o(this.createWebSocketURL(t))},createWebSocketURL:function(t){var e;return t&&!/^wss?:/i.test(t)?(e=document.createElement("a"),e.href=t,e.href=e.href,e.protocol=e.protocol.replace("http","ws"),e.href):t}},t.exports=i},function(t,e,n){var i,o,r,s,c;i=n(3),o=n(5),c=n(6),s=n(7),r=function(){function t(t){this.url=t,this.subscriptions=new c(this),this.connection=new i(this),this.connectionMonitor=new o(this)}return t.prototype.send=function(t){return this.connection.send(t)},t.prototype.inspect=function(){return JSON.stringify(this,null,2)},t.prototype.toJSON=function(){return{url:this.url,subscriptions:this.subscriptions,connection:this.connection,connectionMonitor:this.connectionMonitor}},t}(),t.exports=r},function(t,e,n){var i,o,r=function(t,e){return function(){return t.apply(e,arguments)}},s=[].slice,c=[].indexOf||function(t){for(var e=0,n=this.length;n>e;e++)if(e in this&&this[e]===t)return e;return-1};o=n(4).message_types,i=function(){function t(t){this.consumer=t,this.open=r(this.open,this),this.open()}return t.reopenDelay=500,t.prototype.send=function(t){return this.isOpen()?(this.webSocket.send(JSON.stringify(t)),!0):!1},t.prototype.open=function(){if(this.webSocket&&!this.isState("closed"))throw new Error("Existing connection must be closed before opening");return this.webSocket=new WebSocket(this.consumer.url),this.installEventHandlers(),!0},t.prototype.close=function(){var t;return null!=(t=this.webSocket)?t.close():void 0},t.prototype.reopen=function(){if(this.isState("closed"))return this.open();try{return this.close()}finally{setTimeout(this.open,this.constructor.reopenDelay)}},t.prototype.isOpen=function(){return this.isState("open")},t.prototype.isState=function(){var t,e;return e=1<=arguments.length?s.call(arguments,0):[],t=this.getState(),c.call(e,t)>=0},t.prototype.getState=function(){var t,e,n;for(e in WebSocket)if(n=WebSocket[e],n===(null!=(t=this.webSocket)?t.readyState:void 0))return e.toLowerCase();return null},t.prototype.installEventHandlers=function(){var t,e;for(t in this.events)e=this.events[t].bind(this),this.webSocket["on"+t]=e},t.prototype.events={message:function(t){var e,n,i,r;switch(i=JSON.parse(t.data),e=i.identifier,n=i.message,r=i.type,r){case o.confirmation:return this.consumer.subscriptions.notify(e,"connected");case o.rejection:return this.consumer.subscriptions.reject(e);default:return this.consumer.subscriptions.notify(e,"received",n)}},open:function(){return this.disconnected=!1,this.consumer.subscriptions.reload()},close:function(){return this.disconnect()},error:function(){return this.disconnect()}},t.prototype.disconnect=function(){return this.disconnected?void 0:(this.disconnected=!0,this.consumer.subscriptions.notifyAll("disconnected"))},t.prototype.toJSON=function(){return{state:this.getState()}},t}(),t.exports=i},function(t,e){t.exports={identifiers:{ping:"_ping"},message_types:{confirmation:"confirm_subscription",rejection:"reject_subscription"}}},function(t,e,n){var i,o,r=function(t,e){return function(){return t.apply(e,arguments)}};o=n(4),i=function(){function t(t){this.consumer=t,this.visibilityDidChange=r(this.visibilityDidChange,this),this.consumer.subscriptions.add(this),this.start()}var e,n,i;return t.pollInterval={min:3,max:30},t.staleThreshold=6,t.prototype.identifier=o.identifiers.ping,t.prototype.connected=function(){return this.reset(),this.pingedAt=n(),delete this.disconnectedAt},t.prototype.disconnected=function(){return this.disconnectedAt=n()},t.prototype.received=function(){return this.pingedAt=n()},t.prototype.reset=function(){return this.reconnectAttempts=0},t.prototype.start=function(){return this.reset(),delete this.stoppedAt,this.startedAt=n(),this.poll(),document.addEventListener("visibilitychange",this.visibilityDidChange)},t.prototype.stop=function(){return this.stoppedAt=n(),document.removeEventListener("visibilitychange",this.visibilityDidChange)},t.prototype.poll=function(){return setTimeout(function(t){return function(){return t.stoppedAt?void 0:(t.reconnectIfStale(),t.poll())}}(this),this.getInterval())},t.prototype.getInterval=function(){var t,n,i,o;return o=this.constructor.pollInterval,i=o.min,n=o.max,t=5*Math.log(this.reconnectAttempts+1),1e3*e(t,i,n)},t.prototype.reconnectIfStale=function(){return this.connectionIsStale()&&(this.reconnectAttempts++,!this.disconnectedRecently())?this.consumer.connection.reopen():void 0},t.prototype.connectionIsStale=function(){var t;return i(null!=(t=this.pingedAt)?t:this.startedAt)>this.constructor.staleThreshold},t.prototype.disconnectedRecently=function(){return this.disconnectedAt&&i(this.disconnectedAt)<this.constructor.staleThreshold},t.prototype.visibilityDidChange=function(){return"visible"===document.visibilityState?setTimeout(function(t){return function(){return t.connectionIsStale()||!t.consumer.connection.isOpen()?t.consumer.connection.reopen():void 0}}(this),200):void 0},t.prototype.toJSON=function(){var t,e;return e=this.getInterval(),t=this.connectionIsStale(),{startedAt:this.startedAt,stoppedAt:this.stoppedAt,pingedAt:this.pingedAt,reconnectAttempts:this.reconnectAttempts,connectionIsStale:t,interval:e}},n=function(){return(new Date).getTime()},i=function(t){return(n()-t)/1e3},e=function(t,e,n){return Math.max(e,Math.min(n,t))},t}(),t.exports=i},function(t,e,n){var i,o,r,s=[].slice;i=n(4),o=n(7),r=function(){function t(t){this.consumer=t,this.subscriptions=[],this.history=[]}return t.prototype.create=function(t,e){var n,i;return n=t,i="object"==typeof n?n:{channel:n},new o(this,i,e)},t.prototype.add=function(t){return this.subscriptions.push(t),this.notify(t,"initialized"),this.sendCommand(t,"subscribe")},t.prototype.remove=function(t){return this.forget(t),this.findAll(t.identifier).length?void 0:this.sendCommand(t,"unsubscribe")},t.prototype.reject=function(t){var e,n,i,o,r;for(i=this.findAll(t),o=[],e=0,n=i.length;n>e;e++)r=i[e],this.forget(r),o.push(this.notify(r,"rejected"));return o},t.prototype.forget=function(t){var e;return this.subscriptions=function(){var n,i,o,r;for(o=this.subscriptions,r=[],n=0,i=o.length;i>n;n++)e=o[n],e!==t&&r.push(e);return r}.call(this)},t.prototype.findAll=function(t){var e,n,i,o,r;for(i=this.subscriptions,o=[],e=0,n=i.length;n>e;e++)r=i[e],r.identifier===t&&o.push(r);return o},t.prototype.reload=function(){var t,e,n,i,o;for(n=this.subscriptions,i=[],t=0,e=n.length;e>t;t++)o=n[t],i.push(this.sendCommand(o,"subscribe"));return i},t.prototype.notifyAll=function(){var t,e,n,i,o,r,c;for(e=arguments[0],t=2<=arguments.length?s.call(arguments,1):[],o=this.subscriptions,r=[],n=0,i=o.length;i>n;n++)c=o[n],r.push(this.notify.apply(this,[c,e].concat(s.call(t))));return r},t.prototype.notify=function(){var t,e,n,i,o,r,c,u;for(c=arguments[0],e=arguments[1],t=3<=arguments.length?s.call(arguments,2):[],u="string"==typeof c?this.findAll(c):[c],r=[],n=0,o=u.length;o>n;n++)c=u[n],"function"==typeof c[e]&&c[e].apply(c,t),"initialized"===e||"connected"===e||"disconnected"===e||"rejected"===e?(i=c.identifier,r.push(this.record({notification:{identifier:i,callbackName:e,args:t}}))):r.push(void 0);return r},t.prototype.sendCommand=function(t,e){var n;return n=t.identifier,n===i.identifiers.ping?this.consumer.connection.isOpen():this.consumer.send({command:e,identifier:n})},t.prototype.record=function(t){return t.time=new Date,this.history=this.history.slice(-19),this.history.push(t)},t.prototype.toJSON=function(){var t;return{history:this.history,identifiers:function(){var e,n,i,o;for(i=this.subscriptions,o=[],e=0,n=i.length;n>e;e++)t=i[e],o.push(t.identifier);return o}.call(this)}},t}(),t.exports=r},function(t,e,n){var i,o,r=function(t,e){function n(){this.constructor=t}for(var i in e)s.call(e,i)&&(t[i]=e[i]);return n.prototype=e.prototype,t.prototype=new n,t.__super__=e.prototype,t},s={}.hasOwnProperty,c=[].indexOf||function(t){for(var e=0,n=this.length;n>e;e++)if(e in this&&this[e]===t)return e;return-1};i=n(8),o=function(t){function e(t,e,n){this.subscriptions=t,null==e&&(e={}),this.actions=null!=n?n:[],this.identifier=JSON.stringify(e),this.subscriptions.add(this),this.consumer=this.subscriptions.consumer}return r(e,t),e.prototype.perform=function(t,e){return null==e&&(e={}),e.action=t,this.send(e)},e.prototype.send=function(t){return this.consumer.send({command:"message",identifier:this.identifier,data:JSON.stringify(t)})},e.prototype.unsubscribe=function(){return this.subscriptions.remove(this)},e.prototype.connected=function(){return this.emit("connected")},e.prototype.disconnected=function(){return this.emit("disconnected")},e.prototype.rejected=function(){return this.emit("rejected")},e.prototype.received=function(t){var e;return e=t.action,c.call(this.actions,e)>=0?this.emit(t.action,t):this.emit("received",t)},e}(i),t.exports=o},function(t,e,n){"use strict";function i(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(){}var r="function"!=typeof Object.create?"~":!1;o.prototype._events=void 0,o.prototype.listeners=function(t,e){var n=r?r+t:t,i=this._events&&this._events[n];if(e)return!!i;if(!i)return[];if(i.fn)return[i.fn];for(var o=0,s=i.length,c=new Array(s);s>o;o++)c[o]=i[o].fn;return c},o.prototype.emit=function(t,e,n,i,o,s){var c=r?r+t:t;if(!this._events||!this._events[c])return!1;var u,h,a=this._events[c],p=arguments.length;if("function"==typeof a.fn){switch(a.once&&this.removeListener(t,a.fn,void 0,!0),p){case 1:return a.fn.call(a.context),!0;case 2:return a.fn.call(a.context,e),!0;case 3:return a.fn.call(a.context,e,n),!0;case 4:return a.fn.call(a.context,e,n,i),!0;case 5:return a.fn.call(a.context,e,n,i,o),!0;case 6:return a.fn.call(a.context,e,n,i,o,s),!0}for(h=1,u=new Array(p-1);p>h;h++)u[h-1]=arguments[h];a.fn.apply(a.context,u)}else{var l,f=a.length;for(h=0;f>h;h++)switch(a[h].once&&this.removeListener(t,a[h].fn,void 0,!0),p){case 1:a[h].fn.call(a[h].context);break;case 2:a[h].fn.call(a[h].context,e);break;case 3:a[h].fn.call(a[h].context,e,n);break;default:if(!u)for(l=1,u=new Array(p-1);p>l;l++)u[l-1]=arguments[l];a[h].fn.apply(a[h].context,u)}}return!0},o.prototype.on=function(t,e,n){var o=new i(e,n||this),s=r?r+t:t;return this._events||(this._events=r?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.once=function(t,e,n){var o=new i(e,n||this,!0),s=r?r+t:t;return this._events||(this._events=r?{}:Object.create(null)),this._events[s]?this._events[s].fn?this._events[s]=[this._events[s],o]:this._events[s].push(o):this._events[s]=o,this},o.prototype.removeListener=function(t,e,n,i){var o=r?r+t:t;if(!this._events||!this._events[o])return this;var s=this._events[o],c=[];if(e)if(s.fn)(s.fn!==e||i&&!s.once||n&&s.context!==n)&&c.push(s);else for(var u=0,h=s.length;h>u;u++)(s[u].fn!==e||i&&!s[u].once||n&&s[u].context!==n)&&c.push(s[u]);return c.length?this._events[o]=1===c.length?c[0]:c:delete this._events[o],this},o.prototype.removeAllListeners=function(t){return this._events?(t?delete this._events[r?r+t:t]:this._events=r?{}:Object.create(null),this):this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prototype.setMaxListeners=function(){return this},o.prefixed=r,t.exports=o},function(t,e){var n;n=function(){function t(t){this.channels=t}return t.prototype.channel=function(t){return this.channels[t]},t.prototype.setChannel=function(t,e){return this.channels[t]=e},t}(),t.exports=n},function(t,e){var n;n=function(t){return{componentWillMount:function(){var t;if(!(this.props.cable||this.context&&this.context.cable))throw t=this.constructor.displayName?" of "+this.constructor.displayName:"",new Error("Could not find cable on this.props or this.context"+t)},childContextTypes:{cable:t.PropTypes.object},contextTypes:{cable:t.PropTypes.object},getChildContext:function(){return{cable:this.getCable()}},getCable:function(){return this.props.cable||this.context&&this.context.cable}}},n.componentWillMount=function(){throw new Error("ActionCableReact.CableMixin is a function that takes React as a parameter and returns the mixin, e.g.: mixins: [ActionCableReact.CableMixin(React)]")},t.exports=n},function(t,e,n){var i,o;o=n(12),i=function(){var t;return t=Array.prototype.slice.call(arguments),{componentDidMount:function(){var e,n,i,r,s,c,u;for(i=this.props.cable||this.context.cable,this.mounted=!0,u=[],s=0,c=t.length;c>s;s++)r=t[s],i.channel(r)?(null!=this.handleConnected&&i.channel(r).on("connected",this.handleConnected),null!=this.handleDisconnected&&i.channel(r).on("disconnected",this.handleDisconnected),null!=this.handleDisconnected&&i.channel(r).on("rejected",this.handleDisconnected),null!=this.handleReceived&&i.channel(r).on("received",this.handleReceived),u.push(function(){var t,s,c,u;for(c=i.channel(r).actions,u=[],t=0,s=c.length;s>t;t++)e=c[t],n="handle"+o(e),null!=this[n]?u.push(i.channel(r).on(e,this[n])):u.push(void 0);return u}.call(this))):u.push(void 0);return u},componentWillUnmount:function(){var e,n,i,r,s,c,u;for(i=this.props.cable||this.context.cable,this.mounted=!1,u=[],s=0,c=t.length;c>s;s++)r=t[s],i.channel(r)?(null!=this.handleConnected&&i.channel(r).removeListener("connected",this.handleConnected),null!=this.handleDisconnected&&i.channel(r).removeListener("disconnected",this.handleDisconnected),null!=this.handleDisconnected&&i.channel(r).removeListener("rejected",this.handleDisconnected),null!=this.handleReceived&&i.channel(r).removeListener("received",this.handleReceived),u.push(function(){var t,s,c,u;for(c=i.channel(r).actions,u=[],t=0,s=c.length;s>t;t++)e=c[t],n="handle"+o(e),null!=this[n]?u.push(i.channel(r).removeListener(e,this[n])):u.push(void 0);return u}.call(this))):u.push(void 0);return u},perform:function(t,e,n){var i;return null==n&&(n={}),i=this.props.cable||this.context.cable,i.channel(t).perform(e,n)}}},i.componentWillMount=function(){throw new Error('ActionCableReact.ChannelMixin is a function that takes one or more store names as parameters and returns the mixin, e.g.: mixins: [ActionCableReact.ChannelMixin("Channel1", "Channel2")]')},t.exports=i},function(t,e,n){function i(t){return t=o(t),t&&t.charAt(0).toUpperCase()+t.slice(1)}var o=n(13);t.exports=i},function(t,e){function n(t){return null==t?"":t+""}t.exports=n},function(t,e){t.exports="0.1.0"}]);

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

var Cable;Cable=function(){function n(n){this.channels=n}return n.prototype.channel=function(n){return this.channels[n]},n}(),module.exports=Cable;
var Cable;Cable=function(){function n(n){this.channels=n}return n.prototype.channel=function(n){return this.channels[n]},n.prototype.setChannel=function(n,e){return this.channels[n]=e},n}(),module.exports=Cable;

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

var ChannelMixin,_capitalize;_capitalize=require("lodash.capitalize"),ChannelMixin=function(){var n;return n=Array.prototype.slice.call(arguments),{componentDidMount:function(){var e,t,i,l,c,h,a;for(i=this.props.cable||this.context.cable,this.mounted=!0,a=[],c=0,h=n.length;h>c;c++)l=n[c],null!=this.handleConnected&&i.channel(l).on("connected",this.handleConnected),null!=this.handleDisconnected&&i.channel(l).on("disconnected",this.handleDisconnected),null!=this.handleDisconnected&&i.channel(l).on("rejected",this.handleDisconnected),null!=this.handleReceived&&i.channel(l).on("received",this.handleReceived),a.push(function(){var n,c,h,a;for(h=i.channel(l).actions,a=[],n=0,c=h.length;c>n;n++)e=h[n],t="handle"+_capitalize(e),null!=this[t]?a.push(i.channel(l).on(e,this[t])):a.push(void 0);return a}.call(this));return a},componentWillUnmount:function(){var e,t,i,l,c,h,a;for(i=this.props.cable||this.context.cable,this.mounted=!1,a=[],c=0,h=n.length;h>c;c++)l=n[c],null!=this.handleConnected&&i.channel(l).removeListener("connected",this.handleConnected),null!=this.handleDisconnected&&i.channel(l).removeListener("disconnected",this.handleDisconnected),null!=this.handleDisconnected&&i.channel(l).removeListener("rejected",this.handleDisconnected),null!=this.handleReceived&&i.channel(l).removeListener("received",this.handleReceived),a.push(function(){var n,c,h,a;for(h=i.channel(l).actions,a=[],n=0,c=h.length;c>n;n++)e=h[n],t="handle"+_capitalize(e),null!=this[t]?a.push(i.channel(l).removeListener(e,this[t])):a.push(void 0);return a}.call(this));return a},perform:function(n,e,t){var i;return null==t&&(t={}),i=this.props.cable||this.context.cable,i.channel(n).perform(e,t)}}},ChannelMixin.componentWillMount=function(){throw new Error('ActionCableReact.ChannelMixin is a function that takes one or more store names as parameters and returns the mixin, e.g.: mixins: [ActionCableReact.ChannelMixin("Channel1", "Channel2")]')},module.exports=ChannelMixin;
var ChannelMixin,_capitalize;_capitalize=require("lodash.capitalize"),ChannelMixin=function(){var n;return n=Array.prototype.slice.call(arguments),{componentDidMount:function(){var e,t,i,l,h,c,a;for(i=this.props.cable||this.context.cable,this.mounted=!0,a=[],h=0,c=n.length;c>h;h++)l=n[h],i.channel(l)?(null!=this.handleConnected&&i.channel(l).on("connected",this.handleConnected),null!=this.handleDisconnected&&i.channel(l).on("disconnected",this.handleDisconnected),null!=this.handleDisconnected&&i.channel(l).on("rejected",this.handleDisconnected),null!=this.handleReceived&&i.channel(l).on("received",this.handleReceived),a.push(function(){var n,h,c,a;for(c=i.channel(l).actions,a=[],n=0,h=c.length;h>n;n++)e=c[n],t="handle"+_capitalize(e),null!=this[t]?a.push(i.channel(l).on(e,this[t])):a.push(void 0);return a}.call(this))):a.push(void 0);return a},componentWillUnmount:function(){var e,t,i,l,h,c,a;for(i=this.props.cable||this.context.cable,this.mounted=!1,a=[],h=0,c=n.length;c>h;h++)l=n[h],i.channel(l)?(null!=this.handleConnected&&i.channel(l).removeListener("connected",this.handleConnected),null!=this.handleDisconnected&&i.channel(l).removeListener("disconnected",this.handleDisconnected),null!=this.handleDisconnected&&i.channel(l).removeListener("rejected",this.handleDisconnected),null!=this.handleReceived&&i.channel(l).removeListener("received",this.handleReceived),a.push(function(){var n,h,c,a;for(c=i.channel(l).actions,a=[],n=0,h=c.length;h>n;n++)e=c[n],t="handle"+_capitalize(e),null!=this[t]?a.push(i.channel(l).removeListener(e,this[t])):a.push(void 0);return a}.call(this))):a.push(void 0);return a},perform:function(n,e,t){var i;return null==t&&(t={}),i=this.props.cable||this.context.cable,i.channel(n).perform(e,t)}}},ChannelMixin.componentWillMount=function(){throw new Error('ActionCableReact.ChannelMixin is a function that takes one or more store names as parameters and returns the mixin, e.g.: mixins: [ActionCableReact.ChannelMixin("Channel1", "Channel2")]')},module.exports=ChannelMixin;
{
"name": "action-cable-react",
"version": "0.1.0",
"version": "0.1.1",
"description": "Use Rails 5 ActionCable channels with React for realtime magic.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -0,1 +1,4 @@

[![npm version](https://badge.fury.io/js/action-cable-react.svg)](https://badge.fury.io/js/action-cable-react)
[![Bower version](https://badge.fury.io/bo/action-cable-react.svg)](https://badge.fury.io/bo/action-cable-react)
# ActionCable + React

@@ -9,3 +12,3 @@

Make sure to check out the example [server](https://github.com/schneidmaster/action-cable-react-example-server) and [client](https://github.com/schneidmaster/action-cable-react-example-client) applications to try it out for yourself.
Make sure to check out the example [server](https://github.com/schneidmaster/action-cable-react-example-server) and client ([ES6](https://github.com/schneidmaster/action-cable-react-example-client) or [CoffeeScript](https://github.com/schneidmaster/action-cable-react-example-coffee)) applications to try it out for yourself.

@@ -122,3 +125,3 @@ ## Usage

The full example is available on [GitHub](https://github.com/schneidmaster/action-cable-react-example-client) as well as a companion [server](https://github.com/schneidmaster/action-cable-react-example-server) application.
The full example is available on [GitHub](https://github.com/schneidmaster/action-cable-react-example-client) as well as a companion [server](https://github.com/schneidmaster/action-cable-react-example-server) application. (Or, check it out in [CoffeeScript](https://github.com/schneidmaster/action-cable-react-example-coffee).)

@@ -125,0 +128,0 @@ ## Contributing

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

module.exports = '0.1.0'
module.exports = '0.1.1'
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