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 1.1.0 to 1.1.1

LICENSE

34

dist/syncStorage.js

@@ -8,4 +8,3 @@ 'use strict';

exports.createStorageListener = createStorageListener;
/* global window localStorage true */
var lastTimeStamp = 0;
var lastUuid = 0;
var LAST_ACTION = 'LAST_ACTION';

@@ -61,3 +60,3 @@ var GET_INIT_STATE = '&_GET_INIT_STATE';

var stampedAction = generateUuidForAction(action);
lastTimeStamp = stampedAction.$uuid;
lastUuid = stampedAction.$uuid;
try {

@@ -102,16 +101,23 @@ if (action.type === SEND_INIT_STATE) {

window.addEventListener('storage', function (event) {
var stampedAction = JSON.parse(event.newValue);
if (stampedAction && stampedAction.$uuid !== lastTimeStamp) {
if (stampedAction.type === GET_INIT_STATE && isInitiated) {
store.dispatch(sendIniteState());
} else if (stampedAction.type === SEND_INIT_STATE) {
store.dispatch(receiveIniteState(stampedAction.payload));
isInitiated = true;
} else if (!!allowed(stampedAction.type)) {
lastTimeStamp = stampedAction.$uuid;
store.dispatch(stampedAction);
isInitiated = true;
try {
var stampedAction = JSON.parse(event.newValue);
// ignore other values that saved to localstorage.
if (stampedAction.$uuid) {
if (stampedAction && stampedAction.$uuid !== lastUuid) {
if (stampedAction.type === GET_INIT_STATE && isInitiated) {
store.dispatch(sendIniteState());
} else if (stampedAction.type === SEND_INIT_STATE) {
store.dispatch(receiveIniteState(stampedAction.payload));
isInitiated = true;
} else if (!!allowed(stampedAction.type)) {
lastUuid = stampedAction.$uuid;
store.dispatch(stampedAction);
isInitiated = true;
}
}
}
} catch (e) {
// ignore other data format other than JSON
}
});
}

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

exports.createStorageListener = createStorageListener;
/* global window localStorage true */
var lastTimeStamp = 0;
var lastUuid = 0;
var LAST_ACTION = 'LAST_ACTION';

@@ -144,3 +143,3 @@ var GET_INIT_STATE = '&_GET_INIT_STATE';

var stampedAction = generateUuidForAction(action);
lastTimeStamp = stampedAction.$uuid;
lastUuid = stampedAction.$uuid;
try {

@@ -185,14 +184,21 @@ if (action.type === SEND_INIT_STATE) {

window.addEventListener('storage', function (event) {
var stampedAction = JSON.parse(event.newValue);
if (stampedAction && stampedAction.$uuid !== lastTimeStamp) {
if (stampedAction.type === GET_INIT_STATE && isInitiated) {
store.dispatch(sendIniteState());
} else if (stampedAction.type === SEND_INIT_STATE) {
store.dispatch(receiveIniteState(stampedAction.payload));
isInitiated = true;
} else if (!!allowed(stampedAction.type)) {
lastTimeStamp = stampedAction.$uuid;
store.dispatch(stampedAction);
isInitiated = true;
try {
var stampedAction = JSON.parse(event.newValue);
// ignore other values that saved to localstorage.
if (stampedAction.$uuid) {
if (stampedAction && stampedAction.$uuid !== lastUuid) {
if (stampedAction.type === GET_INIT_STATE && isInitiated) {
store.dispatch(sendIniteState());
} else if (stampedAction.type === SEND_INIT_STATE) {
store.dispatch(receiveIniteState(stampedAction.payload));
isInitiated = true;
} else if (!!allowed(stampedAction.type)) {
lastUuid = stampedAction.$uuid;
store.dispatch(stampedAction);
isInitiated = true;
}
}
}
} catch (e) {
// ignore other data format other than JSON
}

@@ -199,0 +205,0 @@ });

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

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.reduxStateSync=e():t.reduxStateSync=e()}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=0)}([function(t,e,n){"use strict";function r(){return o()+o()+"-"+o()+"-"+o()+"-"+o()+"-"+o()+o()+o()}function o(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}function i(t){var e=t;return e.$uuid=r(),e}function u(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d,n=!1,r=function(){return!0};e.predicate&&"function"==typeof e.predicate?r=e.predicate:Array.isArray(e.ignore)&&(r=function(t){return e.ignore.indexOf(t)<0}),e.initiateWithState&&t.dispatch(p()),window.addEventListener("storage",function(e){var o=JSON.parse(e.newValue);o&&o.$uuid!==a&&(o.type===c&&n?t.dispatch(s()):o.type===f?(t.dispatch(l(o.payload)),n=!0):r(o.type)&&(a=o.$uuid,t.dispatch(o),n=!0))})}Object.defineProperty(e,"__esModule",{value:!0}),e.generateUuidForAction=i,e.createStorageListener=u;var a=0,c="&_GET_INIT_STATE",f="&_SEND_INIT_STATE",d={initiateWithState:!1,predicate:null,ignore:[]},p=function(){return{type:c}},s=function(){return{type:f}},l=function(t){return{type:"&_RECEIVE_INIT_STATE",payload:t}};e.withReduxStateSync=function(t){return function(e,n){return"&_RECEIVE_INIT_STATE"===n.type&&(e=n.payload),t(e,n)}},e.actionStorageMiddleware=function(t){var e=t.getState;return function(t){return function(n){if(n&&!n.$uuid){var r=i(n);a=r.$uuid;try{if(n.type===f)return e()&&(r.payload=e(),localStorage.setItem("LAST_ACTION",JSON.stringify(r))),t(n);localStorage.setItem("LAST_ACTION",JSON.stringify(r))}catch(t){console.error("Your browser doesn't support localStorage")}}return t(n)}}}}])});
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.reduxStateSync=e():t.reduxStateSync=e()}(this,function(){return function(t){function e(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var r={};return e.m=t,e.c=r,e.i=function(t){return t},e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=0)}([function(t,e,r){"use strict";function n(){return o()+o()+"-"+o()+"-"+o()+"-"+o()+"-"+o()+o()+o()}function o(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}function i(t){var e=t;return e.$uuid=n(),e}function u(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d,r=!1,n=function(){return!0};e.predicate&&"function"==typeof e.predicate?n=e.predicate:Array.isArray(e.ignore)&&(n=function(t){return e.ignore.indexOf(t)<0}),e.initiateWithState&&t.dispatch(p()),window.addEventListener("storage",function(e){try{var o=JSON.parse(e.newValue);o.$uuid&&o&&o.$uuid!==a&&(o.type===c&&r?t.dispatch(s()):o.type===f?(t.dispatch(l(o.payload)),r=!0):n(o.type)&&(a=o.$uuid,t.dispatch(o),r=!0))}catch(t){}})}Object.defineProperty(e,"__esModule",{value:!0}),e.generateUuidForAction=i,e.createStorageListener=u;var a=0,c="&_GET_INIT_STATE",f="&_SEND_INIT_STATE",d={initiateWithState:!1,predicate:null,ignore:[]},p=function(){return{type:c}},s=function(){return{type:f}},l=function(t){return{type:"&_RECEIVE_INIT_STATE",payload:t}};e.withReduxStateSync=function(t){return function(e,r){return"&_RECEIVE_INIT_STATE"===r.type&&(e=r.payload),t(e,r)}},e.actionStorageMiddleware=function(t){var e=t.getState;return function(t){return function(r){if(r&&!r.$uuid){var n=i(r);a=n.$uuid;try{if(r.type===f)return e()&&(n.payload=e(),localStorage.setItem("LAST_ACTION",JSON.stringify(n))),t(r);localStorage.setItem("LAST_ACTION",JSON.stringify(n))}catch(t){console.error("Your browser doesn't support localStorage")}}return t(r)}}}}])});
//# sourceMappingURL=syncStorage.umd.min.js.map

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

let nextTodoId = 0
export const addTodo = text => ({

@@ -3,0 +2,0 @@ type: 'ADD_TODO',

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

/* global window localStorage true */
let lastTimeStamp = 0;
let lastUuid = 0;
const LAST_ACTION = 'LAST_ACTION';

@@ -53,3 +52,3 @@ const GET_INIT_STATE = '&_GET_INIT_STATE';

const stampedAction = generateUuidForAction(action);
lastTimeStamp = stampedAction.$uuid;
lastUuid = stampedAction.$uuid;
try {

@@ -86,16 +85,23 @@ if (action.type === SEND_INIT_STATE) {

window.addEventListener('storage', (event) => {
const stampedAction = JSON.parse(event.newValue);
if (stampedAction && stampedAction.$uuid !== lastTimeStamp) {
if (stampedAction.type === GET_INIT_STATE && isInitiated) {
store.dispatch(sendIniteState());
} else if (stampedAction.type === SEND_INIT_STATE) {
store.dispatch(receiveIniteState(stampedAction.payload));
isInitiated = true;
} else if (!!allowed(stampedAction.type)) {
lastTimeStamp = stampedAction.$uuid;
store.dispatch(stampedAction);
isInitiated = true;
try {
const stampedAction = JSON.parse(event.newValue);
// ignore other values that saved to localstorage.
if (stampedAction.$uuid) {
if (stampedAction && stampedAction.$uuid !== lastUuid) {
if (stampedAction.type === GET_INIT_STATE && isInitiated) {
store.dispatch(sendIniteState());
} else if (stampedAction.type === SEND_INIT_STATE) {
store.dispatch(receiveIniteState(stampedAction.payload));
isInitiated = true;
} else if (!!allowed(stampedAction.type)) {
lastUuid = stampedAction.$uuid;
store.dispatch(stampedAction);
isInitiated = true;
}
}
}
} catch (e) {
// ignore other data format other than JSON
}
});
}
{
"name": "redux-state-sync",
"version": "1.1.0",
"version": "1.1.1",
"description": "A middleware for redux to sync state in different tabs",

@@ -5,0 +5,0 @@ "main": "dist/syncStorage.js",

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

/* global window localStorage true */
let lastTimeStamp = 0;
let lastUuid = 0;
const LAST_ACTION = 'LAST_ACTION';

@@ -53,3 +52,3 @@ const GET_INIT_STATE = '&_GET_INIT_STATE';

const stampedAction = generateUuidForAction(action);
lastTimeStamp = stampedAction.$uuid;
lastUuid = stampedAction.$uuid;
try {

@@ -86,16 +85,23 @@ if (action.type === SEND_INIT_STATE) {

window.addEventListener('storage', (event) => {
const stampedAction = JSON.parse(event.newValue);
if (stampedAction && stampedAction.$uuid !== lastTimeStamp) {
if (stampedAction.type === GET_INIT_STATE && isInitiated) {
store.dispatch(sendIniteState());
} else if (stampedAction.type === SEND_INIT_STATE) {
store.dispatch(receiveIniteState(stampedAction.payload));
isInitiated = true;
} else if (!!allowed(stampedAction.type)) {
lastTimeStamp = stampedAction.$uuid;
store.dispatch(stampedAction);
isInitiated = true;
try {
const stampedAction = JSON.parse(event.newValue);
// ignore other values that saved to localstorage.
if (stampedAction.$uuid) {
if (stampedAction && stampedAction.$uuid !== lastUuid) {
if (stampedAction.type === GET_INIT_STATE && isInitiated) {
store.dispatch(sendIniteState());
} else if (stampedAction.type === SEND_INIT_STATE) {
store.dispatch(receiveIniteState(stampedAction.payload));
isInitiated = true;
} else if (!!allowed(stampedAction.type)) {
lastUuid = stampedAction.$uuid;
store.dispatch(stampedAction);
isInitiated = true;
}
}
}
} catch (e) {
// ignore other data format other than JSON
}
});
}

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