Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-live-chat-loader

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-live-chat-loader - npm Package Compare versions

Comparing version 0.0.17 to 0.0.18

16

dist/hooks/useChat.js

@@ -30,2 +30,3 @@ "use strict";

idlePeriod = _useContext.idlePeriod,
maxIdlePeriod = _useContext.maxIdlePeriod,
state = _useContext.state,

@@ -40,3 +41,6 @@ setState = _useContext.setState;

var idleCountThreshold = parseInt(idlePeriod, 10) / 50;
if (isNaN(idleCountThreshold)) return; // deadline.timeRemaining() has an upper limit of 50 milliseconds
var idleTimeout = parseInt(maxIdlePeriod, 10);
if (isNaN(idleCountThreshold) || isNaN(idleTimeout)) return;
var options = {};
if (idleTimeout) options.timeout = idleTimeout; // deadline.timeRemaining() has an upper limit of 50 milliseconds
// We want to ensure the page has been idle for a significant period of time

@@ -47,3 +51,3 @@ // Therefore we count consecutive maximum timeRemaining counts and load chat when we reach our threshold

var scheduleLoad = function scheduleLoad(deadline) {
var scheduleLoadChat = function scheduleLoadChat(deadline) {
if (idleCounts > idleCountThreshold) {

@@ -56,7 +60,7 @@ loadChat({

idleCounts++;
requestIdleCallback(scheduleLoad);
requestIdleCallback(scheduleLoadChat, options);
} else {
// some activity has occurred, reset idle count
idleCounts = 0;
requestIdleCallback(scheduleLoad);
requestIdleCallback(scheduleLoadChat, options);
}

@@ -66,3 +70,3 @@ };

if (requestIdleCallback) {
requestIdleCallback(scheduleLoad);
requestIdleCallback(scheduleLoadChat, options);
} else {

@@ -73,3 +77,3 @@ setTimeout(function () {

});
}, idleCountThreshold);
}, maxIdlePeriod || idleCountThreshold * 50);
}

@@ -76,0 +80,0 @@ }, []);

@@ -60,2 +60,4 @@ "use strict";

idlePeriod = _ref$idlePeriod === void 0 ? 2000 : _ref$idlePeriod,
_ref$maxIdlePeriod = _ref.maxIdlePeriod,
maxIdlePeriod = _ref$maxIdlePeriod === void 0 ? 10000 : _ref$maxIdlePeriod,
children = _ref.children;

@@ -72,2 +74,3 @@

idlePeriod: idlePeriod,
maxIdlePeriod: maxIdlePeriod,
state: state,

@@ -74,0 +77,0 @@ setState: setState

{
"name": "react-live-chat-loader",
"version": "0.0.17",
"version": "0.0.18",
"description": "Implement live chat in your react app without taking a performance hit.",

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

@@ -28,12 +28,7 @@ # React Live Chat Loader

Under the hood React Live Chat Loader makes use of `requestIdleCallback`, but
there is no timeout option because if the main thread is not quiet for a
significant amount of time the should not be blocked with a third party script.
Under the hood React Live Chat Loader makes use of `requestIdleCallback` to
track how long the page has been idle for and checks if the user is on a slow
connection (using `navigator.connection.effectiveType`) or has data-saver enabled
(using `navigator.connection.saveData`) to prevent loading.
In addition to waiting for the page to become idle, React Live Chat Loader
checks if the user isn't on a slow connection (using
`navigator.connection.effectiveType`) or has data-saver enabled (using
`navigator.connection.saveData`) to prevent loading the widget when the page
has been idle.
### Installation

@@ -124,2 +119,6 @@

`2000`. Set to `0` to never load.
- `maxIdlePeriod`: Maximum duration to wait in ms to load the provider in the
event `idlePeriod` is never detected. Default is `5000`. Set to `0` to never
timeout. This value is used in browsers that don't support
`requestIdleCallback`.

@@ -126,0 +125,0 @@ ### Providers

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