Socket
Socket
Sign inDemoInstall

@harelpls/use-pusher

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@harelpls/use-pusher - npm Package Compare versions

Comparing version 3.0.8 to 3.1.0

49

dist/index.es.js
import React, { useRef, useEffect, useContext, useState, useCallback } from 'react';
import PusherClass from 'pusher-js';
import Pusher from 'pusher-js';

@@ -173,4 +173,9 @@ function _extends() {

if (auth) config.auth = auth;
var pusherClientRef = useRef();
var pusherClientRef = useRef(); // track config for comparison
var previousConfig = useRef();
useEffect(function () {
previousConfig.current = config;
});
useEffect(function () {
// if client exists and options are the same, skip.

@@ -185,3 +190,3 @@ if (dequal(previousConfig.current, config) && pusherClientRef.current !== undefined) {

if (!defer) {
pusherClientRef.current = new PusherClass(clientKey, config);
pusherClientRef.current = new Pusher(clientKey, config);
}

@@ -192,9 +197,3 @@

};
}, [clientKey, config, defer, pusherClientRef]); // track config for comparison
var previousConfig = useRef();
useEffect(function () {
previousConfig.current = config;
});
console.log('shouldnt be run');
}, [clientKey, config, defer, pusherClientRef]);
return React.createElement(PusherContext.Provider, _extends({

@@ -265,4 +264,4 @@ value: {

// errors for missing arguments
invariant_1(channelName, "channelName required to subscribe to a channel");
invariant_1(channelName.includes("presence-"), "Presence channels should use prefix 'presence-' in their name. Use the useChannel hook instead.");
invariant_1(channelName, 'channelName required to subscribe to a channel');
invariant_1(channelName.includes('presence-'), "Presence channels should use prefix 'presence-' in their name. Use the useChannel hook instead.");
// Get regular channel functionality

@@ -307,5 +306,5 @@ var _a = useState({}), members = _a[0], setMembers = _a[1];

// bind to all member addition/removal events
channel.bind("pusher:subscription_succeeded", handleSubscriptionSuccess);
channel.bind("pusher:member_added", handleAdd);
channel.bind("pusher:member_removed", handleRemove);
channel.bind('pusher:subscription_succeeded', handleSubscriptionSuccess);
channel.bind('pusher:member_added', handleAdd);
channel.bind('pusher:member_removed', handleRemove);
// set any members that already existed on the channel

@@ -320,5 +319,5 @@ if (channel.members) {

if (channel) {
channel.unbind("pusher:subscription_succeeded", handleSubscriptionSuccess);
channel.unbind("pusher:member_added", handleAdd);
channel.unbind("pusher:member_removed", handleRemove);
channel.unbind('pusher:subscription_succeeded', handleSubscriptionSuccess);
channel.unbind('pusher:member_added', handleAdd);
channel.unbind('pusher:member_removed', handleRemove);
}

@@ -331,3 +330,3 @@ };

members: members,
myID: myID
myID: myID,
};

@@ -402,7 +401,7 @@ }

channel &&
invariant_1(channel.name.match(/(private-|presence-)/gi), "Channel pass wasn't private or presence channel. Client events only work on these types of channels.");
invariant_1(channel.name.match(/(private-|presence-)/gi), "Channel provided to useClientTrigger wasn't private or presence channel. Client events only work on these types of channels.");
// memoize trigger so it's not being created every render
var trigger = useCallback(function (eventName, data) {
if (data === void 0) { data = {}; }
invariant_1(eventName, "Must pass event name to trigger a client event.");
invariant_1(eventName, 'Must pass event name to trigger a client event.');
channel && channel.trigger(eventName, data);

@@ -416,3 +415,3 @@ }, [channel]);

this.callbacks = {};
this.name = name || "channel";
this.name = name || 'channel';
}

@@ -453,4 +452,4 @@ /**

function PusherPresenceChannelMock(name) {
var _this = _super.call(this, name ? name : "presence-") || this;
_this.members = { members: {}, myID: "0a" };
var _this = _super.call(this, name ? name : 'presence-') || this;
_this.members = { members: {}, myID: '0a' };
return _this;

@@ -474,3 +473,3 @@ }

if (!this.channels[name]) {
this.channels[name] = name.includes("-presence")
this.channels[name] = name.includes('presence-')
? new PusherPresenceChannelMock(name)

@@ -477,0 +476,0 @@ : new PusherChannelMock(name);

@@ -9,3 +9,3 @@ 'use strict';

var React__default = _interopDefault(React);
var PusherClass = _interopDefault(require('pusher-js'));
var Pusher = _interopDefault(require('pusher-js'));

@@ -181,4 +181,9 @@ function _extends() {

if (auth) config.auth = auth;
var pusherClientRef = React.useRef();
var pusherClientRef = React.useRef(); // track config for comparison
var previousConfig = React.useRef();
React.useEffect(function () {
previousConfig.current = config;
});
React.useEffect(function () {
// if client exists and options are the same, skip.

@@ -193,3 +198,3 @@ if (dequal(previousConfig.current, config) && pusherClientRef.current !== undefined) {

if (!defer) {
pusherClientRef.current = new PusherClass(clientKey, config);
pusherClientRef.current = new Pusher(clientKey, config);
}

@@ -200,9 +205,3 @@

};
}, [clientKey, config, defer, pusherClientRef]); // track config for comparison
var previousConfig = React.useRef();
React.useEffect(function () {
previousConfig.current = config;
});
console.log('shouldnt be run');
}, [clientKey, config, defer, pusherClientRef]);
return React__default.createElement(PusherContext.Provider, _extends({

@@ -273,4 +272,4 @@ value: {

// errors for missing arguments
invariant_1(channelName, "channelName required to subscribe to a channel");
invariant_1(channelName.includes("presence-"), "Presence channels should use prefix 'presence-' in their name. Use the useChannel hook instead.");
invariant_1(channelName, 'channelName required to subscribe to a channel');
invariant_1(channelName.includes('presence-'), "Presence channels should use prefix 'presence-' in their name. Use the useChannel hook instead.");
// Get regular channel functionality

@@ -315,5 +314,5 @@ var _a = React.useState({}), members = _a[0], setMembers = _a[1];

// bind to all member addition/removal events
channel.bind("pusher:subscription_succeeded", handleSubscriptionSuccess);
channel.bind("pusher:member_added", handleAdd);
channel.bind("pusher:member_removed", handleRemove);
channel.bind('pusher:subscription_succeeded', handleSubscriptionSuccess);
channel.bind('pusher:member_added', handleAdd);
channel.bind('pusher:member_removed', handleRemove);
// set any members that already existed on the channel

@@ -328,5 +327,5 @@ if (channel.members) {

if (channel) {
channel.unbind("pusher:subscription_succeeded", handleSubscriptionSuccess);
channel.unbind("pusher:member_added", handleAdd);
channel.unbind("pusher:member_removed", handleRemove);
channel.unbind('pusher:subscription_succeeded', handleSubscriptionSuccess);
channel.unbind('pusher:member_added', handleAdd);
channel.unbind('pusher:member_removed', handleRemove);
}

@@ -339,3 +338,3 @@ };

members: members,
myID: myID
myID: myID,
};

@@ -410,7 +409,7 @@ }

channel &&
invariant_1(channel.name.match(/(private-|presence-)/gi), "Channel pass wasn't private or presence channel. Client events only work on these types of channels.");
invariant_1(channel.name.match(/(private-|presence-)/gi), "Channel provided to useClientTrigger wasn't private or presence channel. Client events only work on these types of channels.");
// memoize trigger so it's not being created every render
var trigger = React.useCallback(function (eventName, data) {
if (data === void 0) { data = {}; }
invariant_1(eventName, "Must pass event name to trigger a client event.");
invariant_1(eventName, 'Must pass event name to trigger a client event.');
channel && channel.trigger(eventName, data);

@@ -424,3 +423,3 @@ }, [channel]);

this.callbacks = {};
this.name = name || "channel";
this.name = name || 'channel';
}

@@ -461,4 +460,4 @@ /**

function PusherPresenceChannelMock(name) {
var _this = _super.call(this, name ? name : "presence-") || this;
_this.members = { members: {}, myID: "0a" };
var _this = _super.call(this, name ? name : 'presence-') || this;
_this.members = { members: {}, myID: '0a' };
return _this;

@@ -482,3 +481,3 @@ }

if (!this.channels[name]) {
this.channels[name] = name.includes("-presence")
this.channels[name] = name.includes('presence-')
? new PusherPresenceChannelMock(name)

@@ -485,0 +484,0 @@ : new PusherChannelMock(name);

{
"name": "@harelpls/use-pusher",
"version": "3.0.8",
"version": "3.1.0",
"description": "A wrapper around pusher-js for easy-as hooks in React.",

@@ -56,3 +56,2 @@ "author": "@mayteio",

"@types/jest": "^24.0.18",
"@types/pusher-js": "^4.2.2",
"@types/react": "^16.7.22",

@@ -59,0 +58,0 @@ "cross-env": "^5.2.0",

Sorry, the diff of this file is not supported yet

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