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,13 +0,0 @@
1
- import { ModuleDefinition } from '../../../types/index.ts';
2
- import { UseOptions } from '../../types.ts';
3
- import { UseDispatchers } from '../dispatchers/types.ts';
4
- import { UseElements } from '../elements/types.ts';
5
- import { UseUpdate } from '../update/types.ts';
6
- import { default as useLifecycles } from './index.ts';
7
- export type Props<M extends ModuleDefinition> = {
8
- options: UseOptions<M>;
9
- elements: UseElements;
10
- dispatchers: UseDispatchers;
11
- update: UseUpdate;
12
- };
13
- export type UseLifecycles = ReturnType<typeof useLifecycles>;
@@ -1,5 +0,0 @@
1
- import { ModuleDefinition } from '../../../types/index.ts';
2
- import { Props } from './types.ts';
3
- import { Models } from './utils.ts';
4
- import * as React from "react";
5
- export default function useModel<M extends ModuleDefinition>(props: Props<M>): React.RefObject<Models<M["Model"]>>;
@@ -1,15 +0,0 @@
1
- import { default as useModel } from '.';
2
- import { ModuleDefinition, State } from '../../../types/index.ts';
3
- import { UseOptions } from '../../types.ts';
4
- export type Props<M extends ModuleDefinition> = {
5
- options: UseOptions<M>;
6
- };
7
- export type UseModel = ReturnType<typeof useModel>;
8
- export type Validate = {
9
- pending(): boolean;
10
- is(operation: State): boolean;
11
- draft<T>(): T;
12
- };
13
- export type Validatable<M> = {
14
- [K in keyof M]: M[K] extends object ? M[K] extends Array<infer U> ? Array<Validatable<U> & Validate> & Validate : Validatable<M[K]> & Validate : M[K] & Validate;
15
- } & Validate;
@@ -1,8 +0,0 @@
1
- import { ModuleDefinition } from '../../../types/index.ts';
2
- import { Validatable } from './types.ts';
3
- export declare class Models<M extends ModuleDefinition["Model"]> {
4
- stateless: M;
5
- stateful: M;
6
- constructor(stateless: M, stateful?: M);
7
- get validatable(): Validatable<M>;
8
- }
@@ -1 +0,0 @@
1
- export default function usePassive(): import('react').RefObject<number>;
@@ -1,10 +0,0 @@
1
- import { ModuleDefinition } from '../../types/index.ts';
2
- import { UseOptions } from '../types.ts';
3
- import * as React from "react";
4
- export type ElementName = string;
5
- export type Remount = React.ActionDispatch<[]>;
6
- export type Props<M extends ModuleDefinition> = {
7
- options: UseOptions<M>;
8
- };
9
- export type Head<T extends any[]> = T extends [infer X, ...any[]] ? X : never;
10
- export type Tail<T extends any[]> = T extends [any, ...infer XS] ? XS : never;
@@ -1,5 +0,0 @@
1
- import * as React from "react";
2
- export default function useUpdate(): {
3
- hash: number;
4
- rerender: React.ActionDispatch<[]>;
5
- };
@@ -1,2 +0,0 @@
1
- import { default as useUpdate } from '.';
2
- export type UseUpdate = ReturnType<typeof useUpdate>;
@@ -1,8 +0,0 @@
1
- import { ModuleDefinition } from '../../types';
2
- import { ViewArgs } from '../../view/types';
3
- import * as React from "react";
4
- export declare const config: {
5
- elementName: string;
6
- };
7
- export declare const Context: React.Context<ViewArgs<ModuleDefinition> | null>;
8
- export declare function useScoped<M extends ModuleDefinition>(): ViewArgs<M>;
@@ -1,12 +0,0 @@
1
- import { ControllerDefinition } from '../controller/types.ts';
2
- import { ModuleDefinition } from '../types/index.ts';
3
- import { ViewArgs } from '../view/types.ts';
4
- export type UseOptions<M extends ModuleDefinition> = {
5
- using: {
6
- model: M["Model"];
7
- actions: ControllerDefinition<M>;
8
- props?: M["Props"];
9
- };
10
- passive?: boolean;
11
- children(module: ViewArgs<M>): React.ReactNode;
12
- };
@@ -1,23 +0,0 @@
1
- import { Models } from '../../module/renderer/model/utils.ts';
2
- import { Meta, ModuleDefinition, Process } from '../../types/index.ts';
3
- /**
4
- * Produces a new model by applying a series of patches to the given model.
5
- * This function uses Immer to handle immutable updates and applies additional
6
- * processing for `State` instances within the patches.
7
- *
8
- * @template M - The type of the model, extending `ModuleDefinition["Model"]`.
9
- * @param model - The initial model to be updated.
10
- * @param process - The process associated with the `State` instances, or `null` if no process is provided.
11
- * @param ƒ - A function that mutates the model draft to produce the desired changes.
12
- * @returns {Models<M>} A `Models` instance containing the updated model and its draft.
13
- */
14
- export declare function update<M extends ModuleDefinition["Model"]>(models: Models<M>, process: Process, ƒ: (draft: M, meta: Meta) => void): Models<M>;
15
- /**
16
- * Cleans up the model by removing states associated with a specific process.
17
- *
18
- * @template M - The type of the model, extending `ModuleDefinition["Model"]`.
19
- * @param models - The `Models` instance containing the model and its draft.
20
- * @param process - The process whose associated states should be removed.
21
- * @returns {Models<M>} The updated `Models` instance with the states cleaned up.
22
- */
23
- export declare function cleanup<M extends ModuleDefinition["Model"]>(models: Models<M>, process: Process): Models<M>;
@@ -1,15 +0,0 @@
1
- import { Process, State } from '../../types/index.ts';
2
- import { Immer } from 'immer';
3
- export declare const config: {
4
- immer: Immer;
5
- annotations: string;
6
- };
7
- export declare class Annotation<M> {
8
- value: M;
9
- operations: State[];
10
- field: null | number | string;
11
- process: null | Process;
12
- constructor(value: M, operations: State[], field?: null | number | string);
13
- attach(process: Process): Annotation<M>;
14
- }
15
- export declare function annotate<M>(value: M, operations?: State[]): M;
@@ -1,3 +0,0 @@
1
- import { ModuleDefinition } from '../types/index.ts';
2
- import { ViewDefinition } from './types.ts';
3
- export default function view<M extends ModuleDefinition>(definition: ViewDefinition<M>): ViewDefinition<M>;
@@ -1,16 +0,0 @@
1
- import { Validatable } from '../module/renderer/model/types.ts';
2
- import { Boundary, ModuleDefinition } from '../types/index.ts';
3
- import * as React from "react";
4
- export type ViewActions<M extends ModuleDefinition> = {
5
- dispatch(action: M["Actions"]): Promise<void>;
6
- };
7
- export type ViewArgs<M extends ModuleDefinition> = Readonly<{
8
- model: Readonly<M["Model"]>;
9
- props: Readonly<M["Props"]>;
10
- boundary: {
11
- is(boundary: Boundary): boolean;
12
- };
13
- validate: Readonly<Validatable<M["Model"]>>;
14
- actions: Readonly<ViewActions<M>>;
15
- }>;
16
- export type ViewDefinition<M extends ModuleDefinition> = (actions: ViewArgs<M>) => React.ReactNode;