@warp-drive/ember 5.8.0-alpha.4 → 5.8.0-alpha.6

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.
@@ -14,11 +14,11 @@ interface ThrowSignature<E = Error | string | object> {
14
14
  * That's all it does. So don't use it unless the application should
15
15
  * throw an error if it reaches this point in the template.
16
16
  *
17
- * ```hbs
17
+ * ```gts
18
18
  * <Throw @error={{anError}} />
19
19
  * ```
20
20
  *
21
- * @class <Throw />
21
+ * @category Components
22
22
  * @public
23
23
  */ export declare class Throw<T> extends Component<ThrowSignature<T>> {
24
24
  constructor(owner: Owner, args: ThrowSignature<T>["Args"]);
@@ -37,13 +37,13 @@ interface AwaitSignature<
37
37
  };
38
38
  }
39
39
  /**
40
- * The <Await /> component allow you to utilize reactive control flow
40
+ * The `<Await />` component allow you to utilize reactive control flow
41
41
  * for asynchronous states in your application.
42
42
  *
43
43
  * Await is ideal for handling "boundaries", outside which some state is
44
44
  * still allowed to be unresolved and within which it MUST be resolved.
45
45
  *
46
- * ```gjs
46
+ * ```gts
47
47
  * import { Await } from '@warp-drive/ember';
48
48
  *
49
49
  * <template>
@@ -63,12 +63,12 @@ interface AwaitSignature<
63
63
  * </template>
64
64
  * ```
65
65
  *
66
- * The <Await /> component requires that error states are properly handled.
66
+ * The `<Await />` component requires that error states are properly handled.
67
67
  *
68
68
  * If no error block is provided and the promise rejects, the error will
69
69
  * be thrown.
70
70
  *
71
- * @class <Await />
71
+ * @category Components
72
72
  * @public
73
73
  */ export declare class Await<
74
74
  T,
@@ -118,7 +118,7 @@ interface RequestSignature<
118
118
  *
119
119
  * The loading state exposes the download `ReadableStream` instance for consumption
120
120
  *
121
- * ```gjs
121
+ * ```gts
122
122
  * import { Request } from '@warp-drive/ember';
123
123
  *
124
124
  * <template>
@@ -153,7 +153,7 @@ interface RequestSignature<
153
153
  *
154
154
  * Reload and refresh are available as methods on the `content` state.
155
155
  *
156
- * ```gjs
156
+ * ```gts
157
157
  * import { Request } from '@warp-drive/ember';
158
158
  *
159
159
  * <template>
@@ -177,7 +177,7 @@ interface RequestSignature<
177
177
  * We can nest our usage of `<Request />` to handle more advanced
178
178
  * reloading scenarios.
179
179
  *
180
- * ```gjs
180
+ * ```gts
181
181
  * import { Request } from '@warp-drive/ember';
182
182
  *
183
183
  * <template>
@@ -239,7 +239,7 @@ interface RequestSignature<
239
239
  * timer or on a websocket subscription.
240
240
  *
241
241
  *
242
- * ```gjs
242
+ * ```gts
243
243
  * import { Request } from '@warp-drive/ember';
244
244
  *
245
245
  * <template>
@@ -263,7 +263,7 @@ interface RequestSignature<
263
263
  * from multiple `<Request />` components, even if the request is not referentially the
264
264
  * same, only one actual request will be made.
265
265
  *
266
- *
266
+ * @category Components
267
267
  * @public
268
268
  */ export declare class Request<
269
269
  RT,
@@ -1,215 +1,7 @@
1
1
  /**
2
- * <h3 align="center">⚛️ Data utilities for using <em style="color: lightgreen">Warp</em><strong style="color: magenta">Drive</strong> with 🐹 <em style="color: orange">Ember</em><em style="color: lightblue">.js</em></h3>
3
- *
4
- * ## Installation
5
- *
6
- * ```sh
7
- * pnpm install @warp-drive/ember
8
- * ```
9
- *
10
- * ## About
11
- *
12
- * This library provides reactive utilities for working with promises
13
- * and requests, building over these primitives to provide functions
14
- * and components that enable you to build robust performant apps with
15
- * elegant control flow.
16
- *
17
- * ## Using .hbs
18
- *
19
- * The components and utils this library exports are intended for use with Glimmer
20
- * Flavored JavaScript (gjs). To use them in handlebars files, your app should re-
21
- * export them. For instance:
22
- *
23
- * *app/components/await.ts*
24
- * ```ts
25
- * export { Await as default } from '@warp-drive/ember';
26
- * ```
27
- *
28
- * ```hbs
29
- * <Await @promise={{this.getTheData}}></Await>
30
- * ```
31
- *
32
- * This allows renaming them to avoid conflicts just by using a different filename
33
- * if desired:
34
- *
35
- * *app/components/warp-drive-await.ts*
36
- * ```ts
37
- * export { Await as default } from '@warp-drive/ember';
38
- * ```
39
- *
40
- * ```hbs
41
- * <WarpDriveAwait @promise={{this.getTheData}}></WarpDriveAwait>
42
- * ```
43
- *
44
2
  * @module
3
+ * @mergeModuleWith <project>
45
4
  */
46
5
  export { Request, type ContentFeatures, type RecoveryFeatures } from "./-private/request.js";
47
6
  export { Await, Throw } from "./-private/await.js";
48
- /**
49
- * PromiseState provides a reactive wrapper for a promise which allows you write declarative
50
- * code around a promise's control flow. It is useful in both Template and JavaScript contexts,
51
- * allowing you to quickly derive behaviors and data from pending, error and success states.
52
- *
53
- * ```ts
54
- * interface PromiseState<T = unknown, E = unknown> {
55
- * isPending: boolean;
56
- * isSuccess: boolean;
57
- * isError: boolean;
58
- * result: T | null;
59
- * error: E | null;
60
- * }
61
- * ```
62
- *
63
- * To get the state of a promise, use `getPromiseState`.
64
- *
65
- * @class PromiseState
66
- * @public
67
- */
68
- /**
69
- * Returns a reactive state-machine for the provided promise or awaitable.
70
- *
71
- * Repeat calls to `getPromiseState` with the same promise will return the same state object
72
- * making is safe and easy to use in templates and JavaScript code to produce reactive
73
- * behaviors around promises.
74
- *
75
- * `getPromiseState` can be used in both JavaScript and Template contexts.
76
- *
77
- * ```ts
78
- * import { getPromiseState } from '@warp-drive/ember';
79
- *
80
- * const state = getPromiseState(promise);
81
- * ```
82
- *
83
- * For instance, we could write a getter on a component that updates whenever
84
- * the promise state advances or the promise changes, by combining the function
85
- * with the use of `@cached`
86
- *
87
- * ```ts
88
- * class Component {
89
- * @cached
90
- * get title() {
91
- * const state = getPromiseState(this.args.request);
92
- * if (state.isPending) {
93
- * return 'loading...';
94
- * }
95
- * if (state.isError) { return null; }
96
- * return state.result.title;
97
- * }
98
- * }
99
- * ```
100
- *
101
- * Or in a template as a helper:
102
- *
103
- * ```gjs
104
- * import { getPromiseState } from '@warp-drive/ember';
105
- *
106
- * <template>
107
- * {{#let (getPromiseState @request) as |state|}}
108
- * {{#if state.isPending}} <Spinner />
109
- * {{else if state.isError}} <ErrorForm @error={{state.error}} />
110
- * {{else}}
111
- * <h1>{{state.result.title}}</h1>
112
- * {{/if}}
113
- * {{/let}}
114
- * </template>
115
- * ```
116
- *
117
- * If looking to use in a template, consider also the `<Await />` component.
118
-
119
- * @public
120
- * @param {Promise<T> | Awaitable<T, E>} promise
121
- * @return {PromiseState<T, E>}
122
- */
123
- export { getPromiseState } from "@warp-drive/core/store/-private";
124
- /**
125
- * Lazily consumes the stream of a request, providing a number of
126
- * reactive properties that can be used to build UIs that respond
127
- * to the progress of a request.
128
- *
129
- * @class RequestLoadingState
130
- * @public
131
- */
132
- /**
133
- * RequestState extends the concept of PromiseState to provide a reactive
134
- * wrapper for a request `Future` which allows you write declarative code
135
- * around a Future's control flow.
136
- *
137
- * It is useful in both Template and JavaScript contexts, allowing you
138
- * to quickly derive behaviors and data from pending, error and success
139
- * states.
140
- *
141
- * The key difference between a Promise and a Future is that Futures provide
142
- * access to a stream of their content, the identity of the request (if any)
143
- * as well as the ability to attempt to abort the request.
144
- *
145
- * ```ts
146
- * interface Future<T> extends Promise<T>> {
147
- * getStream(): Promise<ReadableStream>;
148
- * abort(): void;
149
- * lid: RequestKey | null;
150
- * }
151
- * ```
152
- *
153
- * These additional APIs allow us to craft even richer state experiences.
154
- *
155
- * To get the state of a request, use `getRequestState`.
156
- *
157
- * @class RequestState
158
- * @public
159
- */
160
- /**
161
- *
162
- *
163
- * `getRequestState` can be used in both JavaScript and Template contexts.
164
- *
165
- * ```ts
166
- * import { getRequestState } from '@warp-drive/ember';
167
- *
168
- * const state = getRequestState(future);
169
- * ```
170
- *
171
- * For instance, we could write a getter on a component that updates whenever
172
- * the request state advances or the future changes, by combining the function
173
- * with the use of `@cached`
174
- *
175
- * ```ts
176
- * class Component {
177
- * @cached
178
- * get title() {
179
- * const state = getRequestState(this.args.request);
180
- * if (state.isPending) {
181
- * return 'loading...';
182
- * }
183
- * if (state.isError) { return null; }
184
- * return state.result.title;
185
- * }
186
- * }
187
- * ```
188
- *
189
- * Or in a template as a helper:
190
- *
191
- * ```gjs
192
- * import { getRequestState } from '@warp-drive/ember';
193
- *
194
- * <template>
195
- * {{#let (getRequestState @request) as |state|}}
196
- * {{#if state.isPending}}
197
- * <Spinner />
198
- * {{else if state.isError}}
199
- * <ErrorForm @error={{state.error}} />
200
- * {{else}}
201
- * <h1>{{state.result.title}}</h1>
202
- * {{/if}}
203
- * {{/let}}
204
- * </template>
205
- * ```
206
- *
207
- * If looking to use in a template, consider also the `<Request />` component
208
- * which offers a numbe of additional capabilities for requests *beyond* what
209
- * `RequestState` provides.
210
- *
211
- * @public
212
- * @param future
213
- * @return {RequestState}
214
- */
215
- export { getRequestState, createRequestSubscription, type RequestLoadingState } from "@warp-drive/core/store/-private";
7
+ export { getPromiseState, getRequestState, createRequestSubscription, type PromiseState, type RequestLoadingState, type RequestState } from "@warp-drive/core/store/-private";
package/dist/index.js CHANGED
@@ -14,11 +14,11 @@ const and = (x, y) => Boolean(x && y);
14
14
  * That's all it does. So don't use it unless the application should
15
15
  * throw an error if it reaches this point in the template.
16
16
  *
17
- * ```hbs
17
+ * ```gts
18
18
  * <Throw @error={{anError}} />
19
19
  * ```
20
20
  *
21
- * @class <Throw />
21
+ * @category Components
22
22
  * @public
23
23
  */
24
24
  class Throw extends Component {
@@ -41,13 +41,13 @@ class Throw extends Component {
41
41
  }
42
42
  }
43
43
  /**
44
- * The <Await /> component allow you to utilize reactive control flow
44
+ * The `<Await />` component allow you to utilize reactive control flow
45
45
  * for asynchronous states in your application.
46
46
  *
47
47
  * Await is ideal for handling "boundaries", outside which some state is
48
48
  * still allowed to be unresolved and within which it MUST be resolved.
49
49
  *
50
- * ```gjs
50
+ * ```gts
51
51
  * import { Await } from '@warp-drive/ember';
52
52
  *
53
53
  * <template>
@@ -67,12 +67,12 @@ class Throw extends Component {
67
67
  * </template>
68
68
  * ```
69
69
  *
70
- * The <Await /> component requires that error states are properly handled.
70
+ * The `<Await />` component requires that error states are properly handled.
71
71
  *
72
72
  * If no error block is provided and the promise rejects, the error will
73
73
  * be thrown.
74
74
  *
75
- * @class <Await />
75
+ * @category Components
76
76
  * @public
77
77
  */
78
78
  class Await extends Component {
@@ -249,7 +249,7 @@ const DefaultChrome = setComponentTemplate(precompileTemplate("{{yield}}", {
249
249
  *
250
250
  * The loading state exposes the download `ReadableStream` instance for consumption
251
251
  *
252
- * ```gjs
252
+ * ```gts
253
253
  * import { Request } from '@warp-drive/ember';
254
254
  *
255
255
  * <template>
@@ -284,7 +284,7 @@ const DefaultChrome = setComponentTemplate(precompileTemplate("{{yield}}", {
284
284
  *
285
285
  * Reload and refresh are available as methods on the `content` state.
286
286
  *
287
- * ```gjs
287
+ * ```gts
288
288
  * import { Request } from '@warp-drive/ember';
289
289
  *
290
290
  * <template>
@@ -308,7 +308,7 @@ const DefaultChrome = setComponentTemplate(precompileTemplate("{{yield}}", {
308
308
  * We can nest our usage of `<Request />` to handle more advanced
309
309
  * reloading scenarios.
310
310
  *
311
- * ```gjs
311
+ * ```gts
312
312
  * import { Request } from '@warp-drive/ember';
313
313
  *
314
314
  * <template>
@@ -370,7 +370,7 @@ const DefaultChrome = setComponentTemplate(precompileTemplate("{{yield}}", {
370
370
  * timer or on a websocket subscription.
371
371
  *
372
372
  *
373
- * ```gjs
373
+ * ```gts
374
374
  * import { Request } from '@warp-drive/ember';
375
375
  *
376
376
  * <template>
@@ -394,7 +394,7 @@ const DefaultChrome = setComponentTemplate(precompileTemplate("{{yield}}", {
394
394
  * from multiple `<Request />` components, even if the request is not referentially the
395
395
  * same, only one actual request will be made.
396
396
  *
397
- *
397
+ * @category Components
398
398
  * @public
399
399
  */
400
400
  class Request extends Component {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@warp-drive/ember",
3
3
  "description": "Data bindings and utilities for Ember applications using WarpDrive",
4
- "version": "5.8.0-alpha.4",
4
+ "version": "5.8.0-alpha.6",
5
5
  "license": "MIT",
6
6
  "author": "Chris Thoburn <runspired@users.noreply.github.com>",
7
7
  "repository": {
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@embroider/macros": "^1.18.1",
41
- "@warp-drive/core": "5.8.0-alpha.4"
41
+ "@warp-drive/core": "5.8.0-alpha.6"
42
42
  },
43
43
  "peerDependenciesMeta": {
44
44
  "ember-provide-consume-context": {
@@ -60,8 +60,8 @@
60
60
  "@embroider/addon-dev": "^8.1.0",
61
61
  "@ember/test-helpers": "5.2.0",
62
62
  "@ember/test-waiters": "^4.1.1",
63
- "@warp-drive/internal-config": "5.8.0-alpha.4",
64
- "@warp-drive/core": "5.8.0-alpha.4",
63
+ "@warp-drive/internal-config": "5.8.0-alpha.6",
64
+ "@warp-drive/core": "5.8.0-alpha.6",
65
65
  "babel-plugin-ember-template-compilation": "^2.4.1",
66
66
  "ember-template-imports": "^4.3.0",
67
67
  "ember-source": "~6.6.0",