applesauce-react 0.0.0-next-20241213171848 → 0.0.0-next-20241219164005
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/use-event-store.d.ts +5 -0
- package/dist/hooks/use-event-store.js +12 -0
- package/dist/hooks/use-query-store.js +1 -1
- package/dist/providers/index.d.ts +1 -1
- package/dist/providers/index.js +1 -1
- package/dist/providers/store-provider.d.ts +12 -0
- package/dist/providers/store-provider.js +12 -0
- package/package.json +4 -4
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useContext } from "react";
|
|
2
|
+
import { EventStoreContext } from "../providers/store-provider.js";
|
|
3
|
+
/**
|
|
4
|
+
* Gets the EventStore from a parent {@link EventStoreProvider} component
|
|
5
|
+
* If there is none it throws an error
|
|
6
|
+
*/
|
|
7
|
+
export function useEventStore() {
|
|
8
|
+
const store = useContext(EventStoreContext);
|
|
9
|
+
if (!store)
|
|
10
|
+
throw new Error("Missing EventStoreProvider");
|
|
11
|
+
return store;
|
|
12
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useContext } from "react";
|
|
2
|
-
import { QueryStoreContext } from "../providers/
|
|
2
|
+
import { QueryStoreContext } from "../providers/store-provider.js";
|
|
3
3
|
/**
|
|
4
4
|
* Gets the QueryStore from a parent {@link QueryStoreProvider} component
|
|
5
5
|
* If there is none it throws an error
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from "./factory-provider.js";
|
|
2
|
-
export * from "./
|
|
2
|
+
export * from "./store-provider.js";
|
package/dist/providers/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from "./factory-provider.js";
|
|
2
|
-
export * from "./
|
|
2
|
+
export * from "./store-provider.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EventStore, QueryStore } from "applesauce-core";
|
|
2
|
+
import { PropsWithChildren } from "react";
|
|
3
|
+
export declare const QueryStoreContext: import("react").Context<QueryStore | null>;
|
|
4
|
+
export declare const EventStoreContext: import("react").Context<EventStore | null>;
|
|
5
|
+
/** Provides a EventStore to the component tree */
|
|
6
|
+
export declare function EventStoreProvider({ eventStore, children }: PropsWithChildren<{
|
|
7
|
+
eventStore: EventStore;
|
|
8
|
+
}>): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
/** Provides a QueryStore and EventStore to the component tree */
|
|
10
|
+
export declare function QueryStoreProvider({ queryStore, children }: PropsWithChildren<{
|
|
11
|
+
queryStore: QueryStore;
|
|
12
|
+
}>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext } from "react";
|
|
3
|
+
export const QueryStoreContext = createContext(null);
|
|
4
|
+
export const EventStoreContext = createContext(null);
|
|
5
|
+
/** Provides a EventStore to the component tree */
|
|
6
|
+
export function EventStoreProvider({ eventStore, children }) {
|
|
7
|
+
return _jsx(EventStoreContext.Provider, { value: eventStore, children: children });
|
|
8
|
+
}
|
|
9
|
+
/** Provides a QueryStore and EventStore to the component tree */
|
|
10
|
+
export function QueryStoreProvider({ queryStore, children }) {
|
|
11
|
+
return (_jsx(EventStoreProvider, { eventStore: queryStore.store, children: _jsx(QueryStoreContext.Provider, { value: queryStore, children: children }) }));
|
|
12
|
+
}
|
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-20241219164005",
|
|
4
4
|
"description": "React hooks for applesauce",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"applesauce-content": "0.0.0-next-
|
|
45
|
-
"applesauce-core": "0.0.0-next-
|
|
46
|
-
"applesauce-factory": "0.0.0-next-
|
|
44
|
+
"applesauce-content": "0.0.0-next-20241219164005",
|
|
45
|
+
"applesauce-core": "0.0.0-next-20241219164005",
|
|
46
|
+
"applesauce-factory": "0.0.0-next-20241219164005",
|
|
47
47
|
"nostr-tools": "^2.10.3",
|
|
48
48
|
"react": "^18.3.1",
|
|
49
49
|
"rxjs": "^7.8.1"
|