react-native-storage-inspector 1.0.2 → 1.0.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/README.md CHANGED
@@ -49,12 +49,11 @@ The component fills its container. The consumer is responsible for header, back
49
49
 
50
50
  ### Props
51
51
 
52
- | Prop | Type | Description |
53
- | ----------------- | ------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
54
- | `mmkvInstances` | `MMKV[]` | **Required for MMKV.** Pass your MMKV instances to inspect. |
55
- | `secureStoreKeys` | `string[]` | **Required for Secure Store.** Keys to list (no list API). |
56
- | `keychainKeys` | `string[]` | Optional. Only for internet credentials (no list API). Generic passwords auto-discovered via `getAllGenericPasswordServices`. |
57
- | `customAdapters` | `IStorageAdapter[]` | Optional. Custom adapters for other storages. |
52
+ | Prop | Type | Description |
53
+ | ----------------- | ------------------- | ------------------------------------------------------------------------------------------------- |
54
+ | `mmkvInstances` | `MMKV[]` | **Required for MMKV.** Pass your MMKV instances to inspect. |
55
+ | `secureStoreKeys` | `string[]` | Optional. Known keys for Secure Store (no list API). Merged with keys persisted by the inspector. |
56
+ | `customAdapters` | `IStorageAdapter[]` | Optional. Custom adapters for other storages. |
58
57
 
59
58
  ## Expo
60
59
 
@@ -92,6 +91,7 @@ interface IStorageAdapter {
92
91
  ## Development
93
92
 
94
93
  ```bash
94
+ npm run commit # Guided commit (Commitizen) – prompts for type, scope, message
95
95
  npm run format # Format all files with Prettier
96
96
  npm run format:check # Check formatting (fails if any file is unformatted)
97
97
  npm run lint # Same as format:check
@@ -99,14 +99,9 @@ npm test # Run tests
99
99
  npm run build # Build src/ to dist/
100
100
  ```
101
101
 
102
- - **Formatting:** No auto-format. Run `npm run format` to fix. **Pre-commit** runs `format:check`; **pre-push** runs `format:check`, `test`, and `build`.
103
- - **Commits:** Use [Conventional Commits](https://www.conventionalcommits.org/) (enforced by `commit-msg` hook).
104
- - **Before publish:** `prepublishOnly` runs `format:check`, `test`, and `build`.
105
-
106
- ### Publishing
107
-
108
- 1. Run `npm version patch` (or `minor`/`major`).
109
- 2. Run `npm publish` (prepublishOnly will run checks and build).
102
+ - **Commits:** Use `npm run commit` for guided [Conventional Commits](https://www.conventionalcommits.org/), or write messages by hand; **Commitlint** (via `commit-msg` hook) enforces the format.
103
+ - **Formatting:** Run `npm run format` to fix. **Pre-commit** runs `format:check`.
104
+ - **Releases:** Version and npm publish are automated by **semantic-release** on push to `main`. See [docs/RELEASES.md](docs/RELEASES.md) for Commitizen, Commitlint, and semantic-release in detail.
110
105
 
111
106
  See [docs/CONTRIBUTING.md](docs/CONTRIBUTING.md) for full guidelines. [Code of Conduct](docs/CODE_OF_CONDUCT.md).
112
107
 
package/dist/index.d.mts CHANGED
@@ -16,99 +16,22 @@ interface IStorageAdapter {
16
16
  isAvailable(): boolean;
17
17
  }
18
18
 
19
- /**
20
- * AsyncStorage-compatible module interface.
21
- * Pass your AsyncStorage instance to avoid Metro "unknown module" errors in Expo:
22
- * @example
23
- * import AsyncStorage from '@react-native-async-storage/async-storage';
24
- * createAsyncStorageAdapter(AsyncStorage)
25
- */
26
- type AsyncStorageModule = {
27
- getAllKeys(): Promise<string[]>;
28
- getItem(key: string): Promise<string | null>;
29
- setItem(key: string, value: string): Promise<void>;
30
- removeItem(key: string): Promise<void>;
31
- };
32
- /**
33
- * Creates an AsyncStorage adapter. Pass the AsyncStorage instance for reliable
34
- * bundling in Expo/Metro (avoids "unknown module" errors):
35
- *
36
- * @example
37
- * import AsyncStorage from '@react-native-async-storage/async-storage';
38
- * createAsyncStorageAdapter(AsyncStorage)
39
- */
40
- declare function createAsyncStorageAdapter(instance?: AsyncStorageModule | null): IStorageAdapter;
41
-
42
- /**
43
- * Keychain-compatible module. Pass your keychain instance to avoid Metro
44
- * "unknown module" errors in Expo.
45
- */
46
- type KeychainModule = {
47
- getAllGenericPasswordServices?(options?: object): Promise<string[]>;
48
- getGenericPassword?(options?: {
49
- service?: string;
50
- }): Promise<{
51
- password: string;
52
- } | false>;
53
- setGenericPassword?(username: string, password: string, options?: {
54
- service?: string;
55
- }): Promise<{
56
- storage: string;
57
- } | false>;
58
- resetGenericPassword?(options?: {
59
- service?: string;
60
- }): Promise<void>;
61
- setInternetCredentials(server: string, username: string, password: string): Promise<{
62
- storage: string;
63
- } | false>;
64
- getInternetCredentials(server: string): Promise<{
65
- username: string;
66
- password: string;
67
- } | null>;
68
- resetInternetCredentials(server: string): Promise<void>;
69
- };
70
- /**
71
- * Keychain adapter. Pass the keychain instance for reliable bundling in Expo:
72
- * @example import * as Keychain from 'react-native-keychain';
73
- * createKeychainAdapter([], Keychain)
74
- */
75
- declare function createKeychainAdapter(knownKeys?: string[], instance?: KeychainModule | null): IStorageAdapter;
76
-
77
- /**
78
- * expo-secure-store compatible module. Pass the module to avoid Metro
79
- * "unknown module" errors in Expo.
80
- */
81
- type SecureStoreModule = {
82
- getItemAsync(key: string): Promise<string | null>;
83
- setItemAsync(key: string, value: string): Promise<void>;
84
- deleteItemAsync(key: string): Promise<void>;
19
+ /** Raw MMKV instance from createMMKV() (react-native-mmkv). */
20
+ type MMKVInstance = {
21
+ getAllKeys(): string[];
22
+ getString(key: string): string | undefined;
23
+ set(key: string, value: string | number | boolean): void;
24
+ remove(key: string): void | boolean;
85
25
  };
86
- /**
87
- * expo-secure-store has no API to list all keys. Pass knownKeys to inspect
88
- * those entries. Pass the module for reliable bundling in Expo:
89
- * @example import * as SecureStore from 'expo-secure-store';
90
- * createSecureStoreAdapter([], SecureStore)
91
- */
92
- declare function createSecureStoreAdapter(knownKeys?: string[], instance?: SecureStoreModule | null): IStorageAdapter;
26
+ declare function createMMKVAdapter(instance: MMKVInstance, name?: string): IStorageAdapter;
93
27
 
94
28
  interface StorageInspectorProps {
95
- mmkvInstances?: Array<{
96
- getAllKeys(): string[];
97
- getString(k: string): string | undefined;
98
- set(k: string, v: string | number | boolean): void;
99
- delete(k: string): void;
100
- }>;
101
- /** Pass AsyncStorage to avoid Metro "unknown module" in Expo. */
102
- asyncStorageInstance?: AsyncStorageModule | null;
103
- keychainKeys?: string[];
104
- /** Pass Keychain module to avoid Metro "unknown module" in Expo. */
105
- keychainInstance?: KeychainModule | null;
29
+ /** Raw MMKV instances from createMMKV() (react-native-mmkv). */
30
+ mmkvInstances?: MMKVInstance[];
106
31
  secureStoreKeys?: string[];
107
- /** Pass SecureStore module to avoid Metro "unknown module" in Expo. */
108
- secureStoreInstance?: SecureStoreModule | null;
109
32
  customAdapters?: IStorageAdapter[];
110
33
  }
111
- declare function StorageInspector({ mmkvInstances, asyncStorageInstance, keychainKeys: keychainKeysProp, keychainInstance, secureStoreKeys: secureStoreKeysProp, secureStoreInstance, customAdapters, }: StorageInspectorProps): React.JSX.Element;
34
+ declare function StorageInspector(props: StorageInspectorProps): React.JSX.Element;
112
35
 
113
36
  /**
114
37
  * Centralized user-facing text for the storage inspector.
@@ -116,19 +39,18 @@ declare function StorageInspector({ mmkvInstances, asyncStorageInstance, keychai
116
39
  */
117
40
  declare const strings: {
118
41
  readonly noAdapterAvailable: "No storage adapter available. Install at least one of: react-native-mmkv, @react-native-async-storage/async-storage, react-native-keychain, expo-secure-store";
119
- readonly keychainHint: "No generic password items yet. Add a key using + above, or pass keychainKeys for internet credentials.";
42
+ readonly keychainHint: "No generic password items yet. Add a key using + above.";
120
43
  readonly secureStoreHint: "Secure Store has no list API. Pass secureStoreKeys prop with known keys, or add a key using + above.";
121
44
  readonly loading: "Loading…";
122
45
  readonly noItems: "No items";
123
46
  readonly valueLabel: "Value";
124
- readonly emptyValue: "(empty)";
125
47
  readonly charCount: (n: number) => string;
126
48
  readonly deleteItemTitle: (key: string) => string;
127
49
  readonly deleteItemMessage: (key: string) => string;
128
50
  readonly clearAllTitle: (name: string) => string;
129
51
  readonly clearAllMessage: (count: number, name: string) => string;
130
52
  readonly storageNotAvailable: "This storage is not available.";
131
- readonly keychainHintShort: "No items yet. Add a key below, or pass keychainKeys for internet credentials.";
53
+ readonly keychainHintShort: "No items yet. Add a key below.";
132
54
  readonly edit: "Edit";
133
55
  readonly delete: "Delete";
134
56
  readonly addItem: "Add item";
@@ -163,16 +85,61 @@ declare const theme: {
163
85
  readonly textSecondary: "#666666";
164
86
  readonly textMuted: "#999999";
165
87
  readonly inverted: "#ffffff";
88
+ readonly overlayBackdrop: "rgba(0,0,0,0.5)";
166
89
  };
167
90
  };
168
91
  type Theme = typeof theme;
169
92
 
170
- type MMKVInstance = {
171
- getAllKeys(): string[];
172
- getString(key: string): string | undefined;
173
- set(key: string, value: string | number | boolean): void;
174
- delete(key: string): void;
93
+ /**
94
+ * AsyncStorage-compatible module interface.
95
+ */
96
+ type AsyncStorageModule = {
97
+ getAllKeys(): Promise<string[]>;
98
+ getItem(key: string): Promise<string | null>;
99
+ setItem(key: string, value: string): Promise<void>;
100
+ removeItem(key: string): Promise<void>;
175
101
  };
176
- declare function createMMKVAdapter(instance: MMKVInstance, name?: string): IStorageAdapter;
102
+ /**
103
+ * Creates an AsyncStorage adapter.
104
+ */
105
+ declare function createAsyncStorageAdapter(): IStorageAdapter;
106
+
107
+ /**
108
+ * Keychain-compatible module (generic password only).
109
+ */
110
+ type KeychainModule = {
111
+ getAllGenericPasswordServices?(options?: object): Promise<string[]>;
112
+ getGenericPassword?(options?: {
113
+ service?: string;
114
+ }): Promise<{
115
+ password: string;
116
+ } | false>;
117
+ setGenericPassword?(username: string, password: string, options?: {
118
+ service?: string;
119
+ }): Promise<{
120
+ storage: string;
121
+ } | false>;
122
+ resetGenericPassword?(options?: {
123
+ service?: string;
124
+ }): Promise<void>;
125
+ };
126
+ /**
127
+ * Creates a Keychain adapter.
128
+ */
129
+ declare function createKeychainAdapter(): IStorageAdapter;
130
+
131
+ /**
132
+ * expo-secure-store compatible module. Pass the module to avoid Metro
133
+ * "unknown module" errors in Expo.
134
+ */
135
+ type SecureStoreModule = {
136
+ getItemAsync(key: string): Promise<string | null>;
137
+ setItemAsync(key: string, value: string): Promise<void>;
138
+ deleteItemAsync(key: string): Promise<void>;
139
+ };
140
+ /**
141
+ * Creates a Secure Store adapter. Since expo-secure-store has no API to list all keys, we persist the list of keys in Secure Store.
142
+ */
143
+ declare function createSecureStoreAdapter(knownKeys?: string[]): IStorageAdapter;
177
144
 
178
- export { type AsyncStorageModule, type IStorageAdapter, type KeychainModule, type SecureStoreModule, StorageInspector, type StorageInspectorProps, type StorageItem, type Theme, createAsyncStorageAdapter, createKeychainAdapter, createMMKVAdapter, createSecureStoreAdapter, strings, theme };
145
+ export { type AsyncStorageModule, type IStorageAdapter, type KeychainModule, type MMKVInstance, type SecureStoreModule, StorageInspector, type StorageInspectorProps, type StorageItem, type Theme, createAsyncStorageAdapter, createKeychainAdapter, createMMKVAdapter, createSecureStoreAdapter, strings, theme };
package/dist/index.d.ts CHANGED
@@ -16,99 +16,22 @@ interface IStorageAdapter {
16
16
  isAvailable(): boolean;
17
17
  }
18
18
 
19
- /**
20
- * AsyncStorage-compatible module interface.
21
- * Pass your AsyncStorage instance to avoid Metro "unknown module" errors in Expo:
22
- * @example
23
- * import AsyncStorage from '@react-native-async-storage/async-storage';
24
- * createAsyncStorageAdapter(AsyncStorage)
25
- */
26
- type AsyncStorageModule = {
27
- getAllKeys(): Promise<string[]>;
28
- getItem(key: string): Promise<string | null>;
29
- setItem(key: string, value: string): Promise<void>;
30
- removeItem(key: string): Promise<void>;
31
- };
32
- /**
33
- * Creates an AsyncStorage adapter. Pass the AsyncStorage instance for reliable
34
- * bundling in Expo/Metro (avoids "unknown module" errors):
35
- *
36
- * @example
37
- * import AsyncStorage from '@react-native-async-storage/async-storage';
38
- * createAsyncStorageAdapter(AsyncStorage)
39
- */
40
- declare function createAsyncStorageAdapter(instance?: AsyncStorageModule | null): IStorageAdapter;
41
-
42
- /**
43
- * Keychain-compatible module. Pass your keychain instance to avoid Metro
44
- * "unknown module" errors in Expo.
45
- */
46
- type KeychainModule = {
47
- getAllGenericPasswordServices?(options?: object): Promise<string[]>;
48
- getGenericPassword?(options?: {
49
- service?: string;
50
- }): Promise<{
51
- password: string;
52
- } | false>;
53
- setGenericPassword?(username: string, password: string, options?: {
54
- service?: string;
55
- }): Promise<{
56
- storage: string;
57
- } | false>;
58
- resetGenericPassword?(options?: {
59
- service?: string;
60
- }): Promise<void>;
61
- setInternetCredentials(server: string, username: string, password: string): Promise<{
62
- storage: string;
63
- } | false>;
64
- getInternetCredentials(server: string): Promise<{
65
- username: string;
66
- password: string;
67
- } | null>;
68
- resetInternetCredentials(server: string): Promise<void>;
69
- };
70
- /**
71
- * Keychain adapter. Pass the keychain instance for reliable bundling in Expo:
72
- * @example import * as Keychain from 'react-native-keychain';
73
- * createKeychainAdapter([], Keychain)
74
- */
75
- declare function createKeychainAdapter(knownKeys?: string[], instance?: KeychainModule | null): IStorageAdapter;
76
-
77
- /**
78
- * expo-secure-store compatible module. Pass the module to avoid Metro
79
- * "unknown module" errors in Expo.
80
- */
81
- type SecureStoreModule = {
82
- getItemAsync(key: string): Promise<string | null>;
83
- setItemAsync(key: string, value: string): Promise<void>;
84
- deleteItemAsync(key: string): Promise<void>;
19
+ /** Raw MMKV instance from createMMKV() (react-native-mmkv). */
20
+ type MMKVInstance = {
21
+ getAllKeys(): string[];
22
+ getString(key: string): string | undefined;
23
+ set(key: string, value: string | number | boolean): void;
24
+ remove(key: string): void | boolean;
85
25
  };
86
- /**
87
- * expo-secure-store has no API to list all keys. Pass knownKeys to inspect
88
- * those entries. Pass the module for reliable bundling in Expo:
89
- * @example import * as SecureStore from 'expo-secure-store';
90
- * createSecureStoreAdapter([], SecureStore)
91
- */
92
- declare function createSecureStoreAdapter(knownKeys?: string[], instance?: SecureStoreModule | null): IStorageAdapter;
26
+ declare function createMMKVAdapter(instance: MMKVInstance, name?: string): IStorageAdapter;
93
27
 
94
28
  interface StorageInspectorProps {
95
- mmkvInstances?: Array<{
96
- getAllKeys(): string[];
97
- getString(k: string): string | undefined;
98
- set(k: string, v: string | number | boolean): void;
99
- delete(k: string): void;
100
- }>;
101
- /** Pass AsyncStorage to avoid Metro "unknown module" in Expo. */
102
- asyncStorageInstance?: AsyncStorageModule | null;
103
- keychainKeys?: string[];
104
- /** Pass Keychain module to avoid Metro "unknown module" in Expo. */
105
- keychainInstance?: KeychainModule | null;
29
+ /** Raw MMKV instances from createMMKV() (react-native-mmkv). */
30
+ mmkvInstances?: MMKVInstance[];
106
31
  secureStoreKeys?: string[];
107
- /** Pass SecureStore module to avoid Metro "unknown module" in Expo. */
108
- secureStoreInstance?: SecureStoreModule | null;
109
32
  customAdapters?: IStorageAdapter[];
110
33
  }
111
- declare function StorageInspector({ mmkvInstances, asyncStorageInstance, keychainKeys: keychainKeysProp, keychainInstance, secureStoreKeys: secureStoreKeysProp, secureStoreInstance, customAdapters, }: StorageInspectorProps): React.JSX.Element;
34
+ declare function StorageInspector(props: StorageInspectorProps): React.JSX.Element;
112
35
 
113
36
  /**
114
37
  * Centralized user-facing text for the storage inspector.
@@ -116,19 +39,18 @@ declare function StorageInspector({ mmkvInstances, asyncStorageInstance, keychai
116
39
  */
117
40
  declare const strings: {
118
41
  readonly noAdapterAvailable: "No storage adapter available. Install at least one of: react-native-mmkv, @react-native-async-storage/async-storage, react-native-keychain, expo-secure-store";
119
- readonly keychainHint: "No generic password items yet. Add a key using + above, or pass keychainKeys for internet credentials.";
42
+ readonly keychainHint: "No generic password items yet. Add a key using + above.";
120
43
  readonly secureStoreHint: "Secure Store has no list API. Pass secureStoreKeys prop with known keys, or add a key using + above.";
121
44
  readonly loading: "Loading…";
122
45
  readonly noItems: "No items";
123
46
  readonly valueLabel: "Value";
124
- readonly emptyValue: "(empty)";
125
47
  readonly charCount: (n: number) => string;
126
48
  readonly deleteItemTitle: (key: string) => string;
127
49
  readonly deleteItemMessage: (key: string) => string;
128
50
  readonly clearAllTitle: (name: string) => string;
129
51
  readonly clearAllMessage: (count: number, name: string) => string;
130
52
  readonly storageNotAvailable: "This storage is not available.";
131
- readonly keychainHintShort: "No items yet. Add a key below, or pass keychainKeys for internet credentials.";
53
+ readonly keychainHintShort: "No items yet. Add a key below.";
132
54
  readonly edit: "Edit";
133
55
  readonly delete: "Delete";
134
56
  readonly addItem: "Add item";
@@ -163,16 +85,61 @@ declare const theme: {
163
85
  readonly textSecondary: "#666666";
164
86
  readonly textMuted: "#999999";
165
87
  readonly inverted: "#ffffff";
88
+ readonly overlayBackdrop: "rgba(0,0,0,0.5)";
166
89
  };
167
90
  };
168
91
  type Theme = typeof theme;
169
92
 
170
- type MMKVInstance = {
171
- getAllKeys(): string[];
172
- getString(key: string): string | undefined;
173
- set(key: string, value: string | number | boolean): void;
174
- delete(key: string): void;
93
+ /**
94
+ * AsyncStorage-compatible module interface.
95
+ */
96
+ type AsyncStorageModule = {
97
+ getAllKeys(): Promise<string[]>;
98
+ getItem(key: string): Promise<string | null>;
99
+ setItem(key: string, value: string): Promise<void>;
100
+ removeItem(key: string): Promise<void>;
175
101
  };
176
- declare function createMMKVAdapter(instance: MMKVInstance, name?: string): IStorageAdapter;
102
+ /**
103
+ * Creates an AsyncStorage adapter.
104
+ */
105
+ declare function createAsyncStorageAdapter(): IStorageAdapter;
106
+
107
+ /**
108
+ * Keychain-compatible module (generic password only).
109
+ */
110
+ type KeychainModule = {
111
+ getAllGenericPasswordServices?(options?: object): Promise<string[]>;
112
+ getGenericPassword?(options?: {
113
+ service?: string;
114
+ }): Promise<{
115
+ password: string;
116
+ } | false>;
117
+ setGenericPassword?(username: string, password: string, options?: {
118
+ service?: string;
119
+ }): Promise<{
120
+ storage: string;
121
+ } | false>;
122
+ resetGenericPassword?(options?: {
123
+ service?: string;
124
+ }): Promise<void>;
125
+ };
126
+ /**
127
+ * Creates a Keychain adapter.
128
+ */
129
+ declare function createKeychainAdapter(): IStorageAdapter;
130
+
131
+ /**
132
+ * expo-secure-store compatible module. Pass the module to avoid Metro
133
+ * "unknown module" errors in Expo.
134
+ */
135
+ type SecureStoreModule = {
136
+ getItemAsync(key: string): Promise<string | null>;
137
+ setItemAsync(key: string, value: string): Promise<void>;
138
+ deleteItemAsync(key: string): Promise<void>;
139
+ };
140
+ /**
141
+ * Creates a Secure Store adapter. Since expo-secure-store has no API to list all keys, we persist the list of keys in Secure Store.
142
+ */
143
+ declare function createSecureStoreAdapter(knownKeys?: string[]): IStorageAdapter;
177
144
 
178
- export { type AsyncStorageModule, type IStorageAdapter, type KeychainModule, type SecureStoreModule, StorageInspector, type StorageInspectorProps, type StorageItem, type Theme, createAsyncStorageAdapter, createKeychainAdapter, createMMKVAdapter, createSecureStoreAdapter, strings, theme };
145
+ export { type AsyncStorageModule, type IStorageAdapter, type KeychainModule, type MMKVInstance, type SecureStoreModule, StorageInspector, type StorageInspectorProps, type StorageItem, type Theme, createAsyncStorageAdapter, createKeychainAdapter, createMMKVAdapter, createSecureStoreAdapter, strings, theme };