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.
@@ -0,0 +1,318 @@
1
+ import checkPropTypes from 'check-prop-types';
2
+
3
+ var index$2 = (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
+ function ownKeys(object, enumerableOnly) {
20
+ var keys = Object.keys(object);
21
+ if (Object.getOwnPropertySymbols) {
22
+ var symbols = Object.getOwnPropertySymbols(object);
23
+ enumerableOnly && (symbols = symbols.filter(function (sym) {
24
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
25
+ })), keys.push.apply(keys, symbols);
26
+ }
27
+ return keys;
28
+ }
29
+ function _objectSpread2(target) {
30
+ for (var i = 1; i < arguments.length; i++) {
31
+ var source = null != arguments[i] ? arguments[i] : {};
32
+ i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
33
+ _defineProperty(target, key, source[key]);
34
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
35
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
36
+ });
37
+ }
38
+ return target;
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 PERSISTENCE_KEY = "astroglide-persist";
179
+ var getPersistedStore = function getPersistedStore() {
180
+ var storage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : localStorage;
181
+ var result = storage.getItem(PERSISTENCE_KEY);
182
+ return JSON.parse(result || "{}");
183
+ };
184
+ var storePersistedValue = function storePersistedValue(key, namespace, value) {
185
+ var storage = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : localStorage;
186
+ var store = getPersistedStore(storage);
187
+ if (namespace) {
188
+ store[namespace] = store[namespace] || {};
189
+ store[namespace][key] = value;
190
+ } else {
191
+ store[key] = value;
192
+ }
193
+ try {
194
+ storage.setItem(PERSISTENCE_KEY, JSON.stringify(store));
195
+ } catch (e) {
196
+ console.error(e);
197
+ }
198
+ };
199
+ var getPersistedValue = function getPersistedValue(key, namespace) {
200
+ var _scope2;
201
+ var storage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : localStorage;
202
+ var scope = getPersistedStore(storage);
203
+ if (namespace) {
204
+ var _scope;
205
+ scope = (_scope = scope) === null || _scope === void 0 ? void 0 : _scope[namespace];
206
+ }
207
+ var retValue = (_scope2 = scope) === null || _scope2 === void 0 ? void 0 : _scope2[key];
208
+ console.log("retValue: ", retValue);
209
+ return retValue;
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 ? localStorage : _ref$storageType;
215
+ return {
216
+ setup: function setup(plugin, _ref2) {
217
+ var sliceConfig = _ref2.sliceConfig;
218
+ return {
219
+ namespace: sliceConfig.name,
220
+ storageType: storageType
221
+ };
222
+ },
223
+ getInitialValue: function getInitialValue(value, _ref3) {
224
+ var sliceConfig = _ref3.sliceConfig,
225
+ key = _ref3.key;
226
+ var existingPersistedValue = getPersistedValue(key, sliceConfig.name);
227
+ if (existingPersistedValue !== undefined) {
228
+ return existingPersistedValue;
229
+ }
230
+ return value;
231
+ },
232
+ update: function update(value, _ref4) {
233
+ var key = _ref4.key,
234
+ sliceConfig = _ref4.sliceConfig;
235
+ storePersistedValue(key, sliceConfig.name, value, this.config.storageType !== undefined ? this.config.storageType : storageType);
236
+ return value;
237
+ }
238
+ };
239
+ });
240
+
241
+ var plugin = function plugin(_ref) {
242
+ var constructorFn = _ref.constructor,
243
+ setup = _ref.setup,
244
+ getInitialValue = _ref.getInitialValue,
245
+ update = _ref.update,
246
+ _ref$config = _ref.config,
247
+ config = _ref$config === void 0 ? {} : _ref$config;
248
+ return /*#__PURE__*/function () {
249
+ function _class(value) {
250
+ _classCallCheck(this, _class);
251
+ this.value = value;
252
+ this.setup = setup || this.setup;
253
+ this.getInitialValue = getInitialValue || this.getInitialValue;
254
+ this.update = update || this.update;
255
+ this.config = config;
256
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
257
+ args[_key - 1] = arguments[_key];
258
+ }
259
+ constructorFn === null || constructorFn === void 0 ? void 0 : constructorFn.call.apply(constructorFn, [this, value].concat(args));
260
+ }
261
+ _createClass(_class, [{
262
+ key: "getValue",
263
+ value: function getValue() {
264
+ return this.value;
265
+ }
266
+ }, {
267
+ key: "setValue",
268
+ value: function setValue(value) {
269
+ this.value = value;
270
+ }
271
+ }, {
272
+ key: "setConfig",
273
+ value: function setConfig(config) {
274
+ this.config = _objectSpread2(_objectSpread2({}, this.config), config);
275
+ }
276
+ }, {
277
+ key: "setup",
278
+ value: function setup(item, _ref2) {
279
+ _objectDestructuringEmpty(_ref2);
280
+ return {
281
+ plugin: item
282
+ };
283
+ }
284
+ }, {
285
+ key: "getInitialValue",
286
+ value: function getInitialValue(value, _ref3) {
287
+ _objectDestructuringEmpty(_ref3);
288
+ return value;
289
+ }
290
+ }, {
291
+ key: "update",
292
+ value: function update(value, _ref4) {
293
+ _objectDestructuringEmpty(_ref4);
294
+ return value;
295
+ }
296
+ }]);
297
+ return _class;
298
+ }();
299
+ };
300
+ var addPlugin = function addPlugin(config) {
301
+ var Class = plugin(config);
302
+ plugins.push(Class);
303
+ return function () {
304
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
305
+ args[_key2] = arguments[_key2];
306
+ }
307
+ return _construct(Class, args);
308
+ };
309
+ };
310
+ var addPlugins = function addPlugins() {
311
+ for (var _len3 = arguments.length, configs = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
312
+ configs[_key3] = arguments[_key3];
313
+ }
314
+ return configs.map(addPlugin);
315
+ };
316
+ var plugins = [];
317
+
318
+ export { addPlugin, addPlugins, index as persist, plugins, index$2 as set, index$1 as type };
@@ -0,0 +1,331 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var checkPropTypes = require('check-prop-types');
6
+
7
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
+
9
+ var checkPropTypes__default = /*#__PURE__*/_interopDefaultLegacy(checkPropTypes);
10
+
11
+ var index$2 = (function (callback) {
12
+ return {
13
+ constructor: function constructor(callback, value) {
14
+ this.value = value;
15
+ this.callback = callback;
16
+ },
17
+ update: function update(value, _ref) {
18
+ var draft = _ref.draft,
19
+ plugin = _ref.plugin;
20
+ return plugin.callback(value, {
21
+ draft: draft
22
+ });
23
+ }
24
+ };
25
+ });
26
+
27
+ function ownKeys(object, enumerableOnly) {
28
+ var keys = Object.keys(object);
29
+ if (Object.getOwnPropertySymbols) {
30
+ var symbols = Object.getOwnPropertySymbols(object);
31
+ enumerableOnly && (symbols = symbols.filter(function (sym) {
32
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
33
+ })), keys.push.apply(keys, symbols);
34
+ }
35
+ return keys;
36
+ }
37
+ function _objectSpread2(target) {
38
+ for (var i = 1; i < arguments.length; i++) {
39
+ var source = null != arguments[i] ? arguments[i] : {};
40
+ i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
41
+ _defineProperty(target, key, source[key]);
42
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
43
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
44
+ });
45
+ }
46
+ return target;
47
+ }
48
+ function _classCallCheck(instance, Constructor) {
49
+ if (!(instance instanceof Constructor)) {
50
+ throw new TypeError("Cannot call a class as a function");
51
+ }
52
+ }
53
+ function _defineProperties(target, props) {
54
+ for (var i = 0; i < props.length; i++) {
55
+ var descriptor = props[i];
56
+ descriptor.enumerable = descriptor.enumerable || false;
57
+ descriptor.configurable = true;
58
+ if ("value" in descriptor) descriptor.writable = true;
59
+ Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
60
+ }
61
+ }
62
+ function _createClass(Constructor, protoProps, staticProps) {
63
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
64
+ if (staticProps) _defineProperties(Constructor, staticProps);
65
+ Object.defineProperty(Constructor, "prototype", {
66
+ writable: false
67
+ });
68
+ return Constructor;
69
+ }
70
+ function _defineProperty(obj, key, value) {
71
+ key = _toPropertyKey(key);
72
+ if (key in obj) {
73
+ Object.defineProperty(obj, key, {
74
+ value: value,
75
+ enumerable: true,
76
+ configurable: true,
77
+ writable: true
78
+ });
79
+ } else {
80
+ obj[key] = value;
81
+ }
82
+ return obj;
83
+ }
84
+ function _setPrototypeOf(o, p) {
85
+ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
86
+ o.__proto__ = p;
87
+ return o;
88
+ };
89
+ return _setPrototypeOf(o, p);
90
+ }
91
+ function _isNativeReflectConstruct() {
92
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
93
+ if (Reflect.construct.sham) return false;
94
+ if (typeof Proxy === "function") return true;
95
+ try {
96
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
97
+ return true;
98
+ } catch (e) {
99
+ return false;
100
+ }
101
+ }
102
+ function _construct(Parent, args, Class) {
103
+ if (_isNativeReflectConstruct()) {
104
+ _construct = Reflect.construct.bind();
105
+ } else {
106
+ _construct = function _construct(Parent, args, Class) {
107
+ var a = [null];
108
+ a.push.apply(a, args);
109
+ var Constructor = Function.bind.apply(Parent, a);
110
+ var instance = new Constructor();
111
+ if (Class) _setPrototypeOf(instance, Class.prototype);
112
+ return instance;
113
+ };
114
+ }
115
+ return _construct.apply(null, arguments);
116
+ }
117
+ function _objectDestructuringEmpty(obj) {
118
+ if (obj == null) throw new TypeError("Cannot destructure " + obj);
119
+ }
120
+ function _toPrimitive(input, hint) {
121
+ if (typeof input !== "object" || input === null) return input;
122
+ var prim = input[Symbol.toPrimitive];
123
+ if (prim !== undefined) {
124
+ var res = prim.call(input, hint || "default");
125
+ if (typeof res !== "object") return res;
126
+ throw new TypeError("@@toPrimitive must return a primitive value.");
127
+ }
128
+ return (hint === "string" ? String : Number)(input);
129
+ }
130
+ function _toPropertyKey(arg) {
131
+ var key = _toPrimitive(arg, "string");
132
+ return typeof key === "symbol" ? key : String(key);
133
+ }
134
+
135
+ var checkPropType = function checkPropType(propType, value, name) {
136
+ var extraProps = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
137
+ return checkPropTypes__default["default"](_defineProperty({}, name, propType), _objectSpread2(_objectSpread2({}, extraProps), {}, _defineProperty({}, name, value)), name, undefined);
138
+ };
139
+ var checkProp = function checkProp(propType, value, name) {
140
+ var shouldTypeErrorPreventUpdate = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
141
+ var result = checkPropType(propType, value, name);
142
+ if (result) {
143
+ var errorText = "Astroglide: prop ".concat(name, " with value ").concat(value, " is not of the specified type");
144
+ if (shouldTypeErrorPreventUpdate) {
145
+ throw Error(errorText);
146
+ } else {
147
+ console.warn(errorText);
148
+ }
149
+ return result;
150
+ }
151
+ return false;
152
+ };
153
+
154
+ var index$1 = (function () {
155
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
156
+ preventUpdate: false
157
+ },
158
+ preventUpdate = _ref.preventUpdate;
159
+ return {
160
+ constructor: function constructor(propType, value) {
161
+ var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
162
+ this.value = value; // value set here because constructor signature is different
163
+ this.propType = propType;
164
+ this.config = _objectSpread2(_objectSpread2({}, this.config), config);
165
+ },
166
+ getInitialValue: function getInitialValue(value, _ref2) {
167
+ var key = _ref2.key,
168
+ plugin = _ref2.plugin;
169
+ var propType = plugin.propType;
170
+ checkProp(propType, value, key);
171
+ return value;
172
+ },
173
+ update: function update(value, _ref3) {
174
+ var key = _ref3.key,
175
+ plugin = _ref3.plugin;
176
+ var propType = plugin.propType;
177
+ checkProp(propType, value, key, plugin.config.preventUpdate !== undefined ? plugin.config.preventUpdate : preventUpdate);
178
+ return value;
179
+ },
180
+ config: {
181
+ preventUpdate: false
182
+ }
183
+ };
184
+ });
185
+
186
+ var PERSISTENCE_KEY = "astroglide-persist";
187
+ var getPersistedStore = function getPersistedStore() {
188
+ var storage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : localStorage;
189
+ var result = storage.getItem(PERSISTENCE_KEY);
190
+ return JSON.parse(result || "{}");
191
+ };
192
+ var storePersistedValue = function storePersistedValue(key, namespace, value) {
193
+ var storage = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : localStorage;
194
+ var store = getPersistedStore(storage);
195
+ if (namespace) {
196
+ store[namespace] = store[namespace] || {};
197
+ store[namespace][key] = value;
198
+ } else {
199
+ store[key] = value;
200
+ }
201
+ try {
202
+ storage.setItem(PERSISTENCE_KEY, JSON.stringify(store));
203
+ } catch (e) {
204
+ console.error(e);
205
+ }
206
+ };
207
+ var getPersistedValue = function getPersistedValue(key, namespace) {
208
+ var _scope2;
209
+ var storage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : localStorage;
210
+ var scope = getPersistedStore(storage);
211
+ if (namespace) {
212
+ var _scope;
213
+ scope = (_scope = scope) === null || _scope === void 0 ? void 0 : _scope[namespace];
214
+ }
215
+ var retValue = (_scope2 = scope) === null || _scope2 === void 0 ? void 0 : _scope2[key];
216
+ console.log("retValue: ", retValue);
217
+ return retValue;
218
+ };
219
+ var index = (function () {
220
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
221
+ _ref$storageType = _ref.storageType,
222
+ storageType = _ref$storageType === void 0 ? localStorage : _ref$storageType;
223
+ return {
224
+ setup: function setup(plugin, _ref2) {
225
+ var sliceConfig = _ref2.sliceConfig;
226
+ return {
227
+ namespace: sliceConfig.name,
228
+ storageType: storageType
229
+ };
230
+ },
231
+ getInitialValue: function getInitialValue(value, _ref3) {
232
+ var sliceConfig = _ref3.sliceConfig,
233
+ key = _ref3.key;
234
+ var existingPersistedValue = getPersistedValue(key, sliceConfig.name);
235
+ if (existingPersistedValue !== undefined) {
236
+ return existingPersistedValue;
237
+ }
238
+ return value;
239
+ },
240
+ update: function update(value, _ref4) {
241
+ var key = _ref4.key,
242
+ sliceConfig = _ref4.sliceConfig;
243
+ storePersistedValue(key, sliceConfig.name, value, this.config.storageType !== undefined ? this.config.storageType : storageType);
244
+ return value;
245
+ }
246
+ };
247
+ });
248
+
249
+ var plugin = function plugin(_ref) {
250
+ var constructorFn = _ref.constructor,
251
+ setup = _ref.setup,
252
+ getInitialValue = _ref.getInitialValue,
253
+ update = _ref.update,
254
+ _ref$config = _ref.config,
255
+ config = _ref$config === void 0 ? {} : _ref$config;
256
+ return /*#__PURE__*/function () {
257
+ function _class(value) {
258
+ _classCallCheck(this, _class);
259
+ this.value = value;
260
+ this.setup = setup || this.setup;
261
+ this.getInitialValue = getInitialValue || this.getInitialValue;
262
+ this.update = update || this.update;
263
+ this.config = config;
264
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
265
+ args[_key - 1] = arguments[_key];
266
+ }
267
+ constructorFn === null || constructorFn === void 0 ? void 0 : constructorFn.call.apply(constructorFn, [this, value].concat(args));
268
+ }
269
+ _createClass(_class, [{
270
+ key: "getValue",
271
+ value: function getValue() {
272
+ return this.value;
273
+ }
274
+ }, {
275
+ key: "setValue",
276
+ value: function setValue(value) {
277
+ this.value = value;
278
+ }
279
+ }, {
280
+ key: "setConfig",
281
+ value: function setConfig(config) {
282
+ this.config = _objectSpread2(_objectSpread2({}, this.config), config);
283
+ }
284
+ }, {
285
+ key: "setup",
286
+ value: function setup(item, _ref2) {
287
+ _objectDestructuringEmpty(_ref2);
288
+ return {
289
+ plugin: item
290
+ };
291
+ }
292
+ }, {
293
+ key: "getInitialValue",
294
+ value: function getInitialValue(value, _ref3) {
295
+ _objectDestructuringEmpty(_ref3);
296
+ return value;
297
+ }
298
+ }, {
299
+ key: "update",
300
+ value: function update(value, _ref4) {
301
+ _objectDestructuringEmpty(_ref4);
302
+ return value;
303
+ }
304
+ }]);
305
+ return _class;
306
+ }();
307
+ };
308
+ var addPlugin = function addPlugin(config) {
309
+ var Class = plugin(config);
310
+ plugins.push(Class);
311
+ return function () {
312
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
313
+ args[_key2] = arguments[_key2];
314
+ }
315
+ return _construct(Class, args);
316
+ };
317
+ };
318
+ var addPlugins = function addPlugins() {
319
+ for (var _len3 = arguments.length, configs = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
320
+ configs[_key3] = arguments[_key3];
321
+ }
322
+ return configs.map(addPlugin);
323
+ };
324
+ var plugins = [];
325
+
326
+ exports.addPlugin = addPlugin;
327
+ exports.addPlugins = addPlugins;
328
+ exports.persist = index;
329
+ exports.plugins = plugins;
330
+ exports.set = index$2;
331
+ exports.type = index$1;