{"version":3,"sources":["../../src/utils.js","../../src/MessageChannel/methods/broadcastChannel.js","../../src/MessageChannel/ObliviousSet.js","../../src/MessageChannel/methods/localStorage.js","../../src/MessageChannel/methods/simulate.js","../../src/MessageChannel/methodChooser.js","../../src/MessageChannel/MessageChannel.js","../../src/MessageChannel/leaderElection.js","../../src/TabManager.js","../../src/IdleTimer.js","../../src/useIdleTimer.js","../node_modules/@babel/runtime/helpers/classCallCheck.js","../node_modules/@babel/runtime/helpers/createClass.js","../node_modules/@babel/runtime/helpers/inherits.js","../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js","../node_modules/@babel/runtime/helpers/getPrototypeOf.js","../node_modules/@babel/runtime/helpers/asyncToGenerator.js"],"names":["IS_BROWSER","window","DEFAULT_ELEMENT","document","DEFAULT_EVENTS","debounced","fn","delay","timerId","result","args","clearTimeout","setTimeout","cancel","throttled","lastCall","now","Date","getTime","lastMs","additional","microSeconds","ms","randomToken","Math","random","toString","substring","sleep","time","Promise","resolve","create","channelName","state","messagesCallback","bc","BroadcastChannel","onmessage","msg","data","close","channelState","onMessage","postMessage","messageJson","err","reject","canBeUsed","type","averageResponseTime","ObliviousSet","ttl","set","Set","timeMap","Map","value","this","has","add","_removeTooOldValues","clear","olderThen","iterator","Symbol","next","get","getLocalStorage","localStorage","e","addStorageEventListener","key","listener","ev","JSON","parse","newValue","addEventListener","ls","setItem","removeItem","options","Error","uuid","eMIs","removeTimeout","msgObj","token","messagesCallbackTime","removeEventListener","writeObj","stringify","createEvent","initEvent","dispatchEvent","userAgent","navigator","toLowerCase","includes","defaultTime","SIMULATE_CHANNELS","name","Array","from","filter","channel","forEach","METHODS","BroadcastChannelMethod","LocalStorageMethod","chooseMethod","SimulateMethod","method","find","m","useMethod","map","MessageChannel","closed","_isListening","_onMessageListener","_addEventListeners","message","internal","_unSendMessagePromises","_beforeClose","_preparePromises","_prepareChannel","_post","listenObj","_removeListenerObject","_addListenerObject","obj","awaitPrepare","then","all","_this","_state","messageChannel","sendPromise","maybePromise","s","_hasMessageListeners","length","push","listenerFn","o","LeaderElection","_channel","_options","isLeader","isDead","_isApplying","_reApply","_unloadFns","_listeners","_intervals","_duplicateListeners","_duplicateCalled","_onBeforeDie","a","unloadFn","die","stopCriteria","handleMessage","context","_this2","action","_sendMessage","responseTime","leaderElector","isLeaderListener","success","applyOnce","_awaitLeadershipPromise","resolved","finish","clearInterval","interval","whenDeathListener","setInterval","fallbackInterval","onBeforeDie","_this3","uFn","msgJson","postInternal","TabManager","emitOnAllTabs","callbacks","start","reset","pause","resume","elector","_leaderElector","registry","leader","allIdle","awaitLeadership","id","idle","active","onIdle","onActive","isIdle","Object","values","every","v","send","isActive","some","onDuplicate","isAllIdle","setAllIdle","bool","IdleTimer","Component","props","oldDate","lastActive","lastIdle","idleTime","remaining","pageX","pageY","tId","eventsBound","callbackRefs","debounce","throttle","_onAction","onAction","eventsThrottle","handleEvent","_handleEvent","bind","startOnMount","startManually","_toggleIdleState","getRemainingTime","getElapsedTime","getLastActiveTime","getLastIdleTime","getTotalIdleTime","getTotalActiveTime","_setupTabManager","_bindEvents","prevProps","_unbindEvents","timeout","manager","console","error","children","crossTab","assign","element","events","passive","capture","force","setState","prevState","_this4","stopOnIdle","elapsedTimeSinceLastActive","remote","timeLeft","useIdleTimer","useRef","firstLoad","_timeout","emitOnIdle","emitOnActive","emitOnAction","useEffect","current","intermediateOnAction","useMemo","callOnAction","nextIdle","eventsWereBound","propTypes","PropTypes","number","arrayOf","string","func","oneOfType","object","shape","oneOf","defaultProps","module","exports","instance","Constructor","TypeError","__esModule","_defineProperties","target","i","descriptor","enumerable","configurable","writable","defineProperty","protoProps","staticProps","prototype","setPrototypeOf","subClass","superClass","constructor","_typeof","assertThisInitialized","self","call","_getPrototypeOf","getPrototypeOf","__proto__","asyncGeneratorStep","gen","_next","_throw","arg","info","done","arguments","apply","undefined"],"mappings":"kXAMaA,EACuD,YAA/C,oBAAXC,4BAA8CA,OAArB,Y,MAAA,GAAqBA,SAO3CC,E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AMrT,GAEzB,SAAS4T,EAAM7Q,GACb2Q,EAAmBC,EAAKtS,EAASgB,EAAQuR,EAAOC,EAAQ,OAAQ9Q,GAGlE,SAAS8Q,EAAOzR,GACdsR,EAAmBC,EAAKtS,EAASgB,EAAQuR,EAAOC,EAAQ,QAASzR,GAGnEwR,OAAMO,QAKwBrC,EAAOC,QAAQI,YAAa,EAAML,EAAOC,QAAiB,QAAID,EAAOC","file":"static/js/12.24beabe6.chunk.js","sourcesContent":["/**\n * Determine if we are in a browser\n * or a server environment\n * @type {Boolean}\n * @private\n */\nexport const IS_BROWSER =\n (typeof window === 'undefined' ? 'undefined' : typeof window) === 'object'\n\n/**\n * Default element to listen for events on\n * @type {Object}\n * @private\n */\nexport const DEFAULT_ELEMENT = IS_BROWSER ? document : {}\n\n/**\n * The default events to determine activity\n * @type {Array}\n * @private\n */\nexport const DEFAULT_EVENTS = [\n 'mousemove',\n 'keydown',\n 'wheel',\n 'DOMMouseScroll',\n 'mousewheel',\n 'mousedown',\n 'touchstart',\n 'touchmove',\n 'MSPointerDown',\n 'MSPointerMove',\n 'visibilitychange'\n]\n\n/**\n * Creates a debounced function that delays invoking func until\n * after delay milliseconds has elapsed since the last time the\n * debounced function was invoked.\n * @name debounced\n * @param {Function} fn Function to debounce\n * @param {Number} delay How long to wait\n * @return {Function} Executed Function\n * @private\n **/\nexport function debounced (fn, delay) {\n let timerId\n function result (...args) {\n if (timerId) {\n clearTimeout(timerId)\n }\n timerId = setTimeout(() => {\n fn(...args)\n timerId = null\n }, delay)\n }\n\n result.cancel = function () {\n clearTimeout(timerId)\n }\n\n return result\n}\n\n/**\n * Creates a throttled function that only invokes func at most\n * once per every wait milliseconds.\n * @name throttled\n * @param {Function} fn Function to debounce\n * @param {Number} delay How long to wait\n * @return {Function} Executed Function\n * @private\n **/\nexport function throttled (fn, delay) {\n let lastCall = 0\n return function (...args) {\n const now = new Date().getTime()\n if (now - lastCall < delay) {\n return\n }\n lastCall = now\n return fn(...args)\n }\n}\n\nlet lastMs = 0\nlet additional = 0\n\n/**\n * Returns current time in microseconds.\n *\n * @returns {Number} current time in microseconds\n * @private\n */\nexport function microSeconds () {\n const ms = new Date().getTime()\n if (ms === lastMs) {\n additional++\n return ms * 1000 + additional\n } else {\n lastMs = ms\n additional = 0\n return ms * 1000\n }\n}\n\n/**\n * Generate and return a random token.\n *\n * @returns {String} Random token.\n * @private\n */\nexport function randomToken () {\n return Math.random().toString(36).substring(2)\n}\n\n/**\n * Checks if a js object is a promise.\n *\n * @param {*} obj Any javascript object.\n * @returns {Boolean} Wether or not this object is a promise.\n */\nexport function isPromise (obj) {\n if (obj && typeof obj.then === 'function') {\n /* istanbul ignore next */\n return true\n } else {\n return false\n }\n}\n\n/**\n * Sleeps for x amount of milliseconds.\n *\n * @param {Number} time Amount of time in milliseconds.\n * @returns {Promise}\n * @private\n */\nexport function sleep (time = 0) {\n return new Promise(resolve => setTimeout(resolve, time))\n}\n\n/**\n * Get the current timestamp.\n *\n * @returns {Number}\n * @private\n */\nexport function now () {\n return new Date().getTime()\n}\n\n/**\n * Waits until the given function returns true\n * @param {function} fn\n * @return {Promise}\n */\nexport function waitUntil (fn, timeout = 0, interval = 20) {\n let timedOut = false\n let ok = false\n\n /* istanbul ignore next */\n if (timeout !== 0) {\n sleep(timeout).then(() => {\n timedOut = true\n })\n }\n\n return new Promise((resolve, reject) => {\n const runLoop = () => {\n if (ok) {\n resolve()\n return\n }\n /* istanbul ignore next */\n if (timedOut) {\n reject(new Error(`❌ waitUntil reached timeout of ${timeout}ms`))\n return\n }\n sleep(interval).then(() => {\n ok = fn()\n runLoop()\n })\n }\n runLoop()\n })\n}\n","/* eslint-env browser */\nimport { microSeconds } from '../../utils'\n\nexport const type = 'broadcastChannel'\n\nexport function create (channelName) {\n const state = {\n messagesCallback: null,\n bc: new BroadcastChannel(channelName)\n }\n\n state.bc.onmessage = msg => {\n if (state.messagesCallback) {\n state.messagesCallback(msg.data)\n }\n }\n\n return state\n}\n\nexport function close (channelState) {\n channelState.bc.close()\n}\n\nexport function postMessage (channelState, messageJson) {\n try {\n channelState.bc.postMessage(messageJson, false)\n return Promise.resolve()\n } catch (err) {\n /* istanbul ignore next */\n return Promise.reject(err)\n }\n}\n\nexport function onMessage (channelState, fn) {\n channelState.messagesCallback = fn\n}\n\nexport function canBeUsed () {\n if (typeof BroadcastChannel === 'function') {\n return true\n } else {\n /* istanbul ignore next */\n return false\n }\n}\n\nexport function averageResponseTime () {\n return 150\n}\n\nexport default {\n create,\n close,\n onMessage,\n postMessage,\n canBeUsed,\n type,\n averageResponseTime,\n microSeconds\n}\n","import { now } from '../utils'\n\nexport default class ObliviousSet {\n constructor (ttl = 1000 * 60) {\n this.ttl = ttl\n this.set = new Set()\n this.timeMap = new Map()\n }\n\n has (value) {\n return this.set.has(value)\n }\n\n add (value) {\n this.timeMap.set(value, now())\n this.set.add(value)\n this._removeTooOldValues()\n }\n\n clear () {\n this.set.clear()\n this.timeMap.clear()\n }\n\n _removeTooOldValues () {\n const olderThen = now() - this.ttl\n const iterator = this.set[Symbol.iterator]()\n\n while (true) {\n const value = iterator.next().value\n if (!value) return // no more elements\n const time = this.timeMap.get(value)\n if (time < olderThen) {\n this.timeMap.delete(value)\n this.set.delete(value)\n } else {\n // We reached a value that is not old enough\n return\n }\n }\n }\n}\n","import ObliviousSet from '../ObliviousSet'\n\nimport {\n randomToken,\n microSeconds\n} from '../../utils'\n\nexport const type = 'localStorage'\n\n/**\n * Returns local storage instance\n */\nexport function getLocalStorage () {\n let localStorage\n if (typeof window === 'undefined') return null\n try {\n localStorage = window.localStorage\n localStorage = window['ie8-eventlistener/storage'] || window.localStorage\n } catch (e) {\n // New versions of Firefox throw a Security exception\n // if cookies are disabled. See\n // https://bugzilla.mozilla.org/show_bug.cgi?id=1028153\n }\n return localStorage\n}\n\nexport function storageKey (channelName) {\n return channelName\n}\n\n/**\n* writes the new message to the storage\n* and fires the storage-event so other readers can find it\n*/\nexport function postMessage (channelState, messageJson) {\n return new Promise(resolve => {\n const key = storageKey(channelState.channelName)\n const writeObj = {\n token: randomToken(),\n time: new Date().getTime(),\n data: messageJson,\n uuid: channelState.uuid\n }\n const value = JSON.stringify(writeObj)\n getLocalStorage().setItem(key, value)\n\n /**\n * StorageEvent does not fire the 'storage' event\n * in the window that changes the state of the local storage.\n * So we fire it manually\n */\n const ev = document.createEvent('Event')\n ev.initEvent('storage', true, true)\n ev.key = key\n ev.newValue = value\n window.dispatchEvent(ev)\n\n resolve()\n })\n}\n\nexport function addStorageEventListener (channelName, fn) {\n const key = storageKey(channelName)\n const listener = ev => {\n if (ev.key === key) {\n fn(JSON.parse(ev.newValue))\n }\n }\n window.addEventListener('storage', listener)\n return listener\n}\nexport function removeStorageEventListener (listener) {\n window.removeEventListener('storage', listener)\n}\n\nexport function create (channelName, options = {}) {\n if (!canBeUsed()) {\n /* istanbul ignore next */\n throw new Error('❌ localStorage cannot be used.')\n }\n\n const uuid = randomToken()\n\n /**\n * eMIs\n * contains all messages that have been emitted before\n * @type {ObliviousSet}\n */\n const eMIs = new ObliviousSet(options.removeTimeout)\n\n const state = {\n channelName,\n uuid,\n eMIs // emittedMessagesIds\n }\n\n state.listener = addStorageEventListener(\n channelName,\n (msgObj) => {\n if (!state.messagesCallback) return // no listener\n if (msgObj.uuid === uuid) return // own message\n if (!msgObj.token || eMIs.has(msgObj.token)) return // already emitted\n if (msgObj.data.time && msgObj.data.time < state.messagesCallbackTime) return // too old\n\n eMIs.add(msgObj.token)\n state.messagesCallback(msgObj.data)\n }\n )\n\n return state\n}\n\nexport function close (channelState) {\n removeStorageEventListener(channelState.listener)\n}\n\nexport function onMessage (channelState, fn, time) {\n channelState.messagesCallbackTime = time\n channelState.messagesCallback = fn\n}\n\nexport function canBeUsed () {\n const ls = getLocalStorage()\n\n if (!ls) return false\n\n try {\n const key = '__check'\n ls.setItem(key, 'works')\n ls.removeItem(key)\n } catch (e) {\n // Safari 10 in private mode will not allow write access to local\n // storage and fail with a QuotaExceededError. See\n // https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API#Private_Browsing_Incognito_modes\n\n /* istanbul ignore next */\n return false\n }\n\n return true\n}\n\n/* istanbul ignore next */\nexport function averageResponseTime () {\n const defaultTime = 120\n const userAgent = navigator.userAgent.toLowerCase()\n if (userAgent.includes('safari') && !userAgent.includes('chrome')) {\n // safari is much slower so this time is higher\n return defaultTime * 2\n }\n return defaultTime\n}\n\nexport default {\n create,\n close,\n onMessage,\n postMessage,\n canBeUsed,\n type,\n averageResponseTime,\n microSeconds\n}\n","import { microSeconds } from '../../utils'\n\nexport const type = 'simulate'\n\nconst SIMULATE_CHANNELS = new Set()\n\nexport function create (channelName) {\n const state = {\n name: channelName,\n messagesCallback: null\n }\n SIMULATE_CHANNELS.add(state)\n\n return state\n}\n\nexport function close (channelState) {\n SIMULATE_CHANNELS.delete(channelState)\n}\n\nexport function postMessage (channelState, messageJson) {\n return new Promise(resolve => setTimeout(() => {\n const channelArray = Array.from(SIMULATE_CHANNELS)\n channelArray\n .filter(channel => channel.name === channelState.name)\n .filter(channel => channel !== channelState)\n .filter(channel => !!channel.messagesCallback)\n .forEach(channel => channel.messagesCallback(messageJson))\n resolve()\n }, 5))\n}\n\nexport function onMessage (channelState, fn) {\n channelState.messagesCallback = fn\n}\n\n/* istanbul ignore next */\nexport function canBeUsed () {\n return true\n}\n\n/* istanbul ignore next */\nexport function averageResponseTime () {\n return 5\n}\n\nexport default {\n create,\n close,\n onMessage,\n postMessage,\n canBeUsed,\n type,\n averageResponseTime,\n microSeconds\n}\n","import BroadcastChannelMethod from './methods/broadcastChannel'\nimport LocalStorageMethod from './methods/localStorage'\nimport SimulateMethod from './methods/simulate'\n\n// Order is important\nconst METHODS = [\n BroadcastChannelMethod,\n LocalStorageMethod\n]\n\nexport function chooseMethod (options = {}) {\n if (options.type) {\n // For testing\n if (options.type === 'simulate') {\n return SimulateMethod\n }\n\n // Chosen type\n const method = METHODS.find(m => m.type === options.type)\n if (!method) throw new Error(`❌ Method ${options.type} is not supported.`)\n else return method\n }\n\n const useMethod = METHODS.find(method => method.canBeUsed())\n\n /* istanbul ignore next */\n if (!useMethod) {\n throw new Error(`❌ No method found ${JSON.stringify(METHODS.map(m => m.type))}`)\n }\n return useMethod\n}\n","import { chooseMethod } from './methodChooser'\nimport { isPromise } from '../utils'\n\nexport class MessageChannel {\n constructor (name, options = {}) {\n this.name = name\n this.options = options\n this.method = chooseMethod(this.options)\n this.closed = false\n\n // isListening\n this._isListening = false\n\n /**\n * _onMessageListener\n * setting onmessage twice,\n * will overwrite the first listener\n */\n this._onMessageListener = null\n\n /**\n * _addEventListeners\n */\n this._addEventListeners = {\n message: [],\n internal: []\n }\n\n /**\n * Un send message promises\n * where the sending is still in progress\n * @type {Set}\n */\n this._unSendMessagePromises = new Set()\n\n /**\n * _beforeClose\n * array of promises that will be awaited\n * before the channel is closed\n */\n this._beforeClose = []\n\n /**\n * _preparePromise\n */\n this._preparePromises = null\n _prepareChannel(this)\n }\n\n postMessage (msg) {\n if (this.closed) {\n throw new Error(\n '❌ Cannot post message after channel has closed'\n )\n }\n return _post(this, 'message', msg)\n }\n\n postInternal (msg) {\n return _post(this, 'internal', msg)\n }\n\n set onmessage (fn) {\n const time = this.method.microSeconds()\n const listenObj = {\n time,\n fn\n }\n _removeListenerObject(this, 'message', this._onMessageListener)\n if (fn && typeof fn === 'function') {\n this._onMessageListener = listenObj\n _addListenerObject(this, 'message', listenObj)\n } else {\n /* istanbul ignore next */\n this._onMessageListener = null\n }\n }\n\n /* istanbul ignore next */\n get onmessage () {\n return this._onMessageListener\n }\n\n addEventListener (type, fn) {\n const time = this.method.microSeconds()\n const listenObj = {\n time,\n fn\n }\n _addListenerObject(this, type, listenObj)\n }\n\n removeEventListener (type, fn) {\n const obj = this._addEventListeners[type].find(obj => obj.fn === fn)\n _removeListenerObject(this, type, obj)\n }\n\n close () {\n if (this.closed) {\n return\n }\n this.closed = true\n const awaitPrepare = this._preparePromises ? this._preparePromises : Promise.resolve()\n\n this._onMessageListener = null\n this._addEventListeners.message = []\n\n return awaitPrepare\n // Wait until all current sending are processed\n .then(() => Promise.all(Array.from(this._unSendMessagePromises)))\n // Run before-close hooks\n .then(() => Promise.all(this._beforeClose.map(fn => fn())))\n // Close the channel\n .then(() => this.method.close(this._state))\n }\n\n get type () {\n return this.method.type\n }\n\n isClosed () {\n return this.closed\n }\n}\n\nfunction _post (messageChannel, type, msg) {\n const time = messageChannel.method.microSeconds()\n const msgObj = {\n time,\n type,\n data: msg\n }\n\n const awaitPrepare = messageChannel._preparePromises ? messageChannel._preparePromises : Promise.resolve()\n return awaitPrepare.then(() => {\n const sendPromise = messageChannel.method.postMessage(\n messageChannel._state,\n msgObj\n )\n\n // add/remove to un-send messages list\n messageChannel._unSendMessagePromises.add(sendPromise)\n sendPromise\n .catch()\n .then(() => messageChannel._unSendMessagePromises.delete(sendPromise))\n\n return sendPromise\n })\n}\n\nfunction _prepareChannel (channel) {\n const maybePromise = channel.method.create(channel.name, channel.options)\n /* istanbul ignore next */\n if (isPromise(maybePromise)) {\n channel._preparePromises = maybePromise\n maybePromise.then(s => {\n channel._state = s\n })\n } else {\n channel._state = maybePromise\n }\n}\n\nfunction _hasMessageListeners (channel) {\n if (channel._addEventListeners.message.length > 0) return true\n if (channel._addEventListeners.internal.length > 0) return true\n return false\n}\n\nfunction _addListenerObject (channel, type, obj) {\n channel._addEventListeners[type].push(obj)\n _startListening(channel)\n}\n\nfunction _removeListenerObject (channel, type, obj) {\n channel._addEventListeners[type] = channel._addEventListeners[type].filter(o => o !== obj)\n _stopListening(channel)\n}\n\nfunction _startListening (channel) {\n if (!channel._isListening && _hasMessageListeners(channel)) {\n // someone is listening, start subscribing\n\n const listenerFn = msgObj => {\n channel._addEventListeners[msgObj.type].forEach(obj => {\n if (msgObj.time >= obj.time) {\n obj.fn(msgObj.data)\n }\n })\n }\n\n const time = channel.method.microSeconds()\n if (channel._preparePromises) {\n /* istanbul ignore next */\n channel._preparePromises.then(() => {\n channel._isListening = true\n channel.method.onMessage(\n channel._state,\n listenerFn,\n time\n )\n })\n } else {\n channel._isListening = true\n channel.method.onMessage(\n channel._state,\n listenerFn,\n time\n )\n }\n }\n}\n\nfunction _stopListening (channel) {\n if (channel._isListening && !_hasMessageListeners(channel)) {\n // no one is listening, stop subscribing\n channel._isListening = false\n const time = channel.method.microSeconds()\n channel.method.onMessage(\n channel._state,\n null,\n time\n )\n }\n}\n","import { IS_BROWSER, sleep, randomToken } from '../utils'\n\nclass LeaderElection {\n constructor (channel, options) {\n this._channel = channel\n this._options = options\n\n this.isLeader = false\n this.isDead = false\n this.token = randomToken()\n\n this._isApplying = false\n this._reApply = false\n\n // things to clean up\n this._unloadFns = []\n this._listeners = []\n this._intervals = []\n this._duplicateListeners = () => { }\n this._duplicateCalled = false\n this._onBeforeDie = async () => {}\n\n const unloadFn = async () => this.die()\n\n if (IS_BROWSER) {\n window.addEventListener('beforeUnload', unloadFn)\n window.addEventListener('unload', unloadFn)\n\n this._unloadFns.push(['beforeUnload', unloadFn])\n this._unloadFns.push(['unload', unloadFn])\n }\n }\n\n applyOnce () {\n if (this.isLeader) return Promise.resolve(false)\n if (this.isDead) return Promise.resolve(false)\n\n // do nothing if already running\n if (this._isApplying) {\n this._reApply = true\n return Promise.resolve(false)\n }\n this._isApplying = true\n\n let stopCriteria = false\n const received = []\n\n const handleMessage = (msg) => {\n if (msg.context === 'leader' && msg.token !== this.token) {\n received.push(msg)\n\n if (msg.action === 'apply') {\n // Other is applying\n if (msg.token > this.token) {\n // Other has higher token, stop applying\n stopCriteria = true\n }\n }\n\n if (msg.action === 'tell') {\n // Other is already leader\n stopCriteria = true\n }\n }\n }\n this._channel.addEventListener('internal', handleMessage)\n\n return _sendMessage(this, 'apply') // send out that this one is applying\n .then(() => sleep(this._options.responseTime)) // let others time to respond\n .then(() => {\n if (stopCriteria) return Promise.reject(new Error())\n else return _sendMessage(this, 'apply')\n })\n .then(() => sleep(this._options.responseTime)) // let others time to respond\n .then(() => {\n if (stopCriteria) return Promise.reject(new Error())\n else return _sendMessage(this)\n })\n .then(() => beLeader(this)) // no one disagreed -> this one is now leader\n .then(() => true)\n .catch(() => false) // apply not successful\n .then(success => {\n this._channel.removeEventListener('internal', handleMessage)\n this._isApplying = false\n if (!success && this._reApply) {\n this._reApply = false\n return this.applyOnce()\n } else return success\n })\n }\n\n awaitLeadership () {\n if (\n !this._awaitLeadershipPromise\n ) {\n this._awaitLeadershipPromise = _awaitLeadershipOnce(this)\n }\n return this._awaitLeadershipPromise\n }\n\n set onDuplicate (fn) {\n this._duplicateListeners = fn\n }\n\n /* istanbul ignore next */\n get onDuplicate () {\n return this._duplicateListeners\n }\n\n set onBeforeDie (fn) {\n this._onBeforeDie = fn\n }\n\n /* istanbul ignore next */\n get onBeforeDie () {\n return this._onBeforeDie\n }\n\n async die () {\n if (this.isDead) return\n this.isDead = true\n\n await this.onBeforeDie()\n this._listeners.forEach(listener => this._channel.removeEventListener('internal', listener))\n this._intervals.forEach(interval => clearInterval(interval))\n this._unloadFns.forEach(uFn => {\n if (IS_BROWSER) {\n window.removeEventListener(uFn[0], uFn[1])\n }\n })\n return _sendMessage(this, 'death')\n }\n}\n\nfunction _awaitLeadershipOnce (leaderElector) {\n if (leaderElector.isLeader) return Promise.resolve()\n\n return new Promise(resolve => {\n let resolved = false\n\n function finish () {\n /* istanbul ignore next */\n if (resolved) {\n return\n }\n resolved = true\n clearInterval(interval)\n leaderElector._channel.removeEventListener('internal', whenDeathListener)\n resolve(true)\n }\n\n // try once now\n leaderElector.applyOnce().then(() => {\n if (leaderElector.isLeader) {\n finish()\n }\n })\n\n // try on fallbackInterval\n const interval = setInterval(() => {\n /* istanbul ignore next */\n leaderElector.applyOnce().then(() => {\n if (leaderElector.isLeader) {\n finish()\n }\n })\n }, leaderElector._options.fallbackInterval)\n leaderElector._intervals.push(interval)\n\n // try when other leader dies\n const whenDeathListener = msg => {\n if (msg.context === 'leader' && msg.action === 'death') {\n leaderElector.applyOnce().then(() => {\n if (leaderElector.isLeader) finish()\n })\n }\n }\n leaderElector._channel.addEventListener('internal', whenDeathListener)\n leaderElector._listeners.push(whenDeathListener)\n })\n}\n\n/**\n * Sends and internal message over the broadcast-channel\n */\nfunction _sendMessage (leaderElector, action) {\n const msgJson = {\n context: 'leader',\n action,\n token: leaderElector.token\n }\n return leaderElector._channel.postInternal(msgJson)\n}\n\nexport function beLeader (leaderElector) {\n leaderElector.isLeader = true\n\n const isLeaderListener = msg => {\n if (msg.context === 'leader' && msg.action === 'apply') {\n _sendMessage(leaderElector, 'tell')\n }\n\n if (msg.context === 'leader' && msg.action === 'tell' && !leaderElector._duplicateCalled) {\n /**\n * Another instance is also leader!\n * This can happen on rare events\n * like when the CPU is at 100% for long time\n * or the tabs are open very long and the browser throttles them.\n */\n leaderElector._duplicateCalled = true\n leaderElector._duplicateListeners() // message the lib user so the app can handle the problem\n _sendMessage(leaderElector, 'tell') // ensure other leader also knows the problem\n }\n }\n leaderElector._channel.addEventListener('internal', isLeaderListener)\n leaderElector._listeners.push(isLeaderListener)\n return _sendMessage(leaderElector, 'tell')\n}\n\nexport function createLeaderElection (channel, options) {\n if (channel._leaderElector) {\n throw new Error('❌ MessageChannel already has a leader-elector')\n }\n\n const elector = new LeaderElection(channel, options)\n channel._beforeClose.push(async () => elector.die())\n\n channel._leaderElector = elector\n return elector\n}\n","import { MessageChannel, createLeaderElection } from './MessageChannel'\nexport const TabManager = ({\n type,\n channelName,\n fallbackInterval,\n responseTime,\n emitOnAllTabs,\n callbacks,\n start,\n reset,\n pause,\n resume\n}) => {\n const channel = new MessageChannel(channelName, { type })\n const elector = createLeaderElection(channel, { fallbackInterval, responseTime })\n const registry = {}\n\n // Register self\n registry[elector.token] = false\n\n let leader = false\n let allIdle = true\n\n const isLeader = () => leader\n\n elector.awaitLeadership().then(() => {\n leader = true\n })\n\n channel.addEventListener('message', ([type, id]) => {\n switch (type) {\n case 'register':\n registry[id] = false\n break\n case 'deregister':\n delete registry[id]\n break\n case 'idle':\n idle(id)\n break\n case 'active':\n active(id)\n break\n case 'emitIdle':\n callbacks.onIdle()\n break\n case 'emitActive':\n callbacks.onActive()\n break\n case 'start':\n start(true)\n break\n case 'reset':\n reset(true)\n break\n case 'pause':\n pause(true)\n break\n case 'resume':\n resume(true)\n break\n default:\n // no op\n }\n })\n\n const setAllIdle = bool => {\n allIdle = bool\n }\n\n const isAllIdle = () => allIdle\n\n const idle = (id = elector.token) => {\n registry[id] = true\n const isIdle = Object.values(registry).every(v => v)\n if (!allIdle && isIdle) {\n allIdle = true\n if (isLeader()) {\n callbacks.onIdle()\n if (emitOnAllTabs) send('emitIdle')\n } else {\n send('idle')\n }\n }\n }\n\n const active = (id = elector.token) => {\n registry[id] = false\n const isActive = Object.values(registry).some(v => !v)\n if (allIdle && isActive) {\n allIdle = false\n if (isLeader()) {\n callbacks.onActive()\n if (emitOnAllTabs) send('emitActive')\n } else {\n send('active')\n }\n }\n }\n\n /* istanbul ignore next */\n elector.onDuplicate = async () => await elector.die()\n elector.onBeforeDie = async () => await send('deregister')\n\n const send = async message => channel.postMessage([message, elector.token])\n\n const close = async () => {\n await elector.die()\n await channel.close()\n }\n\n // Register self with remote tabs\n send('register')\n\n return { close, send, isLeader, idle, active, isAllIdle, setAllIdle }\n}\n","/**\n * ___ _ _ _____ _\n * |_ _|__| | | __|_ _(_)_ __ ___ ___ _ __\n * | |/ _` | |/ _ \\| | | | '_ ` _ \\ / _ \\ '__|\n * | | (_| | | __/| | | | | | | | | __/ |\n * |___\\__,_|_|\\___||_| |_|_| |_| |_|\\___|_|\n *\n * @name IdleTimer\n * @author Randy Lebeau\n * @private\n */\n\nimport { Component } from 'react'\nimport PropTypes from 'prop-types'\nimport { TabManager } from './TabManager'\nimport { IS_BROWSER, DEFAULT_ELEMENT, DEFAULT_EVENTS, debounced, throttled } from './utils'\n\n/**\n * Detects when your user is idle\n * @class IdleTimer\n * @private\n */\nclass IdleTimer extends Component {\n /**\n * Creates an instance of IdleTimer\n * bind all of our internal events here\n * for best performance\n * @param {Object} props\n * @return {IdleTimer}\n * @private\n */\n constructor (props) {\n super(props)\n\n /**\n * Sets initial component state\n * @type {Object}\n * @private\n */\n this.state = {\n idle: false,\n oldDate: +new Date(),\n lastActive: +new Date(),\n lastIdle: null,\n idleTime: 0,\n remaining: null,\n pageX: null,\n pageY: null\n }\n\n /**\n * The timer instance\n * @type {Timeout}\n * @private\n */\n this.tId = null\n\n /**\n * Wether or not events are bound\n * @type {boolean}\n * @private\n */\n this.eventsBound = false\n\n this.callbackRefs = {}\n\n // Debounce and throttle can't both be set\n if (props.debounce > 0 && props.throttle > 0) {\n throw new Error('onAction can either be throttled or debounced (not both)')\n }\n\n // Create debounced action if applicable\n if (props.debounce > 0) {\n this._onAction = debounced(props.onAction, props.debounce)\n\n // Create throttled action if applicable\n } else if (props.throttle > 0) {\n this._onAction = throttled(props.onAction, props.throttle)\n\n // Set custom onAction\n } else {\n this._onAction = props.onAction\n }\n\n // Create a throttle event handler if applicable\n if (props.eventsThrottle > 0) {\n this.handleEvent = throttled(this._handleEvent.bind(this), props.eventsThrottle)\n } else {\n this.handleEvent = this._handleEvent.bind(this)\n }\n\n // If startOnMount is set, idle state defaults to true\n if (!props.startOnMount || props.startManually) {\n this.state.idle = true\n }\n\n // Bind all events to component scope, built for speed 🚀\n this._toggleIdleState = this._toggleIdleState.bind(this)\n this.start = this.start.bind(this)\n this.reset = this.reset.bind(this)\n this.pause = this.pause.bind(this)\n this.resume = this.resume.bind(this)\n this.isIdle = this.isIdle.bind(this)\n this.getRemainingTime = this.getRemainingTime.bind(this)\n this.getElapsedTime = this.getElapsedTime.bind(this)\n this.getLastActiveTime = this.getLastActiveTime.bind(this)\n this.getLastIdleTime = this.getLastIdleTime.bind(this)\n this.getTotalIdleTime = this.getTotalIdleTime.bind(this)\n this.getTotalActiveTime = this.getTotalActiveTime.bind(this)\n }\n\n /**\n * Runs once the component has mounted\n * here we handle automatically starting\n * the idletimer\n * @private\n */\n componentDidMount () {\n const { startOnMount, startManually } = this.props\n\n // Set up cross tab\n this._setupTabManager()\n\n if (startManually) return\n if (startOnMount) {\n this.start()\n } else {\n this._bindEvents()\n }\n }\n\n componentDidUpdate (prevProps) {\n // Update debounce function\n if ((prevProps.debounce !== this.props.debounce) && this.props.debounce > 0) {\n if (this._onAction.cancel) this._onAction.cancel()\n this._onAction = debounced(this.props.onAction, this.props.debounce)\n } else\n // Update throttle function\n if ((prevProps.throttle !== this.props.throttle) && this.props.throttle > 0) {\n if (this._onAction.cancel) this._onAction.cancel()\n this._onAction = throttled(this.props.onAction, this.props.throttle)\n } else\n // Remove throttle or debounce\n if (\n (prevProps.throttle && this.props.throttle === 0) ||\n (prevProps.debounce && this.props.debounce === 0)\n ) {\n if (this._onAction.cancel) this._onAction.cancel()\n this._onAction = this.props.onAction\n }\n\n // Update event throttle function\n if (prevProps.eventsThrottle !== this.props.eventsThrottle) {\n this._unbindEvents()\n this.handleEvent = throttled(this._handleEvent.bind(this), this.props.eventsThrottle)\n this._bindEvents()\n }\n // Update timeout value\n if (prevProps.timeout !== this.props.timeout) {\n if (this.state.idle) this.reset()\n }\n\n // Update callback refs\n if (prevProps.onActive !== this.props.onActive) this.callbackRefs.onActive = this.props.onActive\n if (prevProps.onIdle !== this.props.onIdle) this.callbackRefs.onIdle = this.props.onIdle\n }\n\n /**\n * Called before the component un-mounts\n * here we clear the timer and remove\n * all the event listeners\n * @private\n */\n componentWillUnmount () {\n // Clear timeout to prevent delayed state changes\n clearTimeout(this.tId)\n this._unbindEvents(true)\n // Cancel any debounced onAction handlers\n if (this._onAction.cancel) this._onAction.cancel()\n /* istanbul ignore next */\n if (this.manager) {\n this.manager.close().catch(console.error)\n }\n }\n\n /**\n * Render children if IdleTimer is used as a wrapper\n * @return {Component} children\n * @private\n */\n render () {\n const { children } = this.props\n return children || null\n }\n\n /**\n * Setup the Tab Manager.\n * @private\n */\n _setupTabManager () {\n const { crossTab, onIdle, onActive } = this.props\n this.callbackRefs = { onIdle, onActive }\n\n /* istanbul ignore next */\n if (crossTab) {\n const {\n type,\n channelName,\n fallbackInterval,\n responseTime,\n emitOnAllTabs\n } = Object.assign({\n channelName: 'idle-timer',\n fallbackInterval: 2000,\n responseTime: 100,\n removeTimeout: 1000 * 60,\n emitOnAllTabs: false\n }, crossTab === true ? {} : crossTab)\n\n this.manager = TabManager({\n type,\n channelName,\n fallbackInterval,\n responseTime,\n emitOnAllTabs,\n callbacks: this.callbackRefs,\n start: this.start,\n reset: this.reset,\n pause: this.pause,\n resume: this.resume\n })\n }\n }\n\n /**\n * Binds the specified events\n * @private\n */\n _bindEvents () {\n // Don't bind events if\n // we are not in a browser\n if (!IS_BROWSER) return\n // Otherwise we bind all the events\n // to the supplied element\n const { element, events, passive, capture } = this.props\n if (!this.eventsBound) {\n events.forEach(e => {\n element.addEventListener(e, this.handleEvent, {\n capture,\n passive\n })\n })\n this.eventsBound = true\n }\n }\n\n /**\n * Unbinds all the bound events\n * @private\n */\n _unbindEvents (force = false) {\n // If we are not in a browser\n // we don't need to unbind events\n if (!IS_BROWSER) return\n // Unbind all events\n const { element, events, passive, capture } = this.props\n if (this.eventsBound || force) {\n events.forEach(e => {\n element.removeEventListener(e, this.handleEvent, {\n capture,\n passive\n })\n })\n this.eventsBound = false\n }\n }\n\n /**\n * Toggles the idle state and calls\n * the correct action function\n * @private\n */\n _toggleIdleState (e) {\n // Fire the appropriate action\n // and pass the event through\n // Toggle the idle state\n this.setState((prevState) => ({\n idle: !prevState.idle,\n lastIdle: !prevState.idle ? (+new Date()) - this.props.timeout : prevState.lastIdle,\n idleTime: prevState.idle ? prevState.idleTime + (+new Date()) - prevState.lastIdle : prevState.idleTime\n }), () => {\n const { onActive, onIdle, stopOnIdle } = this.props\n const { idle } = this.state\n if (idle) {\n if (stopOnIdle) {\n // Clear any existing timeout\n clearTimeout(this.tId)\n this.tId = null\n // Unbind events\n this._unbindEvents()\n }\n\n if (this.manager) {\n /* istanbul ignore next */\n this.manager.idle()\n } else {\n onIdle(e)\n }\n } else {\n this._bindEvents()\n if (this.manager) {\n /* istanbul ignore next */\n this.manager.active()\n } else {\n onActive(e)\n }\n }\n })\n }\n\n /**\n * Event handler for supported event types\n * @param {Object} e event object\n * @private\n */\n _handleEvent (e) {\n const { remaining, pageX, pageY, idle } = this.state\n const { timeout, stopOnIdle } = this.props\n\n // Fire onAction event\n this._onAction(e)\n\n // Already active, ignore events\n if (remaining) return\n\n // Mousemove event\n if (e.type === 'mousemove') {\n // If coords are same, it didn't move\n /* istanbul ignore next */\n if (e.pageX === pageX && e.pageY === pageY) {\n return\n }\n // If coords don't exist how could it move\n if (typeof e.pageX === 'undefined' && typeof e.pageY === 'undefined') {\n return\n }\n // Under 200 ms is hard to do\n // continuous activity will bypass this\n /* istanbul ignore next */\n const elapsed = this.getElapsedTime()\n /* istanbul ignore next */\n if (elapsed < 200) {\n return\n }\n }\n\n // Clear any existing timeout\n clearTimeout(this.tId)\n this.tId = null\n\n // Determine last time User was active, as can't rely on setTimeout ticking at the correct interval\n const elapsedTimeSinceLastActive = +new Date() - this.getLastActiveTime()\n\n // If the user is idle or last active time is more than timeout, flip the idle state\n if ((idle && !stopOnIdle) || (!idle && elapsedTimeSinceLastActive > timeout)) {\n this._toggleIdleState(e)\n }\n\n // Store when the user was last active\n // and update the mouse coordinates\n this.setState({\n lastActive: +new Date(),\n pageX: e.pageX,\n pageY: e.pageY\n })\n\n // If the user is idle and stopOnIdle flag is not set\n // set a new timeout\n if (idle) {\n if (!stopOnIdle) {\n this.tId = setTimeout(this._toggleIdleState, timeout)\n }\n } else {\n this.tId = setTimeout(this._toggleIdleState, timeout)\n }\n }\n\n /**\n * Set initial state and start timer\n * @name start\n */\n start (remote = true) {\n // Clear timeout\n clearTimeout(this.tId)\n this.tId = null\n\n // Bind the events\n this._bindEvents()\n\n // Reset state\n this.setState({\n idle: false,\n oldDate: +new Date(),\n lastActive: +new Date(),\n remaining: null\n })\n\n if (this.manager) {\n /* istanbul ignore next */\n this.manager.setAllIdle(false)\n /* istanbul ignore next */\n if (!remote && this.props.crossTab.emitOnAllTabs) {\n this.manager.send('start')\n }\n }\n\n // Set new timeout\n const { timeout } = this.props\n this.tId = setTimeout(this._toggleIdleState, timeout)\n }\n\n /**\n * Restore initial state and restart timer, calling onActive\n * @name reset\n */\n reset (remote = false) {\n // Clear timeout\n clearTimeout(this.tId)\n this.tId = null\n\n // Bind the events\n this._bindEvents()\n\n if (this.state.idle) {\n if (this.manager) {\n /* istanbul ignore next */\n this.manager.active()\n } else {\n this.props.onActive()\n }\n }\n\n if (this.manager) {\n /* istanbul ignore next */\n this.manager.setAllIdle(false)\n /* istanbul ignore next */\n if (!remote && this.props.crossTab.emitOnAllTabs) {\n this.manager.send('reset')\n }\n }\n\n // Reset state\n this.setState({\n idle: false,\n oldDate: +new Date(),\n lastActive: +new Date(),\n remaining: null\n })\n\n // Set new timeout\n const { timeout } = this.props\n this.tId = setTimeout(this._toggleIdleState, timeout)\n }\n\n /**\n * Store remaining time and stop timer\n * @name pause\n */\n pause (remote = false) {\n // Timer is already paused\n const { remaining } = this.state\n if (remaining !== null) return\n\n // Unbind events\n this._unbindEvents()\n\n // Clear existing timeout\n clearTimeout(this.tId)\n this.tId = null\n\n // Send event to other tabs\n if (this.manager) {\n /* istanbul ignore next */\n if (!remote && this.props.crossTab.emitOnAllTabs) {\n this.manager.send('pause')\n }\n }\n\n // Define how much is left on the timer\n this.setState({\n remaining: this.getRemainingTime()\n })\n }\n\n /**\n * Resumes a paused timer\n * @name resume\n */\n resume (remote = false) {\n // Timer is not paused\n const { remaining, idle } = this.state\n if (remaining === null) return\n\n // Bind events\n this._bindEvents()\n\n // Send event to other tabs\n if (this.manager) {\n /* istanbul ignore next */\n if (!remote && this.props.crossTab.emitOnAllTabs) {\n this.manager.send('resume')\n }\n }\n\n // Start timer and clear remaining\n // if we are in the active state\n if (!idle) {\n // Set a new timeout\n this.tId = setTimeout(this._toggleIdleState, remaining)\n // Set new state\n this.setState({ remaining: null, lastActive: +new Date() })\n }\n }\n\n /**\n * Time remaining before idle\n * @name getRemainingTime\n * @return {number} Milliseconds remaining\n */\n getRemainingTime () {\n const { remaining, lastActive } = this.state\n const { timeout } = this.props\n\n // If idle there is no time remaining\n if (remaining !== null) {\n return remaining < 0 ? 0 : remaining\n }\n\n // Determine remaining, if negative idle didn't finish flipping, just return 0\n const timeLeft = timeout - ((+new Date()) - lastActive)\n return timeLeft < 0 ? 0 : timeLeft\n }\n\n /**\n * How much time has elapsed\n * @name getElapsedTime\n * @return {Timestamp}\n */\n getElapsedTime () {\n const { oldDate } = this.state\n return (+new Date()) - oldDate\n }\n\n /**\n * Last time the user was idle\n * @name getLastIdleTime\n * @return {Timestamp}\n */\n getLastIdleTime () {\n const { lastIdle } = this.state\n return lastIdle\n }\n\n /**\n * Total time the user was idle\n * @name getTotalIdleTime\n * @return {number}\n */\n getTotalIdleTime () {\n const { idle, lastIdle, idleTime } = this.state\n if (idle) {\n return ((+new Date()) - lastIdle) + idleTime\n } else {\n return idleTime\n }\n }\n\n /**\n * Last time the user was active\n * @name getLastActiveTime\n * @return {Timestamp}\n */\n getLastActiveTime () {\n const { lastActive } = this.state\n return lastActive\n }\n\n /**\n * Total time the user was active\n * @name getTotalActiveTime\n * @return {number}\n */\n getTotalActiveTime () {\n return this.getElapsedTime() - this.getTotalIdleTime()\n }\n\n /**\n * Returns wether or not the user is idle\n * @name isIdle\n * @return {boolean}\n */\n isIdle () {\n const { idle } = this.state\n return idle\n }\n\n /**\n * Returns wether or not this is the leader tab\n * @name isLeader\n * @return {boolean}\n */\n isLeader () {\n return this.manager ? this.manager.isLeader() : true\n }\n}\n\n/**\n * Type checks for every property\n * @type {Object}\n * @private\n */\nIdleTimer.propTypes = {\n /**\n * Activity Timeout in milliseconds\n * default: 1200000\n * @type {Number}\n */\n timeout: PropTypes.number,\n /**\n * DOM events to listen to\n * default: see [default events](https://github.com/SupremeTechnopriest/react-idle-timer#default-events)\n * @type {Array}\n */\n events: PropTypes.arrayOf(PropTypes.string),\n /**\n * Function to call when user is idle\n * default: () => {}\n * @type {Function}\n */\n onIdle: PropTypes.func,\n /**\n * Function to call when user becomes active\n * default: () => {}\n * @type {Function}\n */\n onActive: PropTypes.func,\n /**\n * Function to call on user actions\n * default: () => {}\n * @type {Function}\n */\n onAction: PropTypes.func,\n /**\n * Debounce the onAction function by setting delay in milliseconds\n * default: 0\n * @type {Number}\n */\n debounce: PropTypes.number,\n /**\n * Throttle the onAction function by setting delay in milliseconds\n * default: 0\n * @type {Number}\n */\n throttle: PropTypes.number,\n /**\n * Throttle the event handler function by setting delay in milliseconds\n * default: 200\n * @type {Number}\n */\n eventsThrottle: PropTypes.number,\n /**\n * Element reference to bind activity listeners to\n * default: document\n * @type {Object}\n */\n element: PropTypes.oneOfType([PropTypes.object, PropTypes.element]),\n /**\n * Start the timer on mount\n * default: true\n * @type {Boolean}\n */\n startOnMount: PropTypes.bool,\n /**\n * Require the timer to be started manually.\n * default: false\n * @type {Boolean}\n */\n startManually: PropTypes.bool,\n /**\n * Once the user goes idle the IdleTimer will not\n * reset on user input instead, reset() must be\n * called manually to restart the timer\n * default: false\n * @type {Boolean}\n */\n stopOnIdle: PropTypes.bool,\n /**\n * Bind events passively\n * default: true\n * @type {Boolean}\n */\n passive: PropTypes.bool,\n /**\n * Capture events\n * default: true\n * @type {Boolean}\n */\n capture: PropTypes.bool,\n /**\n * Cross Tab functionality.\n * default: false\n * @type {Boolean|Object}\n */\n crossTab: PropTypes.oneOfType([\n PropTypes.bool,\n PropTypes.shape({\n type: PropTypes.oneOf(['broadcastChannel', 'localStorage', 'simulate']),\n channelName: PropTypes.string,\n fallbackInterval: PropTypes.number,\n responseTime: PropTypes.number,\n removeTimeout: PropTypes.number,\n emitOnAllTabs: PropTypes.bool\n })\n ])\n}\n\n/**\n * Sets default property values\n * @type {Object}\n * @private\n */\nIdleTimer.defaultProps = {\n timeout: 1000 * 60 * 20,\n element: DEFAULT_ELEMENT,\n events: DEFAULT_EVENTS,\n onIdle: () => { },\n onActive: () => { },\n onAction: () => { },\n debounce: 0,\n throttle: 0,\n eventsThrottle: 200,\n startOnMount: true,\n startManually: false,\n stopOnIdle: false,\n capture: true,\n passive: true,\n crossTab: false\n}\n\nexport default IdleTimer\n","/**\n * ___ _ _ _____ _\n * |_ _|__| | | __|_ _(_)_ __ ___ ___ _ __\n * | |/ _` | |/ _ \\| | | | '_ ` _ \\ / _ \\ '__|\n * | | (_| | | __/| | | | | | | | | __/ |\n * |___\\__,_|_|\\___||_| |_|_| |_| |_|\\___|_|\n *\n * @name useIdleTimer\n * @author Randy Lebeau\n * @private\n */\n\nimport { useEffect, useRef, useMemo } from 'react'\nimport PropTypes from 'prop-types'\nimport { TabManager } from './TabManager'\nimport { IS_BROWSER, DEFAULT_ELEMENT, DEFAULT_EVENTS, debounced, throttled } from './utils'\n\n/**\n * Detects when your user is idle\n * @function useIdleTimer\n * @private\n */\nfunction useIdleTimer ({\n timeout = 1000 * 60 * 20,\n element = DEFAULT_ELEMENT,\n events = DEFAULT_EVENTS,\n onIdle = () => { },\n onActive = () => { },\n onAction = () => { },\n debounce = 0,\n throttle = 0,\n eventsThrottle = 200,\n startOnMount = true,\n startManually = false,\n stopOnIdle = false,\n capture = true,\n passive = true,\n crossTab = false\n} = {}) {\n const eventsBound = useRef(false)\n const idle = useRef(true)\n const oldDate = useRef(+new Date())\n const remaining = useRef(null)\n const pageX = useRef(null)\n const pageY = useRef(null)\n const tId = useRef(null)\n const lastActive = useRef(null)\n const lastIdle = useRef(null)\n const idleTime = useRef(0)\n const firstLoad = useRef(true)\n const _timeout = useRef(timeout)\n const manager = useRef(null)\n\n /* istanbul ignore next */\n if (crossTab) {\n if (crossTab === true) crossTab = {}\n crossTab = Object.assign({\n channelName: 'idle-timer',\n fallbackInterval: 2000,\n responseTime: 100,\n removeTimeout: 1000 * 60,\n emitOnAllTabs: false\n }, crossTab)\n }\n\n // Event emitters\n const emitOnIdle = useRef(onIdle)\n const emitOnActive = useRef(onActive)\n const emitOnAction = useRef(onAction)\n\n useEffect(() => {\n emitOnIdle.current = onIdle\n }, [onIdle])\n\n useEffect(() => {\n emitOnActive.current = onActive\n }, [onActive])\n\n useEffect(() => {\n emitOnAction.current = onAction\n }, [onAction])\n\n const intermediateOnAction = useMemo(() => {\n function callOnAction (e) {\n emitOnAction.current(e)\n }\n\n // Cancel any existing debounce timeouts\n if (callOnAction.cancel) callOnAction.cancel()\n\n // Create debounced action if applicable\n if (debounce > 0) {\n return debounced(callOnAction, debounce)\n\n // Create throttled action if applicable\n } else if (throttle > 0) {\n return throttled(callOnAction, throttle)\n\n // No throttle or debounce\n } else {\n return callOnAction\n }\n }, [throttle, debounce])\n\n /**\n * Toggles the idle state and calls\n * the correct action function\n * @private\n */\n const _toggleIdleState = e => {\n const nextIdle = !idle.current\n idle.current = nextIdle\n if (nextIdle) {\n if (stopOnIdle) {\n // Clear any existing timeout\n clearTimeout(tId.current)\n tId.current = null\n // Unbind events\n _unbindEvents()\n }\n lastIdle.current = (+new Date()) - _timeout.current\n if (manager.current) {\n /* istanbul ignore next */\n manager.current.idle()\n } else {\n emitOnIdle.current(e)\n }\n } else {\n idleTime.current += (+new Date()) - lastIdle.current\n _bindEvents()\n if (manager.current) {\n /* istanbul ignore next */\n manager.current.active()\n } else {\n emitOnActive.current(e)\n }\n }\n }\n\n /**\n * Event handler\n * @param {Event} e\n */\n const _handleEvent = e => {\n // Fire onAction event\n intermediateOnAction(e)\n\n // Already active, ignore events\n if (remaining.current) return\n\n // Mousemove event\n /* istanbul ignore next */\n if (e.type === 'mousemove') {\n // If coords are same, it didn't move\n if (e.pageX === pageX && e.pageY === pageY) {\n return\n }\n // If coords don't exist how could it move\n if (typeof e.pageX === 'undefined' && typeof e.pageY === 'undefined') {\n return\n }\n // Under 200 ms is hard to do\n // continuous activity will bypass this\n const elapsed = getElapsedTime()\n if (elapsed < 200) {\n return\n }\n }\n\n // Clear any existing timeout\n clearTimeout(tId.current)\n tId.current = null\n\n // Determine last time User was active, as can't rely on setTimeout ticking at the correct interval\n const elapsedTimeSinceLastActive = +new Date() - getLastActiveTime()\n\n // If the user is idle or last active time is more than timeout, flip the idle state\n if (\n (idle.current && !stopOnIdle) ||\n (!idle.current && elapsedTimeSinceLastActive > _timeout.current)\n ) {\n _toggleIdleState(e)\n }\n\n // Store when the user was last active\n // and update the mouse coordinates\n lastActive.current = +new Date()\n pageX.current = e.pageX\n pageY.current = e.pageY\n\n // If the user is active, set a new timeout\n if (!idle.current) {\n tId.current = setTimeout(_toggleIdleState, _timeout.current)\n }\n }\n\n /**\n * Reference to current handleEvent function.\n * @private\n */\n const handleEvent = useRef(_handleEvent)\n\n /**\n * Binds the specified events\n * @private\n */\n const _bindEvents = () => {\n // Don't bind events if\n // we are not in a browser\n if (!IS_BROWSER) return\n // Otherwise we bind all the events\n // to the supplied element\n if (!eventsBound.current) {\n events.forEach(e => {\n element.addEventListener(e, handleEvent.current, {\n capture,\n passive\n })\n })\n eventsBound.current = true\n }\n }\n\n /**\n * Unbinds all the bound events\n * @private\n */\n const _unbindEvents = (force = false) => {\n // If we are not in a browser\n // we don't need to unbind events\n if (!IS_BROWSER) return\n // Unbind all events\n if (eventsBound.current || force) {\n events.forEach(e => {\n element.removeEventListener(e, handleEvent.current, {\n capture,\n passive\n })\n })\n eventsBound.current = false\n }\n }\n\n /**\n * Time remaining before idle\n * @name getRemainingTime\n * @return {number} Milliseconds remaining\n */\n const getRemainingTime = () => {\n // If idle there is no time remaining\n if (remaining.current !== null) {\n return remaining.current < 0 ? 0 : remaining.current\n }\n\n // Determine remaining, if negative idle didn't finish flipping, just return 0\n const timeLeft = _timeout.current - ((+new Date()) - lastActive.current)\n return timeLeft < 0 ? 0 : timeLeft\n }\n\n /**\n * How much time has elapsed\n * @name getElapsedTime\n * @return {Timestamp}\n */\n const getElapsedTime = () => (+new Date()) - oldDate.current\n\n /**\n * Last time the user was idle\n * @name getLastIdleTime\n * @return {Timestamp}\n */\n const getLastIdleTime = () => lastIdle.current\n\n /**\n * Get the total time user is idle\n * @name getTotalIdleTime\n * @return {number} Milliseconds idle\n */\n const getTotalIdleTime = () => {\n if (idle.current) {\n return ((+new Date()) - lastIdle.current) + idleTime.current\n } else {\n return idleTime.current\n }\n }\n\n /**\n * Last time the user was active\n * @name getLastActiveTime\n * @return {Timestamp}\n */\n const getLastActiveTime = () => lastActive.current\n\n /**\n * Get the total time user is active\n * @name getTotalActiveTime\n * @return {number} Milliseconds active\n */\n const getTotalActiveTime = () => getElapsedTime() - getTotalIdleTime()\n\n /**\n * Returns wether or not the user is idle\n * @name isIdle\n * @return {Boolean}\n */\n const isIdle = () => idle.current\n\n /**\n * Returns wether or not this is the leader tab\n * @returns {Boolean}\n */\n const isLeader = () => manager.current ? manager.current.isLeader() : true\n\n /**\n * Set initial state and start timer\n * @name reset\n */\n const start = (remote = false) => {\n // Clear timeout\n clearTimeout(tId.current)\n tId.current = null\n\n // Bind the events\n _bindEvents()\n\n // Set state\n idle.current = false\n oldDate.current = +new Date()\n lastActive.current = +new Date()\n remaining.current = null\n\n if (manager.current) {\n /* istanbul ignore next */\n manager.current.setAllIdle(false)\n /* istanbul ignore next */\n if (!remote && crossTab.emitOnAllTabs) {\n manager.current.send('start')\n }\n }\n\n // Set new timeout\n tId.current = setTimeout(_toggleIdleState, _timeout.current)\n }\n\n /**\n * Restore initial state and restart timer, calling onActive\n * @name reset\n */\n const reset = (remote = false) => {\n // Clear timeout\n clearTimeout(tId.current)\n tId.current = null\n\n // Bind the events\n _bindEvents()\n\n // Emit active\n if (idle.current) {\n if (manager.current) {\n /* istanbul ignore next */\n manager.current.active()\n } else {\n emitOnActive.current()\n }\n }\n\n // Reset state\n idle.current = false\n oldDate.current = +new Date()\n lastActive.current = +new Date()\n remaining.current = null\n\n if (manager.current) {\n /* istanbul ignore next */\n manager.current.setAllIdle(false)\n /* istanbul ignore next */\n if (!remote && crossTab.emitOnAllTabs) {\n manager.current.send('reset')\n }\n }\n\n // Set new timeout\n tId.current = setTimeout(_toggleIdleState, _timeout.current)\n }\n\n /**\n * Store remaining time and stop timer\n * @name pause\n */\n const pause = (remote = false) => {\n // Timer is already paused\n if (remaining.current !== null) return\n\n // Unbind events\n _unbindEvents()\n\n // Clear existing timeout\n clearTimeout(tId.current)\n tId.current = null\n\n // Define how much is left on the timer\n remaining.current = getRemainingTime()\n\n if (manager.current) {\n /* istanbul ignore next */\n if (!remote && crossTab.emitOnAllTabs) {\n manager.current.send('pause')\n }\n }\n }\n\n /**\n * Resumes a paused timer\n * @name resume\n */\n const resume = (remote = false) => {\n // Timer is not paused\n if (remaining.current === null) return\n\n // Bind events\n _bindEvents()\n\n // Start timer and clear remaining\n // if we are in the idle state\n if (!idle.current) {\n // Set a new timeout\n tId.current = setTimeout(_toggleIdleState, remaining.current)\n // Set states\n remaining.current = null\n lastActive.current = +new Date()\n }\n\n if (manager.current) {\n /* istanbul ignore next */\n if (!remote && crossTab.emitOnAllTabs) {\n manager.current.send('resume')\n }\n }\n }\n\n /**\n * Hook lifecycle\n */\n useEffect(() => {\n // Debounce and throttle can't both be set\n if (debounce > 0 && throttle > 0) {\n throw new Error('onAction can either be throttled or debounced (not both)')\n }\n\n // Set up cross tab\n /* istanbul ignore next */\n if (crossTab) {\n manager.current = TabManager({\n type: crossTab.type,\n channelName: crossTab.channelName,\n fallbackInterval: crossTab.fallbackInterval,\n responseTime: crossTab.responseTime,\n emitOnAllTabs: crossTab.emitOnAllTabs,\n callbacks: {\n onIdle: emitOnIdle.current,\n onActive: emitOnActive.current\n },\n start,\n reset,\n pause,\n resume\n })\n }\n\n // If startOnMount is enabled, start the timer\n if (startManually) {\n return async () => {\n clearTimeout(tId.current)\n _unbindEvents(true)\n if (crossTab) await manager.current.close()\n }\n }\n\n if (startOnMount) {\n start()\n } else {\n _bindEvents()\n }\n\n // Clear and unbind on unmount\n return async () => {\n clearTimeout(tId.current)\n _unbindEvents(true)\n if (intermediateOnAction.cancel) intermediateOnAction.cancel()\n if (crossTab) await manager.current.close()\n }\n }, [])\n\n useEffect(() => {\n const eventsWereBound = eventsBound.current\n if (eventsWereBound) _unbindEvents()\n if (eventsThrottle > 0) {\n handleEvent.current = throttled(_handleEvent, eventsThrottle)\n } else {\n handleEvent.current = _handleEvent\n }\n if (eventsWereBound) _bindEvents()\n }, [eventsThrottle])\n\n useEffect(() => {\n _timeout.current = timeout\n if (!firstLoad.current && idle.current) {\n reset()\n }\n firstLoad.current = false\n }, [timeout])\n\n return {\n isIdle,\n isLeader,\n start,\n pause,\n reset,\n resume,\n getLastIdleTime,\n getTotalIdleTime,\n getLastActiveTime,\n getTotalActiveTime,\n getElapsedTime,\n getRemainingTime\n }\n}\n\n/**\n * Type checks for every property\n * @type {Object}\n * @private\n */\nuseIdleTimer.propTypes = {\n /**\n * Activity Timeout in milliseconds\n * default: 1200000\n * @type {number}\n */\n timeout: PropTypes.number,\n /**\n * DOM events to listen to\n * default: see [default events](https://github.com/SupremeTechnopriest/react-idle-timer#default-events)\n * @type {Array}\n */\n events: PropTypes.arrayOf(PropTypes.string),\n /**\n * Function to call when user is idle.\n * default: () => {}\n * @type {Function}\n */\n onIdle: PropTypes.func,\n /**\n * Function to call when user becomes active.\n * default: () => {}\n * @type {Function}\n */\n onActive: PropTypes.func,\n /**\n * Function to call on user actions.\n * default: () => {}\n * @type {Function}\n */\n onAction: PropTypes.func,\n /**\n * Debounce the onAction function by setting delay in milliseconds.\n * default: 0\n * @type {number}\n */\n debounce: PropTypes.number,\n /**\n * Throttle the onAction function by setting delay in milliseconds.\n * default: 0\n * @type {number}\n */\n throttle: PropTypes.number,\n /**\n * Throttle the event handler function by setting delay in milliseconds.\n * default: 200\n * @type {number}\n */\n eventsThrottle: PropTypes.number,\n /**\n * Element reference to bind activity listeners to.\n * default: document\n * @type {Object}\n */\n element: PropTypes.oneOfType([PropTypes.object, PropTypes.element]),\n /**\n * Start the timer on mount.\n * default: true\n * @type {Boolean}\n */\n startOnMount: PropTypes.bool,\n /**\n * Require the timer to be started manually.\n * default: false\n * @type {Boolean}\n */\n startManually: PropTypes.bool,\n /**\n * Once the user goes idle the IdleTimer will not\n * reset on user input instead, start() or reset() must be\n * called manually to restart the timer.\n * default: false\n * @type {Boolean}\n */\n stopOnIdle: PropTypes.bool,\n /**\n * Bind events passively.\n * default: true\n * @type {Boolean}\n */\n passive: PropTypes.bool,\n /**\n * Capture events.\n * default: true\n * @type {Boolean}\n */\n capture: PropTypes.bool,\n /**\n * Cross Tab functionality.\n * default: false\n * @type {Boolean|Object}\n */\n crossTab: PropTypes.oneOfType([\n PropTypes.bool,\n PropTypes.shape({\n type: PropTypes.oneOf(['broadcastChannel', 'localStorage', 'simulate']),\n channelName: PropTypes.string,\n fallbackInterval: PropTypes.number,\n responseTime: PropTypes.number,\n removeTimeout: PropTypes.number,\n emitOnAllTabs: PropTypes.bool\n })\n ])\n}\n\n/**\n * Sets default property values\n * @type {Object}\n * @private\n */\nuseIdleTimer.defaultProps = {\n timeout: 1000 * 60 * 20,\n element: DEFAULT_ELEMENT,\n events: DEFAULT_EVENTS,\n onIdle: () => { },\n onActive: () => { },\n onAction: () => { },\n debounce: 0,\n throttle: 0,\n eventsThrottle: 200,\n startOnMount: true,\n startManually: false,\n stopOnIdle: false,\n capture: true,\n passive: true,\n crossTab: false\n}\n\nexport default useIdleTimer\n","function _classCallCheck(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n}\n\nmodule.exports = _classCallCheck, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","function _defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n Object.defineProperty(target, descriptor.key, descriptor);\n }\n}\n\nfunction _createClass(Constructor, protoProps, staticProps) {\n if (protoProps) _defineProperties(Constructor.prototype, protoProps);\n if (staticProps) _defineProperties(Constructor, staticProps);\n Object.defineProperty(Constructor, \"prototype\", {\n writable: false\n });\n return Constructor;\n}\n\nmodule.exports = _createClass, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","var setPrototypeOf = require(\"./setPrototypeOf.js\");\n\nfunction _inherits(subClass, superClass) {\n if (typeof superClass !== \"function\" && superClass !== null) {\n throw new TypeError(\"Super expression must either be null or a function\");\n }\n\n subClass.prototype = Object.create(superClass && superClass.prototype, {\n constructor: {\n value: subClass,\n writable: true,\n configurable: true\n }\n });\n Object.defineProperty(subClass, \"prototype\", {\n writable: false\n });\n if (superClass) setPrototypeOf(subClass, superClass);\n}\n\nmodule.exports = _inherits, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","var _typeof = require(\"./typeof.js\")[\"default\"];\n\nvar assertThisInitialized = require(\"./assertThisInitialized.js\");\n\nfunction _possibleConstructorReturn(self, call) {\n if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) {\n return call;\n } else if (call !== void 0) {\n throw new TypeError(\"Derived constructors may only return object or undefined\");\n }\n\n return assertThisInitialized(self);\n}\n\nmodule.exports = _possibleConstructorReturn, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","function _getPrototypeOf(o) {\n module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n return o.__proto__ || Object.getPrototypeOf(o);\n }, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;\n return _getPrototypeOf(o);\n}\n\nmodule.exports = _getPrototypeOf, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {\n try {\n var info = gen[key](arg);\n var value = info.value;\n } catch (error) {\n reject(error);\n return;\n }\n\n if (info.done) {\n resolve(value);\n } else {\n Promise.resolve(value).then(_next, _throw);\n }\n}\n\nfunction _asyncToGenerator(fn) {\n return function () {\n var self = this,\n args = arguments;\n return new Promise(function (resolve, reject) {\n var gen = fn.apply(self, args);\n\n function _next(value) {\n asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value);\n }\n\n function _throw(err) {\n asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err);\n }\n\n _next(undefined);\n });\n };\n}\n\nmodule.exports = _asyncToGenerator, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;"],"sourceRoot":""}