@warp-drive/react 5.7.0-alpha.37 → 5.7.0-alpha.38

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.
@@ -3,9 +3,16 @@ import { type JSX, type ReactNode, type Context } from "react";
3
3
  export declare function useWatcher(): {
4
4
  watcher: Signal.subtle.Watcher;
5
5
  } | null;
6
+ /**
7
+ * @category Contexts
8
+ */
6
9
  export declare const WatcherContext: Context<{
7
10
  watcher: Signal.subtle.Watcher;
8
11
  } | null>;
12
+ /**
13
+ *
14
+ * @category Components
15
+ */
9
16
  export declare function ReactiveContext({ children }: {
10
17
  children: ReactNode;
11
18
  }): JSX.Element;
@@ -132,6 +132,7 @@ export declare function Throw({ error }: {
132
132
  *
133
133
  * ```
134
134
  *
135
+ * @category Components
135
136
  */
136
137
  export declare function Request<
137
138
  RT,
@@ -1,7 +1,19 @@
1
1
  import { Store } from "@warp-drive/core";
2
2
  import { JSX, ReactNode } from "react";
3
+ /**
4
+ * @category Hooks
5
+ */
3
6
  export declare function useStore(): Store;
4
- export declare function StoreProvider($props: {
5
- Store: Store;
7
+ type WithExistingStore = {
8
+ store: Store;
6
9
  children: ReactNode;
7
- }): JSX.Element;
10
+ };
11
+ type WithNewStore = {
12
+ Store: typeof Store;
13
+ children: ReactNode;
14
+ };
15
+ /**
16
+ * @category Components
17
+ */
18
+ export declare function StoreProvider($props: WithExistingStore | WithNewStore): JSX.Element;
19
+ export {};
@@ -1,9 +1,7 @@
1
1
  /**
2
- * React-specific reactivity integration, components
3
- * and hooks for WarpDrive.
4
- *
5
2
  * @module
3
+ * @mergeModuleWith <project>
6
4
  */
7
- export { ReactiveContext } from "./-private/reactive-context.js";
5
+ export { ReactiveContext, WatcherContext } from "./-private/reactive-context.js";
8
6
  export { StoreProvider, useStore } from "./-private/store-provider.js";
9
7
  export { Request, Throw } from "./-private/request.js";
package/dist/index.js CHANGED
@@ -1,11 +1,16 @@
1
- import { R as ReactiveContext } from "./reactive-context-zIDLf-L0.js";
2
- import { Store } from '@warp-drive/core';
1
+ import { R as ReactiveContext } from "./reactive-context-ClTRYXie.js";
2
+ export { W as WatcherContext } from "./reactive-context-ClTRYXie.js";
3
+ import '@warp-drive/core';
3
4
  import { useMemo, createContext, use, useRef, useEffect } from 'react';
4
5
  import { macroCondition, getGlobalConfig } from '@embroider/macros';
5
6
  import { jsx, Fragment } from 'react/jsx-runtime';
6
7
  import { DISPOSE, createRequestSubscription, signal } from '@warp-drive/core/store/-private';
7
8
  import '@warp-drive/core/request';
8
9
  const StoreContext = /*#__PURE__*/createContext(null);
10
+
11
+ /**
12
+ * @category Hooks
13
+ */
9
14
  function useStore() {
10
15
  const store = use(StoreContext);
11
16
  macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
@@ -15,8 +20,11 @@ function useStore() {
15
20
  })(store) : {};
16
21
  return store;
17
22
  }
23
+ /**
24
+ * @category Components
25
+ */
18
26
  function StoreProvider($props) {
19
- const store = useMemo(() => new Store(), [$props.Store]);
27
+ const store = useMemo(() => "store" in $props ? $props.store : new $props.Store(), ["store" in $props ? $props.store : $props.Store]);
20
28
  return /*#__PURE__*/jsx(StoreContext, {
21
29
  value: store,
22
30
  children: $props.children
@@ -168,6 +176,7 @@ function Throw({
168
176
  *
169
177
  * ```
170
178
  *
179
+ * @category Components
171
180
  */
172
181
  function Request($props) {
173
182
  return /*#__PURE__*/jsx(ReactiveContext, {
package/dist/install.js CHANGED
@@ -1,23 +1,12 @@
1
1
  import { use } from 'react';
2
2
  import { Signal } from 'signal-polyfill';
3
3
  import { setupSignals } from '@warp-drive/core/configure';
4
- import { W as WatcherContext } from "./reactive-context-zIDLf-L0.js";
4
+ import { W as WatcherContext } from "./reactive-context-ClTRYXie.js";
5
5
  import { macroCondition, getGlobalConfig } from '@embroider/macros';
6
6
 
7
7
  /**
8
- * Unlike reactive frameworks, React does not have the ability to support
9
- * fine-grained reactivity. However, we can approximate it to "good enough"
10
- * granularity by keeping track of signals used within a specific context.
11
- *
12
- * React also does not have a built-in way to memoize functions the way that
13
- * reactive frameworks do, but by building overtop of other Signal libraries
14
- * we can provide this.
15
- *
16
- * Due to the above limitations, @warp-drive/react/install is built
17
- * overtop @warp-drive/tc39-proposal-signals/install.
18
- *
19
- * The TC39 Watcher especially is valuable here, as it allows us to subscribe to changes
20
- * to the dependency graph of a memo and not just a signal.
8
+ * {@include ./install.md}
9
+ * @module
21
10
  */
22
11
 
23
12
  function tryConsumeContext(signal) {
@@ -127,7 +127,16 @@ function useWatcher() {
127
127
  };
128
128
  }, () => state.snapshot);
129
129
  }
130
+
131
+ /**
132
+ * @category Contexts
133
+ */
130
134
  const WatcherContext = /*#__PURE__*/createContext(null);
135
+
136
+ /**
137
+ *
138
+ * @category Components
139
+ */
131
140
  function ReactiveContext({
132
141
  children
133
142
  }) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@warp-drive/react",
3
3
  "description": "Data bindings and utilities for React applications using WarpDrive",
4
- "version": "5.7.0-alpha.37",
4
+ "version": "5.7.0-alpha.38",
5
5
  "license": "MIT",
6
6
  "author": "Chris Thoburn <runspired@users.noreply.github.com>",
7
7
  "repository": {
@@ -38,8 +38,8 @@
38
38
  "peerDependencies": {},
39
39
  "dependencies": {
40
40
  "@embroider/macros": "^1.18.1",
41
- "@warp-drive/core": "5.7.0-alpha.37",
42
- "@warp-drive/tc39-proposal-signals": "5.7.0-alpha.37",
41
+ "@warp-drive/core": "5.7.0-alpha.38",
42
+ "@warp-drive/tc39-proposal-signals": "5.7.0-alpha.38",
43
43
  "signal-polyfill": "^0.2.2",
44
44
  "react": "^19.1.1"
45
45
  },
@@ -53,11 +53,11 @@
53
53
  "@babel/runtime": "^7.28.2",
54
54
  "decorator-transforms": "^2.3.0",
55
55
  "@embroider/addon-dev": "^7.1.5",
56
- "@warp-drive/internal-config": "5.7.0-alpha.37",
57
- "@warp-drive/core": "5.7.0-alpha.37",
58
- "@types/react": "^19.1.9",
56
+ "@warp-drive/internal-config": "5.7.0-alpha.38",
57
+ "@warp-drive/core": "5.7.0-alpha.38",
58
+ "@types/react": "^19.1.11",
59
59
  "react": "^19.1.1",
60
- "rollup": "^4.40.0",
60
+ "rollup": "^4.48.0",
61
61
  "typescript": "^5.9.2",
62
62
  "vite": "^7.1.2"
63
63
  },