@warp-drive-mirror/ember 5.6.0-beta.0 → 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.
- package/README.md +1 -1
- package/addon-main.cjs +1 -1
- package/declarations/-private/await.d.ts +81 -0
- package/declarations/-private/request.d.ts +346 -0
- package/declarations/index.d.ts +215 -0
- package/declarations/install.d.ts +6 -0
- package/dist/index.js +25 -556
- package/dist/install.js +15 -5
- package/package.json +13 -35
- package/dist/index.js.map +0 -1
- package/dist/install.js.map +0 -1
- package/unstable-preview-types/-private/await.d.ts +0 -82
- package/unstable-preview-types/-private/await.d.ts.map +0 -1
- package/unstable-preview-types/-private/request.d.ts +0 -502
- package/unstable-preview-types/-private/request.d.ts.map +0 -1
- package/unstable-preview-types/index.d.ts +0 -228
- package/unstable-preview-types/index.d.ts.map +0 -1
- package/unstable-preview-types/install.d.ts +0 -17
- package/unstable-preview-types/install.d.ts.map +0 -1
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
/// <reference path="./install.d.ts" />
|
|
2
|
-
/// <reference path="./-private/request.d.ts" />
|
|
3
|
-
/// <reference path="./-private/await.d.ts" />
|
|
4
|
-
declare module '@warp-drive-mirror/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-mirror/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-mirror/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-mirror/ember';
|
|
42
|
-
* ```
|
|
43
|
-
*
|
|
44
|
-
* ```hbs
|
|
45
|
-
* <WarpDriveAwait @promise={{this.getTheData}}></WarpDriveAwait>
|
|
46
|
-
* ```
|
|
47
|
-
*
|
|
48
|
-
* @module @warp-drive-mirror/ember
|
|
49
|
-
* @main @warp-drive-mirror/ember
|
|
50
|
-
*/
|
|
51
|
-
export { Request } from './-private/request';
|
|
52
|
-
export { Await, Throw } from './-private/await';
|
|
53
|
-
/**
|
|
54
|
-
* PromiseState provides a reactive wrapper for a promise which allows you write declarative
|
|
55
|
-
* code around a promise's control flow. It is useful in both Template and JavaScript contexts,
|
|
56
|
-
* allowing you to quickly derive behaviors and data from pending, error and success states.
|
|
57
|
-
*
|
|
58
|
-
* ```ts
|
|
59
|
-
* interface PromiseState<T = unknown, E = unknown> {
|
|
60
|
-
* isPending: boolean;
|
|
61
|
-
* isSuccess: boolean;
|
|
62
|
-
* isError: boolean;
|
|
63
|
-
* result: T | null;
|
|
64
|
-
* error: E | null;
|
|
65
|
-
* }
|
|
66
|
-
* ```
|
|
67
|
-
*
|
|
68
|
-
* To get the state of a promise, use `getPromiseState`.
|
|
69
|
-
*
|
|
70
|
-
* @class PromiseState
|
|
71
|
-
* @public
|
|
72
|
-
*/
|
|
73
|
-
/**
|
|
74
|
-
* Returns a reactive state-machine for the provided promise or awaitable.
|
|
75
|
-
*
|
|
76
|
-
* Repeat calls to `getPromiseState` with the same promise will return the same state object
|
|
77
|
-
* making is safe and easy to use in templates and JavaScript code to produce reactive
|
|
78
|
-
* behaviors around promises.
|
|
79
|
-
*
|
|
80
|
-
* `getPromiseState` can be used in both JavaScript and Template contexts.
|
|
81
|
-
*
|
|
82
|
-
* ```ts
|
|
83
|
-
* import { getPromiseState } from '@warp-drive-mirror/ember';
|
|
84
|
-
*
|
|
85
|
-
* const state = getPromiseState(promise);
|
|
86
|
-
* ```
|
|
87
|
-
*
|
|
88
|
-
* For instance, we could write a getter on a component that updates whenever
|
|
89
|
-
* the promise state advances or the promise changes, by combining the function
|
|
90
|
-
* with the use of `@cached`
|
|
91
|
-
*
|
|
92
|
-
* ```ts
|
|
93
|
-
* class Component {
|
|
94
|
-
* @cached
|
|
95
|
-
* get title() {
|
|
96
|
-
* const state = getPromiseState(this.args.request);
|
|
97
|
-
* if (state.isPending) {
|
|
98
|
-
* return 'loading...';
|
|
99
|
-
* }
|
|
100
|
-
* if (state.isError) { return null; }
|
|
101
|
-
* return state.result.title;
|
|
102
|
-
* }
|
|
103
|
-
* }
|
|
104
|
-
* ```
|
|
105
|
-
*
|
|
106
|
-
* Or in a template as a helper:
|
|
107
|
-
*
|
|
108
|
-
* ```gjs
|
|
109
|
-
* import { getPromiseState } from '@warp-drive-mirror/ember';
|
|
110
|
-
*
|
|
111
|
-
* <template>
|
|
112
|
-
* {{#let (getPromiseState @request) as |state|}}
|
|
113
|
-
* {{#if state.isPending}} <Spinner />
|
|
114
|
-
* {{else if state.isError}} <ErrorForm @error={{state.error}} />
|
|
115
|
-
* {{else}}
|
|
116
|
-
* <h1>{{state.result.title}}</h1>
|
|
117
|
-
* {{/if}}
|
|
118
|
-
* {{/let}}
|
|
119
|
-
* </template>
|
|
120
|
-
* ```
|
|
121
|
-
*
|
|
122
|
-
* If looking to use in a template, consider also the `<Await />` component.
|
|
123
|
-
*
|
|
124
|
-
* @method getPromiseState
|
|
125
|
-
* @for @warp-drive-mirror/ember
|
|
126
|
-
* @static
|
|
127
|
-
* @public
|
|
128
|
-
* @param {Promise<T> | Awaitable<T, E>} promise
|
|
129
|
-
* @return {PromiseState<T, E>}
|
|
130
|
-
*/
|
|
131
|
-
export { getPromiseState } from '@ember-data-mirror/store/-private';
|
|
132
|
-
/**
|
|
133
|
-
* Lazily consumes the stream of a request, providing a number of
|
|
134
|
-
* reactive properties that can be used to build UIs that respond
|
|
135
|
-
* to the progress of a request.
|
|
136
|
-
*
|
|
137
|
-
* @class RequestLoadingState
|
|
138
|
-
* @public
|
|
139
|
-
*/
|
|
140
|
-
/**
|
|
141
|
-
* RequestState extends the concept of PromiseState to provide a reactive
|
|
142
|
-
* wrapper for a request `Future` which allows you write declarative code
|
|
143
|
-
* around a Future's control flow.
|
|
144
|
-
*
|
|
145
|
-
* It is useful in both Template and JavaScript contexts, allowing you
|
|
146
|
-
* to quickly derive behaviors and data from pending, error and success
|
|
147
|
-
* states.
|
|
148
|
-
*
|
|
149
|
-
* The key difference between a Promise and a Future is that Futures provide
|
|
150
|
-
* access to a stream of their content, the identity of the request (if any)
|
|
151
|
-
* as well as the ability to attempt to abort the request.
|
|
152
|
-
*
|
|
153
|
-
* ```ts
|
|
154
|
-
* interface Future<T> extends Promise<T>> {
|
|
155
|
-
* getStream(): Promise<ReadableStream>;
|
|
156
|
-
* abort(): void;
|
|
157
|
-
* lid: StableDocumentIdentifier | null;
|
|
158
|
-
* }
|
|
159
|
-
* ```
|
|
160
|
-
*
|
|
161
|
-
* These additional APIs allow us to craft even richer state experiences.
|
|
162
|
-
*
|
|
163
|
-
* To get the state of a request, use `getRequestState`.
|
|
164
|
-
*
|
|
165
|
-
* @class RequestState
|
|
166
|
-
* @public
|
|
167
|
-
*/
|
|
168
|
-
/**
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
* `getRequestState` can be used in both JavaScript and Template contexts.
|
|
172
|
-
*
|
|
173
|
-
* ```ts
|
|
174
|
-
* import { getRequestState } from '@warp-drive-mirror/ember';
|
|
175
|
-
*
|
|
176
|
-
* const state = getRequestState(future);
|
|
177
|
-
* ```
|
|
178
|
-
*
|
|
179
|
-
* For instance, we could write a getter on a component that updates whenever
|
|
180
|
-
* the request state advances or the future changes, by combining the function
|
|
181
|
-
* with the use of `@cached`
|
|
182
|
-
*
|
|
183
|
-
* ```ts
|
|
184
|
-
* class Component {
|
|
185
|
-
* @cached
|
|
186
|
-
* get title() {
|
|
187
|
-
* const state = getRequestState(this.args.request);
|
|
188
|
-
* if (state.isPending) {
|
|
189
|
-
* return 'loading...';
|
|
190
|
-
* }
|
|
191
|
-
* if (state.isError) { return null; }
|
|
192
|
-
* return state.result.title;
|
|
193
|
-
* }
|
|
194
|
-
* }
|
|
195
|
-
* ```
|
|
196
|
-
*
|
|
197
|
-
* Or in a template as a helper:
|
|
198
|
-
*
|
|
199
|
-
* ```gjs
|
|
200
|
-
* import { getRequestState } from '@warp-drive-mirror/ember';
|
|
201
|
-
*
|
|
202
|
-
* <template>
|
|
203
|
-
* {{#let (getRequestState @request) as |state|}}
|
|
204
|
-
* {{#if state.isPending}}
|
|
205
|
-
* <Spinner />
|
|
206
|
-
* {{else if state.isError}}
|
|
207
|
-
* <ErrorForm @error={{state.error}} />
|
|
208
|
-
* {{else}}
|
|
209
|
-
* <h1>{{state.result.title}}</h1>
|
|
210
|
-
* {{/if}}
|
|
211
|
-
* {{/let}}
|
|
212
|
-
* </template>
|
|
213
|
-
* ```
|
|
214
|
-
*
|
|
215
|
-
* If looking to use in a template, consider also the `<Request />` component
|
|
216
|
-
* which offers a numbe of additional capabilities for requests *beyond* what
|
|
217
|
-
* `RequestState` provides.
|
|
218
|
-
*
|
|
219
|
-
* @method getRequestState
|
|
220
|
-
* @for @warp-drive-mirror/ember
|
|
221
|
-
* @static
|
|
222
|
-
* @public
|
|
223
|
-
* @param future
|
|
224
|
-
* @return {RequestState}
|
|
225
|
-
*/
|
|
226
|
-
export { getRequestState, type RequestLoadingState } from '@ember-data-mirror/store/-private';
|
|
227
|
-
}
|
|
228
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D;;;;;;;GAOG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH,OAAO,EAAE,eAAe,EAAE,KAAK,mBAAmB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
declare module '@warp-drive-mirror/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":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAQzD,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"}
|