broadcast-channel
Advanced tools
Comparing version 4.16.0 to 4.17.0
@@ -6,2 +6,9 @@ # CHANGELOG | ||
## 4.17.0 (13 September 2022) | ||
- REMOVE the `isNode` utility function so that we do not access the `process` variable in browsers. | ||
## 4.16.0 (13 September 2022) | ||
- Rerelase because npm got stuck | ||
## 4.15.0 (13 September 2022) | ||
@@ -8,0 +15,0 @@ |
@@ -22,4 +22,2 @@ "use strict"; | ||
var _util = require("./util.js"); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
@@ -56,3 +54,3 @@ | ||
if (!options.webWorkerSupport && !_util.isNode) { | ||
if (!options.webWorkerSupport) { | ||
chooseMethods = chooseMethods.filter(function (m) { | ||
@@ -59,0 +57,0 @@ return m.type !== 'idb'; |
@@ -400,5 +400,8 @@ "use strict"; | ||
function canBeUsed() { | ||
if (_util.isNode) return false; | ||
var idb = getIdb(); | ||
if (!idb) return false; | ||
if (!idb) { | ||
return false; | ||
} | ||
return true; | ||
@@ -405,0 +408,0 @@ } |
@@ -159,3 +159,2 @@ "use strict"; | ||
function canBeUsed() { | ||
if (_util.isNode) return false; | ||
var ls = getLocalStorage(); | ||
@@ -162,0 +161,0 @@ if (!ls) return false; |
@@ -58,7 +58,5 @@ "use strict"; | ||
function canBeUsed() { | ||
/** | ||
* in the electron-renderer, isNode will be true even if we are in browser-context | ||
* so we also check if window is undefined | ||
*/ | ||
if (_util.isNode && typeof window === 'undefined') return false; | ||
if (typeof window === 'undefined') { | ||
return false; | ||
} | ||
@@ -71,3 +69,5 @@ if (typeof BroadcastChannel === 'function') { | ||
return true; | ||
} else return false; | ||
} else { | ||
return false; | ||
} | ||
} | ||
@@ -74,0 +74,0 @@ |
@@ -59,4 +59,2 @@ "use strict"; | ||
var _detectNode = _interopRequireDefault(require("detect-node")); | ||
var _pQueue = _interopRequireDefault(require("p-queue")); | ||
@@ -1170,3 +1168,7 @@ | ||
function canBeUsed() { | ||
return _detectNode["default"]; | ||
if (typeof _fs["default"].mkdir === 'function') { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
@@ -1173,0 +1175,0 @@ /** |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.isNode = exports.PROMISE_RESOLVED_VOID = exports.PROMISE_RESOLVED_TRUE = exports.PROMISE_RESOLVED_FALSE = void 0; | ||
exports.PROMISE_RESOLVED_VOID = exports.PROMISE_RESOLVED_TRUE = exports.PROMISE_RESOLVED_FALSE = void 0; | ||
exports.isPromise = isPromise; | ||
@@ -74,11 +74,2 @@ exports.microSeconds = microSeconds; | ||
} | ||
} | ||
/** | ||
* copied from the 'detect-node' npm module | ||
* We cannot use the module directly because it causes problems with rollup | ||
* @link https://github.com/iliakan/detect-node/blob/master/index.js | ||
*/ | ||
var isNode = Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]'; | ||
exports.isNode = isNode; | ||
} |
@@ -6,3 +6,2 @@ import NativeMethod from './methods/native.js'; | ||
import { isNode } from './util.js'; // order is important | ||
@@ -32,3 +31,3 @@ var METHODS = [NativeMethod, // fastest | ||
if (!options.webWorkerSupport && !isNode) { | ||
if (!options.webWorkerSupport) { | ||
chooseMethods = chooseMethods.filter(function (m) { | ||
@@ -35,0 +34,0 @@ return m.type !== 'idb'; |
@@ -9,3 +9,3 @@ /** | ||
*/ | ||
import { sleep, randomInt, randomToken, microSeconds as micro, isNode, PROMISE_RESOLVED_VOID } from '../util.js'; | ||
import { sleep, randomInt, randomToken, microSeconds as micro, PROMISE_RESOLVED_VOID } from '../util.js'; | ||
export var microSeconds = micro; | ||
@@ -357,5 +357,8 @@ import { ObliviousSet } from 'oblivious-set'; | ||
export function canBeUsed() { | ||
if (isNode) return false; | ||
var idb = getIdb(); | ||
if (!idb) return false; | ||
if (!idb) { | ||
return false; | ||
} | ||
return true; | ||
@@ -362,0 +365,0 @@ } |
@@ -10,3 +10,3 @@ /** | ||
import { fillOptionsWithDefaults } from '../options.js'; | ||
import { sleep, randomToken, microSeconds as micro, isNode } from '../util.js'; | ||
import { sleep, randomToken, microSeconds as micro } from '../util.js'; | ||
export var microSeconds = micro; | ||
@@ -127,3 +127,2 @@ var KEY_PREFIX = 'pubkey.broadcastChannel-'; | ||
export function canBeUsed() { | ||
if (isNode) return false; | ||
var ls = getLocalStorage(); | ||
@@ -130,0 +129,0 @@ if (!ls) return false; |
@@ -1,2 +0,2 @@ | ||
import { microSeconds as micro, isNode, PROMISE_RESOLVED_VOID } from '../util.js'; | ||
import { microSeconds as micro, PROMISE_RESOLVED_VOID } from '../util.js'; | ||
export var microSeconds = micro; | ||
@@ -36,7 +36,5 @@ export var type = 'native'; | ||
export function canBeUsed() { | ||
/** | ||
* in the electron-renderer, isNode will be true even if we are in browser-context | ||
* so we also check if window is undefined | ||
*/ | ||
if (isNode && typeof window === 'undefined') return false; | ||
if (typeof window === 'undefined') { | ||
return false; | ||
} | ||
@@ -49,3 +47,5 @@ if (typeof BroadcastChannel === 'function') { | ||
return true; | ||
} else return false; | ||
} else { | ||
return false; | ||
} | ||
} | ||
@@ -52,0 +52,0 @@ export function averageResponseTime() { |
@@ -16,3 +16,2 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator"; | ||
import rimraf from 'rimraf'; | ||
import isNode from 'detect-node'; | ||
import PQueue from 'p-queue'; | ||
@@ -1076,3 +1075,7 @@ import { add as unloadAdd } from 'unload'; | ||
export function canBeUsed() { | ||
return isNode; | ||
if (typeof fs.mkdir === 'function') { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
@@ -1079,0 +1082,0 @@ /** |
@@ -53,9 +53,2 @@ /** | ||
} | ||
} | ||
/** | ||
* copied from the 'detect-node' npm module | ||
* We cannot use the module directly because it causes problems with rollup | ||
* @link https://github.com/iliakan/detect-node/blob/master/index.js | ||
*/ | ||
export var isNode = Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]'; | ||
} |
@@ -6,4 +6,3 @@ import NativeMethod from './methods/native.js'; | ||
import * as NodeMethod from './methods/node.js'; | ||
import { isNode } from './util.js'; // order is important | ||
import * as NodeMethod from './methods/node.js'; // order is important | ||
@@ -34,3 +33,3 @@ var METHODS = [NativeMethod, // fastest | ||
if (!options.webWorkerSupport && !isNode) { | ||
if (!options.webWorkerSupport) { | ||
chooseMethods = chooseMethods.filter(function (m) { | ||
@@ -37,0 +36,0 @@ return m.type !== 'idb'; |
@@ -9,3 +9,3 @@ /** | ||
*/ | ||
import { sleep, randomInt, randomToken, microSeconds as micro, isNode, PROMISE_RESOLVED_VOID } from '../util.js'; | ||
import { sleep, randomInt, randomToken, microSeconds as micro, PROMISE_RESOLVED_VOID } from '../util.js'; | ||
export var microSeconds = micro; | ||
@@ -357,5 +357,8 @@ import { ObliviousSet } from 'oblivious-set'; | ||
export function canBeUsed() { | ||
if (isNode) return false; | ||
var idb = getIdb(); | ||
if (!idb) return false; | ||
if (!idb) { | ||
return false; | ||
} | ||
return true; | ||
@@ -362,0 +365,0 @@ } |
@@ -10,3 +10,3 @@ /** | ||
import { fillOptionsWithDefaults } from '../options.js'; | ||
import { sleep, randomToken, microSeconds as micro, isNode } from '../util.js'; | ||
import { sleep, randomToken, microSeconds as micro } from '../util.js'; | ||
export var microSeconds = micro; | ||
@@ -127,3 +127,2 @@ var KEY_PREFIX = 'pubkey.broadcastChannel-'; | ||
export function canBeUsed() { | ||
if (isNode) return false; | ||
var ls = getLocalStorage(); | ||
@@ -130,0 +129,0 @@ if (!ls) return false; |
@@ -1,2 +0,2 @@ | ||
import { microSeconds as micro, isNode, PROMISE_RESOLVED_VOID } from '../util.js'; | ||
import { microSeconds as micro, PROMISE_RESOLVED_VOID } from '../util.js'; | ||
export var microSeconds = micro; | ||
@@ -36,7 +36,5 @@ export var type = 'native'; | ||
export function canBeUsed() { | ||
/** | ||
* in the electron-renderer, isNode will be true even if we are in browser-context | ||
* so we also check if window is undefined | ||
*/ | ||
if (isNode && typeof window === 'undefined') return false; | ||
if (typeof window === 'undefined') { | ||
return false; | ||
} | ||
@@ -49,3 +47,5 @@ if (typeof BroadcastChannel === 'function') { | ||
return true; | ||
} else return false; | ||
} else { | ||
return false; | ||
} | ||
} | ||
@@ -52,0 +52,0 @@ export function averageResponseTime() { |
@@ -16,3 +16,2 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator"; | ||
import rimraf from 'rimraf'; | ||
import isNode from 'detect-node'; | ||
import PQueue from 'p-queue'; | ||
@@ -1076,3 +1075,7 @@ import { add as unloadAdd } from 'unload'; | ||
export function canBeUsed() { | ||
return isNode; | ||
if (typeof fs.mkdir === 'function') { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
@@ -1079,0 +1082,0 @@ /** |
@@ -53,9 +53,2 @@ /** | ||
} | ||
} | ||
/** | ||
* copied from the 'detect-node' npm module | ||
* We cannot use the module directly because it causes problems with rollup | ||
* @link https://github.com/iliakan/detect-node/blob/master/index.js | ||
*/ | ||
export var isNode = Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]'; | ||
} |
@@ -779,3 +779,3 @@ (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){ | ||
} | ||
},{"./util.js":12,"unload":20}],6:[function(require,module,exports){ | ||
},{"./util.js":12,"unload":19}],6:[function(require,module,exports){ | ||
"use strict"; | ||
@@ -801,4 +801,2 @@ | ||
var _util = require("./util.js"); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
@@ -834,3 +832,3 @@ | ||
if (!options.webWorkerSupport && !_util.isNode) { | ||
if (!options.webWorkerSupport) { | ||
chooseMethods = chooseMethods.filter(function (m) { | ||
@@ -848,3 +846,3 @@ return m.type !== 'idb'; | ||
} | ||
},{"./methods/indexed-db.js":7,"./methods/localstorage.js":8,"./methods/native.js":9,"./methods/simulate.js":10,"./util.js":12,"@babel/runtime/helpers/interopRequireDefault":13,"@babel/runtime/helpers/typeof":14}],7:[function(require,module,exports){ | ||
},{"./methods/indexed-db.js":7,"./methods/localstorage.js":8,"./methods/native.js":9,"./methods/simulate.js":10,"@babel/runtime/helpers/interopRequireDefault":13,"@babel/runtime/helpers/typeof":14}],7:[function(require,module,exports){ | ||
"use strict"; | ||
@@ -1249,5 +1247,8 @@ | ||
function canBeUsed() { | ||
if (_util.isNode) return false; | ||
var idb = getIdb(); | ||
if (!idb) return false; | ||
if (!idb) { | ||
return false; | ||
} | ||
return true; | ||
@@ -1430,3 +1431,2 @@ } | ||
function canBeUsed() { | ||
if (_util.isNode) return false; | ||
var ls = getLocalStorage(); | ||
@@ -1530,7 +1530,5 @@ if (!ls) return false; | ||
function canBeUsed() { | ||
/** | ||
* in the electron-renderer, isNode will be true even if we are in browser-context | ||
* so we also check if window is undefined | ||
*/ | ||
if (_util.isNode && typeof window === 'undefined') return false; | ||
if (typeof window === 'undefined') { | ||
return false; | ||
} | ||
@@ -1543,3 +1541,5 @@ if (typeof BroadcastChannel === 'function') { | ||
return true; | ||
} else return false; | ||
} else { | ||
return false; | ||
} | ||
} | ||
@@ -1678,3 +1678,2 @@ | ||
},{}],12:[function(require,module,exports){ | ||
(function (process){(function (){ | ||
"use strict"; | ||
@@ -1685,3 +1684,3 @@ | ||
}); | ||
exports.isNode = exports.PROMISE_RESOLVED_VOID = exports.PROMISE_RESOLVED_TRUE = exports.PROMISE_RESOLVED_FALSE = void 0; | ||
exports.PROMISE_RESOLVED_VOID = exports.PROMISE_RESOLVED_TRUE = exports.PROMISE_RESOLVED_FALSE = void 0; | ||
exports.isPromise = isPromise; | ||
@@ -1754,13 +1753,3 @@ exports.microSeconds = microSeconds; | ||
} | ||
/** | ||
* copied from the 'detect-node' npm module | ||
* We cannot use the module directly because it causes problems with rollup | ||
* @link https://github.com/iliakan/detect-node/blob/master/index.js | ||
*/ | ||
var isNode = Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]'; | ||
exports.isNode = isNode; | ||
}).call(this)}).call(this,require('_process')) | ||
},{"_process":18}],13:[function(require,module,exports){ | ||
},{}],13:[function(require,module,exports){ | ||
function _interopRequireDefault(obj) { | ||
@@ -1870,188 +1859,2 @@ return obj && obj.__esModule ? obj : { | ||
},{}],18:[function(require,module,exports){ | ||
// shim for using process in browser | ||
var process = module.exports = {}; | ||
// cached from whatever global is present so that test runners that stub it | ||
// don't break things. But we need to wrap it in a try catch in case it is | ||
// wrapped in strict mode code which doesn't define any globals. It's inside a | ||
// function because try/catches deoptimize in certain engines. | ||
var cachedSetTimeout; | ||
var cachedClearTimeout; | ||
function defaultSetTimout() { | ||
throw new Error('setTimeout has not been defined'); | ||
} | ||
function defaultClearTimeout () { | ||
throw new Error('clearTimeout has not been defined'); | ||
} | ||
(function () { | ||
try { | ||
if (typeof setTimeout === 'function') { | ||
cachedSetTimeout = setTimeout; | ||
} else { | ||
cachedSetTimeout = defaultSetTimout; | ||
} | ||
} catch (e) { | ||
cachedSetTimeout = defaultSetTimout; | ||
} | ||
try { | ||
if (typeof clearTimeout === 'function') { | ||
cachedClearTimeout = clearTimeout; | ||
} else { | ||
cachedClearTimeout = defaultClearTimeout; | ||
} | ||
} catch (e) { | ||
cachedClearTimeout = defaultClearTimeout; | ||
} | ||
} ()) | ||
function runTimeout(fun) { | ||
if (cachedSetTimeout === setTimeout) { | ||
//normal enviroments in sane situations | ||
return setTimeout(fun, 0); | ||
} | ||
// if setTimeout wasn't available but was latter defined | ||
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { | ||
cachedSetTimeout = setTimeout; | ||
return setTimeout(fun, 0); | ||
} | ||
try { | ||
// when when somebody has screwed with setTimeout but no I.E. maddness | ||
return cachedSetTimeout(fun, 0); | ||
} catch(e){ | ||
try { | ||
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally | ||
return cachedSetTimeout.call(null, fun, 0); | ||
} catch(e){ | ||
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error | ||
return cachedSetTimeout.call(this, fun, 0); | ||
} | ||
} | ||
} | ||
function runClearTimeout(marker) { | ||
if (cachedClearTimeout === clearTimeout) { | ||
//normal enviroments in sane situations | ||
return clearTimeout(marker); | ||
} | ||
// if clearTimeout wasn't available but was latter defined | ||
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { | ||
cachedClearTimeout = clearTimeout; | ||
return clearTimeout(marker); | ||
} | ||
try { | ||
// when when somebody has screwed with setTimeout but no I.E. maddness | ||
return cachedClearTimeout(marker); | ||
} catch (e){ | ||
try { | ||
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally | ||
return cachedClearTimeout.call(null, marker); | ||
} catch (e){ | ||
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. | ||
// Some versions of I.E. have different rules for clearTimeout vs setTimeout | ||
return cachedClearTimeout.call(this, marker); | ||
} | ||
} | ||
} | ||
var queue = []; | ||
var draining = false; | ||
var currentQueue; | ||
var queueIndex = -1; | ||
function cleanUpNextTick() { | ||
if (!draining || !currentQueue) { | ||
return; | ||
} | ||
draining = false; | ||
if (currentQueue.length) { | ||
queue = currentQueue.concat(queue); | ||
} else { | ||
queueIndex = -1; | ||
} | ||
if (queue.length) { | ||
drainQueue(); | ||
} | ||
} | ||
function drainQueue() { | ||
if (draining) { | ||
return; | ||
} | ||
var timeout = runTimeout(cleanUpNextTick); | ||
draining = true; | ||
var len = queue.length; | ||
while(len) { | ||
currentQueue = queue; | ||
queue = []; | ||
while (++queueIndex < len) { | ||
if (currentQueue) { | ||
currentQueue[queueIndex].run(); | ||
} | ||
} | ||
queueIndex = -1; | ||
len = queue.length; | ||
} | ||
currentQueue = null; | ||
draining = false; | ||
runClearTimeout(timeout); | ||
} | ||
process.nextTick = function (fun) { | ||
var args = new Array(arguments.length - 1); | ||
if (arguments.length > 1) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
args[i - 1] = arguments[i]; | ||
} | ||
} | ||
queue.push(new Item(fun, args)); | ||
if (queue.length === 1 && !draining) { | ||
runTimeout(drainQueue); | ||
} | ||
}; | ||
// v8 likes predictible objects | ||
function Item(fun, array) { | ||
this.fun = fun; | ||
this.array = array; | ||
} | ||
Item.prototype.run = function () { | ||
this.fun.apply(null, this.array); | ||
}; | ||
process.title = 'browser'; | ||
process.browser = true; | ||
process.env = {}; | ||
process.argv = []; | ||
process.version = ''; // empty string to avoid regexp issues | ||
process.versions = {}; | ||
function noop() {} | ||
process.on = noop; | ||
process.addListener = noop; | ||
process.once = noop; | ||
process.off = noop; | ||
process.removeListener = noop; | ||
process.removeAllListeners = noop; | ||
process.emit = noop; | ||
process.prependListener = noop; | ||
process.prependOnceListener = noop; | ||
process.listeners = function (name) { return [] } | ||
process.binding = function (name) { | ||
throw new Error('process.binding is not supported'); | ||
}; | ||
process.cwd = function () { return '/' }; | ||
process.chdir = function (dir) { | ||
throw new Error('process.chdir is not supported'); | ||
}; | ||
process.umask = function() { return 0; }; | ||
},{}],19:[function(require,module,exports){ | ||
"use strict"; | ||
@@ -2100,3 +1903,3 @@ | ||
exports["default"] = _default; | ||
},{}],20:[function(require,module,exports){ | ||
},{}],19:[function(require,module,exports){ | ||
"use strict"; | ||
@@ -2162,2 +1965,2 @@ | ||
} | ||
},{"./browser.js":19,"./node.js":15,"@babel/runtime/helpers/interopRequireDefault":13,"detect-node":16}]},{},[2]); | ||
},{"./browser.js":18,"./node.js":15,"@babel/runtime/helpers/interopRequireDefault":13,"detect-node":16}]},{},[2]); |
@@ -1,1 +0,1 @@ | ||
!function o(r,i,s){function a(t,e){if(!i[t]){if(!r[t]){var n="function"==typeof require&&require;if(!e&&n)return n(t,!0);if(u)return u(t,!0);throw(e=new Error("Cannot find module '"+t+"'")).code="MODULE_NOT_FOUND",e}n=i[t]={exports:{}},r[t][0].call(n.exports,function(e){return a(r[t][1][e]||e)},n,n.exports,o,r,i,s)}return i[t].exports}for(var u="function"==typeof require&&require,e=0;e<s.length;e++)a(s[e]);return a}({1:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.OPEN_BROADCAST_CHANNELS=n.BroadcastChannel=void 0,n.clearNodeFolder=function(e){e=(0,a.fillOptionsWithDefaults)(e);e=(0,s.chooseMethod)(e);return"node"===e.type?e.clearNodeFolder().then(function(){return!0}):i.PROMISE_RESOLVED_FALSE},n.enforceOptions=function(e){r=e};function o(e,t){var n;this.id=c++,u.add(this),this.name=e,r&&(t=r),this.options=(0,a.fillOptionsWithDefaults)(t),this.method=(0,s.chooseMethod)(this.options),this._iL=!1,this._onML=null,this._addEL={message:[],internal:[]},this._uMP=new Set,this._befC=[],this._prepP=null,e=(n=this).method.create(n.name,n.options),(0,i.isPromise)(e)?(n._prepP=e).then(function(e){n._state=e}):n._state=e}var r,i=e("./util.js"),s=e("./method-chooser.js"),a=e("./options.js"),u=new Set,c=(n.OPEN_BROADCAST_CHANNELS=u,0);function l(t,e,n){var o={time:t.method.microSeconds(),type:e,data:n};return(t._prepP||i.PROMISE_RESOLVED_VOID).then(function(){var e=t.method.postMessage(t._state,o);return t._uMP.add(e),e.catch().then(function(){return t._uMP.delete(e)}),e})}function d(e){return 0<e._addEL.message.length||0<e._addEL.internal.length}function f(e,t,n){e._addEL[t].push(n);var o,r,i=e;!i._iL&&d(i)&&(o=function(n){i._addEL[n.type].forEach(function(e){var t=e.time-1e5;n.time>=t&&e.fn(n.data)})},r=i.method.microSeconds(),i._prepP?i._prepP.then(function(){i._iL=!0,i.method.onMessage(i._state,o,r)}):(i._iL=!0,i.method.onMessage(i._state,o,r)))}function h(e,t,n){e._addEL[t]=e._addEL[t].filter(function(e){return e!==n});t=e;t._iL&&!d(t)&&(t._iL=!1,e=t.method.microSeconds(),t.method.onMessage(t._state,null,e))}(n.BroadcastChannel=o)._pubkey=!0,o.prototype={postMessage:function(e){if(this.closed)throw new Error("BroadcastChannel.postMessage(): Cannot post message after channel has closed "+JSON.stringify(e));return l(this,"message",e)},postInternal:function(e){return l(this,"internal",e)},set onmessage(e){var t={time:this.method.microSeconds(),fn:e};h(this,"message",this._onML),e&&"function"==typeof e?(this._onML=t,f(this,"message",t)):this._onML=null},addEventListener:function(e,t){var n=this.method.microSeconds();f(this,e,{time:n,fn:t})},removeEventListener:function(e,t){var n=this._addEL[e].find(function(e){return e.fn===t});h(this,e,n)},close:function(){var e,t=this;if(!this.closed)return u.delete(this),this.closed=!0,e=this._prepP||i.PROMISE_RESOLVED_VOID,this._onML=null,this._addEL.message=[],e.then(function(){return Promise.all(Array.from(t._uMP))}).then(function(){return Promise.all(t._befC.map(function(e){return e()}))}).then(function(){return t.method.close(t._state)})},get type(){return this.method.type},get isClosed(){return this.closed}}},{"./method-chooser.js":6,"./options.js":11,"./util.js":12}],2:[function(e,t,n){"use strict";var e=e("./index.es5.js"),o=e.BroadcastChannel,e=e.createLeaderElection;window.BroadcastChannel2=o,window.createLeaderElection=e},{"./index.es5.js":3}],3:[function(e,t,n){"use strict";e=e("./index.js");t.exports={BroadcastChannel:e.BroadcastChannel,createLeaderElection:e.createLeaderElection,clearNodeFolder:e.clearNodeFolder,enforceOptions:e.enforceOptions,beLeader:e.beLeader}},{"./index.js":4}],4:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"BroadcastChannel",{enumerable:!0,get:function(){return o.BroadcastChannel}}),Object.defineProperty(n,"OPEN_BROADCAST_CHANNELS",{enumerable:!0,get:function(){return o.OPEN_BROADCAST_CHANNELS}}),Object.defineProperty(n,"beLeader",{enumerable:!0,get:function(){return r.beLeader}}),Object.defineProperty(n,"clearNodeFolder",{enumerable:!0,get:function(){return o.clearNodeFolder}}),Object.defineProperty(n,"createLeaderElection",{enumerable:!0,get:function(){return r.createLeaderElection}}),Object.defineProperty(n,"enforceOptions",{enumerable:!0,get:function(){return o.enforceOptions}});var o=e("./broadcast-channel.js"),r=e("./leader-election.js")},{"./broadcast-channel.js":1,"./leader-election.js":5}],5:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.beLeader=l,n.createLeaderElection=function(e,t){if(e._leaderElector)throw new Error("BroadcastChannel already has a leader-elector");t=function(e,t){e=e||{};(e=JSON.parse(JSON.stringify(e))).fallbackInterval||(e.fallbackInterval=3e3);e.responseTime||(e.responseTime=t.method.averageResponseTime(t.options));return e}(t,e);var n=new r(e,t);return e._befC.push(function(){return n.die()}),e._leaderElector=n};var u=e("./util.js"),o=e("unload"),r=function(e,t){function n(e){"leader"===e.context&&("death"===e.action&&(o.hasLeader=!1),"tell"===e.action&&(o.hasLeader=!0))}var o=this;this.broadcastChannel=e,this._options=t,this.isLeader=!1,this.hasLeader=!1,this.isDead=!1,this.token=(0,u.randomToken)(),this._aplQ=u.PROMISE_RESOLVED_VOID,this._aplQC=0,this._unl=[],this._lstns=[],this._dpL=function(){},this._dpLC=!1;this.broadcastChannel.addEventListener("internal",n),this._lstns.push(n)};function c(e,t){t={context:"leader",action:t,token:e.token};return e.broadcastChannel.postInternal(t)}function l(t){t.isLeader=!0,t.hasLeader=!0;function e(e){"leader"===e.context&&"apply"===e.action&&c(t,"tell"),"leader"!==e.context||"tell"!==e.action||t._dpLC||(t._dpLC=!0,t._dpL(),c(t,"tell"))}var n=(0,o.add)(function(){return t.die()});t._unl.push(n);return t.broadcastChannel.addEventListener("internal",e),t._lstns.push(e),c(t,"tell")}r.prototype={applyOnce:function(s){var a=this;return this.isLeader?(0,u.sleep)(0,!0):this.isDead?(0,u.sleep)(0,!1):1<this._aplQC?this._aplQ:(this._aplQC=this._aplQC+1,this._aplQ=this._aplQ.then(function(){return a.isLeader?u.PROMISE_RESOLVED_TRUE:(t=!1,e=new Promise(function(e){n=function(){t=!0,e()}}),o=[],a.broadcastChannel.addEventListener("internal",r=function(e){"leader"===e.context&&e.token!=a.token&&(o.push(e),"apply"===e.action&&e.token>a.token&&n(),"tell"===e.action&&(n(),a.hasLeader=!0))}),i=s?4*a._options.responseTime:a._options.responseTime,c(a,"apply").then(function(){return Promise.race([(0,u.sleep)(i),e.then(function(){return Promise.reject(new Error)})])}).then(function(){return c(a,"apply")}).then(function(){return Promise.race([(0,u.sleep)(i),e.then(function(){return Promise.reject(new Error)})])}).catch(function(){}).then(function(){return a.broadcastChannel.removeEventListener("internal",r),!t&&l(a).then(function(){return!0})}));var t,n,e,o,r,i}).then(function(){a._aplQC=a._aplQC-1}),this._aplQ.then(function(){return a.isLeader}))},awaitLeadership:function(){return this._aLP||(this._aLP=function(r){if(r.isLeader)return u.PROMISE_RESOLVED_VOID;return new Promise(function(e){var t=!1;function n(){t||(t=!0,r.broadcastChannel.removeEventListener("internal",o),e(!0))}r.applyOnce().then(function(){r.isLeader&&n()});(function e(){return(0,u.sleep)(r._options.fallbackInterval).then(function(){if(!r.isDead&&!t)return r.isLeader?void n():r.applyOnce(!0).then(function(){(r.isLeader?n:e)()})})})();var o=function(e){"leader"===e.context&&"death"===e.action&&(r.hasLeader=!1,r.applyOnce().then(function(){r.isLeader&&n()}))};r.broadcastChannel.addEventListener("internal",o),r._lstns.push(o)})}(this)),this._aLP},set onduplicate(e){this._dpL=e},die:function(){var t=this;return this._lstns.forEach(function(e){return t.broadcastChannel.removeEventListener("internal",e)}),this._lstns=[],this._unl.forEach(function(e){return e.remove()}),this._unl=[],this.isLeader&&(this.hasLeader=!1,this.isLeader=!1),this.isDead=!0,c(this,"death")}}},{"./util.js":12,unload:20}],6:[function(e,t,n){"use strict";var o=e("@babel/runtime/helpers/interopRequireDefault"),n=(e("@babel/runtime/helpers/typeof"),Object.defineProperty(n,"__esModule",{value:!0}),n.chooseMethod=function(t){var e=[].concat(t.methods,u).filter(Boolean);if(t.type){if("simulate"===t.type)return s.default;var n=e.find(function(e){return e.type===t.type});if(n)return n;throw new Error("method-type "+t.type+" not found")}t.webWorkerSupport||a.isNode||(e=e.filter(function(e){return"idb"!==e.type}));n=e.find(function(e){return e.canBeUsed()});{if(n)return n;throw new Error("No useable method found in "+JSON.stringify(u.map(function(e){return e.type})))}},o(e("./methods/native.js"))),r=o(e("./methods/indexed-db.js")),i=o(e("./methods/localstorage.js")),s=o(e("./methods/simulate.js")),a=e("./util.js");var u=[n.default,r.default,i.default]},{"./methods/indexed-db.js":7,"./methods/localstorage.js":8,"./methods/native.js":9,"./methods/simulate.js":10,"./util.js":12,"@babel/runtime/helpers/interopRequireDefault":13,"@babel/runtime/helpers/typeof":14}],7:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.TRANSACTION_SETTINGS=void 0,n.averageResponseTime=S,n.canBeUsed=w,n.cleanOldMessages=v,n.close=g,n.commitIndexedDBTransaction=d,n.create=b,n.createDatabase=u,n.default=void 0,n.getAllMessages=function(e){var n=e.transaction(c,"readonly",l),o=n.objectStore(c),r=[];return new Promise(function(t){o.openCursor().onsuccess=function(e){e=e.target.result;e?(r.push(e.value),e.continue()):(d(n),t(r))}})},n.getIdb=a,n.getMessagesHigherThan=h,n.getOldMessages=m,n.microSeconds=void 0,n.onMessage=E,n.postMessage=y,n.removeMessagesById=p,n.type=void 0,n.writeMessage=f;var r=e("../util.js"),i=e("oblivious-set"),s=e("../options.js"),e=r.microSeconds,o=(n.microSeconds=e,"pubkey.broadcast-channel-0-"),c="messages",l={durability:"relaxed"};n.TRANSACTION_SETTINGS=l;function a(){if("undefined"!=typeof indexedDB)return indexedDB;if("undefined"!=typeof window){if(void 0!==window.mozIndexedDB)return window.mozIndexedDB;if(void 0!==window.webkitIndexedDB)return window.webkitIndexedDB;if(void 0!==window.msIndexedDB)return window.msIndexedDB}return!1}function d(e){e.commit&&e.commit()}function u(e){var n=a().open(o+e);return n.onupgradeneeded=function(e){e.target.result.createObjectStore(c,{keyPath:"id",autoIncrement:!0})},new Promise(function(e,t){n.onerror=function(e){return t(e)},n.onsuccess=function(){e(n.result)}})}function f(e,t,n){var o={uuid:t,time:(new Date).getTime(),data:n},r=e.transaction([c],"readwrite",l);return new Promise(function(e,t){r.oncomplete=function(){return e()},r.onerror=function(e){return t(e)},r.objectStore(c).add(o),d(r)})}function h(e,o){var r,i=e.transaction(c,"readonly",l),s=i.objectStore(c),a=[],u=IDBKeyRange.bound(o+1,1/0);return s.getAll?(r=s.getAll(u),new Promise(function(t,n){r.onerror=function(e){return n(e)},r.onsuccess=function(e){t(e.target.result)}})):new Promise(function(t,n){var e=function(){try{return u=IDBKeyRange.bound(o+1,1/0),s.openCursor(u)}catch(e){return s.openCursor()}}();e.onerror=function(e){return n(e)},e.onsuccess=function(e){e=e.target.result;e?e.value.id<o+1?e.continue(o+1):(a.push(e.value),e.continue()):(d(i),t(a))}})}function p(e,t){var n=e.transaction([c],"readwrite",l).objectStore(c);return Promise.all(t.map(function(e){var t=n.delete(e);return new Promise(function(e){t.onsuccess=function(){return e()}})}))}function m(e,t){var o=(new Date).getTime()-t,r=e.transaction(c,"readonly",l),i=r.objectStore(c),s=[];return new Promise(function(n){i.openCursor().onsuccess=function(e){var t,e=e.target.result;e?(t=e.value).time<o?(s.push(t),e.continue()):(d(r),n(s)):n(s)}})}function v(t,e){return m(t,e).then(function(e){return p(t,e.map(function(e){return e.id}))})}function b(n,o){return o=(0,s.fillOptionsWithDefaults)(o),u(n).then(function(e){var t={closed:!1,lastCursorId:0,channelName:n,options:o,uuid:(0,r.randomToken)(),eMIs:new i.ObliviousSet(2*o.idb.ttl),writeBlockPromise:r.PROMISE_RESOLVED_VOID,messagesCallback:null,readQueuePromises:[],db:e};return e.onclose=function(){t.closed=!0,o.idb.onclose&&o.idb.onclose()},function e(t){if(t.closed)return;_(t).then(function(){return(0,r.sleep)(t.options.idb.fallbackInterval)}).then(function(){return e(t)})}(t),t})}function _(n){return!n.closed&&n.messagesCallback?h(n.db,n.lastCursorId).then(function(e){return e.filter(function(e){return!!e}).map(function(e){return e.id>n.lastCursorId&&(n.lastCursorId=e.id),e}).filter(function(e){return t=n,(e=e).uuid!==t.uuid&&(!t.eMIs.has(e.id)&&!(e.data.time<t.messagesCallbackTime));var t}).sort(function(e,t){return e.time-t.time}).forEach(function(e){n.messagesCallback&&(n.eMIs.add(e.id),n.messagesCallback(e.data))}),r.PROMISE_RESOLVED_VOID}):r.PROMISE_RESOLVED_VOID}function g(e){e.closed=!0,e.db.close()}function y(e,t){return e.writeBlockPromise=e.writeBlockPromise.then(function(){return f(e.db,e.uuid,t)}).then(function(){0===(0,r.randomInt)(0,10)&&v(e.db,e.options.idb.ttl)}),e.writeBlockPromise}function E(e,t,n){e.messagesCallbackTime=n,e.messagesCallback=t,_(e)}function w(){return!r.isNode&&!!a()}function S(e){return 2*e.idb.fallbackInterval}n.type="idb",n.default={create:b,close:g,onMessage:E,postMessage:y,canBeUsed:w,type:"idb",averageResponseTime:S,microSeconds:e}},{"../options.js":11,"../util.js":12,"oblivious-set":17}],8:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.addStorageEventListener=d,n.averageResponseTime=b,n.canBeUsed=v,n.close=p,n.create=h,n.default=void 0,n.getLocalStorage=u,n.microSeconds=void 0,n.onMessage=m,n.postMessage=l,n.removeStorageEventListener=f,n.storageKey=c,n.type=void 0;var i=e("oblivious-set"),s=e("../options.js"),a=e("../util.js"),e=a.microSeconds,r=(n.microSeconds=e,"pubkey.broadcastChannel-"),o="localstorage";function u(){var e;if("undefined"==typeof window)return null;try{e=window.localStorage,e=window["ie8-eventlistener/storage"]||window.localStorage}catch(e){}return e}function c(e){return r+e}function l(r,i){return new Promise(function(o){(0,a.sleep)().then(function(){var e=c(r.channelName),t={token:(0,a.randomToken)(),time:(new Date).getTime(),data:i,uuid:r.uuid},t=JSON.stringify(t),n=(u().setItem(e,t),document.createEvent("Event"));n.initEvent("storage",!0,!0),n.key=e,n.newValue=t,window.dispatchEvent(n),o()})})}function d(e,t){function n(e){e.key===o&&t(JSON.parse(e.newValue))}var o=r+e;return window.addEventListener("storage",n),n}function f(e){window.removeEventListener("storage",e)}function h(e,t){var n,o,r;if(t=(0,s.fillOptionsWithDefaults)(t),v())return n=(0,a.randomToken)(),o=new i.ObliviousSet(t.localstorage.removeTimeout),(r={channelName:e,uuid:n,eMIs:o}).listener=d(e,function(e){!r.messagesCallback||e.uuid===n||!e.token||o.has(e.token)||e.data.time&&e.data.time<r.messagesCallbackTime||(o.add(e.token),r.messagesCallback(e.data))}),r;throw new Error("BroadcastChannel: localstorage cannot be used")}function p(e){f(e.listener)}function m(e,t,n){e.messagesCallbackTime=n,e.messagesCallback=t}function v(){if(a.isNode)return!1;var e=u();if(!e)return!1;try{var t="__broadcastchannel_check";e.setItem(t,"works"),e.removeItem(t)}catch(e){return!1}return!0}function b(){var e=navigator.userAgent.toLowerCase();return e.includes("safari")&&!e.includes("chrome")?240:120}n.type=o,n.default={create:h,close:p,onMessage:m,postMessage:l,canBeUsed:v,type:o,averageResponseTime:b,microSeconds:e}},{"../options.js":11,"../util.js":12,"oblivious-set":17}],9:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.averageResponseTime=c,n.canBeUsed=u,n.close=i,n.create=r,n.microSeconds=n.default=void 0,n.onMessage=a,n.postMessage=s,n.type=void 0;var o=e("../util.js"),e=o.microSeconds;n.microSeconds=e;function r(e){var t={messagesCallback:null,bc:new BroadcastChannel(e),subFns:[]};return t.bc.onmessage=function(e){t.messagesCallback&&t.messagesCallback(e.data)},t}function i(e){e.bc.close(),e.subFns=[]}function s(e,t){try{return e.bc.postMessage(t,!1),o.PROMISE_RESOLVED_VOID}catch(e){return Promise.reject(e)}}function a(e,t){e.messagesCallback=t}function u(){if(o.isNode&&"undefined"==typeof window)return!1;if("function"!=typeof BroadcastChannel)return!1;if(BroadcastChannel._pubkey)throw new Error("BroadcastChannel: Do not overwrite window.BroadcastChannel with this module, this is not a polyfill");return!0}function c(){return 150}n.type="native",n.default={create:r,close:i,onMessage:a,postMessage:s,canBeUsed:u,type:"native",averageResponseTime:c,microSeconds:e}},{"../util.js":12}],10:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.averageResponseTime=l,n.canBeUsed=c,n.close=s,n.create=i,n.microSeconds=n.default=void 0,n.onMessage=u,n.postMessage=a,n.type=void 0;var e=e("../util.js").microSeconds,o=(n.microSeconds=e,"simulate"),r=(n.type=o,new Set);function i(e){e={name:e,messagesCallback:null};return r.add(e),e}function s(e){r.delete(e)}function a(t,n){return new Promise(function(e){return setTimeout(function(){Array.from(r).filter(function(e){return e.name===t.name}).filter(function(e){return e!==t}).filter(function(e){return!!e.messagesCallback}).forEach(function(e){return e.messagesCallback(n)}),e()},5)})}function u(e,t){e.messagesCallback=t}function c(){return!0}function l(){return 5}n.default={create:i,close:s,onMessage:u,postMessage:a,canBeUsed:c,type:o,averageResponseTime:l,microSeconds:e}},{"../util.js":12}],11:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.fillOptionsWithDefaults=function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},t=JSON.parse(JSON.stringify(e));void 0===t.webWorkerSupport&&(t.webWorkerSupport=!0);t.idb||(t.idb={});t.idb.ttl||(t.idb.ttl=45e3);t.idb.fallbackInterval||(t.idb.fallbackInterval=150);e.idb&&"function"==typeof e.idb.onclose&&(t.idb.onclose=e.idb.onclose);t.localstorage||(t.localstorage={});t.localstorage.removeTimeout||(t.localstorage.removeTimeout=6e4);e.methods&&(t.methods=e.methods);t.node||(t.node={});t.node.ttl||(t.node.ttl=12e4);t.node.maxParallelWrites||(t.node.maxParallelWrites=2048);void 0===t.node.useFastPath&&(t.node.useFastPath=!0);return t}},{}],12:[function(e,t,r){!function(o){!function(){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.isNode=r.PROMISE_RESOLVED_VOID=r.PROMISE_RESOLVED_TRUE=r.PROMISE_RESOLVED_FALSE=void 0,r.isPromise=function(e){return!(!e||"function"!=typeof e.then)},r.microSeconds=function(){var e=(new Date).getTime();return e===t?1e3*e+ ++n:(n=0,1e3*(t=e))},r.randomInt=function(e,t){return Math.floor(Math.random()*(t-e+1)+e)},r.randomToken=function(){return Math.random().toString(36).substring(2)},r.sleep=function(t,n){t=t||0;return new Promise(function(e){return setTimeout(function(){return e(n)},t)})};var e=Promise.resolve(!1),e=(r.PROMISE_RESOLVED_FALSE=e,Promise.resolve(!0)),e=(r.PROMISE_RESOLVED_TRUE=e,Promise.resolve());r.PROMISE_RESOLVED_VOID=e;var t=0,n=0;e="[object process]"===Object.prototype.toString.call(void 0!==o?o:0);r.isNode=e}.call(this)}.call(this,e("_process"))},{_process:18}],13:[function(e,t,n){t.exports=function(e){return e&&e.__esModule?e:{default:e}},t.exports.__esModule=!0,t.exports.default=t.exports},{}],14:[function(e,t,n){function o(e){return t.exports=o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t.exports.__esModule=!0,t.exports.default=t.exports,o(e)}t.exports=o,t.exports.__esModule=!0,t.exports.default=t.exports},{}],15:[function(e,t,n){},{}],16:[function(e,t,n){t.exports=!1},{}],17:[function(e,t,n){"use strict";function o(e){this.ttl=e,this.map=new Map,this._to=!1}function r(e){for(var t=i()-e.ttl,n=e.map[Symbol.iterator]();;){var o=n.next().value;if(!o)return;var r=o[0];if(!(o[1]<t))return;e.map.delete(r)}}function i(){return(new Date).getTime()}Object.defineProperty(n,"__esModule",{value:!0}),n.now=n.removeTooOldValues=n.ObliviousSet=void 0,o.prototype.has=function(e){return this.map.has(e)},o.prototype.add=function(e){var t=this;this.map.set(e,i()),this._to||(this._to=!0,setTimeout(function(){t._to=!1,r(t)},0))},o.prototype.clear=function(){this.map.clear()},n.ObliviousSet=o,n.removeTooOldValues=r,n.now=i},{}],18:[function(e,t,n){var o,r,t=t.exports={};function i(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}try{o="function"==typeof setTimeout?setTimeout:i}catch(e){o=i}try{r="function"==typeof clearTimeout?clearTimeout:s}catch(e){r=s}function a(t){if(o===setTimeout)return setTimeout(t,0);if((o===i||!o)&&setTimeout)return(o=setTimeout)(t,0);try{return o(t,0)}catch(e){try{return o.call(null,t,0)}catch(e){return o.call(this,t,0)}}}var u,c=[],l=!1,d=-1;function f(){l&&u&&(l=!1,u.length?c=u.concat(c):d=-1,c.length&&h())}function h(){if(!l){for(var e=a(f),t=(l=!0,c.length);t;){for(u=c,c=[];++d<t;)u&&u[d].run();d=-1,t=c.length}u=null,l=!1,!function(t){if(r===clearTimeout)return clearTimeout(t);if((r===s||!r)&&clearTimeout)return(r=clearTimeout)(t);try{r(t)}catch(e){try{return r.call(null,t)}catch(e){return r.call(this,t)}}}(e)}}function p(e,t){this.fun=e,this.array=t}function m(){}t.nextTick=function(e){var t=new Array(arguments.length-1);if(1<arguments.length)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];c.push(new p(e,t)),1!==c.length||l||a(h)},p.prototype.run=function(){this.fun.apply(null,this.array)},t.title="browser",t.browser=!0,t.env={},t.argv=[],t.version="",t.versions={},t.on=m,t.addListener=m,t.once=m,t.off=m,t.removeListener=m,t.removeAllListeners=m,t.emit=m,t.prependListener=m,t.prependOnceListener=m,t.listeners=function(e){return[]},t.binding=function(e){throw new Error("process.binding is not supported")},t.cwd=function(){return"/"},t.chdir=function(e){throw new Error("process.chdir is not supported")},t.umask=function(){return 0}},{}],19:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0,n.default={add:function(e){"function"==typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope||"function"==typeof window.addEventListener&&(window.addEventListener("beforeunload",function(){e()},!0),window.addEventListener("unload",function(){e()},!0))}}},{}],20:[function(e,t,n){"use strict";var o=e("@babel/runtime/helpers/interopRequireDefault"),n=(Object.defineProperty(n,"__esModule",{value:!0}),n.add=function(e){if(a||(a=!0,i.add(u)),"function"!=typeof e)throw new Error("Listener is no function");return s.add(e),{remove:function(){return s.delete(e)},run:function(){return s.delete(e),e()}}},n.getSize=function(){return s.size},n.removeAll=function(){s.clear()},n.runAll=u,o(e("detect-node"))),r=o(e("./browser.js")),o=o(e("./node.js")),i=(n.default?o:r).default,s=new Set,a=!1;function u(){var t=[];return s.forEach(function(e){t.push(e()),s.delete(e)}),Promise.all(t)}},{"./browser.js":19,"./node.js":15,"@babel/runtime/helpers/interopRequireDefault":13,"detect-node":16}]},{},[2]); | ||
!function o(r,i,s){function a(t,e){if(!i[t]){if(!r[t]){var n="function"==typeof require&&require;if(!e&&n)return n(t,!0);if(u)return u(t,!0);throw(e=new Error("Cannot find module '"+t+"'")).code="MODULE_NOT_FOUND",e}n=i[t]={exports:{}},r[t][0].call(n.exports,function(e){return a(r[t][1][e]||e)},n,n.exports,o,r,i,s)}return i[t].exports}for(var u="function"==typeof require&&require,e=0;e<s.length;e++)a(s[e]);return a}({1:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.OPEN_BROADCAST_CHANNELS=n.BroadcastChannel=void 0,n.clearNodeFolder=function(e){e=(0,a.fillOptionsWithDefaults)(e);e=(0,s.chooseMethod)(e);return"node"===e.type?e.clearNodeFolder().then(function(){return!0}):i.PROMISE_RESOLVED_FALSE},n.enforceOptions=function(e){r=e};function o(e,t){var n;this.id=c++,u.add(this),this.name=e,r&&(t=r),this.options=(0,a.fillOptionsWithDefaults)(t),this.method=(0,s.chooseMethod)(this.options),this._iL=!1,this._onML=null,this._addEL={message:[],internal:[]},this._uMP=new Set,this._befC=[],this._prepP=null,e=(n=this).method.create(n.name,n.options),(0,i.isPromise)(e)?(n._prepP=e).then(function(e){n._state=e}):n._state=e}var r,i=e("./util.js"),s=e("./method-chooser.js"),a=e("./options.js"),u=new Set,c=(n.OPEN_BROADCAST_CHANNELS=u,0);function d(t,e,n){var o={time:t.method.microSeconds(),type:e,data:n};return(t._prepP||i.PROMISE_RESOLVED_VOID).then(function(){var e=t.method.postMessage(t._state,o);return t._uMP.add(e),e.catch().then(function(){return t._uMP.delete(e)}),e})}function l(e){return 0<e._addEL.message.length||0<e._addEL.internal.length}function f(e,t,n){e._addEL[t].push(n);var o,r,i=e;!i._iL&&l(i)&&(o=function(n){i._addEL[n.type].forEach(function(e){var t=e.time-1e5;n.time>=t&&e.fn(n.data)})},r=i.method.microSeconds(),i._prepP?i._prepP.then(function(){i._iL=!0,i.method.onMessage(i._state,o,r)}):(i._iL=!0,i.method.onMessage(i._state,o,r)))}function h(e,t,n){e._addEL[t]=e._addEL[t].filter(function(e){return e!==n});t=e;t._iL&&!l(t)&&(t._iL=!1,e=t.method.microSeconds(),t.method.onMessage(t._state,null,e))}(n.BroadcastChannel=o)._pubkey=!0,o.prototype={postMessage:function(e){if(this.closed)throw new Error("BroadcastChannel.postMessage(): Cannot post message after channel has closed "+JSON.stringify(e));return d(this,"message",e)},postInternal:function(e){return d(this,"internal",e)},set onmessage(e){var t={time:this.method.microSeconds(),fn:e};h(this,"message",this._onML),e&&"function"==typeof e?(this._onML=t,f(this,"message",t)):this._onML=null},addEventListener:function(e,t){var n=this.method.microSeconds();f(this,e,{time:n,fn:t})},removeEventListener:function(e,t){var n=this._addEL[e].find(function(e){return e.fn===t});h(this,e,n)},close:function(){var e,t=this;if(!this.closed)return u.delete(this),this.closed=!0,e=this._prepP||i.PROMISE_RESOLVED_VOID,this._onML=null,this._addEL.message=[],e.then(function(){return Promise.all(Array.from(t._uMP))}).then(function(){return Promise.all(t._befC.map(function(e){return e()}))}).then(function(){return t.method.close(t._state)})},get type(){return this.method.type},get isClosed(){return this.closed}}},{"./method-chooser.js":6,"./options.js":11,"./util.js":12}],2:[function(e,t,n){"use strict";var e=e("./index.es5.js"),o=e.BroadcastChannel,e=e.createLeaderElection;window.BroadcastChannel2=o,window.createLeaderElection=e},{"./index.es5.js":3}],3:[function(e,t,n){"use strict";e=e("./index.js");t.exports={BroadcastChannel:e.BroadcastChannel,createLeaderElection:e.createLeaderElection,clearNodeFolder:e.clearNodeFolder,enforceOptions:e.enforceOptions,beLeader:e.beLeader}},{"./index.js":4}],4:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"BroadcastChannel",{enumerable:!0,get:function(){return o.BroadcastChannel}}),Object.defineProperty(n,"OPEN_BROADCAST_CHANNELS",{enumerable:!0,get:function(){return o.OPEN_BROADCAST_CHANNELS}}),Object.defineProperty(n,"beLeader",{enumerable:!0,get:function(){return r.beLeader}}),Object.defineProperty(n,"clearNodeFolder",{enumerable:!0,get:function(){return o.clearNodeFolder}}),Object.defineProperty(n,"createLeaderElection",{enumerable:!0,get:function(){return r.createLeaderElection}}),Object.defineProperty(n,"enforceOptions",{enumerable:!0,get:function(){return o.enforceOptions}});var o=e("./broadcast-channel.js"),r=e("./leader-election.js")},{"./broadcast-channel.js":1,"./leader-election.js":5}],5:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.beLeader=d,n.createLeaderElection=function(e,t){if(e._leaderElector)throw new Error("BroadcastChannel already has a leader-elector");t=function(e,t){e=e||{};(e=JSON.parse(JSON.stringify(e))).fallbackInterval||(e.fallbackInterval=3e3);e.responseTime||(e.responseTime=t.method.averageResponseTime(t.options));return e}(t,e);var n=new r(e,t);return e._befC.push(function(){return n.die()}),e._leaderElector=n};var u=e("./util.js"),o=e("unload"),r=function(e,t){function n(e){"leader"===e.context&&("death"===e.action&&(o.hasLeader=!1),"tell"===e.action&&(o.hasLeader=!0))}var o=this;this.broadcastChannel=e,this._options=t,this.isLeader=!1,this.hasLeader=!1,this.isDead=!1,this.token=(0,u.randomToken)(),this._aplQ=u.PROMISE_RESOLVED_VOID,this._aplQC=0,this._unl=[],this._lstns=[],this._dpL=function(){},this._dpLC=!1;this.broadcastChannel.addEventListener("internal",n),this._lstns.push(n)};function c(e,t){t={context:"leader",action:t,token:e.token};return e.broadcastChannel.postInternal(t)}function d(t){t.isLeader=!0,t.hasLeader=!0;function e(e){"leader"===e.context&&"apply"===e.action&&c(t,"tell"),"leader"!==e.context||"tell"!==e.action||t._dpLC||(t._dpLC=!0,t._dpL(),c(t,"tell"))}var n=(0,o.add)(function(){return t.die()});t._unl.push(n);return t.broadcastChannel.addEventListener("internal",e),t._lstns.push(e),c(t,"tell")}r.prototype={applyOnce:function(s){var a=this;return this.isLeader?(0,u.sleep)(0,!0):this.isDead?(0,u.sleep)(0,!1):1<this._aplQC?this._aplQ:(this._aplQC=this._aplQC+1,this._aplQ=this._aplQ.then(function(){return a.isLeader?u.PROMISE_RESOLVED_TRUE:(t=!1,e=new Promise(function(e){n=function(){t=!0,e()}}),o=[],a.broadcastChannel.addEventListener("internal",r=function(e){"leader"===e.context&&e.token!=a.token&&(o.push(e),"apply"===e.action&&e.token>a.token&&n(),"tell"===e.action&&(n(),a.hasLeader=!0))}),i=s?4*a._options.responseTime:a._options.responseTime,c(a,"apply").then(function(){return Promise.race([(0,u.sleep)(i),e.then(function(){return Promise.reject(new Error)})])}).then(function(){return c(a,"apply")}).then(function(){return Promise.race([(0,u.sleep)(i),e.then(function(){return Promise.reject(new Error)})])}).catch(function(){}).then(function(){return a.broadcastChannel.removeEventListener("internal",r),!t&&d(a).then(function(){return!0})}));var t,n,e,o,r,i}).then(function(){a._aplQC=a._aplQC-1}),this._aplQ.then(function(){return a.isLeader}))},awaitLeadership:function(){return this._aLP||(this._aLP=function(r){if(r.isLeader)return u.PROMISE_RESOLVED_VOID;return new Promise(function(e){var t=!1;function n(){t||(t=!0,r.broadcastChannel.removeEventListener("internal",o),e(!0))}r.applyOnce().then(function(){r.isLeader&&n()});(function e(){return(0,u.sleep)(r._options.fallbackInterval).then(function(){if(!r.isDead&&!t)return r.isLeader?void n():r.applyOnce(!0).then(function(){(r.isLeader?n:e)()})})})();var o=function(e){"leader"===e.context&&"death"===e.action&&(r.hasLeader=!1,r.applyOnce().then(function(){r.isLeader&&n()}))};r.broadcastChannel.addEventListener("internal",o),r._lstns.push(o)})}(this)),this._aLP},set onduplicate(e){this._dpL=e},die:function(){var t=this;return this._lstns.forEach(function(e){return t.broadcastChannel.removeEventListener("internal",e)}),this._lstns=[],this._unl.forEach(function(e){return e.remove()}),this._unl=[],this.isLeader&&(this.hasLeader=!1,this.isLeader=!1),this.isDead=!0,c(this,"death")}}},{"./util.js":12,unload:19}],6:[function(e,t,n){"use strict";var o=e("@babel/runtime/helpers/interopRequireDefault"),n=(e("@babel/runtime/helpers/typeof"),Object.defineProperty(n,"__esModule",{value:!0}),n.chooseMethod=function(t){var e=[].concat(t.methods,a).filter(Boolean);if(t.type){if("simulate"===t.type)return s.default;var n=e.find(function(e){return e.type===t.type});if(n)return n;throw new Error("method-type "+t.type+" not found")}t.webWorkerSupport||(e=e.filter(function(e){return"idb"!==e.type}));n=e.find(function(e){return e.canBeUsed()});{if(n)return n;throw new Error("No useable method found in "+JSON.stringify(a.map(function(e){return e.type})))}},o(e("./methods/native.js"))),r=o(e("./methods/indexed-db.js")),i=o(e("./methods/localstorage.js")),s=o(e("./methods/simulate.js"));var a=[n.default,r.default,i.default]},{"./methods/indexed-db.js":7,"./methods/localstorage.js":8,"./methods/native.js":9,"./methods/simulate.js":10,"@babel/runtime/helpers/interopRequireDefault":13,"@babel/runtime/helpers/typeof":14}],7:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.TRANSACTION_SETTINGS=void 0,n.averageResponseTime=w,n.canBeUsed=S,n.cleanOldMessages=v,n.close=g,n.commitIndexedDBTransaction=l,n.create=_,n.createDatabase=u,n.default=void 0,n.getAllMessages=function(e){var n=e.transaction(c,"readonly",d),o=n.objectStore(c),r=[];return new Promise(function(t){o.openCursor().onsuccess=function(e){e=e.target.result;e?(r.push(e.value),e.continue()):(l(n),t(r))}})},n.getIdb=a,n.getMessagesHigherThan=h,n.getOldMessages=m,n.microSeconds=void 0,n.onMessage=y,n.postMessage=E,n.removeMessagesById=p,n.type=void 0,n.writeMessage=f;var r=e("../util.js"),i=e("oblivious-set"),s=e("../options.js"),e=r.microSeconds,o=(n.microSeconds=e,"pubkey.broadcast-channel-0-"),c="messages",d={durability:"relaxed"};n.TRANSACTION_SETTINGS=d;function a(){if("undefined"!=typeof indexedDB)return indexedDB;if("undefined"!=typeof window){if(void 0!==window.mozIndexedDB)return window.mozIndexedDB;if(void 0!==window.webkitIndexedDB)return window.webkitIndexedDB;if(void 0!==window.msIndexedDB)return window.msIndexedDB}return!1}function l(e){e.commit&&e.commit()}function u(e){var n=a().open(o+e);return n.onupgradeneeded=function(e){e.target.result.createObjectStore(c,{keyPath:"id",autoIncrement:!0})},new Promise(function(e,t){n.onerror=function(e){return t(e)},n.onsuccess=function(){e(n.result)}})}function f(e,t,n){var o={uuid:t,time:(new Date).getTime(),data:n},r=e.transaction([c],"readwrite",d);return new Promise(function(e,t){r.oncomplete=function(){return e()},r.onerror=function(e){return t(e)},r.objectStore(c).add(o),l(r)})}function h(e,o){var r,i=e.transaction(c,"readonly",d),s=i.objectStore(c),a=[],u=IDBKeyRange.bound(o+1,1/0);return s.getAll?(r=s.getAll(u),new Promise(function(t,n){r.onerror=function(e){return n(e)},r.onsuccess=function(e){t(e.target.result)}})):new Promise(function(t,n){var e=function(){try{return u=IDBKeyRange.bound(o+1,1/0),s.openCursor(u)}catch(e){return s.openCursor()}}();e.onerror=function(e){return n(e)},e.onsuccess=function(e){e=e.target.result;e?e.value.id<o+1?e.continue(o+1):(a.push(e.value),e.continue()):(l(i),t(a))}})}function p(e,t){var n=e.transaction([c],"readwrite",d).objectStore(c);return Promise.all(t.map(function(e){var t=n.delete(e);return new Promise(function(e){t.onsuccess=function(){return e()}})}))}function m(e,t){var o=(new Date).getTime()-t,r=e.transaction(c,"readonly",d),i=r.objectStore(c),s=[];return new Promise(function(n){i.openCursor().onsuccess=function(e){var t,e=e.target.result;e?(t=e.value).time<o?(s.push(t),e.continue()):(l(r),n(s)):n(s)}})}function v(t,e){return m(t,e).then(function(e){return p(t,e.map(function(e){return e.id}))})}function _(n,o){return o=(0,s.fillOptionsWithDefaults)(o),u(n).then(function(e){var t={closed:!1,lastCursorId:0,channelName:n,options:o,uuid:(0,r.randomToken)(),eMIs:new i.ObliviousSet(2*o.idb.ttl),writeBlockPromise:r.PROMISE_RESOLVED_VOID,messagesCallback:null,readQueuePromises:[],db:e};return e.onclose=function(){t.closed=!0,o.idb.onclose&&o.idb.onclose()},function e(t){if(t.closed)return;b(t).then(function(){return(0,r.sleep)(t.options.idb.fallbackInterval)}).then(function(){return e(t)})}(t),t})}function b(n){return!n.closed&&n.messagesCallback?h(n.db,n.lastCursorId).then(function(e){return e.filter(function(e){return!!e}).map(function(e){return e.id>n.lastCursorId&&(n.lastCursorId=e.id),e}).filter(function(e){return t=n,(e=e).uuid!==t.uuid&&(!t.eMIs.has(e.id)&&!(e.data.time<t.messagesCallbackTime));var t}).sort(function(e,t){return e.time-t.time}).forEach(function(e){n.messagesCallback&&(n.eMIs.add(e.id),n.messagesCallback(e.data))}),r.PROMISE_RESOLVED_VOID}):r.PROMISE_RESOLVED_VOID}function g(e){e.closed=!0,e.db.close()}function E(e,t){return e.writeBlockPromise=e.writeBlockPromise.then(function(){return f(e.db,e.uuid,t)}).then(function(){0===(0,r.randomInt)(0,10)&&v(e.db,e.options.idb.ttl)}),e.writeBlockPromise}function y(e,t,n){e.messagesCallbackTime=n,e.messagesCallback=t,b(e)}function S(){return!!a()}function w(e){return 2*e.idb.fallbackInterval}n.type="idb",n.default={create:_,close:g,onMessage:y,postMessage:E,canBeUsed:S,type:"idb",averageResponseTime:w,microSeconds:e}},{"../options.js":11,"../util.js":12,"oblivious-set":17}],8:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.addStorageEventListener=l,n.averageResponseTime=_,n.canBeUsed=v,n.close=p,n.create=h,n.default=void 0,n.getLocalStorage=u,n.microSeconds=void 0,n.onMessage=m,n.postMessage=d,n.removeStorageEventListener=f,n.storageKey=c,n.type=void 0;var i=e("oblivious-set"),s=e("../options.js"),a=e("../util.js"),e=a.microSeconds,r=(n.microSeconds=e,"pubkey.broadcastChannel-"),o="localstorage";function u(){var e;if("undefined"==typeof window)return null;try{e=window.localStorage,e=window["ie8-eventlistener/storage"]||window.localStorage}catch(e){}return e}function c(e){return r+e}function d(r,i){return new Promise(function(o){(0,a.sleep)().then(function(){var e=c(r.channelName),t={token:(0,a.randomToken)(),time:(new Date).getTime(),data:i,uuid:r.uuid},t=JSON.stringify(t),n=(u().setItem(e,t),document.createEvent("Event"));n.initEvent("storage",!0,!0),n.key=e,n.newValue=t,window.dispatchEvent(n),o()})})}function l(e,t){function n(e){e.key===o&&t(JSON.parse(e.newValue))}var o=r+e;return window.addEventListener("storage",n),n}function f(e){window.removeEventListener("storage",e)}function h(e,t){var n,o,r;if(t=(0,s.fillOptionsWithDefaults)(t),v())return n=(0,a.randomToken)(),o=new i.ObliviousSet(t.localstorage.removeTimeout),(r={channelName:e,uuid:n,eMIs:o}).listener=l(e,function(e){!r.messagesCallback||e.uuid===n||!e.token||o.has(e.token)||e.data.time&&e.data.time<r.messagesCallbackTime||(o.add(e.token),r.messagesCallback(e.data))}),r;throw new Error("BroadcastChannel: localstorage cannot be used")}function p(e){f(e.listener)}function m(e,t,n){e.messagesCallbackTime=n,e.messagesCallback=t}function v(){var e=u();if(!e)return!1;try{var t="__broadcastchannel_check";e.setItem(t,"works"),e.removeItem(t)}catch(e){return!1}return!0}function _(){var e=navigator.userAgent.toLowerCase();return e.includes("safari")&&!e.includes("chrome")?240:120}n.type=o,n.default={create:h,close:p,onMessage:m,postMessage:d,canBeUsed:v,type:o,averageResponseTime:_,microSeconds:e}},{"../options.js":11,"../util.js":12,"oblivious-set":17}],9:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.averageResponseTime=c,n.canBeUsed=u,n.close=i,n.create=r,n.microSeconds=n.default=void 0,n.onMessage=a,n.postMessage=s,n.type=void 0;var o=e("../util.js"),e=o.microSeconds;n.microSeconds=e;function r(e){var t={messagesCallback:null,bc:new BroadcastChannel(e),subFns:[]};return t.bc.onmessage=function(e){t.messagesCallback&&t.messagesCallback(e.data)},t}function i(e){e.bc.close(),e.subFns=[]}function s(e,t){try{return e.bc.postMessage(t,!1),o.PROMISE_RESOLVED_VOID}catch(e){return Promise.reject(e)}}function a(e,t){e.messagesCallback=t}function u(){if("undefined"==typeof window)return!1;if("function"!=typeof BroadcastChannel)return!1;if(BroadcastChannel._pubkey)throw new Error("BroadcastChannel: Do not overwrite window.BroadcastChannel with this module, this is not a polyfill");return!0}function c(){return 150}n.type="native",n.default={create:r,close:i,onMessage:a,postMessage:s,canBeUsed:u,type:"native",averageResponseTime:c,microSeconds:e}},{"../util.js":12}],10:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.averageResponseTime=d,n.canBeUsed=c,n.close=s,n.create=i,n.microSeconds=n.default=void 0,n.onMessage=u,n.postMessage=a,n.type=void 0;var e=e("../util.js").microSeconds,o=(n.microSeconds=e,"simulate"),r=(n.type=o,new Set);function i(e){e={name:e,messagesCallback:null};return r.add(e),e}function s(e){r.delete(e)}function a(t,n){return new Promise(function(e){return setTimeout(function(){Array.from(r).filter(function(e){return e.name===t.name}).filter(function(e){return e!==t}).filter(function(e){return!!e.messagesCallback}).forEach(function(e){return e.messagesCallback(n)}),e()},5)})}function u(e,t){e.messagesCallback=t}function c(){return!0}function d(){return 5}n.default={create:i,close:s,onMessage:u,postMessage:a,canBeUsed:c,type:o,averageResponseTime:d,microSeconds:e}},{"../util.js":12}],11:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.fillOptionsWithDefaults=function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},t=JSON.parse(JSON.stringify(e));void 0===t.webWorkerSupport&&(t.webWorkerSupport=!0);t.idb||(t.idb={});t.idb.ttl||(t.idb.ttl=45e3);t.idb.fallbackInterval||(t.idb.fallbackInterval=150);e.idb&&"function"==typeof e.idb.onclose&&(t.idb.onclose=e.idb.onclose);t.localstorage||(t.localstorage={});t.localstorage.removeTimeout||(t.localstorage.removeTimeout=6e4);e.methods&&(t.methods=e.methods);t.node||(t.node={});t.node.ttl||(t.node.ttl=12e4);t.node.maxParallelWrites||(t.node.maxParallelWrites=2048);void 0===t.node.useFastPath&&(t.node.useFastPath=!0);return t}},{}],12:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.PROMISE_RESOLVED_VOID=n.PROMISE_RESOLVED_TRUE=n.PROMISE_RESOLVED_FALSE=void 0,n.isPromise=function(e){return!(!e||"function"!=typeof e.then)},n.microSeconds=function(){var e=(new Date).getTime();return e===r?1e3*e+ ++i:(i=0,1e3*(r=e))},n.randomInt=function(e,t){return Math.floor(Math.random()*(t-e+1)+e)},n.randomToken=function(){return Math.random().toString(36).substring(2)},n.sleep=function(t,n){t=t||0;return new Promise(function(e){return setTimeout(function(){return e(n)},t)})};var o=Promise.resolve(!1),o=(n.PROMISE_RESOLVED_FALSE=o,Promise.resolve(!0)),o=(n.PROMISE_RESOLVED_TRUE=o,Promise.resolve());n.PROMISE_RESOLVED_VOID=o;var r=0,i=0},{}],13:[function(e,t,n){t.exports=function(e){return e&&e.__esModule?e:{default:e}},t.exports.__esModule=!0,t.exports.default=t.exports},{}],14:[function(e,t,n){function o(e){return t.exports=o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t.exports.__esModule=!0,t.exports.default=t.exports,o(e)}t.exports=o,t.exports.__esModule=!0,t.exports.default=t.exports},{}],15:[function(e,t,n){},{}],16:[function(e,t,n){t.exports=!1},{}],17:[function(e,t,n){"use strict";function o(e){this.ttl=e,this.map=new Map,this._to=!1}function r(e){for(var t=i()-e.ttl,n=e.map[Symbol.iterator]();;){var o=n.next().value;if(!o)return;var r=o[0];if(!(o[1]<t))return;e.map.delete(r)}}function i(){return(new Date).getTime()}Object.defineProperty(n,"__esModule",{value:!0}),n.now=n.removeTooOldValues=n.ObliviousSet=void 0,o.prototype.has=function(e){return this.map.has(e)},o.prototype.add=function(e){var t=this;this.map.set(e,i()),this._to||(this._to=!0,setTimeout(function(){t._to=!1,r(t)},0))},o.prototype.clear=function(){this.map.clear()},n.ObliviousSet=o,n.removeTooOldValues=r,n.now=i},{}],18:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0,n.default={add:function(e){"function"==typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope||"function"==typeof window.addEventListener&&(window.addEventListener("beforeunload",function(){e()},!0),window.addEventListener("unload",function(){e()},!0))}}},{}],19:[function(e,t,n){"use strict";var o=e("@babel/runtime/helpers/interopRequireDefault"),n=(Object.defineProperty(n,"__esModule",{value:!0}),n.add=function(e){if(a||(a=!0,i.add(u)),"function"!=typeof e)throw new Error("Listener is no function");return s.add(e),{remove:function(){return s.delete(e)},run:function(){return s.delete(e),e()}}},n.getSize=function(){return s.size},n.removeAll=function(){s.clear()},n.runAll=u,o(e("detect-node"))),r=o(e("./browser.js")),o=o(e("./node.js")),i=(n.default?o:r).default,s=new Set,a=!1;function u(){var t=[];return s.forEach(function(e){t.push(e()),s.delete(e)}),Promise.all(t)}},{"./browser.js":18,"./node.js":15,"@babel/runtime/helpers/interopRequireDefault":13,"detect-node":16}]},{},[2]); |
@@ -21,4 +21,2 @@ "use strict"; | ||
var _util = require("./util.js"); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
@@ -54,3 +52,3 @@ | ||
if (!options.webWorkerSupport && !_util.isNode) { | ||
if (!options.webWorkerSupport) { | ||
chooseMethods = chooseMethods.filter(function (m) { | ||
@@ -57,0 +55,0 @@ return m.type !== 'idb'; |
@@ -400,5 +400,8 @@ "use strict"; | ||
function canBeUsed() { | ||
if (_util.isNode) return false; | ||
var idb = getIdb(); | ||
if (!idb) return false; | ||
if (!idb) { | ||
return false; | ||
} | ||
return true; | ||
@@ -405,0 +408,0 @@ } |
@@ -159,3 +159,2 @@ "use strict"; | ||
function canBeUsed() { | ||
if (_util.isNode) return false; | ||
var ls = getLocalStorage(); | ||
@@ -162,0 +161,0 @@ if (!ls) return false; |
@@ -58,7 +58,5 @@ "use strict"; | ||
function canBeUsed() { | ||
/** | ||
* in the electron-renderer, isNode will be true even if we are in browser-context | ||
* so we also check if window is undefined | ||
*/ | ||
if (_util.isNode && typeof window === 'undefined') return false; | ||
if (typeof window === 'undefined') { | ||
return false; | ||
} | ||
@@ -71,3 +69,5 @@ if (typeof BroadcastChannel === 'function') { | ||
return true; | ||
} else return false; | ||
} else { | ||
return false; | ||
} | ||
} | ||
@@ -74,0 +74,0 @@ |
@@ -59,4 +59,2 @@ "use strict"; | ||
var _detectNode = _interopRequireDefault(require("detect-node")); | ||
var _pQueue = _interopRequireDefault(require("p-queue")); | ||
@@ -1170,3 +1168,7 @@ | ||
function canBeUsed() { | ||
return _detectNode["default"]; | ||
if (typeof _fs["default"].mkdir === 'function') { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
@@ -1173,0 +1175,0 @@ /** |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.isNode = exports.PROMISE_RESOLVED_VOID = exports.PROMISE_RESOLVED_TRUE = exports.PROMISE_RESOLVED_FALSE = void 0; | ||
exports.PROMISE_RESOLVED_VOID = exports.PROMISE_RESOLVED_TRUE = exports.PROMISE_RESOLVED_FALSE = void 0; | ||
exports.isPromise = isPromise; | ||
@@ -74,11 +74,2 @@ exports.microSeconds = microSeconds; | ||
} | ||
} | ||
/** | ||
* copied from the 'detect-node' npm module | ||
* We cannot use the module directly because it causes problems with rollup | ||
* @link https://github.com/iliakan/detect-node/blob/master/index.js | ||
*/ | ||
var isNode = Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]'; | ||
exports.isNode = isNode; | ||
} |
{ | ||
"name": "broadcast-channel", | ||
"version": "4.16.0", | ||
"version": "4.17.0", | ||
"description": "A BroadcastChannel that works in New Browsers, Old Browsers, WebWorkers and NodeJs", | ||
@@ -86,3 +86,2 @@ "exports": { | ||
"@babel/runtime": "^7.16.0", | ||
"detect-node": "^2.1.0", | ||
"oblivious-set": "1.1.1", | ||
@@ -103,3 +102,3 @@ "p-queue": "6.6.2", | ||
"@babel/types": "7.19.0", | ||
"@rollup/plugin-node-resolve": "13.3.0", | ||
"@rollup/plugin-node-resolve": "14.1.0", | ||
"@types/core-js": "2.5.5", | ||
@@ -118,3 +117,3 @@ "assert": "2.0.0", | ||
"http-server": "14.1.1", | ||
"jest": "28.1.3", | ||
"jest": "29.0.3", | ||
"karma": "6.4.0", | ||
@@ -139,5 +138,5 @@ "karma-babel-preprocessor": "8.0.2", | ||
"rollup-plugin-terser": "7.0.2", | ||
"testcafe": "1.20.1", | ||
"testcafe": "2.0.0", | ||
"ts-node": "10.9.1", | ||
"typescript": "4.8.2", | ||
"typescript": "4.8.3", | ||
"uglify-js": "3.17.0", | ||
@@ -144,0 +143,0 @@ "watchify": "4.0.0", |
@@ -8,6 +8,2 @@ import NativeMethod from './methods/native.js'; | ||
import { | ||
isNode | ||
} from './util.js'; | ||
// order is important | ||
@@ -41,3 +37,3 @@ const METHODS = [ | ||
*/ | ||
if (!options.webWorkerSupport && !isNode) { | ||
if (!options.webWorkerSupport) { | ||
chooseMethods = chooseMethods.filter(m => m.type !== 'idb'); | ||
@@ -44,0 +40,0 @@ } |
@@ -15,3 +15,2 @@ /** | ||
microSeconds as micro, | ||
isNode, | ||
PROMISE_RESOLVED_VOID | ||
@@ -376,6 +375,6 @@ } from '../util.js'; | ||
export function canBeUsed() { | ||
if (isNode) return false; | ||
const idb = getIdb(); | ||
if (!idb) return false; | ||
if (!idb) { | ||
return false; | ||
} | ||
return true; | ||
@@ -382,0 +381,0 @@ } |
@@ -18,4 +18,3 @@ /** | ||
randomToken, | ||
microSeconds as micro, | ||
isNode | ||
microSeconds as micro | ||
} from '../util.js'; | ||
@@ -147,5 +146,3 @@ | ||
export function canBeUsed() { | ||
if (isNode) return false; | ||
const ls = getLocalStorage(); | ||
if (!ls) return false; | ||
@@ -152,0 +149,0 @@ |
import { | ||
microSeconds as micro, | ||
isNode, | ||
PROMISE_RESOLVED_VOID | ||
@@ -46,9 +45,5 @@ } from '../util.js'; | ||
export function canBeUsed() { | ||
/** | ||
* in the electron-renderer, isNode will be true even if we are in browser-context | ||
* so we also check if window is undefined | ||
*/ | ||
if (isNode && typeof window === 'undefined') return false; | ||
if (typeof window === 'undefined') { | ||
return false; | ||
} | ||
if (typeof BroadcastChannel === 'function') { | ||
@@ -61,3 +56,5 @@ if (BroadcastChannel._pubkey) { | ||
return true; | ||
} else return false; | ||
} else { | ||
return false; | ||
} | ||
} | ||
@@ -64,0 +61,0 @@ |
@@ -14,3 +14,2 @@ /** | ||
import rimraf from 'rimraf'; | ||
import isNode from 'detect-node'; | ||
import PQueue from 'p-queue'; | ||
@@ -668,3 +667,7 @@ import { | ||
export function canBeUsed() { | ||
return isNode; | ||
if (typeof fs.mkdir === 'function') { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
@@ -689,2 +692,2 @@ | ||
return Number(process.hrtime.bigint()); // returns nanoseconds | ||
} | ||
} |
@@ -55,8 +55,1 @@ /** | ||
} | ||
/** | ||
* copied from the 'detect-node' npm module | ||
* We cannot use the module directly because it causes problems with rollup | ||
* @link https://github.com/iliakan/detect-node/blob/master/index.js | ||
*/ | ||
export const isNode = Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
5
9
503567
12986
- Removeddetect-node@^2.1.0