applesauce-react 0.0.0-next-20250312152821 → 0.0.0-next-20250312195837
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/dist/hooks/index.d.ts +3 -1
- package/dist/hooks/index.js +3 -1
- package/dist/hooks/use-action-hub.d.ts +1 -0
- package/dist/hooks/use-action-hub.js +8 -0
- package/dist/hooks/use-action.d.ts +5 -0
- package/dist/hooks/use-action.js +22 -0
- package/dist/providers/actions-provider.d.ts +7 -0
- package/dist/providers/actions-provider.js +7 -0
- package/dist/providers/index.d.ts +1 -0
- package/dist/providers/index.js +1 -0
- package/package.json +6 -5
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
export * from "./use-account-manager.js";
|
|
2
2
|
export * from "./use-accounts.js";
|
|
3
|
+
export * from "./use-action-hub.js";
|
|
4
|
+
export * from "./use-action.js";
|
|
3
5
|
export * from "./use-active-account.js";
|
|
4
6
|
export * from "./use-event-factory.js";
|
|
7
|
+
export * from "./use-event-store.js";
|
|
5
8
|
export * from "./use-observable.js";
|
|
6
9
|
export * from "./use-query-store.js";
|
|
7
10
|
export * from "./use-render-nast.js";
|
|
8
11
|
export * from "./use-rendered-content.js";
|
|
9
12
|
export * from "./use-store-query.js";
|
|
10
|
-
export * from "./use-event-store.js";
|
package/dist/hooks/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
export * from "./use-account-manager.js";
|
|
2
2
|
export * from "./use-accounts.js";
|
|
3
|
+
export * from "./use-action-hub.js";
|
|
4
|
+
export * from "./use-action.js";
|
|
3
5
|
export * from "./use-active-account.js";
|
|
4
6
|
export * from "./use-event-factory.js";
|
|
7
|
+
export * from "./use-event-store.js";
|
|
5
8
|
export * from "./use-observable.js";
|
|
6
9
|
export * from "./use-query-store.js";
|
|
7
10
|
export * from "./use-render-nast.js";
|
|
8
11
|
export * from "./use-rendered-content.js";
|
|
9
12
|
export * from "./use-store-query.js";
|
|
10
|
-
export * from "./use-event-store.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useActionHub(): import("applesauce-actions").ActionHub;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useCallback, useRef, useState } from "react";
|
|
2
|
+
import { useActionHub } from "./use-action-hub.js";
|
|
3
|
+
export function useAction(Action, args) {
|
|
4
|
+
const [loading, setLoading] = useState(false);
|
|
5
|
+
const ref = useRef(args);
|
|
6
|
+
ref.current = args;
|
|
7
|
+
const hub = useActionHub();
|
|
8
|
+
const run = useCallback(async () => {
|
|
9
|
+
if (args === undefined)
|
|
10
|
+
return;
|
|
11
|
+
setLoading(true);
|
|
12
|
+
try {
|
|
13
|
+
await hub.run(Action, ...args);
|
|
14
|
+
setLoading(false);
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
setLoading(false);
|
|
18
|
+
throw error;
|
|
19
|
+
}
|
|
20
|
+
}, [Action]);
|
|
21
|
+
return { loading, run };
|
|
22
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PropsWithChildren } from "react";
|
|
2
|
+
import { ActionHub } from "applesauce-actions";
|
|
3
|
+
export declare const ActionsContext: import("react").Context<ActionHub | undefined>;
|
|
4
|
+
/** Provides an ActionHub to the component tree */
|
|
5
|
+
export declare function ActionsProvider({ actionHub, children }: PropsWithChildren<{
|
|
6
|
+
actionHub?: ActionHub;
|
|
7
|
+
}>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext } from "react";
|
|
3
|
+
export const ActionsContext = createContext(undefined);
|
|
4
|
+
/** Provides an ActionHub to the component tree */
|
|
5
|
+
export function ActionsProvider({ actionHub, children }) {
|
|
6
|
+
return _jsx(ActionsContext.Provider, { value: actionHub, children: children });
|
|
7
|
+
}
|
package/dist/providers/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "applesauce-react",
|
|
3
|
-
"version": "0.0.0-next-
|
|
3
|
+
"version": "0.0.0-next-20250312195837",
|
|
4
4
|
"description": "React hooks for applesauce",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -49,10 +49,11 @@
|
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"applesauce-accounts": "0.0.0-next-
|
|
53
|
-
"applesauce-
|
|
54
|
-
"applesauce-
|
|
55
|
-
"applesauce-
|
|
52
|
+
"applesauce-accounts": "0.0.0-next-20250312195837",
|
|
53
|
+
"applesauce-actions": "0.0.0-next-20250312195837",
|
|
54
|
+
"applesauce-content": "0.0.0-next-20250312195837",
|
|
55
|
+
"applesauce-core": "0.0.0-next-20250312195837",
|
|
56
|
+
"applesauce-factory": "0.0.0-next-20250312195837",
|
|
56
57
|
"nostr-tools": "^2.10.4",
|
|
57
58
|
"observable-hooks": "^4.2.4",
|
|
58
59
|
"react": "^18.3.1",
|