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

redux-state-sync

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-state-sync - npm Package Compare versions

Comparing version 2.0.4 to 2.0.5

510

dist/syncState.umd.js

@@ -76,3 +76,3 @@ (function webpackUniversalModuleDefinition(root, factory) {

/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 5);
/******/ return __webpack_require__(__webpack_require__.s = 4);
/******/ })

@@ -85,7 +85,8 @@ /************************************************************************/

"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = isPromise;
/* harmony export (immutable) */ __webpack_exports__["c"] = sleep;
/* harmony export (immutable) */ __webpack_exports__["e"] = randomInt;
/* harmony export (immutable) */ __webpack_exports__["d"] = randomToken;
/* harmony export (immutable) */ __webpack_exports__["b"] = microSeconds;
/* WEBPACK VAR INJECTION */(function(process) {/* harmony export (immutable) */ __webpack_exports__["a"] = isPromise;
/* harmony export (immutable) */ __webpack_exports__["d"] = sleep;
/* harmony export (immutable) */ __webpack_exports__["f"] = randomInt;
/* harmony export (immutable) */ __webpack_exports__["e"] = randomToken;
/* harmony export (immutable) */ __webpack_exports__["c"] = microSeconds;
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return isNode; });
/**

@@ -147,13 +148,13 @@ * returns true if the given object is a promise

}
/**
* 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]';
/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(10)))
/***/ }),
/* 1 */
/***/ (function(module, exports) {
module.exports = false;
/***/ }),
/* 2 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

@@ -185,49 +186,49 @@

/***/ }),
/* 3 */
/* 2 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* unused harmony export _removeTooOldValues */
/**
*
*
* this is a set which automatically forgets
* a given entry when a new entry is set and the ttl
* of the old one is over
* @constructor
*/
var ObliviousSet = function ObliviousSet(ttl) {
this.ttl = ttl;
this.set = new Set();
this.timeMap = new Map();
this.has = this.set.has.bind(this.set);
};
var set = new Set();
var timeMap = new Map();
this.has = set.has.bind(set);
ObliviousSet.prototype = {
add: function add(value) {
this.timeMap.set(value, now());
this.set.add(value);
this.add = function (value) {
timeMap.set(value, now());
set.add(value);
_removeTooOldValues(this);
},
clear: function clear() {
this.set.clear();
this.timeMap.clear();
}
};
function _removeTooOldValues(obliviousSet) {
var olderThen = now() - obliviousSet.ttl;
var iterator = obliviousSet.set[Symbol.iterator]();
_removeTooOldValues();
};
while (true) {
var value = iterator.next().value;
if (!value) return; // no more elements
this.clear = function () {
set.clear();
timeMap.clear();
};
var time = obliviousSet.timeMap.get(value);
function _removeTooOldValues() {
var olderThen = now() - ttl;
var iterator = set[Symbol.iterator]();
if (time < olderThen) {
obliviousSet.timeMap["delete"](value);
obliviousSet.set["delete"](value);
} else {
// we reached a value that is not old enough
return;
while (true) {
var value = iterator.next().value;
if (!value) return; // no more elements
var time = timeMap.get(value);
if (time < olderThen) {
timeMap["delete"](value);
set["delete"](value);
} else {
// we reached a value that is not old enough
return;
}
}
}
}
};

@@ -241,3 +242,3 @@ function now() {

/***/ }),
/* 4 */
/* 3 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

@@ -248,4 +249,4 @@

/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__util_js__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__method_chooser_js__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__options_js__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__method_chooser_js__ = __webpack_require__(5);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__options_js__ = __webpack_require__(1);

@@ -257,2 +258,7 @@

this.name = name;
if (ENFORCED_OPTIONS) {
options = ENFORCED_OPTIONS;
}
this.options = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__options_js__["a" /* fillOptionsWithDefaults */])(options);

@@ -317,2 +323,13 @@ this.method = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__method_chooser_js__["a" /* chooseMethod */])(this.options); // isListening

}
};
/**
* if set, this method is enforced,
* no mather what the options are
*/
var ENFORCED_OPTIONS;
BroadcastChannel.enforceOptions = function (options) {
ENFORCED_OPTIONS = options;
}; // PROTOTYPE

@@ -478,3 +495,3 @@

/***/ }),
/* 5 */
/* 4 */
/***/ (function(module, exports, __webpack_require__) {

@@ -493,3 +510,3 @@

var _broadcastChannel = __webpack_require__(4);
var _broadcastChannel = __webpack_require__(3);

@@ -672,3 +689,3 @@ var _broadcastChannel2 = _interopRequireDefault(_broadcastChannel);

/***/ }),
/* 6 */
/* 5 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

@@ -678,15 +695,15 @@

/* harmony export (immutable) */ __webpack_exports__["a"] = chooseMethod;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_detect_node__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_detect_node___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_detect_node__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__methods_native_js__ = __webpack_require__(9);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__methods_indexed_db_js__ = __webpack_require__(7);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__methods_localstorage_js__ = __webpack_require__(8);
var require;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__methods_native_js__ = __webpack_require__(8);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__methods_indexed_db_js__ = __webpack_require__(6);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__methods_localstorage_js__ = __webpack_require__(7);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__methods_simulate_js__ = __webpack_require__(9);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util__ = __webpack_require__(0);
// order is important
var METHODS = [__WEBPACK_IMPORTED_MODULE_1__methods_native_js__["a" /* default */], // fastest
__WEBPACK_IMPORTED_MODULE_2__methods_indexed_db_js__["a" /* default */], __WEBPACK_IMPORTED_MODULE_3__methods_localstorage_js__["a" /* default */]];
var REQUIRE_FUN = require;
var METHODS = [__WEBPACK_IMPORTED_MODULE_0__methods_native_js__["a" /* default */], // fastest
__WEBPACK_IMPORTED_MODULE_1__methods_indexed_db_js__["a" /* default */], __WEBPACK_IMPORTED_MODULE_2__methods_localstorage_js__["a" /* default */]];
/**

@@ -697,3 +714,3 @@ * The NodeMethod is loaded lazy

if (__WEBPACK_IMPORTED_MODULE_0_detect_node___default.a) {
if (__WEBPACK_IMPORTED_MODULE_4__util__["b" /* isNode */]) {
/**

@@ -703,3 +720,3 @@ * we use the non-transpiled code for nodejs

*/
var NodeMethod = __webpack_require__(10);
var NodeMethod = __webpack_require__(11);
/**

@@ -710,2 +727,3 @@ * this will be false for webpackbuilds

if (typeof NodeMethod.canBeUsed === 'function') {

@@ -719,2 +737,7 @@ METHODS.push(NodeMethod);

if (options.type) {
if (options.type === 'simulate') {
// only use simulate-method if directly chosen
return __WEBPACK_IMPORTED_MODULE_3__methods_simulate_js__["a" /* default */];
}
var ret = METHODS.find(function (m) {

@@ -725,7 +748,11 @@ return m.type === options.type;

}
/**
* if no webworker support is needed,
* remove idb from the list so that localstorage is been chosen
*/
var chooseMethods = METHODS;
if (!options.webWorkerSupport && !__WEBPACK_IMPORTED_MODULE_0_detect_node___default.a) {
// prefer localstorage over idb when no webworker-support needed
if (!options.webWorkerSupport && !__WEBPACK_IMPORTED_MODULE_4__util__["b" /* isNode */]) {
chooseMethods = METHODS.filter(function (m) {

@@ -745,3 +772,3 @@ return m.type !== 'idb';

/***/ }),
/* 7 */
/* 6 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

@@ -766,7 +793,5 @@

/* unused harmony export averageResponseTime */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_detect_node__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_detect_node___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_detect_node__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_js__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__oblivious_set__ = __webpack_require__(3);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__options__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__util_js__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__oblivious_set__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__options__ = __webpack_require__(1);
/**

@@ -778,6 +803,5 @@ * this method uses indexeddb to store the messages

var microSeconds = __WEBPACK_IMPORTED_MODULE_0__util_js__["c" /* microSeconds */];
var microSeconds = __WEBPACK_IMPORTED_MODULE_1__util_js__["b" /* microSeconds */];
var DB_PREFIX = 'pubkey.broadcast-channel-0-';

@@ -870,4 +894,3 @@ var OBJECT_STORE_ID = 'messages';

if (cursor) {
ret.push(cursor.value); //alert("Name for SSN " + cursor.key + " is " + cursor.value.name);
ret.push(cursor.value);
cursor["continue"]();

@@ -922,3 +945,3 @@ } else {

function create(channelName, options) {
options = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__options__["a" /* fillOptionsWithDefaults */])(options);
options = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__options__["a" /* fillOptionsWithDefaults */])(options);
return createDatabase(channelName).then(function (db) {

@@ -930,3 +953,3 @@ var state = {

options: options,
uuid: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__util_js__["d" /* randomToken */])(10),
uuid: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__util_js__["e" /* randomToken */])(10),

@@ -938,3 +961,3 @@ /**

*/
eMIs: new __WEBPACK_IMPORTED_MODULE_2__oblivious_set__["a" /* default */](options.idb.ttl * 2),
eMIs: new __WEBPACK_IMPORTED_MODULE_1__oblivious_set__["a" /* default */](options.idb.ttl * 2),
// ensures we do not read messages in parrallel

@@ -961,3 +984,3 @@ writeBlockPromise: Promise.resolve(),

return readNewMessages(state).then(function () {
return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__util_js__["c" /* sleep */])(state.options.idb.fallbackInterval);
return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__util_js__["d" /* sleep */])(state.options.idb.fallbackInterval);
}).then(function () {

@@ -988,3 +1011,11 @@ return _readLoop(state);

return getMessagesHigherThen(state.db, state.lastCursorId).then(function (newerMessages) {
var useMessages = newerMessages.map(function (msgObj) {
var useMessages = newerMessages
/**
* there is a bug in iOS where the msgObj can be undefined some times
* so we filter them out
* @link https://github.com/pubkey/broadcast-channel/issues/19
*/
.filter(function (msgObj) {
return !!msgObj;
}).map(function (msgObj) {
if (msgObj.id > state.lastCursorId) {

@@ -1019,3 +1050,3 @@ state.lastCursorId = msgObj.id;

}).then(function () {
if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__util_js__["e" /* randomInt */])(0, 10) === 0) {
if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__util_js__["f" /* randomInt */])(0, 10) === 0) {
/* await (do not await) */

@@ -1033,3 +1064,3 @@ cleanOldMessages(channelState.db, channelState.options.idb.ttl);

function canBeUsed() {
if (__WEBPACK_IMPORTED_MODULE_0_detect_node___default.a) return false;
if (__WEBPACK_IMPORTED_MODULE_0__util_js__["b" /* isNode */]) return false;
var idb = getIdb();

@@ -1054,3 +1085,3 @@ if (!idb) return false;

/***/ }),
/* 8 */
/* 7 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

@@ -1071,7 +1102,5 @@

/* unused harmony export averageResponseTime */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_detect_node__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_detect_node___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_detect_node__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__oblivious_set__ = __webpack_require__(3);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__options__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__oblivious_set__ = __webpack_require__(2);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__options__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util__ = __webpack_require__(0);
/**

@@ -1087,4 +1116,3 @@ * A localStorage-only method which uses localstorage and its 'storage'-event

var microSeconds = __WEBPACK_IMPORTED_MODULE_3__util__["b" /* microSeconds */];
var microSeconds = __WEBPACK_IMPORTED_MODULE_2__util__["c" /* microSeconds */];
var KEY_PREFIX = 'pubkey.broadcastChannel-';

@@ -1121,6 +1149,6 @@ var type = 'localstorage';

return new Promise(function (res) {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["c" /* sleep */])().then(function () {
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__util__["d" /* sleep */])().then(function () {
var key = storageKey(channelState.channelName);
var writeObj = {
token: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["d" /* randomToken */])(10),
token: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__util__["e" /* randomToken */])(10),
time: new Date().getTime(),

@@ -1131,3 +1159,3 @@ data: messageJson,

var value = JSON.stringify(writeObj);
localStorage.setItem(key, value);
getLocalStorage().setItem(key, value);
/**

@@ -1164,3 +1192,3 @@ * StorageEvent does not fire the 'storage' event

function create(channelName, options) {
options = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__options__["a" /* fillOptionsWithDefaults */])(options);
options = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__options__["a" /* fillOptionsWithDefaults */])(options);

@@ -1171,3 +1199,3 @@ if (!canBeUsed()) {

var uuid = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__util__["d" /* randomToken */])(10);
var uuid = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__util__["e" /* randomToken */])(10);
/**

@@ -1179,3 +1207,3 @@ * eMIs

var eMIs = new __WEBPACK_IMPORTED_MODULE_1__oblivious_set__["a" /* default */](options.localstorage.removeTimeout);
var eMIs = new __WEBPACK_IMPORTED_MODULE_0__oblivious_set__["a" /* default */](options.localstorage.removeTimeout);
var state = {

@@ -1209,5 +1237,17 @@ channelName: channelName,

function canBeUsed() {
if (__WEBPACK_IMPORTED_MODULE_0_detect_node___default.a) return false;
if (__WEBPACK_IMPORTED_MODULE_2__util__["b" /* isNode */]) return false;
var ls = getLocalStorage();
if (!ls) return false;
try {
var key = '__broadcastchannel_check';
ls.setItem(key, 'works');
ls.removeItem(key);
} catch (e) {
// Safari 10 in private mode will not allow write access to local
// storage and fail with a QuotaExceededError. See
// https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API#Private_Browsing_Incognito_modes
return false;
}
return true;

@@ -1230,3 +1270,3 @@ }

/***/ }),
/* 9 */
/* 8 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

@@ -1243,8 +1283,5 @@

/* unused harmony export averageResponseTime */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_detect_node__ = __webpack_require__(1);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_detect_node___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_detect_node__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util__ = __webpack_require__(0);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__util__ = __webpack_require__(0);
var microSeconds = __WEBPACK_IMPORTED_MODULE_1__util__["b" /* microSeconds */];
var microSeconds = __WEBPACK_IMPORTED_MODULE_0__util__["c" /* microSeconds */];
var type = 'native';

@@ -1274,4 +1311,3 @@ function create(channelName) {

}
function onMessage(channelState, fn, time) {
channelState.messagesCallbackTime = time;
function onMessage(channelState, fn) {
channelState.messagesCallback = fn;

@@ -1284,3 +1320,3 @@ }

*/
if (__WEBPACK_IMPORTED_MODULE_0_detect_node___default.a && typeof window === 'undefined') return false;
if (__WEBPACK_IMPORTED_MODULE_0__util__["b" /* isNode */] && typeof window === 'undefined') return false;

@@ -1296,3 +1332,3 @@ if (typeof BroadcastChannel === 'function') {

function averageResponseTime() {
return 100;
return 150;
}

@@ -1311,5 +1347,261 @@ /* harmony default export */ __webpack_exports__["a"] = ({

/***/ }),
/* 9 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* unused harmony export microSeconds */
/* unused harmony export type */
/* unused harmony export create */
/* unused harmony export close */
/* unused harmony export postMessage */
/* unused harmony export onMessage */
/* unused harmony export canBeUsed */
/* unused harmony export averageResponseTime */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__util__ = __webpack_require__(0);
var microSeconds = __WEBPACK_IMPORTED_MODULE_0__util__["c" /* microSeconds */];
var type = 'simulate';
var SIMULATE_CHANNELS = new Set();
function create(channelName) {
var state = {
name: channelName,
messagesCallback: null
};
SIMULATE_CHANNELS.add(state);
return state;
}
function close(channelState) {
SIMULATE_CHANNELS["delete"](channelState);
}
function postMessage(channelState, messageJson) {
return new Promise(function (res) {
return setTimeout(function () {
var channelArray = Array.from(SIMULATE_CHANNELS);
channelArray.filter(function (channel) {
return channel.name === channelState.name;
}).filter(function (channel) {
return channel !== channelState;
}).filter(function (channel) {
return !!channel.messagesCallback;
}).forEach(function (channel) {
return channel.messagesCallback(messageJson);
});
res();
}, 5);
});
}
function onMessage(channelState, fn) {
channelState.messagesCallback = fn;
}
function canBeUsed() {
return true;
}
function averageResponseTime() {
return 5;
}
/* harmony default export */ __webpack_exports__["a"] = ({
create: create,
close: close,
onMessage: onMessage,
postMessage: postMessage,
canBeUsed: canBeUsed,
type: type,
averageResponseTime: averageResponseTime,
microSeconds: microSeconds
});
/***/ }),
/* 10 */
/***/ (function(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; };
/***/ }),
/* 11 */
/***/ (function(module, exports) {
/* (ignored) */

@@ -1316,0 +1608,0 @@

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

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.reduxStateSync=t():e.reduxStateSync=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=5)}([function(e,t,n){"use strict";function r(e){return!(!e||"function"!=typeof e.then)}function o(e){return e||(e=0),new Promise(function(t){return setTimeout(t,e)})}function i(e,t){return Math.floor(Math.random()*(t-e+1)+e)}function a(e){e||(e=5);for(var t="",n="abcdefghijklmnopqrstuvwxzy0123456789",r=0;r<e;r++)t+=n.charAt(Math.floor(Math.random()*n.length));return t}function s(){var e=(new Date).getTime();return e===u?(c++,1e3*e+c):(u=e,c=0,1e3*e)}t.a=r,t.c=o,t.e=i,t.d=a,t.b=s;var u=0,c=0},function(e,t){e.exports=!1},function(e,t,n){"use strict";function r(e){return e||(e={}),e=JSON.parse(JSON.stringify(e)),void 0===e.webWorkerSupport&&(e.webWorkerSupport=!0),e.idb||(e.idb={}),e.idb.ttl||(e.idb.ttl=45e3),e.idb.fallbackInterval||(e.idb.fallbackInterval=150),e.localstorage||(e.localstorage={}),e.localstorage.removeTimeout||(e.localstorage.removeTimeout=6e4),e.node||(e.node={}),e.node.ttl||(e.node.ttl=12e4),void 0===e.node.useFastPath&&(e.node.useFastPath=!0),e}t.a=r},function(e,t,n){"use strict";function r(e){for(var t=o()-e.ttl,n=e.set[Symbol.iterator]();;){var r=n.next().value;if(!r)return;if(!(e.timeMap.get(r)<t))return;e.timeMap.delete(r),e.set.delete(r)}}function o(){return(new Date).getTime()}var i=function(e){this.ttl=e,this.set=new Set,this.timeMap=new Map,this.has=this.set.has.bind(this.set)};i.prototype={add:function(e){this.timeMap.set(e,o()),this.set.add(e),r(this)},clear:function(){this.set.clear(),this.timeMap.clear()}},t.a=i},function(e,t,n){"use strict";function r(e,t,n){var r=e.method.microSeconds(),o={time:r,type:t,data:n};return(e._prepP?e._prepP:Promise.resolve()).then(function(){return e.method.postMessage(e._state,o)})}function o(e){var t=e.method.create(e.name,e.options);n.i(d.a)(t)?(e._prepP=t,t.then(function(t){e._state=t})):e._state=t}function i(e){return e._addEL.message.length>0||e._addEL.internal.length>0}function a(e,t,n){e._addEL[t].push(n),u(e)}function s(e,t,n){e._addEL[t]=e._addEL[t].filter(function(e){return e!==n}),c(e)}function u(e){if(!e._iL&&i(e)){var t=function(t){e._addEL[t.type].forEach(function(e){t.time>=e.time&&e.fn(t.data)})},n=e.method.microSeconds();e._prepP?e._prepP.then(function(){e._iL=!0,e.method.onMessage(e._state,t,n)}):(e._iL=!0,e.method.onMessage(e._state,t,n))}}function c(e){if(e._iL&&!i(e)){e._iL=!1;var t=e.method.microSeconds();e.method.onMessage(e._state,null,t)}}Object.defineProperty(t,"__esModule",{value:!0});var d=n(0),f=n(6),l=n(2),p=function(e,t){this.name=e,this.options=n.i(l.a)(t),this.method=n.i(f.a)(this.options),this._iL=!1,this._onML=null,this._addEL={message:[],internal:[]},this._befC=[],this._prepP=null,o(this)};p._pubkey=!0,p.clearNodeFolder=function(e){e=n.i(l.a)(e);var t=n.i(f.a)(e);return"node"===t.type?t.clearNodeFolder().then(function(){return!0}):Promise.resolve(!1)},p.prototype={postMessage:function(e){if(this.closed)throw new Error("BroadcastChannel.postMessage(): Cannot post message after channel has closed");return r(this,"message",e)},postInternal:function(e){return r(this,"internal",e)},set onmessage(e){var t=this.method.microSeconds(),n={time:t,fn:e};s(this,"message",this._onML),e&&"function"==typeof e?(this._onML=n,a(this,"message",n)):this._onML=null},addEventListener:function(e,t){a(this,e,{time:this.method.microSeconds(),fn:t})},removeEventListener:function(e,t){s(this,e,this._addEL[e].find(function(e){return e.fn===t}))},close:function(){var e=this;if(!this.closed){this.closed=!0;var t=this._prepP?this._prepP:Promise.resolve();return this._onML=null,this._addEL.message=[],t.then(function(){return Promise.all(e._befC.map(function(e){return e()}))}).then(function(){return e.method.close(e._state)})}},get type(){return this.method.type}},t.default=p},function(e,t,n){"use strict";function r(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}function o(){return""+r()+r()+"-"+r()+"-"+r()+"-"+r()+"-"+r()+r()+r()}function i(e){var t=e;return t.$uuid=o(),t.$wuid=w,t}function a(e){var t=e.predicate,n=e.blacklist,r=e.whitelist,o=function(){return!0};return t&&"function"==typeof t?o=t:Array.isArray(n)?o=function(e){return n.indexOf(e)<0}:Array.isArray(r)&&(o=function(e){return r.indexOf(e)>=0}),o}function s(e){var t=e.channel,n=e.dispatch,r=e.allowed,o=!1,i={};t.onmessage=function(e){if(e.$wuid!==w&&e.type!==p&&e.$uuid&&e.$uuid!==d)if(e.type!==f||i[e.$wuid]){if(e.type===l&&!i[e.$wuid])return void(o||(o=!0,n(b(e.payload))));r(e.type)&&(d=e.$uuid,n(e))}else i[e.$wuid]=!0,n(v())}}Object.defineProperty(t,"__esModule",{value:!0}),t.initStateWithPrevTab=t.withReduxStateSync=t.createReduxStateSync=t.createStateSyncMiddleware=void 0,t.generateUuidForAction=i,t.isActionAllowed=a,t.createMessageListener=s;var u=n(4),c=function(e){return e&&e.__esModule?e:{default:e}}(u),d=0,f="&_GET_INIT_STATE",l="&_SEND_INIT_STATE",p="&_RECEIVE_INIT_STATE",m={channel:"redux_state_sync",predicate:null,blacklist:[],whitelist:[],broadcastChannelOption:null,prepareState:function(e){return e}},h=function(){return{type:f}},v=function(){return{type:l}},b=function(e){return{type:p,payload:e}},w=o(),g=!1,y=(t.createStateSyncMiddleware=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:m,t=a(e),n=new c.default(e.channel,e.broadcastChannelOption),r=e.prepareState||m.prepareState;return function(e){var o=e.getState,a=e.dispatch;return function(e){return function(u){if(g||(g=!0,s({channel:n,dispatch:a,allowed:t})),u&&!u.$uuid){var c=i(u);d=c.$uuid;try{if(u.type===l)return o()&&(c.payload=r(o()),n.postMessage(c)),e(u);(t(c.type)||u.type===f)&&n.postMessage(c)}catch(e){console.error("Your browser doesn't support cross tab communication")}}return e(u)}}}},t.createReduxStateSync=function(e){var t=e.prepareState;return function(e){return function(n,r){var o=n;return r.type===p&&(o=t(r.payload)),e(o,r)}}});t.withReduxStateSync=y({prepareState:function(e){return e}}),t.initStateWithPrevTab=function(e){(0,e.dispatch)(h())}},function(e,t,n){"use strict";function r(e){if(e.type){var t=c.find(function(t){return t.type===e.type});if(t)return t;throw new Error("method-type "+e.type+" not found")}var n=c;e.webWorkerSupport||i.a||(n=c.filter(function(e){return"idb"!==e.type}));var r=n.find(function(e){return e.canBeUsed()});if(r)return r;throw new Error("No useable methode found:"+JSON.stringify(c.map(function(e){return e.type})))}t.a=r;var o=n(1),i=n.n(o),a=n(9),s=n(7),u=n(8),c=[a.a,s.a,u.a];if(i.a){var d=n(10);"function"==typeof d.canBeUsed&&c.push(d)}},function(e,t,n){"use strict";function r(){return"undefined"!=typeof indexedDB?indexedDB:void 0!==window.mozIndexedDB?window.mozIndexedDB:void 0!==window.webkitIndexedDB?window.webkitIndexedDB:void 0!==window.msIndexedDB&&window.msIndexedDB}function o(e){var t=r(),n=P+e,o=t.open(n,1);return o.onupgradeneeded=function(e){e.target.result.createObjectStore(C,{keyPath:"id",autoIncrement:!0})},new Promise(function(e,t){o.onerror=function(e){return t(e)},o.onsuccess=function(){e(o.result)}})}function i(e,t,n){var r=(new Date).getTime(),o={uuid:t,time:r,data:n},i=e.transaction([C],"readwrite");return new Promise(function(e,t){i.oncomplete=function(){return e()},i.onerror=function(e){return t(e)},i.objectStore(C).add(o)})}function a(e,t){var n=e.transaction(C).objectStore(C),r=[],o=IDBKeyRange.bound(t+1,1/0);return new Promise(function(e){n.openCursor(o).onsuccess=function(t){var n=t.target.result;n?(r.push(n.value),n.continue()):e(r)}})}function s(e,t){var n=e.transaction([C],"readwrite").objectStore(C).delete(t);return new Promise(function(e){n.onsuccess=function(){return e()}})}function u(e,t){var n=(new Date).getTime()-t,r=e.transaction(C).objectStore(C),o=[];return new Promise(function(e){r.openCursor().onsuccess=function(t){var r=t.target.result;if(r){var i=r.value;if(!(i.time<n))return void e(o);o.push(i),r.continue()}else e(o)}})}function c(e,t){return u(e,t).then(function(t){return Promise.all(t.map(function(t){return s(e,t.id)}))})}function d(e,t){return t=n.i(k.a)(t),o(e).then(function(r){var o={closed:!1,lastCursorId:0,channelName:e,options:t,uuid:n.i(_.d)(10),eMIs:new S.a(2*t.idb.ttl),writeBlockPromise:Promise.resolve(),messagesCallback:null,readQueuePromises:[],db:r};return f(o),o})}function f(e){if(!e.closed)return p(e).then(function(){return n.i(_.c)(e.options.idb.fallbackInterval)}).then(function(){return f(e)})}function l(e,t){return e.uuid!==t.uuid&&(!t.eMIs.has(e.id)&&!(e.data.time<t.messagesCallbackTime))}function p(e){return e.closed?Promise.resolve():e.messagesCallback?a(e.db,e.lastCursorId).then(function(t){return t.map(function(t){return t.id>e.lastCursorId&&(e.lastCursorId=t.id),t}).filter(function(t){return l(t,e)}).sort(function(e,t){return e.time-t.time}).forEach(function(t){e.messagesCallback&&(e.eMIs.add(t.id),e.messagesCallback(t.data))}),Promise.resolve()}):Promise.resolve()}function m(e){e.closed=!0,e.db.close()}function h(e,t){return e.writeBlockPromise=e.writeBlockPromise.then(function(){return i(e.db,e.uuid,t)}).then(function(){0===n.i(_.e)(0,10)&&c(e.db,e.options.idb.ttl)}),e.writeBlockPromise}function v(e,t,n){e.messagesCallbackTime=n,e.messagesCallback=t,p(e)}function b(){return!y.a&&!!r()}function w(e){return 2*e.idb.fallbackInterval}var g=n(1),y=n.n(g),_=n(0),S=n(3),k=n(2),M=_.b,P="pubkey.broadcast-channel-0-",C="messages";t.a={create:d,close:m,onMessage:v,postMessage:h,canBeUsed:b,type:"idb",averageResponseTime:w,microSeconds:M}},function(e,t,n){"use strict";function r(){var e;if("undefined"==typeof window)return null;try{e=window.localStorage,e=window["ie8-eventlistener/storage"]||window.localStorage}catch(e){}return e}function o(e){return g+e}function i(e,t){return new Promise(function(r){n.i(b.c)().then(function(){var i=o(e.channelName),a={token:n.i(b.d)(10),time:(new Date).getTime(),data:t,uuid:e.uuid},s=JSON.stringify(a);localStorage.setItem(i,s);var u=document.createEvent("Event");u.initEvent("storage",!0,!0),u.key=i,u.newValue=s,window.dispatchEvent(u),r()})})}function a(e,t){var n=o(e),r=function(e){e.key===n&&t(JSON.parse(e.newValue))};return window.addEventListener("storage",r),r}function s(e){window.removeEventListener("storage",e)}function u(e,t){if(t=n.i(v.a)(t),!f())throw new Error("BroadcastChannel: localstorage cannot be used");var r=n.i(b.d)(10),o=new h.a(t.localstorage.removeTimeout),i={channelName:e,uuid:r,eMIs:o};return i.listener=a(e,function(e){i.messagesCallback&&e.uuid!==r&&e.token&&!o.has(e.token)&&(e.data.time&&e.data.time<i.messagesCallbackTime||(o.add(e.token),i.messagesCallback(e.data)))}),i}function c(e){s(e.listener)}function d(e,t,n){e.messagesCallbackTime=n,e.messagesCallback=t}function f(){return!m.a&&!!r()}function l(){return 120}var p=n(1),m=n.n(p),h=n(3),v=n(2),b=n(0),w=b.b,g="pubkey.broadcastChannel-";t.a={create:u,close:c,onMessage:d,postMessage:i,canBeUsed:f,type:"localstorage",averageResponseTime:l,microSeconds:w}},function(e,t,n){"use strict";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 o(e){e.bc.close(),e.subFns=[]}function i(e,t){e.bc.postMessage(t,!1)}function a(e,t,n){e.messagesCallbackTime=n,e.messagesCallback=t}function s(){if(d.a&&"undefined"==typeof window)return!1;if("function"==typeof BroadcastChannel){if(BroadcastChannel._pubkey)throw new Error("BroadcastChannel: Do not overwrite window.BroadcastChannel with this module, this is not a polyfill");return!0}return!1}function u(){return 100}var c=n(1),d=n.n(c),f=n(0),l=f.b;t.a={create:r,close:o,onMessage:a,postMessage:i,canBeUsed:s,type:"native",averageResponseTime:u,microSeconds:l}},function(e,t){}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.reduxStateSync=t():e.reduxStateSync=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=4)}([function(e,t,n){"use strict";(function(e){function r(e){return!(!e||"function"!=typeof e.then)}function o(e){return e||(e=0),new Promise(function(t){return setTimeout(t,e)})}function i(e,t){return Math.floor(Math.random()*(t-e+1)+e)}function a(e){e||(e=5);for(var t="",n="abcdefghijklmnopqrstuvwxzy0123456789",r=0;r<e;r++)t+=n.charAt(Math.floor(Math.random()*n.length));return t}function u(){var e=(new Date).getTime();return e===s?(c++,1e3*e+c):(s=e,c=0,1e3*e)}t.a=r,t.d=o,t.f=i,t.e=a,t.c=u,n.d(t,"b",function(){return f});var s=0,c=0,f="[object process]"===Object.prototype.toString.call(void 0!==e?e:0)}).call(t,n(10))},function(e,t,n){"use strict";function r(e){return e||(e={}),e=JSON.parse(JSON.stringify(e)),void 0===e.webWorkerSupport&&(e.webWorkerSupport=!0),e.idb||(e.idb={}),e.idb.ttl||(e.idb.ttl=45e3),e.idb.fallbackInterval||(e.idb.fallbackInterval=150),e.localstorage||(e.localstorage={}),e.localstorage.removeTimeout||(e.localstorage.removeTimeout=6e4),e.node||(e.node={}),e.node.ttl||(e.node.ttl=12e4),void 0===e.node.useFastPath&&(e.node.useFastPath=!0),e}t.a=r},function(e,t,n){"use strict";function r(){return(new Date).getTime()}var o=function(e){function t(){for(var t=r()-e,i=n[Symbol.iterator]();;){var a=i.next().value;if(!a)return;if(!(o.get(a)<t))return;o.delete(a),n.delete(a)}}var n=new Set,o=new Map;this.has=n.has.bind(n),this.add=function(e){o.set(e,r()),n.add(e),t()},this.clear=function(){n.clear(),o.clear()}};t.a=o},function(e,t,n){"use strict";function r(e,t,n){var r=e.method.microSeconds(),o={time:r,type:t,data:n};return(e._prepP?e._prepP:Promise.resolve()).then(function(){return e.method.postMessage(e._state,o)})}function o(e){var t=e.method.create(e.name,e.options);n.i(f.a)(t)?(e._prepP=t,t.then(function(t){e._state=t})):e._state=t}function i(e){return e._addEL.message.length>0||e._addEL.internal.length>0}function a(e,t,n){e._addEL[t].push(n),s(e)}function u(e,t,n){e._addEL[t]=e._addEL[t].filter(function(e){return e!==n}),c(e)}function s(e){if(!e._iL&&i(e)){var t=function(t){e._addEL[t.type].forEach(function(e){t.time>=e.time&&e.fn(t.data)})},n=e.method.microSeconds();e._prepP?e._prepP.then(function(){e._iL=!0,e.method.onMessage(e._state,t,n)}):(e._iL=!0,e.method.onMessage(e._state,t,n))}}function c(e){if(e._iL&&!i(e)){e._iL=!1;var t=e.method.microSeconds();e.method.onMessage(e._state,null,t)}}Object.defineProperty(t,"__esModule",{value:!0});var f=n(0),d=n(5),l=n(1),m=function(e,t){this.name=e,p&&(t=p),this.options=n.i(l.a)(t),this.method=n.i(d.a)(this.options),this._iL=!1,this._onML=null,this._addEL={message:[],internal:[]},this._befC=[],this._prepP=null,o(this)};m._pubkey=!0,m.clearNodeFolder=function(e){e=n.i(l.a)(e);var t=n.i(d.a)(e);return"node"===t.type?t.clearNodeFolder().then(function(){return!0}):Promise.resolve(!1)};var p;m.enforceOptions=function(e){p=e},m.prototype={postMessage:function(e){if(this.closed)throw new Error("BroadcastChannel.postMessage(): Cannot post message after channel has closed");return r(this,"message",e)},postInternal:function(e){return r(this,"internal",e)},set onmessage(e){var t=this.method.microSeconds(),n={time:t,fn:e};u(this,"message",this._onML),e&&"function"==typeof e?(this._onML=n,a(this,"message",n)):this._onML=null},addEventListener:function(e,t){a(this,e,{time:this.method.microSeconds(),fn:t})},removeEventListener:function(e,t){u(this,e,this._addEL[e].find(function(e){return e.fn===t}))},close:function(){var e=this;if(!this.closed){this.closed=!0;var t=this._prepP?this._prepP:Promise.resolve();return this._onML=null,this._addEL.message=[],t.then(function(){return Promise.all(e._befC.map(function(e){return e()}))}).then(function(){return e.method.close(e._state)})}},get type(){return this.method.type}},t.default=m},function(e,t,n){"use strict";function r(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}function o(){return""+r()+r()+"-"+r()+"-"+r()+"-"+r()+"-"+r()+r()+r()}function i(e){var t=e;return t.$uuid=o(),t.$wuid=w,t}function a(e){var t=e.predicate,n=e.blacklist,r=e.whitelist,o=function(){return!0};return t&&"function"==typeof t?o=t:Array.isArray(n)?o=function(e){return n.indexOf(e)<0}:Array.isArray(r)&&(o=function(e){return r.indexOf(e)>=0}),o}function u(e){var t=e.channel,n=e.dispatch,r=e.allowed,o=!1,i={};t.onmessage=function(e){if(e.$wuid!==w&&e.type!==m&&e.$uuid&&e.$uuid!==f)if(e.type!==d||i[e.$wuid]){if(e.type===l&&!i[e.$wuid])return void(o||(o=!0,n(b(e.payload))));r(e.type)&&(f=e.$uuid,n(e))}else i[e.$wuid]=!0,n(v())}}Object.defineProperty(t,"__esModule",{value:!0}),t.initStateWithPrevTab=t.withReduxStateSync=t.createReduxStateSync=t.createStateSyncMiddleware=void 0,t.generateUuidForAction=i,t.isActionAllowed=a,t.createMessageListener=u;var s=n(3),c=function(e){return e&&e.__esModule?e:{default:e}}(s),f=0,d="&_GET_INIT_STATE",l="&_SEND_INIT_STATE",m="&_RECEIVE_INIT_STATE",p={channel:"redux_state_sync",predicate:null,blacklist:[],whitelist:[],broadcastChannelOption:null,prepareState:function(e){return e}},h=function(){return{type:d}},v=function(){return{type:l}},b=function(e){return{type:m,payload:e}},w=o(),g=!1,y=(t.createStateSyncMiddleware=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:p,t=a(e),n=new c.default(e.channel,e.broadcastChannelOption),r=e.prepareState||p.prepareState;return function(e){var o=e.getState,a=e.dispatch;return function(e){return function(s){if(g||(g=!0,u({channel:n,dispatch:a,allowed:t})),s&&!s.$uuid){var c=i(s);f=c.$uuid;try{if(s.type===l)return o()&&(c.payload=r(o()),n.postMessage(c)),e(s);(t(c.type)||s.type===d)&&n.postMessage(c)}catch(e){console.error("Your browser doesn't support cross tab communication")}}return e(s)}}}},t.createReduxStateSync=function(e){var t=e.prepareState;return function(e){return function(n,r){var o=n;return r.type===m&&(o=t(r.payload)),e(o,r)}}});t.withReduxStateSync=y({prepareState:function(e){return e}}),t.initStateWithPrevTab=function(e){(0,e.dispatch)(h())}},function(e,t,n){"use strict";function r(e){if(e.type){if("simulate"===e.type)return u.a;var t=c.find(function(t){return t.type===e.type});if(t)return t;throw new Error("method-type "+e.type+" not found")}var n=c;e.webWorkerSupport||s.b||(n=c.filter(function(e){return"idb"!==e.type}));var r=n.find(function(e){return e.canBeUsed()});if(r)return r;throw new Error("No useable methode found:"+JSON.stringify(c.map(function(e){return e.type})))}t.a=r;var o=n(8),i=n(6),a=n(7),u=n(9),s=n(0),c=[o.a,i.a,a.a];if(s.b){var f=n(11);"function"==typeof f.canBeUsed&&c.push(f)}},function(e,t,n){"use strict";function r(){return"undefined"!=typeof indexedDB?indexedDB:void 0!==window.mozIndexedDB?window.mozIndexedDB:void 0!==window.webkitIndexedDB?window.webkitIndexedDB:void 0!==window.msIndexedDB&&window.msIndexedDB}function o(e){var t=r(),n=k+e,o=t.open(n,1);return o.onupgradeneeded=function(e){e.target.result.createObjectStore(T,{keyPath:"id",autoIncrement:!0})},new Promise(function(e,t){o.onerror=function(e){return t(e)},o.onsuccess=function(){e(o.result)}})}function i(e,t,n){var r=(new Date).getTime(),o={uuid:t,time:r,data:n},i=e.transaction([T],"readwrite");return new Promise(function(e,t){i.oncomplete=function(){return e()},i.onerror=function(e){return t(e)},i.objectStore(T).add(o)})}function a(e,t){var n=e.transaction(T).objectStore(T),r=[],o=IDBKeyRange.bound(t+1,1/0);return new Promise(function(e){n.openCursor(o).onsuccess=function(t){var n=t.target.result;n?(r.push(n.value),n.continue()):e(r)}})}function u(e,t){var n=e.transaction([T],"readwrite").objectStore(T).delete(t);return new Promise(function(e){n.onsuccess=function(){return e()}})}function s(e,t){var n=(new Date).getTime()-t,r=e.transaction(T).objectStore(T),o=[];return new Promise(function(e){r.openCursor().onsuccess=function(t){var r=t.target.result;if(r){var i=r.value;if(!(i.time<n))return void e(o);o.push(i),r.continue()}else e(o)}})}function c(e,t){return s(e,t).then(function(t){return Promise.all(t.map(function(t){return u(e,t.id)}))})}function f(e,t){return t=n.i(_.a)(t),o(e).then(function(r){var o={closed:!1,lastCursorId:0,channelName:e,options:t,uuid:n.i(g.e)(10),eMIs:new y.a(2*t.idb.ttl),writeBlockPromise:Promise.resolve(),messagesCallback:null,readQueuePromises:[],db:r};return d(o),o})}function d(e){if(!e.closed)return m(e).then(function(){return n.i(g.d)(e.options.idb.fallbackInterval)}).then(function(){return d(e)})}function l(e,t){return e.uuid!==t.uuid&&(!t.eMIs.has(e.id)&&!(e.data.time<t.messagesCallbackTime))}function m(e){return e.closed?Promise.resolve():e.messagesCallback?a(e.db,e.lastCursorId).then(function(t){return t.filter(function(e){return!!e}).map(function(t){return t.id>e.lastCursorId&&(e.lastCursorId=t.id),t}).filter(function(t){return l(t,e)}).sort(function(e,t){return e.time-t.time}).forEach(function(t){e.messagesCallback&&(e.eMIs.add(t.id),e.messagesCallback(t.data))}),Promise.resolve()}):Promise.resolve()}function p(e){e.closed=!0,e.db.close()}function h(e,t){return e.writeBlockPromise=e.writeBlockPromise.then(function(){return i(e.db,e.uuid,t)}).then(function(){0===n.i(g.f)(0,10)&&c(e.db,e.options.idb.ttl)}),e.writeBlockPromise}function v(e,t,n){e.messagesCallbackTime=n,e.messagesCallback=t,m(e)}function b(){return!g.b&&!!r()}function w(e){return 2*e.idb.fallbackInterval}var g=n(0),y=n(2),_=n(1),S=g.c,k="pubkey.broadcast-channel-0-",T="messages";t.a={create:f,close:p,onMessage:v,postMessage:h,canBeUsed:b,type:"idb",averageResponseTime:w,microSeconds:S}},function(e,t,n){"use strict";function r(){var e;if("undefined"==typeof window)return null;try{e=window.localStorage,e=window["ie8-eventlistener/storage"]||window.localStorage}catch(e){}return e}function o(e){return b+e}function i(e,t){return new Promise(function(i){n.i(h.d)().then(function(){var a=o(e.channelName),u={token:n.i(h.e)(10),time:(new Date).getTime(),data:t,uuid:e.uuid},s=JSON.stringify(u);r().setItem(a,s);var c=document.createEvent("Event");c.initEvent("storage",!0,!0),c.key=a,c.newValue=s,window.dispatchEvent(c),i()})})}function a(e,t){var n=o(e),r=function(e){e.key===n&&t(JSON.parse(e.newValue))};return window.addEventListener("storage",r),r}function u(e){window.removeEventListener("storage",e)}function s(e,t){if(t=n.i(p.a)(t),!d())throw new Error("BroadcastChannel: localstorage cannot be used");var r=n.i(h.e)(10),o=new m.a(t.localstorage.removeTimeout),i={channelName:e,uuid:r,eMIs:o};return i.listener=a(e,function(e){i.messagesCallback&&e.uuid!==r&&e.token&&!o.has(e.token)&&(e.data.time&&e.data.time<i.messagesCallbackTime||(o.add(e.token),i.messagesCallback(e.data)))}),i}function c(e){u(e.listener)}function f(e,t,n){e.messagesCallbackTime=n,e.messagesCallback=t}function d(){if(h.b)return!1;var e=r();if(!e)return!1;try{var t="__broadcastchannel_check";e.setItem(t,"works"),e.removeItem(t)}catch(e){return!1}return!0}function l(){return 120}var m=n(2),p=n(1),h=n(0),v=h.c,b="pubkey.broadcastChannel-";t.a={create:s,close:c,onMessage:f,postMessage:i,canBeUsed:d,type:"localstorage",averageResponseTime:l,microSeconds:v}},function(e,t,n){"use strict";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 o(e){e.bc.close(),e.subFns=[]}function i(e,t){e.bc.postMessage(t,!1)}function a(e,t){e.messagesCallback=t}function u(){if(c.b&&"undefined"==typeof window)return!1;if("function"==typeof BroadcastChannel){if(BroadcastChannel._pubkey)throw new Error("BroadcastChannel: Do not overwrite window.BroadcastChannel with this module, this is not a polyfill");return!0}return!1}function s(){return 150}var c=n(0),f=c.c;t.a={create:r,close:o,onMessage:a,postMessage:i,canBeUsed:u,type:"native",averageResponseTime:s,microSeconds:f}},function(e,t,n){"use strict";function r(e){var t={name:e,messagesCallback:null};return d.add(t),t}function o(e){d.delete(e)}function i(e,t){return new Promise(function(n){return setTimeout(function(){Array.from(d).filter(function(t){return t.name===e.name}).filter(function(t){return t!==e}).filter(function(e){return!!e.messagesCallback}).forEach(function(e){return e.messagesCallback(t)}),n()},5)})}function a(e,t){e.messagesCallback=t}function u(){return!0}function s(){return 5}var c=n(0),f=c.c,d=new Set;t.a={create:r,close:o,onMessage:a,postMessage:i,canBeUsed:u,type:"simulate",averageResponseTime:s,microSeconds:f}},function(e,t){function n(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}function o(e){if(f===setTimeout)return setTimeout(e,0);if((f===n||!f)&&setTimeout)return f=setTimeout,setTimeout(e,0);try{return f(e,0)}catch(t){try{return f.call(null,e,0)}catch(t){return f.call(this,e,0)}}}function i(e){if(d===clearTimeout)return clearTimeout(e);if((d===r||!d)&&clearTimeout)return d=clearTimeout,clearTimeout(e);try{return d(e)}catch(t){try{return d.call(null,e)}catch(t){return d.call(this,e)}}}function a(){h&&m&&(h=!1,m.length?p=m.concat(p):v=-1,p.length&&u())}function u(){if(!h){var e=o(a);h=!0;for(var t=p.length;t;){for(m=p,p=[];++v<t;)m&&m[v].run();v=-1,t=p.length}m=null,h=!1,i(e)}}function s(e,t){this.fun=e,this.array=t}function c(){}var f,d,l=e.exports={};!function(){try{f="function"==typeof setTimeout?setTimeout:n}catch(e){f=n}try{d="function"==typeof clearTimeout?clearTimeout:r}catch(e){d=r}}();var m,p=[],h=!1,v=-1;l.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];p.push(new s(e,t)),1!==p.length||h||o(u)},s.prototype.run=function(){this.fun.apply(null,this.array)},l.title="browser",l.browser=!0,l.env={},l.argv=[],l.version="",l.versions={},l.on=c,l.addListener=c,l.once=c,l.off=c,l.removeListener=c,l.removeAllListeners=c,l.emit=c,l.prependListener=c,l.prependOnceListener=c,l.listeners=function(e){return[]},l.binding=function(e){throw new Error("process.binding is not supported")},l.cwd=function(){return"/"},l.chdir=function(e){throw new Error("process.chdir is not supported")},l.umask=function(){return 0}},function(e,t){}])});
//# sourceMappingURL=syncState.umd.min.js.map

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

'use strict';
"use strict";

@@ -6,3 +6,3 @@ Object.defineProperty(exports, "__esModule", {

});
exports.initStateWithPrevTab = exports.withReduxStateSync = exports.createStateSyncMiddleware = undefined;
exports.initStateWithPrevTab = exports.withReduxStateSync = exports.createReduxStateSync = exports.createStateSyncMiddleware = undefined;
exports.generateUuidForAction = generateUuidForAction;

@@ -12,20 +12,25 @@ exports.isActionAllowed = isActionAllowed;

var _broadcastChannel = require('broadcast-channel');
var _broadcastChannel = require("broadcast-channel");
var _broadcastChannel2 = _interopRequireDefault(_broadcastChannel);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
var lastUuid = 0; /* eslint-env browser */
var GET_INIT_STATE = '&_GET_INIT_STATE';
var SEND_INIT_STATE = '&_SEND_INIT_STATE';
var RECEIVE_INIT_STATE = '&_RECEIVE_INIT_STATE';
var GET_INIT_STATE = "&_GET_INIT_STATE";
var SEND_INIT_STATE = "&_SEND_INIT_STATE";
var RECEIVE_INIT_STATE = "&_RECEIVE_INIT_STATE";
var defaultConfig = {
channel: 'redux_state_sync',
channel: "redux_state_sync",
predicate: null,
blacklist: [],
whitelist: [],
broadcastChannelOption: null
broadcastChannelOption: null,
prepareState: function prepareState(state) {
return state;
}
};

@@ -44,7 +49,23 @@

function s4() {
return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
}
function guid() {
return '' + s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
return (
"" +
s4() +
s4() +
"-" +
s4() +
"-" +
s4() +
"-" +
s4() +
"-" +
s4() +
s4() +
s4()
);
}

@@ -66,4 +87,4 @@

var predicate = _ref.predicate,
blacklist = _ref.blacklist,
whitelist = _ref.whitelist;
blacklist = _ref.blacklist,
whitelist = _ref.whitelist;

@@ -74,3 +95,3 @@ var allowed = function allowed() {

if (predicate && typeof predicate === 'function') {
if (predicate && typeof predicate === "function") {
allowed = predicate;

@@ -91,4 +112,4 @@ } else if (Array.isArray(blacklist)) {

var channel = _ref2.channel,
dispatch = _ref2.dispatch,
allowed = _ref2.allowed;
dispatch = _ref2.dispatch,
allowed = _ref2.allowed;

@@ -98,6 +119,9 @@ var isSynced = false;

var messageChannel = channel;
messageChannel.onmessage = function (stampedAction) {
messageChannel.onmessage = function(stampedAction) {
// ignore if this action is triggered by this window
// IE bug https://stackoverflow.com/questions/18265556/why-does-internet-explorer-fire-the-window-storage-event-on-the-window-that-st
if (stampedAction.$wuid === WINDOW_STATE_SYNC_ID || stampedAction.type === RECEIVE_INIT_STATE) {
if (
stampedAction.$wuid === WINDOW_STATE_SYNC_ID ||
stampedAction.type === RECEIVE_INIT_STATE
) {
return;

@@ -110,3 +134,6 @@ }

dispatch(sendIniteState());
} else if (stampedAction.type === SEND_INIT_STATE && !tabs[stampedAction.$wuid]) {
} else if (
stampedAction.type === SEND_INIT_STATE &&
!tabs[stampedAction.$wuid]
) {
if (!isSynced) {

@@ -125,17 +152,28 @@ isSynced = true;

var createStateSyncMiddleware = exports.createStateSyncMiddleware = function createStateSyncMiddleware() {
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultConfig;
var createStateSyncMiddleware = (exports.createStateSyncMiddleware = function createStateSyncMiddleware() {
var config =
arguments.length > 0 && arguments[0] !== undefined
? arguments[0]
: defaultConfig;
var allowed = isActionAllowed(config);
var channel = new _broadcastChannel2.default(config.channel, config.broadcastChannelOption);
var channel = new _broadcastChannel2.default(
config.channel,
config.broadcastChannelOption
);
var prepareState = config.prepareState || defaultConfig.prepareState;
return function (_ref3) {
return function(_ref3) {
var getState = _ref3.getState,
dispatch = _ref3.dispatch;
return function (next) {
return function (action) {
dispatch = _ref3.dispatch;
return function(next) {
return function(action) {
// create message receiver
if (!isMessageListenerCreated) {
isMessageListenerCreated = true;
createMessageListener({ channel: channel, dispatch: dispatch, allowed: allowed });
createMessageListener({
channel: channel,
dispatch: dispatch,
allowed: allowed
});
}

@@ -149,3 +187,3 @@ // post messages

if (getState()) {
stampedAction.payload = getState();
stampedAction.payload = prepareState(getState());
channel.postMessage(stampedAction);

@@ -159,3 +197,5 @@ }

} catch (e) {
console.error("Your browser doesn't support cross tab communication");
console.error(
"Your browser doesn't support cross tab communication"
);
}

@@ -167,19 +207,32 @@ }

};
};
});
// init state with other tab's state
var withReduxStateSync = exports.withReduxStateSync = function withReduxStateSync(appReducer) {
return function (state, action) {
var initState = state;
if (action.type === RECEIVE_INIT_STATE) {
initState = action.payload;
}
return appReducer(initState, action);
var createReduxStateSync = (exports.createReduxStateSync = function createReduxStateSync(
_ref4
) {
var prepareState = _ref4.prepareState;
return function(appReducer) {
return function(state, action) {
var initState = state;
if (action.type === RECEIVE_INIT_STATE) {
initState = prepareState(action.payload);
}
return appReducer(initState, action);
};
};
};
});
var initStateWithPrevTab = exports.initStateWithPrevTab = function initStateWithPrevTab(_ref4) {
var dispatch = _ref4.dispatch;
// init state with other tab's state
var withReduxStateSync = (exports.withReduxStateSync = createReduxStateSync({
prepareState: function prepareState(state) {
return state;
}
}));
var initStateWithPrevTab = (exports.initStateWithPrevTab = function initStateWithPrevTab(
_ref5
) {
var dispatch = _ref5.dispatch;
dispatch(getIniteState());
};
});
{
"name": "redux-state-sync",
"version": "2.0.4",
"version": "2.0.5",
"description": "A middleware for redux to sync state in different tabs",

@@ -56,3 +56,3 @@ "main": "dist/syncState.js",

"dependencies": {
"broadcast-channel": "^2.1.8"
"broadcast-channel": "^2.3.3"
},

@@ -59,0 +59,0 @@ "jest": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc