redux-astroglide 0.1.2 → 0.1.4

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 CHANGED
@@ -1,7 +1,10 @@
1
1
  # Redux-Astroglide
2
2
 
3
- #### Squeezing a huge package into a tiny space
4
-  
3
+ #### Taking the pain out of state management by squeezing a huge package into a tiny API
4
+
5
+ Astroglide is a set of configuration and automation tools built on top of Redux Toolkit in order to provide the most succinct API with the least boilerplate possible. It's the easiest way to get up and running with redux state, and has the lowest mental overhead of any state management tool for React.
6
+
7
+ We stay DRY so you don't have to.
5
8
 
6
9
  ## Installation
7
10
 
@@ -15,13 +18,13 @@ npm install redux-astroglide
15
18
 
16
19
  # Yarn
17
20
  yarn add redux-astroglide
18
-
21
+
19
22
  # PNPM
20
23
  pnpm add redux-astroglide
21
24
 
22
25
  ```
23
-  
24
26
 
27
+  
25
28
 
26
29
  ## Setup
27
30
 
@@ -34,12 +37,11 @@ import configure from "redux-astroglide";
34
37
  const { store, createSlice } = configure({
35
38
  // ... (configureStore options
36
39
  });
37
-
38
40
  ```
39
-  
40
41
 
41
- [ Learn more about RTK's configureStore function ](https://redux-toolkit.js.org/usage/usage-with-typescript#configurestore)
42
+  
42
43
 
44
+ [Learn more about RTK's configureStore function](https://redux-toolkit.js.org/usage/usage-with-typescript#configurestore)
43
45
 
44
46
  Now just create a slice anywhere in your application and in addition to the actions created by Redux Toolkit you'll get some memoized selectors and hooks from Astroglide:
45
47
 
@@ -48,7 +50,8 @@ import { createSlice } from "../../app/store";
48
50
 
49
51
  const slice = createSlice(
50
52
  "LoginForm", // reducer namespace
51
- { // initial state
53
+ {
54
+ // initial state
52
55
  username: "",
53
56
  password: "",
54
57
  }
@@ -58,8 +61,8 @@ export const { setPassword, setUsername } = slice.actions;
58
61
  export const { selectUsername, selectPassword } = slice.selectors;
59
62
  export const { useUsername, usePassword } = slice.hooks;
60
63
  ```
61
-  
62
64
 
65
+  
63
66
 
64
67
  You can also create the slice using [the same API specified by RTK](https://redux-toolkit.js.org/usage/usage-with-typescript#createslice).
65
68
 
@@ -74,10 +77,10 @@ const slice = createSlice({
74
77
  // custom reducers are the most likely reason to use this syntax
75
78
  },
76
79
  // other RTK functionality can go here
77
- })
80
+ });
78
81
  ```
79
-  
80
82
 
83
+  
81
84
 
82
85
  ## Usage
83
86
 
@@ -87,15 +90,33 @@ These hooks can be used in a React component with the same API as React's setSta
87
90
  export const UsernameField = (props) => {
88
91
  const [username, setUsername] = useUsername();
89
92
 
90
- return <input
91
- name="username"
92
- type="text"
93
- value={username}
94
- onChange={e=> setUsername(e.target.value)} // this triggers a redux action
95
- />
96
- }
93
+ return (
94
+ <input
95
+ name="username"
96
+ type="text"
97
+ value={username}
98
+ onChange={(e) => setUsername(e.target.value)} // this triggers a redux action
99
+ />
100
+ );
101
+ };
97
102
  ```
98
- &nbsp;
103
+
104
+ &nbsp;
105
+
106
+ The setter actions can be passed a function to receive a copy of the latest state value, just like with React's setState:
107
+
108
+ ```jsx
109
+ <input
110
+ //...
111
+ onChange={(e) =>
112
+ setUsername((currentUsername) =>
113
+ isValid(e.target.value) ? e.target.value : currentUsername
114
+ )
115
+ }
116
+ />
117
+ ```
118
+
119
+ &nbsp;
99
120
 
100
121
  Astroglide's createSlice exposes global domain selectors and setters, if you need something like that:
101
122
 
@@ -108,51 +129,71 @@ export { useSlice } = slice.hooks;
108
129
  export { selectSlice } = slice.selectors;
109
130
  export { setSlice } = slice.actions; // will not conflict with existing `slice` prop actions
110
131
  ```
111
- &nbsp;
112
-
113
-
114
- The setter actions can be passed a function to receive a copy of the latest state value, just like with React's setState:
115
-
116
- ```jsx
117
- <input
118
- //...
119
- onChange={e => setUsername(currentUsername =>
120
- isValid(e.target.value) ? e.target.value : currentUsername
121
- )}
122
- />
123
- ```
124
- &nbsp;
125
132
 
133
+ &nbsp;
126
134
 
127
135
  The hooks can also be used outside of a React component (like in a thunk or saga) by destructuring the `select` and `update` props. This allows your reducer file to export as few variables as possible:
128
136
 
129
137
  ```jsx
130
138
  // thunk.js
131
139
  import { createAsyncThunk } from "@reduxjs/toolkit";
132
- import { useUsername, usePassword } from "./slice";
133
140
 
134
- const loginThunk = createAsyncThunk("login", async (
135
- args,
136
- { dispatch, getState }
137
- )=> {
141
+ import { useUsername, usePassword } from "./slice";
142
+ // OR
143
+ import {
144
+ selectUsername,
145
+ setUsername,
146
+ selectPassword,
147
+ setPassword,
148
+ } from "./slice";
149
+
150
+ const loginThunk = createAsyncThunk(
151
+ "login",
152
+ async (args, { dispatch, getState }) => {
138
153
  const username = useUsername.select(getState());
139
154
  const password = usePassword.select(getState());
140
155
  // logic ...
141
- dispatch(useUsername.update("newUsername"));
156
+ dispatch(useUsername.update("newUsername"));
142
157
  // ...
143
158
 
144
159
  // OR
145
160
 
146
- const username = selectUsername(getState)
147
- const password = selectPassword(getState)
161
+ const username = selectUsername(getState());
162
+ const password = selectPassword(getState());
148
163
  // logic ...
149
- dispatch(setUsername("newUsername"))
164
+ dispatch(setUsername("newUsername"));
150
165
  // ...
151
-
152
166
  }
153
- )
167
+ );
168
+
169
+ // saga.js
170
+ import { select, put } from "redux-saga/effects";
171
+
172
+ import { useUsername, usePassword } from "./slice";
173
+ // OR
174
+ import {
175
+ selectUsername,
176
+ setUsername,
177
+ selectPassword,
178
+ setPassword,
179
+ } from "./slice";
180
+
181
+ function* loginSaga(action) {
182
+ const username = yield select(useUsername.select);
183
+ const password = yield select(usePassword.select);
184
+ // logic ...
185
+ yield put(useUsername.update("newUsername"));
186
+
187
+ // OR
188
+
189
+ const username = yield select(selectUsername);
190
+ const password = yield select(selectPassword);
191
+ // logic ...
192
+ yield put(setUsername("newUsername"));
193
+ }
154
194
  ```
155
- &nbsp;
195
+
196
+ &nbsp;
156
197
 
157
198
  Astroglide also provides some of its internal helper functions you may find useful:
158
199
 
@@ -164,10 +205,11 @@ export const {
164
205
  createSlice,
165
206
  injectReducer,
166
207
  injectSlice,
167
- injectMiddleware
208
+ injectMiddleware,
168
209
  } = configure();
169
210
  ```
170
- &nbsp;
211
+
212
+ &nbsp;
171
213
 
172
214
  ## Plugins
173
215
 
@@ -177,21 +219,21 @@ Astroglide ships with a handful of plugins you can use for things like typecheck
177
219
  // Login/slice.js
178
220
  const slice = createSlice("Login", {
179
221
  username: type(PropType.string, ""),
180
- password: type(PropTypes.string, "", { shouldPreventUpdate: true })
222
+ password: type(PropTypes.string, "", { shouldPreventUpdate: true }),
181
223
  });
182
224
 
183
225
  // Nav/slice.js
184
226
  const slice = createSlice("Nav", {
185
- isOpen: type(PropTypes.bool, persist("", {
186
- storageType: localStorage
187
- })),
188
- clickCount: type(PropTypes.number, set((value) => value + 1)),
227
+ isOpen: persist("", {
228
+ storageType: localStorage,
229
+ }),
230
+ clickCount: set((value) => value + 1),
189
231
  });
190
232
  ```
191
- &nbsp;
192
233
 
193
- These plugins can be loaded by adding this to your Astroglide configuration:
234
+ &nbsp;
194
235
 
236
+ These plugins are loaded by adding this to your Astroglide configuration:
195
237
 
196
238
  ```jsx
197
239
  import configure, { addPlugins } from "redux-astroglide";
@@ -210,8 +252,30 @@ export const [set, type, persist] = addPlugins(
210
252
 
211
253
  export const { store, createSlice } = configure();
212
254
  ```
213
- &nbsp;
214
255
 
256
+ Plugins like persist also export their own tools:
257
+
258
+ ```ts
259
+ import {
260
+ getPersistedValue,
261
+ storePersistedValue,
262
+ } from "redux-astroglide/plugins/persist";
263
+
264
+ const currentValue = getPersistedValue(
265
+ "isOpen",
266
+ "Nav"
267
+ // storageType: localStorage | sessionStorage | { getItem, setItem }
268
+ );
269
+
270
+ storePersistedValue(
271
+ "isOpen",
272
+ "Nav",
273
+ true
274
+ // storageType: localStorage | sessionStorage { getItem, setItem }
275
+ );
276
+ ```
277
+
278
+ &nbsp;
215
279
 
216
280
  ## Custom Plugins
217
281
 
@@ -234,22 +298,23 @@ addPlugin({
234
298
  return value;
235
299
  },
236
300
  })
237
- // or
301
+ // or
238
302
  addPlugins({
239
303
  // plugin 1
240
304
  }, {
241
305
  // plugin 2
242
306
  })
243
-
307
+
244
308
  ```
245
- &nbsp;
309
+
310
+ &nbsp;
246
311
 
247
312
  ## Contributing
248
313
 
249
314
  Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
250
315
 
251
- &nbsp;
316
+ &nbsp;
317
+
252
318
  ## License
253
319
 
254
320
  [MIT](https://choosealicense.com/licenses/mit/)
255
-
@@ -1 +1 @@
1
- import t from"check-prop-types";var e=function(t){return{constructor:function(t,e){this.value=e,this.callback=t},update:function(t,e){var n=e.draft;return e.plugin.callback(t,{draft:n})}}};function n(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function r(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?n(Object(r),!0).forEach((function(e){i(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function o(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,l(r.key),r)}}function i(t,e,n){return(e=l(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function u(t,e){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},u(t,e)}function a(t,e,n){return a=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,n){var r=[null];r.push.apply(r,e);var o=new(Function.bind.apply(t,r));return n&&u(o,n.prototype),o},a.apply(null,arguments)}function c(t){if(null==t)throw new TypeError("Cannot destructure "+t)}function l(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}var f=function(e,n,o){var u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return t(i({},o,e),r(r({},u),{},i({},o,n)),o,void 0)},p=function(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],o=f(t,e,n);if(o){var i="Astroglide: prop ".concat(n," with value ").concat(e," is not of the specified type");if(r)throw Error(i);return console.warn(i),o}return!1},s=function(){var t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{preventUpdate:!1}).preventUpdate;return{constructor:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.value=e,this.propType=t,this.config=r(r({},this.config),n)},getInitialValue:function(t,e){var n=e.key,r=e.plugin.propType;return p(r,t,n),t},update:function(e,n){var r=n.key,o=n.plugin,i=o.propType;return p(i,e,r,void 0!==o.config.preventUpdate?o.config.preventUpdate:t),e},config:{preventUpdate:!1}}},v="astroglide-persist",g=function(){var t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:localStorage).getItem(v);return JSON.parse(t||"{}")},y=function(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:localStorage,o=g(r);e?(o[e]=o[e]||{},o[e][t]=n):o[t]=n;try{r.setItem(v,JSON.stringify(o))}catch(t){console.error(t)}},h=function(t,e){var n,r,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:localStorage,i=g(o);e&&(i=null===(r=i)||void 0===r?void 0:r[e]);var u=null===(n=i)||void 0===n?void 0:n[t];return console.log("retValue: ",u),u},d=function(){var t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).storageType,e=void 0===t?localStorage:t;return{setup:function(t,n){return{namespace:n.sliceConfig.name,storageType:e}},getInitialValue:function(t,e){var n=e.sliceConfig,r=e.key,o=h(r,n.name);return void 0!==o?o:t},update:function(t,n){var r=n.key,o=n.sliceConfig;return y(r,o.name,t,void 0!==this.config.storageType?this.config.storageType:e),t}}},b=function(t){var e=t.constructor,n=t.setup,i=t.getInitialValue,u=t.update,a=t.config,l=void 0===a?{}:a;return function(){function t(r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.value=r,this.setup=n||this.setup,this.getInitialValue=i||this.getInitialValue,this.update=u||this.update,this.config=l;for(var o=arguments.length,a=new Array(o>1?o-1:0),c=1;c<o;c++)a[c-1]=arguments[c];null==e||e.call.apply(e,[this,r].concat(a))}var a,f,p;return a=t,f=[{key:"getValue",value:function(){return this.value}},{key:"setValue",value:function(t){this.value=t}},{key:"setConfig",value:function(t){this.config=r(r({},this.config),t)}},{key:"setup",value:function(t,e){return c(e),{plugin:t}}},{key:"getInitialValue",value:function(t,e){return c(e),t}},{key:"update",value:function(t,e){return c(e),t}}],f&&o(a.prototype,f),p&&o(a,p),Object.defineProperty(a,"prototype",{writable:!1}),t}()},O=function(t){var e=b(t);return w.push(e),function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return a(e,n)}},m=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return e.map(O)},w=[];export{O as addPlugin,m as addPlugins,d as persist,w as plugins,e as set,s as type};
1
+ import t from"check-prop-types";var e=function(t){return{constructor:function(t,e){this.value=e,this.callback=t},update:function(t,e){var n=e.draft;return e.plugin.callback(t,{draft:n})}}};function n(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function r(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?n(Object(r),!0).forEach((function(e){i(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function o(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,l(r.key),r)}}function i(t,e,n){return(e=l(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function u(t,e){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},u(t,e)}function a(t,e,n){return a=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,n){var r=[null];r.push.apply(r,e);var o=new(Function.bind.apply(t,r));return n&&u(o,n.prototype),o},a.apply(null,arguments)}function c(t){if(null==t)throw new TypeError("Cannot destructure "+t)}function l(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}var f=function(e,n,o){var u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return t(i({},o,e),r(r({},u),{},i({},o,n)),o,void 0)},p=function(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],o=f(t,e,n);if(o){var i="Astroglide: prop ".concat(n," with value ").concat(e," is not of the specified type");if(r)throw Error(i);return console.warn(i),o}return!1},s=function(){var t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{preventUpdate:!1}).preventUpdate;return{constructor:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.value=e,this.propType=t,this.config=r(r({},this.config),n)},getInitialValue:function(t,e){var n=e.key,r=e.plugin.propType;return p(r,t,n),t},update:function(e,n){var r=n.key,o=n.plugin,i=o.propType;return p(i,e,r,void 0!==o.config.preventUpdate?o.config.preventUpdate:t),e},config:{preventUpdate:!1}}},v="astroglide-persist",g=function(){var t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:localStorage).getItem(v);return JSON.parse(t||"{}")},y=function(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:localStorage,o=g(r);e?(o[e]=o[e]||{},o[e][t]=n):o[t]=n;try{r.setItem(v,JSON.stringify(o))}catch(t){console.error(t)}},h=function(t,e){var n,r,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:localStorage,i=g(o);e&&(i=null===(r=i)||void 0===r?void 0:r[e]);return null===(n=i)||void 0===n?void 0:n[t]},d=function(){var t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).storageType,e=void 0===t?localStorage:t;return{setup:function(t,n){return{namespace:n.sliceConfig.name,storageType:e}},getInitialValue:function(t,e){var n=e.sliceConfig,r=e.key,o=h(r,n.name);return void 0!==o?o:t},update:function(t,n){var r=n.key,o=n.sliceConfig;return y(r,o.name,t,void 0!==this.config.storageType?this.config.storageType:e),t}}},b=function(t){var e=t.constructor,n=t.setup,i=t.getInitialValue,u=t.update,a=t.config,l=void 0===a?{}:a;return function(){function t(r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.value=r,this.setup=n||this.setup,this.getInitialValue=i||this.getInitialValue,this.update=u||this.update,this.config=l;for(var o=arguments.length,a=new Array(o>1?o-1:0),c=1;c<o;c++)a[c-1]=arguments[c];null==e||e.call.apply(e,[this,r].concat(a))}var a,f,p;return a=t,f=[{key:"getValue",value:function(){return this.value}},{key:"setValue",value:function(t){this.value=t}},{key:"setConfig",value:function(t){this.config=r(r({},this.config),t)}},{key:"setup",value:function(t,e){return c(e),{plugin:t}}},{key:"getInitialValue",value:function(t,e){return c(e),t}},{key:"update",value:function(t,e){return c(e),t}}],f&&o(a.prototype,f),p&&o(a,p),Object.defineProperty(a,"prototype",{writable:!1}),t}()},O=function(t){var e=b(t);return w.push(e),function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return a(e,n)}},m=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return e.map(O)},w=[];export{O as addPlugin,m as addPlugins,d as persist,w as plugins,e as set,s as type};
@@ -1 +1 @@
1
- "use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}Object.defineProperty(exports,"__esModule",{value:!0});var e=t(require("check-prop-types"));function r(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function n(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?r(Object(n),!0).forEach((function(e){i(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function o(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,l(n.key),n)}}function i(t,e,r){return(e=l(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function u(t,e){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},u(t,e)}function a(t,e,r){return a=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&u(o,r.prototype),o},a.apply(null,arguments)}function c(t){if(null==t)throw new TypeError("Cannot destructure "+t)}function l(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}var f=function(t,r,o){var u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return e.default(i({},o,t),n(n({},u),{},i({},o,r)),o,void 0)},p=function(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],o=f(t,e,r);if(o){var i="Astroglide: prop ".concat(r," with value ").concat(e," is not of the specified type");if(n)throw Error(i);return console.warn(i),o}return!1},s="astroglide-persist",v=function(){var t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:localStorage).getItem(s);return JSON.parse(t||"{}")},g=function(t,e,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:localStorage,o=v(n);e?(o[e]=o[e]||{},o[e][t]=r):o[t]=r;try{n.setItem(s,JSON.stringify(o))}catch(t){console.error(t)}},y=function(t,e){var r,n,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:localStorage,i=v(o);e&&(i=null===(n=i)||void 0===n?void 0:n[e]);var u=null===(r=i)||void 0===r?void 0:r[t];return console.log("retValue: ",u),u},d=function(t){var e=t.constructor,r=t.setup,i=t.getInitialValue,u=t.update,a=t.config,l=void 0===a?{}:a;return function(){function t(n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.value=n,this.setup=r||this.setup,this.getInitialValue=i||this.getInitialValue,this.update=u||this.update,this.config=l;for(var o=arguments.length,a=new Array(o>1?o-1:0),c=1;c<o;c++)a[c-1]=arguments[c];null==e||e.call.apply(e,[this,n].concat(a))}var a,f,p;return a=t,f=[{key:"getValue",value:function(){return this.value}},{key:"setValue",value:function(t){this.value=t}},{key:"setConfig",value:function(t){this.config=n(n({},this.config),t)}},{key:"setup",value:function(t,e){return c(e),{plugin:t}}},{key:"getInitialValue",value:function(t,e){return c(e),t}},{key:"update",value:function(t,e){return c(e),t}}],f&&o(a.prototype,f),p&&o(a,p),Object.defineProperty(a,"prototype",{writable:!1}),t}()},h=function(t){var e=d(t);return b.push(e),function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return a(e,r)}},b=[];exports.addPlugin=h,exports.addPlugins=function(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return e.map(h)},exports.persist=function(){var t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).storageType,e=void 0===t?localStorage:t;return{setup:function(t,r){return{namespace:r.sliceConfig.name,storageType:e}},getInitialValue:function(t,e){var r=e.sliceConfig,n=e.key,o=y(n,r.name);return void 0!==o?o:t},update:function(t,r){var n=r.key,o=r.sliceConfig;return g(n,o.name,t,void 0!==this.config.storageType?this.config.storageType:e),t}}},exports.plugins=b,exports.set=function(t){return{constructor:function(t,e){this.value=e,this.callback=t},update:function(t,e){var r=e.draft;return e.plugin.callback(t,{draft:r})}}},exports.type=function(){var t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{preventUpdate:!1}).preventUpdate;return{constructor:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.value=e,this.propType=t,this.config=n(n({},this.config),r)},getInitialValue:function(t,e){var r=e.key,n=e.plugin.propType;return p(n,t,r),t},update:function(e,r){var n=r.key,o=r.plugin,i=o.propType;return p(i,e,n,void 0!==o.config.preventUpdate?o.config.preventUpdate:t),e},config:{preventUpdate:!1}}};
1
+ "use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}Object.defineProperty(exports,"__esModule",{value:!0});var e=t(require("check-prop-types"));function n(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function r(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?n(Object(r),!0).forEach((function(e){i(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function o(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,l(r.key),r)}}function i(t,e,n){return(e=l(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function u(t,e){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},u(t,e)}function a(t,e,n){return a=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}()?Reflect.construct.bind():function(t,e,n){var r=[null];r.push.apply(r,e);var o=new(Function.bind.apply(t,r));return n&&u(o,n.prototype),o},a.apply(null,arguments)}function c(t){if(null==t)throw new TypeError("Cannot destructure "+t)}function l(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}var f=function(t,n,o){var u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return e.default(i({},o,t),r(r({},u),{},i({},o,n)),o,void 0)},p=function(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],o=f(t,e,n);if(o){var i="Astroglide: prop ".concat(n," with value ").concat(e," is not of the specified type");if(r)throw Error(i);return console.warn(i),o}return!1},s="astroglide-persist",v=function(){var t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:localStorage).getItem(s);return JSON.parse(t||"{}")},g=function(t,e,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:localStorage,o=v(r);e?(o[e]=o[e]||{},o[e][t]=n):o[t]=n;try{r.setItem(s,JSON.stringify(o))}catch(t){console.error(t)}},y=function(t,e){var n,r,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:localStorage,i=v(o);e&&(i=null===(r=i)||void 0===r?void 0:r[e]);return null===(n=i)||void 0===n?void 0:n[t]},d=function(t){var e=t.constructor,n=t.setup,i=t.getInitialValue,u=t.update,a=t.config,l=void 0===a?{}:a;return function(){function t(r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.value=r,this.setup=n||this.setup,this.getInitialValue=i||this.getInitialValue,this.update=u||this.update,this.config=l;for(var o=arguments.length,a=new Array(o>1?o-1:0),c=1;c<o;c++)a[c-1]=arguments[c];null==e||e.call.apply(e,[this,r].concat(a))}var a,f,p;return a=t,f=[{key:"getValue",value:function(){return this.value}},{key:"setValue",value:function(t){this.value=t}},{key:"setConfig",value:function(t){this.config=r(r({},this.config),t)}},{key:"setup",value:function(t,e){return c(e),{plugin:t}}},{key:"getInitialValue",value:function(t,e){return c(e),t}},{key:"update",value:function(t,e){return c(e),t}}],f&&o(a.prototype,f),p&&o(a,p),Object.defineProperty(a,"prototype",{writable:!1}),t}()},h=function(t){var e=d(t);return b.push(e),function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return a(e,n)}},b=[];exports.addPlugin=h,exports.addPlugins=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return e.map(h)},exports.persist=function(){var t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).storageType,e=void 0===t?localStorage:t;return{setup:function(t,n){return{namespace:n.sliceConfig.name,storageType:e}},getInitialValue:function(t,e){var n=e.sliceConfig,r=e.key,o=y(r,n.name);return void 0!==o?o:t},update:function(t,n){var r=n.key,o=n.sliceConfig;return g(r,o.name,t,void 0!==this.config.storageType?this.config.storageType:e),t}}},exports.plugins=b,exports.set=function(t){return{constructor:function(t,e){this.value=e,this.callback=t},update:function(t,e){var n=e.draft;return e.plugin.callback(t,{draft:n})}}},exports.type=function(){var t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{preventUpdate:!1}).preventUpdate;return{constructor:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.value=e,this.propType=t,this.config=r(r({},this.config),n)},getInitialValue:function(t,e){var n=e.key,r=e.plugin.propType;return p(r,t,n),t},update:function(e,n){var r=n.key,o=n.plugin,i=o.propType;return p(i,e,r,void 0!==o.config.preventUpdate?o.config.preventUpdate:t),e},config:{preventUpdate:!1}}};
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["redux-astroglide/plugins"]={})}(this,(function(e){"use strict";function t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function n(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?t(Object(r),!0).forEach((function(t){o(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):t(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,c(r.key),r)}}function o(e,t,n){return(t=c(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},i(e,t)}function u(e,t,n){return u=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}()?Reflect.construct.bind():function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&i(o,n.prototype),o},u.apply(null,arguments)}function a(e){if(null==e)throw new TypeError("Cannot destructure "+e)}function c(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}var f,l,p={exports:{}};function s(e,t,n,r,o){if("production"!==process.env.NODE_ENV){const p=l?f:(l=1,f="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");var i=r||"React class";for(var u in e)if(e.hasOwnProperty(u)){var a;if("function"!=typeof e[u])return i+": "+n+" type `"+u+"` is invalid; it must be a function, usually from React.PropTypes.";try{a=e[u](t,u,r,n,null,p)}catch(e){a=e}if(a&&!(a instanceof Error))return i+": type specification of "+n+" `"+u+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof a+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).";if(a instanceof Error){var c=o&&o()||"";return"Failed "+n+" type: "+a.message+c}}}}p.exports=s,p.exports.assertPropTypes=function(){if("production"!==process.env.NODE_ENV){var e=s.apply(null,arguments);if(e)throw new Error(e)}};var v=function(e,t,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return p.exports(o({},r,e),n(n({},i),{},o({},r,t)),r,void 0)},y=function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],o=v(e,t,n);if(o){var i="Astroglide: prop ".concat(n," with value ").concat(t," is not of the specified type");if(r)throw Error(i);return console.warn(i),o}return!1},g="astroglide-persist",d=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:localStorage).getItem(g);return JSON.parse(e||"{}")},h=function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:localStorage,o=d(r);t?(o[t]=o[t]||{},o[t][e]=n):o[e]=n;try{r.setItem(g,JSON.stringify(o))}catch(e){console.error(e)}},b=function(e,t){var n,r,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:localStorage,i=d(o);t&&(i=null===(r=i)||void 0===r?void 0:r[t]);var u=null===(n=i)||void 0===n?void 0:n[e];return console.log("retValue: ",u),u},O=function(e){var t=e.constructor,o=e.setup,i=e.getInitialValue,u=e.update,c=e.config,f=void 0===c?{}:c;return function(){function e(n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.value=n,this.setup=o||this.setup,this.getInitialValue=i||this.getInitialValue,this.update=u||this.update,this.config=f;for(var r=arguments.length,a=new Array(r>1?r-1:0),c=1;c<r;c++)a[c-1]=arguments[c];null==t||t.call.apply(t,[this,n].concat(a))}var c,l,p;return c=e,l=[{key:"getValue",value:function(){return this.value}},{key:"setValue",value:function(e){this.value=e}},{key:"setConfig",value:function(e){this.config=n(n({},this.config),e)}},{key:"setup",value:function(e,t){return a(t),{plugin:e}}},{key:"getInitialValue",value:function(e,t){return a(t),e}},{key:"update",value:function(e,t){return a(t),e}}],l&&r(c.prototype,l),p&&r(c,p),Object.defineProperty(c,"prototype",{writable:!1}),e}()},m=function(e){var t=O(e);return w.push(t),function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return u(t,n)}},w=[];e.addPlugin=m,e.addPlugins=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.map(m)},e.persist=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).storageType,t=void 0===e?localStorage:e;return{setup:function(e,n){return{namespace:n.sliceConfig.name,storageType:t}},getInitialValue:function(e,t){var n=t.sliceConfig,r=t.key,o=b(r,n.name);return void 0!==o?o:e},update:function(e,n){var r=n.key,o=n.sliceConfig;return h(r,o.name,e,void 0!==this.config.storageType?this.config.storageType:t),e}}},e.plugins=w,e.set=function(e){return{constructor:function(e,t){this.value=t,this.callback=e},update:function(e,t){var n=t.draft;return t.plugin.callback(e,{draft:n})}}},e.type=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{preventUpdate:!1}).preventUpdate;return{constructor:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.value=t,this.propType=e,this.config=n(n({},this.config),r)},getInitialValue:function(e,t){var n=t.key,r=t.plugin.propType;return y(r,e,n),e},update:function(t,n){var r=n.key,o=n.plugin,i=o.propType;return y(i,t,r,void 0!==o.config.preventUpdate?o.config.preventUpdate:e),t},config:{preventUpdate:!1}}},Object.defineProperty(e,"__esModule",{value:!0})}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["redux-astroglide/plugins"]={})}(this,(function(e){"use strict";function t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function n(e){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?t(Object(r),!0).forEach((function(t){o(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):t(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,c(r.key),r)}}function o(e,t,n){return(t=c(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},i(e,t)}function u(e,t,n){return u=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}()?Reflect.construct.bind():function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&i(o,n.prototype),o},u.apply(null,arguments)}function a(e){if(null==e)throw new TypeError("Cannot destructure "+e)}function c(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}var f,l,p={exports:{}};function s(e,t,n,r,o){if("production"!==process.env.NODE_ENV){const p=l?f:(l=1,f="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");var i=r||"React class";for(var u in e)if(e.hasOwnProperty(u)){var a;if("function"!=typeof e[u])return i+": "+n+" type `"+u+"` is invalid; it must be a function, usually from React.PropTypes.";try{a=e[u](t,u,r,n,null,p)}catch(e){a=e}if(a&&!(a instanceof Error))return i+": type specification of "+n+" `"+u+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof a+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).";if(a instanceof Error){var c=o&&o()||"";return"Failed "+n+" type: "+a.message+c}}}}p.exports=s,p.exports.assertPropTypes=function(){if("production"!==process.env.NODE_ENV){var e=s.apply(null,arguments);if(e)throw new Error(e)}};var v=function(e,t,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return p.exports(o({},r,e),n(n({},i),{},o({},r,t)),r,void 0)},y=function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],o=v(e,t,n);if(o){var i="Astroglide: prop ".concat(n," with value ").concat(t," is not of the specified type");if(r)throw Error(i);return console.warn(i),o}return!1},g="astroglide-persist",d=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:localStorage).getItem(g);return JSON.parse(e||"{}")},h=function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:localStorage,o=d(r);t?(o[t]=o[t]||{},o[t][e]=n):o[e]=n;try{r.setItem(g,JSON.stringify(o))}catch(e){console.error(e)}},b=function(e,t){var n,r,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:localStorage,i=d(o);t&&(i=null===(r=i)||void 0===r?void 0:r[t]);return null===(n=i)||void 0===n?void 0:n[e]},O=function(e){var t=e.constructor,o=e.setup,i=e.getInitialValue,u=e.update,c=e.config,f=void 0===c?{}:c;return function(){function e(n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.value=n,this.setup=o||this.setup,this.getInitialValue=i||this.getInitialValue,this.update=u||this.update,this.config=f;for(var r=arguments.length,a=new Array(r>1?r-1:0),c=1;c<r;c++)a[c-1]=arguments[c];null==t||t.call.apply(t,[this,n].concat(a))}var c,l,p;return c=e,l=[{key:"getValue",value:function(){return this.value}},{key:"setValue",value:function(e){this.value=e}},{key:"setConfig",value:function(e){this.config=n(n({},this.config),e)}},{key:"setup",value:function(e,t){return a(t),{plugin:e}}},{key:"getInitialValue",value:function(e,t){return a(t),e}},{key:"update",value:function(e,t){return a(t),e}}],l&&r(c.prototype,l),p&&r(c,p),Object.defineProperty(c,"prototype",{writable:!1}),e}()},m=function(e){var t=O(e);return w.push(t),function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return u(t,n)}},w=[];e.addPlugin=m,e.addPlugins=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.map(m)},e.persist=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).storageType,t=void 0===e?localStorage:e;return{setup:function(e,n){return{namespace:n.sliceConfig.name,storageType:t}},getInitialValue:function(e,t){var n=t.sliceConfig,r=t.key,o=b(r,n.name);return void 0!==o?o:e},update:function(e,n){var r=n.key,o=n.sliceConfig;return h(r,o.name,e,void 0!==this.config.storageType?this.config.storageType:t),e}}},e.plugins=w,e.set=function(e){return{constructor:function(e,t){this.value=t,this.callback=e},update:function(e,t){var n=t.draft;return t.plugin.callback(e,{draft:n})}}},e.type=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{preventUpdate:!1}).preventUpdate;return{constructor:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.value=t,this.propType=e,this.config=n(n({},this.config),r)},getInitialValue:function(e,t){var n=t.key,r=t.plugin.propType;return y(r,e,n),e},update:function(t,n){var r=n.key,o=n.plugin,i=o.propType;return y(i,t,r,void 0!==o.config.preventUpdate?o.config.preventUpdate:e),t},config:{preventUpdate:!1}}},Object.defineProperty(e,"__esModule",{value:!0})}));
@@ -1 +1 @@
1
- var e="astroglide-persist",o=function(){var o=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:localStorage).getItem(e);return JSON.parse(o||"{}")},t=function(t,n,r){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:localStorage,i=o(a);n?(i[n]=i[n]||{},i[n][t]=r):i[t]=r;try{a.setItem(e,JSON.stringify(i))}catch(e){console.error(e)}},n=function(e,t){var n,r,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:localStorage,i=o(a);t&&(i=null===(r=i)||void 0===r?void 0:r[t]);var l=null===(n=i)||void 0===n?void 0:n[e];return console.log("retValue: ",l),l},r=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).storageType,o=void 0===e?localStorage:e;return{setup:function(e,t){return{namespace:t.sliceConfig.name,storageType:o}},getInitialValue:function(e,o){var t=o.sliceConfig,r=o.key,a=n(r,t.name);return void 0!==a?a:e},update:function(e,n){var r=n.key,a=n.sliceConfig;return t(r,a.name,e,void 0!==this.config.storageType?this.config.storageType:o),e}}};export{r as default,o as getPersistedStore,n as getPersistedValue,t as storePersistedValue};
1
+ var e="astroglide-persist",t=function(){var t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:localStorage).getItem(e);return JSON.parse(t||"{}")},o=function(o,n,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:localStorage,a=t(i);n?(a[n]=a[n]||{},a[n][o]=r):a[o]=r;try{i.setItem(e,JSON.stringify(a))}catch(e){console.error(e)}},n=function(e,o){var n,r,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:localStorage,a=t(i);o&&(a=null===(r=a)||void 0===r?void 0:r[o]);return null===(n=a)||void 0===n?void 0:n[e]},r=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).storageType,t=void 0===e?localStorage:e;return{setup:function(e,o){return{namespace:o.sliceConfig.name,storageType:t}},getInitialValue:function(e,t){var o=t.sliceConfig,r=t.key,i=n(r,o.name);return void 0!==i?i:e},update:function(e,n){var r=n.key,i=n.sliceConfig;return o(r,i.name,e,void 0!==this.config.storageType?this.config.storageType:t),e}}};export{r as default,t as getPersistedStore,n as getPersistedValue,o as storePersistedValue};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e="astroglide-persist",t=function(){var t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:localStorage).getItem(e);return JSON.parse(t||"{}")},o=function(o,r,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:localStorage,a=t(i);r?(a[r]=a[r]||{},a[r][o]=n):a[o]=n;try{i.setItem(e,JSON.stringify(a))}catch(e){console.error(e)}},r=function(e,o){var r,n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:localStorage,a=t(i);o&&(a=null===(n=a)||void 0===n?void 0:n[o]);var s=null===(r=a)||void 0===r?void 0:r[e];return console.log("retValue: ",s),s};exports.default=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).storageType,t=void 0===e?localStorage:e;return{setup:function(e,o){return{namespace:o.sliceConfig.name,storageType:t}},getInitialValue:function(e,t){var o=t.sliceConfig,n=t.key,i=r(n,o.name);return void 0!==i?i:e},update:function(e,r){var n=r.key,i=r.sliceConfig;return o(n,i.name,e,void 0!==this.config.storageType?this.config.storageType:t),e}}},exports.getPersistedStore=t,exports.getPersistedValue=r,exports.storePersistedValue=o;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e="astroglide-persist",t=function(){var t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:localStorage).getItem(e);return JSON.parse(t||"{}")},o=function(o,r,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:localStorage,a=t(n);r?(a[r]=a[r]||{},a[r][o]=i):a[o]=i;try{n.setItem(e,JSON.stringify(a))}catch(e){console.error(e)}},r=function(e,o){var r,i,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:localStorage,a=t(n);o&&(a=null===(i=a)||void 0===i?void 0:i[o]);return null===(r=a)||void 0===r?void 0:r[e]};exports.default=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).storageType,t=void 0===e?localStorage:e;return{setup:function(e,o){return{namespace:o.sliceConfig.name,storageType:t}},getInitialValue:function(e,t){var o=t.sliceConfig,i=t.key,n=r(i,o.name);return void 0!==n?n:e},update:function(e,r){var i=r.key,n=r.sliceConfig;return o(i,n.name,e,void 0!==this.config.storageType?this.config.storageType:t),e}}},exports.getPersistedStore=t,exports.getPersistedValue=r,exports.storePersistedValue=o;
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["redux-astroglide/plugins/persist"]={})}(this,(function(e){"use strict";var t="astroglide-persist",o=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:localStorage).getItem(t);return JSON.parse(e||"{}")},n=function(e,n,i){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:localStorage,a=o(r);n?(a[n]=a[n]||{},a[n][e]=i):a[e]=i;try{r.setItem(t,JSON.stringify(a))}catch(e){console.error(e)}},i=function(e,t){var n,i,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:localStorage,a=o(r);t&&(a=null===(i=a)||void 0===i?void 0:i[t]);var s=null===(n=a)||void 0===n?void 0:n[e];return console.log("retValue: ",s),s};e.default=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).storageType,t=void 0===e?localStorage:e;return{setup:function(e,o){return{namespace:o.sliceConfig.name,storageType:t}},getInitialValue:function(e,t){var o=t.sliceConfig,n=t.key,r=i(n,o.name);return void 0!==r?r:e},update:function(e,o){var i=o.key,r=o.sliceConfig;return n(i,r.name,e,void 0!==this.config.storageType?this.config.storageType:t),e}}},e.getPersistedStore=o,e.getPersistedValue=i,e.storePersistedValue=n,Object.defineProperty(e,"__esModule",{value:!0})}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["redux-astroglide/plugins/persist"]={})}(this,(function(e){"use strict";var t="astroglide-persist",o=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:localStorage).getItem(t);return JSON.parse(e||"{}")},i=function(e,i,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:localStorage,s=o(r);i?(s[i]=s[i]||{},s[i][e]=n):s[e]=n;try{r.setItem(t,JSON.stringify(s))}catch(e){console.error(e)}},n=function(e,t){var i,n,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:localStorage,s=o(r);t&&(s=null===(n=s)||void 0===n?void 0:n[t]);return null===(i=s)||void 0===i?void 0:i[e]};e.default=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).storageType,t=void 0===e?localStorage:e;return{setup:function(e,o){return{namespace:o.sliceConfig.name,storageType:t}},getInitialValue:function(e,t){var o=t.sliceConfig,i=t.key,r=n(i,o.name);return void 0!==r?r:e},update:function(e,o){var n=o.key,r=o.sliceConfig;return i(n,r.name,e,void 0!==this.config.storageType?this.config.storageType:t),e}}},e.getPersistedStore=o,e.getPersistedValue=n,e.storePersistedValue=i,Object.defineProperty(e,"__esModule",{value:!0})}));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "redux-astroglide",
3
- "version": "0.1.2",
4
- "description": "Taking the pain out of redux state",
3
+ "version": "0.1.4",
4
+ "description": "Taking the pain out of redux state management",
5
5
  "keywords": [
6
6
  "boilerplate",
7
7
  "library",
@@ -66,7 +66,6 @@
66
66
  "@babel/core": "^7.18.2",
67
67
  "@babel/preset-env": "^7.18.2",
68
68
  "@babel/preset-typescript": "^7.17.12",
69
- "@commitlint/cli": "17.0.3",
70
69
  "@commitlint/config-conventional": "17.0.3",
71
70
  "@reduxjs/toolkit": "^1.9.2",
72
71
  "@rollup/plugin-babel": "5.3.1",
@@ -105,7 +104,6 @@
105
104
  "dev": "BUILD_ENV=dev npm run build:js -- --watch",
106
105
  "build": "rimraf dist && npm run build:types && npm run build:js",
107
106
  "build:js": "rollup -c",
108
- "build:types": "tsc --emitDeclarationOnly",
109
- "preinstall": "npx only-allow pnpm"
107
+ "build:types": "tsc --emitDeclarationOnly"
110
108
  }
111
109
  }