@sigx/lynx-storage 0.4.2 → 0.4.3
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 +0 -17
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,32 +1,21 @@
|
|
|
1
1
|
# @sigx/lynx-storage
|
|
2
|
-
|
|
3
2
|
Persistent key-value storage for sigx-lynx. `UserDefaults` on iOS, `SharedPreferences` on Android. Same shape as `localStorage` / `AsyncStorage` (string keys, string values).
|
|
4
|
-
|
|
5
3
|
## Install
|
|
6
|
-
|
|
7
4
|
```bash
|
|
8
5
|
pnpm add @sigx/lynx-storage
|
|
9
6
|
```
|
|
10
|
-
|
|
11
7
|
`sigx prebuild` auto-discovers the package via its `signalx-module.json` and links the native module. No special permissions on either platform.
|
|
12
|
-
|
|
13
8
|
## Usage
|
|
14
|
-
|
|
15
9
|
```ts
|
|
16
10
|
import { Storage } from '@sigx/lynx-storage';
|
|
17
|
-
|
|
18
11
|
Storage.setItem('user', JSON.stringify({ name: 'Alice', id: 42 }));
|
|
19
12
|
const raw = await Storage.getItem('user');
|
|
20
13
|
const user = raw ? JSON.parse(raw) : null;
|
|
21
|
-
|
|
22
14
|
Storage.removeItem('user');
|
|
23
|
-
|
|
24
15
|
const keys = await Storage.getAllKeys();
|
|
25
16
|
Storage.clear(); // wipes everything in this app's namespace
|
|
26
17
|
```
|
|
27
|
-
|
|
28
18
|
## API
|
|
29
|
-
|
|
30
19
|
| Method | Notes |
|
|
31
20
|
| -------------------------------------------- | -------------------------------------------------------------------------------------------------- |
|
|
32
21
|
| `setItem(key: string, value: string): void` | Sync — fire-and-forget write. |
|
|
@@ -35,13 +24,7 @@ Storage.clear(); // wipes everything in this app's namespace
|
|
|
35
24
|
| `clear(): void` | Wipes the entire app namespace. |
|
|
36
25
|
| `getAllKeys(): Promise<string[]>` | Returns all currently-set keys. |
|
|
37
26
|
| `isAvailable(): boolean` | Whether the native module is registered in the current build. |
|
|
38
|
-
|
|
39
27
|
## Gotchas
|
|
40
|
-
|
|
41
28
|
- **String values only.** Serialize objects with `JSON.stringify` / `JSON.parse` yourself. Don't dump raw binary — use `@sigx/lynx-file-system` for that.
|
|
42
29
|
- **Sync writes can race with reads** if you `setItem` then immediately `getItem` the same key from BG. UserDefaults / SharedPreferences both use a write-behind buffer; values are returned correctly within the same process, just be aware of cross-process scenarios (extension apps on iOS, etc.) where eventual consistency applies.
|
|
43
30
|
- **Persistence semantics.** Both stores survive app updates, are excluded from app-data exports on Android, and follow iCloud-backup rules on iOS (UserDefaults is included by default).
|
|
44
|
-
|
|
45
|
-
## Reference app
|
|
46
|
-
|
|
47
|
-
`examples/lynx-one/my-sigx-app/src/cards/StorageCard.tsx` covers a write/read round-trip + getAllKeys + clear.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sigx/lynx-storage",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "Persistent key-value storage for sigx-lynx",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"signalx-module.json"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@sigx/lynx-core": "^0.4.
|
|
22
|
+
"@sigx/lynx-core": "^0.4.3"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@typescript/native-preview": "7.0.0-dev.20260521.1",
|