march-hare 0.8.0 → 0.9.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 +480 -209
- package/dist/{hooks → actions}/index.d.ts +2 -39
- package/dist/{hooks → actions}/utils.d.ts +0 -39
- package/dist/app/index.d.ts +112 -0
- package/dist/app/types.d.ts +49 -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/index.d.ts +10 -10
- package/dist/boundary/types.d.ts +6 -16
- package/dist/cache/index.d.ts +4 -4
- package/dist/coalesce/index.d.ts +57 -0
- package/dist/context/index.d.ts +39 -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 +8 -13
- package/dist/march-hare.js +7 -5
- package/dist/march-hare.umd.cjs +1 -1
- package/dist/resource/index.d.ts +52 -78
- package/dist/resource/types.d.ts +83 -10
- package/dist/scope/index.d.ts +63 -0
- package/dist/scope/types.d.ts +55 -0
- package/dist/types/index.d.ts +77 -39
- package/dist/utils/index.d.ts +6 -5
- package/dist/with/index.d.ts +40 -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 → actions}/types.d.ts +0 -0
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { RefObject } from 'react';
|
|
2
|
-
import { Store } from './index';
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
/**
|
|
5
|
-
* React context exposing the per-Boundary Store ref. The ref itself is
|
|
6
|
-
* stable across renders — readers grab `.current` at call time.
|
|
7
|
-
*
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
export declare const Context: React.Context<React.RefObject<Store>>;
|
|
11
|
-
/**
|
|
12
|
-
* Hook that returns a read-only handle to the per-Boundary {@link Store}.
|
|
13
|
-
* Reads use plain dot notation (`store.session`) and always reflect the
|
|
14
|
-
* latest value, even after `await` boundaries — the handle is a
|
|
15
|
-
* `Proxy` that delegates property access to the live ref.
|
|
16
|
-
*
|
|
17
|
-
* Writes are not exposed here. Mutate the Store inside an action handler
|
|
18
|
-
* via `context.actions.produce(({ model, store }) => { store.x = ... })`
|
|
19
|
-
* — the same Immer-style recipe used for the model. Mutations do
|
|
20
|
-
* **not** trigger a re-render; drive view state through the model.
|
|
21
|
-
*
|
|
22
|
-
* The Store's shape is declared via module augmentation on the library's
|
|
23
|
-
* {@link Store} interface, so dot reads are fully typed at every call
|
|
24
|
-
* site.
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* ```ts
|
|
28
|
-
* declare module "march-hare" {
|
|
29
|
-
* interface Store {
|
|
30
|
-
* session: Session | null;
|
|
31
|
-
* locale: string;
|
|
32
|
-
* }
|
|
33
|
-
* }
|
|
34
|
-
*
|
|
35
|
-
* function useAuthActions() {
|
|
36
|
-
* const store = useStore();
|
|
37
|
-
* const actions = useActions<void, typeof Actions>();
|
|
38
|
-
*
|
|
39
|
-
* actions.useAction(Actions.SignIn, async (context, credentials) => {
|
|
40
|
-
* const result = await context.actions.resource(signIn(credentials));
|
|
41
|
-
* context.actions.produce(({ store }) => {
|
|
42
|
-
* store.session = result;
|
|
43
|
-
* });
|
|
44
|
-
* });
|
|
45
|
-
*
|
|
46
|
-
* actions.useAction(Actions.Refresh, async (context) => {
|
|
47
|
-
* if (store.session === null) return;
|
|
48
|
-
* // ...
|
|
49
|
-
* });
|
|
50
|
-
*
|
|
51
|
-
* return actions;
|
|
52
|
-
* }
|
|
53
|
-
* ```
|
|
54
|
-
*/
|
|
55
|
-
export declare function useStore(): Store;
|
|
56
|
-
/**
|
|
57
|
-
* Internal accessor for the per-Boundary Store ref — used by the
|
|
58
|
-
* Resource layer to pass a fresh snapshot to each fetcher invocation
|
|
59
|
-
* and by the action layer to write through `context.actions.produce`.
|
|
60
|
-
* Not exported from the library.
|
|
61
|
-
*
|
|
62
|
-
* @internal
|
|
63
|
-
*/
|
|
64
|
-
export declare function useStoreRef(): RefObject<Store>;
|
|
File without changes
|