@fto-consult/expo-ui 6.37.3 → 6.37.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/node_modules/.package-lock.json +26218 -26188
- package/node_modules/@react-native-async-storage/async-storage/LICENSE +21 -0
- package/node_modules/@react-native-async-storage/async-storage/README.md +27 -0
- package/node_modules/@react-native-async-storage/async-storage/RNCAsyncStorage.podspec +19 -0
- package/node_modules/@react-native-async-storage/async-storage/android/build.gradle +142 -0
- package/node_modules/@react-native-async-storage/async-storage/android/src/main/AndroidManifest.xml +6 -0
- package/node_modules/@react-native-async-storage/async-storage/android/src/main/java/com/reactnativecommunity/asyncstorage/AsyncLocalStorageUtil.java +178 -0
- package/node_modules/@react-native-async-storage/async-storage/android/src/main/java/com/reactnativecommunity/asyncstorage/AsyncStorageErrorUtil.java +45 -0
- package/node_modules/@react-native-async-storage/async-storage/android/src/main/java/com/reactnativecommunity/asyncstorage/AsyncStorageExpoMigration.java +154 -0
- package/node_modules/@react-native-async-storage/async-storage/android/src/main/java/com/reactnativecommunity/asyncstorage/AsyncStorageModule.java +424 -0
- package/node_modules/@react-native-async-storage/async-storage/android/src/main/java/com/reactnativecommunity/asyncstorage/AsyncStoragePackage.java +58 -0
- package/node_modules/@react-native-async-storage/async-storage/android/src/main/java/com/reactnativecommunity/asyncstorage/ReactDatabaseSupplier.java +163 -0
- package/node_modules/@react-native-async-storage/async-storage/android/src/main/java/com/reactnativecommunity/asyncstorage/SerialExecutor.java +40 -0
- package/node_modules/@react-native-async-storage/async-storage/android/src/main/java/com/reactnativecommunity/asyncstorage/next/ArgumentHelpers.kt +86 -0
- package/node_modules/@react-native-async-storage/async-storage/android/src/main/java/com/reactnativecommunity/asyncstorage/next/ErrorHelpers.kt +39 -0
- package/node_modules/@react-native-async-storage/async-storage/android/src/main/java/com/reactnativecommunity/asyncstorage/next/StorageModule.kt +90 -0
- package/node_modules/@react-native-async-storage/async-storage/android/src/main/java/com/reactnativecommunity/asyncstorage/next/StorageSupplier.kt +161 -0
- package/node_modules/@react-native-async-storage/async-storage/android/src/test/java/com/reactnativecommunity/asyncstorage/next/ArgumentHelpersTest.kt +93 -0
- package/node_modules/@react-native-async-storage/async-storage/android/src/test/java/com/reactnativecommunity/asyncstorage/next/StorageTest.kt +141 -0
- package/node_modules/@react-native-async-storage/async-storage/android/testresults.gradle +38 -0
- package/node_modules/@react-native-async-storage/async-storage/ios/RNCAsyncStorage.h +51 -0
- package/node_modules/@react-native-async-storage/async-storage/ios/RNCAsyncStorage.m +898 -0
- package/node_modules/@react-native-async-storage/async-storage/ios/RNCAsyncStorage.xcodeproj/project.pbxproj +283 -0
- package/node_modules/@react-native-async-storage/async-storage/ios/RNCAsyncStorageDelegate.h +73 -0
- package/node_modules/@react-native-async-storage/async-storage/jest/async-storage-mock.d.ts +9 -0
- package/node_modules/@react-native-async-storage/async-storage/jest/async-storage-mock.js +109 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/commonjs/AsyncStorage.js +164 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/commonjs/AsyncStorage.js.map +1 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/commonjs/AsyncStorage.native.js +366 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/commonjs/AsyncStorage.native.js.map +1 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/commonjs/RCTAsyncStorage.js +30 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/commonjs/RCTAsyncStorage.js.map +1 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/commonjs/helpers.js +69 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/commonjs/helpers.js.map +1 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/commonjs/hooks.js +44 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/commonjs/hooks.js.map +1 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/commonjs/index.js +22 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/commonjs/index.js.map +1 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/commonjs/shouldFallbackToLegacyNativeModule.js +39 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/commonjs/shouldFallbackToLegacyNativeModule.js.map +1 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/commonjs/types.js +2 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/commonjs/types.js.map +1 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/module/AsyncStorage.js +153 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/module/AsyncStorage.js.map +1 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/module/AsyncStorage.native.js +348 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/module/AsyncStorage.native.js.map +1 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/module/RCTAsyncStorage.js +20 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/module/RCTAsyncStorage.js.map +1 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/module/helpers.js +56 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/module/helpers.js.map +1 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/module/hooks.js +34 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/module/hooks.js.map +1 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/module/index.js +4 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/module/index.js.map +1 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/module/shouldFallbackToLegacyNativeModule.js +31 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/module/shouldFallbackToLegacyNativeModule.js.map +1 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/module/types.js +2 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/module/types.js.map +1 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/typescript/AsyncStorage.d.ts +10 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/typescript/AsyncStorage.native.d.ts +16 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/typescript/RCTAsyncStorage.d.ts +2 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/typescript/helpers.d.ts +5 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/typescript/hooks.d.ts +2 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/typescript/index.d.ts +4 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/typescript/shouldFallbackToLegacyNativeModule.d.ts +1 -0
- package/node_modules/@react-native-async-storage/async-storage/lib/typescript/types.d.ts +113 -0
- package/node_modules/@react-native-async-storage/async-storage/macos/RNCAsyncStorage.xcodeproj/project.pbxproj +385 -0
- package/node_modules/@react-native-async-storage/async-storage/macos/RNCAsyncStorage.xcodeproj/xcshareddata/xcschemes/RNCAsyncStorage-macOS.xcscheme +67 -0
- package/node_modules/@react-native-async-storage/async-storage/macos/RNCAsyncStorage.xcodeproj/xcshareddata/xcschemes/RNCAsyncStorage.xcscheme +67 -0
- package/node_modules/@react-native-async-storage/async-storage/package.json +197 -0
- package/node_modules/@react-native-async-storage/async-storage/src/AsyncStorage.native.ts +356 -0
- package/node_modules/@react-native-async-storage/async-storage/src/AsyncStorage.ts +173 -0
- package/node_modules/@react-native-async-storage/async-storage/src/RCTAsyncStorage.ts +28 -0
- package/node_modules/@react-native-async-storage/async-storage/src/helpers.ts +74 -0
- package/node_modules/@react-native-async-storage/async-storage/src/hooks.ts +11 -0
- package/node_modules/@react-native-async-storage/async-storage/src/index.ts +7 -0
- package/node_modules/@react-native-async-storage/async-storage/src/shouldFallbackToLegacyNativeModule.ts +34 -0
- package/node_modules/@react-native-async-storage/async-storage/src/types.ts +155 -0
- package/node_modules/@react-native-async-storage/async-storage/windows/ReactNativeAsyncStorage/PropertySheet.props +16 -0
- package/node_modules/@react-native-async-storage/async-storage/windows/ReactNativeAsyncStorage/ReactNativeAsyncStorage.vcxproj +172 -0
- package/node_modules/@react-native-async-storage/async-storage/windows/ReactNativeAsyncStorage/ReactNativeAsyncStorage.vcxproj.filters +34 -0
- package/node_modules/@react-native-async-storage/async-storage/windows/ReactNativeAsyncStorage/packages.config +4 -0
- package/node_modules/@react-native-async-storage/async-storage/windows/ReactNativeAsyncStorage.sln +172 -0
- package/node_modules/@react-native-async-storage/async-storage/windows/ReactNativeAsyncStorage61/PropertySheet.props +16 -0
- package/node_modules/@react-native-async-storage/async-storage/windows/ReactNativeAsyncStorage61/ReactNativeAsyncStorage61.vcxproj +157 -0
- package/node_modules/@react-native-async-storage/async-storage/windows/ReactNativeAsyncStorage61/ReactNativeAsyncStorage61.vcxproj.filters +34 -0
- package/node_modules/@react-native-async-storage/async-storage/windows/ReactNativeAsyncStorage61/packages.config +4 -0
- package/node_modules/@react-native-async-storage/async-storage/windows/ReactNativeAsyncStorage61.sln +195 -0
- package/node_modules/@react-native-async-storage/async-storage/windows/ReactNativeAsyncStorage62.sln +192 -0
- package/node_modules/@react-native-async-storage/async-storage/windows/code/DBStorage.cpp +599 -0
- package/node_modules/@react-native-async-storage/async-storage/windows/code/DBStorage.h +162 -0
- package/node_modules/@react-native-async-storage/async-storage/windows/code/RNCAsyncStorage.h +118 -0
- package/node_modules/@react-native-async-storage/async-storage/windows/code/ReactNativeAsyncStorage.def +3 -0
- package/node_modules/@react-native-async-storage/async-storage/windows/code/ReactPackageProvider.cpp +20 -0
- package/node_modules/@react-native-async-storage/async-storage/windows/code/ReactPackageProvider.h +23 -0
- package/node_modules/@react-native-async-storage/async-storage/windows/code/ReactPackageProvider.idl +7 -0
- package/node_modules/@react-native-async-storage/async-storage/windows/code/pch.cpp +3 -0
- package/node_modules/@react-native-async-storage/async-storage/windows/code/pch.h +15 -0
- package/node_modules/merge-options/index.d.ts +2 -0
- package/node_modules/merge-options/index.js +171 -0
- package/node_modules/merge-options/index.mjs +8 -0
- package/node_modules/merge-options/license +21 -0
- package/node_modules/merge-options/node_modules/is-plain-obj/index.d.ts +29 -0
- package/node_modules/merge-options/node_modules/is-plain-obj/index.js +10 -0
- package/node_modules/merge-options/node_modules/is-plain-obj/license +9 -0
- package/node_modules/merge-options/node_modules/is-plain-obj/package.json +38 -0
- package/node_modules/merge-options/node_modules/is-plain-obj/readme.md +54 -0
- package/node_modules/merge-options/package.json +59 -0
- package/node_modules/merge-options/readme.md +130 -0
- package/package.json +131 -130
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["export type ErrorLike = {\n message: string;\n key: string;\n};\n\nexport type Callback = (error?: Error | null) => void;\n\nexport type CallbackWithResult<T> = (\n error?: Error | null,\n result?: T | null\n) => void;\n\nexport type KeyValuePair = [string, string | null];\n\nexport type MultiCallback = (errors?: readonly (Error | null)[] | null) => void;\n\nexport type MultiGetCallback = (\n errors?: readonly (Error | null)[] | null,\n result?: readonly KeyValuePair[]\n) => void;\n\nexport type MultiRequest = {\n keys: readonly string[];\n callback?: MultiGetCallback;\n keyIndex: number;\n resolve?: (result: readonly KeyValuePair[]) => void;\n reject?: (error?: any) => void;\n};\n\nexport type AsyncStorageHook = {\n getItem: (callback?: CallbackWithResult<string>) => Promise<string | null>;\n setItem: (value: string, callback?: Callback) => Promise<void>;\n mergeItem: (value: string, callback?: Callback) => Promise<void>;\n removeItem: (callback?: Callback) => Promise<void>;\n};\n\n/**\n * `AsyncStorage` is a simple, unencrypted, asynchronous, persistent, key-value\n * storage system that is global to the app. It should be used instead of\n * LocalStorage.\n *\n * See https://react-native-async-storage.github.io/async-storage/docs/api\n */\nexport type AsyncStorageStatic = {\n /**\n * Fetches an item for a `key` and invokes a callback upon completion.\n *\n * See https://react-native-async-storage.github.io/async-storage/docs/api#getitem\n */\n getItem: (\n key: string,\n callback?: CallbackWithResult<string>\n ) => Promise<string | null>;\n\n /**\n * Sets the value for a `key` and invokes a callback upon completion.\n *\n * See https://react-native-async-storage.github.io/async-storage/docs/api#setitem\n */\n setItem: (key: string, value: string, callback?: Callback) => Promise<void>;\n\n /**\n * Removes an item for a `key` and invokes a callback upon completion.\n *\n * See https://react-native-async-storage.github.io/async-storage/docs/api#removeitem\n */\n removeItem: (key: string, callback?: Callback) => Promise<void>;\n\n /**\n * Merges an existing `key` value with an input value, assuming both values\n * are stringified JSON.\n *\n * See https://react-native-async-storage.github.io/async-storage/docs/api#mergeitem\n */\n mergeItem: (key: string, value: string, callback?: Callback) => Promise<void>;\n\n /**\n * Erases *all* `AsyncStorage` for all clients, libraries, etc. You probably\n * don't want to call this; use `removeItem` or `multiRemove` to clear only\n * your app's keys.\n *\n * See https://react-native-async-storage.github.io/async-storage/docs/api#clear\n */\n clear: (callback?: Callback) => Promise<void>;\n\n /**\n * Gets *all* keys known to your app; for all callers, libraries, etc.\n *\n * See https://react-native-async-storage.github.io/async-storage/docs/api#getallkeys\n */\n getAllKeys: (\n callback?: CallbackWithResult<readonly string[]>\n ) => Promise<readonly string[]>;\n\n /**\n * The following batched functions are useful for executing a lot of\n * operations at once, allowing for native optimizations and provide the\n * convenience of a single callback after all operations are complete.\n *\n * These functions return arrays of errors, potentially one for every key.\n * For key-specific errors, the Error object will have a key property to\n * indicate which key caused the error.\n */\n\n /**\n * Flushes any pending requests using a single batch call to get the data.\n *\n * See https://react-native-async-storage.github.io/async-storage/docs/api#flushgetrequests\n * */\n flushGetRequests: () => void;\n\n /**\n * This allows you to batch the fetching of items given an array of `key`\n * inputs. Your callback will be invoked with an array of corresponding\n * key-value pairs found.\n *\n * See https://react-native-async-storage.github.io/async-storage/docs/api#multiget\n */\n multiGet: (\n keys: readonly string[],\n callback?: MultiGetCallback\n ) => Promise<readonly KeyValuePair[]>;\n\n /**\n * Use this as a batch operation for storing multiple key-value pairs. When\n * the operation completes you'll get a single callback with any errors.\n *\n * See https://react-native-async-storage.github.io/async-storage/docs/api#multiset\n */\n multiSet: (\n keyValuePairs: [string, string][],\n callback?: MultiCallback\n ) => Promise<void>;\n\n /**\n * Call this to batch the deletion of all keys in the `keys` array.\n *\n * See https://react-native-async-storage.github.io/async-storage/docs/api#multiremove\n */\n multiRemove: (\n keys: readonly string[],\n callback?: MultiCallback\n ) => Promise<void>;\n\n /**\n * Batch operation to merge in existing and new values for a given set of\n * keys. This assumes that the values are stringified JSON.\n *\n * See https://react-native-async-storage.github.io/async-storage/docs/api#multimerge\n */\n multiMerge: (\n keyValuePairs: [string, string][],\n callback?: MultiCallback\n ) => Promise<void>;\n};\n"],"mappings":""}
|
@@ -0,0 +1,153 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) Nicolas Gallagher.
|
3
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
4
|
+
*
|
5
|
+
* This source code is licensed under the MIT license found in the
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
7
|
+
*/
|
8
|
+
// @ts-ignore Cannot find module 'merge-options' or its corresponding type declarations
|
9
|
+
import mergeOptions from 'merge-options';
|
10
|
+
const merge = mergeOptions.bind({
|
11
|
+
concatArrays: true,
|
12
|
+
ignoreUndefined: true
|
13
|
+
});
|
14
|
+
|
15
|
+
function mergeLocalStorageItem(key, value) {
|
16
|
+
const oldValue = window.localStorage.getItem(key);
|
17
|
+
|
18
|
+
if (oldValue) {
|
19
|
+
const oldObject = JSON.parse(oldValue);
|
20
|
+
const newObject = JSON.parse(value);
|
21
|
+
const nextValue = JSON.stringify(merge(oldObject, newObject));
|
22
|
+
window.localStorage.setItem(key, nextValue);
|
23
|
+
} else {
|
24
|
+
window.localStorage.setItem(key, value);
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
function createPromise(getValue, callback) {
|
29
|
+
return new Promise((resolve, reject) => {
|
30
|
+
try {
|
31
|
+
const value = getValue();
|
32
|
+
callback === null || callback === void 0 ? void 0 : callback(null, value);
|
33
|
+
resolve(value);
|
34
|
+
} catch (err) {
|
35
|
+
callback === null || callback === void 0 ? void 0 : callback(err);
|
36
|
+
reject(err);
|
37
|
+
}
|
38
|
+
});
|
39
|
+
}
|
40
|
+
|
41
|
+
function createPromiseAll(promises, callback, processResult) {
|
42
|
+
return Promise.all(promises).then(result => {
|
43
|
+
const value = (processResult === null || processResult === void 0 ? void 0 : processResult(result)) ?? null;
|
44
|
+
callback === null || callback === void 0 ? void 0 : callback(null, value);
|
45
|
+
return Promise.resolve(value);
|
46
|
+
}, errors => {
|
47
|
+
callback === null || callback === void 0 ? void 0 : callback(errors);
|
48
|
+
return Promise.reject(errors);
|
49
|
+
});
|
50
|
+
}
|
51
|
+
|
52
|
+
const AsyncStorage = {
|
53
|
+
/**
|
54
|
+
* Fetches `key` value.
|
55
|
+
*/
|
56
|
+
getItem: (key, callback) => {
|
57
|
+
return createPromise(() => window.localStorage.getItem(key), callback);
|
58
|
+
},
|
59
|
+
|
60
|
+
/**
|
61
|
+
* Sets `value` for `key`.
|
62
|
+
*/
|
63
|
+
setItem: (key, value, callback) => {
|
64
|
+
return createPromise(() => window.localStorage.setItem(key, value), callback);
|
65
|
+
},
|
66
|
+
|
67
|
+
/**
|
68
|
+
* Removes a `key`
|
69
|
+
*/
|
70
|
+
removeItem: (key, callback) => {
|
71
|
+
return createPromise(() => window.localStorage.removeItem(key), callback);
|
72
|
+
},
|
73
|
+
|
74
|
+
/**
|
75
|
+
* Merges existing value with input value, assuming they are stringified JSON.
|
76
|
+
*/
|
77
|
+
mergeItem: (key, value, callback) => {
|
78
|
+
return createPromise(() => mergeLocalStorageItem(key, value), callback);
|
79
|
+
},
|
80
|
+
|
81
|
+
/**
|
82
|
+
* Erases *all* AsyncStorage for the domain.
|
83
|
+
*/
|
84
|
+
clear: callback => {
|
85
|
+
return createPromise(() => window.localStorage.clear(), callback);
|
86
|
+
},
|
87
|
+
|
88
|
+
/**
|
89
|
+
* Gets *all* keys known to the app, for all callers, libraries, etc.
|
90
|
+
*/
|
91
|
+
getAllKeys: callback => {
|
92
|
+
return createPromise(() => {
|
93
|
+
const numberOfKeys = window.localStorage.length;
|
94
|
+
const keys = [];
|
95
|
+
|
96
|
+
for (let i = 0; i < numberOfKeys; i += 1) {
|
97
|
+
const key = window.localStorage.key(i) || '';
|
98
|
+
keys.push(key);
|
99
|
+
}
|
100
|
+
|
101
|
+
return keys;
|
102
|
+
}, callback);
|
103
|
+
},
|
104
|
+
|
105
|
+
/**
|
106
|
+
* (stub) Flushes any pending requests using a single batch call to get the data.
|
107
|
+
*/
|
108
|
+
flushGetRequests: () => undefined,
|
109
|
+
|
110
|
+
/**
|
111
|
+
* multiGet resolves to an array of key-value pair arrays that matches the
|
112
|
+
* input format of multiSet.
|
113
|
+
*
|
114
|
+
* multiGet(['k1', 'k2']) -> [['k1', 'val1'], ['k2', 'val2']]
|
115
|
+
*/
|
116
|
+
multiGet: (keys, callback) => {
|
117
|
+
const promises = keys.map(key => AsyncStorage.getItem(key));
|
118
|
+
|
119
|
+
const processResult = result => result.map((value, i) => [keys[i], value]);
|
120
|
+
|
121
|
+
return createPromiseAll(promises, callback, processResult);
|
122
|
+
},
|
123
|
+
|
124
|
+
/**
|
125
|
+
* Takes an array of key-value array pairs.
|
126
|
+
* multiSet([['k1', 'val1'], ['k2', 'val2']])
|
127
|
+
*/
|
128
|
+
multiSet: (keyValuePairs, callback) => {
|
129
|
+
const promises = keyValuePairs.map(item => AsyncStorage.setItem(item[0], item[1]));
|
130
|
+
return createPromiseAll(promises, callback);
|
131
|
+
},
|
132
|
+
|
133
|
+
/**
|
134
|
+
* Delete all the keys in the `keys` array.
|
135
|
+
*/
|
136
|
+
multiRemove: (keys, callback) => {
|
137
|
+
const promises = keys.map(key => AsyncStorage.removeItem(key));
|
138
|
+
return createPromiseAll(promises, callback);
|
139
|
+
},
|
140
|
+
|
141
|
+
/**
|
142
|
+
* Takes an array of key-value array pairs and merges them with existing
|
143
|
+
* values, assuming they are stringified JSON.
|
144
|
+
*
|
145
|
+
* multiMerge([['k1', 'val1'], ['k2', 'val2']])
|
146
|
+
*/
|
147
|
+
multiMerge: (keyValuePairs, callback) => {
|
148
|
+
const promises = keyValuePairs.map(item => AsyncStorage.mergeItem(item[0], item[1]));
|
149
|
+
return createPromiseAll(promises, callback);
|
150
|
+
}
|
151
|
+
};
|
152
|
+
export default AsyncStorage;
|
153
|
+
//# sourceMappingURL=AsyncStorage.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["mergeOptions","merge","bind","concatArrays","ignoreUndefined","mergeLocalStorageItem","key","value","oldValue","window","localStorage","getItem","oldObject","JSON","parse","newObject","nextValue","stringify","setItem","createPromise","getValue","callback","Promise","resolve","reject","err","createPromiseAll","promises","processResult","all","then","result","errors","AsyncStorage","removeItem","mergeItem","clear","getAllKeys","numberOfKeys","length","keys","i","push","flushGetRequests","undefined","multiGet","map","multiSet","keyValuePairs","item","multiRemove","multiMerge"],"sources":["AsyncStorage.ts"],"sourcesContent":["/**\n * Copyright (c) Nicolas Gallagher.\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n// @ts-ignore Cannot find module 'merge-options' or its corresponding type declarations\nimport mergeOptions from 'merge-options';\nimport type {\n AsyncStorageStatic,\n MultiCallback,\n MultiGetCallback,\n} from './types';\n\nconst merge = mergeOptions.bind({\n concatArrays: true,\n ignoreUndefined: true,\n});\n\nfunction mergeLocalStorageItem(key: string, value: string) {\n const oldValue = window.localStorage.getItem(key);\n if (oldValue) {\n const oldObject = JSON.parse(oldValue);\n const newObject = JSON.parse(value);\n const nextValue = JSON.stringify(merge(oldObject, newObject));\n window.localStorage.setItem(key, nextValue);\n } else {\n window.localStorage.setItem(key, value);\n }\n}\n\nfunction createPromise<Result, Callback extends Function>(\n getValue: () => Result,\n callback?: Callback\n): Promise<Result> {\n return new Promise((resolve, reject) => {\n try {\n const value = getValue();\n callback?.(null, value);\n resolve(value);\n } catch (err) {\n callback?.(err);\n reject(err);\n }\n });\n}\n\nfunction createPromiseAll<ReturnType, Result, ResultProcessor extends Function>(\n promises: Promise<Result>[],\n callback?: MultiCallback | MultiGetCallback,\n processResult?: ResultProcessor\n): Promise<ReturnType> {\n return Promise.all(promises).then(\n (result) => {\n const value = processResult?.(result) ?? null;\n callback?.(null, value);\n return Promise.resolve(value);\n },\n (errors) => {\n callback?.(errors);\n return Promise.reject(errors);\n }\n );\n}\n\nconst AsyncStorage: AsyncStorageStatic = {\n /**\n * Fetches `key` value.\n */\n getItem: (key, callback) => {\n return createPromise(() => window.localStorage.getItem(key), callback);\n },\n\n /**\n * Sets `value` for `key`.\n */\n setItem: (key, value, callback) => {\n return createPromise(\n () => window.localStorage.setItem(key, value),\n callback\n );\n },\n\n /**\n * Removes a `key`\n */\n removeItem: (key, callback) => {\n return createPromise(() => window.localStorage.removeItem(key), callback);\n },\n\n /**\n * Merges existing value with input value, assuming they are stringified JSON.\n */\n mergeItem: (key, value, callback) => {\n return createPromise(() => mergeLocalStorageItem(key, value), callback);\n },\n\n /**\n * Erases *all* AsyncStorage for the domain.\n */\n clear: (callback) => {\n return createPromise(() => window.localStorage.clear(), callback);\n },\n\n /**\n * Gets *all* keys known to the app, for all callers, libraries, etc.\n */\n getAllKeys: (callback) => {\n return createPromise(() => {\n const numberOfKeys = window.localStorage.length;\n const keys: string[] = [];\n for (let i = 0; i < numberOfKeys; i += 1) {\n const key = window.localStorage.key(i) || '';\n keys.push(key);\n }\n return keys;\n }, callback);\n },\n\n /**\n * (stub) Flushes any pending requests using a single batch call to get the data.\n */\n flushGetRequests: () => undefined,\n\n /**\n * multiGet resolves to an array of key-value pair arrays that matches the\n * input format of multiSet.\n *\n * multiGet(['k1', 'k2']) -> [['k1', 'val1'], ['k2', 'val2']]\n */\n multiGet: (keys, callback) => {\n const promises = keys.map((key) => AsyncStorage.getItem(key));\n const processResult = (result: string[]) =>\n result.map((value, i) => [keys[i], value]);\n return createPromiseAll(promises, callback, processResult);\n },\n\n /**\n * Takes an array of key-value array pairs.\n * multiSet([['k1', 'val1'], ['k2', 'val2']])\n */\n multiSet: (keyValuePairs, callback) => {\n const promises = keyValuePairs.map((item) =>\n AsyncStorage.setItem(item[0], item[1])\n );\n return createPromiseAll(promises, callback);\n },\n\n /**\n * Delete all the keys in the `keys` array.\n */\n multiRemove: (keys, callback) => {\n const promises = keys.map((key) => AsyncStorage.removeItem(key));\n return createPromiseAll(promises, callback);\n },\n\n /**\n * Takes an array of key-value array pairs and merges them with existing\n * values, assuming they are stringified JSON.\n *\n * multiMerge([['k1', 'val1'], ['k2', 'val2']])\n */\n multiMerge: (keyValuePairs, callback) => {\n const promises = keyValuePairs.map((item) =>\n AsyncStorage.mergeItem(item[0], item[1])\n );\n return createPromiseAll(promises, callback);\n },\n};\n\nexport default AsyncStorage;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA,OAAOA,YAAP,MAAyB,eAAzB;AAOA,MAAMC,KAAK,GAAGD,YAAY,CAACE,IAAb,CAAkB;EAC9BC,YAAY,EAAE,IADgB;EAE9BC,eAAe,EAAE;AAFa,CAAlB,CAAd;;AAKA,SAASC,qBAAT,CAA+BC,GAA/B,EAA4CC,KAA5C,EAA2D;EACzD,MAAMC,QAAQ,GAAGC,MAAM,CAACC,YAAP,CAAoBC,OAApB,CAA4BL,GAA5B,CAAjB;;EACA,IAAIE,QAAJ,EAAc;IACZ,MAAMI,SAAS,GAAGC,IAAI,CAACC,KAAL,CAAWN,QAAX,CAAlB;IACA,MAAMO,SAAS,GAAGF,IAAI,CAACC,KAAL,CAAWP,KAAX,CAAlB;IACA,MAAMS,SAAS,GAAGH,IAAI,CAACI,SAAL,CAAehB,KAAK,CAACW,SAAD,EAAYG,SAAZ,CAApB,CAAlB;IACAN,MAAM,CAACC,YAAP,CAAoBQ,OAApB,CAA4BZ,GAA5B,EAAiCU,SAAjC;EACD,CALD,MAKO;IACLP,MAAM,CAACC,YAAP,CAAoBQ,OAApB,CAA4BZ,GAA5B,EAAiCC,KAAjC;EACD;AACF;;AAED,SAASY,aAAT,CACEC,QADF,EAEEC,QAFF,EAGmB;EACjB,OAAO,IAAIC,OAAJ,CAAY,CAACC,OAAD,EAAUC,MAAV,KAAqB;IACtC,IAAI;MACF,MAAMjB,KAAK,GAAGa,QAAQ,EAAtB;MACAC,QAAQ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C,CAAzC;AAyGA,eAAeY,YAAf"}
|
package/node_modules/@react-native-async-storage/async-storage/lib/module/AsyncStorage.native.js
ADDED
@@ -0,0 +1,348 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
3
|
+
*
|
4
|
+
* This source code is licensed under the MIT license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*/
|
7
|
+
import { checkValidArgs, checkValidInput, convertError, convertErrors } from './helpers';
|
8
|
+
import RCTAsyncStorage from './RCTAsyncStorage';
|
9
|
+
|
10
|
+
if (!RCTAsyncStorage) {
|
11
|
+
throw new Error(`[@RNC/AsyncStorage]: NativeModule: AsyncStorage is null.
|
12
|
+
|
13
|
+
To fix this issue try these steps:
|
14
|
+
|
15
|
+
• Rebuild and restart the app.
|
16
|
+
|
17
|
+
• Run the packager with \`--reset-cache\` flag.
|
18
|
+
|
19
|
+
• If you are using CocoaPods on iOS, run \`pod install\` in the \`ios\` directory and then rebuild and re-run the app.
|
20
|
+
|
21
|
+
• If this happens while testing with Jest, check out docs how to integrate AsyncStorage with it: https://react-native-async-storage.github.io/async-storage/docs/advanced/jest
|
22
|
+
|
23
|
+
If none of these fix the issue, please open an issue on the Github repository: https://github.com/react-native-async-storage/async-storage/issues
|
24
|
+
`);
|
25
|
+
}
|
26
|
+
/**
|
27
|
+
* `AsyncStorage` is a simple, unencrypted, asynchronous, persistent, key-value
|
28
|
+
* storage system that is global to the app. It should be used instead of
|
29
|
+
* LocalStorage.
|
30
|
+
*
|
31
|
+
* See https://react-native-async-storage.github.io/async-storage/docs/api
|
32
|
+
*/
|
33
|
+
|
34
|
+
|
35
|
+
const AsyncStorage = (() => {
|
36
|
+
let _getRequests = [];
|
37
|
+
let _getKeys = [];
|
38
|
+
let _immediate = null;
|
39
|
+
return {
|
40
|
+
/**
|
41
|
+
* Fetches an item for a `key` and invokes a callback upon completion.
|
42
|
+
*
|
43
|
+
* See https://react-native-async-storage.github.io/async-storage/docs/api#getitem
|
44
|
+
*/
|
45
|
+
getItem: (key, callback) => {
|
46
|
+
return new Promise((resolve, reject) => {
|
47
|
+
checkValidInput(key);
|
48
|
+
RCTAsyncStorage.multiGet([key], (errors, result) => {
|
49
|
+
var _result$;
|
50
|
+
|
51
|
+
// Unpack result to get value from [[key,value]]
|
52
|
+
const value = result !== null && result !== void 0 && (_result$ = result[0]) !== null && _result$ !== void 0 && _result$[1] ? result[0][1] : null;
|
53
|
+
const errs = convertErrors(errors);
|
54
|
+
callback === null || callback === void 0 ? void 0 : callback(errs === null || errs === void 0 ? void 0 : errs[0], value);
|
55
|
+
|
56
|
+
if (errs) {
|
57
|
+
reject(errs[0]);
|
58
|
+
} else {
|
59
|
+
resolve(value);
|
60
|
+
}
|
61
|
+
});
|
62
|
+
});
|
63
|
+
},
|
64
|
+
|
65
|
+
/**
|
66
|
+
* Sets the value for a `key` and invokes a callback upon completion.
|
67
|
+
*
|
68
|
+
* See https://react-native-async-storage.github.io/async-storage/docs/api#setitem
|
69
|
+
*/
|
70
|
+
setItem: (key, value, callback) => {
|
71
|
+
return new Promise((resolve, reject) => {
|
72
|
+
checkValidInput(key, value);
|
73
|
+
RCTAsyncStorage.multiSet([[key, value]], errors => {
|
74
|
+
const errs = convertErrors(errors);
|
75
|
+
callback === null || callback === void 0 ? void 0 : callback(errs === null || errs === void 0 ? void 0 : errs[0]);
|
76
|
+
|
77
|
+
if (errs) {
|
78
|
+
reject(errs[0]);
|
79
|
+
} else {
|
80
|
+
resolve();
|
81
|
+
}
|
82
|
+
});
|
83
|
+
});
|
84
|
+
},
|
85
|
+
|
86
|
+
/**
|
87
|
+
* Removes an item for a `key` and invokes a callback upon completion.
|
88
|
+
*
|
89
|
+
* See https://react-native-async-storage.github.io/async-storage/docs/api#removeitem
|
90
|
+
*/
|
91
|
+
removeItem: (key, callback) => {
|
92
|
+
return new Promise((resolve, reject) => {
|
93
|
+
checkValidInput(key);
|
94
|
+
RCTAsyncStorage.multiRemove([key], errors => {
|
95
|
+
const errs = convertErrors(errors);
|
96
|
+
callback === null || callback === void 0 ? void 0 : callback(errs === null || errs === void 0 ? void 0 : errs[0]);
|
97
|
+
|
98
|
+
if (errs) {
|
99
|
+
reject(errs[0]);
|
100
|
+
} else {
|
101
|
+
resolve();
|
102
|
+
}
|
103
|
+
});
|
104
|
+
});
|
105
|
+
},
|
106
|
+
|
107
|
+
/**
|
108
|
+
* Merges an existing `key` value with an input value, assuming both values
|
109
|
+
* are stringified JSON.
|
110
|
+
*
|
111
|
+
* See https://react-native-async-storage.github.io/async-storage/docs/api#mergeitem
|
112
|
+
*/
|
113
|
+
mergeItem: (key, value, callback) => {
|
114
|
+
return new Promise((resolve, reject) => {
|
115
|
+
checkValidInput(key, value);
|
116
|
+
RCTAsyncStorage.multiMerge([[key, value]], errors => {
|
117
|
+
const errs = convertErrors(errors);
|
118
|
+
callback === null || callback === void 0 ? void 0 : callback(errs === null || errs === void 0 ? void 0 : errs[0]);
|
119
|
+
|
120
|
+
if (errs) {
|
121
|
+
reject(errs[0]);
|
122
|
+
} else {
|
123
|
+
resolve();
|
124
|
+
}
|
125
|
+
});
|
126
|
+
});
|
127
|
+
},
|
128
|
+
|
129
|
+
/**
|
130
|
+
* Erases *all* `AsyncStorage` for all clients, libraries, etc. You probably
|
131
|
+
* don't want to call this; use `removeItem` or `multiRemove` to clear only
|
132
|
+
* your app's keys.
|
133
|
+
*
|
134
|
+
* See https://react-native-async-storage.github.io/async-storage/docs/api#clear
|
135
|
+
*/
|
136
|
+
clear: callback => {
|
137
|
+
return new Promise((resolve, reject) => {
|
138
|
+
RCTAsyncStorage.clear(error => {
|
139
|
+
const err = convertError(error);
|
140
|
+
callback === null || callback === void 0 ? void 0 : callback(err);
|
141
|
+
|
142
|
+
if (err) {
|
143
|
+
reject(err);
|
144
|
+
} else {
|
145
|
+
resolve();
|
146
|
+
}
|
147
|
+
});
|
148
|
+
});
|
149
|
+
},
|
150
|
+
|
151
|
+
/**
|
152
|
+
* Gets *all* keys known to your app; for all callers, libraries, etc.
|
153
|
+
*
|
154
|
+
* See https://react-native-async-storage.github.io/async-storage/docs/api#getallkeys
|
155
|
+
*/
|
156
|
+
getAllKeys: callback => {
|
157
|
+
return new Promise((resolve, reject) => {
|
158
|
+
RCTAsyncStorage.getAllKeys((error, keys) => {
|
159
|
+
const err = convertError(error);
|
160
|
+
callback === null || callback === void 0 ? void 0 : callback(err, keys);
|
161
|
+
|
162
|
+
if (keys) {
|
163
|
+
resolve(keys);
|
164
|
+
} else {
|
165
|
+
reject(err);
|
166
|
+
}
|
167
|
+
});
|
168
|
+
});
|
169
|
+
},
|
170
|
+
|
171
|
+
/**
|
172
|
+
* The following batched functions are useful for executing a lot of
|
173
|
+
* operations at once, allowing for native optimizations and provide the
|
174
|
+
* convenience of a single callback after all operations are complete.
|
175
|
+
*
|
176
|
+
* These functions return arrays of errors, potentially one for every key.
|
177
|
+
* For key-specific errors, the Error object will have a key property to
|
178
|
+
* indicate which key caused the error.
|
179
|
+
*/
|
180
|
+
|
181
|
+
/**
|
182
|
+
* Flushes any pending requests using a single batch call to get the data.
|
183
|
+
*
|
184
|
+
* See https://react-native-async-storage.github.io/async-storage/docs/api#flushgetrequests
|
185
|
+
* */
|
186
|
+
flushGetRequests: () => {
|
187
|
+
const getRequests = _getRequests;
|
188
|
+
const getKeys = _getKeys;
|
189
|
+
_getRequests = [];
|
190
|
+
_getKeys = [];
|
191
|
+
RCTAsyncStorage.multiGet(getKeys, (errors, result) => {
|
192
|
+
// Even though the runtime complexity of this is theoretically worse vs if we used a map,
|
193
|
+
// it's much, much faster in practice for the data sets we deal with (we avoid
|
194
|
+
// allocating result pair arrays). This was heavily benchmarked.
|
195
|
+
//
|
196
|
+
// Is there a way to avoid using the map but fix the bug in this breaking test?
|
197
|
+
// https://github.com/facebook/react-native/commit/8dd8ad76579d7feef34c014d387bf02065692264
|
198
|
+
const map = {};
|
199
|
+
result === null || result === void 0 ? void 0 : result.forEach(_ref => {
|
200
|
+
let [key, value] = _ref;
|
201
|
+
map[key] = value;
|
202
|
+
return value;
|
203
|
+
});
|
204
|
+
const reqLength = getRequests.length;
|
205
|
+
/**
|
206
|
+
* As mentioned few lines above, this method could be called with the array of potential error,
|
207
|
+
* in case of anything goes wrong. The problem is, if any of the batched calls fails
|
208
|
+
* the rest of them would fail too, but the error would be consumed by just one. The rest
|
209
|
+
* would simply return `undefined` as their result, rendering false negatives.
|
210
|
+
*
|
211
|
+
* In order to avoid this situation, in case of any call failing,
|
212
|
+
* the rest of them will be rejected as well (with the same error).
|
213
|
+
*/
|
214
|
+
|
215
|
+
const errorList = convertErrors(errors);
|
216
|
+
const error = errorList !== null && errorList !== void 0 && errorList.length ? errorList[0] : null;
|
217
|
+
|
218
|
+
for (let i = 0; i < reqLength; i++) {
|
219
|
+
var _request$callback2, _request$resolve;
|
220
|
+
|
221
|
+
const request = getRequests[i];
|
222
|
+
|
223
|
+
if (error) {
|
224
|
+
var _request$callback, _request$reject;
|
225
|
+
|
226
|
+
(_request$callback = request.callback) === null || _request$callback === void 0 ? void 0 : _request$callback.call(request, errorList);
|
227
|
+
(_request$reject = request.reject) === null || _request$reject === void 0 ? void 0 : _request$reject.call(request, error);
|
228
|
+
continue;
|
229
|
+
}
|
230
|
+
|
231
|
+
const requestResult = request.keys.map(key => [key, map[key]]);
|
232
|
+
(_request$callback2 = request.callback) === null || _request$callback2 === void 0 ? void 0 : _request$callback2.call(request, null, requestResult);
|
233
|
+
(_request$resolve = request.resolve) === null || _request$resolve === void 0 ? void 0 : _request$resolve.call(request, requestResult);
|
234
|
+
}
|
235
|
+
});
|
236
|
+
},
|
237
|
+
|
238
|
+
/**
|
239
|
+
* This allows you to batch the fetching of items given an array of `key`
|
240
|
+
* inputs. Your callback will be invoked with an array of corresponding
|
241
|
+
* key-value pairs found.
|
242
|
+
*
|
243
|
+
* See https://react-native-async-storage.github.io/async-storage/docs/api#multiget
|
244
|
+
*/
|
245
|
+
multiGet: (keys, callback) => {
|
246
|
+
if (!_immediate) {
|
247
|
+
_immediate = setImmediate(() => {
|
248
|
+
_immediate = null;
|
249
|
+
AsyncStorage.flushGetRequests();
|
250
|
+
});
|
251
|
+
}
|
252
|
+
|
253
|
+
const getRequest = {
|
254
|
+
keys: keys,
|
255
|
+
callback: callback,
|
256
|
+
// do we need this?
|
257
|
+
keyIndex: _getKeys.length,
|
258
|
+
resolve: null,
|
259
|
+
reject: null
|
260
|
+
};
|
261
|
+
const promiseResult = new Promise((resolve, reject) => {
|
262
|
+
getRequest.resolve = resolve;
|
263
|
+
getRequest.reject = reject;
|
264
|
+
});
|
265
|
+
|
266
|
+
_getRequests.push(getRequest); // avoid fetching duplicates
|
267
|
+
|
268
|
+
|
269
|
+
keys.forEach(key => {
|
270
|
+
if (_getKeys.indexOf(key) === -1) {
|
271
|
+
_getKeys.push(key);
|
272
|
+
}
|
273
|
+
});
|
274
|
+
return promiseResult;
|
275
|
+
},
|
276
|
+
|
277
|
+
/**
|
278
|
+
* Use this as a batch operation for storing multiple key-value pairs. When
|
279
|
+
* the operation completes you'll get a single callback with any errors.
|
280
|
+
*
|
281
|
+
* See https://react-native-async-storage.github.io/async-storage/docs/api#multiset
|
282
|
+
*/
|
283
|
+
multiSet: (keyValuePairs, callback) => {
|
284
|
+
checkValidArgs(keyValuePairs, callback);
|
285
|
+
return new Promise((resolve, reject) => {
|
286
|
+
keyValuePairs.forEach(_ref2 => {
|
287
|
+
let [key, value] = _ref2;
|
288
|
+
checkValidInput(key, value);
|
289
|
+
});
|
290
|
+
RCTAsyncStorage.multiSet(keyValuePairs, errors => {
|
291
|
+
const error = convertErrors(errors);
|
292
|
+
callback === null || callback === void 0 ? void 0 : callback(error);
|
293
|
+
|
294
|
+
if (error) {
|
295
|
+
reject(error);
|
296
|
+
} else {
|
297
|
+
resolve();
|
298
|
+
}
|
299
|
+
});
|
300
|
+
});
|
301
|
+
},
|
302
|
+
|
303
|
+
/**
|
304
|
+
* Call this to batch the deletion of all keys in the `keys` array.
|
305
|
+
*
|
306
|
+
* See https://react-native-async-storage.github.io/async-storage/docs/api#multiremove
|
307
|
+
*/
|
308
|
+
multiRemove: (keys, callback) => {
|
309
|
+
return new Promise((resolve, reject) => {
|
310
|
+
keys.forEach(key => checkValidInput(key));
|
311
|
+
RCTAsyncStorage.multiRemove(keys, errors => {
|
312
|
+
const error = convertErrors(errors);
|
313
|
+
callback === null || callback === void 0 ? void 0 : callback(error);
|
314
|
+
|
315
|
+
if (error) {
|
316
|
+
reject(error);
|
317
|
+
} else {
|
318
|
+
resolve();
|
319
|
+
}
|
320
|
+
});
|
321
|
+
});
|
322
|
+
},
|
323
|
+
|
324
|
+
/**
|
325
|
+
* Batch operation to merge in existing and new values for a given set of
|
326
|
+
* keys. This assumes that the values are stringified JSON.
|
327
|
+
*
|
328
|
+
* See https://react-native-async-storage.github.io/async-storage/docs/api#multimerge
|
329
|
+
*/
|
330
|
+
multiMerge: (keyValuePairs, callback) => {
|
331
|
+
return new Promise((resolve, reject) => {
|
332
|
+
RCTAsyncStorage.multiMerge(keyValuePairs, errors => {
|
333
|
+
const error = convertErrors(errors);
|
334
|
+
callback === null || callback === void 0 ? void 0 : callback(error);
|
335
|
+
|
336
|
+
if (error) {
|
337
|
+
reject(error);
|
338
|
+
} else {
|
339
|
+
resolve();
|
340
|
+
}
|
341
|
+
});
|
342
|
+
});
|
343
|
+
}
|
344
|
+
};
|
345
|
+
})();
|
346
|
+
|
347
|
+
export default AsyncStorage;
|
348
|
+
//# sourceMappingURL=AsyncStorage.native.js.map
|
package/node_modules/@react-native-async-storage/async-storage/lib/module/AsyncStorage.native.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["checkValidArgs","checkValidInput","convertError","convertErrors","RCTAsyncStorage","Error","AsyncStorage","_getRequests","_getKeys","_immediate","getItem","key","callback","Promise","resolve","reject","multiGet","errors","result","value","errs","setItem","multiSet","removeItem","multiRemove","mergeItem","multiMerge","clear","error","err","getAllKeys","keys","flushGetRequests","getRequests","getKeys","map","forEach","reqLength","length","errorList","i","request","requestResult","setImmediate","getRequest","keyIndex","promiseResult","push","indexOf","keyValuePairs"],"sources":["AsyncStorage.native.ts"],"sourcesContent":["/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport {\n checkValidArgs,\n checkValidInput,\n convertError,\n convertErrors,\n} from './helpers';\nimport RCTAsyncStorage from './RCTAsyncStorage';\nimport type {\n AsyncStorageStatic,\n ErrorLike,\n KeyValuePair,\n MultiRequest,\n} from './types';\n\nif (!RCTAsyncStorage) {\n throw new Error(`[@RNC/AsyncStorage]: NativeModule: AsyncStorage is null.\n\nTo fix this issue try these steps:\n\n • Rebuild and restart the app.\n\n • Run the packager with \\`--reset-cache\\` flag.\n\n • If you are using CocoaPods on iOS, run \\`pod install\\` in the \\`ios\\` directory and then rebuild and re-run the app.\n\n • If this happens while testing with Jest, check out docs how to integrate AsyncStorage with it: https://react-native-async-storage.github.io/async-storage/docs/advanced/jest\n\nIf none of these fix the issue, please open an issue on the Github repository: https://github.com/react-native-async-storage/async-storage/issues\n`);\n}\n\n/**\n * `AsyncStorage` is a simple, unencrypted, asynchronous, persistent, key-value\n * storage system that is global to the app. It should be used instead of\n * LocalStorage.\n *\n * See https://react-native-async-storage.github.io/async-storage/docs/api\n */\nconst AsyncStorage = ((): AsyncStorageStatic => {\n let _getRequests: MultiRequest[] = [];\n let _getKeys: string[] = [];\n let _immediate: ReturnType<typeof setImmediate> | null = null;\n\n return {\n /**\n * Fetches an item for a `key` and invokes a callback upon completion.\n *\n * See https://react-native-async-storage.github.io/async-storage/docs/api#getitem\n */\n getItem: (key, callback) => {\n return new Promise((resolve, reject) => {\n checkValidInput(key);\n RCTAsyncStorage.multiGet(\n [key],\n (errors?: ErrorLike[], result?: string[][]) => {\n // Unpack result to get value from [[key,value]]\n const value = result?.[0]?.[1] ? result[0][1] : null;\n const errs = convertErrors(errors);\n callback?.(errs?.[0], value);\n if (errs) {\n reject(errs[0]);\n } else {\n resolve(value);\n }\n }\n );\n });\n },\n\n /**\n * Sets the value for a `key` and invokes a callback upon completion.\n *\n * See https://react-native-async-storage.github.io/async-storage/docs/api#setitem\n */\n setItem: (key, value, callback) => {\n return new Promise((resolve, reject) => {\n checkValidInput(key, value);\n RCTAsyncStorage.multiSet([[key, value]], (errors?: ErrorLike[]) => {\n const errs = convertErrors(errors);\n callback?.(errs?.[0]);\n if (errs) {\n reject(errs[0]);\n } else {\n resolve();\n }\n });\n });\n },\n\n /**\n * Removes an item for a `key` and invokes a callback upon completion.\n *\n * See https://react-native-async-storage.github.io/async-storage/docs/api#removeitem\n */\n removeItem: (key, callback) => {\n return new Promise((resolve, reject) => {\n checkValidInput(key);\n RCTAsyncStorage.multiRemove([key], (errors?: ErrorLike[]) => {\n const errs = convertErrors(errors);\n callback?.(errs?.[0]);\n if (errs) {\n reject(errs[0]);\n } else {\n resolve();\n }\n });\n });\n },\n\n /**\n * Merges an existing `key` value with an input value, assuming both values\n * are stringified JSON.\n *\n * See https://react-native-async-storage.github.io/async-storage/docs/api#mergeitem\n */\n mergeItem: (key, value, callback) => {\n return new Promise((resolve, reject) => {\n checkValidInput(key, value);\n RCTAsyncStorage.multiMerge([[key, value]], (errors?: ErrorLike[]) => {\n const errs = convertErrors(errors);\n callback?.(errs?.[0]);\n if (errs) {\n reject(errs[0]);\n } else {\n resolve();\n }\n });\n });\n },\n\n /**\n * Erases *all* `AsyncStorage` for all clients, libraries, etc. You probably\n * don't want to call this; use `removeItem` or `multiRemove` to clear only\n * your app's keys.\n *\n * See https://react-native-async-storage.github.io/async-storage/docs/api#clear\n */\n clear: (callback) => {\n return new Promise((resolve, reject) => {\n RCTAsyncStorage.clear((error?: ErrorLike) => {\n const err = convertError(error);\n callback?.(err);\n if (err) {\n reject(err);\n } else {\n resolve();\n }\n });\n });\n },\n\n /**\n * Gets *all* keys known to your app; for all callers, libraries, etc.\n *\n * See https://react-native-async-storage.github.io/async-storage/docs/api#getallkeys\n */\n getAllKeys: (callback) => {\n return new Promise((resolve, reject) => {\n RCTAsyncStorage.getAllKeys((error?: ErrorLike, keys?: string[]) => {\n const err = convertError(error);\n callback?.(err, keys);\n if (keys) {\n resolve(keys);\n } else {\n reject(err);\n }\n });\n });\n },\n\n /**\n * The following batched functions are useful for executing a lot of\n * operations at once, allowing for native optimizations and provide the\n * convenience of a single callback after all operations are complete.\n *\n * These functions return arrays of errors, potentially one for every key.\n * For key-specific errors, the Error object will have a key property to\n * indicate which key caused the error.\n */\n\n /**\n * Flushes any pending requests using a single batch call to get the data.\n *\n * See https://react-native-async-storage.github.io/async-storage/docs/api#flushgetrequests\n * */\n flushGetRequests: () => {\n const getRequests = _getRequests;\n const getKeys = _getKeys;\n\n _getRequests = [];\n _getKeys = [];\n\n RCTAsyncStorage.multiGet(\n getKeys,\n (errors?: ErrorLike[], result?: string[][]) => {\n // Even though the runtime complexity of this is theoretically worse vs if we used a map,\n // it's much, much faster in practice for the data sets we deal with (we avoid\n // allocating result pair arrays). This was heavily benchmarked.\n //\n // Is there a way to avoid using the map but fix the bug in this breaking test?\n // https://github.com/facebook/react-native/commit/8dd8ad76579d7feef34c014d387bf02065692264\n const map: Record<string, string> = {};\n result?.forEach(([key, value]) => {\n map[key] = value;\n return value;\n });\n const reqLength = getRequests.length;\n\n /**\n * As mentioned few lines above, this method could be called with the array of potential error,\n * in case of anything goes wrong. The problem is, if any of the batched calls fails\n * the rest of them would fail too, but the error would be consumed by just one. The rest\n * would simply return `undefined` as their result, rendering false negatives.\n *\n * In order to avoid this situation, in case of any call failing,\n * the rest of them will be rejected as well (with the same error).\n */\n const errorList = convertErrors(errors);\n const error = errorList?.length ? errorList[0] : null;\n\n for (let i = 0; i < reqLength; i++) {\n const request = getRequests[i];\n if (error) {\n request.callback?.(errorList);\n request.reject?.(error);\n continue;\n }\n const requestResult = request.keys.map<KeyValuePair>((key) => [\n key,\n map[key],\n ]);\n request.callback?.(null, requestResult);\n request.resolve?.(requestResult);\n }\n }\n );\n },\n\n /**\n * This allows you to batch the fetching of items given an array of `key`\n * inputs. Your callback will be invoked with an array of corresponding\n * key-value pairs found.\n *\n * See https://react-native-async-storage.github.io/async-storage/docs/api#multiget\n */\n multiGet: (keys, callback) => {\n if (!_immediate) {\n _immediate = setImmediate(() => {\n _immediate = null;\n AsyncStorage.flushGetRequests();\n });\n }\n\n const getRequest: MultiRequest = {\n keys: keys,\n callback: callback,\n // do we need this?\n keyIndex: _getKeys.length,\n resolve: null as any,\n reject: null as any,\n };\n\n const promiseResult = new Promise<readonly KeyValuePair[]>(\n (resolve, reject) => {\n getRequest.resolve = resolve;\n getRequest.reject = reject;\n }\n );\n\n _getRequests.push(getRequest);\n // avoid fetching duplicates\n keys.forEach((key) => {\n if (_getKeys.indexOf(key) === -1) {\n _getKeys.push(key);\n }\n });\n\n return promiseResult;\n },\n\n /**\n * Use this as a batch operation for storing multiple key-value pairs. When\n * the operation completes you'll get a single callback with any errors.\n *\n * See https://react-native-async-storage.github.io/async-storage/docs/api#multiset\n */\n multiSet: (keyValuePairs, callback) => {\n checkValidArgs(keyValuePairs, callback);\n return new Promise((resolve, reject) => {\n keyValuePairs.forEach(([key, value]) => {\n checkValidInput(key, value);\n });\n\n RCTAsyncStorage.multiSet(keyValuePairs, (errors?: ErrorLike[]) => {\n const error = convertErrors(errors);\n callback?.(error);\n if (error) {\n reject(error);\n } else {\n resolve();\n }\n });\n });\n },\n\n /**\n * Call this to batch the deletion of all keys in the `keys` array.\n *\n * See https://react-native-async-storage.github.io/async-storage/docs/api#multiremove\n */\n multiRemove: (keys, callback) => {\n return new Promise((resolve, reject) => {\n keys.forEach((key) => checkValidInput(key));\n\n RCTAsyncStorage.multiRemove(keys, (errors?: ErrorLike[]) => {\n const error = convertErrors(errors);\n callback?.(error);\n if (error) {\n reject(error);\n } else {\n resolve();\n }\n });\n });\n },\n\n /**\n * Batch operation to merge in existing and new values for a given set of\n * keys. This assumes that the values are stringified JSON.\n *\n * See https://react-native-async-storage.github.io/async-storage/docs/api#multimerge\n */\n multiMerge: (keyValuePairs, callback) => {\n return new Promise((resolve, reject) => {\n RCTAsyncStorage.multiMerge(keyValuePairs, (errors?: ErrorLike[]) => {\n const error = convertErrors(errors);\n callback?.(error);\n if (error) {\n reject(error);\n } else {\n resolve();\n }\n });\n });\n },\n };\n})();\n\nexport default AsyncStorage;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AAEA,SACEA,cADF,EAEEC,eAFF,EAGEC,YAHF,EAIEC,aAJF,QAKO,WALP;AAMA,OAAOC,eAAP,MAA4B,mBAA5B;;AAQA,IAAI,CAACA,eAAL,EAAsB;EACpB,MAAM,IAAIC,KAAJ,CAAW;AACnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAbQ,CAAN;AAcD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,MAAMC,YAAY,GAAG,CAAC,MAA0B;EAC9C,IAAIC,YAA4B,GAAG,EAAnC;EACA,IAAIC,QAAkB,GAAG,EAAzB;EACA,IAAIC,UAAkD,GAAG,IAAzD;EAEA,OAAO;IACL;AACJ;AACA;AACA;AACA;IACIC,OAAO,EAAE,CAACC,GAAD,EAAMC,QAAN,KAAmB;MAC1B,OAAO,IAAIC,OAAJ,CAAY,CAACC,OAAD,EAAUC,MAAV,KAAqB;QACtCd,eAAe,CAACU,GAAD,CAAf;QACAP,eAAe,CAACY,QAAhB,CACE,CAACL,GAAD,CADF,EAEE,CAACM,MAAD,EAAuBC,MAAvB,KAA+C;UAAA;;UAC7C;UACA,MAAMC,KAAK,GAAGD,MAAM,SAAN,IAAAA,MAAM,WAAN,gBAAAA,MAAM,CAAG,CAAH,CAAN,8CAAc,CAAd,IAAmBA,MAAM,CAAC,CAAD,CAAN,CAAU,CAAV,CAAnB,GAAkC,IAAhD;UACA,MAAME,IAAI,GAAGjB,aAAa,CAACc,MAAD,CAA1B;UACAL,QAAQ,SAAR,IAAAA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;AACA;AACA;IACIU,WAAW,EAAE,CAACO,IAAD,EAAOnB,QAAP,KAAoB;MAC/B,OAAO,IAAIC,OAAJ,CAAY,CAACC,OAAD,EAAUC,MAAV,KAAqB;QACtCgB,IAAI,CAACK,OAAL,CAAczB,GAAD,IAASV,eAAe,CAACU,GAAD,CAArC;QAEAP,eAAe,CAACoB,WAAhB,CAA4BO,IAA5B,EAAmCd,MAAD,IAA0B;UAC1D,MAAMW,KAAK,GAAGzB,aAAa,CAACc,MAAD,CAA3B;UACAL,QAAQ,SAAR,IAAAA,QAAQ,WAAR,YAAAA,QAAQ,CAAGgB,KAAH,CAAR;;UACA,IAAIA,KAAJ,EAAW;YACTb,MAAM,CAACa,KAAD,CAAN;UACD,CAFD,MAEO;YACLd,OAAO;UACR;QACF,CARD;MASD,CAZM,CAAP;IAaD,CAzRI;;IA2RL;AACJ;AACA;AACA;AACA;AACA;IACIY,UAAU,EAAE,CAACuB,aAAD,EAAgBrC,QAAhB,KAA6B;MACvC,OAAO,IAAIC,OAAJ,CAAY,CAACC,OAAD,EAAUC,MAAV,KAAqB;QACtCX,eAAe,CAACsB,UAAhB,CAA2BuB,aAA3B,EAA2ChC,MAAD,IAA0B;UAClE,MAAMW,KAAK,GAAGzB,aAAa,CAACc,MAAD,CAA3B;UACAL,QAAQ,SAAR,IAAAA,QAAQ,WAAR,YAAAA,QAAQ,CAAGgB,KAAH,CAAR;;UACA,IAAIA,KAAJ,EAAW;YACTb,MAAM,CAACa,KAAD,CAAN;UACD,CAFD,MAEO;YACLd,OAAO;UACR;QACF,CARD;MASD,CAVM,CAAP;IAWD;EA7SI,CAAP;AA+SD,CApToB,GAArB;;AAsTA,eAAeR,YAAf"}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
// @ts-ignore Module '"react-native"' has no exported member 'TurboModuleRegistry'.
|
2
|
+
import { NativeModules, TurboModuleRegistry } from 'react-native';
|
3
|
+
import { shouldFallbackToLegacyNativeModule } from './shouldFallbackToLegacyNativeModule'; // TurboModuleRegistry falls back to NativeModules so we don't have to try go
|
4
|
+
// assign NativeModules' counterparts if TurboModuleRegistry would resolve
|
5
|
+
// with undefined.
|
6
|
+
|
7
|
+
let RCTAsyncStorage = TurboModuleRegistry ? TurboModuleRegistry.get('PlatformLocalStorage') || // Support for external modules, like react-native-windows
|
8
|
+
TurboModuleRegistry.get('RNC_AsyncSQLiteDBStorage') || TurboModuleRegistry.get('RNCAsyncStorage') : NativeModules['PlatformLocalStorage'] || // Support for external modules, like react-native-windows
|
9
|
+
NativeModules['RNC_AsyncSQLiteDBStorage'] || NativeModules['RNCAsyncStorage'];
|
10
|
+
|
11
|
+
if (!RCTAsyncStorage && shouldFallbackToLegacyNativeModule()) {
|
12
|
+
if (TurboModuleRegistry) {
|
13
|
+
RCTAsyncStorage = TurboModuleRegistry.get('AsyncSQLiteDBStorage') || TurboModuleRegistry.get('AsyncLocalStorage');
|
14
|
+
} else {
|
15
|
+
RCTAsyncStorage = NativeModules['AsyncSQLiteDBStorage'] || NativeModules['AsyncLocalStorage'];
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
19
|
+
export default RCTAsyncStorage;
|
20
|
+
//# sourceMappingURL=RCTAsyncStorage.js.map
|
package/node_modules/@react-native-async-storage/async-storage/lib/module/RCTAsyncStorage.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["NativeModules","TurboModuleRegistry","shouldFallbackToLegacyNativeModule","RCTAsyncStorage","get"],"sources":["RCTAsyncStorage.ts"],"sourcesContent":["// @ts-ignore Module '\"react-native\"' has no exported member 'TurboModuleRegistry'.\nimport { NativeModules, TurboModuleRegistry } from 'react-native';\nimport { shouldFallbackToLegacyNativeModule } from './shouldFallbackToLegacyNativeModule';\n\n// TurboModuleRegistry falls back to NativeModules so we don't have to try go\n// assign NativeModules' counterparts if TurboModuleRegistry would resolve\n// with undefined.\nlet RCTAsyncStorage = TurboModuleRegistry\n ? TurboModuleRegistry.get('PlatformLocalStorage') || // Support for external modules, like react-native-windows\n TurboModuleRegistry.get('RNC_AsyncSQLiteDBStorage') ||\n TurboModuleRegistry.get('RNCAsyncStorage')\n : NativeModules['PlatformLocalStorage'] || // Support for external modules, like react-native-windows\n NativeModules['RNC_AsyncSQLiteDBStorage'] ||\n NativeModules['RNCAsyncStorage'];\n\nif (!RCTAsyncStorage && shouldFallbackToLegacyNativeModule()) {\n if (TurboModuleRegistry) {\n RCTAsyncStorage =\n TurboModuleRegistry.get('AsyncSQLiteDBStorage') ||\n TurboModuleRegistry.get('AsyncLocalStorage');\n } else {\n RCTAsyncStorage =\n NativeModules['AsyncSQLiteDBStorage'] ||\n NativeModules['AsyncLocalStorage'];\n }\n}\n\nexport default RCTAsyncStorage;\n"],"mappings":"AAAA;AACA,SAASA,aAAT,EAAwBC,mBAAxB,QAAmD,cAAnD;AACA,SAASC,kCAAT,QAAmD,sCAAnD,C,CAEA;AACA;AACA;;AACA,IAAIC,eAAe,GAAGF,mBAAmB,GACrCA,mBAAmB,CAACG,GAApB,CAAwB,sBAAxB,KAAmD;AACnDH,mBAAmB,CAACG,GAApB,CAAwB,0BAAxB,CADA,IAEAH,mBAAmB,CAACG,GAApB,CAAwB,iBAAxB,CAHqC,GAIrCJ,aAAa,CAAC,sBAAD,CAAb,IAAyC;AACzCA,aAAa,CAAC,0BAAD,CADb,IAEAA,aAAa,CAAC,iBAAD,CANjB;;AAQA,IAAI,CAACG,eAAD,IAAoBD,kCAAkC,EAA1D,EAA8D;EAC5D,IAAID,mBAAJ,EAAyB;IACvBE,eAAe,GACbF,mBAAmB,CAACG,GAApB,CAAwB,sBAAxB,KACAH,mBAAmB,CAACG,GAApB,CAAwB,mBAAxB,CAFF;EAGD,CAJD,MAIO;IACLD,eAAe,GACbH,aAAa,CAAC,sBAAD,CAAb,IACAA,aAAa,CAAC,mBAAD,CAFf;EAGD;AACF;;AAED,eAAeG,eAAf"}
|
@@ -0,0 +1,56 @@
|
|
1
|
+
export function checkValidArgs(keyValuePairs, callback) {
|
2
|
+
if (!Array.isArray(keyValuePairs) || keyValuePairs.length === 0 || !Array.isArray(keyValuePairs[0])) {
|
3
|
+
throw new Error('[AsyncStorage] Expected array of key-value pairs as first argument to multiSet');
|
4
|
+
}
|
5
|
+
|
6
|
+
if (callback && typeof callback !== 'function') {
|
7
|
+
if (Array.isArray(callback)) {
|
8
|
+
throw new Error('[AsyncStorage] Expected function as second argument to multiSet. Did you forget to wrap key-value pairs in an array for the first argument?');
|
9
|
+
}
|
10
|
+
|
11
|
+
throw new Error('[AsyncStorage] Expected function as second argument to multiSet');
|
12
|
+
}
|
13
|
+
}
|
14
|
+
export function checkValidInput() {
|
15
|
+
for (var _len = arguments.length, input = new Array(_len), _key = 0; _key < _len; _key++) {
|
16
|
+
input[_key] = arguments[_key];
|
17
|
+
}
|
18
|
+
|
19
|
+
const [key, value] = input;
|
20
|
+
|
21
|
+
if (typeof key !== 'string') {
|
22
|
+
console.warn(`[AsyncStorage] Using ${typeof key} type for key is not supported. This can lead to unexpected behavior/errors. Use string instead.\nKey passed: ${key}\n`);
|
23
|
+
}
|
24
|
+
|
25
|
+
if (input.length > 1 && typeof value !== 'string') {
|
26
|
+
if (value == null) {
|
27
|
+
throw new Error(`[AsyncStorage] Passing null/undefined as value is not supported. If you want to remove value, Use .removeItem method instead.\nPassed value: ${value}\nPassed key: ${key}\n`);
|
28
|
+
} else {
|
29
|
+
console.warn(`[AsyncStorage] The value for key "${key}" is not a string. This can lead to unexpected behavior/errors. Consider stringifying it.\nPassed value: ${value}\nPassed key: ${key}\n`);
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}
|
33
|
+
export function convertError(error) {
|
34
|
+
if (!error) {
|
35
|
+
return null;
|
36
|
+
}
|
37
|
+
|
38
|
+
const out = new Error(error.message);
|
39
|
+
out.key = error.key;
|
40
|
+
return out;
|
41
|
+
}
|
42
|
+
export function convertErrors(errs) {
|
43
|
+
const errors = ensureArray(errs);
|
44
|
+
return errors ? errors.map(e => convertError(e)) : null;
|
45
|
+
}
|
46
|
+
|
47
|
+
function ensureArray(e) {
|
48
|
+
if (Array.isArray(e)) {
|
49
|
+
return e.length === 0 ? null : e;
|
50
|
+
} else if (e) {
|
51
|
+
return [e];
|
52
|
+
} else {
|
53
|
+
return null;
|
54
|
+
}
|
55
|
+
}
|
56
|
+
//# sourceMappingURL=helpers.js.map
|