@codeleap/store 4.3.9 → 5.0.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeleap/store",
3
- "version": "4.3.9",
3
+ "version": "5.0.1",
4
4
  "main": "src/index.ts",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -9,15 +9,15 @@
9
9
  "directory": "packages/store"
10
10
  },
11
11
  "devDependencies": {
12
- "@codeleap/config": "4.3.9",
12
+ "@codeleap/config": "5.0.1",
13
13
  "ts-node-dev": "1.1.8"
14
14
  },
15
15
  "scripts": {
16
16
  "build": "echo 'No build needed'"
17
17
  },
18
18
  "peerDependencies": {
19
- "typescript": "5.0.4",
20
- "react": "18.1.0",
19
+ "typescript": "5.5.2",
20
+ "react": "18.2.0",
21
21
  "nanostores": "*",
22
22
  "@nanostores/react": "*",
23
23
  "@nanostores/persistent": "*"
package/package.json.bak CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeleap/store",
3
- "version": "4.3.9",
3
+ "version": "5.0.1",
4
4
  "main": "src/index.ts",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -16,8 +16,8 @@
16
16
  "build": "echo 'No build needed'"
17
17
  },
18
18
  "peerDependencies": {
19
- "typescript": "5.0.4",
20
- "react": "18.1.0",
19
+ "typescript": "5.5.2",
20
+ "react": "18.2.0",
21
21
  "nanostores": "*",
22
22
  "@nanostores/react": "*",
23
23
  "@nanostores/persistent": "*"
package/src/types.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { WritableAtom } from 'nanostores'
1
+ import { WritableAtom } from 'nanostores'
2
2
  import { PersistentStore, PersistentEvents, PersistentEvent } from '@nanostores/persistent'
3
3
 
4
4
  export type StateSelector<S, R> = (state: S) => R
package/src/utils.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { useStore } from '@nanostores/react'
2
- import { WritableStore } from 'nanostores'
2
+ import { WritableAtom } from 'nanostores'
3
3
  import { useMemo } from 'react'
4
4
 
5
5
  export function stateAssign<T>(newValue: Partial<T>, stateValue: T): T {
@@ -17,9 +17,9 @@ export function stateAssign<T>(newValue: Partial<T>, stateValue: T): T {
17
17
  }
18
18
 
19
19
  export const createStateSlice = <T, R>(
20
- store: WritableStore<T>,
20
+ store: WritableAtom<T>,
21
21
  selector: (state: T) => R,
22
- deselector?: (result: R) => T extends Record<string, any> ? Partial<T> : T
22
+ deselector?: (result: R) => Partial<T>
23
23
  ) => ({
24
24
  get: () => selector(store.get()),
25
25
  listen: (listener: (value: R) => void) => {
@@ -39,10 +39,10 @@ export const createStateSlice = <T, R>(
39
39
 
40
40
  store.set(newValue)
41
41
  }
42
- } as WritableStore<R>)
42
+ } as WritableAtom<R>)
43
43
 
44
44
  export function useStateSelector<T, R>(
45
- store: WritableStore<T>,
45
+ store: WritableAtom<T>,
46
46
  selector: (state: T) => R
47
47
  ): R {
48
48
  const slice = useMemo(() => createStateSlice(store, selector), [selector])