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.
- package/README.md +491 -211
- package/dist/actions/index.d.ts +46 -0
- package/dist/{hooks → actions}/utils.d.ts +0 -39
- package/dist/app/index.d.ts +132 -0
- package/dist/app/types.d.ts +82 -0
- package/dist/boundary/components/broadcast/utils.d.ts +1 -1
- package/dist/boundary/components/env/index.d.ts +26 -0
- package/dist/boundary/components/env/types.d.ts +11 -0
- package/dist/boundary/components/env/utils.d.ts +36 -0
- package/dist/boundary/components/scope/index.d.ts +1 -39
- package/dist/boundary/components/scope/types.d.ts +17 -13
- package/dist/boundary/components/scope/utils.d.ts +12 -8
- package/dist/boundary/components/sharing/index.d.ts +43 -0
- package/dist/boundary/components/tap/index.d.ts +36 -0
- package/dist/boundary/components/tap/types.d.ts +150 -0
- package/dist/boundary/components/tap/utils.d.ts +14 -0
- package/dist/boundary/index.d.ts +10 -10
- package/dist/boundary/types.d.ts +46 -14
- package/dist/cache/index.d.ts +4 -4
- package/dist/coalesce/index.d.ts +57 -0
- package/dist/context/index.d.ts +41 -0
- package/dist/context/types.d.ts +14 -0
- package/dist/error/index.d.ts +1 -1
- package/dist/error/types.d.ts +8 -19
- package/dist/index.d.ts +9 -13
- package/dist/march-hare.js +8 -5
- package/dist/march-hare.umd.cjs +1 -1
- package/dist/resource/index.d.ts +55 -78
- package/dist/resource/types.d.ts +87 -11
- package/dist/resource/utils.d.ts +1 -1
- package/dist/scope/index.d.ts +63 -0
- package/dist/scope/types.d.ts +55 -0
- package/dist/types/index.d.ts +108 -58
- package/dist/utils/index.d.ts +6 -5
- package/dist/with/index.d.ts +111 -0
- package/package.json +1 -1
- package/dist/boundary/components/store/index.d.ts +0 -41
- package/dist/boundary/components/store/types.d.ts +0 -11
- package/dist/boundary/components/store/utils.d.ts +0 -64
- package/dist/hooks/index.d.ts +0 -83
- /package/dist/{hooks → actions}/types.d.ts +0 -0
package/dist/hooks/index.d.ts
DELETED
|
@@ -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 — 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 — 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
|
-
* — the M and D pair of `useContext<M, AC, D>` — 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 — not
|
|
61
|
-
* synchronously during render — 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
|