New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

subapp-redux

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

subapp-redux - npm Package Compare versions

Comparing version 1.0.13 to 1.0.14

71

dist/dev/shared.js

@@ -18,21 +18,33 @@ import _typeof from "@babel/runtime/helpers/typeof";

var shared = {
var persistenStoreContainer = {
namedStores: {}
};
function setStoreContainer(container) {
shared = container;
shared.namedStores = shared.namedStores || {};
function initContainer(storeContainer) {
storeContainer = storeContainer || persistenStoreContainer;
if (!storeContainer.namedStores) {
storeContainer.namedStores = {};
}
return storeContainer;
}
function setStoreContainer(storeContainer) {
persistenStoreContainer = storeContainer;
initContainer(storeContainer);
}
function clearSharedStore() {
shared.namedStores = {};
persistenStoreContainer.namedStores = {};
}
function getSharedStore(name) {
return name && shared.namedStores[name === true ? "_" : name] || {};
function getSharedStore(name, storeContainer) {
storeContainer = initContainer(storeContainer);
return name && storeContainer.namedStores[name === true ? "_" : name] || {};
}
function setSharedStore(name, contents) {
shared.namedStores[name === true ? "_" : name] = contents;
function setSharedStore(name, contents, storeContainer) {
storeContainer = initContainer(storeContainer);
storeContainer.namedStores[name === true ? "_" : name] = contents;
}

@@ -75,4 +87,4 @@

function replaceReducer(newReducers, info) {
var _getSharedStore = getSharedStore(info.reduxShareStore),
function replaceReducer(newReducers, info, storeContainer) {
var _getSharedStore = getSharedStore(info.reduxShareStore, storeContainer),
store = _getSharedStore.store,

@@ -85,9 +97,9 @@ reducerContainer = _getSharedStore.reducerContainer;

function createSharedStore(initialState, info) {
var sharedStore = info.reduxShareStore;
function createSharedStore(initialState, info, storeContainer) {
var sharedStoreName = info.reduxShareStore;
if (sharedStore) {
if (sharedStoreName) {
assert(info._genReduxCreateStore || !info.reduxCreateStore, "".concat(WHEN_SHARED_MSG, ", you cannot have reduxCreateStore"));
var _getSharedStore2 = getSharedStore(sharedStore),
var _getSharedStore2 = getSharedStore(sharedStoreName, storeContainer),
store = _getSharedStore2.store,

@@ -99,3 +111,3 @@ reducerContainer = _getSharedStore2.reducerContainer;

// after store's created? What can we do about this?
replaceReducer(info.reduxReducers, info);
replaceReducer(info.reduxReducers, info, storeContainer);
} else {

@@ -105,18 +117,23 @@ reducerContainer = newReducerContainer();

store[originalReplaceReducerSym] = store.replaceReducer; //
// TODO: monkey patching store is bad
// since this is share store, reducers must be replaced
// as object of named reducers also, but patching an API
// that alters argument type is worst
// TODO: better handling of a replaceReducer that takes extra params
//
// Since this is share store, reducers must be replaced
// as object of named reducers also.
//
// Maybe create a proxy store object, one for each sub-app
//
// NOTE: It's only on SSR that we need to share store within the
// request and replaceReducer doesn't make sense for SSR, but it's
// taking a storeContainer here anyways.
//
store.replaceReducer = function (reducers, info2) {
return replaceReducer(reducers, info2);
store.replaceReducer = function (reducers, info2, storeContainer2) {
return replaceReducer(reducers, info2, storeContainer2);
};
}
setSharedStore(sharedStore, {
setSharedStore(sharedStoreName, {
store: store,
reducerContainer: reducerContainer
});
}, storeContainer);
return store;

@@ -127,2 +144,4 @@ } // call user provided reduxCreateStore

if (info.reduxCreateStore && !info._genReduxCreateStore) {
// TODO: given the complexities of dealing with and maintaining store
// allowing user reduxCreateStore is not a good idea. Consider for removal.
return info.reduxCreateStore(initialState);

@@ -149,4 +168,4 @@ }

function getReduxCreateStore(info) {
return function (initialState) {
return createSharedStore(initialState, info);
return function (initialState, storeContainer) {
return createSharedStore(initialState, info, storeContainer);
};

@@ -153,0 +172,0 @@ }

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

import _typeof from"@babel/runtime/helpers/typeof";import _defineProperty from"@babel/runtime/helpers/defineProperty";import{createStore,combineReducers}from"redux";var shared={namedStores:{}};function setStoreContainer(a){shared=a,shared.namedStores=shared.namedStores||{}}function clearSharedStore(){shared.namedStores={}}function getSharedStore(a){return a&&shared.namedStores[!0===a?"_":a]||{}}function setSharedStore(a,b){shared.namedStores[!0===a?"_":a]=b}var assert=function(a,b){if(!a)throw new Error(b)},reducerNamesSym="- reducer owner names -",originalReplaceReducerSym="- original replace reducer -",newReducerContainer=function(){return _defineProperty({},reducerNamesSym,[])},WHEN_SHARED_MSG="When using reduxShareStore to share stores",errReducersMustBeObject="".concat(WHEN_SHARED_MSG,", reduxReducers must be an object of named reducers."),addSharedReducer=function(a,b,c){assert("object"===_typeof(c),errReducersMustBeObject);var d=b[reducerNamesSym];b.hasOwnProperty(a.name)||d.push(a.name),b[a.name]=c;var e=d.reduce(function(a,c){return Object.assign(a,b[c])},{});return e},combineSharedReducers=function(a,b,c){return combineReducers(addSharedReducer(a,b,c))};function replaceReducer(a,b){var c=getSharedStore(b.reduxShareStore),d=c.store,e=c.reducerContainer,f=combineSharedReducers(b,e,a);return d[originalReplaceReducerSym](f)}function createSharedStore(a,b){var c=b.reduxShareStore;if(c){assert(b._genReduxCreateStore||!b.reduxCreateStore,"".concat(WHEN_SHARED_MSG,", you cannot have reduxCreateStore"));var d=getSharedStore(c),e=d.store,f=d.reducerContainer;return e?replaceReducer(b.reduxReducers,b):(f=newReducerContainer(),e=createStore(combineSharedReducers(b,f,b.reduxReducers),a),e[originalReplaceReducerSym]=e.replaceReducer,e.replaceReducer=function(a,b){return replaceReducer(a,b)}),setSharedStore(c,{store:e,reducerContainer:f}),e}if(b.reduxCreateStore&&!b._genReduxCreateStore)return b.reduxCreateStore(a);var g,h=_typeof(b.reduxReducers);return g="function"===h?b.reduxReducers:"object"===h?combineReducers(b.reduxReducers):function(a){return a},createStore(g,a)}function getReduxCreateStore(a){return function(b){return createSharedStore(b,a)}}export{setStoreContainer,getReduxCreateStore,createSharedStore,getSharedStore,setSharedStore,clearSharedStore};
import _typeof from"@babel/runtime/helpers/typeof";import _defineProperty from"@babel/runtime/helpers/defineProperty";import{createStore,combineReducers}from"redux";var persistenStoreContainer={namedStores:{}};function initContainer(a){return a=a||persistenStoreContainer,a.namedStores||(a.namedStores={}),a}function setStoreContainer(a){persistenStoreContainer=a,initContainer(a)}function clearSharedStore(){persistenStoreContainer.namedStores={}}function getSharedStore(a,b){return b=initContainer(b),a&&b.namedStores[!0===a?"_":a]||{}}function setSharedStore(a,b,c){c=initContainer(c),c.namedStores[!0===a?"_":a]=b}var assert=function(a,b){if(!a)throw new Error(b)},reducerNamesSym="- reducer owner names -",originalReplaceReducerSym="- original replace reducer -",newReducerContainer=function(){return _defineProperty({},reducerNamesSym,[])},WHEN_SHARED_MSG="When using reduxShareStore to share stores",errReducersMustBeObject="".concat(WHEN_SHARED_MSG,", reduxReducers must be an object of named reducers."),addSharedReducer=function(a,b,c){assert("object"===_typeof(c),errReducersMustBeObject);var d=b[reducerNamesSym];b.hasOwnProperty(a.name)||d.push(a.name),b[a.name]=c;var e=d.reduce(function(a,c){return Object.assign(a,b[c])},{});return e},combineSharedReducers=function(a,b,c){return combineReducers(addSharedReducer(a,b,c))};function replaceReducer(a,b,c){var d=getSharedStore(b.reduxShareStore,c),e=d.store,f=d.reducerContainer,g=combineSharedReducers(b,f,a);return e[originalReplaceReducerSym](g)}function createSharedStore(a,b,c){var d=b.reduxShareStore;if(d){assert(b._genReduxCreateStore||!b.reduxCreateStore,"".concat(WHEN_SHARED_MSG,", you cannot have reduxCreateStore"));var e=getSharedStore(d,c),f=e.store,g=e.reducerContainer;return f?replaceReducer(b.reduxReducers,b,c):(g=newReducerContainer(),f=createStore(combineSharedReducers(b,g,b.reduxReducers),a),f[originalReplaceReducerSym]=f.replaceReducer,f.replaceReducer=function(a,b,c){return replaceReducer(a,b,c)}),setSharedStore(d,{store:f,reducerContainer:g},c),f}if(b.reduxCreateStore&&!b._genReduxCreateStore)return b.reduxCreateStore(a);var h,i=_typeof(b.reduxReducers);return h="function"===i?b.reduxReducers:"object"===i?combineReducers(b.reduxReducers):function(a){return a},createStore(h,a)}function getReduxCreateStore(a){return function(b,c){return createSharedStore(b,a,c)}}export{setStoreContainer,getReduxCreateStore,createSharedStore,getSharedStore,setSharedStore,clearSharedStore};

@@ -29,21 +29,33 @@ "use strict";

//
let shared = {
let persistenStoreContainer = {
namedStores: {}
};
function setStoreContainer(container) {
shared = container;
shared.namedStores = shared.namedStores || {};
function initContainer(storeContainer) {
storeContainer = storeContainer || persistenStoreContainer;
if (!storeContainer.namedStores) {
storeContainer.namedStores = {};
}
return storeContainer;
}
function setStoreContainer(storeContainer) {
persistenStoreContainer = storeContainer;
initContainer(storeContainer);
}
function clearSharedStore() {
shared.namedStores = {};
persistenStoreContainer.namedStores = {};
}
function getSharedStore(name) {
return name && shared.namedStores[name === true ? "_" : name] || {};
function getSharedStore(name, storeContainer) {
storeContainer = initContainer(storeContainer);
return name && storeContainer.namedStores[name === true ? "_" : name] || {};
}
function setSharedStore(name, contents) {
shared.namedStores[name === true ? "_" : name] = contents;
function setSharedStore(name, contents, storeContainer) {
storeContainer = initContainer(storeContainer);
storeContainer.namedStores[name === true ? "_" : name] = contents;
}

@@ -84,7 +96,7 @@

function replaceReducer(newReducers, info) {
function replaceReducer(newReducers, info, storeContainer) {
let {
store,
reducerContainer
} = getSharedStore(info.reduxShareStore);
} = getSharedStore(info.reduxShareStore, storeContainer);
const reducer = combineSharedReducers(info, reducerContainer, newReducers);

@@ -94,6 +106,6 @@ return store[originalReplaceReducerSym](reducer);

function createSharedStore(initialState, info) {
const sharedStore = info.reduxShareStore;
function createSharedStore(initialState, info, storeContainer) {
const sharedStoreName = info.reduxShareStore;
if (sharedStore) {
if (sharedStoreName) {
assert(info._genReduxCreateStore || !info.reduxCreateStore, `${WHEN_SHARED_MSG}, you cannot have reduxCreateStore`);

@@ -103,3 +115,3 @@ let {

reducerContainer
} = getSharedStore(sharedStore);
} = getSharedStore(sharedStoreName, storeContainer);

@@ -109,3 +121,3 @@ if (store) {

// after store's created? What can we do about this?
replaceReducer(info.reduxReducers, info);
replaceReducer(info.reduxReducers, info, storeContainer);
} else {

@@ -115,16 +127,23 @@ reducerContainer = newReducerContainer();

store[originalReplaceReducerSym] = store.replaceReducer; //
// TODO: monkey patching store is bad
// since this is share store, reducers must be replaced
// as object of named reducers also, but patching an API
// that alters argument type is worst
// TODO: better handling of a replaceReducer that takes extra params
//
// Since this is share store, reducers must be replaced
// as object of named reducers also.
//
// Maybe create a proxy store object, one for each sub-app
//
// NOTE: It's only on SSR that we need to share store within the
// request and replaceReducer doesn't make sense for SSR, but it's
// taking a storeContainer here anyways.
//
store.replaceReducer = (reducers, info2) => replaceReducer(reducers, info2);
store.replaceReducer = (reducers, info2, storeContainer2) => {
return replaceReducer(reducers, info2, storeContainer2);
};
}
setSharedStore(sharedStore, {
setSharedStore(sharedStoreName, {
store,
reducerContainer
});
}, storeContainer);
return store;

@@ -135,2 +154,4 @@ } // call user provided reduxCreateStore

if (info.reduxCreateStore && !info._genReduxCreateStore) {
// TODO: given the complexities of dealing with and maintaining store
// allowing user reduxCreateStore is not a good idea. Consider for removal.
return info.reduxCreateStore(initialState);

@@ -154,4 +175,4 @@ }

function getReduxCreateStore(info) {
return initialState => createSharedStore(initialState, info);
return (initialState, storeContainer) => createSharedStore(initialState, info, storeContainer);
}
//# sourceMappingURL=shared.js.map
{
"name": "subapp-redux",
"version": "1.0.13",
"version": "1.0.14",
"description": "Electrode subapp redux support",

@@ -30,3 +30,3 @@ "module": "dist/dev/index.js",

"subapp-util": "^1.0.3",
"subapp-web": "^1.0.12"
"subapp-web": "^1.0.13"
},

@@ -33,0 +33,0 @@ "devDependencies": {

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