@warp-drive-mirror/react 5.9.0-beta.0 → 5.9.0-beta.1

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 (43) hide show
  1. package/declarations/index.d.ts +179 -6
  2. package/declarations/index.d.ts.map +1 -0
  3. package/declarations/install.d.ts +21 -3
  4. package/declarations/install.d.ts.map +1 -0
  5. package/dist/index.js +216 -251
  6. package/dist/index.js.map +1 -0
  7. package/dist/install.js +90 -94
  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 +260 -299
  12. package/dist/unpkg/dev/index.js.map +1 -0
  13. package/dist/unpkg/dev/install.js +82 -92
  14. package/dist/unpkg/dev/install.js.map +1 -0
  15. package/dist/unpkg/dev/reactive-context-C9-Fc8qx.js +218 -0
  16. package/dist/unpkg/dev/reactive-context-C9-Fc8qx.js.map +1 -0
  17. package/dist/unpkg/dev-deprecated/index.js +260 -299
  18. package/dist/unpkg/dev-deprecated/index.js.map +1 -0
  19. package/dist/unpkg/dev-deprecated/install.js +82 -92
  20. package/dist/unpkg/dev-deprecated/install.js.map +1 -0
  21. package/dist/unpkg/dev-deprecated/reactive-context-DhpCE2Tv.js +218 -0
  22. package/dist/unpkg/dev-deprecated/reactive-context-DhpCE2Tv.js.map +1 -0
  23. package/dist/unpkg/prod/index.js +199 -226
  24. package/dist/unpkg/prod/index.js.map +1 -0
  25. package/dist/unpkg/prod/install.js +56 -48
  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 +199 -226
  30. package/dist/unpkg/prod-deprecated/index.js.map +1 -0
  31. package/dist/unpkg/prod-deprecated/install.js +56 -48
  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 +14 -15
  36. package/declarations/-private/reactive-context.d.ts +0 -18
  37. package/declarations/-private/request.d.ts +0 -142
  38. package/declarations/-private/store-provider.d.ts +0 -19
  39. package/dist/reactive-context-ClTRYXie.js +0 -154
  40. package/dist/unpkg/dev/reactive-context-B815u0_c.js +0 -290
  41. package/dist/unpkg/dev-deprecated/reactive-context-DMgQ7YV_.js +0 -290
  42. package/dist/unpkg/prod/reactive-context-DKimDkR3.js +0 -110
  43. package/dist/unpkg/prod-deprecated/reactive-context-DKimDkR3.js +0 -110
@@ -1,7 +1,180 @@
1
+ import { Signal } from "signal-polyfill";
2
+ import { Context, JSX, ReactNode } from "react";
3
+ import { RequestLoadingState, RequestState } from "@warp-drive-mirror/core/reactive";
4
+ import { ContentFeatures, RecoveryFeatures, RequestArgs } from "@warp-drive-mirror/core/signals/-leaked";
5
+ import { Store } from "@warp-drive-mirror/core";
6
+ import { StructuredErrorDocument } from "@warp-drive-mirror/core/types/request";
7
+ //#region src/-private/reactive-context.d.ts
1
8
  /**
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";
9
+ * @category Contexts
10
+ */
11
+ declare const WatcherContext: Context<{
12
+ /**
13
+ * The `Signal.subtle.Watcher` used to observe signal changes for the nearest {@link ReactiveContext}.
14
+ */
15
+ watcher: Signal.subtle.Watcher;
16
+ } | null>;
17
+ /**
18
+ *
19
+ * @category Components
20
+ */
21
+ declare function ReactiveContext({ children }: {
22
+ children: ReactNode;
23
+ }): JSX.Element;
24
+ //#endregion
25
+ //#region src/-private/store-provider.d.ts
26
+ /**
27
+ * @category Hooks
28
+ */
29
+ declare function useStore(): Store;
30
+ type WithExistingStore = {
31
+ store: Store;
32
+ children: ReactNode;
33
+ };
34
+ type WithNewStore = {
35
+ Store: typeof Store;
36
+ children: ReactNode;
37
+ };
38
+ /**
39
+ * @category Components
40
+ */
41
+ declare function StoreProvider($props: WithExistingStore | WithNewStore): JSX.Element;
42
+ //#endregion
43
+ //#region src/-private/request.d.ts
44
+ interface ChromeComponentProps<RT> {
45
+ children: ReactNode;
46
+ state: RequestState | null;
47
+ features: ContentFeatures<RT>;
48
+ }
49
+ interface RequestProps<RT, E> extends RequestArgs<RT, E> {
50
+ chrome?: React.FC<ChromeComponentProps<RT>>;
51
+ states: RequestStates<RT, E>;
52
+ }
53
+ interface RequestStates<RT, E> {
54
+ /**
55
+ * The block to render when the component is idle and waiting to be given a request.
56
+ *
57
+ */
58
+ idle?: React.FC<{}>;
59
+ /**
60
+ * The block to render when the request is loading.
61
+ *
62
+ */
63
+ loading?: React.FC<{
64
+ state: RequestLoadingState;
65
+ }>;
66
+ /**
67
+ * The block to render when the request was cancelled.
68
+ *
69
+ */
70
+ cancelled?: React.FC<{
71
+ /**
72
+ * The Error the request rejected with.
73
+ */
74
+ error: StructuredErrorDocument<E>;
75
+ /**
76
+ * Utilities to assist in recovering from the error.
77
+ */
78
+ features: RecoveryFeatures;
79
+ }>;
80
+ /**
81
+ * The block to render when the request failed. If this block is not provided,
82
+ * the error will be rethrown.
83
+ *
84
+ * Thus it is required to provide an error block and proper error handling if
85
+ * you do not want the error to crash the application.
86
+ */
87
+ error: React.FC<{
88
+ /**
89
+ * The Error the request rejected with.
90
+ */
91
+ error: StructuredErrorDocument<E>;
92
+ /**
93
+ * Utilities to assist in recovering from the error.
94
+ */
95
+ features: RecoveryFeatures;
96
+ }>;
97
+ /**
98
+ * The block to render when the request succeeded.
99
+ *
100
+ */
101
+ content: React.FC<{
102
+ result: RT;
103
+ features: ContentFeatures<RT>;
104
+ }>;
105
+ }
106
+ /**
107
+ * Throws the given error. Used internally to rethrow request errors that
108
+ * are not otherwise handled by a provided error/cancelled block.
109
+ *
110
+ * @private
111
+ */
112
+ declare function Throw({ error }: {
113
+ error: Error;
114
+ }): never;
115
+ /**
116
+ * The `<Request />` component is a powerful tool for managing data fetching and
117
+ * state in your React application. It provides a declarative approach to reactive
118
+ * control-flow for managing requests and state in your application.
119
+ *
120
+ * The `<Request />` component is ideal for handling "boundaries", outside which some
121
+ * state is still allowed to be unresolved and within which it MUST be resolved.
122
+ *
123
+ * ## Request States
124
+ *
125
+ * `<Request />` has five states, only one of which will be active and rendered at a time.
126
+ *
127
+ * - `idle`: The component is waiting to be given a request to monitor
128
+ * - `loading`: The request is in progress
129
+ * - `error`: The request failed
130
+ * - `content`: The request succeeded
131
+ * - `cancelled`: The request was cancelled
132
+ *
133
+ * Additionally, the `content` state has a `refresh` method that can be used to
134
+ * refresh the request in the background, which is available as a sub-state of
135
+ * the `content` state.
136
+ *
137
+ * ### Example Usage
138
+ *
139
+ * ```tsx
140
+ * import { Request } from "@warp-drive-mirror/react";
141
+ *
142
+ * export function UserPreview($props: { id: string | null }) {
143
+ * return (
144
+ * <Request
145
+ * query={findRecord('user', $props.id)}
146
+ * states={{
147
+ * idle: () => <div>Waiting for User Selection</div>,
148
+ * loading: ({ state }) => <div>Loading user data...</div>,
149
+ * cancelled: ({ error, features }) => (
150
+ * <div>
151
+ * <p>Request Cancelled</p>
152
+ * <p><button onClick={features.retry}>Start Again?</button></p>
153
+ * </div>
154
+ * ),
155
+ * error: ({ error, features }) => (
156
+ * <div>
157
+ * <p>Error: {error.message}</p>
158
+ * <p><button onClick={features.retry}>Try Again?</button></p>
159
+ * </div>
160
+ * ),
161
+ * content: ({ result, features }) => (
162
+ * <div>
163
+ * <h2>User Details</h2>
164
+ * <p>ID: {result.id}</p>
165
+ * <p>Name: {result.name}</p>
166
+ * </div>
167
+ * ),
168
+ * }}
169
+ * />
170
+ * );
171
+ * }
172
+ *
173
+ * ```
174
+ *
175
+ * @category Components
176
+ */
177
+ declare function Request<RT, E>($props: RequestProps<RT, E>): JSX.Element;
178
+ //#endregion
179
+ export { ReactiveContext, Request, StoreProvider, Throw, WatcherContext, useStore };
180
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/-private/reactive-context.tsx","../src/-private/store-provider.tsx","../src/-private/request.tsx"],"mappings":";;;;;;;;;;cA+Ia,gBAAgB;;;;EAI3B,SAAS,OAAO,OAAO;;;;;;iBAST,kBAAkB;EAAc,UAAU;IAAc,IAAI;;;;;;iBChJ5D,YAAY;KASvB;EAAsB,OAAO;EAAO,UAAU;;KAC9C;EAAiB,cAAc;EAAO,UAAU;;;;;iBAKrC,cAAc,QAAQ,oBAAoB,eAAe,IAAI;;;UCQnE,qBAAqB;EAC7B,UAAU;EACV,OAAO;EACP,UAAU,gBAAgB;;UAOX,aAAa,IAAI,WAAW,YAAY,IAAI;EAC3D,SAAS,MAAM,GAAG,qBAAqB;EAEvC,QAAQ,cAAc,IAAI;;UAGlB,cAAc,IAAI;;;;;EAK1B,OAAO,MAAM;;;;;EAMb,UAAU,MAAM;IAAK,OAAO;;;;;;EAM5B,YAAY,MAAM;;;;IAIhB,OAAO,wBAAwB;;;;IAI/B,UAAU;;;;;;;;;EAUZ,OAAO,MAAM;;;;IAIX,OAAO,wBAAwB;;;;IAI/B,UAAU;;;;;;EAOZ,SAAS,MAAM;IAAK,QAAQ;IAAI,UAAU,gBAAgB;;;;;;;;;iBAS5C,QAAQ;EAAW,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkE1B,QAAQ,IAAI,GAAG,QAAQ,aAAa,IAAI,KAAK,IAAI"}
@@ -1,3 +1,21 @@
1
- import { type HooksOptions, type SignalHooks } from "@warp-drive-mirror/core/configure";
2
- export declare function settled(): Promise<void>;
3
- export declare function buildSignalConfig(options: HooksOptions): SignalHooks;
1
+ import { HooksOptions, SignalHooks } from "@warp-drive-mirror/core/configure";
2
+ //#region src/install.d.ts
3
+ /**
4
+ * Resolves once all pending requests started via WarpDrive's React signal
5
+ * integration have settled. Only tracks requests while `TESTING` is enabled;
6
+ * a no-op otherwise.
7
+ *
8
+ * @public
9
+ */
10
+ declare function settled(): Promise<void>;
11
+ /**
12
+ * Builds the {@link SignalHooks} implementation backed by the
13
+ * [Signal Polyfill](https://github.com/proposal-signals/signal-polyfill),
14
+ * used to wire WarpDrive's reactivity primitives into React.
15
+ *
16
+ * @public
17
+ */
18
+ declare function buildSignalConfig(options: HooksOptions): SignalHooks;
19
+ //#endregion
20
+ export { buildSignalConfig, settled };
21
+ //# sourceMappingURL=install.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install.d.ts","names":[],"sources":["../src/install.ts"],"mappings":";;;;;;;;;iBAiDsB,WAAW;;;;;;;;iBAsBjB,kBAAkB,SAAS,eAAe"}