react-native-global-state-hooks 7.1.0 → 8.0.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/GlobalStore.d.ts +29 -0
- package/GlobalStore.js +1 -0
- package/GlobalStoreAbstract.d.ts +9 -0
- package/GlobalStoreAbstract.js +1 -0
- package/README.md +78 -125
- package/asyncStorageWrapper.d.ts +8 -0
- package/asyncStorageWrapper.js +1 -0
- package/bundle.js +1 -0
- package/combineRetrieverAsynchronously.d.ts +1 -0
- package/combineRetrieverAsynchronously.js +1 -0
- package/combineRetrieverEmitterAsynchronously.d.ts +1 -0
- package/combineRetrieverEmitterAsynchronously.js +1 -0
- package/createContext.d.ts +1 -0
- package/createContext.js +1 -0
- package/createCustomGlobalState.d.ts +22 -0
- package/createCustomGlobalState.js +1 -0
- package/createGlobalState.d.ts +20 -0
- package/createGlobalState.js +1 -0
- package/debounce.d.ts +1 -0
- package/debounce.js +1 -0
- package/getAsyncStorageItem.d.ts +2 -0
- package/getAsyncStorageItem.js +1 -0
- package/index.d.ts +23 -0
- package/isRecord.d.ts +1 -0
- package/isRecord.js +1 -0
- package/package.json +94 -8
- package/setAsyncStorageItem.d.ts +2 -0
- package/setAsyncStorageItem.js +1 -0
- package/shallowCompare.d.ts +1 -0
- package/shallowCompare.js +1 -0
- package/throwWrongKeyOnActionCollectionConfig.d.ts +1 -0
- package/throwWrongKeyOnActionCollectionConfig.js +1 -0
- package/types.d.ts +83 -0
- package/types.js +1 -0
- package/uniqueId.d.ts +1 -0
- package/uniqueId.js +1 -0
- package/uniqueSymbol.d.ts +1 -0
- package/uniqueSymbol.js +1 -0
- package/useConstantValueRef.d.ts +1 -0
- package/useConstantValueRef.js +1 -0
- package/webpack.config.js +89 -0
- package/lib/bundle.js +0 -2
- package/lib/bundle.js.LICENSE.txt +0 -1
- package/lib/src/GlobalStore.context.d.ts +0 -6
- package/lib/src/GlobalStore.d.ts +0 -31
- package/lib/src/GlobalStore.functionHooks.d.ts +0 -19
- package/lib/src/GlobalStore.types.d.ts +0 -124
- package/lib/src/GlobalStore.utils.d.ts +0 -16
- package/lib/src/GlobalStoreAbstract.d.ts +0 -16
- package/lib/src/index.d.ts +0 -12
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ The best part? [react-hooks-global-states](https://www.npmjs.com/package/react-h
|
|
|
23
23
|
We are gonna create a global state hook **useCount** with one line of code.
|
|
24
24
|
|
|
25
25
|
```ts
|
|
26
|
-
import { createGlobalState } from "react-native-global-state-hooks";
|
|
26
|
+
import { createGlobalState } from "react-native-global-state-hooks/createGlobalState";
|
|
27
27
|
|
|
28
28
|
export const useCount = createGlobalState(0);
|
|
29
29
|
```
|
|
@@ -118,8 +118,7 @@ Okay, everything works when the changes come from the state, but what happens if
|
|
|
118
118
|
const [filter, setFilter] = useState("");
|
|
119
119
|
|
|
120
120
|
const [contacts] = useContacts(
|
|
121
|
-
(state) =>
|
|
122
|
-
[...state.entities.values()].filter((item) => item.name.includes(filter)),
|
|
121
|
+
(state) => [...state.entities.values()].filter((item) => item.name.includes(filter)),
|
|
123
122
|
{
|
|
124
123
|
isEqualRoot: (a, b) => a.entities === b.entities,
|
|
125
124
|
/**
|
|
@@ -140,12 +139,9 @@ export const useContacts = createGlobalState({
|
|
|
140
139
|
selected: Set<number>,
|
|
141
140
|
});
|
|
142
141
|
|
|
143
|
-
const useContactsArray = useContacts.createSelectorHook(
|
|
144
|
-
(
|
|
145
|
-
|
|
146
|
-
isEqualRoot: (a, b) => a.entities === b.entities,
|
|
147
|
-
}
|
|
148
|
-
);
|
|
142
|
+
const useContactsArray = useContacts.createSelectorHook((state) => [...state.entities.values()], {
|
|
143
|
+
isEqualRoot: (a, b) => a.entities === b.entities,
|
|
144
|
+
});
|
|
149
145
|
```
|
|
150
146
|
|
|
151
147
|
Now inside your component just call the new hook
|
|
@@ -155,39 +151,28 @@ Now inside your component just call the new hook
|
|
|
155
151
|
```tsx
|
|
156
152
|
const [filter, setFilter] = useState("");
|
|
157
153
|
|
|
158
|
-
const [contacts] = useContactsArray(
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
dependencies: [filter],
|
|
162
|
-
}
|
|
163
|
-
);
|
|
154
|
+
const [contacts] = useContactsArray((entities) => entities.name.includes(filter), {
|
|
155
|
+
dependencies: [filter],
|
|
156
|
+
});
|
|
164
157
|
```
|
|
165
158
|
|
|
166
159
|
Or you can create another selectorHook from your **useContactsArray**
|
|
167
160
|
|
|
168
161
|
```ts
|
|
169
|
-
const useContactsArray = useContacts.createSelectorHook(
|
|
170
|
-
(
|
|
171
|
-
|
|
172
|
-
isEqualRoot: (a, b) => a.entities === b.entities,
|
|
173
|
-
}
|
|
174
|
-
);
|
|
162
|
+
const useContactsArray = useContacts.createSelectorHook((state) => [...state.entities.values()], {
|
|
163
|
+
isEqualRoot: (a, b) => a.entities === b.entities,
|
|
164
|
+
});
|
|
175
165
|
|
|
176
|
-
const useContactsLength = useContactsArray.createSelectorHook(
|
|
177
|
-
(entities) => entities.length
|
|
178
|
-
);
|
|
166
|
+
const useContactsLength = useContactsArray.createSelectorHook((entities) => entities.length);
|
|
179
167
|
```
|
|
180
168
|
|
|
181
169
|
Or you can create a custom hook
|
|
182
170
|
|
|
183
171
|
```tsx
|
|
184
172
|
const useFilteredContacts = (filter: string) => {
|
|
185
|
-
const [contacts] = useContactsArray(
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
dependencies: [filter],
|
|
189
|
-
}
|
|
190
|
-
);
|
|
173
|
+
const [contacts] = useContactsArray((entities) => entities.name.includes(filter), {
|
|
174
|
+
dependencies: [filter],
|
|
175
|
+
});
|
|
191
176
|
|
|
192
177
|
return contacts;
|
|
193
178
|
};
|
|
@@ -198,31 +183,28 @@ To summarize
|
|
|
198
183
|
```tsx
|
|
199
184
|
const [filter, setFilter] = useState("");
|
|
200
185
|
|
|
201
|
-
const [contacts] = useContacts(
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
*/
|
|
209
|
-
isEqualRoot: (r1, r2) => r1.filter === r2.filter,
|
|
186
|
+
const [contacts] = useContacts((state) => state.contacts.filter((contact) => contact.name.includes(filter)), {
|
|
187
|
+
/**
|
|
188
|
+
* You can use the `isEqualRoot` to validate if the values before the selector are equal.
|
|
189
|
+
* This validation will run before `isEqual` and if the result is true the selector will not be recomputed.
|
|
190
|
+
* If the result is true the re-render of the component will be prevented.
|
|
191
|
+
*/
|
|
192
|
+
isEqualRoot: (r1, r2) => r1.filter === r2.filter,
|
|
210
193
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
194
|
+
/**
|
|
195
|
+
* You can use the `isEqual` to validate if the values after the selector are equal.
|
|
196
|
+
* This validation will run after the selector computed a new value...
|
|
197
|
+
* and if the result is true it will prevent the re-render of the component.
|
|
198
|
+
*/
|
|
199
|
+
isEqual: (filter1, filter2) => filter1 === filter2,
|
|
217
200
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
);
|
|
201
|
+
/**
|
|
202
|
+
* You can use the `dependencies` array as with regular hooks to to force the recomputation of the selector.
|
|
203
|
+
* Is important ot mention that changes in the dependencies will not trigger a re-render of the component...
|
|
204
|
+
* Instead the recomputation of the selector will returned immediately.
|
|
205
|
+
*/
|
|
206
|
+
dependencies: [filter],
|
|
207
|
+
});
|
|
226
208
|
|
|
227
209
|
return (
|
|
228
210
|
<ul>
|
|
@@ -253,13 +235,9 @@ const useFilter = useContacts.createSelectorHook(({ filter }) => filter);
|
|
|
253
235
|
|
|
254
236
|
const useContactsArray = useContacts.createSelectorHook(({ items }) => items);
|
|
255
237
|
|
|
256
|
-
const useContactsLength = useContactsArray.createSelectorHook(
|
|
257
|
-
(items) => items.length
|
|
258
|
-
);
|
|
238
|
+
const useContactsLength = useContactsArray.createSelectorHook((items) => items.length);
|
|
259
239
|
|
|
260
|
-
const useIsContactsEmpty = useContactsLength.createSelectorHook(
|
|
261
|
-
(length) => !length
|
|
262
|
-
);
|
|
240
|
+
const useIsContactsEmpty = useContactsLength.createSelectorHook((length) => !length);
|
|
263
241
|
```
|
|
264
242
|
|
|
265
243
|
It can't get any simpler, right? Everything is connected, everything is reactive. Plus, these hooks are strongly typed, so if you're working with **TypeScript**, you'll absolutely love it.
|
|
@@ -275,30 +253,29 @@ By defining a custom API for the **useContacts**, we can encapsulate and expose
|
|
|
275
253
|
```ts
|
|
276
254
|
import { createGlobalState } from "react-native-global-state-hooks";
|
|
277
255
|
|
|
278
|
-
const
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
type State = typeof initialState;
|
|
285
|
-
|
|
286
|
-
export const useContacts = createGlobalState(initialState, {
|
|
287
|
-
// this are the actions available for this state
|
|
288
|
-
actions: {
|
|
289
|
-
setFilter(filter: string) {
|
|
290
|
-
return ({ setState }: StoreTools<State>) => {
|
|
291
|
-
setState((state) => ({
|
|
292
|
-
...state,
|
|
293
|
-
filter,
|
|
294
|
-
}));
|
|
295
|
-
};
|
|
296
|
-
},
|
|
297
|
-
} as const,
|
|
298
|
-
onInit: async ({ setState }: StoreTools<State>) => {
|
|
299
|
-
// fetch contacts
|
|
256
|
+
export const useContacts = createGlobalState(
|
|
257
|
+
{
|
|
258
|
+
isLoading: true,
|
|
259
|
+
filter: "",
|
|
260
|
+
items: [] as Contact[],
|
|
300
261
|
},
|
|
301
|
-
|
|
262
|
+
{
|
|
263
|
+
// this are the actions available for this state
|
|
264
|
+
actions: {
|
|
265
|
+
setFilter(filter: string) {
|
|
266
|
+
return ({ setState }) => {
|
|
267
|
+
setState((state) => ({
|
|
268
|
+
...state,
|
|
269
|
+
filter,
|
|
270
|
+
}));
|
|
271
|
+
};
|
|
272
|
+
},
|
|
273
|
+
} as const,
|
|
274
|
+
onInit: ({ setState }) => {
|
|
275
|
+
// fetch contacts
|
|
276
|
+
},
|
|
277
|
+
}
|
|
278
|
+
);
|
|
302
279
|
```
|
|
303
280
|
|
|
304
281
|
That's it! In this updated version, the **useContacts** hook will no longer return [**state**, **stateMutator**] but instead will return [**state**, **actions**]. This change will provide a more intuitive and convenient way to access and interact with the state and its associated actions.
|
|
@@ -452,9 +429,7 @@ const MyComponent = () => {
|
|
|
452
429
|
|
|
453
430
|
// This component can access only the stateMutator of the state,
|
|
454
431
|
// and won't re-render if the counter changes
|
|
455
|
-
return (
|
|
456
|
-
<button onClick={() => setCount((count) => count + 1)}>Increase</button>
|
|
457
|
-
);
|
|
432
|
+
return <button onClick={() => setCount((count) => count + 1)}>Increase</button>;
|
|
458
433
|
};
|
|
459
434
|
```
|
|
460
435
|
|
|
@@ -482,20 +457,14 @@ const MyComponent = () => {
|
|
|
482
457
|
```tsx
|
|
483
458
|
import { createStatefulContext, StoreTools } from "react-global-state-hooks";
|
|
484
459
|
|
|
485
|
-
type CounterState = {
|
|
486
|
-
count: number;
|
|
487
|
-
};
|
|
488
|
-
|
|
489
|
-
const initialState: CounterState = {
|
|
490
|
-
count: 0,
|
|
491
|
-
};
|
|
492
|
-
|
|
493
460
|
export const [useCounterContext, CounterProvider] = createStatefulContext(
|
|
494
|
-
|
|
461
|
+
{
|
|
462
|
+
count: 0,
|
|
463
|
+
},
|
|
495
464
|
{
|
|
496
465
|
actions: {
|
|
497
466
|
increase: (value: number = 1) => {
|
|
498
|
-
return ({ setState }
|
|
467
|
+
return ({ setState }) => {
|
|
499
468
|
setState((state) => ({
|
|
500
469
|
...state,
|
|
501
470
|
count: state.count + value,
|
|
@@ -503,7 +472,7 @@ export const [useCounterContext, CounterProvider] = createStatefulContext(
|
|
|
503
472
|
};
|
|
504
473
|
},
|
|
505
474
|
decrease: (value: number = 1) => {
|
|
506
|
-
return ({ setState }
|
|
475
|
+
return ({ setState }) => {
|
|
507
476
|
setState((state) => ({
|
|
508
477
|
...state,
|
|
509
478
|
count: state.count - value,
|
|
@@ -530,12 +499,9 @@ const MyComponent = () => {
|
|
|
530
499
|
So, we have seen that we can subscribe a callback to state changes, create **selector hooks** from our global states. Guess what? We can also create derived **emitters** and subscribe callbacks to specific portions of the state. Let's review it:
|
|
531
500
|
|
|
532
501
|
```ts
|
|
533
|
-
const subscribeToFilter = createDerivateEmitter(
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
filter,
|
|
537
|
-
})
|
|
538
|
-
);
|
|
502
|
+
const subscribeToFilter = createDerivateEmitter(contactsRetriever, ({ filter }) => ({
|
|
503
|
+
filter,
|
|
504
|
+
}));
|
|
539
505
|
```
|
|
540
506
|
|
|
541
507
|
Cool, it's basically the same, but instead of using the **hook** as a parameter, we just have to use the **stateRetriever** as a parameter, and that will make the magic.
|
|
@@ -587,15 +553,9 @@ const removeFilterSubscription = subscribeToFilter<Subscribe>(
|
|
|
587
553
|
And guess what again? You can also derive emitters from derived emitters without any trouble at all! It works basically the same. Let's see an example:
|
|
588
554
|
|
|
589
555
|
```ts
|
|
590
|
-
const subscribeToItems = createDerivateEmitter(
|
|
591
|
-
contactsRetriever,
|
|
592
|
-
({ items }) => items
|
|
593
|
-
);
|
|
556
|
+
const subscribeToItems = createDerivateEmitter(contactsRetriever, ({ items }) => items);
|
|
594
557
|
|
|
595
|
-
const subscribeToItemsLength = createDerivateEmitter(
|
|
596
|
-
subscribeToItems,
|
|
597
|
-
(items) => items.length
|
|
598
|
-
);
|
|
558
|
+
const subscribeToItemsLength = createDerivateEmitter(subscribeToItems, (items) => items.length);
|
|
599
559
|
```
|
|
600
560
|
|
|
601
561
|
The examples may seem a little silly, but they allow you to see the incredible things you can accomplish with these **derived states** and **emitters**. They open up a world of possibilities!
|
|
@@ -702,8 +662,7 @@ const [stateRetriever3, stateMutator3] = useHook3.stateControls();
|
|
|
702
662
|
|
|
703
663
|
const useIsLoading = createGlobalState(false);
|
|
704
664
|
|
|
705
|
-
const [isLoadingStateRetriever, isLoadingMutator] =
|
|
706
|
-
useIsLoading.stateControls();
|
|
665
|
+
const [isLoadingStateRetriever, isLoadingMutator] = useIsLoading.stateControls();
|
|
707
666
|
```
|
|
708
667
|
|
|
709
668
|
Once we created another peace of state, we can combine it with our other **global hooks** and **emitters**
|
|
@@ -895,17 +854,17 @@ onInit?: ({
|
|
|
895
854
|
/**
|
|
896
855
|
* @description - callback function called every time the state is changed
|
|
897
856
|
*/
|
|
898
|
-
onStateChanged?: (parameters:
|
|
857
|
+
onStateChanged?: (parameters: StoreTools<any, any> & StateChanges<unknown>) => void;
|
|
899
858
|
|
|
900
859
|
/**
|
|
901
860
|
* callback function called every time a component is subscribed to the store
|
|
902
861
|
*/
|
|
903
|
-
onSubscribed?: (parameters:
|
|
862
|
+
onSubscribed?: (parameters: StoreTools<any, any>) => void;
|
|
904
863
|
|
|
905
864
|
/**
|
|
906
865
|
* callback function called every time the state is about to change and it allows you to prevent the state change
|
|
907
866
|
*/
|
|
908
|
-
computePreventStateChange?: (parameters:
|
|
867
|
+
computePreventStateChange?: (parameters: StoreTools<any, any> & StateChanges<unknown>) => boolean;
|
|
909
868
|
```
|
|
910
869
|
|
|
911
870
|
You can pass this callbacks between on the second parameter of the builders like **createGlobalState**
|
|
@@ -939,9 +898,7 @@ export class GlobalStore<
|
|
|
939
898
|
asyncStorageKey?: string;
|
|
940
899
|
isAsyncStorageReady?: boolean;
|
|
941
900
|
} | null = null,
|
|
942
|
-
TStateSetter extends
|
|
943
|
-
| ActionCollectionConfig<TState, TMetadata>
|
|
944
|
-
| StateSetter<TState> = StateSetter<TState>
|
|
901
|
+
TStateSetter extends ActionCollectionConfig<TState, TMetadata> | StateSetter<TState> = StateSetter<TState>
|
|
945
902
|
> extends GlobalStoreAbstract<TState, TMetadata, TStateSetter> {
|
|
946
903
|
constructor(
|
|
947
904
|
state: TState,
|
|
@@ -989,10 +946,7 @@ export class GlobalStore<
|
|
|
989
946
|
setState(items, { forceUpdate: true });
|
|
990
947
|
};
|
|
991
948
|
|
|
992
|
-
protected onChange = ({
|
|
993
|
-
getMetadata,
|
|
994
|
-
getState,
|
|
995
|
-
}: StateChangesParam<TState, TMetadata, NonNullable<TStateSetter>>) => {
|
|
949
|
+
protected onChange = ({ getMetadata, getState }: StoreTools<any, any> & StateChanges<unknown>) => {
|
|
996
950
|
const asyncStorageKey = getMetadata()?.asyncStorageKey;
|
|
997
951
|
|
|
998
952
|
if (!asyncStorageKey) return;
|
|
@@ -1012,9 +966,8 @@ Then, from an instance of the global store, you will be able to access the hooks
|
|
|
1012
966
|
|
|
1013
967
|
```ts
|
|
1014
968
|
const storage = new GlobalStore(0, {
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
isAsyncStorageReady: false,
|
|
969
|
+
asyncStorage: {
|
|
970
|
+
key: "counter",
|
|
1018
971
|
},
|
|
1019
972
|
});
|
|
1020
973
|
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type AsyncStorageManager = {
|
|
2
|
+
getItem: <T extends string | null>(key: string) => Promise<T>;
|
|
3
|
+
setItem: (key: string, value: string) => Promise<void>;
|
|
4
|
+
};
|
|
5
|
+
export declare const asyncStorageWrapper: AsyncStorageManager & {
|
|
6
|
+
addAsyncStorageManager: (callback: () => Promise<AsyncStorageManager>) => Promise<void>;
|
|
7
|
+
};
|
|
8
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@react-native-async-storage/async-storage")):"function"==typeof define&&define.amd?define(["@react-native-async-storage/async-storage"],e):"object"==typeof exports?exports["react-native-global-state-hooks"]=e(require("@react-native-async-storage/async-storage")):t["react-native-global-state-hooks"]=e(t["@react-native-async-storage/async-storage"])}(this,(t=>(()=>{"use strict";var e={878:e=>{e.exports=t}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var a=r[t]={exports:{}};return e[t](a,a.exports,n),a.exports}var o={};return(()=>{var t=o;function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}function r(){r=function(){return n};var t,n={},o=Object.prototype,a=o.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},c="function"==typeof Symbol?Symbol:{},u=c.iterator||"@@iterator",s=c.asyncIterator||"@@asyncIterator",f=c.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function h(t,e,r,n){var o=e&&e.prototype instanceof w?e:w,a=Object.create(o.prototype),c=new G(n||[]);return i(a,"_invoke",{value:S(t,r,c)}),a}function p(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}n.wrap=h;var v="suspendedStart",y="suspendedYield",d="executing",g="completed",m={};function w(){}function b(){}function x(){}var L={};l(L,u,(function(){return this}));var j=Object.getPrototypeOf,E=j&&j(j(M([])));E&&E!==o&&a.call(E,u)&&(L=E);var O=x.prototype=w.prototype=Object.create(L);function _(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function k(t,r){function n(o,i,c,u){var s=p(t[o],t,i);if("throw"!==s.type){var f=s.arg,l=f.value;return l&&"object"==e(l)&&a.call(l,"__await")?r.resolve(l.__await).then((function(t){n("next",t,c,u)}),(function(t){n("throw",t,c,u)})):r.resolve(l).then((function(t){f.value=t,c(f)}),(function(t){return n("throw",t,c,u)}))}u(s.arg)}var o;i(this,"_invoke",{value:function(t,e){function a(){return new r((function(r,o){n(t,e,r,o)}))}return o=o?o.then(a,a):a()}})}function S(e,r,n){var o=v;return function(a,i){if(o===d)throw new Error("Generator is already running");if(o===g){if("throw"===a)throw i;return{value:t,done:!0}}for(n.method=a,n.arg=i;;){var c=n.delegate;if(c){var u=P(c,n);if(u){if(u===m)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===v)throw o=g,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=d;var s=p(e,r,n);if("normal"===s.type){if(o=n.done?g:y,s.arg===m)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=g,n.method="throw",n.arg=s.arg)}}}function P(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,P(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var a=p(o,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,m;var i=a.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,m):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function I(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function N(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function G(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(I,this),this.reset(!0)}function M(r){if(r||""===r){var n=r[u];if(n)return n.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var o=-1,i=function e(){for(;++o<r.length;)if(a.call(r,o))return e.value=r[o],e.done=!1,e;return e.value=t,e.done=!0,e};return i.next=i}}throw new TypeError(e(r)+" is not iterable")}return b.prototype=x,i(O,"constructor",{value:x,configurable:!0}),i(x,"constructor",{value:b,configurable:!0}),b.displayName=l(x,f,"GeneratorFunction"),n.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===b||"GeneratorFunction"===(e.displayName||e.name))},n.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,x):(t.__proto__=x,l(t,f,"GeneratorFunction")),t.prototype=Object.create(O),t},n.awrap=function(t){return{__await:t}},_(k.prototype),l(k.prototype,s,(function(){return this})),n.AsyncIterator=k,n.async=function(t,e,r,o,a){void 0===a&&(a=Promise);var i=new k(h(t,e,r,o),a);return n.isGeneratorFunction(e)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},_(O),l(O,f,"Generator"),l(O,u,(function(){return this})),l(O,"toString",(function(){return"[object Generator]"})),n.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},n.values=M,G.prototype={constructor:G,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(N),!e)for(var r in this)"t"===r.charAt(0)&&a.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),s=a.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&a.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method="next",this.next=o.finallyLoc,m):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),m},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),N(r),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;N(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:M(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),m}},n}var a=Object.create?function(t,e,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]},i=Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e},c=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.prototype.hasOwnProperty.call(t,r)&&a(e,t,r);return i(e,t),e},u=function(t,e,r,n){return new(r||(r=Promise))((function(o,a){function i(t){try{u(n.next(t))}catch(t){a(t)}}function c(t){try{u(n.throw(t))}catch(t){a(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(i,c)}u((n=n.apply(t,e||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.asyncStorageWrapper=void 0,t.asyncStorageWrapper=function(){var t,e="pending",o=null;u(void 0,void 0,void 0,r().mark((function a(){var i,u,s,f,l;return r().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,i=Promise.resolve().then((function(){return c(n(878))})),t=i,r.next=5,i;case 5:u=r.sent,s=u.default,f=s.getItem,l=s.setItem,f.bind(s),l.bind(s),o={getItem:f,setItem:l},e="resolved",r.next=18;break;case 14:r.prev=14,r.t0=r.catch(0),e="rejected";case 18:return r.prev=18,t=null,r.finish(18);case 21:case"end":return r.stop()}}),a,null,[[0,14,18,21]])})));var a=function(){throw new Error("[AsyncStorageManager Not Found] \n\n Please install the react-native-async-storage/async-storage to be use as the default async storage manager or\n add an AsyncStorageManager using the asyncStorageWrapper.addAsyncStorageManager method before attempting to get or set items.")},i=function(){return u(void 0,void 0,void 0,r().mark((function n(){return r().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if("pending"!==e||!t){r.next=2;break}return r.abrupt("return",t);case 2:if("rejected"!==e){r.next=4;break}return r.abrupt("return",t.catch((function(t){throw t})));case 4:return o||a(),r.abrupt("return",o);case 6:case"end":return r.stop()}}),n)})))};return{getItem:function(t){return u(void 0,void 0,void 0,r().mark((function e(){return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i();case 2:return e.abrupt("return",o.getItem(t));case 3:case"end":return e.stop()}}),e)})))},setItem:function(t,e){return u(void 0,void 0,void 0,r().mark((function n(){return r().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,i();case 2:return r.abrupt("return",o.setItem(t,e));case 3:case"end":return r.stop()}}),n)})))},addAsyncStorageManager:function(n){return u(void 0,void 0,void 0,r().mark((function a(){var i;return r().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(r.prev=0,"pending"!==e||!t){r.next=4;break}return r.next=4,t.catch((function(){}));case 4:return e="pending",i=n(),t=i,r.next=9,i;case 9:o=r.sent,e="resolved",r.next=18;break;case 13:throw r.prev=13,r.t0=r.catch(0),t=null,e="rejected",r.t0;case 18:case"end":return r.stop()}}),a,null,[[0,13]])})))}}}()})(),o})()));
|