redux-astroglide 0.1.0
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/LICENSE +21 -0
- package/README.md +255 -0
- package/dist/index.es.js +3916 -0
- package/dist/index.js +3925 -0
- package/dist/index.umd.js +5983 -0
- package/dist/plugins/index.es.js +318 -0
- package/dist/plugins/index.js +331 -0
- package/dist/plugins/index.umd.js +415 -0
- package/dist/plugins/persist/index.es.js +64 -0
- package/dist/plugins/persist/index.js +71 -0
- package/dist/plugins/persist/index.umd.js +77 -0
- package/dist/plugins/set/index.es.js +17 -0
- package/dist/plugins/set/index.js +19 -0
- package/dist/plugins/set/index.umd.js +25 -0
- package/dist/plugins/type/index.es.js +104 -0
- package/dist/plugins/type/index.js +110 -0
- package/dist/plugins/type/index.umd.js +194 -0
- package/dist/types/actions.d.ts +3 -0
- package/dist/types/astroglide.d.ts +20 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/middleware.d.ts +1 -0
- package/dist/types/plugins/index.d.ts +4 -0
- package/dist/types/plugins/persist/index.d.ts +24 -0
- package/dist/types/plugins/service.d.ts +6 -0
- package/dist/types/plugins/set/index.d.ts +10 -0
- package/dist/types/plugins/type/index.d.ts +17 -0
- package/dist/types/plugins/type/types.d.ts +2 -0
- package/dist/types/reducers.d.ts +4 -0
- package/dist/types/selectors.d.ts +13 -0
- package/package.json +111 -0
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["redux-astroglide/plugins"] = {}));
|
|
5
|
+
})(this, (function (exports) { 'use strict';
|
|
6
|
+
|
|
7
|
+
var index$2 = (function (callback) {
|
|
8
|
+
return {
|
|
9
|
+
constructor: function constructor(callback, value) {
|
|
10
|
+
this.value = value;
|
|
11
|
+
this.callback = callback;
|
|
12
|
+
},
|
|
13
|
+
update: function update(value, _ref) {
|
|
14
|
+
var draft = _ref.draft,
|
|
15
|
+
plugin = _ref.plugin;
|
|
16
|
+
return plugin.callback(value, {
|
|
17
|
+
draft: draft
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
function ownKeys(object, enumerableOnly) {
|
|
24
|
+
var keys = Object.keys(object);
|
|
25
|
+
if (Object.getOwnPropertySymbols) {
|
|
26
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
27
|
+
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
28
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
29
|
+
})), keys.push.apply(keys, symbols);
|
|
30
|
+
}
|
|
31
|
+
return keys;
|
|
32
|
+
}
|
|
33
|
+
function _objectSpread2(target) {
|
|
34
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
35
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
36
|
+
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
37
|
+
_defineProperty(target, key, source[key]);
|
|
38
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
39
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return target;
|
|
43
|
+
}
|
|
44
|
+
function _classCallCheck(instance, Constructor) {
|
|
45
|
+
if (!(instance instanceof Constructor)) {
|
|
46
|
+
throw new TypeError("Cannot call a class as a function");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function _defineProperties(target, props) {
|
|
50
|
+
for (var i = 0; i < props.length; i++) {
|
|
51
|
+
var descriptor = props[i];
|
|
52
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
53
|
+
descriptor.configurable = true;
|
|
54
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
55
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
59
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
60
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
61
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
62
|
+
writable: false
|
|
63
|
+
});
|
|
64
|
+
return Constructor;
|
|
65
|
+
}
|
|
66
|
+
function _defineProperty(obj, key, value) {
|
|
67
|
+
key = _toPropertyKey(key);
|
|
68
|
+
if (key in obj) {
|
|
69
|
+
Object.defineProperty(obj, key, {
|
|
70
|
+
value: value,
|
|
71
|
+
enumerable: true,
|
|
72
|
+
configurable: true,
|
|
73
|
+
writable: true
|
|
74
|
+
});
|
|
75
|
+
} else {
|
|
76
|
+
obj[key] = value;
|
|
77
|
+
}
|
|
78
|
+
return obj;
|
|
79
|
+
}
|
|
80
|
+
function _setPrototypeOf(o, p) {
|
|
81
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
82
|
+
o.__proto__ = p;
|
|
83
|
+
return o;
|
|
84
|
+
};
|
|
85
|
+
return _setPrototypeOf(o, p);
|
|
86
|
+
}
|
|
87
|
+
function _isNativeReflectConstruct() {
|
|
88
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
89
|
+
if (Reflect.construct.sham) return false;
|
|
90
|
+
if (typeof Proxy === "function") return true;
|
|
91
|
+
try {
|
|
92
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
93
|
+
return true;
|
|
94
|
+
} catch (e) {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function _construct(Parent, args, Class) {
|
|
99
|
+
if (_isNativeReflectConstruct()) {
|
|
100
|
+
_construct = Reflect.construct.bind();
|
|
101
|
+
} else {
|
|
102
|
+
_construct = function _construct(Parent, args, Class) {
|
|
103
|
+
var a = [null];
|
|
104
|
+
a.push.apply(a, args);
|
|
105
|
+
var Constructor = Function.bind.apply(Parent, a);
|
|
106
|
+
var instance = new Constructor();
|
|
107
|
+
if (Class) _setPrototypeOf(instance, Class.prototype);
|
|
108
|
+
return instance;
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
return _construct.apply(null, arguments);
|
|
112
|
+
}
|
|
113
|
+
function _objectDestructuringEmpty(obj) {
|
|
114
|
+
if (obj == null) throw new TypeError("Cannot destructure " + obj);
|
|
115
|
+
}
|
|
116
|
+
function _toPrimitive(input, hint) {
|
|
117
|
+
if (typeof input !== "object" || input === null) return input;
|
|
118
|
+
var prim = input[Symbol.toPrimitive];
|
|
119
|
+
if (prim !== undefined) {
|
|
120
|
+
var res = prim.call(input, hint || "default");
|
|
121
|
+
if (typeof res !== "object") return res;
|
|
122
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
123
|
+
}
|
|
124
|
+
return (hint === "string" ? String : Number)(input);
|
|
125
|
+
}
|
|
126
|
+
function _toPropertyKey(arg) {
|
|
127
|
+
var key = _toPrimitive(arg, "string");
|
|
128
|
+
return typeof key === "symbol" ? key : String(key);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
var checkPropTypes$1 = {exports: {}};
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
135
|
+
*
|
|
136
|
+
* This source code is licensed under the MIT license found in the
|
|
137
|
+
* LICENSE file in the root directory of this source tree.
|
|
138
|
+
*/
|
|
139
|
+
var ReactPropTypesSecret_1;
|
|
140
|
+
var hasRequiredReactPropTypesSecret;
|
|
141
|
+
function requireReactPropTypesSecret() {
|
|
142
|
+
if (hasRequiredReactPropTypesSecret) return ReactPropTypesSecret_1;
|
|
143
|
+
hasRequiredReactPropTypesSecret = 1;
|
|
144
|
+
var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
|
145
|
+
ReactPropTypesSecret_1 = ReactPropTypesSecret;
|
|
146
|
+
return ReactPropTypesSecret_1;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Copyright Facebook, ratehub.
|
|
151
|
+
* All rights reserved.
|
|
152
|
+
*
|
|
153
|
+
* This code is intended to closely match the behaviour of checkPropTypes() from
|
|
154
|
+
* facebook/prop-types. The license for that code can be found here:
|
|
155
|
+
* https://github.com/facebook/prop-types/blob/be165febc8133dfbe2c45133db6d25664dd68ad8/LICENSE
|
|
156
|
+
*
|
|
157
|
+
* That function's source:
|
|
158
|
+
* https://github.com/facebook/prop-types/blob/be165febc8133dfbe2c45133db6d25664dd68ad8/checkPropTypes.js
|
|
159
|
+
*/
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Check if the values match with the type specs
|
|
163
|
+
* Return a type error message or null
|
|
164
|
+
*
|
|
165
|
+
* @param {object} typeSpecs Map of name to a ReactPropType
|
|
166
|
+
* @param {object} values Runtime values that need to be type-checked
|
|
167
|
+
* @param {string} location e.g. "prop", "context", "child context"
|
|
168
|
+
* @param {string} componentName Name of the component for error messages.
|
|
169
|
+
* @param {?Function} getStack Returns the component stack.
|
|
170
|
+
*/
|
|
171
|
+
function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
|
172
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
173
|
+
const ReactPropTypesSecret = requireReactPropTypesSecret();
|
|
174
|
+
var name = componentName || 'React class';
|
|
175
|
+
for (var typeSpecName in typeSpecs) {
|
|
176
|
+
if (typeSpecs.hasOwnProperty(typeSpecName)) {
|
|
177
|
+
var error;
|
|
178
|
+
if (typeof typeSpecs[typeSpecName] !== 'function') {
|
|
179
|
+
return name + ': ' + location + ' type `' + typeSpecName + '` is ' + 'invalid; it must be a function, usually from React.PropTypes.';
|
|
180
|
+
} else {
|
|
181
|
+
// Prop type validation may throw. In case they do, catch and save the
|
|
182
|
+
// exception as the error.
|
|
183
|
+
try {
|
|
184
|
+
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
|
|
185
|
+
} catch (ex) {
|
|
186
|
+
error = ex;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
if (error && !(error instanceof Error)) {
|
|
190
|
+
return name + ': type specification of ' + location + ' `' + typeSpecName + '` is invalid; the type checker function must ' + 'return `null` or an `Error` but returned a ' + typeof error + '. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).';
|
|
191
|
+
}
|
|
192
|
+
if (error instanceof Error) {
|
|
193
|
+
var stack = getStack && getStack() || '';
|
|
194
|
+
return 'Failed ' + location + ' type: ' + error.message + stack;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Same as checkPropTypes but throws on error
|
|
203
|
+
*/
|
|
204
|
+
function assertPropTypes() {
|
|
205
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
206
|
+
var error = checkPropTypes.apply(null, arguments);
|
|
207
|
+
if (error) {
|
|
208
|
+
throw new Error(error);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
checkPropTypes$1.exports = checkPropTypes;
|
|
213
|
+
checkPropTypes$1.exports.assertPropTypes = assertPropTypes;
|
|
214
|
+
|
|
215
|
+
var checkPropType = function checkPropType(propType, value, name) {
|
|
216
|
+
var extraProps = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
217
|
+
return checkPropTypes$1.exports(_defineProperty({}, name, propType), _objectSpread2(_objectSpread2({}, extraProps), {}, _defineProperty({}, name, value)), name, undefined);
|
|
218
|
+
};
|
|
219
|
+
var checkProp = function checkProp(propType, value, name) {
|
|
220
|
+
var shouldTypeErrorPreventUpdate = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
221
|
+
var result = checkPropType(propType, value, name);
|
|
222
|
+
if (result) {
|
|
223
|
+
var errorText = "Astroglide: prop ".concat(name, " with value ").concat(value, " is not of the specified type");
|
|
224
|
+
if (shouldTypeErrorPreventUpdate) {
|
|
225
|
+
throw Error(errorText);
|
|
226
|
+
} else {
|
|
227
|
+
console.warn(errorText);
|
|
228
|
+
}
|
|
229
|
+
return result;
|
|
230
|
+
}
|
|
231
|
+
return false;
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
var index$1 = (function () {
|
|
235
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
236
|
+
preventUpdate: false
|
|
237
|
+
},
|
|
238
|
+
preventUpdate = _ref.preventUpdate;
|
|
239
|
+
return {
|
|
240
|
+
constructor: function constructor(propType, value) {
|
|
241
|
+
var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
242
|
+
this.value = value; // value set here because constructor signature is different
|
|
243
|
+
this.propType = propType;
|
|
244
|
+
this.config = _objectSpread2(_objectSpread2({}, this.config), config);
|
|
245
|
+
},
|
|
246
|
+
getInitialValue: function getInitialValue(value, _ref2) {
|
|
247
|
+
var key = _ref2.key,
|
|
248
|
+
plugin = _ref2.plugin;
|
|
249
|
+
var propType = plugin.propType;
|
|
250
|
+
checkProp(propType, value, key);
|
|
251
|
+
return value;
|
|
252
|
+
},
|
|
253
|
+
update: function update(value, _ref3) {
|
|
254
|
+
var key = _ref3.key,
|
|
255
|
+
plugin = _ref3.plugin;
|
|
256
|
+
var propType = plugin.propType;
|
|
257
|
+
checkProp(propType, value, key, plugin.config.preventUpdate !== undefined ? plugin.config.preventUpdate : preventUpdate);
|
|
258
|
+
return value;
|
|
259
|
+
},
|
|
260
|
+
config: {
|
|
261
|
+
preventUpdate: false
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
var PERSISTENCE_KEY = "astroglide-persist";
|
|
267
|
+
var getPersistedStore = function getPersistedStore() {
|
|
268
|
+
var storage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : localStorage;
|
|
269
|
+
var result = storage.getItem(PERSISTENCE_KEY);
|
|
270
|
+
return JSON.parse(result || "{}");
|
|
271
|
+
};
|
|
272
|
+
var storePersistedValue = function storePersistedValue(key, namespace, value) {
|
|
273
|
+
var storage = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : localStorage;
|
|
274
|
+
var store = getPersistedStore(storage);
|
|
275
|
+
if (namespace) {
|
|
276
|
+
store[namespace] = store[namespace] || {};
|
|
277
|
+
store[namespace][key] = value;
|
|
278
|
+
} else {
|
|
279
|
+
store[key] = value;
|
|
280
|
+
}
|
|
281
|
+
try {
|
|
282
|
+
storage.setItem(PERSISTENCE_KEY, JSON.stringify(store));
|
|
283
|
+
} catch (e) {
|
|
284
|
+
console.error(e);
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
var getPersistedValue = function getPersistedValue(key, namespace) {
|
|
288
|
+
var _scope2;
|
|
289
|
+
var storage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : localStorage;
|
|
290
|
+
var scope = getPersistedStore(storage);
|
|
291
|
+
if (namespace) {
|
|
292
|
+
var _scope;
|
|
293
|
+
scope = (_scope = scope) === null || _scope === void 0 ? void 0 : _scope[namespace];
|
|
294
|
+
}
|
|
295
|
+
var retValue = (_scope2 = scope) === null || _scope2 === void 0 ? void 0 : _scope2[key];
|
|
296
|
+
console.log("retValue: ", retValue);
|
|
297
|
+
return retValue;
|
|
298
|
+
};
|
|
299
|
+
var index = (function () {
|
|
300
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
301
|
+
_ref$storageType = _ref.storageType,
|
|
302
|
+
storageType = _ref$storageType === void 0 ? localStorage : _ref$storageType;
|
|
303
|
+
return {
|
|
304
|
+
setup: function setup(plugin, _ref2) {
|
|
305
|
+
var sliceConfig = _ref2.sliceConfig;
|
|
306
|
+
return {
|
|
307
|
+
namespace: sliceConfig.name,
|
|
308
|
+
storageType: storageType
|
|
309
|
+
};
|
|
310
|
+
},
|
|
311
|
+
getInitialValue: function getInitialValue(value, _ref3) {
|
|
312
|
+
var sliceConfig = _ref3.sliceConfig,
|
|
313
|
+
key = _ref3.key;
|
|
314
|
+
var existingPersistedValue = getPersistedValue(key, sliceConfig.name);
|
|
315
|
+
if (existingPersistedValue !== undefined) {
|
|
316
|
+
return existingPersistedValue;
|
|
317
|
+
}
|
|
318
|
+
return value;
|
|
319
|
+
},
|
|
320
|
+
update: function update(value, _ref4) {
|
|
321
|
+
var key = _ref4.key,
|
|
322
|
+
sliceConfig = _ref4.sliceConfig;
|
|
323
|
+
storePersistedValue(key, sliceConfig.name, value, this.config.storageType !== undefined ? this.config.storageType : storageType);
|
|
324
|
+
return value;
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
var plugin = function plugin(_ref) {
|
|
330
|
+
var constructorFn = _ref.constructor,
|
|
331
|
+
setup = _ref.setup,
|
|
332
|
+
getInitialValue = _ref.getInitialValue,
|
|
333
|
+
update = _ref.update,
|
|
334
|
+
_ref$config = _ref.config,
|
|
335
|
+
config = _ref$config === void 0 ? {} : _ref$config;
|
|
336
|
+
return /*#__PURE__*/function () {
|
|
337
|
+
function _class(value) {
|
|
338
|
+
_classCallCheck(this, _class);
|
|
339
|
+
this.value = value;
|
|
340
|
+
this.setup = setup || this.setup;
|
|
341
|
+
this.getInitialValue = getInitialValue || this.getInitialValue;
|
|
342
|
+
this.update = update || this.update;
|
|
343
|
+
this.config = config;
|
|
344
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
345
|
+
args[_key - 1] = arguments[_key];
|
|
346
|
+
}
|
|
347
|
+
constructorFn === null || constructorFn === void 0 ? void 0 : constructorFn.call.apply(constructorFn, [this, value].concat(args));
|
|
348
|
+
}
|
|
349
|
+
_createClass(_class, [{
|
|
350
|
+
key: "getValue",
|
|
351
|
+
value: function getValue() {
|
|
352
|
+
return this.value;
|
|
353
|
+
}
|
|
354
|
+
}, {
|
|
355
|
+
key: "setValue",
|
|
356
|
+
value: function setValue(value) {
|
|
357
|
+
this.value = value;
|
|
358
|
+
}
|
|
359
|
+
}, {
|
|
360
|
+
key: "setConfig",
|
|
361
|
+
value: function setConfig(config) {
|
|
362
|
+
this.config = _objectSpread2(_objectSpread2({}, this.config), config);
|
|
363
|
+
}
|
|
364
|
+
}, {
|
|
365
|
+
key: "setup",
|
|
366
|
+
value: function setup(item, _ref2) {
|
|
367
|
+
_objectDestructuringEmpty(_ref2);
|
|
368
|
+
return {
|
|
369
|
+
plugin: item
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
}, {
|
|
373
|
+
key: "getInitialValue",
|
|
374
|
+
value: function getInitialValue(value, _ref3) {
|
|
375
|
+
_objectDestructuringEmpty(_ref3);
|
|
376
|
+
return value;
|
|
377
|
+
}
|
|
378
|
+
}, {
|
|
379
|
+
key: "update",
|
|
380
|
+
value: function update(value, _ref4) {
|
|
381
|
+
_objectDestructuringEmpty(_ref4);
|
|
382
|
+
return value;
|
|
383
|
+
}
|
|
384
|
+
}]);
|
|
385
|
+
return _class;
|
|
386
|
+
}();
|
|
387
|
+
};
|
|
388
|
+
var addPlugin = function addPlugin(config) {
|
|
389
|
+
var Class = plugin(config);
|
|
390
|
+
plugins.push(Class);
|
|
391
|
+
return function () {
|
|
392
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
393
|
+
args[_key2] = arguments[_key2];
|
|
394
|
+
}
|
|
395
|
+
return _construct(Class, args);
|
|
396
|
+
};
|
|
397
|
+
};
|
|
398
|
+
var addPlugins = function addPlugins() {
|
|
399
|
+
for (var _len3 = arguments.length, configs = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
400
|
+
configs[_key3] = arguments[_key3];
|
|
401
|
+
}
|
|
402
|
+
return configs.map(addPlugin);
|
|
403
|
+
};
|
|
404
|
+
var plugins = [];
|
|
405
|
+
|
|
406
|
+
exports.addPlugin = addPlugin;
|
|
407
|
+
exports.addPlugins = addPlugins;
|
|
408
|
+
exports.persist = index;
|
|
409
|
+
exports.plugins = plugins;
|
|
410
|
+
exports.set = index$2;
|
|
411
|
+
exports.type = index$1;
|
|
412
|
+
|
|
413
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
414
|
+
|
|
415
|
+
}));
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var PERSISTENCE_KEY = "astroglide-persist";
|
|
2
|
+
var getPersistedStore = function getPersistedStore() {
|
|
3
|
+
var storage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : localStorage;
|
|
4
|
+
var result = storage.getItem(PERSISTENCE_KEY);
|
|
5
|
+
return JSON.parse(result || "{}");
|
|
6
|
+
};
|
|
7
|
+
var storePersistedValue = function storePersistedValue(key, namespace, value) {
|
|
8
|
+
var storage = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : localStorage;
|
|
9
|
+
var store = getPersistedStore(storage);
|
|
10
|
+
if (namespace) {
|
|
11
|
+
store[namespace] = store[namespace] || {};
|
|
12
|
+
store[namespace][key] = value;
|
|
13
|
+
} else {
|
|
14
|
+
store[key] = value;
|
|
15
|
+
}
|
|
16
|
+
try {
|
|
17
|
+
storage.setItem(PERSISTENCE_KEY, JSON.stringify(store));
|
|
18
|
+
} catch (e) {
|
|
19
|
+
console.error(e);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
var getPersistedValue = function getPersistedValue(key, namespace) {
|
|
23
|
+
var _scope2;
|
|
24
|
+
var storage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : localStorage;
|
|
25
|
+
var scope = getPersistedStore(storage);
|
|
26
|
+
if (namespace) {
|
|
27
|
+
var _scope;
|
|
28
|
+
scope = (_scope = scope) === null || _scope === void 0 ? void 0 : _scope[namespace];
|
|
29
|
+
}
|
|
30
|
+
var retValue = (_scope2 = scope) === null || _scope2 === void 0 ? void 0 : _scope2[key];
|
|
31
|
+
console.log("retValue: ", retValue);
|
|
32
|
+
return retValue;
|
|
33
|
+
};
|
|
34
|
+
var index = (function () {
|
|
35
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
36
|
+
_ref$storageType = _ref.storageType,
|
|
37
|
+
storageType = _ref$storageType === void 0 ? localStorage : _ref$storageType;
|
|
38
|
+
return {
|
|
39
|
+
setup: function setup(plugin, _ref2) {
|
|
40
|
+
var sliceConfig = _ref2.sliceConfig;
|
|
41
|
+
return {
|
|
42
|
+
namespace: sliceConfig.name,
|
|
43
|
+
storageType: storageType
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
getInitialValue: function getInitialValue(value, _ref3) {
|
|
47
|
+
var sliceConfig = _ref3.sliceConfig,
|
|
48
|
+
key = _ref3.key;
|
|
49
|
+
var existingPersistedValue = getPersistedValue(key, sliceConfig.name);
|
|
50
|
+
if (existingPersistedValue !== undefined) {
|
|
51
|
+
return existingPersistedValue;
|
|
52
|
+
}
|
|
53
|
+
return value;
|
|
54
|
+
},
|
|
55
|
+
update: function update(value, _ref4) {
|
|
56
|
+
var key = _ref4.key,
|
|
57
|
+
sliceConfig = _ref4.sliceConfig;
|
|
58
|
+
storePersistedValue(key, sliceConfig.name, value, this.config.storageType !== undefined ? this.config.storageType : storageType);
|
|
59
|
+
return value;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
export { index as default, getPersistedStore, getPersistedValue, storePersistedValue };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var PERSISTENCE_KEY = "astroglide-persist";
|
|
6
|
+
var getPersistedStore = function getPersistedStore() {
|
|
7
|
+
var storage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : localStorage;
|
|
8
|
+
var result = storage.getItem(PERSISTENCE_KEY);
|
|
9
|
+
return JSON.parse(result || "{}");
|
|
10
|
+
};
|
|
11
|
+
var storePersistedValue = function storePersistedValue(key, namespace, value) {
|
|
12
|
+
var storage = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : localStorage;
|
|
13
|
+
var store = getPersistedStore(storage);
|
|
14
|
+
if (namespace) {
|
|
15
|
+
store[namespace] = store[namespace] || {};
|
|
16
|
+
store[namespace][key] = value;
|
|
17
|
+
} else {
|
|
18
|
+
store[key] = value;
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
storage.setItem(PERSISTENCE_KEY, JSON.stringify(store));
|
|
22
|
+
} catch (e) {
|
|
23
|
+
console.error(e);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
var getPersistedValue = function getPersistedValue(key, namespace) {
|
|
27
|
+
var _scope2;
|
|
28
|
+
var storage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : localStorage;
|
|
29
|
+
var scope = getPersistedStore(storage);
|
|
30
|
+
if (namespace) {
|
|
31
|
+
var _scope;
|
|
32
|
+
scope = (_scope = scope) === null || _scope === void 0 ? void 0 : _scope[namespace];
|
|
33
|
+
}
|
|
34
|
+
var retValue = (_scope2 = scope) === null || _scope2 === void 0 ? void 0 : _scope2[key];
|
|
35
|
+
console.log("retValue: ", retValue);
|
|
36
|
+
return retValue;
|
|
37
|
+
};
|
|
38
|
+
var index = (function () {
|
|
39
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
40
|
+
_ref$storageType = _ref.storageType,
|
|
41
|
+
storageType = _ref$storageType === void 0 ? localStorage : _ref$storageType;
|
|
42
|
+
return {
|
|
43
|
+
setup: function setup(plugin, _ref2) {
|
|
44
|
+
var sliceConfig = _ref2.sliceConfig;
|
|
45
|
+
return {
|
|
46
|
+
namespace: sliceConfig.name,
|
|
47
|
+
storageType: storageType
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
getInitialValue: function getInitialValue(value, _ref3) {
|
|
51
|
+
var sliceConfig = _ref3.sliceConfig,
|
|
52
|
+
key = _ref3.key;
|
|
53
|
+
var existingPersistedValue = getPersistedValue(key, sliceConfig.name);
|
|
54
|
+
if (existingPersistedValue !== undefined) {
|
|
55
|
+
return existingPersistedValue;
|
|
56
|
+
}
|
|
57
|
+
return value;
|
|
58
|
+
},
|
|
59
|
+
update: function update(value, _ref4) {
|
|
60
|
+
var key = _ref4.key,
|
|
61
|
+
sliceConfig = _ref4.sliceConfig;
|
|
62
|
+
storePersistedValue(key, sliceConfig.name, value, this.config.storageType !== undefined ? this.config.storageType : storageType);
|
|
63
|
+
return value;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
exports["default"] = index;
|
|
69
|
+
exports.getPersistedStore = getPersistedStore;
|
|
70
|
+
exports.getPersistedValue = getPersistedValue;
|
|
71
|
+
exports.storePersistedValue = storePersistedValue;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["redux-astroglide/plugins/persist"] = {}));
|
|
5
|
+
})(this, (function (exports) { 'use strict';
|
|
6
|
+
|
|
7
|
+
var PERSISTENCE_KEY = "astroglide-persist";
|
|
8
|
+
var getPersistedStore = function getPersistedStore() {
|
|
9
|
+
var storage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : localStorage;
|
|
10
|
+
var result = storage.getItem(PERSISTENCE_KEY);
|
|
11
|
+
return JSON.parse(result || "{}");
|
|
12
|
+
};
|
|
13
|
+
var storePersistedValue = function storePersistedValue(key, namespace, value) {
|
|
14
|
+
var storage = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : localStorage;
|
|
15
|
+
var store = getPersistedStore(storage);
|
|
16
|
+
if (namespace) {
|
|
17
|
+
store[namespace] = store[namespace] || {};
|
|
18
|
+
store[namespace][key] = value;
|
|
19
|
+
} else {
|
|
20
|
+
store[key] = value;
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
storage.setItem(PERSISTENCE_KEY, JSON.stringify(store));
|
|
24
|
+
} catch (e) {
|
|
25
|
+
console.error(e);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
var getPersistedValue = function getPersistedValue(key, namespace) {
|
|
29
|
+
var _scope2;
|
|
30
|
+
var storage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : localStorage;
|
|
31
|
+
var scope = getPersistedStore(storage);
|
|
32
|
+
if (namespace) {
|
|
33
|
+
var _scope;
|
|
34
|
+
scope = (_scope = scope) === null || _scope === void 0 ? void 0 : _scope[namespace];
|
|
35
|
+
}
|
|
36
|
+
var retValue = (_scope2 = scope) === null || _scope2 === void 0 ? void 0 : _scope2[key];
|
|
37
|
+
console.log("retValue: ", retValue);
|
|
38
|
+
return retValue;
|
|
39
|
+
};
|
|
40
|
+
var index = (function () {
|
|
41
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
42
|
+
_ref$storageType = _ref.storageType,
|
|
43
|
+
storageType = _ref$storageType === void 0 ? localStorage : _ref$storageType;
|
|
44
|
+
return {
|
|
45
|
+
setup: function setup(plugin, _ref2) {
|
|
46
|
+
var sliceConfig = _ref2.sliceConfig;
|
|
47
|
+
return {
|
|
48
|
+
namespace: sliceConfig.name,
|
|
49
|
+
storageType: storageType
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
getInitialValue: function getInitialValue(value, _ref3) {
|
|
53
|
+
var sliceConfig = _ref3.sliceConfig,
|
|
54
|
+
key = _ref3.key;
|
|
55
|
+
var existingPersistedValue = getPersistedValue(key, sliceConfig.name);
|
|
56
|
+
if (existingPersistedValue !== undefined) {
|
|
57
|
+
return existingPersistedValue;
|
|
58
|
+
}
|
|
59
|
+
return value;
|
|
60
|
+
},
|
|
61
|
+
update: function update(value, _ref4) {
|
|
62
|
+
var key = _ref4.key,
|
|
63
|
+
sliceConfig = _ref4.sliceConfig;
|
|
64
|
+
storePersistedValue(key, sliceConfig.name, value, this.config.storageType !== undefined ? this.config.storageType : storageType);
|
|
65
|
+
return value;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
exports["default"] = index;
|
|
71
|
+
exports.getPersistedStore = getPersistedStore;
|
|
72
|
+
exports.getPersistedValue = getPersistedValue;
|
|
73
|
+
exports.storePersistedValue = storePersistedValue;
|
|
74
|
+
|
|
75
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
76
|
+
|
|
77
|
+
}));
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var index = (function (callback) {
|
|
2
|
+
return {
|
|
3
|
+
constructor: function constructor(callback, value) {
|
|
4
|
+
this.value = value;
|
|
5
|
+
this.callback = callback;
|
|
6
|
+
},
|
|
7
|
+
update: function update(value, _ref) {
|
|
8
|
+
var draft = _ref.draft,
|
|
9
|
+
plugin = _ref.plugin;
|
|
10
|
+
return plugin.callback(value, {
|
|
11
|
+
draft: draft
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export { index as default };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = (function (callback) {
|
|
4
|
+
return {
|
|
5
|
+
constructor: function constructor(callback, value) {
|
|
6
|
+
this.value = value;
|
|
7
|
+
this.callback = 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
|
+
module.exports = index;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global["redux-astroglide/plugins/set"] = factory());
|
|
5
|
+
})(this, (function () { 'use strict';
|
|
6
|
+
|
|
7
|
+
var index = (function (callback) {
|
|
8
|
+
return {
|
|
9
|
+
constructor: function constructor(callback, value) {
|
|
10
|
+
this.value = value;
|
|
11
|
+
this.callback = callback;
|
|
12
|
+
},
|
|
13
|
+
update: function update(value, _ref) {
|
|
14
|
+
var draft = _ref.draft,
|
|
15
|
+
plugin = _ref.plugin;
|
|
16
|
+
return plugin.callback(value, {
|
|
17
|
+
draft: draft
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
return index;
|
|
24
|
+
|
|
25
|
+
}));
|