@dynamic-labs/store 3.0.0-alpha.14 → 3.0.0-alpha.16

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/CHANGELOG.md CHANGED
@@ -1,4 +1,32 @@
1
1
 
2
+ ## [3.0.0-alpha.16](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.15...v3.0.0-alpha.16) (2024-07-11)
3
+
4
+
5
+ ### ⚠ BREAKING CHANGES
6
+
7
+ * remove isConnected prop from wallets and have it as a method instead (#6265)
8
+
9
+ ### Features
10
+
11
+ * add bundlerRpc and paymasterRpc parameters to zerodev ([#6304](https://github.com/dynamic-labs/DynamicAuth/issues/6304)) ([156469b](https://github.com/dynamic-labs/DynamicAuth/commit/156469bf703f0c7fa455a24b8e4e328d3a0c58fc))
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * headless embedded wallet export session refresh ([#6307](https://github.com/dynamic-labs/DynamicAuth/issues/6307)) ([5423cc1](https://github.com/dynamic-labs/DynamicAuth/commit/5423cc14c370968acf718b7deff6ea8df9228189))
17
+
18
+
19
+ * remove isConnected prop from wallets and have it as a method instead ([#6265](https://github.com/dynamic-labs/DynamicAuth/issues/6265)) ([652dcc2](https://github.com/dynamic-labs/DynamicAuth/commit/652dcc2d34c9a9719238606c67f600e40621183b))
20
+
21
+ ## [3.0.0-alpha.15](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.14...v3.0.0-alpha.15) (2024-07-11)
22
+
23
+
24
+ ### Bug Fixes
25
+
26
+ * catch third party wallet construction errors ([#6268](https://github.com/dynamic-labs/DynamicAuth/issues/6268)) ([badef39](https://github.com/dynamic-labs/DynamicAuth/commit/badef39d753c7d29925c6c8680053027bd99b69b))
27
+ * decode all solana transactions ([#6294](https://github.com/dynamic-labs/DynamicAuth/issues/6294)) ([5220ab2](https://github.com/dynamic-labs/DynamicAuth/commit/5220ab29381f3a7f1afc7043332b5a018b47eb0a))
28
+ * passkey cta ([#6255](https://github.com/dynamic-labs/DynamicAuth/issues/6255)) ([1b1b152](https://github.com/dynamic-labs/DynamicAuth/commit/1b1b152a24b409c5d941a9c92a003daf0bbe48a1))
29
+
2
30
  ## [3.0.0-alpha.14](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.13...v3.0.0-alpha.14) (2024-07-09)
3
31
 
4
32
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/store",
3
- "version": "3.0.0-alpha.14",
3
+ "version": "3.0.0-alpha.16",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
@@ -26,7 +26,7 @@
26
26
  "./package.json": "./package.json"
27
27
  },
28
28
  "dependencies": {
29
- "@dynamic-labs/logger": "3.0.0-alpha.14"
29
+ "@dynamic-labs/logger": "3.0.0-alpha.16"
30
30
  },
31
31
  "peerDependencies": {}
32
32
  }
package/src/index.cjs CHANGED
@@ -10,5 +10,5 @@ var subscribeWithSelector = require('./lib/subscribeWithSelector/subscribeWithSe
10
10
 
11
11
 
12
12
  exports.createStore = createStore.createStore;
13
- exports.createPersist = persist.createPersist;
13
+ exports.persist = persist.persist;
14
14
  exports.subscribeWithSelector = subscribeWithSelector.subscribeWithSelector;
package/src/index.d.ts CHANGED
@@ -1 +1,4 @@
1
- export { type StoreApi, type PersistStorage, createPersist, createStore, subscribeWithSelector, } from './lib';
1
+ export type { StoreApi } from './lib/types';
2
+ export { createStore } from './lib/createStore';
3
+ export { persist, type PersistStorage } from './lib/persist';
4
+ export { subscribeWithSelector } from './lib/subscribeWithSelector';
package/src/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use client'
2
2
  export { createStore } from './lib/createStore/createStore.js';
3
- export { createPersist } from './lib/persist/persist.js';
3
+ export { persist } from './lib/persist/persist.js';
4
4
  export { subscribeWithSelector } from './lib/subscribeWithSelector/subscribeWithSelector.js';
@@ -1,2 +1,2 @@
1
- export { createPersist } from './persist';
1
+ export { persist } from './persist';
2
2
  export type { PersistStorage } from './persist';
@@ -8,16 +8,17 @@ var logger = require('../utils/logger/logger.cjs');
8
8
  /**
9
9
  * Creates a persist middleware that saves the store state to the storage.
10
10
  */
11
- const createPersist = ({ name, version = 0, storage }) => (store) => {
11
+ const persist = ({ name, version = 0, storage, store, partialize, }) => {
12
12
  store.subscribe((state) => {
13
- storage.setItem(name, JSON.stringify({ state, version }));
13
+ const persistedState = partialize(state);
14
+ storage.setItem(name, JSON.stringify({ state: persistedState, version }));
14
15
  });
15
16
  const storedState = storage.getItem(name);
16
17
  if (storedState) {
17
18
  try {
18
19
  const { state: storedStateData, version: storedVersion } = JSON.parse(storedState);
19
20
  if (storedVersion === version) {
20
- store.setState(storedStateData);
21
+ store.setState(Object.assign(store.getInitialState(), storedStateData));
21
22
  }
22
23
  }
23
24
  catch (error) {
@@ -27,4 +28,4 @@ const createPersist = ({ name, version = 0, storage }) => (store) => {
27
28
  return store;
28
29
  };
29
30
 
30
- exports.createPersist = createPersist;
31
+ exports.persist = persist;
@@ -3,13 +3,15 @@ export type PersistStorage = {
3
3
  getItem: (key: string) => string | null;
4
4
  setItem: (key: string, value: string) => void;
5
5
  };
6
- type CreatePersistProps = {
6
+ type CreatePersistProps<TStore extends object> = {
7
7
  name: string;
8
8
  version?: number;
9
9
  storage: PersistStorage;
10
+ partialize: (state: TStore) => Partial<TStore>;
11
+ store: StoreApi<TStore>;
10
12
  };
11
13
  /**
12
14
  * Creates a persist middleware that saves the store state to the storage.
13
15
  */
14
- export declare const createPersist: ({ name, version, storage }: CreatePersistProps) => <TStore extends object>(store: StoreApi<TStore>) => StoreApi<TStore>;
16
+ export declare const persist: <TStore extends object>({ name, version, storage, store, partialize, }: CreatePersistProps<TStore>) => StoreApi<TStore>;
15
17
  export {};
@@ -4,16 +4,17 @@ import { logger } from '../utils/logger/logger.js';
4
4
  /**
5
5
  * Creates a persist middleware that saves the store state to the storage.
6
6
  */
7
- const createPersist = ({ name, version = 0, storage }) => (store) => {
7
+ const persist = ({ name, version = 0, storage, store, partialize, }) => {
8
8
  store.subscribe((state) => {
9
- storage.setItem(name, JSON.stringify({ state, version }));
9
+ const persistedState = partialize(state);
10
+ storage.setItem(name, JSON.stringify({ state: persistedState, version }));
10
11
  });
11
12
  const storedState = storage.getItem(name);
12
13
  if (storedState) {
13
14
  try {
14
15
  const { state: storedStateData, version: storedVersion } = JSON.parse(storedState);
15
16
  if (storedVersion === version) {
16
- store.setState(storedStateData);
17
+ store.setState(Object.assign(store.getInitialState(), storedStateData));
17
18
  }
18
19
  }
19
20
  catch (error) {
@@ -23,4 +24,4 @@ const createPersist = ({ name, version = 0, storage }) => (store) => {
23
24
  return store;
24
25
  };
25
26
 
26
- export { createPersist };
27
+ export { persist };
@@ -1,4 +0,0 @@
1
- export type { StoreApi } from './types';
2
- export { createStore } from './createStore';
3
- export { createPersist, type PersistStorage } from './persist';
4
- export { subscribeWithSelector } from './subscribeWithSelector';