@warp-drive/react 5.9.0-beta.0 → 5.9.0-beta.2

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 (46) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/dist/index.d.ts +180 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +216 -251
  5. package/dist/index.js.map +1 -0
  6. package/dist/install.d.ts +21 -0
  7. package/dist/install.d.ts.map +1 -0
  8. package/dist/install.js +90 -94
  9. package/dist/install.js.map +1 -0
  10. package/dist/reactive-context-DhUW_l--.js +122 -0
  11. package/dist/reactive-context-DhUW_l--.js.map +1 -0
  12. package/dist/unpkg/dev/index.js +260 -299
  13. package/dist/unpkg/dev/index.js.map +1 -0
  14. package/dist/unpkg/dev/install.js +82 -92
  15. package/dist/unpkg/dev/install.js.map +1 -0
  16. package/dist/unpkg/dev/reactive-context-Ax2U-96G.js +218 -0
  17. package/dist/unpkg/dev/reactive-context-Ax2U-96G.js.map +1 -0
  18. package/dist/unpkg/dev-deprecated/index.js +260 -299
  19. package/dist/unpkg/dev-deprecated/index.js.map +1 -0
  20. package/dist/unpkg/dev-deprecated/install.js +82 -92
  21. package/dist/unpkg/dev-deprecated/install.js.map +1 -0
  22. package/dist/unpkg/dev-deprecated/reactive-context-B-pn7tS7.js +218 -0
  23. package/dist/unpkg/dev-deprecated/reactive-context-B-pn7tS7.js.map +1 -0
  24. package/dist/unpkg/prod/index.js +199 -226
  25. package/dist/unpkg/prod/index.js.map +1 -0
  26. package/dist/unpkg/prod/install.js +56 -48
  27. package/dist/unpkg/prod/install.js.map +1 -0
  28. package/dist/unpkg/prod/reactive-context-eAEvPuqb.js +92 -0
  29. package/dist/unpkg/prod/reactive-context-eAEvPuqb.js.map +1 -0
  30. package/dist/unpkg/prod-deprecated/index.js +199 -226
  31. package/dist/unpkg/prod-deprecated/index.js.map +1 -0
  32. package/dist/unpkg/prod-deprecated/install.js +56 -48
  33. package/dist/unpkg/prod-deprecated/install.js.map +1 -0
  34. package/dist/unpkg/prod-deprecated/reactive-context-eAEvPuqb.js +92 -0
  35. package/dist/unpkg/prod-deprecated/reactive-context-eAEvPuqb.js.map +1 -0
  36. package/package.json +25 -33
  37. package/declarations/-private/reactive-context.d.ts +0 -18
  38. package/declarations/-private/request.d.ts +0 -142
  39. package/declarations/-private/store-provider.d.ts +0 -19
  40. package/declarations/index.d.ts +0 -7
  41. package/declarations/install.d.ts +0 -3
  42. package/dist/reactive-context-ClTRYXie.js +0 -154
  43. package/dist/unpkg/dev/reactive-context-B815u0_c.js +0 -290
  44. package/dist/unpkg/dev-deprecated/reactive-context-DMgQ7YV_.js +0 -290
  45. package/dist/unpkg/prod/reactive-context-DKimDkR3.js +0 -110
  46. package/dist/unpkg/prod-deprecated/reactive-context-DKimDkR3.js +0 -110
package/CHANGELOG.md ADDED
@@ -0,0 +1,38 @@
1
+ # @warp-drive/ember Changelog
2
+
3
+ For the full project changelog see [https://github.com/warp-drive-data/warp-drive/blob/main/CHANGELOG.md](https://github.com/warp-drive-data/warp-drive/blob/main/CHANGELOG.md)
4
+
5
+ ## v0.0.0-alpha.47 (2024-06-15)
6
+
7
+ #### :memo: Documentation
8
+
9
+ * [#9390](https://github.com/warp-drive-data/warp-drive/pull/9390) docs: fix readme links in @warp-drive/ember ([@runspired](https://github.com/runspired))
10
+ * [#9328](https://github.com/warp-drive-data/warp-drive/pull/9328) chore: update READMEs with status and dist tag info ([@runspired](https://github.com/runspired))
11
+
12
+ #### :rocket: Enhancement
13
+
14
+ * [#9471](https://github.com/warp-drive-data/warp-drive/pull/9471) feat: npx warp-drive ([@runspired](https://github.com/runspired))
15
+ * [#9468](https://github.com/warp-drive-data/warp-drive/pull/9468) feat: string utils 🌌 ([@runspired](https://github.com/runspired))
16
+ * [#9366](https://github.com/warp-drive-data/warp-drive/pull/9366) feat: typed Model ([@runspired](https://github.com/runspired))
17
+ * [#9363](https://github.com/warp-drive-data/warp-drive/pull/9363) feat: <Request /> autoRefresh ([@runspired](https://github.com/runspired))
18
+ * [#9359](https://github.com/warp-drive-data/warp-drive/pull/9359) feat: type checked builders and inferred request types from builders ([@runspired](https://github.com/runspired))
19
+ * [#9317](https://github.com/warp-drive-data/warp-drive/pull/9317) feat: ensure data utils work well with legacy relationship proxies ([@runspired](https://github.com/runspired))
20
+ * [#9260](https://github.com/warp-drive-data/warp-drive/pull/9260) feat: ember specific data utils ([@runspired](https://github.com/runspired))
21
+
22
+ #### :bug: Bug Fix
23
+
24
+ * [#9456](https://github.com/warp-drive-data/warp-drive/pull/9456) fix: visibilitychange => hidden should update unavailableStart ([@runspired](https://github.com/runspired))
25
+ * [#9454](https://github.com/warp-drive-data/warp-drive/pull/9454) Allow RequestState.abort to be used with on modifier ([@gitKrystan](https://github.com/gitKrystan))
26
+ * [#9391](https://github.com/warp-drive-data/warp-drive/pull/9391) fix: dont fall-through after shouldAttempt on refresh ([@runspired](https://github.com/runspired))
27
+ * [#9369](https://github.com/warp-drive-data/warp-drive/pull/9369) fix: @warp-drive-ember, dont leak empty slot ([@runspired](https://github.com/runspired))
28
+
29
+ #### :house: Internal
30
+
31
+ * [#9292](https://github.com/warp-drive-data/warp-drive/pull/9292) feat: add new build-config package ([@runspired](https://github.com/runspired))
32
+ * [#9370](https://github.com/warp-drive-data/warp-drive/pull/9370) chore: rename macros ([@runspired](https://github.com/runspired))
33
+
34
+ #### Committers: (2)
35
+
36
+ Chris Thoburn ([@runspired](https://github.com/runspired))
37
+ Krystan HuffMenne ([@gitKrystan](https://github.com/gitKrystan))
38
+
@@ -0,0 +1,180 @@
1
+ import { Context, JSX, ReactNode } from "react";
2
+ import { Signal } from "signal-polyfill";
3
+ import { RequestLoadingState, RequestState } from "@warp-drive/core/reactive";
4
+ import { ContentFeatures, RecoveryFeatures, RequestArgs } from "@warp-drive/core/signals/-leaked";
5
+ import { Store } from "@warp-drive/core";
6
+ import { StructuredErrorDocument } from "@warp-drive/core/types/request";
7
+ //#region src/-private/reactive-context.d.ts
8
+ /**
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<object>;
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/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":";;;;;;;;;;cAyJa,gBAAgB;;;;EAI3B,SAAS,OAAO,OAAO;;;;;;iBAST,kBAAkB;EAAc,UAAU;IAAc,IAAI;;;;;;iBCxJ5D,YAAY;KASvB;EAAsB,OAAO;EAAO,UAAU;;KAC9C;EAAiB,cAAc;EAAO,UAAU;;;;;iBAKrC,cAAc,QAAQ,oBAAoB,eAAe,IAAI;;;UCSnE,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"}