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

@shopify/react-idle

Package Overview
Dependencies
Maintainers
19
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shopify/react-idle - npm Package Compare versions

Comparing version 1.1.7 to 2.0.0

44

build/cjs/hooks.js

@@ -1,25 +0,17 @@

"use strict";
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.useIdleCallback = useIdleCallback;
Object.defineProperty(exports, '__esModule', { value: true });
var _react = require("react");
var react = require('react');
var types = require('./types.js');
var _types = require("./types.js");
function useIdleCallback(callback) {
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
_ref$unsupportedBehav = _ref.unsupportedBehavior,
unsupportedBehavior = _ref$unsupportedBehav === void 0 ? _types.UnsupportedBehavior.AnimationFrame : _ref$unsupportedBehav;
var handle = (0, _react.useRef)(null);
(0, _react.useEffect)(function () {
function useIdleCallback(callback, {
unsupportedBehavior = types.UnsupportedBehavior.AnimationFrame
} = {}) {
const handle = react.useRef(null);
react.useEffect(() => {
if ('requestIdleCallback' in window) {
handle.current = window.requestIdleCallback(function () {
return callback();
});
} else if (unsupportedBehavior === _types.UnsupportedBehavior.AnimationFrame) {
handle.current = window.requestAnimationFrame(function () {
handle.current = window.requestIdleCallback(() => callback());
} else if (unsupportedBehavior === types.UnsupportedBehavior.AnimationFrame) {
handle.current = window.requestAnimationFrame(() => {
callback();

@@ -31,4 +23,6 @@ });

return function () {
var currentHandle = handle.current;
return () => {
const {
current: currentHandle
} = handle;
handle.current = null;

@@ -42,3 +36,3 @@

window.cancelIdleCallback(currentHandle);
} else if (unsupportedBehavior === _types.UnsupportedBehavior.AnimationFrame) {
} else if (unsupportedBehavior === types.UnsupportedBehavior.AnimationFrame) {
window.cancelAnimationFrame(currentHandle);

@@ -48,2 +42,4 @@ }

}, [callback, unsupportedBehavior]);
}
}
exports.useIdleCallback = useIdleCallback;

@@ -1,39 +0,18 @@

"use strict";
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _exportNames = {
useIdleCallback: true,
OnIdle: true
};
Object.defineProperty(exports, "useIdleCallback", {
enumerable: true,
get: function get() {
return _hooks.useIdleCallback;
}
});
Object.defineProperty(exports, "OnIdle", {
enumerable: true,
get: function get() {
return _OnIdle.OnIdle;
}
});
Object.defineProperty(exports, '__esModule', { value: true });
var _types = require("./types.js");
var types = require('./types.js');
var hooks = require('./hooks.js');
var OnIdle = require('./OnIdle.js');
Object.keys(_types).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _types[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _types[key];
}
});
});
var _hooks = require("./hooks.js");
var _OnIdle = require("./OnIdle.js");
Object.defineProperty(exports, 'UnsupportedBehavior', {
enumerable: true,
get: function () {
return types.UnsupportedBehavior;
}
});
exports.useIdleCallback = hooks.useIdleCallback;
exports.OnIdle = OnIdle.OnIdle;

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

"use strict";
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.OnIdle = OnIdle;
Object.defineProperty(exports, '__esModule', { value: true });
var _hooks = require("./hooks.js");
var hooks = require('./hooks.js');
function OnIdle(_ref) {
var perform = _ref.perform,
unsupportedBehavior = _ref.unsupportedBehavior;
(0, _hooks.useIdleCallback)(perform, {
unsupportedBehavior: unsupportedBehavior
function OnIdle({
perform,
unsupportedBehavior
}) {
hooks.useIdleCallback(perform, {
unsupportedBehavior
});
return null;
}
}
exports.OnIdle = OnIdle;

@@ -1,9 +0,6 @@

"use strict";
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, '__esModule', { value: true });
exports.UnsupportedBehavior = void 0;
var UnsupportedBehavior;
exports.UnsupportedBehavior = UnsupportedBehavior;

@@ -13,2 +10,2 @@ (function (UnsupportedBehavior) {

UnsupportedBehavior[UnsupportedBehavior["AnimationFrame"] = 1] = "AnimationFrame";
})(UnsupportedBehavior || (exports.UnsupportedBehavior = UnsupportedBehavior = {}));
})(exports.UnsupportedBehavior || (exports.UnsupportedBehavior = {}));

@@ -10,2 +10,8 @@ # Changelog

## 2.0.0 - 2021-05-21
### Breaking Change
- Update minimum supported node version to 12.14.0. Add engines field to help enforce usage of this version. [#1906](https://github.com/Shopify/quilt/pull/1906)
## 1.1.4 - 2021-04-13

@@ -12,0 +18,0 @@

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

module.exports = require("./build/node/index.js");
module.exports = require("./build/cjs/index.js");
{
"name": "@shopify/react-idle",
"version": "1.1.7",
"version": "2.0.0",
"license": "MIT",

@@ -23,5 +23,8 @@ "description": "Utilities for working with idle callbacks in React",

"homepage": "https://github.com/Shopify/quilt/blob/main/packages/react-idle/README.md",
"engines": {
"node": ">=12.14.0"
},
"dependencies": {
"@shopify/async": "^2.2.6",
"@shopify/useful-types": "^2.4.2"
"@shopify/async": "^3.0.0",
"@shopify/useful-types": "^3.0.0"
},

@@ -49,3 +52,3 @@ "peerDependencies": {

},
"gitHead": "4324f27f72ae7b1800ec6bde9087af4ed89b3833"
"gitHead": "40de4af181104f298cbab42d2d3d68e228a9a31a"
}

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

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