march-hare 0.8.0 → 0.10.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.
Files changed (41) hide show
  1. package/README.md +491 -211
  2. package/dist/actions/index.d.ts +46 -0
  3. package/dist/{hooks → actions}/utils.d.ts +0 -39
  4. package/dist/app/index.d.ts +132 -0
  5. package/dist/app/types.d.ts +82 -0
  6. package/dist/boundary/components/broadcast/utils.d.ts +1 -1
  7. package/dist/boundary/components/env/index.d.ts +26 -0
  8. package/dist/boundary/components/env/types.d.ts +11 -0
  9. package/dist/boundary/components/env/utils.d.ts +36 -0
  10. package/dist/boundary/components/scope/index.d.ts +1 -39
  11. package/dist/boundary/components/scope/types.d.ts +17 -13
  12. package/dist/boundary/components/scope/utils.d.ts +12 -8
  13. package/dist/boundary/components/sharing/index.d.ts +43 -0
  14. package/dist/boundary/components/tap/index.d.ts +36 -0
  15. package/dist/boundary/components/tap/types.d.ts +150 -0
  16. package/dist/boundary/components/tap/utils.d.ts +14 -0
  17. package/dist/boundary/index.d.ts +10 -10
  18. package/dist/boundary/types.d.ts +46 -14
  19. package/dist/cache/index.d.ts +4 -4
  20. package/dist/coalesce/index.d.ts +57 -0
  21. package/dist/context/index.d.ts +41 -0
  22. package/dist/context/types.d.ts +14 -0
  23. package/dist/error/index.d.ts +1 -1
  24. package/dist/error/types.d.ts +8 -19
  25. package/dist/index.d.ts +9 -13
  26. package/dist/march-hare.js +8 -5
  27. package/dist/march-hare.umd.cjs +1 -1
  28. package/dist/resource/index.d.ts +55 -78
  29. package/dist/resource/types.d.ts +87 -11
  30. package/dist/resource/utils.d.ts +1 -1
  31. package/dist/scope/index.d.ts +63 -0
  32. package/dist/scope/types.d.ts +55 -0
  33. package/dist/types/index.d.ts +108 -58
  34. package/dist/utils/index.d.ts +6 -5
  35. package/dist/with/index.d.ts +111 -0
  36. package/package.json +1 -1
  37. package/dist/boundary/components/store/index.d.ts +0 -41
  38. package/dist/boundary/components/store/types.d.ts +0 -11
  39. package/dist/boundary/components/store/utils.d.ts +0 -64
  40. package/dist/hooks/index.d.ts +0 -83
  41. /package/dist/{hooks → actions}/types.d.ts +0 -0
@@ -1,83 +0,0 @@
1
- import { Data } from './types';
2
- import { Model, Props, Actions, UseActions, Context as ContextHandle } from '../types/index';
3
- export { With } from './utils';
4
- /**
5
- * A hook for managing state with actions.
6
- *
7
- * Call `useActions` first, then use `actions.useAction` to bind handlers
8
- * to action symbols. Types are pre-baked from the generic parameters, so
9
- * no additional type annotations are needed on handler calls.
10
- *
11
- * The hook returns a result containing:
12
- * 1. The current model state
13
- * 2. An actions object with `dispatch`, `inspect`, and `useAction`
14
- * 3. A read-only snapshot of the data values produced by `getData` —
15
- * the same values handlers read via `context.data`, exposed here for
16
- * JSX consumption so the view and the handler share one named source.
17
- *
18
- * The `inspect` property provides access to Immertation's annotation system,
19
- * allowing you to check for pending operations on model properties.
20
- *
21
- * @template M The model type representing the component's state.
22
- * @template AC The actions class containing action definitions.
23
- * @template D The data type for reactive external values.
24
- * @param initialModel The initial model state.
25
- * @param getData Optional function that returns reactive values as data.
26
- * Values returned are accessible via `context.data` in action handlers,
27
- * always reflecting the latest values even after await operations.
28
- * @returns A result `[model, actions, data]` with pre-typed `useAction` method.
29
- *
30
- * @example
31
- * ```typescript
32
- * // Basic usage
33
- * const [model, actions] = useActions<Model, typeof Actions>(model);
34
- *
35
- * // Without a model (actions-only)
36
- * const [, actions] = useActions<void, typeof Actions>();
37
- *
38
- * // With reactive data &mdash; consumed in JSX and handlers alike.
39
- * const [model, actions, data] = useActions<
40
- * Model,
41
- * typeof Actions,
42
- * { query: string }
43
- * >(initialModel, () => ({ query: props.query }));
44
- * ```
45
- */
46
- export declare function useActions<_M extends void = void, A extends Actions | void = void, D extends Props = Props>(getData?: Data<D>): UseActions<void, A, D>;
47
- export declare function useActions<M extends Model, A extends Actions | void = void, D extends Props = Props>(initialModel: M, getData?: Data<D>): UseActions<M, A, D>;
48
- /**
49
- * Returns a stable, typed controller handle up-front &mdash; before a
50
- * model is declared via `context.useActions(...)`. Use this when an
51
- * external imperative library (form, animation, third-party SDK) needs a
52
- * dispatch callback at construction time, while the value that library
53
- * returns must flow back into the controller's data callback.
54
- *
55
- * The handle exposes `dispatch(action, payload?)` and a `useView(...)`
56
- * method that materialises the component-local model and reactive data
57
- * &mdash; the M and D pair of `useContext<M, AC, D>` &mdash; and
58
- * returns the `[model, actions, data]` tuple with `useAction`, `dispatch`,
59
- * `inspect`, and `stream` attached. The first invocation of
60
- * `context.actions.dispatch(...)` must come from an event handler &mdash; not
61
- * synchronously during render &mdash; because the underlying dispatch
62
- * target is wired up when `context.useActions(...)` runs in the same
63
- * render pass.
64
- *
65
- * @template M The model type representing the component's state.
66
- * @template AC The actions class containing action definitions.
67
- * @template D The data type for reactive external values.
68
- *
69
- * @example
70
- * ```ts
71
- * const context = useContext<Model, typeof Actions, Data>();
72
- *
73
- * const form = useForm({
74
- * onSubmit: () => void context.actions.dispatch(Actions.Submit),
75
- * });
76
- *
77
- * const actions = context.useActions(
78
- * { user: user() },
79
- * () => ({ form }),
80
- * );
81
- * ```
82
- */
83
- export declare function useContext<M extends Model | void = void, AC extends Actions | void = void, D extends Props = Props>(): ContextHandle<M, AC, D>;
File without changes