chizu 0.2.26 → 0.2.28

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.
Files changed (52) hide show
  1. package/README.md +104 -97
  2. package/dist/action/index.d.ts +19 -0
  3. package/dist/chizu.js +142 -425
  4. package/dist/chizu.umd.cjs +3 -1
  5. package/dist/decorators/index.d.ts +6 -0
  6. package/dist/error/index.d.ts +4 -0
  7. package/dist/error/types.d.ts +6 -0
  8. package/dist/hooks/index.d.ts +66 -10
  9. package/dist/hooks/types.d.ts +2 -0
  10. package/dist/hooks/utils.d.ts +18 -0
  11. package/dist/index.d.ts +6 -9
  12. package/dist/types/index.d.ts +47 -52
  13. package/dist/use/index.d.ts +5 -0
  14. package/dist/use/types.d.ts +3 -0
  15. package/dist/use/utils.d.ts +2 -0
  16. package/dist/utils/index.d.ts +28 -3
  17. package/package.json +51 -32
  18. package/dist/context/index.d.ts +0 -7
  19. package/dist/context/types.d.ts +0 -2
  20. package/dist/controller/index.d.ts +0 -3
  21. package/dist/controller/types.d.ts +0 -30
  22. package/dist/errors/index.d.ts +0 -8
  23. package/dist/errors/types.d.ts +0 -13
  24. package/dist/errors/utils.d.ts +0 -30
  25. package/dist/module/index.d.ts +0 -4
  26. package/dist/module/renderer/actions/index.d.ts +0 -3
  27. package/dist/module/renderer/actions/types.d.ts +0 -19
  28. package/dist/module/renderer/controller/index.d.ts +0 -4
  29. package/dist/module/renderer/controller/types.d.ts +0 -11
  30. package/dist/module/renderer/dispatchers/index.d.ts +0 -12
  31. package/dist/module/renderer/dispatchers/types.d.ts +0 -18
  32. package/dist/module/renderer/dispatchers/utils.d.ts +0 -10
  33. package/dist/module/renderer/elements/index.d.ts +0 -4
  34. package/dist/module/renderer/elements/types.d.ts +0 -2
  35. package/dist/module/renderer/elements/utils.d.ts +0 -4
  36. package/dist/module/renderer/index.d.ts +0 -4
  37. package/dist/module/renderer/lifecycles/index.d.ts +0 -3
  38. package/dist/module/renderer/lifecycles/types.d.ts +0 -13
  39. package/dist/module/renderer/model/index.d.ts +0 -5
  40. package/dist/module/renderer/model/types.d.ts +0 -15
  41. package/dist/module/renderer/model/utils.d.ts +0 -8
  42. package/dist/module/renderer/passive/index.d.ts +0 -1
  43. package/dist/module/renderer/types.d.ts +0 -10
  44. package/dist/module/renderer/update/index.d.ts +0 -5
  45. package/dist/module/renderer/update/types.d.ts +0 -2
  46. package/dist/module/renderer/utils.d.ts +0 -8
  47. package/dist/module/types.d.ts +0 -12
  48. package/dist/utils/produce/index.d.ts +0 -23
  49. package/dist/utils/produce/utils.d.ts +0 -15
  50. package/dist/view/index.d.ts +0 -3
  51. package/dist/view/types.d.ts +0 -16
  52. /package/dist/{utils/produce/index.test.d.ts → index.test.d.ts} +0 -0
@@ -1,16 +1,72 @@
1
- import * as React from "react";
1
+ import { Context, Model, Payload, Props, ActionsClass, Actions, UseActions } from '../types/index.ts';
2
2
  /**
3
- * Optimises the memoisation of a value based on its dependencies.
3
+ * Memoizes an action handler for performance optimization.
4
4
  *
5
- * @param factory {() => T}
6
- * @param dependencies {React.DependencyList}
7
- * @returns {T}
5
+ * @template Model The type of the model.
6
+ * @template Actions The type of the actions.
7
+ * @template Action The specific action being handled.
8
+ * @param {(context: Context<Model, Actions>, name: Action) => void} action The action handler function.
9
+ * @returns {React.useCallback} The memoized action handler.
8
10
  */
9
- export declare function useOptimisedMemo<T>(factory: () => T, dependencies: React.DependencyList): T;
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>;
10
12
  /**
11
- * Optimises the execution of an effect based on its dependencies.
13
+ * A hook for managing state with actions.
12
14
  *
13
- * @param effect {React.EffectCallback}
14
- * @param dependencies {React.DependencyList}
15
+ * Pass type parameters explicitly to get proper type inference for the returned tuple:
16
+ * `useActions<Model, typeof Actions>(initialModel, actionClass)`
17
+ *
18
+ * The hook returns a tuple containing:
19
+ * 1. The current model state
20
+ * 2. An actions object with `dispatch` and `inspect` properties
21
+ *
22
+ * The `inspect` property provides access to Immertation's annotation system,
23
+ * allowing you to check for pending operations on model properties using
24
+ * methods like `actions.inspect.count.pending()` and `actions.inspect.count.remaining()`.
25
+ *
26
+ * @template M The type of the model state.
27
+ * @template AC The type of the actions class (should be `typeof YourActionsClass`).
28
+ * @param {M} initialModel The initial model state.
29
+ * @param {Actions<M, AC> | (new () => unknown)} ActionClass The class defining the actions.
30
+ * @returns {UseActions<M, AC>} A tuple `[model, actions]` where `actions` includes `dispatch` and `inspect`.
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * // In your actions file
35
+ * export default function useCounterActions() {
36
+ * return useActions<Model, typeof Actions>(
37
+ * { count: 0 },
38
+ * class {
39
+ * [Actions.Increment] = incrementAction;
40
+ * [Actions.Decrement] = decrementAction;
41
+ * }
42
+ * );
43
+ * }
44
+ *
45
+ * // In your component
46
+ * function Counter() {
47
+ * const [model, actions] = useActions();
48
+ *
49
+ * return (
50
+ * <div>
51
+ * <p>Count: {model.count}</p>
52
+ * {actions.inspect.count.pending() && <Spinner />}
53
+ * {actions.inspect.count.pending() && (
54
+ * <p>Remaining: {actions.inspect.count.remaining()}</p>
55
+ * )}
56
+ * <button onClick={() => actions.dispatch(Actions.Increment)}>+</button>
57
+ * </div>
58
+ * );
59
+ * }
60
+ * ```
61
+ */
62
+ export declare function useActions<M extends Model, AC extends ActionsClass<any>>(initialModel: M, ActionClass: Actions<M, AC> | (new () => unknown)): UseActions<M, AC>;
63
+ /**
64
+ * Creates a snapshot of a given object, returning a memoized version.
65
+ * The snapshot provides stable access to the object's properties,
66
+ * even as the original object changes across renders.
67
+ *
68
+ * @template T The type of the object.
69
+ * @param {T} props The object to create a snapshot of.
70
+ * @returns {T} A memoized snapshot of the object.
15
71
  */
16
- export declare function useOptimisedEffect(effect: React.EffectCallback, dependencies: React.DependencyList): void;
72
+ export declare function useSnapshot<P extends Props>(props: P): P;
@@ -0,0 +1,2 @@
1
+ import { State } from 'immertation';
2
+ export type Store = State<Record<string, unknown>> | null;
@@ -0,0 +1,18 @@
1
+ import { RefObject } from 'react';
2
+ import { Props } from '../types';
3
+ /**
4
+ * @name withGetters
5
+ * @description This function creates a new object with getters for each property of the input object.
6
+ * The getters retrieve the current value from a ref, ensuring that the latest value is always accessed.
7
+ * @param {P} a The object to create getters for.
8
+ * @param {RefObject<P>} b The ref object containing the current values.
9
+ * @returns {P} A new object with getters that access the current values from the ref.
10
+ */
11
+ export declare function withGetters<P extends Props>(a: P, b: RefObject<P>): P;
12
+ /**
13
+ * @name isGenerator
14
+ * @description Checks if the given result is a generator or async generator.
15
+ * @param result The result to check.
16
+ * @returns {boolean} True if the result is a generator or async generator, false otherwise.
17
+ */
18
+ export declare function isGenerator(result: unknown): result is Generator | AsyncGenerator;
package/dist/index.d.ts CHANGED
@@ -1,11 +1,8 @@
1
- import { ControllerDefinition } from './controller/types.ts';
2
- import { ViewArgs } from './view/types.ts';
3
- export { Lifecycle, State, Boundary } from './types/index.ts';
1
+ export { ActionError } from './error/index.tsx';
2
+ export { createAction, createDistributedAction } from './action/index.ts';
3
+ export type { Pk, Context, ActionInstance, ActionsClass, UseActions, Actions, } from './types/index.ts';
4
+ export { Lifecycle } from './types/index.ts';
4
5
  export * as utils from './utils/index.ts';
5
- export { default as Scope } from './module/index.tsx';
6
6
  export { Broadcaster } from './broadcast/index.tsx';
7
- export { useScoped } from './module/renderer/utils.ts';
8
- export { isTypedError, TypedError } from './errors/utils.ts';
9
- export type { Schema, Pk } from './types/index.ts';
10
- export type { ViewArgs as Scoped };
11
- export type { ControllerDefinition as Actions };
7
+ export { useActions, useAction, useSnapshot } from './hooks/index.ts';
8
+ export { Operation, Op, State } from 'immertation';
@@ -1,58 +1,53 @@
1
- export declare enum Transmit {
2
- Unicast = "unicast",
3
- Multicast = "multicast",
4
- Broadcast = "broadcast"
1
+ import { Operation, Process, Inspect } from 'immertation';
2
+ import { context } from '../use';
3
+ export declare class Lifecycle {
4
+ static Mount: symbol;
5
+ static Node: symbol;
6
+ static Derive: symbol;
7
+ static Error: symbol;
8
+ static Unmount: symbol;
5
9
  }
6
- export declare class Draft<T> {
7
- value: T;
8
- constructor(value: T);
9
- }
10
- export declare class State {
11
- static Op: {
12
- Add: number;
13
- Remove: number;
14
- Update: number;
15
- Move: number;
16
- Replace: number;
17
- };
18
- static Draft<T>(value: T): Draft<T>;
19
- }
20
- export type ActionName = Lifecycle | symbol | string | number;
21
- type ActionPayload = [any, ...any[]];
22
- export declare enum Lifecycle {
23
- Mount = "lifecycle/mount",
24
- Node = "lifecycle/node",
25
- Derive = "lifecycle/derive",
26
- Error = "lifecycle/error",
27
- Unmount = "lifecycle/unmount"
28
- }
29
- export type Model = Record<symbol | string, any>;
30
- export type Actions = [] | [ActionName] | [ActionName, ...ActionPayload];
31
- export type Props = Record<string, unknown>;
32
- export type Context = Record<string, React.Context<any>>;
33
- export type Schema<M extends Model, A extends Actions = [], P extends Props = Record<string, never>> = {
34
- Model: M;
35
- Actions: A;
36
- Props: P;
37
- };
38
- export type ModuleDefinition = {
39
- Model: Model;
40
- Actions: Actions;
41
- Props: Props;
42
- };
43
10
  export type Pk<T> = undefined | symbol | T;
44
11
  export type Task = PromiseWithResolvers<void>;
45
- export type Process = symbol;
46
- export type Op = number;
47
- export declare enum Boundary {
48
- Default = 0,
49
- Error = 1
50
- }
51
- export type Meta = {
52
- boundary: Boundary;
12
+ export type Model<M = Record<string, unknown>> = M;
13
+ export declare const PayloadKey: unique symbol;
14
+ export type Payload<T = unknown> = symbol & {
15
+ [PayloadKey]: T;
16
+ };
17
+ type PayloadType<A> = A extends Payload<infer P> ? P : never;
18
+ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
19
+ export type Props = Record<string, unknown>;
20
+ export type Action = symbol | string;
21
+ export type ActionsClass<AC extends Record<string, Payload<any>>> = {
22
+ new (): unknown;
23
+ } & AC;
24
+ export type ActionInstance<M extends Model, AC extends ActionsClass<any>> = UnionToIntersection<AC[keyof AC] extends infer P ? P extends symbol ? P extends Payload<infer T> ? {
25
+ [K in P]: ((context: Context<M, AC>, payload: T) => void | Promise<void>) & {
26
+ payload: T;
27
+ };
28
+ } : never : never : never>;
29
+ export type Result = {
30
+ processes: Set<Process>;
53
31
  };
54
- export type ContextType<T> = T extends React.Context<infer U> ? U : never;
55
- export type ContextTypes<T extends Record<string, React.Context<any>>> = {
56
- [K in keyof T]: ContextType<T[K]>;
32
+ export type OperationFunction = <T>(value: T, process: Process) => T;
33
+ export type Context<M extends Model, AC extends ActionsClass<any>> = {
34
+ model: M;
35
+ signal: AbortSignal;
36
+ actions: {
37
+ produce(ƒ: (model: M) => void): M;
38
+ dispatch<A extends AC[keyof AC] & Payload<any>>(...args: [PayloadType<A>] extends [never] ? [A] : [A, PayloadType<A>]): void;
39
+ annotate<T>(operation: Operation, value: T): T;
40
+ };
41
+ [context]: {
42
+ controller: AbortController;
43
+ };
57
44
  };
45
+ export type Actions<M extends Model, AC extends ActionsClass<any>> = new () => ActionInstance<M, AC>;
46
+ export type UseActions<M extends Model, AC extends ActionsClass<any>> = [
47
+ M,
48
+ {
49
+ dispatch<A extends AC[keyof AC] & Payload<any>>(...args: [PayloadType<A>] extends [never] ? [A] : [A, PayloadType<A>]): void;
50
+ inspect: Inspect<M>;
51
+ }
52
+ ];
58
53
  export {};
@@ -0,0 +1,5 @@
1
+ import { Field } from './types';
2
+ export { context } from './utils';
3
+ export declare const use: {
4
+ serial(): (_: unknown, field: Field) => void;
5
+ };
@@ -0,0 +1,3 @@
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>>;
@@ -0,0 +1,2 @@
1
+ export declare const contexts: WeakMap<typeof context, any>;
2
+ export declare const context: unique symbol;
@@ -1,6 +1,31 @@
1
- import { Pk } from '../types/index.ts';
1
+ import { ActionsClass, Context, Model, Payload, Pk } from '../types/index.ts';
2
2
  export { default as sleep } from './sleep/index.ts';
3
+ /**
4
+ * Generates a unique primary key.
5
+ * @returns A new unique symbol representing the primary key.
6
+ */
3
7
  export declare function pk(): symbol;
8
+ /**
9
+ * Checks if the provided ID is a valid primary key.
10
+ * A valid primary key is considered any value that is not a symbol.
11
+ * @template T The type of the object.
12
+ * @param id The primary key to validate.
13
+ * @returns `true` if the ID is valid, `false` otherwise.
14
+ */
4
15
  export declare function pk<T>(id: Pk<T>): boolean;
5
- export declare function hash<T>(x: T): string;
6
- export declare const meta: unique symbol;
16
+ /** Shorthand alias for {@link pk}. */
17
+ export declare const κ: typeof pk;
18
+ /**
19
+ * Creates a generic "setter" action that updates a specific property in the state.
20
+ * This is a higher-order function that takes a property name and returns an action function.
21
+ * The returned action, when called, will update the state with the provided payload for the specified property.
22
+ * It uses `produce` to handle immutable state updates.
23
+ *
24
+ * @template M The model (state) type.
25
+ * @template A The actions type.
26
+ * @param property The name of the property in the state to update.
27
+ * @returns An action function that takes the context and a payload, and updates the state.
28
+ */
29
+ export declare function set<M extends Model, AC extends ActionsClass<any>>(property: string): (context: Context<M, AC>, payload: Payload) => void;
30
+ /** Shorthand alias for {@link set}. */
31
+ export declare const λ: typeof set;
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "chizu",
3
- "version": "0.2.26",
3
+ "version": "0.2.28",
4
4
  "type": "module",
5
+ "license": "MIT",
5
6
  "main": "./dist/chizu.js",
6
7
  "types": "./dist/index.d.ts",
7
8
  "exports": {
@@ -13,52 +14,70 @@
13
14
  },
14
15
  "dependencies": {
15
16
  "eventemitter3": "^5.0.1",
16
- "immer": "^10.1.1",
17
+ "immertation": "^0.1.15",
17
18
  "lodash": "^4.17.21",
18
- "react": "^19.1.0",
19
- "traverse": "0.6.8"
19
+ "traverse": "0.6.11"
20
+ },
21
+ "peerDependencies": {
22
+ "@mobily/ts-belt": "^3.0.0",
23
+ "immer": "^10.0.0",
24
+ "react": "^18.0.0 || ^19.0.0",
25
+ "react-dom": "^18.0.0 || ^19.0.0"
20
26
  },
21
27
  "files": [
22
28
  "dist"
23
29
  ],
24
30
  "scripts": {
31
+ "build": "vite build",
32
+ "build:example": "vite build --mode example --outDir dist-example --base /Chizu/",
33
+ "dev": "vite",
34
+ "preview": "vite preview",
25
35
  "release": "make checks"
26
36
  },
27
37
  "devDependencies": {
28
- "@babel/preset-env": "^7.27.2",
29
- "@babel/preset-react": "^7.27.1",
30
- "@babel/preset-typescript": "^7.27.1",
38
+ "@babel/plugin-proposal-decorators": "^7.28.0",
39
+ "@babel/preset-env": "^7.28.5",
40
+ "@babel/preset-react": "^7.28.5",
41
+ "@babel/preset-typescript": "^7.28.5",
31
42
  "@emotion/css": "^11.13.5",
32
- "@eslint/js": "^9.27.0",
33
- "@jest/globals": "^30.0.0-beta.3",
34
- "@testing-library/dom": "^10.4.0",
35
- "@testing-library/jest-dom": "^6.6.3",
43
+ "@eslint/js": "^9.39.1",
44
+ "@faker-js/faker": "^10.1.0",
45
+ "@jest/globals": "^30.2.0",
46
+ "@mobily/ts-belt": "^3.13.1",
47
+ "@testing-library/dom": "^10.4.1",
48
+ "@testing-library/jest-dom": "^6.9.1",
36
49
  "@testing-library/react": "^16.3.0",
37
- "@types/lodash": "^4.17.17",
38
- "@types/react": "^19.1.6",
39
- "@types/react-dom": "^19.1.5",
50
+ "@types/lodash": "^4.17.21",
51
+ "@types/ramda": "^0.31.1",
52
+ "@types/react": "^19.2.7",
53
+ "@types/react-dom": "^19.2.3",
40
54
  "@types/traverse": "^0.6.37",
41
- "commit-and-tag-version": "^12.5.1",
42
- "dayjs": "^1.11.13",
43
- "dexie": "^4.0.11",
44
- "eslint": "^9.27.0",
55
+ "@vitejs/plugin-react": "^5.1.1",
56
+ "commit-and-tag-version": "^12.6.1",
57
+ "dayjs": "^1.11.19",
58
+ "dexie": "^4.2.1",
59
+ "eslint": "^9.39.1",
45
60
  "eslint-plugin-react": "^7.37.5",
46
61
  "get-port-cli": "^3.0.0",
47
- "globals": "^16.2.0",
48
- "jest": "^29.7.0",
49
- "jest-environment-jsdom": "^30.0.0-beta.3",
50
- "lucide-react": "^0.511.0",
51
- "prettier": "^3.5.3",
52
- "react-dom": "^19.1.0",
53
- "react-router-dom": "^7.6.1",
54
- "react-test-renderer": "^19.1.0",
55
- "rollup-plugin-visualizer": "^6.0.1",
56
- "ts-jest": "^29.3.4",
62
+ "globals": "^16.5.0",
63
+ "immer": "^11.0.1",
64
+ "jest": "^30.2.0",
65
+ "jest-environment-jsdom": "^30.2.0",
66
+ "lucide-react": "^0.555.0",
67
+ "prettier": "^3.7.4",
68
+ "ramda": "^0.32.0",
69
+ "react": "^19.2.1",
70
+ "react-dom": "^19.2.1",
71
+ "react-flip-numbers": "^3.0.9",
72
+ "react-router-dom": "^7.10.1",
73
+ "react-test-renderer": "^19.2.1",
74
+ "rollup-plugin-visualizer": "^6.0.5",
75
+ "ts-jest": "^29.4.6",
57
76
  "ts-node": "^10.9.2",
58
- "typescript": "^5.8.3",
59
- "typescript-eslint": "^8.33.0",
60
- "vite": "^6.3.5",
77
+ "typescript": "^5.9.3",
78
+ "typescript-eslint": "^8.48.1",
79
+ "vite": "^7.2.6",
61
80
  "vite-plugin-dts": "^4.5.4",
62
- "wait-on": "^8.0.3"
81
+ "wait-on": "^9.0.3"
63
82
  }
64
83
  }
@@ -1,7 +0,0 @@
1
- import { Context, ContextTypes } from '../types/index.ts';
2
- import * as React from "react";
3
- export default function useContext<C extends Context>(): {
4
- use: React.RefObject<C>;
5
- values: React.RefObject<ContextTypes<C>>;
6
- update: () => void;
7
- };
@@ -1,2 +0,0 @@
1
- import { default as useContext } from './index.ts';
2
- export type UseContext = ReturnType<typeof useContext>;
@@ -1,3 +0,0 @@
1
- import { ModuleDefinition } from '../types/index.ts';
2
- import { ControllerDefinition } from './types.ts';
3
- export default function controller<M extends ModuleDefinition>(definition: ControllerDefinition<M>): ControllerDefinition<M>;
@@ -1,30 +0,0 @@
1
- import { TypedError } from '../errors/utils.ts';
2
- import { Models } from '../module/renderer/model/utils.ts';
3
- import { Head } from '../module/renderer/types.ts';
4
- import { Actions, Context, ContextTypes, Draft, Lifecycle, Meta, ModuleDefinition, Op } from '../types/index.ts';
5
- export type ControllerActions<M extends ModuleDefinition> = {
6
- annotate<T>(value: T, operations?: (Op | Draft<T>)[]): T;
7
- produce(ƒ: (model: M["Model"], meta: Meta) => void): (models: Models<M["Model"]>, process: symbol) => Models<M["Model"]>;
8
- dispatch(action: M["Actions"]): Promise<void>;
9
- context<C extends Context>(context: C): ContextTypes<C>;
10
- };
11
- export type ControllerArgs<M extends ModuleDefinition> = Readonly<{
12
- model: Readonly<M["Model"]>;
13
- props: Readonly<M["Props"]>;
14
- actions: Readonly<ControllerActions<M>>;
15
- }>;
16
- export type ActionEvent<M extends ModuleDefinition> = (...args: M["Actions"][number]) => ActionGenerator<M>;
17
- type ActionEvents<M extends ModuleDefinition> = {
18
- [K in Head<M["Actions"]>]: (payload: Payload<M["Actions"], K>) => ActionGenerator<M>;
19
- };
20
- export type ActionGenerator<M extends ModuleDefinition> = void | Promise<void> | ((models: Models<M["Model"]>, process: symbol) => Models<M["Model"]>) | Promise<(models: Models<M["Model"]>, process: symbol) => Models<M["Model"]>> | AsyncGenerator<(models: Models<M["Model"]>, process: symbol) => Models<M["Model"]>, (models: Models<M["Model"]>, process: symbol) => Models<M["Model"]>, unknown>;
21
- export type ControllerDefinition<M extends ModuleDefinition> = (controller: ControllerArgs<M>) => ControllerInstance<M>;
22
- export type ControllerInstance<M extends ModuleDefinition> = {
23
- [Lifecycle.Mount]?(): ActionGenerator<M>;
24
- [Lifecycle.Derive]?(): ActionGenerator<M>;
25
- [Lifecycle.Node]?(tree: HTMLElement): ActionGenerator<M>;
26
- [Lifecycle.Error]?(error: Error | TypedError): ActionGenerator<M>;
27
- [Lifecycle.Unmount]?(): ActionGenerator<M>;
28
- } & Partial<ActionEvents<M>>;
29
- type Payload<A extends Actions, K> = A extends [K, infer P] ? P : never;
30
- export {};
@@ -1,8 +0,0 @@
1
- import { Props } from './types.ts';
2
- import { ModuleDefinition } from '../types/index.ts';
3
- import * as React from "react";
4
- export default class ErrorBoundary<M extends ModuleDefinition> extends React.Component<Props<M>> {
5
- constructor(props: Props<M>);
6
- componentDidCatch(error: unknown): void;
7
- render(): import("react/jsx-runtime").JSX.Element;
8
- }
@@ -1,13 +0,0 @@
1
- import { ModuleDefinition } from '../types/index.ts';
2
- import { ViewArgs } from '../view/types.ts';
3
- import { UseModel } from '../module/renderer/model/types.ts';
4
- import { UseDispatchers } from '../module/renderer/dispatchers/types.ts';
5
- import { UseUpdate } from '../module/renderer/update/types.ts';
6
- import * as React from "react";
7
- export type Props<M extends ModuleDefinition> = {
8
- module: ViewArgs<M>;
9
- model: UseModel;
10
- dispatchers: UseDispatchers;
11
- update: UseUpdate;
12
- children(): React.ReactNode;
13
- };
@@ -1,30 +0,0 @@
1
- import { ModuleDefinition } from '../types/index.ts';
2
- import { Props } from './types.ts';
3
- /**
4
- * Check if the error is an instance of TypedError.
5
- *
6
- * @param error {Error | TypedError}
7
- * @returns {boolean}
8
- */
9
- export declare function isTypedError(error: Error | TypedError): error is TypedError;
10
- /**
11
- * Convert an unknown error into a known error type.
12
- *
13
- * @function intoError
14
- * @param error {unknown} - The error to convert to a known error type.
15
- * @returns {Error | TypedError}
16
- */
17
- export declare function intoError(error: unknown): Error | TypedError;
18
- /**
19
- * @class TypedError
20
- * @extends Error
21
- * @param type {string} - The type of the error.
22
- * @param message {string} - The error message.
23
- */
24
- export declare class TypedError extends Error {
25
- #private;
26
- constructor(type: number | string | symbol, message?: null | string);
27
- get type(): number | string | symbol;
28
- get message(): string;
29
- }
30
- export declare function Child<M extends ModuleDefinition>({ children, }: Pick<Props<M>, "children">): React.ReactNode;
@@ -1,4 +0,0 @@
1
- import { ModuleDefinition } from '../types/index.ts';
2
- import { UseOptions } from './types.ts';
3
- import * as React from "react";
4
- export default function Scope<M extends ModuleDefinition>(options: UseOptions<M>): React.ReactNode;
@@ -1,3 +0,0 @@
1
- import { ModuleDefinition } from '../../../types/index.ts';
2
- import { Props, UseActions } from './types.ts';
3
- export default function useActions<M extends ModuleDefinition>(props: Props<M>): UseActions<M>;
@@ -1,19 +0,0 @@
1
- import { UseBroadcast } from '../../../broadcast/types.ts';
2
- import { UseContext } from '../../../context/types.ts';
3
- import { ControllerArgs } from '../../../controller/types.ts';
4
- import { ModuleDefinition } from '../../../types/index.ts';
5
- import { ViewArgs } from '../../../view/types.ts';
6
- import { UseOptions } from '../../types.ts';
7
- import { UseDispatchers } from '../dispatchers/types.ts';
8
- import { UseModel } from '../model/types.ts';
9
- export type Props<M extends ModuleDefinition> = {
10
- broadcast: UseBroadcast;
11
- options: UseOptions<M>;
12
- model: UseModel;
13
- dispatchers: UseDispatchers;
14
- context: UseContext;
15
- };
16
- export type UseActions<M extends ModuleDefinition> = {
17
- controller: ControllerArgs<M>;
18
- view: ViewArgs<M>;
19
- };
@@ -1,4 +0,0 @@
1
- import { ModuleDefinition } from '../../../types/index.ts';
2
- import { Props } from './types.ts';
3
- import { ControllerInstance } from '../../../controller/types.ts';
4
- export default function useController<M extends ModuleDefinition>(props: Props<M>): ControllerInstance<M> | undefined;
@@ -1,11 +0,0 @@
1
- import { ModuleDefinition } from '../../../types/index.ts';
2
- import { UseOptions } from '../../types.ts';
3
- import { UseActions } from '../actions/types.ts';
4
- import { UseDispatchers } from '../dispatchers/types.ts';
5
- import { default as useController } from './index.ts';
6
- export type Props<M extends ModuleDefinition> = {
7
- actions: UseActions<M>;
8
- options: UseOptions<M>;
9
- dispatchers: UseDispatchers;
10
- };
11
- export type UseController = ReturnType<typeof useController>;
@@ -1,12 +0,0 @@
1
- import { ActionEvent } from '../../../controller/types.ts';
2
- import { ModuleDefinition, Task } from '../../../types/index.ts';
3
- import { Head, Tail } from '../types.ts';
4
- import { Props } from './types.ts';
5
- /**
6
- * @param props {Props<M>}
7
- * @returns { attach: (action: Head<M["Actions"]>, ƒ: F) => void; dispatch: (action: Head<M["Actions"]>, data: Tail<M["Actions"]>) => void; }
8
- */
9
- export default function useDispatchers<M extends ModuleDefinition>(props: Props<M>): {
10
- attach<F extends ActionEvent<M>>(action: Head<M["Actions"]>, ƒ: F): void;
11
- dispatch(action: Head<M["Actions"]>, data: Tail<M["Actions"]>, task?: Task): void;
12
- };
@@ -1,18 +0,0 @@
1
- import { default as EventEmitter } from 'eventemitter3';
2
- import { UseBroadcast } from '../../../broadcast/types.ts';
3
- import { ModuleDefinition } from '../../../types/index.ts';
4
- import { UseOptions } from '../../types.ts';
5
- import { UseModel } from '../model/types.ts';
6
- import { UseUpdate } from '../update/types.ts';
7
- import { default as useDispatchers } from './index.ts';
8
- export type Props<M extends ModuleDefinition> = {
9
- broadcast: UseBroadcast;
10
- options: UseOptions<M>;
11
- update: UseUpdate;
12
- model: UseModel;
13
- };
14
- export type UseDispatchers = ReturnType<typeof useDispatchers>;
15
- export type UseDispatchHandlerProps<M extends ModuleDefinition> = Props<M> & {
16
- unicast: EventEmitter;
17
- };
18
- export type Fn = (...args: any[]) => void;
@@ -1,10 +0,0 @@
1
- import { ActionEvent } from '../../../controller/types.ts';
2
- import { ModuleDefinition, Task } from '../../../types/index.ts';
3
- import { Head, Tail } from '../types.ts';
4
- import { UseDispatchHandlerProps } from './types.ts';
5
- /**
6
- * @function useDispatcher
7
- * @param props {UseDispatchHandlerProps<M>}
8
- * @returns {(name: Head<M["Actions"]>, ƒ: GeneratorFn<M>) => (payload: Tail<M["Actions"]>) => Promise<void>}
9
- */
10
- export declare function useDispatcher<M extends ModuleDefinition>(props: UseDispatchHandlerProps<M>): (_name: Head<M["Actions"]>, ƒ: ActionEvent<M>) => (task: Task | undefined, payload: Tail<M["Actions"]>) => Promise<void>;
@@ -1,4 +0,0 @@
1
- import * as React from "react";
2
- export default function useElements(): {
3
- customElement: React.RefObject<HTMLElement | null>;
4
- };
@@ -1,2 +0,0 @@
1
- import { default as useElements } from './index.ts';
2
- export type UseElements = ReturnType<typeof useElements>;
@@ -1,4 +0,0 @@
1
- /**
2
- * @returns {string}
3
- */
4
- export declare function useCacheKey(): string;
@@ -1,4 +0,0 @@
1
- import { ModuleDefinition } from '../../types/index.ts';
2
- import { Props } from './types.ts';
3
- import * as React from "react";
4
- export default function Renderer<M extends ModuleDefinition>({ options, }: Props<M>): React.ReactNode;
@@ -1,3 +0,0 @@
1
- import { ModuleDefinition } from '../../../types/index.ts';
2
- import { Props } from './types.ts';
3
- export default function useLifecycles<M extends ModuleDefinition>(props: Props<M>): void;