@warp-drive-mirror/react 5.8.0-alpha.37 → 5.8.0-alpha.40

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.
Files changed (37) hide show
  1. package/dist/unpkg/dev/index.js +75 -26
  2. package/dist/unpkg/dev/install.js +8 -10
  3. package/dist/unpkg/dev/reactive-context-CTtwoaBx.js +290 -0
  4. package/dist/unpkg/dev-deprecated/index.js +75 -26
  5. package/dist/unpkg/dev-deprecated/install.js +8 -10
  6. package/dist/unpkg/dev-deprecated/reactive-context-sqyJMb7I.js +290 -0
  7. package/dist/unpkg/prod/index.js +5 -30
  8. package/dist/unpkg/prod/install.js +3 -51
  9. package/dist/unpkg/prod/reactive-context-DKimDkR3.js +110 -0
  10. package/dist/unpkg/prod-deprecated/index.js +5 -30
  11. package/dist/unpkg/prod-deprecated/install.js +3 -51
  12. package/dist/unpkg/prod-deprecated/reactive-context-DKimDkR3.js +110 -0
  13. package/package.json +13 -21
  14. package/dist/unpkg/dev/declarations/-private/reactive-context.d.ts +0 -18
  15. package/dist/unpkg/dev/declarations/-private/request.d.ts +0 -141
  16. package/dist/unpkg/dev/declarations/-private/store-provider.d.ts +0 -19
  17. package/dist/unpkg/dev/declarations/index.d.ts +0 -7
  18. package/dist/unpkg/dev/declarations/install.d.ts +0 -3
  19. package/dist/unpkg/dev/reactive-context-ClTRYXie.js +0 -154
  20. package/dist/unpkg/dev-deprecated/declarations/-private/reactive-context.d.ts +0 -18
  21. package/dist/unpkg/dev-deprecated/declarations/-private/request.d.ts +0 -141
  22. package/dist/unpkg/dev-deprecated/declarations/-private/store-provider.d.ts +0 -19
  23. package/dist/unpkg/dev-deprecated/declarations/index.d.ts +0 -7
  24. package/dist/unpkg/dev-deprecated/declarations/install.d.ts +0 -3
  25. package/dist/unpkg/dev-deprecated/reactive-context-ClTRYXie.js +0 -154
  26. package/dist/unpkg/prod/declarations/-private/reactive-context.d.ts +0 -18
  27. package/dist/unpkg/prod/declarations/-private/request.d.ts +0 -141
  28. package/dist/unpkg/prod/declarations/-private/store-provider.d.ts +0 -19
  29. package/dist/unpkg/prod/declarations/index.d.ts +0 -7
  30. package/dist/unpkg/prod/declarations/install.d.ts +0 -3
  31. package/dist/unpkg/prod/reactive-context-ClTRYXie.js +0 -154
  32. package/dist/unpkg/prod-deprecated/declarations/-private/reactive-context.d.ts +0 -18
  33. package/dist/unpkg/prod-deprecated/declarations/-private/request.d.ts +0 -141
  34. package/dist/unpkg/prod-deprecated/declarations/-private/store-provider.d.ts +0 -19
  35. package/dist/unpkg/prod-deprecated/declarations/index.d.ts +0 -7
  36. package/dist/unpkg/prod-deprecated/declarations/install.d.ts +0 -3
  37. package/dist/unpkg/prod-deprecated/reactive-context-ClTRYXie.js +0 -154
@@ -1,8 +1,7 @@
1
1
  import { use } from 'react';
2
2
  import { Signal } from 'signal-polyfill';
3
3
  import { setupSignals } from '@warp-drive-mirror/core/configure';
4
- import { W as WatcherContext } from "./reactive-context-ClTRYXie.js";
5
- import { macroCondition, getGlobalConfig } from '@embroider/macros';
4
+ import { W as WatcherContext } from "./reactive-context-DKimDkR3.js";
6
5
 
7
6
  /**
8
7
  * {@include ./install.md}
@@ -20,59 +19,20 @@ function tryConsumeContext(signal) {
20
19
  // eslint-disable-next-line no-console
21
20
  console.error = logError;
22
21
  watcher?.watcher.watch(signal);
23
- if (macroCondition(getGlobalConfig().WarpDriveMirror.activeLogging.LOG_REACT_SIGNAL_INTEGRATION)) {
24
- if (getGlobalConfig().WarpDriveMirror.debug.LOG_REACT_SIGNAL_INTEGRATION || globalThis.getWarpDriveRuntimeConfig().debug.LOG_REACT_SIGNAL_INTEGRATION) {
25
- // eslint-disable-next-line no-console
26
- console.log(`[WarpDrive] Consumed Context Signal`, signal, watcher);
27
- }
28
- }
29
22
  } catch {
30
23
  // eslint-disable-next-line no-console
31
24
  console.error = logError;
32
25
  // if we are not in a React context, we will Error
33
26
  // so we just ignore it.
34
- if (macroCondition(getGlobalConfig().WarpDriveMirror.activeLogging.LOG_REACT_SIGNAL_INTEGRATION)) {
35
- if (getGlobalConfig().WarpDriveMirror.debug.LOG_REACT_SIGNAL_INTEGRATION || globalThis.getWarpDriveRuntimeConfig().debug.LOG_REACT_SIGNAL_INTEGRATION) {
36
- // eslint-disable-next-line no-console
37
- console.log(`[WarpDrive] No Context Available To Consume Signal`, signal);
38
- }
39
- }
40
- }
41
- }
42
- let pending;
43
- async function settled() {
44
- if (macroCondition(getGlobalConfig().WarpDriveMirror.env.TESTING)) {
45
- // in testing mode we provide a test waiter integration
46
- if (!pending || !pending.length) return;
47
- const current = pending ?? [];
48
- pending = [];
49
- await Promise.allSettled(current);
50
- await Promise.resolve();
51
- await Promise.resolve();
52
- await Promise.resolve();
53
- return settled();
54
27
  }
55
28
  }
29
+ async function settled() {}
56
30
  function buildSignalConfig(options) {
57
31
  return {
58
- createSignal: (obj, key) => new Signal.State(macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? {
59
- obj,
60
- key
61
- } : null, {
32
+ createSignal: (obj, key) => new Signal.State(null, {
62
33
  equals: () => false
63
34
  }),
64
35
  notifySignal: signal => {
65
- if (macroCondition(getGlobalConfig().WarpDriveMirror.activeLogging.LOG_REACT_SIGNAL_INTEGRATION)) {
66
- if (getGlobalConfig().WarpDriveMirror.debug.LOG_REACT_SIGNAL_INTEGRATION || globalThis.getWarpDriveRuntimeConfig().debug.LOG_REACT_SIGNAL_INTEGRATION) {
67
- if (Signal.subtle.hasSinks(signal)) {
68
- // eslint-disable-next-line no-console
69
- console.log(`[WarpDrive] Notifying Signal`, signal);
70
- } else {
71
- // eslint-disable-next-line no-console
72
- console.log(`[WarpDrive] Notified Signal That Has No Watcher`, signal);
73
- }
74
- }
75
- }
76
36
  signal.set(signal.get());
77
37
  },
78
38
  consumeSignal: signal => {
@@ -87,14 +47,6 @@ function buildSignalConfig(options) {
87
47
  };
88
48
  },
89
49
  waitFor: promise => {
90
- if (macroCondition(getGlobalConfig().WarpDriveMirror.env.TESTING)) {
91
- pending = pending || [];
92
- const newPromise = promise.finally(() => {
93
- pending = pending.filter(p => p !== newPromise);
94
- });
95
- pending.push(newPromise);
96
- return newPromise;
97
- }
98
50
  return promise;
99
51
  },
100
52
  willSyncFlushWatchers: () => false
@@ -0,0 +1,110 @@
1
+ import { Signal } from 'signal-polyfill';
2
+ import { createContext, useMemo, useSyncExternalStore } from 'react';
3
+ import { jsx } from 'react/jsx-runtime';
4
+ let nextFlush = null;
5
+ let watchers = [];
6
+ let watcherId = 0;
7
+ function clearWatcher(state) {
8
+ state.watcher.unwatch(...Signal.subtle.introspectSources(state.watcher));
9
+ }
10
+ function flush(state) {
11
+ state.pending = false;
12
+ if (state.destroyed) {
13
+ state.snapshot = null;
14
+ clearWatcher(state);
15
+ return;
16
+ }
17
+ // any time signals have changed, we notify React that our store has updated
18
+ state.snapshot = {
19
+ watcher: state.watcher
20
+ };
21
+ if (state.notifyReact) state.notifyReact();
22
+
23
+ // tell the Watcher to start watching for changes again
24
+ // by signaling that notifications have been flushed.
25
+ state.watcher.watch();
26
+ }
27
+ function _createWatcher() {
28
+ const id = watcherId++;
29
+ const state = {
30
+ watcherId: id,
31
+ pending: false,
32
+ destroyed: false,
33
+ notifyReact: null,
34
+ watcher: null,
35
+ // the extra wrapper returned here ensures that the context value for the watcher
36
+ // changes causing a re-render when the watcher is updated.
37
+ snapshot: null
38
+ };
39
+ state.watcher = new Signal.subtle.Watcher((...args) => {
40
+ if (!state.pending && !state.destroyed) {
41
+ watchers.push(state);
42
+ state.pending = true;
43
+ if (!nextFlush) {
44
+ nextFlush = new Promise(resolve => {
45
+ queueMicrotask(() => {
46
+ queueMicrotask(() => {
47
+ queueMicrotask(() => {
48
+ watchers.forEach(flush);
49
+ watchers = [];
50
+ nextFlush = null;
51
+ resolve();
52
+ });
53
+ });
54
+ });
55
+ });
56
+ }
57
+ } else if (state.destroyed) {
58
+ // if we are destroyed, we clear the watcher signals
59
+ // so that it does not continue to watch for changes.
60
+ state.snapshot = null;
61
+ clearWatcher(state);
62
+ }
63
+ });
64
+
65
+ // The watcher won't begin watching until we call `watcher.watch()`
66
+ state.watcher.watch();
67
+ state.snapshot = {
68
+ watcher: state.watcher
69
+ };
70
+ return state;
71
+ }
72
+ function useWatcher() {
73
+ const state = useMemo(_createWatcher, []);
74
+ return useSyncExternalStore(notifyChanged => {
75
+ state.destroyed = false;
76
+ state.notifyReact = notifyChanged;
77
+
78
+ // The watcher won't begin watching until we call `watcher.watch()`
79
+ state.watcher.watch();
80
+ return () => {
81
+ state.destroyed = true;
82
+ state.notifyReact = null;
83
+ };
84
+ }, () => state.snapshot);
85
+ }
86
+
87
+ /**
88
+ * @category Contexts
89
+ */
90
+ const WatcherContext = /*#__PURE__*/createContext(null);
91
+
92
+ /**
93
+ *
94
+ * @category Components
95
+ */
96
+ function ReactiveContext({
97
+ children
98
+ }) {
99
+ const watcher = useWatcher();
100
+ /**
101
+ * Unlike other frameworks, React does not have a built-in way to provide
102
+ * a context value other than by rendering an extra component.
103
+ *
104
+ */
105
+ return /*#__PURE__*/jsx(WatcherContext, {
106
+ value: watcher,
107
+ children: children
108
+ });
109
+ }
110
+ export { ReactiveContext as R, WatcherContext as W };
@@ -1,8 +1,7 @@
1
- import { R as ReactiveContext } from "./reactive-context-ClTRYXie.js";
2
- export { W as WatcherContext } from "./reactive-context-ClTRYXie.js";
1
+ import { R as ReactiveContext } from "./reactive-context-DKimDkR3.js";
2
+ export { W as WatcherContext } from "./reactive-context-DKimDkR3.js";
3
3
  import '@warp-drive-mirror/core';
4
4
  import { useMemo, createContext, use, useRef, useEffect } from 'react';
5
- import { macroCondition, getGlobalConfig } from '@embroider/macros';
6
5
  import { jsx, Fragment } from 'react/jsx-runtime';
7
6
  import { DISPOSE, createRequestSubscription, signal } from '@warp-drive-mirror/core/store/-private';
8
7
  import '@warp-drive-mirror/core/request';
@@ -13,11 +12,6 @@ const StoreContext = /*#__PURE__*/createContext(null);
13
12
  */
14
13
  function useStore() {
15
14
  const store = use(StoreContext);
16
- macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? (test => {
17
- if (!test) {
18
- throw new Error("No Store provided via context. Please ensure you are using <StoreProvider> to provide a Store instance.");
19
- }
20
- })(store) : {};
21
15
  return store;
22
16
  }
23
17
  /**
@@ -186,18 +180,14 @@ function Request($props) {
186
180
  });
187
181
  }
188
182
  function isStrictModeRender() {
189
- const count = useRef(0);
183
+ useRef(0);
190
184
 
191
185
  // in debug we need to skip every second invocation
192
- if (macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG)) {
193
- if (count.current++ % 2 === 1) {
194
- return true;
195
- }
196
- }
186
+
197
187
  return false;
198
188
  }
199
189
  function InternalRequest($props) {
200
- const isStrict = isStrictModeRender();
190
+ isStrictModeRender();
201
191
  const store = $props.store ?? useStore();
202
192
  const Chrome = $props.chrome ?? DefaultChrome;
203
193
  const sink = useRef(null);
@@ -228,21 +218,6 @@ function InternalRequest($props) {
228
218
  return sink.current ? initialized.current.dispose : undefined;
229
219
  };
230
220
  let maybeEffect = effect;
231
- if (macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG)) {
232
- if (isStrict) {
233
- maybeEffect = () => {
234
- if (initialized.current) {
235
- return effect();
236
- }
237
- return () => {
238
- // initialize our actual effect
239
- effect();
240
- // in strict mode we don't want to run the teardown
241
- // for the second invocation
242
- };
243
- };
244
- }
245
- }
246
221
  useEffect(maybeEffect, [sink.current]);
247
222
  const state = $props.subscription ?? sink.current;
248
223
  const slots = $props.states;
@@ -1,8 +1,7 @@
1
1
  import { use } from 'react';
2
2
  import { Signal } from 'signal-polyfill';
3
3
  import { setupSignals } from '@warp-drive-mirror/core/configure';
4
- import { W as WatcherContext } from "./reactive-context-ClTRYXie.js";
5
- import { macroCondition, getGlobalConfig } from '@embroider/macros';
4
+ import { W as WatcherContext } from "./reactive-context-DKimDkR3.js";
6
5
 
7
6
  /**
8
7
  * {@include ./install.md}
@@ -20,59 +19,20 @@ function tryConsumeContext(signal) {
20
19
  // eslint-disable-next-line no-console
21
20
  console.error = logError;
22
21
  watcher?.watcher.watch(signal);
23
- if (macroCondition(getGlobalConfig().WarpDriveMirror.activeLogging.LOG_REACT_SIGNAL_INTEGRATION)) {
24
- if (getGlobalConfig().WarpDriveMirror.debug.LOG_REACT_SIGNAL_INTEGRATION || globalThis.getWarpDriveRuntimeConfig().debug.LOG_REACT_SIGNAL_INTEGRATION) {
25
- // eslint-disable-next-line no-console
26
- console.log(`[WarpDrive] Consumed Context Signal`, signal, watcher);
27
- }
28
- }
29
22
  } catch {
30
23
  // eslint-disable-next-line no-console
31
24
  console.error = logError;
32
25
  // if we are not in a React context, we will Error
33
26
  // so we just ignore it.
34
- if (macroCondition(getGlobalConfig().WarpDriveMirror.activeLogging.LOG_REACT_SIGNAL_INTEGRATION)) {
35
- if (getGlobalConfig().WarpDriveMirror.debug.LOG_REACT_SIGNAL_INTEGRATION || globalThis.getWarpDriveRuntimeConfig().debug.LOG_REACT_SIGNAL_INTEGRATION) {
36
- // eslint-disable-next-line no-console
37
- console.log(`[WarpDrive] No Context Available To Consume Signal`, signal);
38
- }
39
- }
40
- }
41
- }
42
- let pending;
43
- async function settled() {
44
- if (macroCondition(getGlobalConfig().WarpDriveMirror.env.TESTING)) {
45
- // in testing mode we provide a test waiter integration
46
- if (!pending || !pending.length) return;
47
- const current = pending ?? [];
48
- pending = [];
49
- await Promise.allSettled(current);
50
- await Promise.resolve();
51
- await Promise.resolve();
52
- await Promise.resolve();
53
- return settled();
54
27
  }
55
28
  }
29
+ async function settled() {}
56
30
  function buildSignalConfig(options) {
57
31
  return {
58
- createSignal: (obj, key) => new Signal.State(macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) ? {
59
- obj,
60
- key
61
- } : null, {
32
+ createSignal: (obj, key) => new Signal.State(null, {
62
33
  equals: () => false
63
34
  }),
64
35
  notifySignal: signal => {
65
- if (macroCondition(getGlobalConfig().WarpDriveMirror.activeLogging.LOG_REACT_SIGNAL_INTEGRATION)) {
66
- if (getGlobalConfig().WarpDriveMirror.debug.LOG_REACT_SIGNAL_INTEGRATION || globalThis.getWarpDriveRuntimeConfig().debug.LOG_REACT_SIGNAL_INTEGRATION) {
67
- if (Signal.subtle.hasSinks(signal)) {
68
- // eslint-disable-next-line no-console
69
- console.log(`[WarpDrive] Notifying Signal`, signal);
70
- } else {
71
- // eslint-disable-next-line no-console
72
- console.log(`[WarpDrive] Notified Signal That Has No Watcher`, signal);
73
- }
74
- }
75
- }
76
36
  signal.set(signal.get());
77
37
  },
78
38
  consumeSignal: signal => {
@@ -87,14 +47,6 @@ function buildSignalConfig(options) {
87
47
  };
88
48
  },
89
49
  waitFor: promise => {
90
- if (macroCondition(getGlobalConfig().WarpDriveMirror.env.TESTING)) {
91
- pending = pending || [];
92
- const newPromise = promise.finally(() => {
93
- pending = pending.filter(p => p !== newPromise);
94
- });
95
- pending.push(newPromise);
96
- return newPromise;
97
- }
98
50
  return promise;
99
51
  },
100
52
  willSyncFlushWatchers: () => false
@@ -0,0 +1,110 @@
1
+ import { Signal } from 'signal-polyfill';
2
+ import { createContext, useMemo, useSyncExternalStore } from 'react';
3
+ import { jsx } from 'react/jsx-runtime';
4
+ let nextFlush = null;
5
+ let watchers = [];
6
+ let watcherId = 0;
7
+ function clearWatcher(state) {
8
+ state.watcher.unwatch(...Signal.subtle.introspectSources(state.watcher));
9
+ }
10
+ function flush(state) {
11
+ state.pending = false;
12
+ if (state.destroyed) {
13
+ state.snapshot = null;
14
+ clearWatcher(state);
15
+ return;
16
+ }
17
+ // any time signals have changed, we notify React that our store has updated
18
+ state.snapshot = {
19
+ watcher: state.watcher
20
+ };
21
+ if (state.notifyReact) state.notifyReact();
22
+
23
+ // tell the Watcher to start watching for changes again
24
+ // by signaling that notifications have been flushed.
25
+ state.watcher.watch();
26
+ }
27
+ function _createWatcher() {
28
+ const id = watcherId++;
29
+ const state = {
30
+ watcherId: id,
31
+ pending: false,
32
+ destroyed: false,
33
+ notifyReact: null,
34
+ watcher: null,
35
+ // the extra wrapper returned here ensures that the context value for the watcher
36
+ // changes causing a re-render when the watcher is updated.
37
+ snapshot: null
38
+ };
39
+ state.watcher = new Signal.subtle.Watcher((...args) => {
40
+ if (!state.pending && !state.destroyed) {
41
+ watchers.push(state);
42
+ state.pending = true;
43
+ if (!nextFlush) {
44
+ nextFlush = new Promise(resolve => {
45
+ queueMicrotask(() => {
46
+ queueMicrotask(() => {
47
+ queueMicrotask(() => {
48
+ watchers.forEach(flush);
49
+ watchers = [];
50
+ nextFlush = null;
51
+ resolve();
52
+ });
53
+ });
54
+ });
55
+ });
56
+ }
57
+ } else if (state.destroyed) {
58
+ // if we are destroyed, we clear the watcher signals
59
+ // so that it does not continue to watch for changes.
60
+ state.snapshot = null;
61
+ clearWatcher(state);
62
+ }
63
+ });
64
+
65
+ // The watcher won't begin watching until we call `watcher.watch()`
66
+ state.watcher.watch();
67
+ state.snapshot = {
68
+ watcher: state.watcher
69
+ };
70
+ return state;
71
+ }
72
+ function useWatcher() {
73
+ const state = useMemo(_createWatcher, []);
74
+ return useSyncExternalStore(notifyChanged => {
75
+ state.destroyed = false;
76
+ state.notifyReact = notifyChanged;
77
+
78
+ // The watcher won't begin watching until we call `watcher.watch()`
79
+ state.watcher.watch();
80
+ return () => {
81
+ state.destroyed = true;
82
+ state.notifyReact = null;
83
+ };
84
+ }, () => state.snapshot);
85
+ }
86
+
87
+ /**
88
+ * @category Contexts
89
+ */
90
+ const WatcherContext = /*#__PURE__*/createContext(null);
91
+
92
+ /**
93
+ *
94
+ * @category Components
95
+ */
96
+ function ReactiveContext({
97
+ children
98
+ }) {
99
+ const watcher = useWatcher();
100
+ /**
101
+ * Unlike other frameworks, React does not have a built-in way to provide
102
+ * a context value other than by rendering an extra component.
103
+ *
104
+ */
105
+ return /*#__PURE__*/jsx(WatcherContext, {
106
+ value: watcher,
107
+ children: children
108
+ });
109
+ }
110
+ export { ReactiveContext as R, WatcherContext as W };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@warp-drive-mirror/react",
3
3
  "description": "Data bindings and utilities for React applications using WarpDrive",
4
- "version": "5.8.0-alpha.37",
4
+ "version": "5.8.0-alpha.40",
5
5
  "license": "MIT",
6
6
  "author": "Chris Thoburn <runspired@users.noreply.github.com>",
7
7
  "repository": {
@@ -27,26 +27,18 @@
27
27
  ],
28
28
  "exports": {
29
29
  ".": {
30
- "unpkg": {
31
- "development": {
32
- "deprecations": "./dist/unpkg/dev-deprecated/index.js",
33
- "default": "./dist/unpkg/dev/index.js"
34
- },
35
- "deprecations": "./dist/unpkg/prod-deprecated/index.js",
36
- "default": "./dist/unpkg/prod/index.js"
37
- },
30
+ "unpkg-dev-deprecated": "./dist/unpkg/dev-deprecated/index.js",
31
+ "unpkg-dev": "./dist/unpkg/dev/index.js",
32
+ "unpkg-deprecated": "./dist/unpkg/prod-deprecated/index.js",
33
+ "unpkg": "./dist/unpkg/prod/index.js",
38
34
  "types": "./declarations/index.d.ts",
39
35
  "default": "./dist/index.js"
40
36
  },
41
37
  "./*": {
42
- "unpkg": {
43
- "development": {
44
- "deprecations": "./dist/unpkg/dev-deprecated/*.js",
45
- "default": "./dist/unpkg/dev/*.js"
46
- },
47
- "deprecations": "./dist/unpkg/prod-deprecated/*.js",
48
- "default": "./dist/unpkg/prod/*.js"
49
- },
38
+ "unpkg-dev-deprecated": "./dist/unpkg/dev-deprecated/*.js",
39
+ "unpkg-dev": "./dist/unpkg/dev/*.js",
40
+ "unpkg-deprecated": "./dist/unpkg/prod-deprecated/*.js",
41
+ "unpkg": "./dist/unpkg/prod/*.js",
50
42
  "types": "./declarations/*.d.ts",
51
43
  "default": "./dist/*.js"
52
44
  }
@@ -54,8 +46,8 @@
54
46
  "peerDependencies": {},
55
47
  "dependencies": {
56
48
  "@embroider/macros": "^1.18.1",
57
- "@warp-drive-mirror/core": "5.8.0-alpha.37",
58
- "@warp-drive-mirror/tc39-proposal-signals": "5.8.0-alpha.37",
49
+ "@warp-drive-mirror/core": "5.8.0-alpha.40",
50
+ "@warp-drive-mirror/tc39-proposal-signals": "5.8.0-alpha.40",
59
51
  "signal-polyfill": "^0.2.2",
60
52
  "react": "^19.1.1"
61
53
  },
@@ -69,8 +61,8 @@
69
61
  "@babel/runtime": "^7.28.3",
70
62
  "decorator-transforms": "^2.3.0",
71
63
  "@embroider/addon-dev": "^8.1.0",
72
- "@warp-drive/internal-config": "5.8.0-alpha.37",
73
- "@warp-drive-mirror/core": "5.8.0-alpha.37",
64
+ "@warp-drive/internal-config": "5.8.0-alpha.40",
65
+ "@warp-drive-mirror/core": "5.8.0-alpha.40",
74
66
  "@types/react": "^19.1.11",
75
67
  "react": "^19.1.1",
76
68
  "rollup": "^4.48.0",
@@ -1,18 +0,0 @@
1
- import { Signal } from "signal-polyfill";
2
- import { type JSX, type ReactNode, type Context } from "react";
3
- export declare function useWatcher(): {
4
- watcher: Signal.subtle.Watcher;
5
- } | null;
6
- /**
7
- * @category Contexts
8
- */
9
- export declare const WatcherContext: Context<{
10
- watcher: Signal.subtle.Watcher;
11
- } | null>;
12
- /**
13
- *
14
- * @category Components
15
- */
16
- export declare function ReactiveContext({ children }: {
17
- children: ReactNode;
18
- }): JSX.Element;
@@ -1,141 +0,0 @@
1
- import { RequestArgs, type ContentFeatures, type RecoveryFeatures, type RequestLoadingState, type RequestState } from "@warp-drive-mirror/core/store/-private";
2
- import type { StructuredErrorDocument } from "@warp-drive-mirror/core/types/request";
3
- import { JSX, ReactNode } from "react";
4
- interface ChromeComponentProps<RT> {
5
- children: ReactNode;
6
- state: RequestState | null;
7
- features: ContentFeatures<RT>;
8
- }
9
- export interface RequestProps<
10
- RT,
11
- E
12
- > extends RequestArgs<RT, E> {
13
- chrome?: React.FC<ChromeComponentProps<RT>>;
14
- states: RequestStates<RT, E>;
15
- }
16
- interface RequestStates<
17
- RT,
18
- E
19
- > {
20
- /**
21
- * The block to render when the component is idle and waiting to be given a request.
22
- *
23
- */
24
- idle?: React.FC<{}>;
25
- /**
26
- * The block to render when the request is loading.
27
- *
28
- */
29
- loading?: React.FC<{
30
- state: RequestLoadingState;
31
- }>;
32
- /**
33
- * The block to render when the request was cancelled.
34
- *
35
- */
36
- cancelled?: React.FC<{
37
- /**
38
- * The Error the request rejected with.
39
- */
40
- error: StructuredErrorDocument<E>;
41
- /**
42
- * Utilities to assist in recovering from the error.
43
- */
44
- features: RecoveryFeatures;
45
- }>;
46
- /**
47
- * The block to render when the request failed. If this block is not provided,
48
- * the error will be rethrown.
49
- *
50
- * Thus it is required to provide an error block and proper error handling if
51
- * you do not want the error to crash the application.
52
- */
53
- error: React.FC<{
54
- /**
55
- * The Error the request rejected with.
56
- */
57
- error: StructuredErrorDocument<E>;
58
- /**
59
- * Utilities to assist in recovering from the error.
60
- */
61
- features: RecoveryFeatures;
62
- }>;
63
- /**
64
- * The block to render when the request succeeded.
65
- *
66
- */
67
- content: React.FC<{
68
- result: RT;
69
- features: ContentFeatures<RT>;
70
- }>;
71
- }
72
- export declare function Throw({ error }: {
73
- error: Error;
74
- }): never;
75
- /**
76
- * The `<Request />` component is a powerful tool for managing data fetching and
77
- * state in your React application. It provides a declarative approach to reactive
78
- * control-flow for managing requests and state in your application.
79
- *
80
- * The `<Request />` component is ideal for handling "boundaries", outside which some
81
- * state is still allowed to be unresolved and within which it MUST be resolved.
82
- *
83
- * ## Request States
84
- *
85
- * `<Request />` has five states, only one of which will be active and rendered at a time.
86
- *
87
- * - `idle`: The component is waiting to be given a request to monitor
88
- * - `loading`: The request is in progress
89
- * - `error`: The request failed
90
- * - `content`: The request succeeded
91
- * - `cancelled`: The request was cancelled
92
- *
93
- * Additionally, the `content` state has a `refresh` method that can be used to
94
- * refresh the request in the background, which is available as a sub-state of
95
- * the `content` state.
96
- *
97
- * ### Example Usage
98
- *
99
- * ```tsx
100
- * import { Request } from "@warp-drive-mirror/react";
101
- *
102
- * export function UserPreview($props: { id: string | null }) {
103
- * return (
104
- * <Request
105
- * query={findRecord('user', $props.id)}
106
- * states={{
107
- * idle: () => <div>Waiting for User Selection</div>,
108
- * loading: ({ state }) => <div>Loading user data...</div>,
109
- * cancelled: ({ error, features }) => (
110
- * <div>
111
- * <p>Request Cancelled</p>
112
- * <p><button onClick={features.retry}>Start Again?</button></p>
113
- * </div>
114
- * ),
115
- * error: ({ error, features }) => (
116
- * <div>
117
- * <p>Error: {error.message}</p>
118
- * <p><button onClick={features.retry}>Try Again?</button></p>
119
- * </div>
120
- * ),
121
- * content: ({ result, features }) => (
122
- * <div>
123
- * <h2>User Details</h2>
124
- * <p>ID: {result.id}</p>
125
- * <p>Name: {result.name}</p>
126
- * </div>
127
- * ),
128
- * }}
129
- * />
130
- * );
131
- * }
132
- *
133
- * ```
134
- *
135
- * @category Components
136
- */
137
- export declare function Request<
138
- RT,
139
- E
140
- >($props: RequestProps<RT, E>): JSX.Element;
141
- export {};