react-native-nitro-storage 0.6.0 → 0.7.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 +11 -0
- package/README.md +22 -9
- package/android/src/main/java/com/nitrostorage/AndroidStorageAdapter.kt +225 -76
- package/app.plugin.js +2 -0
- package/cpp/bindings/HybridStorage.cpp +4 -12
- package/docs/secure-storage.md +4 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.web.js.map +1 -1
- package/lib/commonjs/indexeddb-backend.js.map +1 -1
- package/lib/commonjs/internal.js.map +1 -1
- package/lib/commonjs/storage-core.js.map +1 -1
- package/lib/commonjs/storage-events.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js.map +1 -1
- package/lib/module/indexeddb-backend.js.map +1 -1
- package/lib/module/internal.js.map +1 -1
- package/lib/module/storage-core.js.map +1 -1
- package/lib/module/storage-events.js.map +1 -1
- package/lib/typescript/index.d.ts +6 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/index.web.d.ts +6 -1
- package/lib/typescript/index.web.d.ts.map +1 -1
- package/lib/typescript/indexeddb-backend.d.ts.map +1 -1
- package/lib/typescript/storage-core.d.ts +11 -1
- package/lib/typescript/storage-core.d.ts.map +1 -1
- package/lib/typescript/storage-events.d.ts.map +1 -1
- package/lib/typescript/testing.d.ts +12 -2
- package/lib/typescript/testing.d.ts.map +1 -1
- package/package.json +5 -6
- package/src/index.ts +1 -2
- package/src/index.web.ts +1 -2
- package/src/indexeddb-backend.ts +1 -2
- package/src/internal.ts +1 -1
- package/src/storage-core.ts +19 -2
- package/src/storage-events.ts +1 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nitro-storage",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Synchronous React Native storage powered by Nitro Modules and JSI: typed Memory, Disk, Keychain/Android Keystore secure storage, biometric auth, MMKV migration, Expo, Zustand/Jotai persistence, and web IndexedDB support.",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -122,16 +122,15 @@
|
|
|
122
122
|
"registry": "https://registry.npmjs.org/"
|
|
123
123
|
},
|
|
124
124
|
"devDependencies": {
|
|
125
|
-
"@expo/config-plugins": "^
|
|
126
|
-
"@react-native/babel-preset": "^0.
|
|
127
|
-
"@testing-library/react-hooks": "^8.0.1",
|
|
125
|
+
"@expo/config-plugins": "^57.0.6",
|
|
126
|
+
"@react-native/babel-preset": "^0.86.2",
|
|
128
127
|
"@testing-library/react-native": "^13.3.3",
|
|
129
|
-
"@types/react": "~19.2.
|
|
128
|
+
"@types/react": "~19.2.17"
|
|
130
129
|
},
|
|
131
130
|
"peerDependencies": {
|
|
132
131
|
"react": ">=18.2.0",
|
|
133
132
|
"react-native": ">=0.75.0",
|
|
134
|
-
"react-native-nitro-modules": ">=0.
|
|
133
|
+
"react-native-nitro-modules": ">=0.36.4 <0.37.0"
|
|
135
134
|
},
|
|
136
135
|
"react-native-builder-bob": {
|
|
137
136
|
"source": "src",
|
package/src/index.ts
CHANGED
package/src/index.web.ts
CHANGED
package/src/indexeddb-backend.ts
CHANGED
|
@@ -110,8 +110,7 @@ export async function createIndexedDBBackend(
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
const data = event.data as
|
|
113
|
-
|
|
114
|
-
| undefined;
|
|
113
|
+
(WebStorageChangeEvent & { sourceId?: string }) | undefined;
|
|
115
114
|
if (!data || data.sourceId === sourceId) {
|
|
116
115
|
return;
|
|
117
116
|
}
|
package/src/internal.ts
CHANGED
|
@@ -99,7 +99,7 @@ export function serializeWithPrimitiveFastPath<T>(value: T): string {
|
|
|
99
99
|
if (Number.isFinite(value)) {
|
|
100
100
|
return PRIM_NUMBER_PREFIX + String(value);
|
|
101
101
|
}
|
|
102
|
-
if (Number.isNaN(value
|
|
102
|
+
if (Number.isNaN(value)) {
|
|
103
103
|
return PRIM_NAN;
|
|
104
104
|
}
|
|
105
105
|
if (value === Infinity) {
|
package/src/storage-core.ts
CHANGED
|
@@ -158,6 +158,19 @@ export type StorageBatchSetItem<T> = {
|
|
|
158
158
|
value: T;
|
|
159
159
|
};
|
|
160
160
|
|
|
161
|
+
type StorageBatchSetCandidate = {
|
|
162
|
+
get: () => unknown;
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
type StorageBatchSetEntries<
|
|
166
|
+
TItems extends readonly StorageBatchSetCandidate[],
|
|
167
|
+
> = {
|
|
168
|
+
[Index in keyof TItems]: {
|
|
169
|
+
item: TItems[Index] & StorageItem<ReturnType<TItems[Index]["get"]>>;
|
|
170
|
+
value: ReturnType<TItems[Index]["get"]>;
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
|
|
161
174
|
export type StorageKeyRef = string | { readonly key: string };
|
|
162
175
|
|
|
163
176
|
export type StorageClearOptions = {
|
|
@@ -1050,7 +1063,7 @@ export function createStorageCore(
|
|
|
1050
1063
|
}
|
|
1051
1064
|
const separatorIndex = registryKey.indexOf(":");
|
|
1052
1065
|
duplicates.push({
|
|
1053
|
-
scope: Number(registryKey.slice(0, separatorIndex))
|
|
1066
|
+
scope: Number(registryKey.slice(0, separatorIndex)),
|
|
1054
1067
|
key: registryKey.slice(separatorIndex + 1),
|
|
1055
1068
|
count,
|
|
1056
1069
|
});
|
|
@@ -1062,7 +1075,7 @@ export function createStorageCore(
|
|
|
1062
1075
|
registeredKeyCounts.forEach((_count, registryKey) => {
|
|
1063
1076
|
const separatorIndex = registryKey.indexOf(":");
|
|
1064
1077
|
result.push({
|
|
1065
|
-
scope: Number(registryKey.slice(0, separatorIndex))
|
|
1078
|
+
scope: Number(registryKey.slice(0, separatorIndex)),
|
|
1066
1079
|
key: registryKey.slice(separatorIndex + 1),
|
|
1067
1080
|
});
|
|
1068
1081
|
});
|
|
@@ -2227,6 +2240,10 @@ export function createStorageCore(
|
|
|
2227
2240
|
) as BatchValues<TItems>;
|
|
2228
2241
|
}
|
|
2229
2242
|
|
|
2243
|
+
function setBatch<const TItems extends readonly StorageBatchSetCandidate[]>(
|
|
2244
|
+
items: StorageBatchSetEntries<TItems>,
|
|
2245
|
+
scope: StorageScope,
|
|
2246
|
+
): void;
|
|
2230
2247
|
function setBatch<T>(
|
|
2231
2248
|
items: readonly StorageBatchSetItem<T>[],
|
|
2232
2249
|
scope: StorageScope,
|
package/src/storage-events.ts
CHANGED
|
@@ -33,8 +33,7 @@ export type StorageBatchChangeEvent = {
|
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
export type StorageChangeEvent =
|
|
36
|
-
|
|
|
37
|
-
| StorageBatchChangeEvent;
|
|
36
|
+
StorageKeyChangeEvent | StorageBatchChangeEvent;
|
|
38
37
|
|
|
39
38
|
export type StorageEventListener = (event: StorageChangeEvent) => void;
|
|
40
39
|
|