applesauce-react 0.0.0-next-20241207164640 → 0.0.0-next-20241210191750

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 CHANGED
@@ -6,7 +6,8 @@ React hooks for applesauce
6
6
 
7
7
  ```jsx
8
8
  import { EventStore, QueryStore, Queries } from "applesauce-core";
9
- import { QueryStoreProvider, useStoreQuery } from "applesauce-react";
9
+ import { QueryStoreProvider } from "applesauce-react/providers";
10
+ import { useStoreQuery } from "applesauce-react/hooks";
10
11
 
11
12
  const events = new EventStore();
12
13
  const store = new QueryStore(events);
@@ -3,3 +3,4 @@ export * from "./use-store-query.js";
3
3
  export * from "./use-render-nast.js";
4
4
  export * from "./use-query-store.js";
5
5
  export * from "./use-rendered-content.js";
6
+ export * from "./use-event-factory.js";
@@ -3,3 +3,4 @@ export * from "./use-store-query.js";
3
3
  export * from "./use-render-nast.js";
4
4
  export * from "./use-query-store.js";
5
5
  export * from "./use-rendered-content.js";
6
+ export * from "./use-event-factory.js";
@@ -0,0 +1 @@
1
+ export declare function useEventFactory(): import("applesauce-factory").EventFactory | undefined;
@@ -0,0 +1,5 @@
1
+ import { useContext } from "react";
2
+ import { FactoryContext } from "../providers/factory-provider.js";
3
+ export function useEventFactory() {
4
+ return useContext(FactoryContext);
5
+ }
@@ -1,5 +1,5 @@
1
1
  import { useContext } from "react";
2
- import { QueryStoreContext } from "../provider.js";
2
+ import { QueryStoreContext } from "../providers/query-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
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from "./provider.js";
1
+ export * as Providers from "./providers/index.js";
2
2
  export * as Helpers from "./helpers/index.js";
3
3
  export * as Hooks from "./hooks/index.js";
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export * from "./provider.js";
1
+ export * as Providers from "./providers/index.js";
2
2
  export * as Helpers from "./helpers/index.js";
3
3
  export * as Hooks from "./hooks/index.js";
@@ -0,0 +1,7 @@
1
+ import { EventFactory } from "applesauce-factory";
2
+ import { PropsWithChildren } from "react";
3
+ export declare const FactoryContext: import("react").Context<EventFactory | undefined>;
4
+ /** Provides an EventFactory to the component tree */
5
+ export declare function FactoryProvider({ factory, children }: PropsWithChildren<{
6
+ factory?: EventFactory;
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 FactoryContext = createContext(undefined);
4
+ /** Provides an EventFactory to the component tree */
5
+ export function FactoryProvider({ factory, children }) {
6
+ return _jsx(FactoryContext.Provider, { value: factory, children: children });
7
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./factory-provider.js";
2
+ export * from "./query-store-provider.js";
@@ -0,0 +1,2 @@
1
+ export * from "./factory-provider.js";
2
+ export * from "./query-store-provider.js";
@@ -0,0 +1,7 @@
1
+ import { QueryStore } from "applesauce-core";
2
+ import { PropsWithChildren } from "react";
3
+ export declare const QueryStoreContext: import("react").Context<QueryStore | null>;
4
+ /** Provides a QueryStore to the component tree */
5
+ export declare function QueryStoreProvider({ store, children }: PropsWithChildren<{
6
+ store: QueryStore;
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 QueryStoreContext = createContext(null);
4
+ /** Provides a QueryStore to the component tree */
5
+ export function QueryStoreProvider({ store, children }) {
6
+ return _jsx(QueryStoreContext.Provider, { value: store, children: children });
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "applesauce-react",
3
- "version": "0.0.0-next-20241207164640",
3
+ "version": "0.0.0-next-20241210191750",
4
4
  "description": "React hooks for applesauce",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -27,14 +27,23 @@
27
27
  "import": "./dist/hooks/*.js",
28
28
  "types": "./dist/hooks/*.d.ts"
29
29
  },
30
+ "./providers": {
31
+ "import": "./dist/providers/index.js",
32
+ "types": "./dist/providers/index.d.ts"
33
+ },
34
+ "./providers/*": {
35
+ "import": "./dist/providers/*.js",
36
+ "types": "./dist/providers/*.d.ts"
37
+ },
30
38
  "./helpers": {
31
39
  "import": "./dist/helpers/index.js",
32
40
  "types": "./dist/helpers/index.d.ts"
33
41
  }
34
42
  },
35
43
  "dependencies": {
36
- "applesauce-content": "0.0.0-next-20241207164640",
37
- "applesauce-core": "0.0.0-next-20241207164640",
44
+ "applesauce-content": "0.0.0-next-20241210191750",
45
+ "applesauce-core": "0.0.0-next-20241210191750",
46
+ "applesauce-factory": "0.0.0-next-20241210191750",
38
47
  "nostr-tools": "^2.10.3",
39
48
  "react": "^18.3.1",
40
49
  "rxjs": "^7.8.1"