@novasamatech/storage-adapter 0.7.6 → 0.7.8-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/dist/fieldView.js CHANGED
@@ -7,10 +7,12 @@ export function fieldView({ storage, initial, key, from, to, autosync = true })
7
7
  },
8
8
  write(value) {
9
9
  const data = to(value);
10
- if (data !== null) {
11
- return storage.write(key, data).map(() => value);
10
+ // `to` returning null means "no representation"; clear the key so
11
+ // persisted state stays in sync with `value`.
12
+ if (data === null) {
13
+ return storage.clear(key).map(() => null);
12
14
  }
13
- return okAsync(null);
15
+ return storage.write(key, data).map(() => value);
14
16
  },
15
17
  clear() {
16
18
  return storage.clear(key);
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export type { StorageAdapter } from './types.js';
2
2
  export { createMemoryAdapter } from './memory.js';
3
- export { createLocalStorageAdapter } from './localStorage.js';
3
+ export { LOCAL_STORAGE_PREFIX, createLocalStorageAdapter } from './localStorage.js';
4
4
  export { fieldListView, fieldView } from './fieldView.js';
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  export { createMemoryAdapter } from './memory.js';
2
- export { createLocalStorageAdapter } from './localStorage.js';
2
+ export { LOCAL_STORAGE_PREFIX, createLocalStorageAdapter } from './localStorage.js';
3
3
  export { fieldListView, fieldView } from './fieldView.js';
@@ -1,2 +1,3 @@
1
1
  import type { StorageAdapter } from './types.js';
2
+ export declare const LOCAL_STORAGE_PREFIX = "polkadot_";
2
3
  export declare function createLocalStorageAdapter(prefix: string): StorageAdapter;
@@ -1,9 +1,10 @@
1
1
  import { createNanoEvents } from 'nanoevents';
2
2
  import { fromAsyncThrowable } from 'neverthrow';
3
3
  import { toError } from './helpers.js';
4
+ export const LOCAL_STORAGE_PREFIX = 'polkadot_';
4
5
  export function createLocalStorageAdapter(prefix) {
5
6
  const events = createNanoEvents();
6
- const prefixPattern = `PAPP_${prefix}_`;
7
+ const prefixPattern = `${LOCAL_STORAGE_PREFIX}${prefix}_`;
7
8
  const withPrefix = (key) => `${prefixPattern}${key}`;
8
9
  return {
9
10
  write: fromAsyncThrowable(async (key, value) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@novasamatech/storage-adapter",
3
3
  "type": "module",
4
- "version": "0.7.6",
4
+ "version": "0.7.8-0",
5
5
  "description": "Statement store integration",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {