applesauce-react 0.0.0-next-20250128152442 → 0.0.0-next-20250128164720

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.
@@ -1,3 +1,6 @@
1
+ export * from "./use-account-manager.js";
2
+ export * from "./use-accounts.js";
3
+ export * from "./use-active-accounts.js";
1
4
  export * from "./use-event-factory.js";
2
5
  export * from "./use-observable.js";
3
6
  export * from "./use-query-store.js";
@@ -1,3 +1,6 @@
1
+ export * from "./use-account-manager.js";
2
+ export * from "./use-accounts.js";
3
+ export * from "./use-active-accounts.js";
1
4
  export * from "./use-event-factory.js";
2
5
  export * from "./use-observable.js";
3
6
  export * from "./use-query-store.js";
@@ -0,0 +1 @@
1
+ export declare function useAccountManager(): import("applesauce-accounts").AccountManager<any> | undefined;
@@ -0,0 +1,5 @@
1
+ import { useContext } from "react";
2
+ import { AccountsContext } from "../providers/accounts-provider.js";
3
+ export function useAccountManager() {
4
+ return useContext(AccountsContext);
5
+ }
@@ -0,0 +1 @@
1
+ export declare function useAccounts(): import("applesauce-accounts").IAccount<any, any, any>[];
@@ -0,0 +1,6 @@
1
+ import { useObservable } from "./use-observable.js";
2
+ import { useAccountManager } from "./use-account-manager.js";
3
+ export function useAccounts() {
4
+ const manager = useAccountManager();
5
+ return useObservable(manager?.accounts$);
6
+ }
@@ -0,0 +1 @@
1
+ export declare function useActiveAccount(): import("applesauce-accounts").IAccount<any, any, any> | null;
@@ -0,0 +1,6 @@
1
+ import { useObservable } from "./use-observable.js";
2
+ import { useAccountManager } from "./use-account-manager.js";
3
+ export function useActiveAccount() {
4
+ const manager = useAccountManager();
5
+ return useObservable(manager?.active$);
6
+ }
@@ -0,0 +1,7 @@
1
+ import { PropsWithChildren } from "react";
2
+ import { AccountManager } from "applesauce-accounts";
3
+ export declare const AccountsContext: import("react").Context<AccountManager<any> | undefined>;
4
+ /** Provides an AccountManager to the component tree */
5
+ export declare function AccountsProvider({ manager, children }: PropsWithChildren<{
6
+ manager?: AccountManager;
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 AccountsContext = createContext(undefined);
4
+ /** Provides an AccountManager to the component tree */
5
+ export function AccountsProvider({ manager, children }) {
6
+ return _jsx(AccountsContext.Provider, { value: manager, children: children });
7
+ }
@@ -1,2 +1,3 @@
1
1
  export * from "./factory-provider.js";
2
2
  export * from "./store-provider.js";
3
+ export * from "./accounts-provider.js";
@@ -1,2 +1,3 @@
1
1
  export * from "./factory-provider.js";
2
2
  export * from "./store-provider.js";
3
+ export * from "./accounts-provider.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "applesauce-react",
3
- "version": "0.0.0-next-20250128152442",
3
+ "version": "0.0.0-next-20250128164720",
4
4
  "description": "React hooks for applesauce",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -48,9 +48,10 @@
48
48
  }
49
49
  },
50
50
  "dependencies": {
51
- "applesauce-content": "0.0.0-next-20250128152442",
52
- "applesauce-core": "0.0.0-next-20250128152442",
53
- "applesauce-factory": "0.0.0-next-20250128152442",
51
+ "applesauce-accounts": "0.0.0-next-20250128164720",
52
+ "applesauce-content": "0.0.0-next-20250128164720",
53
+ "applesauce-core": "0.0.0-next-20250128164720",
54
+ "applesauce-factory": "0.0.0-next-20250128164720",
54
55
  "nostr-tools": "^2.10.3",
55
56
  "react": "^18.3.1",
56
57
  "rxjs": "^7.8.1"