Skip to content

Commit c60bc48

Browse files
Merge pull request #16 from JoaoPauloCMarra/release/0.5.1
feat: prepare storage 0.5.1 release
2 parents b21b32a + 320e312 commit c60bc48

26 files changed

Lines changed: 3069 additions & 483 deletions

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,26 @@ All notable changes to this project are documented in this file.
44

55
The format follows Keep a Changelog and the project adheres to SemVer.
66

7+
## 0.5.1 - 2026-04-24
8+
9+
### Added
10+
11+
- Add `storage.export(scope)` for raw string snapshots that can be restored with `storage.import(data, scope)`.
12+
- Add event subscriptions with `storage.subscribe`, `storage.subscribeKey`, `storage.subscribePrefix`, and `storage.subscribeNamespace`.
13+
- Add `StorageItem#subscribeSelector()` for selector-based subscriptions with equality checks.
14+
- Add `storage.setEventObserver()` for devtools and storage event logging integrations.
15+
- Add enforced JS/TS and C++ coverage gates for the package release path.
16+
- Extend the example smoke runner to cover the full public API surface and show unsupported platform checks as skipped.
17+
18+
### Changed
19+
20+
- Improve Memory namespace clear notification fan-out so subscribers under the cleared namespace are notified consistently.
21+
- Improve web key-index fast paths when the active backend exposes indexed key operations.
22+
- Emit batch change envelopes for raw import/export-adjacent workflows and batch writes/removes.
23+
- Document raw import/export workflows and warn that Secure exports expose secret values.
24+
- Align the Expo example and workspace dependency pins with Expo Doctor recommendations.
25+
- Refactor the publish script to validate release docs, report check timings, support coverage gates, and avoid redundant pack dry-runs.
26+
727
## 0.5.0 - 2026-04-18
828

929
### Added

README.md

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![npm](https://img.shields.io/npm/v/react-native-nitro-storage)](https://www.npmjs.com/package/react-native-nitro-storage)
44
[![MIT license](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
55
[![React Native](https://img.shields.io/badge/react--native-%3E%3D0.75-61dafb)](https://reactnative.dev/)
6-
[![Nitro Modules](https://img.shields.io/badge/nitro--modules-%3E%3D0.35.4-black)](https://nitro.margelo.com/)
6+
[![Nitro Modules](https://img.shields.io/badge/nitro--modules-%3E%3D0.35.5-black)](https://nitro.margelo.com/)
77

88
One storage layer for render-time state, persisted app state, and native secrets.
99

@@ -42,6 +42,7 @@ Use it when you want one storage API for React Native and web, with fast synchro
4242
| Move existing MMKV data | `migrateFromMMKV` |
4343
| Persist storage on web | `setWebDiskStorageBackend` or `createIndexedDBBackend` |
4444
| Inspect secure backend state | `getSecurityCapabilities`, `getSecureMetadata`, metadata APIs |
45+
| Connect external state/debug code | `subscribeNamespace`, `subscribePrefix`, `setEventObserver` |
4546

4647
## Use It When
4748

@@ -56,7 +57,7 @@ Use a database or server-state cache instead when you need relational queries, c
5657
- Three scopes: in-memory session state, persisted disk state, and platform secure storage.
5758
- Secure storage backed by iOS Keychain and Android Keystore/EncryptedSharedPreferences.
5859
- React hooks without providers: `useStorage`, `useStorageSelector`, and `useSetStorage`.
59-
- Batch reads/writes, namespace cleanup, raw import/export, transactions, and migrations.
60+
- Batch reads/writes, namespace cleanup, raw import/export, event subscriptions, transactions, and migrations.
6061
- Web parity with configurable Disk/Secure backends and an IndexedDB backend.
6162
- MMKV migration helper for moving existing keys without rewriting app code first.
6263

@@ -188,6 +189,37 @@ runTransaction(StorageScope.Disk, (tx) => {
188189
});
189190
```
190191

192+
Create a raw snapshot for backups or test fixtures, then restore it later:
193+
194+
```ts
195+
import { StorageScope, storage } from "react-native-nitro-storage";
196+
197+
const snapshot = storage.export(StorageScope.Disk);
198+
199+
storage.import(snapshot, StorageScope.Disk);
200+
```
201+
202+
`storage.export(StorageScope.Secure)` returns raw secret values. Do not log Secure exports or include them in diagnostics, analytics, crash reports, or support bundles.
203+
204+
Subscribe to storage changes outside React:
205+
206+
```ts
207+
import { StorageScope, storage } from "react-native-nitro-storage";
208+
209+
const unsubscribe = storage.subscribeNamespace(
210+
"settings",
211+
StorageScope.Disk,
212+
(event) => {
213+
if (event.type === "batch") {
214+
console.log("settings changed", event.changes.length);
215+
return;
216+
}
217+
218+
console.log(event.key, event.operation);
219+
},
220+
);
221+
```
222+
191223
## Storage Scopes
192224

193225
| Scope | Backing store | Best for |
@@ -243,7 +275,7 @@ import {
243275
The main building blocks are:
244276

245277
- `createStorageItem<T>(config)` for typed values.
246-
- `storage` for raw reads, namespace cleanup, secure metadata, metrics, and runtime capability checks.
278+
- `storage` for raw reads, namespace cleanup, events, secure metadata, metrics, and runtime capability checks.
247279
- `getBatch`, `setBatch`, and `removeBatch` for multi-key work.
248280
- `runTransaction` for synchronous rollback on failure.
249281
- `registerMigration` and `migrateToLatest` for versioned local data migrations.
@@ -265,7 +297,7 @@ Peer dependencies:
265297

266298
- `react >=18.2.0`
267299
- `react-native >=0.75.0`
268-
- `react-native-nitro-modules >=0.35.4`
300+
- `react-native-nitro-modules >=0.35.5`
269301

270302
## Security Model
271303

@@ -355,9 +387,11 @@ bun run format:check -- --filter=react-native-nitro-storage
355387
bun run typecheck -- --filter=react-native-nitro-storage
356388
bun run test:types -- --filter=react-native-nitro-storage
357389
bun run test -- --filter=react-native-nitro-storage
390+
bun run test:coverage -- --filter=react-native-nitro-storage
358391
bun run test:cpp -- --filter=react-native-nitro-storage
392+
bun run test:cpp:coverage -- --filter=react-native-nitro-storage
359393
bun run --cwd packages/react-native-nitro-storage check:pack
360-
npm publish --dry-run
394+
bun run publish-package:dry -- --yes --with-coverage
361395
```
362396

363397
## Development
@@ -378,7 +412,7 @@ Release checks:
378412
bun run build -- --filter=react-native-nitro-storage
379413
bun run benchmark -- --filter=react-native-nitro-storage
380414
bun run --cwd packages/react-native-nitro-storage check:pack
381-
npm publish --dry-run
415+
bun run publish-package:dry -- --yes
382416
```
383417

384418
## License

apps/example/.maestro/main.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ name: "Nitro Storage - Smoke Test"
44
- launchApp:
55
clearState: true
66

7-
# Scroll to the Smoke Test runner at the bottom
8-
- scrollUntilVisible:
9-
element:
10-
id: "smoke-run-all"
11-
direction: DOWN
12-
timeout: 20000
13-
speed: 80
7+
# Scroll to the Smoke Test runner at the bottom. Fixed swipes are more stable
8+
# on iOS because the button is exposed as accessibility text/resource-id but
9+
# scrollUntilVisible can miss it inside the nested Expo scroll view.
10+
- repeat:
11+
times: 7
12+
commands:
13+
- swipe:
14+
direction: UP
1415

1516
# Tap "Run All" to execute every smoke test
1617
- tapOn:
@@ -20,7 +21,6 @@ name: "Nitro Storage - Smoke Test"
2021
- extendedWaitUntil:
2122
visible:
2223
text: "Run All"
23-
id: "smoke-run-all"
2424
timeout: 30000
2525

2626
# Assert no test failed

apps/example/assets/icon.png

788 KB
Loading

0 commit comments

Comments
 (0)