@fto-consult/expo-ui 6.37.3 → 6.37.5

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.
Files changed (114) hide show
  1. package/App.js +0 -1
  2. package/node_modules/.package-lock.json +26218 -26188
  3. package/node_modules/@fto-consult/common/babel.config.alias.js +18 -1
  4. package/node_modules/@fto-consult/common/package.json +1 -1
  5. package/node_modules/@react-native-async-storage/async-storage/LICENSE +21 -0
  6. package/node_modules/@react-native-async-storage/async-storage/README.md +27 -0
  7. package/node_modules/@react-native-async-storage/async-storage/RNCAsyncStorage.podspec +19 -0
  8. package/node_modules/@react-native-async-storage/async-storage/android/build.gradle +142 -0
  9. package/node_modules/@react-native-async-storage/async-storage/android/src/main/AndroidManifest.xml +6 -0
  10. package/node_modules/@react-native-async-storage/async-storage/android/src/main/java/com/reactnativecommunity/asyncstorage/AsyncLocalStorageUtil.java +178 -0
  11. package/node_modules/@react-native-async-storage/async-storage/android/src/main/java/com/reactnativecommunity/asyncstorage/AsyncStorageErrorUtil.java +45 -0
  12. package/node_modules/@react-native-async-storage/async-storage/android/src/main/java/com/reactnativecommunity/asyncstorage/AsyncStorageExpoMigration.java +154 -0
  13. package/node_modules/@react-native-async-storage/async-storage/android/src/main/java/com/reactnativecommunity/asyncstorage/AsyncStorageModule.java +424 -0
  14. package/node_modules/@react-native-async-storage/async-storage/android/src/main/java/com/reactnativecommunity/asyncstorage/AsyncStoragePackage.java +58 -0
  15. package/node_modules/@react-native-async-storage/async-storage/android/src/main/java/com/reactnativecommunity/asyncstorage/ReactDatabaseSupplier.java +163 -0
  16. package/node_modules/@react-native-async-storage/async-storage/android/src/main/java/com/reactnativecommunity/asyncstorage/SerialExecutor.java +40 -0
  17. package/node_modules/@react-native-async-storage/async-storage/android/src/main/java/com/reactnativecommunity/asyncstorage/next/ArgumentHelpers.kt +86 -0
  18. package/node_modules/@react-native-async-storage/async-storage/android/src/main/java/com/reactnativecommunity/asyncstorage/next/ErrorHelpers.kt +39 -0
  19. package/node_modules/@react-native-async-storage/async-storage/android/src/main/java/com/reactnativecommunity/asyncstorage/next/StorageModule.kt +90 -0
  20. package/node_modules/@react-native-async-storage/async-storage/android/src/main/java/com/reactnativecommunity/asyncstorage/next/StorageSupplier.kt +161 -0
  21. package/node_modules/@react-native-async-storage/async-storage/android/src/test/java/com/reactnativecommunity/asyncstorage/next/ArgumentHelpersTest.kt +93 -0
  22. package/node_modules/@react-native-async-storage/async-storage/android/src/test/java/com/reactnativecommunity/asyncstorage/next/StorageTest.kt +141 -0
  23. package/node_modules/@react-native-async-storage/async-storage/android/testresults.gradle +38 -0
  24. package/node_modules/@react-native-async-storage/async-storage/ios/RNCAsyncStorage.h +51 -0
  25. package/node_modules/@react-native-async-storage/async-storage/ios/RNCAsyncStorage.m +898 -0
  26. package/node_modules/@react-native-async-storage/async-storage/ios/RNCAsyncStorage.xcodeproj/project.pbxproj +283 -0
  27. package/node_modules/@react-native-async-storage/async-storage/ios/RNCAsyncStorageDelegate.h +73 -0
  28. package/node_modules/@react-native-async-storage/async-storage/jest/async-storage-mock.d.ts +9 -0
  29. package/node_modules/@react-native-async-storage/async-storage/jest/async-storage-mock.js +109 -0
  30. package/node_modules/@react-native-async-storage/async-storage/lib/commonjs/AsyncStorage.js +164 -0
  31. package/node_modules/@react-native-async-storage/async-storage/lib/commonjs/AsyncStorage.js.map +1 -0
  32. package/node_modules/@react-native-async-storage/async-storage/lib/commonjs/AsyncStorage.native.js +366 -0
  33. package/node_modules/@react-native-async-storage/async-storage/lib/commonjs/AsyncStorage.native.js.map +1 -0
  34. package/node_modules/@react-native-async-storage/async-storage/lib/commonjs/RCTAsyncStorage.js +30 -0
  35. package/node_modules/@react-native-async-storage/async-storage/lib/commonjs/RCTAsyncStorage.js.map +1 -0
  36. package/node_modules/@react-native-async-storage/async-storage/lib/commonjs/helpers.js +69 -0
  37. package/node_modules/@react-native-async-storage/async-storage/lib/commonjs/helpers.js.map +1 -0
  38. package/node_modules/@react-native-async-storage/async-storage/lib/commonjs/hooks.js +44 -0
  39. package/node_modules/@react-native-async-storage/async-storage/lib/commonjs/hooks.js.map +1 -0
  40. package/node_modules/@react-native-async-storage/async-storage/lib/commonjs/index.js +22 -0
  41. package/node_modules/@react-native-async-storage/async-storage/lib/commonjs/index.js.map +1 -0
  42. package/node_modules/@react-native-async-storage/async-storage/lib/commonjs/shouldFallbackToLegacyNativeModule.js +39 -0
  43. package/node_modules/@react-native-async-storage/async-storage/lib/commonjs/shouldFallbackToLegacyNativeModule.js.map +1 -0
  44. package/node_modules/@react-native-async-storage/async-storage/lib/commonjs/types.js +2 -0
  45. package/node_modules/@react-native-async-storage/async-storage/lib/commonjs/types.js.map +1 -0
  46. package/node_modules/@react-native-async-storage/async-storage/lib/module/AsyncStorage.js +153 -0
  47. package/node_modules/@react-native-async-storage/async-storage/lib/module/AsyncStorage.js.map +1 -0
  48. package/node_modules/@react-native-async-storage/async-storage/lib/module/AsyncStorage.native.js +348 -0
  49. package/node_modules/@react-native-async-storage/async-storage/lib/module/AsyncStorage.native.js.map +1 -0
  50. package/node_modules/@react-native-async-storage/async-storage/lib/module/RCTAsyncStorage.js +20 -0
  51. package/node_modules/@react-native-async-storage/async-storage/lib/module/RCTAsyncStorage.js.map +1 -0
  52. package/node_modules/@react-native-async-storage/async-storage/lib/module/helpers.js +56 -0
  53. package/node_modules/@react-native-async-storage/async-storage/lib/module/helpers.js.map +1 -0
  54. package/node_modules/@react-native-async-storage/async-storage/lib/module/hooks.js +34 -0
  55. package/node_modules/@react-native-async-storage/async-storage/lib/module/hooks.js.map +1 -0
  56. package/node_modules/@react-native-async-storage/async-storage/lib/module/index.js +4 -0
  57. package/node_modules/@react-native-async-storage/async-storage/lib/module/index.js.map +1 -0
  58. package/node_modules/@react-native-async-storage/async-storage/lib/module/shouldFallbackToLegacyNativeModule.js +31 -0
  59. package/node_modules/@react-native-async-storage/async-storage/lib/module/shouldFallbackToLegacyNativeModule.js.map +1 -0
  60. package/node_modules/@react-native-async-storage/async-storage/lib/module/types.js +2 -0
  61. package/node_modules/@react-native-async-storage/async-storage/lib/module/types.js.map +1 -0
  62. package/node_modules/@react-native-async-storage/async-storage/lib/typescript/AsyncStorage.d.ts +10 -0
  63. package/node_modules/@react-native-async-storage/async-storage/lib/typescript/AsyncStorage.native.d.ts +16 -0
  64. package/node_modules/@react-native-async-storage/async-storage/lib/typescript/RCTAsyncStorage.d.ts +2 -0
  65. package/node_modules/@react-native-async-storage/async-storage/lib/typescript/helpers.d.ts +5 -0
  66. package/node_modules/@react-native-async-storage/async-storage/lib/typescript/hooks.d.ts +2 -0
  67. package/node_modules/@react-native-async-storage/async-storage/lib/typescript/index.d.ts +4 -0
  68. package/node_modules/@react-native-async-storage/async-storage/lib/typescript/shouldFallbackToLegacyNativeModule.d.ts +1 -0
  69. package/node_modules/@react-native-async-storage/async-storage/lib/typescript/types.d.ts +113 -0
  70. package/node_modules/@react-native-async-storage/async-storage/macos/RNCAsyncStorage.xcodeproj/project.pbxproj +385 -0
  71. package/node_modules/@react-native-async-storage/async-storage/macos/RNCAsyncStorage.xcodeproj/xcshareddata/xcschemes/RNCAsyncStorage-macOS.xcscheme +67 -0
  72. package/node_modules/@react-native-async-storage/async-storage/macos/RNCAsyncStorage.xcodeproj/xcshareddata/xcschemes/RNCAsyncStorage.xcscheme +67 -0
  73. package/node_modules/@react-native-async-storage/async-storage/package.json +197 -0
  74. package/node_modules/@react-native-async-storage/async-storage/src/AsyncStorage.native.ts +356 -0
  75. package/node_modules/@react-native-async-storage/async-storage/src/AsyncStorage.ts +173 -0
  76. package/node_modules/@react-native-async-storage/async-storage/src/RCTAsyncStorage.ts +28 -0
  77. package/node_modules/@react-native-async-storage/async-storage/src/helpers.ts +74 -0
  78. package/node_modules/@react-native-async-storage/async-storage/src/hooks.ts +11 -0
  79. package/node_modules/@react-native-async-storage/async-storage/src/index.ts +7 -0
  80. package/node_modules/@react-native-async-storage/async-storage/src/shouldFallbackToLegacyNativeModule.ts +34 -0
  81. package/node_modules/@react-native-async-storage/async-storage/src/types.ts +155 -0
  82. package/node_modules/@react-native-async-storage/async-storage/windows/ReactNativeAsyncStorage/PropertySheet.props +16 -0
  83. package/node_modules/@react-native-async-storage/async-storage/windows/ReactNativeAsyncStorage/ReactNativeAsyncStorage.vcxproj +172 -0
  84. package/node_modules/@react-native-async-storage/async-storage/windows/ReactNativeAsyncStorage/ReactNativeAsyncStorage.vcxproj.filters +34 -0
  85. package/node_modules/@react-native-async-storage/async-storage/windows/ReactNativeAsyncStorage/packages.config +4 -0
  86. package/node_modules/@react-native-async-storage/async-storage/windows/ReactNativeAsyncStorage.sln +172 -0
  87. package/node_modules/@react-native-async-storage/async-storage/windows/ReactNativeAsyncStorage61/PropertySheet.props +16 -0
  88. package/node_modules/@react-native-async-storage/async-storage/windows/ReactNativeAsyncStorage61/ReactNativeAsyncStorage61.vcxproj +157 -0
  89. package/node_modules/@react-native-async-storage/async-storage/windows/ReactNativeAsyncStorage61/ReactNativeAsyncStorage61.vcxproj.filters +34 -0
  90. package/node_modules/@react-native-async-storage/async-storage/windows/ReactNativeAsyncStorage61/packages.config +4 -0
  91. package/node_modules/@react-native-async-storage/async-storage/windows/ReactNativeAsyncStorage61.sln +195 -0
  92. package/node_modules/@react-native-async-storage/async-storage/windows/ReactNativeAsyncStorage62.sln +192 -0
  93. package/node_modules/@react-native-async-storage/async-storage/windows/code/DBStorage.cpp +599 -0
  94. package/node_modules/@react-native-async-storage/async-storage/windows/code/DBStorage.h +162 -0
  95. package/node_modules/@react-native-async-storage/async-storage/windows/code/RNCAsyncStorage.h +118 -0
  96. package/node_modules/@react-native-async-storage/async-storage/windows/code/ReactNativeAsyncStorage.def +3 -0
  97. package/node_modules/@react-native-async-storage/async-storage/windows/code/ReactPackageProvider.cpp +20 -0
  98. package/node_modules/@react-native-async-storage/async-storage/windows/code/ReactPackageProvider.h +23 -0
  99. package/node_modules/@react-native-async-storage/async-storage/windows/code/ReactPackageProvider.idl +7 -0
  100. package/node_modules/@react-native-async-storage/async-storage/windows/code/pch.cpp +3 -0
  101. package/node_modules/@react-native-async-storage/async-storage/windows/code/pch.h +15 -0
  102. package/node_modules/merge-options/index.d.ts +2 -0
  103. package/node_modules/merge-options/index.js +171 -0
  104. package/node_modules/merge-options/index.mjs +8 -0
  105. package/node_modules/merge-options/license +21 -0
  106. package/node_modules/merge-options/node_modules/is-plain-obj/index.d.ts +29 -0
  107. package/node_modules/merge-options/node_modules/is-plain-obj/index.js +10 -0
  108. package/node_modules/merge-options/node_modules/is-plain-obj/license +9 -0
  109. package/node_modules/merge-options/node_modules/is-plain-obj/package.json +38 -0
  110. package/node_modules/merge-options/node_modules/is-plain-obj/readme.md +54 -0
  111. package/node_modules/merge-options/package.json +59 -0
  112. package/node_modules/merge-options/readme.md +130 -0
  113. package/package.json +131 -130
  114. package/src/components/Chart/appexChart/appexChart.html +23 -23
@@ -0,0 +1,197 @@
1
+ {
2
+ "name": "@react-native-async-storage/async-storage",
3
+ "version": "1.18.2",
4
+ "description": "Asynchronous, persistent, key-value storage system for React Native.",
5
+ "main": "lib/commonjs/index.js",
6
+ "module": "lib/module/index.js",
7
+ "react-native": "src/index.ts",
8
+ "types": "lib/typescript/index.d.ts",
9
+ "files": [
10
+ "RNCAsyncStorage.podspec",
11
+ "android/build.gradle",
12
+ "android/src",
13
+ "android/testresults.gradle",
14
+ "ios/",
15
+ "jest/",
16
+ "lib/",
17
+ "macos/",
18
+ "src/",
19
+ "windows/"
20
+ ],
21
+ "author": "Krzysztof Borowy <hello@krizzu.dev>",
22
+ "contributors": [
23
+ "Evan Bacon <bacon@expo.io> (https://github.com/evanbacon)",
24
+ "Tommy Nguyen <4123478+tido64@users.noreply.github.com> (https://github.com/tido64)"
25
+ ],
26
+ "homepage": "https://github.com/react-native-async-storage/async-storage#readme",
27
+ "license": "MIT",
28
+ "keywords": [
29
+ "react-native",
30
+ "react native",
31
+ "async storage",
32
+ "asyncstorage",
33
+ "storage"
34
+ ],
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "https://github.com/react-native-async-storage/async-storage.git"
38
+ },
39
+ "scripts": {
40
+ "format": "concurrently yarn:format:*",
41
+ "format:c": "clang-format -i $(git ls-files '*.cpp' '*.h' '*.m' '*.mm')",
42
+ "format:js": "prettier --write $(git ls-files '*.js' '*.json' '*.md' '*.ts' '*.tsx' '*.yml')",
43
+ "prepare": "bob build",
44
+ "start": "react-native start",
45
+ "start:android": "react-native run-android",
46
+ "start:ios": "react-native run-ios --project-path example/ios",
47
+ "start:macos": "react-native run-macos --project-path example/macos --scheme AsyncStorageExample",
48
+ "start:web": "expo start:web",
49
+ "start:windows": "install-windows-test-app -p example/windows && react-native run-windows --root example --logging --no-packager --no-telemetry",
50
+ "build:e2e:android": "scripts/android_e2e.sh 'build'",
51
+ "build:e2e:ios": "scripts/ios_e2e.sh 'build'",
52
+ "build:e2e:macos": "scripts/macos_e2e.sh 'build'",
53
+ "bundle:android": "scripts/android_e2e.sh 'bundle'",
54
+ "bundle:ios": "scripts/ios_e2e.sh 'bundle'",
55
+ "bundle:macos": "react-native bundle --entry-file index.ts --platform macos --bundle-output example/index.macos.jsbundle",
56
+ "test": "concurrently -n lint,ts yarn:test:lint yarn:test:ts",
57
+ "test:lint": "eslint src/**/*.ts example/**/*.ts jest/*.js",
58
+ "test:ts": "tsc --project tsconfig.all.json",
59
+ "test:e2e:android": "detox test -c android.emu.release --maxConcurrency 1",
60
+ "test:e2e:ios": "detox test -c ios.sim.release --maxConcurrency 1",
61
+ "test:e2e:macos": "scripts/macos_e2e.sh 'test'"
62
+ },
63
+ "dependencies": {
64
+ "merge-options": "^3.0.4"
65
+ },
66
+ "peerDependencies": {
67
+ "react-native": "^0.0.0-0 || 0.60 - 0.72 || 1000.0.0"
68
+ },
69
+ "devDependencies": {
70
+ "@babel/core": "^7.12.0",
71
+ "@babel/preset-env": "^7.1.6",
72
+ "@react-native-community/eslint-config": "^3.0.0",
73
+ "@semantic-release/changelog": "^6.0.0",
74
+ "@semantic-release/git": "^10.0.0",
75
+ "@types/lodash": "^4.14.184",
76
+ "@types/react": "^17.0.0",
77
+ "@types/react-native": "^0.68.0",
78
+ "concurrently": "^6.4.0",
79
+ "detox": "^19.4.5",
80
+ "eslint": "^8.0.0",
81
+ "expo": "^45.0.0",
82
+ "jest": "^26.6.3",
83
+ "jest-circus": "^26.6.1",
84
+ "lodash": "^4.17.21",
85
+ "prettier": "^2.5.1",
86
+ "react": "17.0.2",
87
+ "react-dom": "17.0.2",
88
+ "react-native": "^0.68.0",
89
+ "react-native-builder-bob": "^0.18.0",
90
+ "react-native-macos": "^0.68.0",
91
+ "react-native-test-app": "^2.3.10",
92
+ "react-native-web": "^0.17.0",
93
+ "react-native-windows": "^0.68.0",
94
+ "react-test-renderer": "17.0.2",
95
+ "semantic-release": "^19.0.0",
96
+ "typescript": "^4.5.0"
97
+ },
98
+ "packageManager": "yarn@3.4.1",
99
+ "resolutions": {
100
+ "body-parser/qs": "^6.7.3",
101
+ "find-babel-config/json5": "^2.1.1",
102
+ "npm/chalk": "^4.1.2"
103
+ },
104
+ "jest": {
105
+ "preset": "react-native",
106
+ "setupFiles": [
107
+ "./example/jest.setup.js"
108
+ ]
109
+ },
110
+ "detox": {
111
+ "test-runner": "jest",
112
+ "runner-config": "example/e2e/config.json",
113
+ "configurations": {
114
+ "ios.sim.release": {
115
+ "binaryPath": "example/ios/build/Build/Products/Release-iphonesimulator/ReactTestApp.app",
116
+ "type": "ios.simulator",
117
+ "device": {
118
+ "type": "iPhone 13"
119
+ }
120
+ },
121
+ "android.emu.release": {
122
+ "binaryPath": "example/android/app/build/outputs/apk/release/app-release.apk",
123
+ "testBinaryPath": "example/android/app/build/outputs/apk/androidTest/release/app-release-androidTest.apk",
124
+ "type": "android.emulator",
125
+ "device": {
126
+ "avdName": "E2E_API_30",
127
+ "utilBinaryPaths": [
128
+ "/var/tmp/test-butler.apk"
129
+ ]
130
+ }
131
+ },
132
+ "android.emu.release.next": {
133
+ "binaryPath": "example/android/app/build/outputs/apk/next/app-next.apk",
134
+ "testBinaryPath": "example/android/app/build/outputs/apk/androidTest/release/app-release-androidTest.apk",
135
+ "type": "android.emulator",
136
+ "device": {
137
+ "avdName": "E2E_API_30",
138
+ "utilBinaryPaths": [
139
+ "/var/tmp/test-butler.apk"
140
+ ]
141
+ }
142
+ }
143
+ }
144
+ },
145
+ "eslintConfig": {
146
+ "extends": [
147
+ "@react-native-community",
148
+ "plugin:jest/recommended"
149
+ ],
150
+ "rules": {
151
+ "dot-notation": "off"
152
+ }
153
+ },
154
+ "prettier": {
155
+ "endOfLine": "auto",
156
+ "singleQuote": true,
157
+ "overrides": [
158
+ {
159
+ "files": "*.md",
160
+ "options": {
161
+ "proseWrap": "always"
162
+ }
163
+ }
164
+ ]
165
+ },
166
+ "react-native-builder-bob": {
167
+ "source": "src",
168
+ "output": "lib",
169
+ "targets": [
170
+ "commonjs",
171
+ "module",
172
+ "typescript"
173
+ ]
174
+ },
175
+ "release": {
176
+ "branches": [
177
+ "master"
178
+ ],
179
+ "plugins": [
180
+ "@semantic-release/commit-analyzer",
181
+ "@semantic-release/release-notes-generator",
182
+ "@semantic-release/changelog",
183
+ "@semantic-release/npm",
184
+ "@semantic-release/github",
185
+ [
186
+ "@semantic-release/git",
187
+ {
188
+ "assets": [
189
+ "CHANGELOG.md",
190
+ "package.json"
191
+ ],
192
+ "message": "chore(release): ${nextRelease.version} [skip ci]"
193
+ }
194
+ ]
195
+ ]
196
+ }
197
+ }
@@ -0,0 +1,356 @@
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
+
8
+ import {
9
+ checkValidArgs,
10
+ checkValidInput,
11
+ convertError,
12
+ convertErrors,
13
+ } from './helpers';
14
+ import RCTAsyncStorage from './RCTAsyncStorage';
15
+ import type {
16
+ AsyncStorageStatic,
17
+ ErrorLike,
18
+ KeyValuePair,
19
+ MultiRequest,
20
+ } from './types';
21
+
22
+ if (!RCTAsyncStorage) {
23
+ throw new Error(`[@RNC/AsyncStorage]: NativeModule: AsyncStorage is null.
24
+
25
+ To fix this issue try these steps:
26
+
27
+ • Rebuild and restart the app.
28
+
29
+ • Run the packager with \`--reset-cache\` flag.
30
+
31
+ • If you are using CocoaPods on iOS, run \`pod install\` in the \`ios\` directory and then rebuild and re-run the app.
32
+
33
+ • 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
34
+
35
+ 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
36
+ `);
37
+ }
38
+
39
+ /**
40
+ * `AsyncStorage` is a simple, unencrypted, asynchronous, persistent, key-value
41
+ * storage system that is global to the app. It should be used instead of
42
+ * LocalStorage.
43
+ *
44
+ * See https://react-native-async-storage.github.io/async-storage/docs/api
45
+ */
46
+ const AsyncStorage = ((): AsyncStorageStatic => {
47
+ let _getRequests: MultiRequest[] = [];
48
+ let _getKeys: string[] = [];
49
+ let _immediate: ReturnType<typeof setImmediate> | null = null;
50
+
51
+ return {
52
+ /**
53
+ * Fetches an item for a `key` and invokes a callback upon completion.
54
+ *
55
+ * See https://react-native-async-storage.github.io/async-storage/docs/api#getitem
56
+ */
57
+ getItem: (key, callback) => {
58
+ return new Promise((resolve, reject) => {
59
+ checkValidInput(key);
60
+ RCTAsyncStorage.multiGet(
61
+ [key],
62
+ (errors?: ErrorLike[], result?: string[][]) => {
63
+ // Unpack result to get value from [[key,value]]
64
+ const value = result?.[0]?.[1] ? result[0][1] : null;
65
+ const errs = convertErrors(errors);
66
+ callback?.(errs?.[0], value);
67
+ if (errs) {
68
+ reject(errs[0]);
69
+ } else {
70
+ resolve(value);
71
+ }
72
+ }
73
+ );
74
+ });
75
+ },
76
+
77
+ /**
78
+ * Sets the value for a `key` and invokes a callback upon completion.
79
+ *
80
+ * See https://react-native-async-storage.github.io/async-storage/docs/api#setitem
81
+ */
82
+ setItem: (key, value, callback) => {
83
+ return new Promise((resolve, reject) => {
84
+ checkValidInput(key, value);
85
+ RCTAsyncStorage.multiSet([[key, value]], (errors?: ErrorLike[]) => {
86
+ const errs = convertErrors(errors);
87
+ callback?.(errs?.[0]);
88
+ if (errs) {
89
+ reject(errs[0]);
90
+ } else {
91
+ resolve();
92
+ }
93
+ });
94
+ });
95
+ },
96
+
97
+ /**
98
+ * Removes an item for a `key` and invokes a callback upon completion.
99
+ *
100
+ * See https://react-native-async-storage.github.io/async-storage/docs/api#removeitem
101
+ */
102
+ removeItem: (key, callback) => {
103
+ return new Promise((resolve, reject) => {
104
+ checkValidInput(key);
105
+ RCTAsyncStorage.multiRemove([key], (errors?: ErrorLike[]) => {
106
+ const errs = convertErrors(errors);
107
+ callback?.(errs?.[0]);
108
+ if (errs) {
109
+ reject(errs[0]);
110
+ } else {
111
+ resolve();
112
+ }
113
+ });
114
+ });
115
+ },
116
+
117
+ /**
118
+ * Merges an existing `key` value with an input value, assuming both values
119
+ * are stringified JSON.
120
+ *
121
+ * See https://react-native-async-storage.github.io/async-storage/docs/api#mergeitem
122
+ */
123
+ mergeItem: (key, value, callback) => {
124
+ return new Promise((resolve, reject) => {
125
+ checkValidInput(key, value);
126
+ RCTAsyncStorage.multiMerge([[key, value]], (errors?: ErrorLike[]) => {
127
+ const errs = convertErrors(errors);
128
+ callback?.(errs?.[0]);
129
+ if (errs) {
130
+ reject(errs[0]);
131
+ } else {
132
+ resolve();
133
+ }
134
+ });
135
+ });
136
+ },
137
+
138
+ /**
139
+ * Erases *all* `AsyncStorage` for all clients, libraries, etc. You probably
140
+ * don't want to call this; use `removeItem` or `multiRemove` to clear only
141
+ * your app's keys.
142
+ *
143
+ * See https://react-native-async-storage.github.io/async-storage/docs/api#clear
144
+ */
145
+ clear: (callback) => {
146
+ return new Promise((resolve, reject) => {
147
+ RCTAsyncStorage.clear((error?: ErrorLike) => {
148
+ const err = convertError(error);
149
+ callback?.(err);
150
+ if (err) {
151
+ reject(err);
152
+ } else {
153
+ resolve();
154
+ }
155
+ });
156
+ });
157
+ },
158
+
159
+ /**
160
+ * Gets *all* keys known to your app; for all callers, libraries, etc.
161
+ *
162
+ * See https://react-native-async-storage.github.io/async-storage/docs/api#getallkeys
163
+ */
164
+ getAllKeys: (callback) => {
165
+ return new Promise((resolve, reject) => {
166
+ RCTAsyncStorage.getAllKeys((error?: ErrorLike, keys?: string[]) => {
167
+ const err = convertError(error);
168
+ callback?.(err, keys);
169
+ if (keys) {
170
+ resolve(keys);
171
+ } else {
172
+ reject(err);
173
+ }
174
+ });
175
+ });
176
+ },
177
+
178
+ /**
179
+ * The following batched functions are useful for executing a lot of
180
+ * operations at once, allowing for native optimizations and provide the
181
+ * convenience of a single callback after all operations are complete.
182
+ *
183
+ * These functions return arrays of errors, potentially one for every key.
184
+ * For key-specific errors, the Error object will have a key property to
185
+ * indicate which key caused the error.
186
+ */
187
+
188
+ /**
189
+ * Flushes any pending requests using a single batch call to get the data.
190
+ *
191
+ * See https://react-native-async-storage.github.io/async-storage/docs/api#flushgetrequests
192
+ * */
193
+ flushGetRequests: () => {
194
+ const getRequests = _getRequests;
195
+ const getKeys = _getKeys;
196
+
197
+ _getRequests = [];
198
+ _getKeys = [];
199
+
200
+ RCTAsyncStorage.multiGet(
201
+ getKeys,
202
+ (errors?: ErrorLike[], result?: string[][]) => {
203
+ // Even though the runtime complexity of this is theoretically worse vs if we used a map,
204
+ // it's much, much faster in practice for the data sets we deal with (we avoid
205
+ // allocating result pair arrays). This was heavily benchmarked.
206
+ //
207
+ // Is there a way to avoid using the map but fix the bug in this breaking test?
208
+ // https://github.com/facebook/react-native/commit/8dd8ad76579d7feef34c014d387bf02065692264
209
+ const map: Record<string, string> = {};
210
+ result?.forEach(([key, value]) => {
211
+ map[key] = value;
212
+ return value;
213
+ });
214
+ const reqLength = getRequests.length;
215
+
216
+ /**
217
+ * As mentioned few lines above, this method could be called with the array of potential error,
218
+ * in case of anything goes wrong. The problem is, if any of the batched calls fails
219
+ * the rest of them would fail too, but the error would be consumed by just one. The rest
220
+ * would simply return `undefined` as their result, rendering false negatives.
221
+ *
222
+ * In order to avoid this situation, in case of any call failing,
223
+ * the rest of them will be rejected as well (with the same error).
224
+ */
225
+ const errorList = convertErrors(errors);
226
+ const error = errorList?.length ? errorList[0] : null;
227
+
228
+ for (let i = 0; i < reqLength; i++) {
229
+ const request = getRequests[i];
230
+ if (error) {
231
+ request.callback?.(errorList);
232
+ request.reject?.(error);
233
+ continue;
234
+ }
235
+ const requestResult = request.keys.map<KeyValuePair>((key) => [
236
+ key,
237
+ map[key],
238
+ ]);
239
+ request.callback?.(null, requestResult);
240
+ request.resolve?.(requestResult);
241
+ }
242
+ }
243
+ );
244
+ },
245
+
246
+ /**
247
+ * This allows you to batch the fetching of items given an array of `key`
248
+ * inputs. Your callback will be invoked with an array of corresponding
249
+ * key-value pairs found.
250
+ *
251
+ * See https://react-native-async-storage.github.io/async-storage/docs/api#multiget
252
+ */
253
+ multiGet: (keys, callback) => {
254
+ if (!_immediate) {
255
+ _immediate = setImmediate(() => {
256
+ _immediate = null;
257
+ AsyncStorage.flushGetRequests();
258
+ });
259
+ }
260
+
261
+ const getRequest: MultiRequest = {
262
+ keys: keys,
263
+ callback: callback,
264
+ // do we need this?
265
+ keyIndex: _getKeys.length,
266
+ resolve: null as any,
267
+ reject: null as any,
268
+ };
269
+
270
+ const promiseResult = new Promise<readonly KeyValuePair[]>(
271
+ (resolve, reject) => {
272
+ getRequest.resolve = resolve;
273
+ getRequest.reject = reject;
274
+ }
275
+ );
276
+
277
+ _getRequests.push(getRequest);
278
+ // avoid fetching duplicates
279
+ keys.forEach((key) => {
280
+ if (_getKeys.indexOf(key) === -1) {
281
+ _getKeys.push(key);
282
+ }
283
+ });
284
+
285
+ return promiseResult;
286
+ },
287
+
288
+ /**
289
+ * Use this as a batch operation for storing multiple key-value pairs. When
290
+ * the operation completes you'll get a single callback with any errors.
291
+ *
292
+ * See https://react-native-async-storage.github.io/async-storage/docs/api#multiset
293
+ */
294
+ multiSet: (keyValuePairs, callback) => {
295
+ checkValidArgs(keyValuePairs, callback);
296
+ return new Promise((resolve, reject) => {
297
+ keyValuePairs.forEach(([key, value]) => {
298
+ checkValidInput(key, value);
299
+ });
300
+
301
+ RCTAsyncStorage.multiSet(keyValuePairs, (errors?: ErrorLike[]) => {
302
+ const error = convertErrors(errors);
303
+ callback?.(error);
304
+ if (error) {
305
+ reject(error);
306
+ } else {
307
+ resolve();
308
+ }
309
+ });
310
+ });
311
+ },
312
+
313
+ /**
314
+ * Call this to batch the deletion of all keys in the `keys` array.
315
+ *
316
+ * See https://react-native-async-storage.github.io/async-storage/docs/api#multiremove
317
+ */
318
+ multiRemove: (keys, callback) => {
319
+ return new Promise((resolve, reject) => {
320
+ keys.forEach((key) => checkValidInput(key));
321
+
322
+ RCTAsyncStorage.multiRemove(keys, (errors?: ErrorLike[]) => {
323
+ const error = convertErrors(errors);
324
+ callback?.(error);
325
+ if (error) {
326
+ reject(error);
327
+ } else {
328
+ resolve();
329
+ }
330
+ });
331
+ });
332
+ },
333
+
334
+ /**
335
+ * Batch operation to merge in existing and new values for a given set of
336
+ * keys. This assumes that the values are stringified JSON.
337
+ *
338
+ * See https://react-native-async-storage.github.io/async-storage/docs/api#multimerge
339
+ */
340
+ multiMerge: (keyValuePairs, callback) => {
341
+ return new Promise((resolve, reject) => {
342
+ RCTAsyncStorage.multiMerge(keyValuePairs, (errors?: ErrorLike[]) => {
343
+ const error = convertErrors(errors);
344
+ callback?.(error);
345
+ if (error) {
346
+ reject(error);
347
+ } else {
348
+ resolve();
349
+ }
350
+ });
351
+ });
352
+ },
353
+ };
354
+ })();
355
+
356
+ export default AsyncStorage;