react-native-nitro-storage 0.12.0 → 0.13.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/CHANGELOG.md +32 -0
- package/README.md +50 -12
- package/SECURITY.md +2 -2
- package/android/build.gradle +5 -0
- package/android/src/main/cpp/AndroidStorageAdapterCpp.cpp +12 -13
- package/android/src/main/cpp/JniSize.hpp +21 -0
- package/android/src/main/java/com/nitrostorage/AndroidStorageAdapter.kt +94 -7
- package/android/src/main/java/com/nitrostorage/DiskSqliteStore.kt +147 -34
- package/cpp/bindings/HybridStorage.cpp +12 -4
- package/cpp/core/SqliteDiskStore.cpp +172 -26
- package/cpp/core/SqliteDiskStore.hpp +10 -1
- package/docs/api-reference.md +11 -11
- package/docs/native-libraries.md +28 -0
- package/ios/IOSStorageAdapterCpp.mm +89 -22
- package/lib/commonjs/storage-core.js +26 -6
- package/lib/commonjs/storage-core.js.map +1 -1
- package/lib/module/storage-core.js +26 -6
- package/lib/module/storage-core.js.map +1 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/index.web.d.ts.map +1 -1
- package/lib/typescript/storage-core.d.ts.map +1 -1
- package/lib/typescript/testing.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/storage-core.ts +26 -6
package/src/storage-core.ts
CHANGED
|
@@ -574,8 +574,9 @@ export function createStorageCore(
|
|
|
574
574
|
operation: StorageChangeOperation,
|
|
575
575
|
source: StorageChangeSource,
|
|
576
576
|
changes: StorageKeyChangeEvent[],
|
|
577
|
+
emitWhenEmpty = false,
|
|
577
578
|
): void {
|
|
578
|
-
if (changes.length === 0) {
|
|
579
|
+
if (changes.length === 0 && !emitWhenEmpty) {
|
|
579
580
|
return;
|
|
580
581
|
}
|
|
581
582
|
|
|
@@ -1024,9 +1025,18 @@ export function createStorageCore(
|
|
|
1024
1025
|
return;
|
|
1025
1026
|
}
|
|
1026
1027
|
measureOperation("storage:clear", scope, () => {
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1028
|
+
let previousValues: Record<string, string> = {};
|
|
1029
|
+
let previousValuesUnreadable = false;
|
|
1030
|
+
if (shouldReadPreviousEventValues(scope)) {
|
|
1031
|
+
try {
|
|
1032
|
+
previousValues = storage.getAll(scope);
|
|
1033
|
+
} catch (error) {
|
|
1034
|
+
if (scope !== StorageScope.Disk) {
|
|
1035
|
+
throw error;
|
|
1036
|
+
}
|
|
1037
|
+
previousValuesUnreadable = true;
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1030
1040
|
if (scope === StorageScope.Memory) {
|
|
1031
1041
|
memoryStore.clear();
|
|
1032
1042
|
memoryExpirationDeadlines.clear();
|
|
@@ -1049,9 +1059,15 @@ export function createStorageCore(
|
|
|
1049
1059
|
return;
|
|
1050
1060
|
}
|
|
1051
1061
|
|
|
1062
|
+
let diskFlushFailed = false;
|
|
1052
1063
|
if (scope === StorageScope.Disk) {
|
|
1053
|
-
|
|
1054
|
-
|
|
1064
|
+
try {
|
|
1065
|
+
flushDiskWrites();
|
|
1066
|
+
durability.clearAllPendingDiskWrites();
|
|
1067
|
+
} catch {
|
|
1068
|
+
diskFlushFailed = true;
|
|
1069
|
+
previousValuesUnreadable = shouldReadPreviousEventValues(scope);
|
|
1070
|
+
}
|
|
1055
1071
|
}
|
|
1056
1072
|
|
|
1057
1073
|
if (scope === StorageScope.Secure) {
|
|
@@ -1061,6 +1077,9 @@ export function createStorageCore(
|
|
|
1061
1077
|
|
|
1062
1078
|
clearScopeRawCache(scope);
|
|
1063
1079
|
adapter.backend.clear(scope);
|
|
1080
|
+
if (diskFlushFailed) {
|
|
1081
|
+
durability.clearAllPendingDiskWrites();
|
|
1082
|
+
}
|
|
1064
1083
|
emitBatchChange(
|
|
1065
1084
|
scope,
|
|
1066
1085
|
"clear",
|
|
@@ -1075,6 +1094,7 @@ export function createStorageCore(
|
|
|
1075
1094
|
adapter.changeSource,
|
|
1076
1095
|
),
|
|
1077
1096
|
),
|
|
1097
|
+
previousValuesUnreadable,
|
|
1078
1098
|
);
|
|
1079
1099
|
});
|
|
1080
1100
|
},
|