@sigx/lynx-storage 0.4.1 → 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 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/dist/storage.d.ts CHANGED
@@ -10,11 +10,11 @@
10
10
  * ```
11
11
  */
12
12
  export declare const Storage: {
13
- setItem(key: string, value: string): void;
14
- getItem(key: string): Promise<string | null>;
15
- removeItem(key: string): void;
16
- clear(): void;
17
- getAllKeys(): Promise<string[]>;
18
- isAvailable(): boolean;
13
+ readonly setItem: (key: string, value: string) => void;
14
+ readonly getItem: (key: string) => Promise<string | null>;
15
+ readonly removeItem: (key: string) => void;
16
+ readonly clear: () => void;
17
+ readonly getAllKeys: () => Promise<string[]>;
18
+ readonly isAvailable: () => boolean;
19
19
  };
20
20
  //# sourceMappingURL=storage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,OAAO;IAChB,OAAO,MAAM,MAAM,SAAS,MAAM,GAAG,IAAI;IAIzC,OAAO,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAI5C,UAAU,MAAM,MAAM,GAAG,IAAI;IAI7B,KAAK,IAAI,IAAI;IAIb,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAI/B,WAAW,IAAI,OAAO;CAGhB,CAAC"}
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,OAAO;aAChB,OAAO,QAAM,MAAM,SAAS,MAAM,KAAG,IAAI;aAIzC,OAAO,QAAM,MAAM,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;aAI5C,UAAU,QAAM,MAAM,KAAG,IAAI;aAI7B,KAAK,QAAI,IAAI;aAIb,UAAU,QAAI,OAAO,CAAC,MAAM,EAAE,CAAC;aAI/B,WAAW,QAAI,OAAO;CAGhB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sigx/lynx-storage",
3
- "version": "0.4.1",
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,10 +19,10 @@
19
19
  "signalx-module.json"
20
20
  ],
21
21
  "dependencies": {
22
- "@sigx/lynx-core": "^0.4.1"
22
+ "@sigx/lynx-core": "^0.4.3"
23
23
  },
24
24
  "devDependencies": {
25
- "@typescript/native-preview": "7.0.0-dev.20260511.1",
25
+ "@typescript/native-preview": "7.0.0-dev.20260521.1",
26
26
  "typescript": "^6.0.3"
27
27
  },
28
28
  "author": "Andreas Ekdahl",