@warp-drive/ember 5.6.0-alpha.5 → 5.6.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.
@@ -1,221 +0,0 @@
1
- /// <reference path="./install.d.ts" />
2
- /// <reference path="./-private/await.gts.d.ts" />
3
- /// <reference path="./-private/request.gts.d.ts" />
4
- declare module '@warp-drive/ember' {
5
- /**
6
- * <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>
7
- *
8
- * ## Installation
9
- *
10
- * ```cli
11
- * pnpm install @warp-drive/ember
12
- * ```
13
- *
14
- * ## About
15
- *
16
- * This library provides reactive utilities for working with promises
17
- * and requests, building over these primitives to provide functions
18
- * and components that enable you to build robust performant apps with
19
- * elegant control flow.
20
- *
21
- * ## Using .hbs
22
- *
23
- * The components and utils this library exports are intended for use with Glimmer
24
- * Flavored JavaScript (gjs). To use them in handlebars files, your app should re-
25
- * export them. For instance:
26
- *
27
- * *app/components/await.ts*
28
- * ```ts
29
- * export { Await as default } from '@warp-drive/ember';
30
- * ```
31
- *
32
- * ```hbs
33
- * <Await @promise={{this.getTheData}}></Await>
34
- * ```
35
- *
36
- * This allows renaming them to avoid conflicts just by using a different filename
37
- * if desired:
38
- *
39
- * *app/components/warp-drive-await.ts*
40
- * ```ts
41
- * export { Await as default } from '@warp-drive/ember';
42
- * ```
43
- *
44
- * ```hbs
45
- * <WarpDriveAwait @promise={{this.getTheData}}></WarpDriveAwait>
46
- * ```
47
- *
48
- * @module
49
- */
50
- export { Request } from './-private/request';
51
- export { Await, Throw } from './-private/await';
52
- /**
53
- * PromiseState provides a reactive wrapper for a promise which allows you write declarative
54
- * code around a promise's control flow. It is useful in both Template and JavaScript contexts,
55
- * allowing you to quickly derive behaviors and data from pending, error and success states.
56
- *
57
- * ```ts
58
- * interface PromiseState<T = unknown, E = unknown> {
59
- * isPending: boolean;
60
- * isSuccess: boolean;
61
- * isError: boolean;
62
- * result: T | null;
63
- * error: E | null;
64
- * }
65
- * ```
66
- *
67
- * To get the state of a promise, use `getPromiseState`.
68
- *
69
- * @class PromiseState
70
- * @public
71
- */
72
- /**
73
- * Returns a reactive state-machine for the provided promise or awaitable.
74
- *
75
- * Repeat calls to `getPromiseState` with the same promise will return the same state object
76
- * making is safe and easy to use in templates and JavaScript code to produce reactive
77
- * behaviors around promises.
78
- *
79
- * `getPromiseState` can be used in both JavaScript and Template contexts.
80
- *
81
- * ```ts
82
- * import { getPromiseState } from '@warp-drive/ember';
83
- *
84
- * const state = getPromiseState(promise);
85
- * ```
86
- *
87
- * For instance, we could write a getter on a component that updates whenever
88
- * the promise state advances or the promise changes, by combining the function
89
- * with the use of `@cached`
90
- *
91
- * ```ts
92
- * class Component {
93
- * @cached
94
- * get title() {
95
- * const state = getPromiseState(this.args.request);
96
- * if (state.isPending) {
97
- * return 'loading...';
98
- * }
99
- * if (state.isError) { return null; }
100
- * return state.result.title;
101
- * }
102
- * }
103
- * ```
104
- *
105
- * Or in a template as a helper:
106
- *
107
- * ```gjs
108
- * import { getPromiseState } from '@warp-drive/ember';
109
- *
110
- * <template>
111
- * {{#let (getPromiseState @request) as |state|}}
112
- * {{#if state.isPending}} <Spinner />
113
- * {{else if state.isError}} <ErrorForm @error={{state.error}} />
114
- * {{else}}
115
- * <h1>{{state.result.title}}</h1>
116
- * {{/if}}
117
- * {{/let}}
118
- * </template>
119
- * ```
120
- *
121
- * If looking to use in a template, consider also the `<Await />` component.
122
-
123
- * @public
124
- * @param {Promise<T> | Awaitable<T, E>} promise
125
- * @return {PromiseState<T, E>}
126
- */
127
- export { getPromiseState } from '@ember-data/store/-private';
128
- /**
129
- * Lazily consumes the stream of a request, providing a number of
130
- * reactive properties that can be used to build UIs that respond
131
- * to the progress of a request.
132
- *
133
- * @class RequestLoadingState
134
- * @public
135
- */
136
- /**
137
- * RequestState extends the concept of PromiseState to provide a reactive
138
- * wrapper for a request `Future` which allows you write declarative code
139
- * around a Future's control flow.
140
- *
141
- * It is useful in both Template and JavaScript contexts, allowing you
142
- * to quickly derive behaviors and data from pending, error and success
143
- * states.
144
- *
145
- * The key difference between a Promise and a Future is that Futures provide
146
- * access to a stream of their content, the identity of the request (if any)
147
- * as well as the ability to attempt to abort the request.
148
- *
149
- * ```ts
150
- * interface Future<T> extends Promise<T>> {
151
- * getStream(): Promise<ReadableStream>;
152
- * abort(): void;
153
- * lid: StableDocumentIdentifier | null;
154
- * }
155
- * ```
156
- *
157
- * These additional APIs allow us to craft even richer state experiences.
158
- *
159
- * To get the state of a request, use `getRequestState`.
160
- *
161
- * @class RequestState
162
- * @public
163
- */
164
- /**
165
- *
166
- *
167
- * `getRequestState` can be used in both JavaScript and Template contexts.
168
- *
169
- * ```ts
170
- * import { getRequestState } from '@warp-drive/ember';
171
- *
172
- * const state = getRequestState(future);
173
- * ```
174
- *
175
- * For instance, we could write a getter on a component that updates whenever
176
- * the request state advances or the future changes, by combining the function
177
- * with the use of `@cached`
178
- *
179
- * ```ts
180
- * class Component {
181
- * @cached
182
- * get title() {
183
- * const state = getRequestState(this.args.request);
184
- * if (state.isPending) {
185
- * return 'loading...';
186
- * }
187
- * if (state.isError) { return null; }
188
- * return state.result.title;
189
- * }
190
- * }
191
- * ```
192
- *
193
- * Or in a template as a helper:
194
- *
195
- * ```gjs
196
- * import { getRequestState } from '@warp-drive/ember';
197
- *
198
- * <template>
199
- * {{#let (getRequestState @request) as |state|}}
200
- * {{#if state.isPending}}
201
- * <Spinner />
202
- * {{else if state.isError}}
203
- * <ErrorForm @error={{state.error}} />
204
- * {{else}}
205
- * <h1>{{state.result.title}}</h1>
206
- * {{/if}}
207
- * {{/let}}
208
- * </template>
209
- * ```
210
- *
211
- * If looking to use in a template, consider also the `<Request />` component
212
- * which offers a numbe of additional capabilities for requests *beyond* what
213
- * `RequestState` provides.
214
- *
215
- * @public
216
- * @param future
217
- * @return {RequestState}
218
- */
219
- export { getRequestState, type RequestLoadingState } from '@ember-data/store/-private';
220
- }
221
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D;;;;;;;GAOG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,OAAO,EAAE,eAAe,EAAE,KAAK,mBAAmB,EAAE,MAAM,4BAA4B,CAAC"}
@@ -1,17 +0,0 @@
1
- declare module '@warp-drive/ember/install' {
2
- import { tagForProperty } from '@ember/-internals/metal';
3
- type Tag = ReturnType<typeof tagForProperty>;
4
- export function buildSignalConfig(options: {
5
- wellknown: {
6
- Array: symbol | string;
7
- };
8
- }): {
9
- createSignal(obj: object, key: string | symbol): import("@glimmer/validator").Tag | [import("@glimmer/validator").Tag, import("@glimmer/validator").Tag, import("@glimmer/validator").Tag];
10
- consumeSignal(signal: Tag | [Tag, Tag, Tag]): void;
11
- notifySignal(signal: Tag | [Tag, Tag, Tag]): void;
12
- createMemo: <F>(object: object, key: string | symbol, fn: () => F) => (() => F);
13
- willSyncFlushWatchers: () => boolean;
14
- };
15
- export {};
16
- }
17
- //# sourceMappingURL=install.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../src/install.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AASzD,KAAK,GAAG,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAG7C,wBAAgB,iBAAiB,CAAC,OAAO,EAAE;IACzC,SAAS,EAAE;QACT,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;KACxB,CAAC;CACH;sBAIqB,MAAM,OAAO,MAAM,GAAG,MAAM;0BAQxB,GAAG,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;yBAYtB,GAAG,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;iBAW7B,CAAC,UAAU,MAAM,OAAO,MAAM,GAAG,MAAM,MAAM,MAAM,CAAC,KAAG,CAAC,MAAM,CAAC,CAAC;;EAwBhF"}