@stackmeister/react-use-document-visibility
Advanced tools
| import useDocumentVisibility from './useDocumentVisibility'; | ||
| export type { UseDocumentVisibilityResult } from './useDocumentVisibility'; | ||
| export default useDocumentVisibility; |
+10
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| exports.default = void 0; | ||
| var _useDocumentVisibility = _interopRequireDefault(require("./useDocumentVisibility")); | ||
| function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
| var _default = _useDocumentVisibility.default; | ||
| exports.default = _default; |
| export declare type UseDocumentVisibilityResult = boolean; | ||
| declare const useDocumentVisibility: () => UseDocumentVisibilityResult; | ||
| export default useDocumentVisibility; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| exports.default = void 0; | ||
| var _react = require("react"); | ||
| function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | ||
| function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
| function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
| function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
| function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
| function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
| var useDocumentVisibility = function useDocumentVisibility() { | ||
| var _useState = (0, _react.useState)(function () { | ||
| var _globalThis$document$, _globalThis$document; | ||
| return (_globalThis$document$ = (_globalThis$document = globalThis.document) === null || _globalThis$document === void 0 ? void 0 : _globalThis$document.hidden) !== null && _globalThis$document$ !== void 0 ? _globalThis$document$ : false; | ||
| }), | ||
| _useState2 = _slicedToArray(_useState, 2), | ||
| hidden = _useState2[0], | ||
| setHidden = _useState2[1]; | ||
| (0, _react.useEffect)(function () { | ||
| var _globalThis$addEventL; | ||
| var onVisibilityChange = function onVisibilityChange() { | ||
| var _globalThis$document$2, _globalThis$document2; | ||
| return setHidden((_globalThis$document$2 = (_globalThis$document2 = globalThis.document) === null || _globalThis$document2 === void 0 ? void 0 : _globalThis$document2.hidden) !== null && _globalThis$document$2 !== void 0 ? _globalThis$document$2 : false); | ||
| }; | ||
| (_globalThis$addEventL = globalThis.addEventListener) === null || _globalThis$addEventL === void 0 ? void 0 : _globalThis$addEventL.call(globalThis, 'visibilitychange', onVisibilityChange); | ||
| return function () { | ||
| var _globalThis$removeEve; | ||
| (_globalThis$removeEve = globalThis.removeEventListener) === null || _globalThis$removeEve === void 0 ? void 0 : _globalThis$removeEve.call(globalThis, 'visibilitychange', onVisibilityChange); | ||
| }; | ||
| }, []); | ||
| return hidden; | ||
| }; | ||
| var _default = useDocumentVisibility; | ||
| exports.default = _default; |
+2
-2
| { | ||
| "name": "@stackmeister/react-use-document-visibility", | ||
| "version": "0.1.3", | ||
| "version": "0.1.4", | ||
| "license": "MIT", | ||
@@ -45,3 +45,3 @@ "main": "cjs/index.js", | ||
| }, | ||
| "gitHead": "10afb42327a036a31985be857f0a68c765e99a66" | ||
| "gitHead": "7cda2f247123d83cf1a4c697dc6748885d336561" | ||
| } |
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
7145
121.76%7
133.33%51
Infinity%0
-100%