march-hare 0.6.1 → 0.7.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 +89 -96
- package/dist/march-hare.js +6 -6
- package/dist/march-hare.umd.cjs +1 -1
- package/dist/src/library/action/index.d.ts +17 -13
- package/dist/src/library/boundary/components/store/index.d.ts +41 -0
- package/dist/src/library/boundary/components/store/types.d.ts +11 -0
- package/dist/src/library/boundary/components/store/utils.d.ts +64 -0
- package/dist/src/library/boundary/components/tasks/types.d.ts +3 -3
- package/dist/src/library/boundary/index.d.ts +8 -7
- package/dist/src/library/boundary/types.d.ts +18 -0
- package/dist/src/library/cache/index.d.ts +44 -0
- package/dist/src/library/cache/types.d.ts +54 -0
- package/dist/src/library/index.d.ts +8 -6
- package/dist/src/library/resource/index.d.ts +82 -45
- package/dist/src/library/resource/types.d.ts +20 -143
- package/dist/src/library/resource/utils.d.ts +24 -10
- package/dist/src/library/types/index.d.ts +160 -19
- package/dist/src/library/utils/index.d.ts +1 -41
- package/dist/src/library/utils/types.d.ts +3 -86
- package/package.json +2 -2
- package/dist/src/library/boundary/components/mode/index.d.ts +0 -15
- package/dist/src/library/boundary/components/mode/types.d.ts +0 -7
- package/dist/src/library/boundary/components/mode/utils.d.ts +0 -55
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "march-hare",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"packageManager": "yarn@1.22.22",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"react-flip-numbers": "^3.0.9",
|
|
89
89
|
"react-router-dom": "^7.13.0",
|
|
90
90
|
"react-test-renderer": "^19.2.4",
|
|
91
|
-
"react-wayfinder": "^0.1.
|
|
91
|
+
"react-wayfinder": "^0.1.4",
|
|
92
92
|
"rollup-plugin-visualizer": "^6.0.5",
|
|
93
93
|
"terser": "^5.46.0",
|
|
94
94
|
"traverse": "^0.6.11",
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Props } from './types.ts';
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
export { useMode } from './utils.ts';
|
|
4
|
-
export type { ModeHandle } from './utils.ts';
|
|
5
|
-
/**
|
|
6
|
-
* Provides a single mutable mode handle to every component inside the
|
|
7
|
-
* boundary. Components opt in by calling {@link useMode} and threading the
|
|
8
|
-
* returned handle through {@link useActions}'s `data` callback.
|
|
9
|
-
*
|
|
10
|
-
* Mode is **not** reactive — mutating it does not trigger a re-render.
|
|
11
|
-
* Use it for cross-handler coordination (e.g. flagging an in-progress
|
|
12
|
-
* sign-out) when you do not want the value showing up as render-time UI
|
|
13
|
-
* state.
|
|
14
|
-
*/
|
|
15
|
-
export declare function Mode({ children }: Props): React.ReactNode;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
/**
|
|
3
|
-
* React context exposing the per-Boundary mode handle. The handle itself
|
|
4
|
-
* is stable across renders — readers grab `.current` at call time.
|
|
5
|
-
*
|
|
6
|
-
* @internal
|
|
7
|
-
*/
|
|
8
|
-
export declare const Context: React.Context<React.RefObject<unknown>>;
|
|
9
|
-
/**
|
|
10
|
-
* Handle returned by {@link useMode}. Reads always reflect the latest
|
|
11
|
-
* write, even after `await` boundaries.
|
|
12
|
-
*/
|
|
13
|
-
export type ModeHandle<T> = {
|
|
14
|
-
read(): T | null;
|
|
15
|
-
update(value: T | null): void;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Hook that returns a `{ read, update }` handle to the per-Boundary mode
|
|
19
|
-
* value.
|
|
20
|
-
*
|
|
21
|
-
* Mode is a single mutable value shared across every component inside the
|
|
22
|
-
* surrounding `<Boundary>`. It is **not** reactive — mutating it does
|
|
23
|
-
* not trigger a re-render. Use it for coordinating between async action
|
|
24
|
-
* handlers (e.g. short-circuiting refreshes during sign-out).
|
|
25
|
-
*
|
|
26
|
-
* Pass the handle through the {@link useActions} `data` callback so it
|
|
27
|
-
* shows up under `context.data` inside handlers, fully typed.
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* ```ts
|
|
31
|
-
* enum Mode {
|
|
32
|
-
* Idle,
|
|
33
|
-
* SigningOut,
|
|
34
|
-
* }
|
|
35
|
-
*
|
|
36
|
-
* function useSignOutActions() {
|
|
37
|
-
* const mode = useMode<Mode>();
|
|
38
|
-
* const actions = useActions<Model, typeof Actions>(model, () => ({ mode }));
|
|
39
|
-
*
|
|
40
|
-
* actions.useAction(Actions.SignOut, async (context) => {
|
|
41
|
-
* context.data.mode.update(Mode.SigningOut);
|
|
42
|
-
* await api.signOut();
|
|
43
|
-
* context.data.mode.update(Mode.Idle);
|
|
44
|
-
* });
|
|
45
|
-
*
|
|
46
|
-
* actions.useAction(Actions.Refresh, async (context) => {
|
|
47
|
-
* if (context.data.mode.read() === Mode.SigningOut) return;
|
|
48
|
-
* // ...
|
|
49
|
-
* });
|
|
50
|
-
*
|
|
51
|
-
* return actions;
|
|
52
|
-
* }
|
|
53
|
-
* ```
|
|
54
|
-
*/
|
|
55
|
-
export declare function useMode<T>(): ModeHandle<T>;
|