@warp-drive/react 5.9.0-alpha.21 → 5.9.0-alpha.23

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 (45) hide show
  1. package/dist/index.d.ts +180 -0
  2. package/dist/index.d.ts.map +1 -0
  3. package/dist/index.js +215 -256
  4. package/dist/index.js.map +1 -0
  5. package/dist/install.d.ts +21 -0
  6. package/dist/install.d.ts.map +1 -0
  7. package/dist/install.js +88 -107
  8. package/dist/install.js.map +1 -0
  9. package/dist/reactive-context-DNq02nr1.js +122 -0
  10. package/dist/reactive-context-DNq02nr1.js.map +1 -0
  11. package/dist/unpkg/dev/index.js +259 -304
  12. package/dist/unpkg/dev/index.js.map +1 -0
  13. package/dist/unpkg/dev/install.js +80 -105
  14. package/dist/unpkg/dev/install.js.map +1 -0
  15. package/dist/unpkg/dev/reactive-context-CFMABIw9.js +218 -0
  16. package/dist/unpkg/dev/reactive-context-CFMABIw9.js.map +1 -0
  17. package/dist/unpkg/dev-deprecated/index.js +259 -304
  18. package/dist/unpkg/dev-deprecated/index.js.map +1 -0
  19. package/dist/unpkg/dev-deprecated/install.js +80 -105
  20. package/dist/unpkg/dev-deprecated/install.js.map +1 -0
  21. package/dist/unpkg/dev-deprecated/reactive-context-gO-P9dMN.js +218 -0
  22. package/dist/unpkg/dev-deprecated/reactive-context-gO-P9dMN.js.map +1 -0
  23. package/dist/unpkg/prod/index.js +198 -231
  24. package/dist/unpkg/prod/index.js.map +1 -0
  25. package/dist/unpkg/prod/install.js +54 -61
  26. package/dist/unpkg/prod/install.js.map +1 -0
  27. package/dist/unpkg/prod/reactive-context-CvfXAZqb.js +92 -0
  28. package/dist/unpkg/prod/reactive-context-CvfXAZqb.js.map +1 -0
  29. package/dist/unpkg/prod-deprecated/index.js +198 -231
  30. package/dist/unpkg/prod-deprecated/index.js.map +1 -0
  31. package/dist/unpkg/prod-deprecated/install.js +54 -61
  32. package/dist/unpkg/prod-deprecated/install.js.map +1 -0
  33. package/dist/unpkg/prod-deprecated/reactive-context-CvfXAZqb.js +92 -0
  34. package/dist/unpkg/prod-deprecated/reactive-context-CvfXAZqb.js.map +1 -0
  35. package/package.json +21 -23
  36. package/declarations/-private/reactive-context.d.ts +0 -21
  37. package/declarations/-private/request.d.ts +0 -148
  38. package/declarations/-private/store-provider.d.ts +0 -19
  39. package/declarations/index.d.ts +0 -7
  40. package/declarations/install.d.ts +0 -17
  41. package/dist/reactive-context-ClTRYXie.js +0 -154
  42. package/dist/unpkg/dev/reactive-context-4Y50NyRg.js +0 -306
  43. package/dist/unpkg/dev-deprecated/reactive-context-D54NwOLZ.js +0 -306
  44. package/dist/unpkg/prod/reactive-context-DKimDkR3.js +0 -110
  45. package/dist/unpkg/prod-deprecated/reactive-context-DKimDkR3.js +0 -110
@@ -1,71 +1,64 @@
1
- import { use } from 'react';
2
- import { Signal } from 'signal-polyfill';
3
- import { setupSignals } from '@warp-drive/core/configure';
4
- import { W as WatcherContext } from "./reactive-context-DKimDkR3.js";
1
+ import { n as WatcherContext } from "./reactive-context-CvfXAZqb.js";
2
+ import { Signal } from "signal-polyfill";
3
+ import { use } from "react";
4
+ import { setupSignals } from "@warp-drive/core/configure";
5
5
 
6
+ //#region src/install.ts
6
7
  /**
7
- * {@include ./install.md}
8
- * @module
9
- */
10
-
8
+ * {@include ./install.md}
9
+ * @module
10
+ */
11
11
  function tryConsumeContext(signal) {
12
- // eslint-disable-next-line no-console
13
- const logError = console.error;
14
- try {
15
- // eslint-disable-next-line no-console
16
- console.error = () => {};
17
- // ensure signals are watched by our closest watcher
18
- const watcher = use(WatcherContext);
19
- // eslint-disable-next-line no-console
20
- console.error = logError;
21
- watcher?.watcher.watch(signal);
22
- } catch {
23
- // eslint-disable-next-line no-console
24
- console.error = logError;
25
- // if we are not in a React context, we will Error
26
- // so we just ignore it.
27
- }
12
+ const logError = console.error;
13
+ try {
14
+ console.error = () => {};
15
+ const watcher = use(WatcherContext);
16
+ console.error = logError;
17
+ watcher?.watcher.watch(signal);
18
+ } catch {
19
+ console.error = logError;
20
+ }
28
21
  }
29
22
  /**
30
- * Resolves once all pending requests started via WarpDrive's React signal
31
- * integration have settled. Only tracks requests while `TESTING` is enabled;
32
- * a no-op otherwise.
33
- *
34
- * @public
35
- */
23
+ * Resolves once all pending requests started via WarpDrive's React signal
24
+ * integration have settled. Only tracks requests while `TESTING` is enabled;
25
+ * a no-op otherwise.
26
+ *
27
+ * @public
28
+ */
36
29
  async function settled() {}
37
-
38
30
  /**
39
- * Builds the {@link SignalHooks} implementation backed by the
40
- * [Signal Polyfill](https://github.com/proposal-signals/signal-polyfill),
41
- * used to wire WarpDrive's reactivity primitives into React.
42
- *
43
- * @public
44
- */
31
+ * Builds the {@link SignalHooks} implementation backed by the
32
+ * [Signal Polyfill](https://github.com/proposal-signals/signal-polyfill),
33
+ * used to wire WarpDrive's reactivity primitives into React.
34
+ *
35
+ * @public
36
+ */
45
37
  function buildSignalConfig(options) {
46
- return {
47
- createSignal: (obj, key) => new Signal.State(null, {
48
- equals: () => false
49
- }),
50
- notifySignal: signal => {
51
- signal.set(signal.get());
52
- },
53
- consumeSignal: signal => {
54
- tryConsumeContext(signal);
55
- void signal.get();
56
- },
57
- createMemo: (object, key, fn) => {
58
- const memo = new Signal.Computed(fn);
59
- return () => {
60
- tryConsumeContext(memo);
61
- return memo.get();
62
- };
63
- },
64
- waitFor: promise => {
65
- return promise;
66
- },
67
- willSyncFlushWatchers: () => false
68
- };
38
+ return {
39
+ createSignal: (obj, key) => new Signal.State(null, { equals: () => false }),
40
+ notifySignal: (signal) => {
41
+ signal.set(signal.get());
42
+ },
43
+ consumeSignal: (signal) => {
44
+ tryConsumeContext(signal);
45
+ signal.get();
46
+ },
47
+ createMemo: (object, key, fn) => {
48
+ const memo = new Signal.Computed(fn);
49
+ return () => {
50
+ tryConsumeContext(memo);
51
+ return memo.get();
52
+ };
53
+ },
54
+ waitFor: (promise) => {
55
+ return promise;
56
+ },
57
+ willSyncFlushWatchers: () => false
58
+ };
69
59
  }
70
60
  setupSignals(buildSignalConfig);
71
- export { buildSignalConfig, settled };
61
+
62
+ //#endregion
63
+ export { buildSignalConfig, settled };
64
+ //# sourceMappingURL=install.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install.js","names":["use","Signal","setupSignals","WatcherContext","tryConsumeContext","signal","logError","console","error","watcher","watch","pending","settled","buildSignalConfig","options","createSignal","obj","key","State","equals","notifySignal","set","get","consumeSignal","createMemo","object","fn","memo","Computed","waitFor","promise","willSyncFlushWatchers"],"sources":["../../../src/install.ts"],"sourcesContent":["/**\n * {@include ./install.md}\n * @module\n */\n\nimport { use } from 'react';\nimport { Signal } from 'signal-polyfill';\n\nimport { LOG_REACT_SIGNAL_INTEGRATION } from '@warp-drive/core/build-config/debugging';\nimport { DEBUG, TESTING } from '@warp-drive/core/build-config/env';\nimport { type HooksOptions, setupSignals, type SignalHooks } from '@warp-drive/core/configure';\n\nimport { WatcherContext } from './-private/reactive-context';\n\nfunction tryConsumeContext(signal: Signal.State<unknown> | Signal.Computed<unknown>): void {\n // eslint-disable-next-line no-console\n const logError = console.error;\n try {\n // eslint-disable-next-line no-console\n console.error = () => {};\n // ensure signals are watched by our closest watcher\n const watcher = use(WatcherContext);\n // eslint-disable-next-line no-console\n console.error = logError;\n watcher?.watcher.watch(signal);\n if (LOG_REACT_SIGNAL_INTEGRATION) {\n // eslint-disable-next-line no-console\n console.log(`[WarpDrive] Consumed Context Signal`, signal, watcher);\n }\n } catch {\n // eslint-disable-next-line no-console\n console.error = logError;\n // if we are not in a React context, we will Error\n // so we just ignore it.\n if (LOG_REACT_SIGNAL_INTEGRATION) {\n // eslint-disable-next-line no-console\n console.log(`[WarpDrive] No Context Available To Consume Signal`, signal);\n }\n }\n}\n\nlet pending: Promise<unknown>[];\n/**\n * Resolves once all pending requests started via WarpDrive's React signal\n * integration have settled. Only tracks requests while `TESTING` is enabled;\n * a no-op otherwise.\n *\n * @public\n */\nexport async function settled(): Promise<void> {\n if (TESTING) {\n // in testing mode we provide a test waiter integration\n if (!pending || !pending.length) return;\n const current = pending ?? [];\n pending = [];\n await Promise.allSettled(current);\n await Promise.resolve();\n await Promise.resolve();\n await Promise.resolve();\n\n return settled();\n }\n}\n\n/**\n * Builds the {@link SignalHooks} implementation backed by the\n * [Signal Polyfill](https://github.com/proposal-signals/signal-polyfill),\n * used to wire WarpDrive's reactivity primitives into React.\n *\n * @public\n */\nexport function buildSignalConfig(options: HooksOptions): SignalHooks {\n return {\n createSignal: (obj: object, key: string | symbol) =>\n new Signal.State(DEBUG ? { obj, key } : null, { equals: () => false }),\n\n notifySignal: (signal: Signal.State<unknown>) => {\n if (LOG_REACT_SIGNAL_INTEGRATION) {\n if (Signal.subtle.hasSinks(signal)) {\n // eslint-disable-next-line no-console\n console.log(`[WarpDrive] Notifying Signal`, signal);\n } else {\n // eslint-disable-next-line no-console\n console.log(`[WarpDrive] Notified Signal That Has No Watcher`, signal);\n }\n }\n signal.set(signal.get());\n },\n\n consumeSignal: (signal: Signal.State<unknown>) => {\n tryConsumeContext(signal);\n void signal.get();\n },\n\n createMemo: <F>(object: object, key: string | symbol, fn: () => F): (() => F) => {\n const memo = new Signal.Computed<F>(fn);\n return () => {\n tryConsumeContext(memo);\n\n return memo.get();\n };\n },\n\n waitFor: (promise) => {\n if (TESTING) {\n pending = pending || [];\n const newPromise = promise.finally(() => {\n pending = pending.filter((p) => p !== newPromise);\n });\n pending.push(newPromise);\n return newPromise;\n }\n return promise;\n },\n\n willSyncFlushWatchers: () => false,\n } as SignalHooks;\n}\n\nsetupSignals(buildSignalConfig);\n"],"mappings":";;;;;;;;;;AAcA,SAASI,kBAAkBC,QAAgE;CAEzF,MAAMC,WAAWC,QAAQC;CACzB,IAAI;EAEFD,QAAQC,cAAc,CAAC;EAEvB,MAAMC,UAAUT,IAAIG,cAAc;EAElCI,QAAQC,QAAQF;EAChBG,SAASA,QAAQC,MAAML,MAAM;CAK/B,QAAQ;EAENE,QAAQC,QAAQF;CAOlB;AACF;;;;;;;;AAUA,eAAsBM,UAAyB,CAa/C;;;;;;;;AASA,SAAgBC,kBAAkBC,SAAoC;CACpE,OAAO;EACLC,eAAeC,KAAaC,QAC1B,IAAIhB,OAAOiB,MAA6B,MAAM,EAAEC,cAAc,MAAM,CAAC;EAEvEC,eAAef,WAAkC;GAU/CA,OAAOgB,IAAIhB,OAAOiB,IAAI,CAAC;EACzB;EAEAC,gBAAgBlB,WAAkC;GAChDD,kBAAkBC,MAAM;GACxB,AAAKA,OAAOiB,IAAI;EAClB;EAEAE,aAAgBC,QAAgBR,KAAsBS,OAA2B;GAC/E,MAAMC,OAAO,IAAI1B,OAAO2B,SAAYF,EAAE;GACtC,aAAa;IACXtB,kBAAkBuB,IAAI;IAEtB,OAAOA,KAAKL,IAAI;GAClB;EACF;EAEAO,UAAUC,YAAY;GASpB,OAAOA;EACT;EAEAC,6BAA6B;CAC/B;AACF;AAEA7B,aAAaW,iBAAiB"}
@@ -0,0 +1,92 @@
1
+ import { Signal } from "signal-polyfill";
2
+ import { createContext, useMemo, useSyncExternalStore } from "react";
3
+ import { jsx } from "react/jsx-runtime";
4
+
5
+ //#region src/-private/reactive-context.tsx
6
+ let nextFlush = null;
7
+ let watchers = [];
8
+ let watcherId = 0;
9
+ function clearWatcher(state) {
10
+ state.watcher.unwatch(...Signal.subtle.introspectSources(state.watcher));
11
+ }
12
+ function flush(state) {
13
+ state.pending = false;
14
+ if (state.destroyed) {
15
+ state.snapshot = null;
16
+ clearWatcher(state);
17
+ return;
18
+ }
19
+ state.snapshot = { watcher: state.watcher };
20
+ if (state.notifyReact) state.notifyReact();
21
+ state.watcher.watch();
22
+ }
23
+ function _createWatcher() {
24
+ const state = {
25
+ watcherId: watcherId++,
26
+ pending: false,
27
+ destroyed: false,
28
+ notifyReact: null,
29
+ watcher: null,
30
+ snapshot: null
31
+ };
32
+ state.watcher = new Signal.subtle.Watcher((...args) => {
33
+ if (!state.pending && !state.destroyed) {
34
+ watchers.push(state);
35
+ state.pending = true;
36
+ if (!nextFlush) nextFlush = new Promise((resolve) => {
37
+ queueMicrotask(() => {
38
+ queueMicrotask(() => {
39
+ queueMicrotask(() => {
40
+ watchers.forEach(flush);
41
+ watchers = [];
42
+ nextFlush = null;
43
+ resolve();
44
+ });
45
+ });
46
+ });
47
+ });
48
+ } else if (state.destroyed) {
49
+ state.snapshot = null;
50
+ clearWatcher(state);
51
+ }
52
+ });
53
+ state.watcher.watch();
54
+ state.snapshot = { watcher: state.watcher };
55
+ return state;
56
+ }
57
+ function useWatcher() {
58
+ const state = useMemo(_createWatcher, []);
59
+ return useSyncExternalStore((notifyChanged) => {
60
+ state.destroyed = false;
61
+ state.notifyReact = notifyChanged;
62
+ state.watcher.watch();
63
+ return () => {
64
+ state.destroyed = true;
65
+ state.notifyReact = null;
66
+ };
67
+ }, () => state.snapshot);
68
+ }
69
+ /**
70
+ * @category Contexts
71
+ */
72
+ const WatcherContext = /*#__PURE__*/ createContext(null);
73
+ /**
74
+ *
75
+ * @category Components
76
+ */
77
+ function ReactiveContext({ children }) {
78
+ const watcher = useWatcher();
79
+ /**
80
+ * Unlike other frameworks, React does not have a built-in way to provide
81
+ * a context value other than by rendering an extra component.
82
+ *
83
+ */
84
+ return /*#__PURE__*/ jsx(WatcherContext, {
85
+ value: watcher,
86
+ children
87
+ });
88
+ }
89
+
90
+ //#endregion
91
+ export { WatcherContext as n, ReactiveContext as t };
92
+ //# sourceMappingURL=reactive-context-CvfXAZqb.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactive-context-CvfXAZqb.js","names":["Signal","createContext","useSyncExternalStore","useMemo","jsx","_jsx","nextFlush","watchers","watcherId","clearWatcher","state","watcher","unwatch","subtle","introspectSources","flush","pending","destroyed","snapshot","notifyReact","watch","_createWatcher","id","Watcher","args","push","Promise","resolve","queueMicrotask","forEach","useWatcher","notifyChanged","WatcherContext","ReactiveContext","children","value"],"sources":["../../../src/-private/reactive-context.tsx"],"sourcesContent":["import { Signal } from \"signal-polyfill\";\nimport { createContext, type JSX, type ReactNode, useSyncExternalStore, type Context, useMemo } from \"react\";\nimport { LOG_REACT_SIGNAL_INTEGRATION } from \"@warp-drive/core/build-config/debugging\";\n\nlet nextFlush: Promise<void> | null = null;\nlet watchers: WatcherState[] = [];\nlet watcherId = 0;\n\ninterface WatcherState {\n watcherId: number;\n pending: boolean;\n destroyed: boolean;\n notifyReact: (() => void) | null;\n watcher: Signal.subtle.Watcher;\n\n // the extra wrapper returned here ensures that the context value for the watcher\n // changes causing a re-render when the watcher is updated.\n snapshot: { watcher: Signal.subtle.Watcher } | null;\n}\n\nfunction clearWatcher(state: WatcherState) {\n state.watcher.unwatch(...Signal.subtle.introspectSources(state.watcher));\n}\n\nfunction flush(state: WatcherState) {\n state.pending = false;\n if (state.destroyed) {\n if (LOG_REACT_SIGNAL_INTEGRATION) {\n console.log(`[WarpDrive] Detected Watcher Destroyed During Notify Flush, clearing signals`);\n }\n state.snapshot = null;\n clearWatcher(state);\n return;\n }\n\n if (LOG_REACT_SIGNAL_INTEGRATION) {\n console.log(`[WarpDrive] Notifying React That WatcherContext:${state.watcherId} Has Updated`);\n console.log(\"all signals\", new Set(Signal.subtle.introspectSources(state.watcher)));\n console.log(\"dirty signals\", new Set(state.watcher.getPending()));\n }\n\n // any time signals have changed, we notify React that our store has updated\n state.snapshot = { watcher: state.watcher };\n if (state.notifyReact) state.notifyReact();\n\n // tell the Watcher to start watching for changes again\n // by signaling that notifications have been flushed.\n state.watcher.watch();\n}\n\nfunction _createWatcher() {\n const id = watcherId++;\n if (LOG_REACT_SIGNAL_INTEGRATION) {\n console.log(`[WarpDrive] Creating a WatcherContext:${id}`);\n }\n const state: WatcherState = {\n watcherId: id,\n pending: false,\n destroyed: false,\n notifyReact: null as (() => void) | null,\n watcher: null as unknown as Signal.subtle.Watcher,\n\n // the extra wrapper returned here ensures that the context value for the watcher\n // changes causing a re-render when the watcher is updated.\n snapshot: null as { watcher: Signal.subtle.Watcher } | null,\n };\n\n state.watcher = new Signal.subtle.Watcher((...args) => {\n if (LOG_REACT_SIGNAL_INTEGRATION) {\n console.log(`watcher ${state.watcherId} notified`, args, state.watcher);\n }\n if (!state.pending && !state.destroyed) {\n watchers.push(state);\n state.pending = true;\n\n if (!nextFlush) {\n nextFlush = new Promise((resolve) => {\n queueMicrotask(() => {\n queueMicrotask(() => {\n queueMicrotask(() => {\n watchers.forEach(flush);\n if (LOG_REACT_SIGNAL_INTEGRATION) {\n console.log(\n \"Flushed watcher:\",\n watchers.map((w) => w.watcherId)\n );\n }\n watchers = [];\n nextFlush = null;\n\n resolve();\n });\n });\n });\n });\n }\n } else if (state.destroyed) {\n if (LOG_REACT_SIGNAL_INTEGRATION) {\n console.log(`[WarpDrive] Detected Watcher Destroyed During Notify, clearing signals`);\n }\n // if we are destroyed, we clear the watcher signals\n // so that it does not continue to watch for changes.\n state.snapshot = null;\n clearWatcher(state);\n }\n });\n\n // The watcher won't begin watching until we call `watcher.watch()`\n state.watcher.watch();\n state.snapshot = { watcher: state.watcher };\n\n return state;\n}\n\nexport function useWatcher(): { watcher: Signal.subtle.Watcher } | null {\n const state = useMemo(_createWatcher, []);\n\n return useSyncExternalStore(\n (notifyChanged: () => void) => {\n if (LOG_REACT_SIGNAL_INTEGRATION) {\n console.log(`[WarpDrive] Subscribing to Watcher`);\n }\n state.destroyed = false;\n state.notifyReact = notifyChanged;\n\n // The watcher won't begin watching until we call `watcher.watch()`\n state.watcher.watch();\n\n return () => {\n if (LOG_REACT_SIGNAL_INTEGRATION) {\n console.log(`[WarpDrive] Deactivating Watcher Subscription`);\n }\n state.destroyed = true;\n state.notifyReact = null;\n };\n },\n () => state.snapshot\n );\n}\n\n/**\n * @category Contexts\n */\nexport const WatcherContext: Context<{\n /**\n * The `Signal.subtle.Watcher` used to observe signal changes for the nearest {@link ReactiveContext}.\n */\n watcher: Signal.subtle.Watcher;\n} | null> = createContext<{\n watcher: Signal.subtle.Watcher;\n} | null>(null);\n\n/**\n *\n * @category Components\n */\nexport function ReactiveContext({ children }: { children: ReactNode }): JSX.Element {\n const watcher = useWatcher();\n /**\n * Unlike other frameworks, React does not have a built-in way to provide\n * a context value other than by rendering an extra component.\n *\n */\n return <WatcherContext value={watcher}>{children}</WatcherContext>;\n}\n"],"mappings":";;;;;AAIA,IAAIM,YAAkC;AACtC,IAAIC,WAA2B,CAAA;AAC/B,IAAIC,YAAY;AAchB,SAASC,aAAaC,OAAqB;CACzCA,MAAMC,QAAQC,QAAQ,GAAGZ,OAAOa,OAAOC,kBAAkBJ,MAAMC,OAAO,CAAC;AACzE;AAEA,SAASI,MAAML,OAAqB;CAClCA,MAAMM,UAAU;CAChB,IAAIN,MAAMO,WAAW;EAInBP,MAAMQ,WAAW;EACjBT,aAAaC,KAAK;EAClB;CACF;CASAA,MAAMQ,WAAW,EAAEP,SAASD,MAAMC,QAAQ;CAC1C,IAAID,MAAMS,aAAaT,MAAMS,YAAY;CAIzCT,MAAMC,QAAQS,MAAM;AACtB;AAEA,SAASC,iBAAiB;CAKxB,MAAMX,QAAsB;EAC1BF,WAAWc,AALFd;EAMTQ,SAAS;EACTC,WAAW;EACXE,aAAa;EACbR,SAAS;EAITO,UAAU;CACZ;CAEAR,MAAMC,UAAU,IAAIX,OAAOa,OAAOU,SAAS,GAAGC,SAAS;EAIrD,IAAI,CAACd,MAAMM,WAAW,CAACN,MAAMO,WAAW;GACtCV,SAASkB,KAAKf,KAAK;GACnBA,MAAMM,UAAU;GAEhB,IAAI,CAACV,WACHA,YAAY,IAAIoB,SAASC,YAAY;IACnCC,qBAAqB;KACnBA,qBAAqB;MACnBA,qBAAqB;OACnBrB,SAASsB,QAAQd,KAAK;OAOtBR,WAAW,CAAA;OACXD,YAAY;OAEZqB,QAAQ;MACV,CAAC;KACH,CAAC;IACH,CAAC;GACH,CAAC;EAEL,OAAO,IAAIjB,MAAMO,WAAW;GAM1BP,MAAMQ,WAAW;GACjBT,aAAaC,KAAK;EACpB;CACF,CAAC;CAGDA,MAAMC,QAAQS,MAAM;CACpBV,MAAMQ,WAAW,EAAEP,SAASD,MAAMC,QAAQ;CAE1C,OAAOD;AACT;AAEA,SAAgBoB,aAAwD;CACtE,MAAMpB,QAAQP,QAAQkB,gBAAgB,CAAA,CAAE;CAExC,OAAOnB,sBACJ6B,kBAA8B;EAI7BrB,MAAMO,YAAY;EAClBP,MAAMS,cAAcY;EAGpBrB,MAAMC,QAAQS,MAAM;EAEpB,aAAa;GAIXV,MAAMO,YAAY;GAClBP,MAAMS,cAAc;EACtB;CACF,SACMT,MAAMQ,QACd;AACF;;;;AAKA,MAAac,iBAKD/B,4BAEF,IAAI;;;;;AAMd,SAAgBgC,gBAAgB,EAAEC,YAAkD;CAClF,MAAMvB,UAAUmB,WAAW;;;;;;CAM3B,OAAOzB,kBAAC2B,gBAAc;EAACG,OAAOxB;EAAUuB;CAAQ,CAAiB;AACnE"}
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.9.0-alpha.21",
4
+ "version": "5.9.0-alpha.23",
5
5
  "license": "MIT",
6
6
  "author": "Chris Thoburn <runspired@users.noreply.github.com>",
7
7
  "repository": {
@@ -18,7 +18,6 @@
18
18
  "warp-drive"
19
19
  ],
20
20
  "files": [
21
- "declarations",
22
21
  "addon-main.cjs",
23
22
  "dist",
24
23
  "README.md",
@@ -31,7 +30,7 @@
31
30
  "unpkg-dev": "./dist/unpkg/dev/index.js",
32
31
  "unpkg-deprecated": "./dist/unpkg/prod-deprecated/index.js",
33
32
  "unpkg": "./dist/unpkg/prod/index.js",
34
- "types": "./declarations/index.d.ts",
33
+ "types": "./dist/index.d.ts",
35
34
  "default": "./dist/index.js"
36
35
  },
37
36
  "./*": {
@@ -39,34 +38,32 @@
39
38
  "unpkg-dev": "./dist/unpkg/dev/*.js",
40
39
  "unpkg-deprecated": "./dist/unpkg/prod-deprecated/*.js",
41
40
  "unpkg": "./dist/unpkg/prod/*.js",
42
- "types": "./declarations/*.d.ts",
41
+ "types": "./dist/*.d.ts",
43
42
  "default": "./dist/*.js"
44
43
  }
45
44
  },
46
45
  "dependencies": {
47
46
  "@embroider/macros": "^1.20.6",
48
- "@warp-drive/core": "5.9.0-alpha.21",
49
- "@warp-drive/tc39-proposal-signals": "5.9.0-alpha.21",
50
- "react": "^19.1.1",
47
+ "@warp-drive/core": "5.9.0-alpha.23",
48
+ "@warp-drive/tc39-proposal-signals": "5.9.0-alpha.23",
49
+ "react": "^19.2.8",
51
50
  "signal-polyfill": "^0.2.2"
52
51
  },
53
52
  "peerDependenciesMeta": {},
54
53
  "devDependencies": {
55
- "@babel/core": "^7.28.3",
56
- "@babel/plugin-transform-typescript": "^7.28.0",
57
- "@babel/preset-env": "^7.28.3",
58
- "@babel/preset-react": "^7.27.1",
59
- "@babel/preset-typescript": "^7.27.1",
60
- "@babel/runtime": "^7.28.3",
61
- "@embroider/addon-dev": "^8.1.0",
62
- "@types/react": "^19.1.11",
63
- "@warp-drive/core": "5.9.0-alpha.21",
64
- "@warp-drive/internal-config": "5.9.0-alpha.21",
54
+ "@babel/core": "^7.29.7",
55
+ "@babel/plugin-transform-typescript": "^7.29.7",
56
+ "@babel/preset-env": "^7.29.7",
57
+ "@babel/preset-react": "^7.29.7",
58
+ "@babel/preset-typescript": "^7.29.7",
59
+ "@babel/runtime": "^7.29.7",
60
+ "@types/react": "^19.2.18",
61
+ "@warp-drive/core": "5.9.0-alpha.23",
62
+ "@warp-drive/internal-config": "5.9.0-alpha.23",
65
63
  "decorator-transforms": "^2.3.0",
66
- "react": "^19.1.1",
67
- "rollup": "^4.48.0",
68
- "typescript": "^5.9.3",
69
- "vite": "^7.3.1"
64
+ "react": "^19.2.8",
65
+ "tsdown": "^0.22.14",
66
+ "typescript": "^5.9.3"
70
67
  },
71
68
  "volta": {
72
69
  "extends": "../../package.json"
@@ -81,9 +78,10 @@
81
78
  "edition": "octane"
82
79
  },
83
80
  "scripts": {
84
- "build:pkg": "vite build",
81
+ "build:pkg": "NODE_ENV=production node node_modules/tsdown/dist/run.mjs",
85
82
  "sync": "echo \"syncing\"",
86
83
  "lint": "eslint . --quiet --cache --cache-strategy=content",
87
- "start": "vite"
84
+ "check:types": "tsc --noEmit",
85
+ "start": "node node_modules/tsdown/dist/run.mjs --watch"
88
86
  }
89
87
  }
@@ -1,21 +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
- /**
11
- * The `Signal.subtle.Watcher` used to observe signal changes for the nearest {@link ReactiveContext}.
12
- */
13
- watcher: Signal.subtle.Watcher;
14
- } | null>;
15
- /**
16
- *
17
- * @category Components
18
- */
19
- export declare function ReactiveContext({ children }: {
20
- children: ReactNode;
21
- }): JSX.Element;
@@ -1,148 +0,0 @@
1
- import { type RequestLoadingState, type RequestState } from "@warp-drive/core/reactive";
2
- import { RequestArgs, type ContentFeatures, type RecoveryFeatures } from "@warp-drive/core/signals/-leaked";
3
- import type { StructuredErrorDocument } from "@warp-drive/core/types/request";
4
- import { JSX, ReactNode } from "react";
5
- interface ChromeComponentProps<RT> {
6
- children: ReactNode;
7
- state: RequestState | null;
8
- features: ContentFeatures<RT>;
9
- }
10
- export interface RequestProps<
11
- RT,
12
- E
13
- > extends RequestArgs<RT, E> {
14
- chrome?: React.FC<ChromeComponentProps<RT>>;
15
- states: RequestStates<RT, E>;
16
- }
17
- interface RequestStates<
18
- RT,
19
- E
20
- > {
21
- /**
22
- * The block to render when the component is idle and waiting to be given a request.
23
- *
24
- */
25
- idle?: React.FC<{}>;
26
- /**
27
- * The block to render when the request is loading.
28
- *
29
- */
30
- loading?: React.FC<{
31
- state: RequestLoadingState;
32
- }>;
33
- /**
34
- * The block to render when the request was cancelled.
35
- *
36
- */
37
- cancelled?: React.FC<{
38
- /**
39
- * The Error the request rejected with.
40
- */
41
- error: StructuredErrorDocument<E>;
42
- /**
43
- * Utilities to assist in recovering from the error.
44
- */
45
- features: RecoveryFeatures;
46
- }>;
47
- /**
48
- * The block to render when the request failed. If this block is not provided,
49
- * the error will be rethrown.
50
- *
51
- * Thus it is required to provide an error block and proper error handling if
52
- * you do not want the error to crash the application.
53
- */
54
- error: React.FC<{
55
- /**
56
- * The Error the request rejected with.
57
- */
58
- error: StructuredErrorDocument<E>;
59
- /**
60
- * Utilities to assist in recovering from the error.
61
- */
62
- features: RecoveryFeatures;
63
- }>;
64
- /**
65
- * The block to render when the request succeeded.
66
- *
67
- */
68
- content: React.FC<{
69
- result: RT;
70
- features: ContentFeatures<RT>;
71
- }>;
72
- }
73
- /**
74
- * Throws the given error. Used internally to rethrow request errors that
75
- * are not otherwise handled by a provided error/cancelled block.
76
- *
77
- * @private
78
- */
79
- export declare function Throw({ error }: {
80
- error: Error;
81
- }): never;
82
- /**
83
- * The `<Request />` component is a powerful tool for managing data fetching and
84
- * state in your React application. It provides a declarative approach to reactive
85
- * control-flow for managing requests and state in your application.
86
- *
87
- * The `<Request />` component is ideal for handling "boundaries", outside which some
88
- * state is still allowed to be unresolved and within which it MUST be resolved.
89
- *
90
- * ## Request States
91
- *
92
- * `<Request />` has five states, only one of which will be active and rendered at a time.
93
- *
94
- * - `idle`: The component is waiting to be given a request to monitor
95
- * - `loading`: The request is in progress
96
- * - `error`: The request failed
97
- * - `content`: The request succeeded
98
- * - `cancelled`: The request was cancelled
99
- *
100
- * Additionally, the `content` state has a `refresh` method that can be used to
101
- * refresh the request in the background, which is available as a sub-state of
102
- * the `content` state.
103
- *
104
- * ### Example Usage
105
- *
106
- * ```tsx
107
- * import { Request } from "@warp-drive/react";
108
- *
109
- * export function UserPreview($props: { id: string | null }) {
110
- * return (
111
- * <Request
112
- * query={findRecord('user', $props.id)}
113
- * states={{
114
- * idle: () => <div>Waiting for User Selection</div>,
115
- * loading: ({ state }) => <div>Loading user data...</div>,
116
- * cancelled: ({ error, features }) => (
117
- * <div>
118
- * <p>Request Cancelled</p>
119
- * <p><button onClick={features.retry}>Start Again?</button></p>
120
- * </div>
121
- * ),
122
- * error: ({ error, features }) => (
123
- * <div>
124
- * <p>Error: {error.message}</p>
125
- * <p><button onClick={features.retry}>Try Again?</button></p>
126
- * </div>
127
- * ),
128
- * content: ({ result, features }) => (
129
- * <div>
130
- * <h2>User Details</h2>
131
- * <p>ID: {result.id}</p>
132
- * <p>Name: {result.name}</p>
133
- * </div>
134
- * ),
135
- * }}
136
- * />
137
- * );
138
- * }
139
- *
140
- * ```
141
- *
142
- * @category Components
143
- */
144
- export declare function Request<
145
- RT,
146
- E
147
- >($props: RequestProps<RT, E>): JSX.Element;
148
- export {};
@@ -1,19 +0,0 @@
1
- import { Store } from "@warp-drive/core";
2
- import { JSX, ReactNode } from "react";
3
- /**
4
- * @category Hooks
5
- */
6
- export declare function useStore(): Store;
7
- type WithExistingStore = {
8
- store: Store;
9
- children: ReactNode;
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,7 +0,0 @@
1
- /**
2
- * @module
3
- * @mergeModuleWith <project>
4
- */
5
- export { ReactiveContext, WatcherContext } from "./-private/reactive-context.js";
6
- export { StoreProvider, useStore } from "./-private/store-provider.js";
7
- export { Request, Throw } from "./-private/request.js";
@@ -1,17 +0,0 @@
1
- import { type HooksOptions, type SignalHooks } from "@warp-drive/core/configure";
2
- /**
3
- * Resolves once all pending requests started via WarpDrive's React signal
4
- * integration have settled. Only tracks requests while `TESTING` is enabled;
5
- * a no-op otherwise.
6
- *
7
- * @public
8
- */
9
- export declare function settled(): Promise<void>;
10
- /**
11
- * Builds the {@link SignalHooks} implementation backed by the
12
- * [Signal Polyfill](https://github.com/proposal-signals/signal-polyfill),
13
- * used to wire WarpDrive's reactivity primitives into React.
14
- *
15
- * @public
16
- */
17
- export declare function buildSignalConfig(options: HooksOptions): SignalHooks;