chizu 0.2.28 → 0.2.31

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.
@@ -8,7 +8,7 @@ import { Context, Model, Payload, Props, ActionsClass, Actions, UseActions } fro
8
8
  * @param {(context: Context<Model, Actions>, name: Action) => void} action The action handler function.
9
9
  * @returns {React.useCallback} The memoized action handler.
10
10
  */
11
- export declare function useAction<M extends Model, AC extends ActionsClass<any> = never>(handler: (context: Context<M, AC>, payload: AC extends Payload<infer P> ? P : never) => void | Promise<void> | AsyncGenerator | Generator): (context: Context<M, AC>, payload: AC extends Payload<infer P> ? P : never) => Promise<void>;
11
+ export declare function useAction<M extends Model, AC extends ActionsClass<any>, K extends Exclude<keyof AC, "prototype"> | never = never>(handler: (context: Context<M, AC>, payload: [K] extends [never] ? unknown : AC[K] extends Payload<infer P> ? P : unknown) => void | Promise<void> | AsyncGenerator | Generator): (context: Context<M, AC>, payload: [K] extends [never] ? unknown : AC[K] extends Payload<infer P> ? P : unknown) => Promise<void>;
12
12
  /**
13
13
  * A hook for managing state with actions.
14
14
  *
@@ -1,3 +1,8 @@
1
- import { ActionsClass, Context, Model } from '../types';
2
- export type Field = ClassFieldDecoratorContext<any, Context<Model, ActionsClass<any>>>;
3
- export type Args = Context<Model, ActionsClass<any>>;
1
+ import { ActionsClass, Context, Model, Payload } from '../types';
2
+ export type Field = ClassFieldDecoratorContext<object, Context<Model, ActionsClass<Record<string, Payload>>>>;
3
+ export type Args = Context<Model, ActionsClass<Record<string, Payload>>>;
4
+ export type Instance = Record<string | symbol, unknown>;
5
+ export type Method = (args: Args) => Promise<unknown>;
6
+ export type ContextValue = {
7
+ controller: AbortController;
8
+ };
@@ -1,2 +1,3 @@
1
- export declare const contexts: WeakMap<typeof context, any>;
1
+ import { ContextValue } from './types';
2
+ export declare const contexts: WeakMap<object, ContextValue>;
2
3
  export declare const context: unique symbol;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chizu",
3
- "version": "0.2.28",
3
+ "version": "0.2.31",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "main": "./dist/chizu.js",
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "dependencies": {
16
16
  "eventemitter3": "^5.0.1",
17
- "immertation": "^0.1.15",
17
+ "immertation": "^0.1.16",
18
18
  "lodash": "^4.17.21",
19
19
  "traverse": "0.6.11"
20
20
  },