redux-astroglide 0.1.20 → 0.1.21
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/dist/index.es.js +101 -139
- package/dist/index.js +101 -139
- package/dist/index.umd.js +3058 -329
- package/dist/plugins/index.es.js +58 -84
- package/dist/plugins/index.js +58 -84
- package/dist/plugins/index.umd.js +58 -84
- package/dist/plugins/persist/index.es.js +3 -1
- package/dist/plugins/persist/index.js +3 -1
- package/dist/plugins/persist/index.umd.js +3 -1
- package/dist/plugins/type/index.es.js +18 -24
- package/dist/plugins/type/index.js +18 -24
- package/dist/plugins/type/index.umd.js +18 -24
- package/dist/selectors/index.es.js +58 -72
- package/dist/selectors/index.js +58 -72
- package/dist/selectors/index.umd.js +2841 -80
- package/dist/types/astroglide.d.ts +1 -1
- package/dist/types/plugins/persist/__tests__/persist.test.d.ts +1 -0
- package/dist/types/setupTests.d.ts +2 -0
- package/package.json +14 -2
- package/CHANGELOG.md +0 -4
- package/plugins/index.es.js +0 -325
- package/plugins/index.js +0 -338
- package/plugins/index.umd.js +0 -422
- package/plugins/persist/index.es.js +0 -69
- package/plugins/persist/index.js +0 -76
- package/plugins/persist/index.umd.js +0 -82
- package/plugins/set/index.es.js +0 -17
- package/plugins/set/index.js +0 -19
- package/plugins/set/index.umd.js +0 -25
- package/plugins/type/index.es.js +0 -104
- package/plugins/type/index.js +0 -110
- package/plugins/type/index.umd.js +0 -194
|
@@ -15,6 +15,6 @@ export declare const configure: ({ middleware, devTools, preloadedState, enhance
|
|
|
15
15
|
injectReducer: (key: any, asyncReducer: any) => void;
|
|
16
16
|
injectSlice: (slice: any) => void;
|
|
17
17
|
injectMiddleware: any;
|
|
18
|
-
store: import("@reduxjs/toolkit/dist/configureStore").ToolkitStore<any, import("
|
|
18
|
+
store: import("@reduxjs/toolkit/dist/configureStore").ToolkitStore<any, import("@reduxjs/toolkit").AnyAction, any[]>;
|
|
19
19
|
};
|
|
20
20
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "redux-astroglide",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.21",
|
|
4
4
|
"description": "Taking the pain out of redux state management",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"redux",
|
|
@@ -32,7 +32,10 @@
|
|
|
32
32
|
"build": "rimraf dist && npm run build:js && npm run build:types",
|
|
33
33
|
"build:js": "rollup -c",
|
|
34
34
|
"build:types": "tsc --emitDeclarationOnly",
|
|
35
|
-
"prepare": "husky install"
|
|
35
|
+
"prepare": "husky install",
|
|
36
|
+
"test": "jest",
|
|
37
|
+
"test:watch": "jest --watch",
|
|
38
|
+
"test:coverage": "jest --coverage"
|
|
36
39
|
},
|
|
37
40
|
"lint-staged": {
|
|
38
41
|
"*.{js,jsx,ts,tsx}": [
|
|
@@ -65,8 +68,16 @@
|
|
|
65
68
|
"@semantic-release/github": "8.0.4",
|
|
66
69
|
"@semantic-release/npm": "9.0.1",
|
|
67
70
|
"@semantic-release/release-notes-generator": "10.0.3",
|
|
71
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
72
|
+
"@testing-library/react": "^16.3.1",
|
|
73
|
+
"@testing-library/user-event": "^14.6.1",
|
|
74
|
+
"@types/jest": "^30.0.0",
|
|
68
75
|
"@types/lodash": "4.14.182",
|
|
69
76
|
"husky": "^8.0.0",
|
|
77
|
+
"identity-obj-proxy": "^3.0.0",
|
|
78
|
+
"jest": "^30.2.0",
|
|
79
|
+
"jest-environment-jsdom": "^30.2.0",
|
|
80
|
+
"jest-localstorage-mock": "^2.4.26",
|
|
70
81
|
"lint-staged": "^12.4.2",
|
|
71
82
|
"prettier": "^2.6.2",
|
|
72
83
|
"prop-types": "^15.8.1",
|
|
@@ -74,6 +85,7 @@
|
|
|
74
85
|
"rollup": "^2.74.1",
|
|
75
86
|
"rollup-plugin-terser": "^7.0.2",
|
|
76
87
|
"semantic-release": "19.0.3",
|
|
88
|
+
"ts-jest": "^29.4.6",
|
|
77
89
|
"typescript": "^4.7.2"
|
|
78
90
|
},
|
|
79
91
|
"peerDependencies": {
|
package/CHANGELOG.md
DELETED
package/plugins/index.es.js
DELETED
|
@@ -1,325 +0,0 @@
|
|
|
1
|
-
import checkPropTypes from 'check-prop-types';
|
|
2
|
-
|
|
3
|
-
var index$2 = (function (callback) {
|
|
4
|
-
return {
|
|
5
|
-
constructor: function constructor(innerCallback, value) {
|
|
6
|
-
this.value = value;
|
|
7
|
-
this.callback = innerCallback || callback;
|
|
8
|
-
},
|
|
9
|
-
update: function update(value, _ref) {
|
|
10
|
-
var draft = _ref.draft,
|
|
11
|
-
plugin = _ref.plugin;
|
|
12
|
-
return plugin.callback(value, {
|
|
13
|
-
draft: draft
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
function ownKeys(e, r) {
|
|
20
|
-
var t = Object.keys(e);
|
|
21
|
-
if (Object.getOwnPropertySymbols) {
|
|
22
|
-
var o = Object.getOwnPropertySymbols(e);
|
|
23
|
-
r && (o = o.filter(function (r) {
|
|
24
|
-
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
25
|
-
})), t.push.apply(t, o);
|
|
26
|
-
}
|
|
27
|
-
return t;
|
|
28
|
-
}
|
|
29
|
-
function _objectSpread2(e) {
|
|
30
|
-
for (var r = 1; r < arguments.length; r++) {
|
|
31
|
-
var t = null != arguments[r] ? arguments[r] : {};
|
|
32
|
-
r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
|
|
33
|
-
_defineProperty(e, r, t[r]);
|
|
34
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
35
|
-
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
return e;
|
|
39
|
-
}
|
|
40
|
-
function _classCallCheck(instance, Constructor) {
|
|
41
|
-
if (!(instance instanceof Constructor)) {
|
|
42
|
-
throw new TypeError("Cannot call a class as a function");
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
function _defineProperties(target, props) {
|
|
46
|
-
for (var i = 0; i < props.length; i++) {
|
|
47
|
-
var descriptor = props[i];
|
|
48
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
49
|
-
descriptor.configurable = true;
|
|
50
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
51
|
-
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
55
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
56
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
57
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
58
|
-
writable: false
|
|
59
|
-
});
|
|
60
|
-
return Constructor;
|
|
61
|
-
}
|
|
62
|
-
function _defineProperty(obj, key, value) {
|
|
63
|
-
key = _toPropertyKey(key);
|
|
64
|
-
if (key in obj) {
|
|
65
|
-
Object.defineProperty(obj, key, {
|
|
66
|
-
value: value,
|
|
67
|
-
enumerable: true,
|
|
68
|
-
configurable: true,
|
|
69
|
-
writable: true
|
|
70
|
-
});
|
|
71
|
-
} else {
|
|
72
|
-
obj[key] = value;
|
|
73
|
-
}
|
|
74
|
-
return obj;
|
|
75
|
-
}
|
|
76
|
-
function _setPrototypeOf(o, p) {
|
|
77
|
-
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
78
|
-
o.__proto__ = p;
|
|
79
|
-
return o;
|
|
80
|
-
};
|
|
81
|
-
return _setPrototypeOf(o, p);
|
|
82
|
-
}
|
|
83
|
-
function _isNativeReflectConstruct() {
|
|
84
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
85
|
-
if (Reflect.construct.sham) return false;
|
|
86
|
-
if (typeof Proxy === "function") return true;
|
|
87
|
-
try {
|
|
88
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
89
|
-
return true;
|
|
90
|
-
} catch (e) {
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
function _construct(Parent, args, Class) {
|
|
95
|
-
if (_isNativeReflectConstruct()) {
|
|
96
|
-
_construct = Reflect.construct.bind();
|
|
97
|
-
} else {
|
|
98
|
-
_construct = function _construct(Parent, args, Class) {
|
|
99
|
-
var a = [null];
|
|
100
|
-
a.push.apply(a, args);
|
|
101
|
-
var Constructor = Function.bind.apply(Parent, a);
|
|
102
|
-
var instance = new Constructor();
|
|
103
|
-
if (Class) _setPrototypeOf(instance, Class.prototype);
|
|
104
|
-
return instance;
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
return _construct.apply(null, arguments);
|
|
108
|
-
}
|
|
109
|
-
function _objectDestructuringEmpty(obj) {
|
|
110
|
-
if (obj == null) throw new TypeError("Cannot destructure " + obj);
|
|
111
|
-
}
|
|
112
|
-
function _toPrimitive(input, hint) {
|
|
113
|
-
if (typeof input !== "object" || input === null) return input;
|
|
114
|
-
var prim = input[Symbol.toPrimitive];
|
|
115
|
-
if (prim !== undefined) {
|
|
116
|
-
var res = prim.call(input, hint || "default");
|
|
117
|
-
if (typeof res !== "object") return res;
|
|
118
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
119
|
-
}
|
|
120
|
-
return (hint === "string" ? String : Number)(input);
|
|
121
|
-
}
|
|
122
|
-
function _toPropertyKey(arg) {
|
|
123
|
-
var key = _toPrimitive(arg, "string");
|
|
124
|
-
return typeof key === "symbol" ? key : String(key);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
var checkPropType = function checkPropType(propType, value, name) {
|
|
128
|
-
var extraProps = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
129
|
-
return checkPropTypes(_defineProperty({}, name, propType), _objectSpread2(_objectSpread2({}, extraProps), {}, _defineProperty({}, name, value)), name, undefined);
|
|
130
|
-
};
|
|
131
|
-
var checkProp = function checkProp(propType, value, name) {
|
|
132
|
-
var shouldTypeErrorPreventUpdate = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
133
|
-
var result = checkPropType(propType, value, name);
|
|
134
|
-
if (result) {
|
|
135
|
-
var errorText = "Astroglide: prop ".concat(name, " with value ").concat(value, " is not of the specified type");
|
|
136
|
-
if (shouldTypeErrorPreventUpdate) {
|
|
137
|
-
throw Error(errorText);
|
|
138
|
-
} else {
|
|
139
|
-
console.warn(errorText);
|
|
140
|
-
}
|
|
141
|
-
return result;
|
|
142
|
-
}
|
|
143
|
-
return false;
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
var index$1 = (function () {
|
|
147
|
-
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
148
|
-
preventUpdate: false
|
|
149
|
-
},
|
|
150
|
-
preventUpdate = _ref.preventUpdate;
|
|
151
|
-
return {
|
|
152
|
-
constructor: function constructor(propType, value) {
|
|
153
|
-
var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
154
|
-
this.value = value; // value set here because constructor signature is different
|
|
155
|
-
this.propType = propType;
|
|
156
|
-
this.config = _objectSpread2(_objectSpread2({}, this.config), config);
|
|
157
|
-
},
|
|
158
|
-
getInitialValue: function getInitialValue(value, _ref2) {
|
|
159
|
-
var key = _ref2.key,
|
|
160
|
-
plugin = _ref2.plugin;
|
|
161
|
-
var propType = plugin.propType;
|
|
162
|
-
checkProp(propType, value, key);
|
|
163
|
-
return value;
|
|
164
|
-
},
|
|
165
|
-
update: function update(value, _ref3) {
|
|
166
|
-
var key = _ref3.key,
|
|
167
|
-
plugin = _ref3.plugin;
|
|
168
|
-
var propType = plugin.propType;
|
|
169
|
-
checkProp(propType, value, key, plugin.config.preventUpdate !== undefined ? plugin.config.preventUpdate : preventUpdate);
|
|
170
|
-
return value;
|
|
171
|
-
},
|
|
172
|
-
config: {
|
|
173
|
-
preventUpdate: false
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
var localStorage = (window || {}).localStorage;
|
|
179
|
-
var isLocalStorageAvaialble = !!localStorage;
|
|
180
|
-
var PERSISTENCE_KEY = "astroglide-persist";
|
|
181
|
-
var defaultStorageType = localStorage;
|
|
182
|
-
var getPersistedStore = function getPersistedStore() {
|
|
183
|
-
var storage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultStorageType;
|
|
184
|
-
return JSON.parse(storage.getItem(PERSISTENCE_KEY) || "{}");
|
|
185
|
-
};
|
|
186
|
-
var storePersistedValue = function storePersistedValue(key, namespace, value) {
|
|
187
|
-
var storage = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : localStorage;
|
|
188
|
-
var store = getPersistedStore(storage);
|
|
189
|
-
if (namespace) {
|
|
190
|
-
store[namespace] = store[namespace] || {};
|
|
191
|
-
store[namespace][key] = value;
|
|
192
|
-
} else {
|
|
193
|
-
store[key] = value;
|
|
194
|
-
}
|
|
195
|
-
try {
|
|
196
|
-
storage.setItem(PERSISTENCE_KEY, JSON.stringify(store));
|
|
197
|
-
} catch (e) {
|
|
198
|
-
console.error(e);
|
|
199
|
-
}
|
|
200
|
-
};
|
|
201
|
-
var getPersistedValue = function getPersistedValue(key, namespace, _storage) {
|
|
202
|
-
var _scope2;
|
|
203
|
-
var storage = _storage || defaultStorageType;
|
|
204
|
-
var scope = getPersistedStore(storage);
|
|
205
|
-
if (namespace) {
|
|
206
|
-
var _scope;
|
|
207
|
-
scope = (_scope = scope) === null || _scope === void 0 ? void 0 : _scope[namespace];
|
|
208
|
-
}
|
|
209
|
-
return (_scope2 = scope) === null || _scope2 === void 0 ? void 0 : _scope2[key];
|
|
210
|
-
};
|
|
211
|
-
var index = (function () {
|
|
212
|
-
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
213
|
-
_ref$storageType = _ref.storageType,
|
|
214
|
-
storageType = _ref$storageType === void 0 ? defaultStorageType : _ref$storageType;
|
|
215
|
-
if (!isLocalStorageAvaialble && !storageType) {
|
|
216
|
-
console.warn("localStorage is not available! You must provide your own storage to persist"); // eslint-disable-line no-console
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
defaultStorageType = storageType;
|
|
220
|
-
return {
|
|
221
|
-
setup: function setup(plugin, _ref2) {
|
|
222
|
-
var sliceConfig = _ref2.sliceConfig;
|
|
223
|
-
return {
|
|
224
|
-
namespace: sliceConfig.name,
|
|
225
|
-
storageType: storageType
|
|
226
|
-
};
|
|
227
|
-
},
|
|
228
|
-
getInitialValue: function getInitialValue(value, _ref3) {
|
|
229
|
-
var sliceConfig = _ref3.sliceConfig,
|
|
230
|
-
key = _ref3.key;
|
|
231
|
-
var existingPersistedValue = getPersistedValue(key, sliceConfig.name, storageType);
|
|
232
|
-
if (existingPersistedValue !== undefined) {
|
|
233
|
-
return existingPersistedValue;
|
|
234
|
-
}
|
|
235
|
-
return value;
|
|
236
|
-
},
|
|
237
|
-
update: function update(value, _ref4) {
|
|
238
|
-
var key = _ref4.key,
|
|
239
|
-
sliceConfig = _ref4.sliceConfig;
|
|
240
|
-
storePersistedValue(key, sliceConfig.name, value, storageType !== undefined ? storageType : this.config.storageType || defaultStorageType);
|
|
241
|
-
return value;
|
|
242
|
-
}
|
|
243
|
-
};
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
var plugin = function plugin(_ref) {
|
|
247
|
-
var constructorFn = _ref.constructor,
|
|
248
|
-
setup = _ref.setup,
|
|
249
|
-
getInitialValue = _ref.getInitialValue,
|
|
250
|
-
update = _ref.update,
|
|
251
|
-
_ref$config = _ref.config,
|
|
252
|
-
config = _ref$config === void 0 ? {} : _ref$config;
|
|
253
|
-
return /*#__PURE__*/function () {
|
|
254
|
-
function _class(value) {
|
|
255
|
-
_classCallCheck(this, _class);
|
|
256
|
-
this.value = value;
|
|
257
|
-
this.setup = setup || this.setup;
|
|
258
|
-
this.getInitialValue = getInitialValue || this.getInitialValue;
|
|
259
|
-
this.update = update || this.update;
|
|
260
|
-
this.config = config;
|
|
261
|
-
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
262
|
-
args[_key - 1] = arguments[_key];
|
|
263
|
-
}
|
|
264
|
-
constructorFn === null || constructorFn === void 0 || constructorFn.call.apply(constructorFn, [this, value].concat(args));
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
// either the initial state value or the next plugin
|
|
268
|
-
_createClass(_class, [{
|
|
269
|
-
key: "getValue",
|
|
270
|
-
value: function getValue() {
|
|
271
|
-
return this.value;
|
|
272
|
-
}
|
|
273
|
-
}, {
|
|
274
|
-
key: "setValue",
|
|
275
|
-
value: function setValue(value) {
|
|
276
|
-
this.value = value;
|
|
277
|
-
}
|
|
278
|
-
}, {
|
|
279
|
-
key: "setConfig",
|
|
280
|
-
value: function setConfig(config) {
|
|
281
|
-
this.config = _objectSpread2(_objectSpread2({}, this.config), config);
|
|
282
|
-
}
|
|
283
|
-
}, {
|
|
284
|
-
key: "setup",
|
|
285
|
-
value: function setup(item, _ref2) {
|
|
286
|
-
_objectDestructuringEmpty(_ref2);
|
|
287
|
-
return {
|
|
288
|
-
plugin: item
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
}, {
|
|
292
|
-
key: "getInitialValue",
|
|
293
|
-
value: function getInitialValue(value, _ref3) {
|
|
294
|
-
_objectDestructuringEmpty(_ref3);
|
|
295
|
-
return value;
|
|
296
|
-
}
|
|
297
|
-
}, {
|
|
298
|
-
key: "update",
|
|
299
|
-
value: function update(value, _ref4) {
|
|
300
|
-
_objectDestructuringEmpty(_ref4);
|
|
301
|
-
return value;
|
|
302
|
-
}
|
|
303
|
-
}]);
|
|
304
|
-
return _class;
|
|
305
|
-
}();
|
|
306
|
-
};
|
|
307
|
-
var addPlugin = function addPlugin(config) {
|
|
308
|
-
var Class = plugin(config);
|
|
309
|
-
plugins.push(Class);
|
|
310
|
-
return function () {
|
|
311
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
312
|
-
args[_key2] = arguments[_key2];
|
|
313
|
-
}
|
|
314
|
-
return _construct(Class, args);
|
|
315
|
-
};
|
|
316
|
-
};
|
|
317
|
-
var addPlugins = function addPlugins() {
|
|
318
|
-
for (var _len3 = arguments.length, configs = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
319
|
-
configs[_key3] = arguments[_key3];
|
|
320
|
-
}
|
|
321
|
-
return configs.map(addPlugin);
|
|
322
|
-
};
|
|
323
|
-
var plugins = [];
|
|
324
|
-
|
|
325
|
-
export { addPlugin, addPlugins, index as persist, plugins, index$2 as set, index$1 as type };
|