react-native-nitro-storage 0.5.9 → 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 +39 -0
- package/README.md +193 -16
- package/android/src/main/java/com/nitrostorage/AndroidStorageAdapter.kt +225 -76
- package/app.plugin.js +2 -0
- package/cpp/bindings/HybridStorage.cpp +29 -21
- package/cpp/bindings/HybridStorage.hpp +5 -0
- package/docs/secure-storage.md +4 -0
- package/lib/commonjs/index.js +19 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.web.js +19 -2
- 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/shared.js.map +1 -1
- package/lib/commonjs/storage-core.js +306 -10
- package/lib/commonjs/storage-core.js.map +1 -1
- package/lib/commonjs/storage-events.js.map +1 -1
- package/lib/commonjs/storage-hooks.js +16 -1
- package/lib/commonjs/storage-hooks.js.map +1 -1
- package/lib/commonjs/testing.js +267 -0
- package/lib/commonjs/testing.js.map +1 -0
- package/lib/module/index.js +5 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +5 -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/shared.js.map +1 -1
- package/lib/module/storage-core.js +307 -11
- package/lib/module/storage-core.js.map +1 -1
- package/lib/module/storage-events.js.map +1 -1
- package/lib/module/storage-hooks.js +15 -2
- package/lib/module/storage-hooks.js.map +1 -1
- package/lib/module/testing.js +188 -0
- package/lib/module/testing.js.map +1 -0
- package/lib/typescript/index.d.ts +28 -5
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/index.web.d.ts +28 -5
- package/lib/typescript/index.web.d.ts.map +1 -1
- package/lib/typescript/indexeddb-backend.d.ts.map +1 -1
- package/lib/typescript/shared.d.ts +1 -0
- package/lib/typescript/shared.d.ts.map +1 -1
- package/lib/typescript/storage-core.d.ts +62 -3
- package/lib/typescript/storage-core.d.ts.map +1 -1
- package/lib/typescript/storage-events.d.ts +1 -1
- package/lib/typescript/storage-events.d.ts.map +1 -1
- package/lib/typescript/storage-hooks.d.ts +18 -1
- package/lib/typescript/storage-hooks.d.ts.map +1 -1
- package/lib/typescript/testing.d.ts +158 -0
- package/lib/typescript/testing.d.ts.map +1 -0
- package/package.json +11 -6
- package/src/index.ts +17 -4
- package/src/index.web.ts +17 -4
- package/src/indexeddb-backend.ts +1 -2
- package/src/internal.ts +1 -1
- package/src/shared.ts +1 -0
- package/src/storage-core.ts +463 -11
- package/src/storage-events.ts +3 -2
- package/src/storage-hooks.ts +42 -3
- package/src/testing.ts +270 -0
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",
|
|
@@ -20,6 +20,12 @@
|
|
|
20
20
|
"types": "./lib/typescript/indexeddb-backend.d.ts",
|
|
21
21
|
"default": "./lib/commonjs/indexeddb-backend.js"
|
|
22
22
|
},
|
|
23
|
+
"./testing": {
|
|
24
|
+
"types": "./lib/typescript/testing.d.ts",
|
|
25
|
+
"react-native": "./src/testing.ts",
|
|
26
|
+
"browser": "./src/testing.ts",
|
|
27
|
+
"default": "./lib/commonjs/testing.js"
|
|
28
|
+
},
|
|
23
29
|
"./app.plugin": "./app.plugin.js",
|
|
24
30
|
"./app.plugin.js": "./app.plugin.js",
|
|
25
31
|
"./package.json": "./package.json"
|
|
@@ -116,16 +122,15 @@
|
|
|
116
122
|
"registry": "https://registry.npmjs.org/"
|
|
117
123
|
},
|
|
118
124
|
"devDependencies": {
|
|
119
|
-
"@expo/config-plugins": "^
|
|
120
|
-
"@react-native/babel-preset": "^0.
|
|
121
|
-
"@testing-library/react-hooks": "^8.0.1",
|
|
125
|
+
"@expo/config-plugins": "^57.0.6",
|
|
126
|
+
"@react-native/babel-preset": "^0.86.2",
|
|
122
127
|
"@testing-library/react-native": "^13.3.3",
|
|
123
|
-
"@types/react": "~19.2.
|
|
128
|
+
"@types/react": "~19.2.17"
|
|
124
129
|
},
|
|
125
130
|
"peerDependencies": {
|
|
126
131
|
"react": ">=18.2.0",
|
|
127
132
|
"react-native": ">=0.75.0",
|
|
128
|
-
"react-native-nitro-modules": ">=0.
|
|
133
|
+
"react-native-nitro-modules": ">=0.36.4 <0.37.0"
|
|
129
134
|
},
|
|
130
135
|
"react-native-builder-bob": {
|
|
131
136
|
"source": "src",
|
package/src/index.ts
CHANGED
|
@@ -58,7 +58,7 @@ export type {
|
|
|
58
58
|
StorageEventListener,
|
|
59
59
|
StorageKeyChangeEvent,
|
|
60
60
|
} from "./storage-events";
|
|
61
|
-
export type { StorageSetter } from "./storage-hooks";
|
|
61
|
+
export type { StorageActions, StorageSetter } from "./storage-hooks";
|
|
62
62
|
export type {
|
|
63
63
|
WebDiskStorageBackend,
|
|
64
64
|
WebSecureStorageBackend,
|
|
@@ -67,9 +67,13 @@ export type {
|
|
|
67
67
|
WebStorageScope,
|
|
68
68
|
} from "./web-storage-backend";
|
|
69
69
|
export type {
|
|
70
|
+
SetItemConfig,
|
|
71
|
+
SetStorageItem,
|
|
70
72
|
StorageBatchSetItem,
|
|
73
|
+
StorageClearOptions,
|
|
71
74
|
StorageItem,
|
|
72
75
|
StorageItemConfig,
|
|
76
|
+
StorageKeyRef,
|
|
73
77
|
TransactionContext,
|
|
74
78
|
} from "./storage-core";
|
|
75
79
|
|
|
@@ -307,6 +311,10 @@ export const storage = {
|
|
|
307
311
|
};
|
|
308
312
|
|
|
309
313
|
export const createStorageItem = core.createStorageItem;
|
|
314
|
+
export const memoryItem = core.memoryItem;
|
|
315
|
+
export const diskItem = core.diskItem;
|
|
316
|
+
export const secureItem = core.secureItem;
|
|
317
|
+
export const createSetItem = core.createSetItem;
|
|
310
318
|
export const getBatch = core.getBatch;
|
|
311
319
|
export const setBatch = core.setBatch;
|
|
312
320
|
export const removeBatch = core.removeBatch;
|
|
@@ -322,8 +330,7 @@ export function setWebSecureStorageBackend(
|
|
|
322
330
|
}
|
|
323
331
|
|
|
324
332
|
export function getWebSecureStorageBackend():
|
|
325
|
-
|
|
|
326
|
-
| undefined {
|
|
333
|
+
WebSecureStorageBackend | undefined {
|
|
327
334
|
return undefined;
|
|
328
335
|
}
|
|
329
336
|
|
|
@@ -341,5 +348,11 @@ export async function flushWebStorageBackends(): Promise<void> {
|
|
|
341
348
|
// Native platforms do not use web storage backends.
|
|
342
349
|
}
|
|
343
350
|
|
|
344
|
-
export {
|
|
351
|
+
export {
|
|
352
|
+
useSetStorage,
|
|
353
|
+
useStorage,
|
|
354
|
+
useStorageActions,
|
|
355
|
+
useStorageSelector,
|
|
356
|
+
useStorageValue,
|
|
357
|
+
} from "./storage-hooks";
|
|
345
358
|
export { createIndexedDBBackend } from "./indexeddb-backend";
|
package/src/index.web.ts
CHANGED
|
@@ -57,7 +57,7 @@ export type {
|
|
|
57
57
|
StorageEventListener,
|
|
58
58
|
StorageKeyChangeEvent,
|
|
59
59
|
} from "./storage-events";
|
|
60
|
-
export type { StorageSetter } from "./storage-hooks";
|
|
60
|
+
export type { StorageActions, StorageSetter } from "./storage-hooks";
|
|
61
61
|
export type {
|
|
62
62
|
WebDiskStorageBackend,
|
|
63
63
|
WebSecureStorageBackend,
|
|
@@ -66,9 +66,13 @@ export type {
|
|
|
66
66
|
WebStorageScope,
|
|
67
67
|
} from "./web-storage-backend";
|
|
68
68
|
export type {
|
|
69
|
+
SetItemConfig,
|
|
70
|
+
SetStorageItem,
|
|
69
71
|
StorageBatchSetItem,
|
|
72
|
+
StorageClearOptions,
|
|
70
73
|
StorageItem,
|
|
71
74
|
StorageItemConfig,
|
|
75
|
+
StorageKeyRef,
|
|
72
76
|
TransactionContext,
|
|
73
77
|
} from "./storage-core";
|
|
74
78
|
|
|
@@ -818,6 +822,10 @@ export const storage = {
|
|
|
818
822
|
};
|
|
819
823
|
|
|
820
824
|
export const createStorageItem = core.createStorageItem;
|
|
825
|
+
export const memoryItem = core.memoryItem;
|
|
826
|
+
export const diskItem = core.diskItem;
|
|
827
|
+
export const secureItem = core.secureItem;
|
|
828
|
+
export const createSetItem = core.createSetItem;
|
|
821
829
|
export const getBatch = core.getBatch;
|
|
822
830
|
export const setBatch = core.setBatch;
|
|
823
831
|
export const removeBatch = core.removeBatch;
|
|
@@ -843,8 +851,7 @@ export function setWebSecureStorageBackend(
|
|
|
843
851
|
}
|
|
844
852
|
|
|
845
853
|
export function getWebSecureStorageBackend():
|
|
846
|
-
|
|
|
847
|
-
| undefined {
|
|
854
|
+
WebSecureStorageBackend | undefined {
|
|
848
855
|
return webSecureStorageBackend;
|
|
849
856
|
}
|
|
850
857
|
|
|
@@ -886,5 +893,11 @@ export async function flushWebStorageBackends(): Promise<void> {
|
|
|
886
893
|
await Promise.all(flushes);
|
|
887
894
|
}
|
|
888
895
|
|
|
889
|
-
export {
|
|
896
|
+
export {
|
|
897
|
+
useSetStorage,
|
|
898
|
+
useStorage,
|
|
899
|
+
useStorageActions,
|
|
900
|
+
useStorageSelector,
|
|
901
|
+
useStorageValue,
|
|
902
|
+
} from "./storage-hooks";
|
|
890
903
|
export { createIndexedDBBackend } from "./indexeddb-backend";
|
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/shared.ts
CHANGED