redux-astroglide 0.1.25 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/index.js +13 -14
- package/dist/index.mjs +13 -14
- package/dist/index.umd.js +13 -14
- package/dist/plugins/index.js +12 -7
- package/dist/plugins/index.mjs +12 -7
- package/dist/plugins/index.umd.js +12 -7
- package/dist/plugins/persist/index.js +5 -4
- package/dist/plugins/persist/index.mjs +5 -4
- package/dist/plugins/persist/index.umd.js +5 -4
- package/dist/plugins/set/index.js +2 -0
- package/dist/plugins/set/index.mjs +2 -0
- package/dist/plugins/set/index.umd.js +2 -0
- package/dist/plugins/type/index.js +5 -3
- package/dist/plugins/type/index.mjs +5 -3
- package/dist/plugins/type/index.umd.js +5 -3
- package/dist/selectors/index.js +3 -26
- package/dist/selectors/index.mjs +3 -26
- package/dist/selectors/index.umd.js +3 -26
- package/dist/types/actions.d.ts +7 -3
- package/dist/types/plugins/persist/index.d.ts +14 -12
- package/dist/types/plugins/set/index.d.ts +10 -6
- package/dist/types/plugins/type/index.d.ts +18 -13
- package/dist/types/plugins/type/types.d.ts +2 -2
- package/dist/types/reducers.d.ts +19 -4
- package/dist/types/selectors/index.d.ts +20 -8
- package/package.json +19 -14
- package/plugins/package.json +6 -0
- package/plugins/persist/package.json +6 -0
- package/plugins/set/package.json +6 -0
- package/plugins/type/package.json +6 -0
- package/selectors/package.json +6 -0
- package/CHANGELOG.md +0 -4
package/README.md
CHANGED
|
@@ -357,6 +357,10 @@ addPlugins({
|
|
|
357
357
|
|
|
358
358
|
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
|
|
359
359
|
|
|
360
|
+
Releases are automated via semantic-release on push to `main`. See
|
|
361
|
+
[RELEASE.md](RELEASE.md) for the full publish process, including how commit messages
|
|
362
|
+
map to version bumps.
|
|
363
|
+
|
|
360
364
|
|
|
361
365
|
|
|
362
366
|
## License
|
package/dist/index.js
CHANGED
|
@@ -3536,7 +3536,7 @@ var injectSlice = function injectSlice(store, staticReducers, slice) {
|
|
|
3536
3536
|
var getSetterActionName = function getSetterActionName(name) {
|
|
3537
3537
|
return "set".concat(upperFirst_1(name));
|
|
3538
3538
|
};
|
|
3539
|
-
var makeSetterReducersFromInitialState = function makeSetterReducersFromInitialState(initialState,
|
|
3539
|
+
var makeSetterReducersFromInitialState = function makeSetterReducersFromInitialState(initialState, _config, pluginsData) {
|
|
3540
3540
|
var reducer = {};
|
|
3541
3541
|
Object.keys(initialState).forEach(function (name) {
|
|
3542
3542
|
var key = getSetterActionName(name);
|
|
@@ -3684,13 +3684,12 @@ var configure$1 = function configure(store) {
|
|
|
3684
3684
|
return makeReduxStateHook(name, baseSelector, slice);
|
|
3685
3685
|
});
|
|
3686
3686
|
}
|
|
3687
|
-
names = [names];
|
|
3688
3687
|
return makeReduxStateHook(names, baseSelector, slice);
|
|
3689
3688
|
};
|
|
3690
3689
|
};
|
|
3691
3690
|
var makeReduxStateHook = function makeReduxStateHook(name, baseSelector, slice) {
|
|
3692
|
-
var selector = toolkit.createDraftSafeSelector(baseSelector, selectProp(name));
|
|
3693
|
-
var actionName = getSetterActionName(name);
|
|
3691
|
+
var selector = toolkit.createDraftSafeSelector(baseSelector, selectProp(Array.isArray(name) ? name[0] : name));
|
|
3692
|
+
var actionName = getSetterActionName(Array.isArray(name) ? name[0] : name);
|
|
3694
3693
|
var updateAction = function updateAction() {
|
|
3695
3694
|
var _slice$actions;
|
|
3696
3695
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
@@ -3726,7 +3725,7 @@ var configure$1 = function configure(store) {
|
|
|
3726
3725
|
var makePropertySelectorHooksFromInitialState = function makePropertySelectorHooksFromInitialState(baseSelector, slice, initialState) {
|
|
3727
3726
|
var selectorHooksFactory = makePropertySelectorHookFactory(baseSelector, slice);
|
|
3728
3727
|
var selectorHooksObject = {};
|
|
3729
|
-
Object.keys(initialState).forEach(function (key
|
|
3728
|
+
Object.keys(initialState).forEach(function (key) {
|
|
3730
3729
|
selectorHooksObject[getHookName(key)] = selectorHooksFactory(key);
|
|
3731
3730
|
});
|
|
3732
3731
|
return selectorHooksObject;
|
|
@@ -3911,9 +3910,9 @@ var configure = function configure() {
|
|
|
3911
3910
|
}
|
|
3912
3911
|
}), sliceConfig.reducers || {})
|
|
3913
3912
|
}));
|
|
3914
|
-
var
|
|
3915
|
-
selectDomain =
|
|
3916
|
-
hooks = _objectWithoutProperties(
|
|
3913
|
+
var _ref2 = makePropertySelectorsFromSlice(slice),
|
|
3914
|
+
selectDomain = _ref2.selectDomain,
|
|
3915
|
+
hooks = _objectWithoutProperties(_ref2, _excluded2);
|
|
3917
3916
|
var domainHookKey = "useSlice";
|
|
3918
3917
|
while (!!hooks[domainHookKey]) {
|
|
3919
3918
|
// avoid naming conflicts in case initialState contains a "domain" property
|
|
@@ -3931,8 +3930,8 @@ var configure = function configure() {
|
|
|
3931
3930
|
return params;
|
|
3932
3931
|
};
|
|
3933
3932
|
var updateFn = function updateFn() {
|
|
3934
|
-
var
|
|
3935
|
-
return (
|
|
3933
|
+
var _ref3;
|
|
3934
|
+
return (_ref3 = slice.actions)[sliceSetterKey].apply(_ref3, _toConsumableArray(getParams.apply(void 0, arguments)));
|
|
3936
3935
|
};
|
|
3937
3936
|
updateFn.toString = function () {
|
|
3938
3937
|
return slice.actions[sliceSetterKey].toString();
|
|
@@ -3950,13 +3949,13 @@ var configure = function configure() {
|
|
|
3950
3949
|
/* eslint-enable react-hooks/rules-of-hooks */
|
|
3951
3950
|
|
|
3952
3951
|
slice.hooks = hooks;
|
|
3953
|
-
slice.selectors = _objectSpread2(_objectSpread2({
|
|
3954
|
-
selectDomain: selectDomain
|
|
3955
|
-
}, reduce_1(map_1(slice.hooks, function (hook, key) {
|
|
3952
|
+
slice.selectors = _objectSpread2(_objectSpread2({}, reduce_1(map_1(slice.hooks, function (hook, key) {
|
|
3956
3953
|
return _defineProperty({}, key.replace(/^use/, "select"), hook.select);
|
|
3957
3954
|
}), function (a, b) {
|
|
3958
3955
|
return _objectSpread2(_objectSpread2({}, a), b);
|
|
3959
|
-
})),
|
|
3956
|
+
})), {}, {
|
|
3957
|
+
selectDomain: selectDomain
|
|
3958
|
+
}, slice.selectors || {});
|
|
3960
3959
|
injectSlice$1(slice);
|
|
3961
3960
|
return slice;
|
|
3962
3961
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -3532,7 +3532,7 @@ var injectSlice = function injectSlice(store, staticReducers, slice) {
|
|
|
3532
3532
|
var getSetterActionName = function getSetterActionName(name) {
|
|
3533
3533
|
return "set".concat(upperFirst_1(name));
|
|
3534
3534
|
};
|
|
3535
|
-
var makeSetterReducersFromInitialState = function makeSetterReducersFromInitialState(initialState,
|
|
3535
|
+
var makeSetterReducersFromInitialState = function makeSetterReducersFromInitialState(initialState, _config, pluginsData) {
|
|
3536
3536
|
var reducer = {};
|
|
3537
3537
|
Object.keys(initialState).forEach(function (name) {
|
|
3538
3538
|
var key = getSetterActionName(name);
|
|
@@ -3680,13 +3680,12 @@ var configure$1 = function configure(store) {
|
|
|
3680
3680
|
return makeReduxStateHook(name, baseSelector, slice);
|
|
3681
3681
|
});
|
|
3682
3682
|
}
|
|
3683
|
-
names = [names];
|
|
3684
3683
|
return makeReduxStateHook(names, baseSelector, slice);
|
|
3685
3684
|
};
|
|
3686
3685
|
};
|
|
3687
3686
|
var makeReduxStateHook = function makeReduxStateHook(name, baseSelector, slice) {
|
|
3688
|
-
var selector = createDraftSafeSelector(baseSelector, selectProp(name));
|
|
3689
|
-
var actionName = getSetterActionName(name);
|
|
3687
|
+
var selector = createDraftSafeSelector(baseSelector, selectProp(Array.isArray(name) ? name[0] : name));
|
|
3688
|
+
var actionName = getSetterActionName(Array.isArray(name) ? name[0] : name);
|
|
3690
3689
|
var updateAction = function updateAction() {
|
|
3691
3690
|
var _slice$actions;
|
|
3692
3691
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
@@ -3722,7 +3721,7 @@ var configure$1 = function configure(store) {
|
|
|
3722
3721
|
var makePropertySelectorHooksFromInitialState = function makePropertySelectorHooksFromInitialState(baseSelector, slice, initialState) {
|
|
3723
3722
|
var selectorHooksFactory = makePropertySelectorHookFactory(baseSelector, slice);
|
|
3724
3723
|
var selectorHooksObject = {};
|
|
3725
|
-
Object.keys(initialState).forEach(function (key
|
|
3724
|
+
Object.keys(initialState).forEach(function (key) {
|
|
3726
3725
|
selectorHooksObject[getHookName(key)] = selectorHooksFactory(key);
|
|
3727
3726
|
});
|
|
3728
3727
|
return selectorHooksObject;
|
|
@@ -3907,9 +3906,9 @@ var configure = function configure() {
|
|
|
3907
3906
|
}
|
|
3908
3907
|
}), sliceConfig.reducers || {})
|
|
3909
3908
|
}));
|
|
3910
|
-
var
|
|
3911
|
-
selectDomain =
|
|
3912
|
-
hooks = _objectWithoutProperties(
|
|
3909
|
+
var _ref2 = makePropertySelectorsFromSlice(slice),
|
|
3910
|
+
selectDomain = _ref2.selectDomain,
|
|
3911
|
+
hooks = _objectWithoutProperties(_ref2, _excluded2);
|
|
3913
3912
|
var domainHookKey = "useSlice";
|
|
3914
3913
|
while (!!hooks[domainHookKey]) {
|
|
3915
3914
|
// avoid naming conflicts in case initialState contains a "domain" property
|
|
@@ -3927,8 +3926,8 @@ var configure = function configure() {
|
|
|
3927
3926
|
return params;
|
|
3928
3927
|
};
|
|
3929
3928
|
var updateFn = function updateFn() {
|
|
3930
|
-
var
|
|
3931
|
-
return (
|
|
3929
|
+
var _ref3;
|
|
3930
|
+
return (_ref3 = slice.actions)[sliceSetterKey].apply(_ref3, _toConsumableArray(getParams.apply(void 0, arguments)));
|
|
3932
3931
|
};
|
|
3933
3932
|
updateFn.toString = function () {
|
|
3934
3933
|
return slice.actions[sliceSetterKey].toString();
|
|
@@ -3946,13 +3945,13 @@ var configure = function configure() {
|
|
|
3946
3945
|
/* eslint-enable react-hooks/rules-of-hooks */
|
|
3947
3946
|
|
|
3948
3947
|
slice.hooks = hooks;
|
|
3949
|
-
slice.selectors = _objectSpread2(_objectSpread2({
|
|
3950
|
-
selectDomain: selectDomain
|
|
3951
|
-
}, reduce_1(map_1(slice.hooks, function (hook, key) {
|
|
3948
|
+
slice.selectors = _objectSpread2(_objectSpread2({}, reduce_1(map_1(slice.hooks, function (hook, key) {
|
|
3952
3949
|
return _defineProperty({}, key.replace(/^use/, "select"), hook.select);
|
|
3953
3950
|
}), function (a, b) {
|
|
3954
3951
|
return _objectSpread2(_objectSpread2({}, a), b);
|
|
3955
|
-
})),
|
|
3952
|
+
})), {}, {
|
|
3953
|
+
selectDomain: selectDomain
|
|
3954
|
+
}, slice.selectors || {});
|
|
3956
3955
|
injectSlice$1(slice);
|
|
3957
3956
|
return slice;
|
|
3958
3957
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -3533,7 +3533,7 @@
|
|
|
3533
3533
|
var getSetterActionName = function getSetterActionName(name) {
|
|
3534
3534
|
return "set".concat(upperFirst_1(name));
|
|
3535
3535
|
};
|
|
3536
|
-
var makeSetterReducersFromInitialState = function makeSetterReducersFromInitialState(initialState,
|
|
3536
|
+
var makeSetterReducersFromInitialState = function makeSetterReducersFromInitialState(initialState, _config, pluginsData) {
|
|
3537
3537
|
var reducer = {};
|
|
3538
3538
|
Object.keys(initialState).forEach(function (name) {
|
|
3539
3539
|
var key = getSetterActionName(name);
|
|
@@ -3681,13 +3681,12 @@
|
|
|
3681
3681
|
return makeReduxStateHook(name, baseSelector, slice);
|
|
3682
3682
|
});
|
|
3683
3683
|
}
|
|
3684
|
-
names = [names];
|
|
3685
3684
|
return makeReduxStateHook(names, baseSelector, slice);
|
|
3686
3685
|
};
|
|
3687
3686
|
};
|
|
3688
3687
|
var makeReduxStateHook = function makeReduxStateHook(name, baseSelector, slice) {
|
|
3689
|
-
var selector = toolkit.createDraftSafeSelector(baseSelector, selectProp(name));
|
|
3690
|
-
var actionName = getSetterActionName(name);
|
|
3688
|
+
var selector = toolkit.createDraftSafeSelector(baseSelector, selectProp(Array.isArray(name) ? name[0] : name));
|
|
3689
|
+
var actionName = getSetterActionName(Array.isArray(name) ? name[0] : name);
|
|
3691
3690
|
var updateAction = function updateAction() {
|
|
3692
3691
|
var _slice$actions;
|
|
3693
3692
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
@@ -3723,7 +3722,7 @@
|
|
|
3723
3722
|
var makePropertySelectorHooksFromInitialState = function makePropertySelectorHooksFromInitialState(baseSelector, slice, initialState) {
|
|
3724
3723
|
var selectorHooksFactory = makePropertySelectorHookFactory(baseSelector, slice);
|
|
3725
3724
|
var selectorHooksObject = {};
|
|
3726
|
-
Object.keys(initialState).forEach(function (key
|
|
3725
|
+
Object.keys(initialState).forEach(function (key) {
|
|
3727
3726
|
selectorHooksObject[getHookName(key)] = selectorHooksFactory(key);
|
|
3728
3727
|
});
|
|
3729
3728
|
return selectorHooksObject;
|
|
@@ -3908,9 +3907,9 @@
|
|
|
3908
3907
|
}
|
|
3909
3908
|
}), sliceConfig.reducers || {})
|
|
3910
3909
|
}));
|
|
3911
|
-
var
|
|
3912
|
-
selectDomain =
|
|
3913
|
-
hooks = _objectWithoutProperties(
|
|
3910
|
+
var _ref2 = makePropertySelectorsFromSlice(slice),
|
|
3911
|
+
selectDomain = _ref2.selectDomain,
|
|
3912
|
+
hooks = _objectWithoutProperties(_ref2, _excluded2);
|
|
3914
3913
|
var domainHookKey = "useSlice";
|
|
3915
3914
|
while (!!hooks[domainHookKey]) {
|
|
3916
3915
|
// avoid naming conflicts in case initialState contains a "domain" property
|
|
@@ -3928,8 +3927,8 @@
|
|
|
3928
3927
|
return params;
|
|
3929
3928
|
};
|
|
3930
3929
|
var updateFn = function updateFn() {
|
|
3931
|
-
var
|
|
3932
|
-
return (
|
|
3930
|
+
var _ref3;
|
|
3931
|
+
return (_ref3 = slice.actions)[sliceSetterKey].apply(_ref3, _toConsumableArray(getParams.apply(void 0, arguments)));
|
|
3933
3932
|
};
|
|
3934
3933
|
updateFn.toString = function () {
|
|
3935
3934
|
return slice.actions[sliceSetterKey].toString();
|
|
@@ -3947,13 +3946,13 @@
|
|
|
3947
3946
|
/* eslint-enable react-hooks/rules-of-hooks */
|
|
3948
3947
|
|
|
3949
3948
|
slice.hooks = hooks;
|
|
3950
|
-
slice.selectors = _objectSpread2(_objectSpread2({
|
|
3951
|
-
selectDomain: selectDomain
|
|
3952
|
-
}, reduce_1(map_1(slice.hooks, function (hook, key) {
|
|
3949
|
+
slice.selectors = _objectSpread2(_objectSpread2({}, reduce_1(map_1(slice.hooks, function (hook, key) {
|
|
3953
3950
|
return _defineProperty({}, key.replace(/^use/, "select"), hook.select);
|
|
3954
3951
|
}), function (a, b) {
|
|
3955
3952
|
return _objectSpread2(_objectSpread2({}, a), b);
|
|
3956
|
-
})),
|
|
3953
|
+
})), {}, {
|
|
3954
|
+
selectDomain: selectDomain
|
|
3955
|
+
}, slice.selectors || {});
|
|
3957
3956
|
injectSlice$1(slice);
|
|
3958
3957
|
return slice;
|
|
3959
3958
|
};
|
package/dist/plugins/index.js
CHANGED
|
@@ -10,6 +10,8 @@ var checkPropTypes__default = /*#__PURE__*/_interopDefaultLegacy(checkPropTypes)
|
|
|
10
10
|
|
|
11
11
|
var index$2 = (function (callback) {
|
|
12
12
|
return {
|
|
13
|
+
value: undefined,
|
|
14
|
+
callback: callback,
|
|
13
15
|
constructor: function constructor(innerCallback, value) {
|
|
14
16
|
this.value = value;
|
|
15
17
|
this.callback = innerCallback || callback;
|
|
@@ -130,6 +132,11 @@ var index$1 = (function () {
|
|
|
130
132
|
},
|
|
131
133
|
preventUpdate = _ref.preventUpdate;
|
|
132
134
|
return {
|
|
135
|
+
value: undefined,
|
|
136
|
+
propType: undefined,
|
|
137
|
+
config: {
|
|
138
|
+
preventUpdate: false
|
|
139
|
+
},
|
|
133
140
|
constructor: function constructor(propType, value) {
|
|
134
141
|
var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
135
142
|
this.value = value; // value set here because constructor signature is different
|
|
@@ -149,15 +156,12 @@ var index$1 = (function () {
|
|
|
149
156
|
var propType = plugin.propType;
|
|
150
157
|
checkProp(propType, value, key, plugin.config.preventUpdate !== undefined ? plugin.config.preventUpdate : preventUpdate);
|
|
151
158
|
return value;
|
|
152
|
-
},
|
|
153
|
-
config: {
|
|
154
|
-
preventUpdate: false
|
|
155
159
|
}
|
|
156
160
|
};
|
|
157
161
|
});
|
|
158
162
|
|
|
159
|
-
var localStorage = (window
|
|
160
|
-
var
|
|
163
|
+
var localStorage = (typeof window !== 'undefined' ? window : {}).localStorage;
|
|
164
|
+
var isLocalStorageAvailable = !!localStorage;
|
|
161
165
|
var PERSISTENCE_KEY = "astroglide-persist";
|
|
162
166
|
var defaultStorageType = localStorage;
|
|
163
167
|
var getPersistedStore = function getPersistedStore() {
|
|
@@ -193,11 +197,12 @@ var index = (function () {
|
|
|
193
197
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
194
198
|
_ref$storageType = _ref.storageType,
|
|
195
199
|
storageType = _ref$storageType === void 0 ? defaultStorageType : _ref$storageType;
|
|
196
|
-
if (!
|
|
200
|
+
if (!isLocalStorageAvailable && !storageType) {
|
|
197
201
|
console.warn("localStorage is not available! You must provide your own storage to persist"); // eslint-disable-line no-console
|
|
198
202
|
}
|
|
199
203
|
defaultStorageType = storageType;
|
|
200
204
|
return {
|
|
205
|
+
storageType: storageType,
|
|
201
206
|
setup: function setup(plugin, _ref2) {
|
|
202
207
|
var sliceConfig = _ref2.sliceConfig;
|
|
203
208
|
return {
|
|
@@ -220,7 +225,7 @@ var index = (function () {
|
|
|
220
225
|
update: function update(value, _ref4) {
|
|
221
226
|
var key = _ref4.key,
|
|
222
227
|
sliceConfig = _ref4.sliceConfig;
|
|
223
|
-
storePersistedValue(key, sliceConfig.name, value, storageType !== undefined ? storageType : this.
|
|
228
|
+
storePersistedValue(key, sliceConfig.name, value, storageType !== undefined ? storageType : this.storageType || defaultStorageType);
|
|
224
229
|
return value;
|
|
225
230
|
}
|
|
226
231
|
};
|
package/dist/plugins/index.mjs
CHANGED
|
@@ -2,6 +2,8 @@ import checkPropTypes from 'check-prop-types';
|
|
|
2
2
|
|
|
3
3
|
var index$2 = (function (callback) {
|
|
4
4
|
return {
|
|
5
|
+
value: undefined,
|
|
6
|
+
callback: callback,
|
|
5
7
|
constructor: function constructor(innerCallback, value) {
|
|
6
8
|
this.value = value;
|
|
7
9
|
this.callback = innerCallback || callback;
|
|
@@ -122,6 +124,11 @@ var index$1 = (function () {
|
|
|
122
124
|
},
|
|
123
125
|
preventUpdate = _ref.preventUpdate;
|
|
124
126
|
return {
|
|
127
|
+
value: undefined,
|
|
128
|
+
propType: undefined,
|
|
129
|
+
config: {
|
|
130
|
+
preventUpdate: false
|
|
131
|
+
},
|
|
125
132
|
constructor: function constructor(propType, value) {
|
|
126
133
|
var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
127
134
|
this.value = value; // value set here because constructor signature is different
|
|
@@ -141,15 +148,12 @@ var index$1 = (function () {
|
|
|
141
148
|
var propType = plugin.propType;
|
|
142
149
|
checkProp(propType, value, key, plugin.config.preventUpdate !== undefined ? plugin.config.preventUpdate : preventUpdate);
|
|
143
150
|
return value;
|
|
144
|
-
},
|
|
145
|
-
config: {
|
|
146
|
-
preventUpdate: false
|
|
147
151
|
}
|
|
148
152
|
};
|
|
149
153
|
});
|
|
150
154
|
|
|
151
|
-
var localStorage = (window
|
|
152
|
-
var
|
|
155
|
+
var localStorage = (typeof window !== 'undefined' ? window : {}).localStorage;
|
|
156
|
+
var isLocalStorageAvailable = !!localStorage;
|
|
153
157
|
var PERSISTENCE_KEY = "astroglide-persist";
|
|
154
158
|
var defaultStorageType = localStorage;
|
|
155
159
|
var getPersistedStore = function getPersistedStore() {
|
|
@@ -185,11 +189,12 @@ var index = (function () {
|
|
|
185
189
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
186
190
|
_ref$storageType = _ref.storageType,
|
|
187
191
|
storageType = _ref$storageType === void 0 ? defaultStorageType : _ref$storageType;
|
|
188
|
-
if (!
|
|
192
|
+
if (!isLocalStorageAvailable && !storageType) {
|
|
189
193
|
console.warn("localStorage is not available! You must provide your own storage to persist"); // eslint-disable-line no-console
|
|
190
194
|
}
|
|
191
195
|
defaultStorageType = storageType;
|
|
192
196
|
return {
|
|
197
|
+
storageType: storageType,
|
|
193
198
|
setup: function setup(plugin, _ref2) {
|
|
194
199
|
var sliceConfig = _ref2.sliceConfig;
|
|
195
200
|
return {
|
|
@@ -212,7 +217,7 @@ var index = (function () {
|
|
|
212
217
|
update: function update(value, _ref4) {
|
|
213
218
|
var key = _ref4.key,
|
|
214
219
|
sliceConfig = _ref4.sliceConfig;
|
|
215
|
-
storePersistedValue(key, sliceConfig.name, value, storageType !== undefined ? storageType : this.
|
|
220
|
+
storePersistedValue(key, sliceConfig.name, value, storageType !== undefined ? storageType : this.storageType || defaultStorageType);
|
|
216
221
|
return value;
|
|
217
222
|
}
|
|
218
223
|
};
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
|
|
11
11
|
var index$2 = (function (callback) {
|
|
12
12
|
return {
|
|
13
|
+
value: undefined,
|
|
14
|
+
callback: callback,
|
|
13
15
|
constructor: function constructor(innerCallback, value) {
|
|
14
16
|
this.value = value;
|
|
15
17
|
this.callback = innerCallback || callback;
|
|
@@ -130,6 +132,11 @@
|
|
|
130
132
|
},
|
|
131
133
|
preventUpdate = _ref.preventUpdate;
|
|
132
134
|
return {
|
|
135
|
+
value: undefined,
|
|
136
|
+
propType: undefined,
|
|
137
|
+
config: {
|
|
138
|
+
preventUpdate: false
|
|
139
|
+
},
|
|
133
140
|
constructor: function constructor(propType, value) {
|
|
134
141
|
var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
135
142
|
this.value = value; // value set here because constructor signature is different
|
|
@@ -149,15 +156,12 @@
|
|
|
149
156
|
var propType = plugin.propType;
|
|
150
157
|
checkProp(propType, value, key, plugin.config.preventUpdate !== undefined ? plugin.config.preventUpdate : preventUpdate);
|
|
151
158
|
return value;
|
|
152
|
-
},
|
|
153
|
-
config: {
|
|
154
|
-
preventUpdate: false
|
|
155
159
|
}
|
|
156
160
|
};
|
|
157
161
|
});
|
|
158
162
|
|
|
159
|
-
var localStorage = (window
|
|
160
|
-
var
|
|
163
|
+
var localStorage = (typeof window !== 'undefined' ? window : {}).localStorage;
|
|
164
|
+
var isLocalStorageAvailable = !!localStorage;
|
|
161
165
|
var PERSISTENCE_KEY = "astroglide-persist";
|
|
162
166
|
var defaultStorageType = localStorage;
|
|
163
167
|
var getPersistedStore = function getPersistedStore() {
|
|
@@ -193,11 +197,12 @@
|
|
|
193
197
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
194
198
|
_ref$storageType = _ref.storageType,
|
|
195
199
|
storageType = _ref$storageType === void 0 ? defaultStorageType : _ref$storageType;
|
|
196
|
-
if (!
|
|
200
|
+
if (!isLocalStorageAvailable && !storageType) {
|
|
197
201
|
console.warn("localStorage is not available! You must provide your own storage to persist"); // eslint-disable-line no-console
|
|
198
202
|
}
|
|
199
203
|
defaultStorageType = storageType;
|
|
200
204
|
return {
|
|
205
|
+
storageType: storageType,
|
|
201
206
|
setup: function setup(plugin, _ref2) {
|
|
202
207
|
var sliceConfig = _ref2.sliceConfig;
|
|
203
208
|
return {
|
|
@@ -220,7 +225,7 @@
|
|
|
220
225
|
update: function update(value, _ref4) {
|
|
221
226
|
var key = _ref4.key,
|
|
222
227
|
sliceConfig = _ref4.sliceConfig;
|
|
223
|
-
storePersistedValue(key, sliceConfig.name, value, storageType !== undefined ? storageType : this.
|
|
228
|
+
storePersistedValue(key, sliceConfig.name, value, storageType !== undefined ? storageType : this.storageType || defaultStorageType);
|
|
224
229
|
return value;
|
|
225
230
|
}
|
|
226
231
|
};
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var localStorage = (window
|
|
6
|
-
var
|
|
5
|
+
var localStorage = (typeof window !== 'undefined' ? window : {}).localStorage;
|
|
6
|
+
var isLocalStorageAvailable = !!localStorage;
|
|
7
7
|
var PERSISTENCE_KEY = "astroglide-persist";
|
|
8
8
|
var defaultStorageType = localStorage;
|
|
9
9
|
var getPersistedStore = function getPersistedStore() {
|
|
@@ -39,11 +39,12 @@ var index = (function () {
|
|
|
39
39
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
40
40
|
_ref$storageType = _ref.storageType,
|
|
41
41
|
storageType = _ref$storageType === void 0 ? defaultStorageType : _ref$storageType;
|
|
42
|
-
if (!
|
|
42
|
+
if (!isLocalStorageAvailable && !storageType) {
|
|
43
43
|
console.warn("localStorage is not available! You must provide your own storage to persist"); // eslint-disable-line no-console
|
|
44
44
|
}
|
|
45
45
|
defaultStorageType = storageType;
|
|
46
46
|
return {
|
|
47
|
+
storageType: storageType,
|
|
47
48
|
setup: function setup(plugin, _ref2) {
|
|
48
49
|
var sliceConfig = _ref2.sliceConfig;
|
|
49
50
|
return {
|
|
@@ -66,7 +67,7 @@ var index = (function () {
|
|
|
66
67
|
update: function update(value, _ref4) {
|
|
67
68
|
var key = _ref4.key,
|
|
68
69
|
sliceConfig = _ref4.sliceConfig;
|
|
69
|
-
storePersistedValue(key, sliceConfig.name, value, storageType !== undefined ? storageType : this.
|
|
70
|
+
storePersistedValue(key, sliceConfig.name, value, storageType !== undefined ? storageType : this.storageType || defaultStorageType);
|
|
70
71
|
return value;
|
|
71
72
|
}
|
|
72
73
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var localStorage = (window
|
|
2
|
-
var
|
|
1
|
+
var localStorage = (typeof window !== 'undefined' ? window : {}).localStorage;
|
|
2
|
+
var isLocalStorageAvailable = !!localStorage;
|
|
3
3
|
var PERSISTENCE_KEY = "astroglide-persist";
|
|
4
4
|
var defaultStorageType = localStorage;
|
|
5
5
|
var getPersistedStore = function getPersistedStore() {
|
|
@@ -35,11 +35,12 @@ var index = (function () {
|
|
|
35
35
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
36
36
|
_ref$storageType = _ref.storageType,
|
|
37
37
|
storageType = _ref$storageType === void 0 ? defaultStorageType : _ref$storageType;
|
|
38
|
-
if (!
|
|
38
|
+
if (!isLocalStorageAvailable && !storageType) {
|
|
39
39
|
console.warn("localStorage is not available! You must provide your own storage to persist"); // eslint-disable-line no-console
|
|
40
40
|
}
|
|
41
41
|
defaultStorageType = storageType;
|
|
42
42
|
return {
|
|
43
|
+
storageType: storageType,
|
|
43
44
|
setup: function setup(plugin, _ref2) {
|
|
44
45
|
var sliceConfig = _ref2.sliceConfig;
|
|
45
46
|
return {
|
|
@@ -62,7 +63,7 @@ var index = (function () {
|
|
|
62
63
|
update: function update(value, _ref4) {
|
|
63
64
|
var key = _ref4.key,
|
|
64
65
|
sliceConfig = _ref4.sliceConfig;
|
|
65
|
-
storePersistedValue(key, sliceConfig.name, value, storageType !== undefined ? storageType : this.
|
|
66
|
+
storePersistedValue(key, sliceConfig.name, value, storageType !== undefined ? storageType : this.storageType || defaultStorageType);
|
|
66
67
|
return value;
|
|
67
68
|
}
|
|
68
69
|
};
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["redux-astroglide/plugins/persist"] = {}));
|
|
5
5
|
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
-
var localStorage = (window
|
|
8
|
-
var
|
|
7
|
+
var localStorage = (typeof window !== 'undefined' ? window : {}).localStorage;
|
|
8
|
+
var isLocalStorageAvailable = !!localStorage;
|
|
9
9
|
var PERSISTENCE_KEY = "astroglide-persist";
|
|
10
10
|
var defaultStorageType = localStorage;
|
|
11
11
|
var getPersistedStore = function getPersistedStore() {
|
|
@@ -41,11 +41,12 @@
|
|
|
41
41
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
42
42
|
_ref$storageType = _ref.storageType,
|
|
43
43
|
storageType = _ref$storageType === void 0 ? defaultStorageType : _ref$storageType;
|
|
44
|
-
if (!
|
|
44
|
+
if (!isLocalStorageAvailable && !storageType) {
|
|
45
45
|
console.warn("localStorage is not available! You must provide your own storage to persist"); // eslint-disable-line no-console
|
|
46
46
|
}
|
|
47
47
|
defaultStorageType = storageType;
|
|
48
48
|
return {
|
|
49
|
+
storageType: storageType,
|
|
49
50
|
setup: function setup(plugin, _ref2) {
|
|
50
51
|
var sliceConfig = _ref2.sliceConfig;
|
|
51
52
|
return {
|
|
@@ -68,7 +69,7 @@
|
|
|
68
69
|
update: function update(value, _ref4) {
|
|
69
70
|
var key = _ref4.key,
|
|
70
71
|
sliceConfig = _ref4.sliceConfig;
|
|
71
|
-
storePersistedValue(key, sliceConfig.name, value, storageType !== undefined ? storageType : this.
|
|
72
|
+
storePersistedValue(key, sliceConfig.name, value, storageType !== undefined ? storageType : this.storageType || defaultStorageType);
|
|
72
73
|
return value;
|
|
73
74
|
}
|
|
74
75
|
};
|
|
@@ -75,6 +75,11 @@ var index = (function () {
|
|
|
75
75
|
},
|
|
76
76
|
preventUpdate = _ref.preventUpdate;
|
|
77
77
|
return {
|
|
78
|
+
value: undefined,
|
|
79
|
+
propType: undefined,
|
|
80
|
+
config: {
|
|
81
|
+
preventUpdate: false
|
|
82
|
+
},
|
|
78
83
|
constructor: function constructor(propType, value) {
|
|
79
84
|
var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
80
85
|
this.value = value; // value set here because constructor signature is different
|
|
@@ -94,9 +99,6 @@ var index = (function () {
|
|
|
94
99
|
var propType = plugin.propType;
|
|
95
100
|
checkProp(propType, value, key, plugin.config.preventUpdate !== undefined ? plugin.config.preventUpdate : preventUpdate);
|
|
96
101
|
return value;
|
|
97
|
-
},
|
|
98
|
-
config: {
|
|
99
|
-
preventUpdate: false
|
|
100
102
|
}
|
|
101
103
|
};
|
|
102
104
|
});
|
|
@@ -69,6 +69,11 @@ var index = (function () {
|
|
|
69
69
|
},
|
|
70
70
|
preventUpdate = _ref.preventUpdate;
|
|
71
71
|
return {
|
|
72
|
+
value: undefined,
|
|
73
|
+
propType: undefined,
|
|
74
|
+
config: {
|
|
75
|
+
preventUpdate: false
|
|
76
|
+
},
|
|
72
77
|
constructor: function constructor(propType, value) {
|
|
73
78
|
var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
74
79
|
this.value = value; // value set here because constructor signature is different
|
|
@@ -88,9 +93,6 @@ var index = (function () {
|
|
|
88
93
|
var propType = plugin.propType;
|
|
89
94
|
checkProp(propType, value, key, plugin.config.preventUpdate !== undefined ? plugin.config.preventUpdate : preventUpdate);
|
|
90
95
|
return value;
|
|
91
|
-
},
|
|
92
|
-
config: {
|
|
93
|
-
preventUpdate: false
|
|
94
96
|
}
|
|
95
97
|
};
|
|
96
98
|
});
|
|
@@ -77,6 +77,11 @@
|
|
|
77
77
|
},
|
|
78
78
|
preventUpdate = _ref.preventUpdate;
|
|
79
79
|
return {
|
|
80
|
+
value: undefined,
|
|
81
|
+
propType: undefined,
|
|
82
|
+
config: {
|
|
83
|
+
preventUpdate: false
|
|
84
|
+
},
|
|
80
85
|
constructor: function constructor(propType, value) {
|
|
81
86
|
var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
82
87
|
this.value = value; // value set here because constructor signature is different
|
|
@@ -96,9 +101,6 @@
|
|
|
96
101
|
var propType = plugin.propType;
|
|
97
102
|
checkProp(propType, value, key, plugin.config.preventUpdate !== undefined ? plugin.config.preventUpdate : preventUpdate);
|
|
98
103
|
return value;
|
|
99
|
-
},
|
|
100
|
-
config: {
|
|
101
|
-
preventUpdate: false
|
|
102
104
|
}
|
|
103
105
|
};
|
|
104
106
|
});
|
package/dist/selectors/index.js
CHANGED
|
@@ -49,26 +49,6 @@ function _objectSpread2(e) {
|
|
|
49
49
|
}
|
|
50
50
|
return e;
|
|
51
51
|
}
|
|
52
|
-
function _objectWithoutProperties(e, t) {
|
|
53
|
-
if (null == e) return {};
|
|
54
|
-
var o,
|
|
55
|
-
r,
|
|
56
|
-
i = _objectWithoutPropertiesLoose(e, t);
|
|
57
|
-
if (Object.getOwnPropertySymbols) {
|
|
58
|
-
var n = Object.getOwnPropertySymbols(e);
|
|
59
|
-
for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
60
|
-
}
|
|
61
|
-
return i;
|
|
62
|
-
}
|
|
63
|
-
function _objectWithoutPropertiesLoose(r, e) {
|
|
64
|
-
if (null == r) return {};
|
|
65
|
-
var t = {};
|
|
66
|
-
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
67
|
-
if (-1 !== e.indexOf(n)) continue;
|
|
68
|
-
t[n] = r[n];
|
|
69
|
-
}
|
|
70
|
-
return t;
|
|
71
|
-
}
|
|
72
52
|
function _toConsumableArray(r) {
|
|
73
53
|
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
74
54
|
}
|
|
@@ -1524,7 +1504,6 @@ function get(object, path, defaultValue) {
|
|
|
1524
1504
|
}
|
|
1525
1505
|
var get_1 = get;
|
|
1526
1506
|
|
|
1527
|
-
var _excluded = ["data"];
|
|
1528
1507
|
var makeSelectorHook = function makeSelectorHook(selector) {
|
|
1529
1508
|
return function () {
|
|
1530
1509
|
return reactRedux.useSelector(selector, reactRedux.shallowEqual);
|
|
@@ -1556,7 +1535,6 @@ var makeQuerySelectors = function makeQuerySelectors(endpoint, defaultValue) {
|
|
|
1556
1535
|
var selector = endpoint.select();
|
|
1557
1536
|
var dataSelector = toolkit.createDraftSafeSelector(selector, function (_ref) {
|
|
1558
1537
|
var data = _ref.data;
|
|
1559
|
-
_objectWithoutProperties(_ref, _excluded);
|
|
1560
1538
|
return data || defaultValue;
|
|
1561
1539
|
});
|
|
1562
1540
|
return [selector, dataSelector];
|
|
@@ -1595,13 +1573,12 @@ var configure = function configure(store) {
|
|
|
1595
1573
|
return makeReduxStateHook(name, baseSelector, slice);
|
|
1596
1574
|
});
|
|
1597
1575
|
}
|
|
1598
|
-
names = [names];
|
|
1599
1576
|
return makeReduxStateHook(names, baseSelector, slice);
|
|
1600
1577
|
};
|
|
1601
1578
|
};
|
|
1602
1579
|
var makeReduxStateHook = function makeReduxStateHook(name, baseSelector, slice) {
|
|
1603
|
-
var selector = toolkit.createDraftSafeSelector(baseSelector, selectProp(name));
|
|
1604
|
-
var actionName = getSetterActionName(name);
|
|
1580
|
+
var selector = toolkit.createDraftSafeSelector(baseSelector, selectProp(Array.isArray(name) ? name[0] : name));
|
|
1581
|
+
var actionName = getSetterActionName(Array.isArray(name) ? name[0] : name);
|
|
1605
1582
|
var updateAction = function updateAction() {
|
|
1606
1583
|
var _slice$actions;
|
|
1607
1584
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
@@ -1637,7 +1614,7 @@ var configure = function configure(store) {
|
|
|
1637
1614
|
var makePropertySelectorHooksFromInitialState = function makePropertySelectorHooksFromInitialState(baseSelector, slice, initialState) {
|
|
1638
1615
|
var selectorHooksFactory = makePropertySelectorHookFactory(baseSelector, slice);
|
|
1639
1616
|
var selectorHooksObject = {};
|
|
1640
|
-
Object.keys(initialState).forEach(function (key
|
|
1617
|
+
Object.keys(initialState).forEach(function (key) {
|
|
1641
1618
|
selectorHooksObject[getHookName(key)] = selectorHooksFactory(key);
|
|
1642
1619
|
});
|
|
1643
1620
|
return selectorHooksObject;
|
package/dist/selectors/index.mjs
CHANGED
|
@@ -45,26 +45,6 @@ function _objectSpread2(e) {
|
|
|
45
45
|
}
|
|
46
46
|
return e;
|
|
47
47
|
}
|
|
48
|
-
function _objectWithoutProperties(e, t) {
|
|
49
|
-
if (null == e) return {};
|
|
50
|
-
var o,
|
|
51
|
-
r,
|
|
52
|
-
i = _objectWithoutPropertiesLoose(e, t);
|
|
53
|
-
if (Object.getOwnPropertySymbols) {
|
|
54
|
-
var n = Object.getOwnPropertySymbols(e);
|
|
55
|
-
for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
56
|
-
}
|
|
57
|
-
return i;
|
|
58
|
-
}
|
|
59
|
-
function _objectWithoutPropertiesLoose(r, e) {
|
|
60
|
-
if (null == r) return {};
|
|
61
|
-
var t = {};
|
|
62
|
-
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
63
|
-
if (-1 !== e.indexOf(n)) continue;
|
|
64
|
-
t[n] = r[n];
|
|
65
|
-
}
|
|
66
|
-
return t;
|
|
67
|
-
}
|
|
68
48
|
function _toConsumableArray(r) {
|
|
69
49
|
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
70
50
|
}
|
|
@@ -1520,7 +1500,6 @@ function get(object, path, defaultValue) {
|
|
|
1520
1500
|
}
|
|
1521
1501
|
var get_1 = get;
|
|
1522
1502
|
|
|
1523
|
-
var _excluded = ["data"];
|
|
1524
1503
|
var makeSelectorHook = function makeSelectorHook(selector) {
|
|
1525
1504
|
return function () {
|
|
1526
1505
|
return useSelector(selector, shallowEqual);
|
|
@@ -1552,7 +1531,6 @@ var makeQuerySelectors = function makeQuerySelectors(endpoint, defaultValue) {
|
|
|
1552
1531
|
var selector = endpoint.select();
|
|
1553
1532
|
var dataSelector = createDraftSafeSelector(selector, function (_ref) {
|
|
1554
1533
|
var data = _ref.data;
|
|
1555
|
-
_objectWithoutProperties(_ref, _excluded);
|
|
1556
1534
|
return data || defaultValue;
|
|
1557
1535
|
});
|
|
1558
1536
|
return [selector, dataSelector];
|
|
@@ -1591,13 +1569,12 @@ var configure = function configure(store) {
|
|
|
1591
1569
|
return makeReduxStateHook(name, baseSelector, slice);
|
|
1592
1570
|
});
|
|
1593
1571
|
}
|
|
1594
|
-
names = [names];
|
|
1595
1572
|
return makeReduxStateHook(names, baseSelector, slice);
|
|
1596
1573
|
};
|
|
1597
1574
|
};
|
|
1598
1575
|
var makeReduxStateHook = function makeReduxStateHook(name, baseSelector, slice) {
|
|
1599
|
-
var selector = createDraftSafeSelector(baseSelector, selectProp(name));
|
|
1600
|
-
var actionName = getSetterActionName(name);
|
|
1576
|
+
var selector = createDraftSafeSelector(baseSelector, selectProp(Array.isArray(name) ? name[0] : name));
|
|
1577
|
+
var actionName = getSetterActionName(Array.isArray(name) ? name[0] : name);
|
|
1601
1578
|
var updateAction = function updateAction() {
|
|
1602
1579
|
var _slice$actions;
|
|
1603
1580
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
@@ -1633,7 +1610,7 @@ var configure = function configure(store) {
|
|
|
1633
1610
|
var makePropertySelectorHooksFromInitialState = function makePropertySelectorHooksFromInitialState(baseSelector, slice, initialState) {
|
|
1634
1611
|
var selectorHooksFactory = makePropertySelectorHookFactory(baseSelector, slice);
|
|
1635
1612
|
var selectorHooksObject = {};
|
|
1636
|
-
Object.keys(initialState).forEach(function (key
|
|
1613
|
+
Object.keys(initialState).forEach(function (key) {
|
|
1637
1614
|
selectorHooksObject[getHookName(key)] = selectorHooksFactory(key);
|
|
1638
1615
|
});
|
|
1639
1616
|
return selectorHooksObject;
|
|
@@ -47,26 +47,6 @@
|
|
|
47
47
|
}
|
|
48
48
|
return e;
|
|
49
49
|
}
|
|
50
|
-
function _objectWithoutProperties(e, t) {
|
|
51
|
-
if (null == e) return {};
|
|
52
|
-
var o,
|
|
53
|
-
r,
|
|
54
|
-
i = _objectWithoutPropertiesLoose(e, t);
|
|
55
|
-
if (Object.getOwnPropertySymbols) {
|
|
56
|
-
var n = Object.getOwnPropertySymbols(e);
|
|
57
|
-
for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
58
|
-
}
|
|
59
|
-
return i;
|
|
60
|
-
}
|
|
61
|
-
function _objectWithoutPropertiesLoose(r, e) {
|
|
62
|
-
if (null == r) return {};
|
|
63
|
-
var t = {};
|
|
64
|
-
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
65
|
-
if (-1 !== e.indexOf(n)) continue;
|
|
66
|
-
t[n] = r[n];
|
|
67
|
-
}
|
|
68
|
-
return t;
|
|
69
|
-
}
|
|
70
50
|
function _toConsumableArray(r) {
|
|
71
51
|
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
72
52
|
}
|
|
@@ -1522,7 +1502,6 @@
|
|
|
1522
1502
|
}
|
|
1523
1503
|
var get_1 = get;
|
|
1524
1504
|
|
|
1525
|
-
var _excluded = ["data"];
|
|
1526
1505
|
var makeSelectorHook = function makeSelectorHook(selector) {
|
|
1527
1506
|
return function () {
|
|
1528
1507
|
return reactRedux.useSelector(selector, reactRedux.shallowEqual);
|
|
@@ -1554,7 +1533,6 @@
|
|
|
1554
1533
|
var selector = endpoint.select();
|
|
1555
1534
|
var dataSelector = toolkit.createDraftSafeSelector(selector, function (_ref) {
|
|
1556
1535
|
var data = _ref.data;
|
|
1557
|
-
_objectWithoutProperties(_ref, _excluded);
|
|
1558
1536
|
return data || defaultValue;
|
|
1559
1537
|
});
|
|
1560
1538
|
return [selector, dataSelector];
|
|
@@ -1593,13 +1571,12 @@
|
|
|
1593
1571
|
return makeReduxStateHook(name, baseSelector, slice);
|
|
1594
1572
|
});
|
|
1595
1573
|
}
|
|
1596
|
-
names = [names];
|
|
1597
1574
|
return makeReduxStateHook(names, baseSelector, slice);
|
|
1598
1575
|
};
|
|
1599
1576
|
};
|
|
1600
1577
|
var makeReduxStateHook = function makeReduxStateHook(name, baseSelector, slice) {
|
|
1601
|
-
var selector = toolkit.createDraftSafeSelector(baseSelector, selectProp(name));
|
|
1602
|
-
var actionName = getSetterActionName(name);
|
|
1578
|
+
var selector = toolkit.createDraftSafeSelector(baseSelector, selectProp(Array.isArray(name) ? name[0] : name));
|
|
1579
|
+
var actionName = getSetterActionName(Array.isArray(name) ? name[0] : name);
|
|
1603
1580
|
var updateAction = function updateAction() {
|
|
1604
1581
|
var _slice$actions;
|
|
1605
1582
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
@@ -1635,7 +1612,7 @@
|
|
|
1635
1612
|
var makePropertySelectorHooksFromInitialState = function makePropertySelectorHooksFromInitialState(baseSelector, slice, initialState) {
|
|
1636
1613
|
var selectorHooksFactory = makePropertySelectorHookFactory(baseSelector, slice);
|
|
1637
1614
|
var selectorHooksObject = {};
|
|
1638
|
-
Object.keys(initialState).forEach(function (key
|
|
1615
|
+
Object.keys(initialState).forEach(function (key) {
|
|
1639
1616
|
selectorHooksObject[getHookName(key)] = selectorHooksFactory(key);
|
|
1640
1617
|
});
|
|
1641
1618
|
return selectorHooksObject;
|
package/dist/types/actions.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { ActionCreatorsMapObject, ActionCreator } from "@reduxjs/toolkit";
|
|
2
|
+
import { DependencyList } from "react";
|
|
3
|
+
type ActionCreatorOrMap = ActionCreator<any> | ActionCreatorsMapObject<any>;
|
|
4
|
+
export declare const useAction: (action: ActionCreatorOrMap, deps?: DependencyList) => any;
|
|
5
|
+
export declare const useActions: (actions: ActionCreatorOrMap | ActionCreatorOrMap[], deps?: DependencyList) => ActionCreatorsMapObject<any> | ActionCreatorsMapObject<any>[];
|
|
6
|
+
export declare const makeUseActions: (actions: ActionCreatorOrMap | ActionCreatorOrMap[]) => (deps?: DependencyList) => ActionCreatorsMapObject<any> | ActionCreatorsMapObject<any>[];
|
|
7
|
+
export {};
|
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
import type { PluginClass, sliceConfig } from "../plugins";
|
|
2
2
|
import type { Storage } from "./types";
|
|
3
|
-
export declare const getPersistedStore: (storage?: Storage) => any
|
|
3
|
+
export declare const getPersistedStore: (storage?: Storage) => Record<string, any>;
|
|
4
4
|
export declare const storePersistedValue: (key: string, namespace?: string, value?: any, storage?: Storage) => void;
|
|
5
5
|
export declare const getPersistedValue: (key: string, namespace?: string, _storage?: Storage) => any;
|
|
6
|
-
|
|
7
|
-
storageType
|
|
8
|
-
|
|
9
|
-
setup(plugin: PluginClass, { sliceConfig }: {
|
|
6
|
+
interface PersistPlugin {
|
|
7
|
+
storageType: Storage;
|
|
8
|
+
setup(plugin: PluginClass, context: {
|
|
10
9
|
sliceConfig: sliceConfig;
|
|
11
10
|
}): {
|
|
12
11
|
namespace: string;
|
|
13
12
|
storageType: Storage;
|
|
14
13
|
};
|
|
15
|
-
getInitialValue(value: any,
|
|
16
|
-
sliceConfig:
|
|
17
|
-
key:
|
|
14
|
+
getInitialValue(value: any, context: {
|
|
15
|
+
sliceConfig: sliceConfig;
|
|
16
|
+
key: string;
|
|
18
17
|
}): any;
|
|
19
|
-
update(value: any,
|
|
20
|
-
key:
|
|
21
|
-
sliceConfig:
|
|
18
|
+
update(value: any, context: {
|
|
19
|
+
key: string;
|
|
20
|
+
sliceConfig: sliceConfig;
|
|
22
21
|
}): any;
|
|
23
|
-
}
|
|
22
|
+
}
|
|
23
|
+
declare const _default: ({ storageType, }?: {
|
|
24
|
+
storageType?: Storage;
|
|
25
|
+
}) => PersistPlugin;
|
|
24
26
|
export default _default;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
type SetCallback = (value: any, context: {
|
|
2
2
|
draft: any;
|
|
3
|
-
}) => any
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
}) => any;
|
|
4
|
+
interface SetPlugin {
|
|
5
|
+
value: any;
|
|
6
|
+
callback: SetCallback;
|
|
7
|
+
constructor(innerCallback: SetCallback | null, value: any): void;
|
|
8
|
+
update(value: any, context: {
|
|
6
9
|
draft: any;
|
|
7
|
-
plugin:
|
|
10
|
+
plugin: SetPlugin;
|
|
8
11
|
}): any;
|
|
9
|
-
}
|
|
12
|
+
}
|
|
13
|
+
declare const _default: (callback: SetCallback) => SetPlugin;
|
|
10
14
|
export default _default;
|
|
@@ -1,17 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
type PropType = any;
|
|
2
|
+
interface TypePluginConfig {
|
|
2
3
|
preventUpdate: boolean;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
}
|
|
5
|
+
interface TypePlugin {
|
|
6
|
+
value: any;
|
|
7
|
+
propType: PropType;
|
|
8
|
+
config: TypePluginConfig;
|
|
9
|
+
constructor(propType: PropType, value: any, config?: Partial<TypePluginConfig>): void;
|
|
10
|
+
getInitialValue(value: any, context: {
|
|
11
|
+
key: string;
|
|
12
|
+
plugin: TypePlugin;
|
|
8
13
|
}): any;
|
|
9
|
-
update(value: any,
|
|
10
|
-
key:
|
|
11
|
-
plugin:
|
|
14
|
+
update(value: any, context: {
|
|
15
|
+
key: string;
|
|
16
|
+
plugin: TypePlugin;
|
|
12
17
|
}): any;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
18
|
+
}
|
|
19
|
+
declare const _default: ({ preventUpdate }?: {
|
|
20
|
+
preventUpdate: boolean;
|
|
21
|
+
}) => TypePlugin;
|
|
17
22
|
export default _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const checkPropType: (propType: any, value: any, name: string, extraProps?: object) =>
|
|
2
|
-
export declare const checkProp: (propType: any, value: any, name: string, shouldTypeErrorPreventUpdate?: boolean) =>
|
|
1
|
+
export declare const checkPropType: (propType: any, value: any, name: string, extraProps?: object) => string;
|
|
2
|
+
export declare const checkProp: (propType: any, value: any, name: string, shouldTypeErrorPreventUpdate?: boolean) => string | false;
|
package/dist/types/reducers.d.ts
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { Store, Reducer, PayloadAction } from "@reduxjs/toolkit";
|
|
2
|
+
type ReducersMapObject = Record<string, Reducer>;
|
|
3
|
+
type PluginData = {
|
|
4
|
+
data: Record<string, any>;
|
|
5
|
+
plugin: {
|
|
6
|
+
update: (value: any, context: Record<string, any>) => any;
|
|
7
|
+
config?: Record<string, any>;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
type PluginsDataMap = Record<string, PluginData[]>;
|
|
11
|
+
export declare const injectReducer: (store: Store, staticReducers: ReducersMapObject, key: string, asyncReducer: Reducer) => void;
|
|
12
|
+
type SliceLike = {
|
|
13
|
+
name: string;
|
|
14
|
+
reducer: Reducer;
|
|
15
|
+
};
|
|
16
|
+
export declare const injectSlice: (store: Store, staticReducers: ReducersMapObject, slice: SliceLike) => void;
|
|
17
|
+
export declare const getSetterActionName: (name: string) => string;
|
|
18
|
+
export declare const makeSetterReducersFromInitialState: (initialState: Record<string, any>, _config: Record<string, any>, pluginsData: PluginsDataMap) => Record<string, (state: Record<string, any>, action: PayloadAction<any>) => void>;
|
|
19
|
+
export {};
|
|
@@ -1,14 +1,26 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { Store } from "@reduxjs/toolkit";
|
|
2
|
+
import type { Selector } from "@reduxjs/toolkit";
|
|
3
|
+
type SelectorFunction<T = any> = (state: any) => T;
|
|
4
|
+
type SelectorFactory<T = any> = (args: any) => SelectorFunction<T>;
|
|
5
|
+
type EndpointLike = {
|
|
6
|
+
select: () => SelectorFunction;
|
|
7
|
+
};
|
|
8
|
+
type SliceLike = {
|
|
9
|
+
name: string;
|
|
10
|
+
getInitialState: () => any;
|
|
11
|
+
actions: Record<string, any>;
|
|
12
|
+
};
|
|
13
|
+
export declare const makeSelectorHook: <T>(selector: SelectorFunction<T>) => () => any;
|
|
14
|
+
export declare const makeSelectorFactoryHook: <T>(selectorFactory: SelectorFactory<T>) => (args: any) => any;
|
|
15
|
+
export declare const createSelectorUpdateHook: (selector: Selector, action: any) => () => any[];
|
|
5
16
|
export declare const createSelectorHook: (args_0: any) => any;
|
|
6
|
-
export declare const makeQuerySelectors: (endpoint:
|
|
17
|
+
export declare const makeQuerySelectors: <T>(endpoint: EndpointLike, defaultValue: T) => SelectorFunction<any>[];
|
|
7
18
|
export declare const dataSelector: ({ data }: {
|
|
8
19
|
data: any;
|
|
9
20
|
}) => any;
|
|
10
|
-
export declare const configure: (store:
|
|
11
|
-
makePropertySelectorsFromSlice: (slice:
|
|
12
|
-
selectDomain: (state: any) => any;
|
|
21
|
+
export declare const configure: (store: Store) => {
|
|
22
|
+
makePropertySelectorsFromSlice: (slice: SliceLike) => {
|
|
23
|
+
selectDomain: (state: Record<string, any>) => any;
|
|
13
24
|
};
|
|
14
25
|
};
|
|
26
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "redux-astroglide",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Taking the pain out of redux state management",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"redux",
|
|
@@ -56,7 +56,9 @@
|
|
|
56
56
|
"browser": "./dist/index.umd.js",
|
|
57
57
|
"types": "./dist/types/index.d.ts",
|
|
58
58
|
"files": [
|
|
59
|
-
"dist"
|
|
59
|
+
"dist",
|
|
60
|
+
"plugins",
|
|
61
|
+
"selectors"
|
|
60
62
|
],
|
|
61
63
|
"scripts": {
|
|
62
64
|
"start": "BUILD_ENV=dev npm run build:js -- --watch",
|
|
@@ -76,12 +78,10 @@
|
|
|
76
78
|
},
|
|
77
79
|
"lint-staged": {
|
|
78
80
|
"*.{js,jsx,ts,tsx}": [
|
|
79
|
-
"prettier --write"
|
|
80
|
-
"git add"
|
|
81
|
+
"prettier --write"
|
|
81
82
|
],
|
|
82
83
|
"*.{json,md,yml}": [
|
|
83
|
-
"prettier --write"
|
|
84
|
-
"git add"
|
|
84
|
+
"prettier --write"
|
|
85
85
|
]
|
|
86
86
|
},
|
|
87
87
|
"dependencies": {
|
|
@@ -93,23 +93,27 @@
|
|
|
93
93
|
"@babel/core": "^7.18.2",
|
|
94
94
|
"@babel/preset-env": "^7.18.2",
|
|
95
95
|
"@babel/preset-typescript": "^7.17.12",
|
|
96
|
+
"@commitlint/cli": "^21.0.0",
|
|
96
97
|
"@commitlint/config-conventional": "17.0.3",
|
|
97
98
|
"@reduxjs/toolkit": "^1.9.2",
|
|
98
99
|
"@rollup/plugin-babel": "5.3.1",
|
|
99
100
|
"@rollup/plugin-commonjs": "^22.0.0",
|
|
100
101
|
"@rollup/plugin-json": "^4.1.0",
|
|
101
102
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
102
|
-
"@semantic-release/changelog": "6.0.
|
|
103
|
-
"@semantic-release/commit-analyzer": "
|
|
104
|
-
"@semantic-release/git": "10.0.1",
|
|
105
|
-
"@semantic-release/github": "
|
|
106
|
-
"@semantic-release/npm": "
|
|
107
|
-
"@semantic-release/release-notes-generator": "
|
|
103
|
+
"@semantic-release/changelog": "^6.0.3",
|
|
104
|
+
"@semantic-release/commit-analyzer": "^13.0.0",
|
|
105
|
+
"@semantic-release/git": "^10.0.1",
|
|
106
|
+
"@semantic-release/github": "^12.0.0",
|
|
107
|
+
"@semantic-release/npm": "^13.0.0",
|
|
108
|
+
"@semantic-release/release-notes-generator": "^14.0.0",
|
|
108
109
|
"@testing-library/jest-dom": "^6.9.1",
|
|
109
110
|
"@testing-library/react": "^16.3.1",
|
|
110
111
|
"@testing-library/user-event": "^14.6.1",
|
|
111
112
|
"@types/jest": "^30.0.0",
|
|
112
113
|
"@types/lodash": "4.14.182",
|
|
114
|
+
"@types/react": "^19.2.9",
|
|
115
|
+
"@types/react-dom": "^19.2.3",
|
|
116
|
+
"@types/react-redux": "^7.1.34",
|
|
113
117
|
"husky": "^8.0.0",
|
|
114
118
|
"identity-obj-proxy": "^3.0.0",
|
|
115
119
|
"jest": "^30.2.0",
|
|
@@ -125,7 +129,7 @@
|
|
|
125
129
|
"rimraf": "^3.0.2",
|
|
126
130
|
"rollup": "^2.74.1",
|
|
127
131
|
"rollup-plugin-terser": "^7.0.2",
|
|
128
|
-
"semantic-release": "
|
|
132
|
+
"semantic-release": "^25.0.0",
|
|
129
133
|
"ts-jest": "^29.4.6",
|
|
130
134
|
"typescript": "^4.7.2"
|
|
131
135
|
},
|
|
@@ -139,5 +143,6 @@
|
|
|
139
143
|
},
|
|
140
144
|
"publishConfig": {
|
|
141
145
|
"access": "public"
|
|
142
|
-
}
|
|
146
|
+
},
|
|
147
|
+
"packageManager": "pnpm@10.25.0"
|
|
143
148
|
}
|
package/CHANGELOG.md
DELETED