ccstate-svelte 4.2.0 → 4.3.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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # ccstate-svelte
2
2
 
3
+ ## 4.3.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [89d98a2]
8
+ - ccstate@4.3.0
9
+
3
10
  ## 4.2.0
4
11
 
5
12
  ### Patch Changes
package/dist/index.d.cts CHANGED
@@ -1,11 +1,11 @@
1
- import { State, Computed, Updater, Command, Store } from 'ccstate';
1
+ import { State, Computed, StateArg, Command, Store } from 'ccstate';
2
2
 
3
3
  declare function useGet<T>(atom: State<T> | Computed<T>): {
4
4
  subscribe(fn: (payload: T) => void): () => void;
5
5
  };
6
6
 
7
- declare function useSet<T>(atom: State<T>): (value: T | Updater<T>) => void;
8
- declare function useSet<T, ARGS extends unknown[]>(atom: Command<T, ARGS>): (...args: ARGS) => T;
7
+ declare function useSet<T>(atom: State<T>): (value: StateArg<T>) => void;
8
+ declare function useSet<T, CommandArgs extends unknown[]>(atom: Command<T, CommandArgs>): (...args: CommandArgs) => T;
9
9
 
10
10
  declare const provideStore: (store: Store) => void;
11
11
  declare const useStore: () => Store;
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- import { State, Computed, Updater, Command, Store } from 'ccstate';
1
+ import { State, Computed, StateArg, Command, Store } from 'ccstate';
2
2
 
3
3
  declare function useGet<T>(atom: State<T> | Computed<T>): {
4
4
  subscribe(fn: (payload: T) => void): () => void;
5
5
  };
6
6
 
7
- declare function useSet<T>(atom: State<T>): (value: T | Updater<T>) => void;
8
- declare function useSet<T, ARGS extends unknown[]>(atom: Command<T, ARGS>): (...args: ARGS) => T;
7
+ declare function useSet<T>(atom: State<T>): (value: StateArg<T>) => void;
8
+ declare function useSet<T, CommandArgs extends unknown[]>(atom: Command<T, CommandArgs>): (...args: CommandArgs) => T;
9
9
 
10
10
  declare const provideStore: (store: Store) => void;
11
11
  declare const useStore: () => Store;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccstate-svelte",
3
- "version": "4.2.0",
3
+ "version": "4.3.0",
4
4
  "description": "CCState Svelte Hooks",
5
5
  "repository": {
6
6
  "type": "git",
@@ -17,7 +17,7 @@
17
17
  }
18
18
  },
19
19
  "dependencies": {
20
- "ccstate": "^4.2.0"
20
+ "ccstate": "^4.3.0"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@babel/preset-env": "^7.26.0",
@@ -38,7 +38,7 @@
38
38
  "svelte": "^5.15.0",
39
39
  "vite": "^6.0.5",
40
40
  "vitest": "^2.1.8",
41
- "ccstate": "^4.2.0"
41
+ "ccstate": "^4.3.0"
42
42
  },
43
43
  "scripts": {
44
44
  "build": "rollup -c",
package/src/useSet.ts CHANGED
@@ -1,22 +1,22 @@
1
1
  import { useStore } from './provider';
2
- import type { Command, Updater, State } from 'ccstate';
2
+ import type { Command, State, StateArg } from 'ccstate';
3
3
 
4
- export function useSet<T>(atom: State<T>): (value: T | Updater<T>) => void;
5
- export function useSet<T, ARGS extends unknown[]>(atom: Command<T, ARGS>): (...args: ARGS) => T;
6
- export function useSet<T, ARGS extends unknown[]>(
7
- atom: State<T> | Command<T, ARGS>,
8
- ): ((value: T | Updater<T>) => void) | ((...args: ARGS) => T) {
4
+ export function useSet<T>(atom: State<T>): (value: StateArg<T>) => void;
5
+ export function useSet<T, CommandArgs extends unknown[]>(atom: Command<T, CommandArgs>): (...args: CommandArgs) => T;
6
+ export function useSet<T, CommandArgs extends unknown[]>(
7
+ atom: State<T> | Command<T, CommandArgs>,
8
+ ): ((value: StateArg<T>) => void) | ((...args: CommandArgs) => T) {
9
9
  const store = useStore();
10
10
 
11
11
  if ('write' in atom) {
12
- return (...args: ARGS): T => {
12
+ return (...args: CommandArgs): T => {
13
13
  const ret = store.set(atom, ...args);
14
14
 
15
15
  return ret;
16
16
  };
17
17
  }
18
18
 
19
- return (value: T | Updater<T>) => {
19
+ return (value: StateArg<T>) => {
20
20
  store.set(atom, value);
21
21
  };
22
22
  }