@warp-drive-mirror/ember 5.7.0-alpha.9 → 5.7.0-beta.0
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/declarations/-private/request.d.ts +37 -94
- package/declarations/index.d.ts +4 -4
- package/dist/index.js +51 -10
- package/package.json +28 -23
package/README.md
CHANGED
|
@@ -1,80 +1,28 @@
|
|
|
1
1
|
import Component from "@glimmer/component";
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type { RequestLoadingState, RequestState, RequestSubscription } from "@warp-drive-mirror/core/store/-private";
|
|
2
|
+
import type { ComponentLike } from "@glint/template";
|
|
3
|
+
import type { RequestManager, Store } from "@warp-drive-mirror/core";
|
|
4
|
+
import type { ContentFeatures, RecoveryFeatures, RequestArgs, RequestLoadingState, RequestState, RequestSubscription } from "@warp-drive-mirror/core/store/-private";
|
|
5
5
|
import type { StructuredErrorDocument } from "@warp-drive-mirror/core/types/request";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
export { ContentFeatures, RecoveryFeatures };
|
|
7
|
+
export interface EmberRequestArgs<
|
|
8
|
+
RT,
|
|
9
|
+
E
|
|
10
|
+
> extends RequestArgs<RT, E> {
|
|
11
|
+
chrome?: ComponentLike<{
|
|
12
|
+
Blocks: {
|
|
13
|
+
default: [];
|
|
14
|
+
};
|
|
15
|
+
Args: {
|
|
16
|
+
state: RequestState | null;
|
|
17
|
+
features: ContentFeatures<RT>;
|
|
18
|
+
};
|
|
19
|
+
}>;
|
|
20
|
+
}
|
|
17
21
|
interface RequestSignature<
|
|
18
22
|
RT,
|
|
19
|
-
T,
|
|
20
23
|
E
|
|
21
24
|
> {
|
|
22
|
-
Args:
|
|
23
|
-
/**
|
|
24
|
-
* The request to monitor. This should be a `Future` instance returned
|
|
25
|
-
* by either the `store.request` or `store.requestManager.request` methods.
|
|
26
|
-
*
|
|
27
|
-
*/ request?: Future<RT>;
|
|
28
|
-
/**
|
|
29
|
-
* A query to use for the request. This should be an object that can be
|
|
30
|
-
* passed to `store.request`. Use this in place of `@request` if you would
|
|
31
|
-
* like the component to also initiate the request.
|
|
32
|
-
*
|
|
33
|
-
*/ query?: StoreRequestInput<RT, T>;
|
|
34
|
-
/**
|
|
35
|
-
* The store instance to use for making requests. If contexts are available,
|
|
36
|
-
* the component will default to using the `store` on the context.
|
|
37
|
-
*
|
|
38
|
-
* This is required if the store is not available via context or should be
|
|
39
|
-
* different from the store provided via context.
|
|
40
|
-
*
|
|
41
|
-
*/ store?: Store;
|
|
42
|
-
/**
|
|
43
|
-
* The autorefresh behavior for the request. This can be a boolean, or any
|
|
44
|
-
* combination of the following values: `'online'`, `'interval'`, `'invalid'`.
|
|
45
|
-
*
|
|
46
|
-
* - `'online'`: Refresh the request when the browser comes back online
|
|
47
|
-
* - `'interval'`: Refresh the request at a specified interval
|
|
48
|
-
* - `'invalid'`: Refresh the request when the store emits an invalidation
|
|
49
|
-
*
|
|
50
|
-
* If `true`, this is equivalent to `'online,invalid'`.
|
|
51
|
-
*
|
|
52
|
-
* Defaults to `false`.
|
|
53
|
-
*
|
|
54
|
-
*/ autorefresh?: AutorefreshBehaviorCombos;
|
|
55
|
-
/**
|
|
56
|
-
* The number of milliseconds to wait before refreshing the request when the
|
|
57
|
-
* browser comes back online or the network becomes available.
|
|
58
|
-
*
|
|
59
|
-
* This also controls the interval at which the request will be refreshed if
|
|
60
|
-
* the `interval` autorefresh type is enabled.
|
|
61
|
-
*
|
|
62
|
-
* Defaults to `30_000` (30 seconds).
|
|
63
|
-
*
|
|
64
|
-
*/ autorefreshThreshold?: number;
|
|
65
|
-
/**
|
|
66
|
-
* The behavior of the request initiated by autorefresh. This can be one of
|
|
67
|
-
* the following values:
|
|
68
|
-
*
|
|
69
|
-
* - `'refresh'`: Refresh the request in the background
|
|
70
|
-
* - `'reload'`: Force a reload of the request
|
|
71
|
-
* - `'policy'` (**default**): Let the store's configured CachePolicy decide whether to
|
|
72
|
-
* reload, refresh, or do nothing.
|
|
73
|
-
*
|
|
74
|
-
* Defaults to `'policy'`.
|
|
75
|
-
*
|
|
76
|
-
*/ autorefreshBehavior?: "refresh" | "reload" | "policy";
|
|
77
|
-
};
|
|
25
|
+
Args: EmberRequestArgs<RT, E>;
|
|
78
26
|
Blocks: {
|
|
79
27
|
/**
|
|
80
28
|
* The block to render when the component is idle and waiting to be given a request.
|
|
@@ -87,28 +35,19 @@ interface RequestSignature<
|
|
|
87
35
|
/**
|
|
88
36
|
* The block to render when the request was cancelled.
|
|
89
37
|
*
|
|
90
|
-
*/ cancelled: [error: StructuredErrorDocument<E>, features:
|
|
91
|
-
isOnline: boolean;
|
|
92
|
-
isHidden: boolean;
|
|
93
|
-
retry: () => Promise<void>;
|
|
94
|
-
}];
|
|
38
|
+
*/ cancelled: [error: StructuredErrorDocument<E>, features: RecoveryFeatures];
|
|
95
39
|
/**
|
|
96
40
|
* The block to render when the request failed. If this block is not provided,
|
|
97
41
|
* the error will be rethrown.
|
|
98
42
|
*
|
|
99
43
|
* Thus it is required to provide an error block and proper error handling if
|
|
100
44
|
* you do not want the error to crash the application.
|
|
101
|
-
|
|
102
|
-
*/ error: [error: StructuredErrorDocument<E>, features: {
|
|
103
|
-
isOnline: boolean;
|
|
104
|
-
isHidden: boolean;
|
|
105
|
-
retry: () => Promise<void>;
|
|
106
|
-
}];
|
|
45
|
+
*/ error: [error: StructuredErrorDocument<E>, features: RecoveryFeatures];
|
|
107
46
|
/**
|
|
108
47
|
* The block to render when the request succeeded.
|
|
109
48
|
*
|
|
110
49
|
*/ content: [value: RT, features: ContentFeatures<RT>];
|
|
111
|
-
always: [state: RequestState<RT,
|
|
50
|
+
always: [state: RequestState<RT, StructuredErrorDocument<E>>];
|
|
112
51
|
};
|
|
113
52
|
}
|
|
114
53
|
/**
|
|
@@ -325,22 +264,26 @@ interface RequestSignature<
|
|
|
325
264
|
* same, only one actual request will be made.
|
|
326
265
|
*
|
|
327
266
|
*
|
|
328
|
-
* @class <Request />
|
|
329
267
|
* @public
|
|
330
268
|
*/ export declare class Request<
|
|
331
269
|
RT,
|
|
332
|
-
T,
|
|
333
270
|
E
|
|
334
|
-
> extends Component<RequestSignature<RT,
|
|
271
|
+
> extends Component<RequestSignature<RT, E>> {
|
|
272
|
+
get store(): Store | RequestManager;
|
|
273
|
+
_state: RequestSubscription<RT, E> | null;
|
|
274
|
+
get state(): RequestSubscription<RT, E>;
|
|
335
275
|
/**
|
|
336
|
-
* The
|
|
337
|
-
* will be the `store` on the context, else it will be the store service.
|
|
276
|
+
* The chrome component to use for rendering the request.
|
|
338
277
|
*
|
|
339
|
-
* @
|
|
340
|
-
*/
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
278
|
+
* @private
|
|
279
|
+
*/ get Chrome(): ComponentLike<{
|
|
280
|
+
Blocks: {
|
|
281
|
+
default: [];
|
|
282
|
+
};
|
|
283
|
+
Args: {
|
|
284
|
+
state: RequestState | null;
|
|
285
|
+
features: ContentFeatures<RT>;
|
|
286
|
+
};
|
|
287
|
+
}>;
|
|
344
288
|
willDestroy(): void;
|
|
345
289
|
}
|
|
346
|
-
export {};
|
package/declarations/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* ## Installation
|
|
5
5
|
*
|
|
6
|
-
* ```
|
|
6
|
+
* ```sh
|
|
7
7
|
* pnpm install @warp-drive-mirror/ember
|
|
8
8
|
* ```
|
|
9
9
|
*
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
*
|
|
44
44
|
* @module
|
|
45
45
|
*/
|
|
46
|
-
export { Request } from "./-private/request.js";
|
|
46
|
+
export { Request, type ContentFeatures, type RecoveryFeatures } from "./-private/request.js";
|
|
47
47
|
export { Await, Throw } from "./-private/await.js";
|
|
48
48
|
/**
|
|
49
49
|
* PromiseState provides a reactive wrapper for a promise which allows you write declarative
|
|
@@ -146,7 +146,7 @@ export { getPromiseState } from "@warp-drive-mirror/core/store/-private";
|
|
|
146
146
|
* interface Future<T> extends Promise<T>> {
|
|
147
147
|
* getStream(): Promise<ReadableStream>;
|
|
148
148
|
* abort(): void;
|
|
149
|
-
* lid:
|
|
149
|
+
* lid: RequestKey | null;
|
|
150
150
|
* }
|
|
151
151
|
* ```
|
|
152
152
|
*
|
|
@@ -212,4 +212,4 @@ export { getPromiseState } from "@warp-drive-mirror/core/store/-private";
|
|
|
212
212
|
* @param future
|
|
213
213
|
* @return {RequestState}
|
|
214
214
|
*/
|
|
215
|
-
export { getRequestState, type RequestLoadingState } from "@warp-drive-mirror/core/store/-private";
|
|
215
|
+
export { getRequestState, createRequestSubscription, type RequestLoadingState } from "@warp-drive-mirror/core/store/-private";
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { service } from '@ember/service';
|
|
2
2
|
import Component from '@glimmer/component';
|
|
3
|
-
import { macroCondition, moduleExists, importSync
|
|
4
|
-
import { getPromiseState, DISPOSE, createRequestSubscription } from '@warp-drive-mirror/core/store/-private';
|
|
5
|
-
export { getPromiseState, getRequestState } from '@warp-drive-mirror/core/store/-private';
|
|
3
|
+
import { macroCondition, getGlobalConfig, moduleExists, importSync } from '@embroider/macros';
|
|
4
|
+
import { getPromiseState, DISPOSE, createRequestSubscription, memoized } from '@warp-drive-mirror/core/store/-private';
|
|
5
|
+
export { createRequestSubscription, getPromiseState, getRequestState } from '@warp-drive-mirror/core/store/-private';
|
|
6
6
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
7
7
|
import { setComponentTemplate } from '@ember/component';
|
|
8
|
+
import templateOnly from '@ember/component/template-only';
|
|
8
9
|
|
|
9
10
|
const and = (x, y) => Boolean(x && y);
|
|
10
11
|
/**
|
|
@@ -25,8 +26,13 @@ class Throw extends Component {
|
|
|
25
26
|
super(owner, args);
|
|
26
27
|
// this error is opaque (user supplied) so we don't validate it
|
|
27
28
|
// as an Error instance.
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
if (macroCondition(getGlobalConfig().WarpDriveMirror.env.PRODUCTION)) {
|
|
30
|
+
// eslint-disable-next-line no-console
|
|
31
|
+
console.error(this.args.error);
|
|
32
|
+
} else {
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/only-throw-error
|
|
34
|
+
throw this.args.error;
|
|
35
|
+
}
|
|
30
36
|
}
|
|
31
37
|
static {
|
|
32
38
|
setComponentTemplate(precompileTemplate("", {
|
|
@@ -129,6 +135,20 @@ function decorateFieldV2(prototype, prop, decorators, initializer) {
|
|
|
129
135
|
deferDecorator(prototype, prop, desc);
|
|
130
136
|
}
|
|
131
137
|
}
|
|
138
|
+
function decorateMethodV2(prototype, prop, decorators) {
|
|
139
|
+
const origDesc = Object.getOwnPropertyDescriptor(prototype, prop);
|
|
140
|
+
let desc = {
|
|
141
|
+
...origDesc
|
|
142
|
+
};
|
|
143
|
+
for (let decorator of decorators) {
|
|
144
|
+
desc = decorator(prototype, prop, desc) || desc;
|
|
145
|
+
}
|
|
146
|
+
if (desc.initializer !== void 0) {
|
|
147
|
+
desc.value = desc.initializer ? desc.initializer.call(prototype) : void 0;
|
|
148
|
+
desc.initializer = void 0;
|
|
149
|
+
}
|
|
150
|
+
Object.defineProperty(prototype, prop, desc);
|
|
151
|
+
}
|
|
132
152
|
function initializeDeferredDecorator(target, prop) {
|
|
133
153
|
let desc = findDeferredDecorator(target.constructor, prop);
|
|
134
154
|
if (desc) {
|
|
@@ -158,6 +178,9 @@ if (macroCondition(moduleExists('ember-provide-consume-context'))) {
|
|
|
158
178
|
} = importSync('ember-provide-consume-context');
|
|
159
179
|
consume = contextConsume;
|
|
160
180
|
}
|
|
181
|
+
const DefaultChrome = setComponentTemplate(precompileTemplate("{{yield}}", {
|
|
182
|
+
strictMode: true
|
|
183
|
+
}), templateOnly());
|
|
161
184
|
/**
|
|
162
185
|
* The `<Request />` component is a powerful tool for managing data fetching and
|
|
163
186
|
* state in your Ember application. It provides a declarative approach to reactive
|
|
@@ -372,7 +395,6 @@ if (macroCondition(moduleExists('ember-provide-consume-context'))) {
|
|
|
372
395
|
* same, only one actual request will be made.
|
|
373
396
|
*
|
|
374
397
|
*
|
|
375
|
-
* @class <Request />
|
|
376
398
|
* @public
|
|
377
399
|
*/
|
|
378
400
|
class Request extends Component {
|
|
@@ -403,21 +425,40 @@ class Request extends Component {
|
|
|
403
425
|
const {
|
|
404
426
|
store
|
|
405
427
|
} = this;
|
|
406
|
-
|
|
428
|
+
const {
|
|
429
|
+
subscription
|
|
430
|
+
} = this.args;
|
|
431
|
+
if (_state && (_state.store !== store || subscription)) {
|
|
407
432
|
_state[DISPOSE]();
|
|
408
433
|
_state = null;
|
|
409
434
|
}
|
|
435
|
+
if (subscription) {
|
|
436
|
+
return subscription;
|
|
437
|
+
}
|
|
410
438
|
if (!_state) {
|
|
411
439
|
this._state = _state = createRequestSubscription(store, this.args);
|
|
412
440
|
}
|
|
413
441
|
return _state;
|
|
414
442
|
}
|
|
443
|
+
/**
|
|
444
|
+
* The chrome component to use for rendering the request.
|
|
445
|
+
*
|
|
446
|
+
* @private
|
|
447
|
+
*/
|
|
448
|
+
get Chrome() {
|
|
449
|
+
return this.args.chrome || DefaultChrome;
|
|
450
|
+
}
|
|
451
|
+
static {
|
|
452
|
+
decorateMethodV2(this.prototype, "Chrome", [memoized]);
|
|
453
|
+
}
|
|
415
454
|
willDestroy() {
|
|
416
|
-
this._state
|
|
417
|
-
|
|
455
|
+
if (this._state) {
|
|
456
|
+
this._state[DISPOSE]();
|
|
457
|
+
this._state = null;
|
|
458
|
+
}
|
|
418
459
|
}
|
|
419
460
|
static {
|
|
420
|
-
setComponentTemplate(precompileTemplate("\n {{#if (and this.state.isIdle (has-block \"idle\"))}}\n
|
|
461
|
+
setComponentTemplate(precompileTemplate("\n <this.Chrome @state={{if this.state.isIdle null this.state.reqState}} @features={{this.state.contentFeatures}}>\n {{#if (and this.state.isIdle (has-block \"idle\"))}}\n {{yield to=\"idle\"}}\n\n {{else if this.state.isIdle}}\n <Throw @error={{IdleBlockMissingError}} />\n\n {{else if this.state.reqState.isLoading}}\n {{yield this.state.reqState.loadingState to=\"loading\"}}\n\n {{else if (and this.state.reqState.isCancelled (has-block \"cancelled\"))}}\n {{yield (notNull this.state.reqState.reason) this.state.errorFeatures to=\"cancelled\"}}\n\n {{else if (and this.state.reqState.isError (has-block \"error\"))}}\n {{yield (notNull this.state.reqState.reason) this.state.errorFeatures to=\"error\"}}\n\n {{else if this.state.reqState.isSuccess}}\n {{yield this.state.result this.state.contentFeatures to=\"content\"}}\n\n {{else if (not this.state.reqState.isCancelled)}}\n <Throw @error={{(notNull this.state.reqState.reason)}} />\n {{/if}}\n\n {{yield this.state.reqState to=\"always\"}}\n </this.Chrome>\n ", {
|
|
421
462
|
strictMode: true,
|
|
422
463
|
scope: () => ({
|
|
423
464
|
and,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@warp-drive-mirror/ember",
|
|
3
3
|
"description": "Data bindings and utilities for Ember applications using WarpDrive",
|
|
4
|
-
"version": "5.7.0-
|
|
4
|
+
"version": "5.7.0-beta.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Chris Thoburn <runspired@users.noreply.github.com>",
|
|
7
7
|
"repository": {
|
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"@ember/test-waiters": "^3.1.0 || ^4.0.0",
|
|
37
|
-
"ember-provide-consume-context": "^0.
|
|
37
|
+
"ember-provide-consume-context": "^0.8.0"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@embroider/macros": "^1.
|
|
41
|
-
"@warp-drive-mirror/core": "5.7.0-
|
|
40
|
+
"@embroider/macros": "^1.18.1",
|
|
41
|
+
"@warp-drive-mirror/core": "5.7.0-beta.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependenciesMeta": {
|
|
44
44
|
"ember-provide-consume-context": {
|
|
@@ -46,29 +46,29 @@
|
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@babel/core": "^7.
|
|
50
|
-
"@babel/plugin-transform-typescript": "^7.
|
|
51
|
-
"@babel/preset-env": "^7.
|
|
52
|
-
"@babel/preset-typescript": "^7.27.
|
|
53
|
-
"@babel/runtime": "^7.
|
|
49
|
+
"@babel/core": "^7.28.3",
|
|
50
|
+
"@babel/plugin-transform-typescript": "^7.28.0",
|
|
51
|
+
"@babel/preset-env": "^7.28.3",
|
|
52
|
+
"@babel/preset-typescript": "^7.27.1",
|
|
53
|
+
"@babel/runtime": "^7.28.3",
|
|
54
54
|
"@glimmer/component": "^2.0.0",
|
|
55
|
-
"@glint/core": "
|
|
56
|
-
"@glint/environment-ember-loose": "
|
|
57
|
-
"@glint/environment-ember-template-imports": "
|
|
58
|
-
"@glint/template": "
|
|
55
|
+
"@glint/core": "alpha",
|
|
56
|
+
"@glint/environment-ember-loose": "alpha",
|
|
57
|
+
"@glint/environment-ember-template-imports": "alpha",
|
|
58
|
+
"@glint/template": "alpha",
|
|
59
59
|
"decorator-transforms": "^2.3.0",
|
|
60
|
-
"@embroider/addon-dev": "^
|
|
60
|
+
"@embroider/addon-dev": "^8.1.0",
|
|
61
61
|
"@ember/test-helpers": "5.2.0",
|
|
62
|
-
"@ember/test-waiters": "^4.1.
|
|
63
|
-
"@warp-drive/internal-config": "5.7.0-
|
|
64
|
-
"@warp-drive-mirror/core": "5.7.0-
|
|
62
|
+
"@ember/test-waiters": "^4.1.1",
|
|
63
|
+
"@warp-drive/internal-config": "5.7.0-beta.0",
|
|
64
|
+
"@warp-drive-mirror/core": "5.7.0-beta.0",
|
|
65
65
|
"babel-plugin-ember-template-compilation": "^2.4.1",
|
|
66
66
|
"ember-template-imports": "^4.3.0",
|
|
67
|
-
"ember-source": "~6.
|
|
68
|
-
"rollup": "^4.
|
|
69
|
-
"typescript": "^5.
|
|
70
|
-
"vite": "^7.
|
|
71
|
-
"ember-provide-consume-context": "^0.
|
|
67
|
+
"ember-source": "~6.6.0",
|
|
68
|
+
"rollup": "^4.48.0",
|
|
69
|
+
"typescript": "^5.9.2",
|
|
70
|
+
"vite": "^7.1.3",
|
|
71
|
+
"ember-provide-consume-context": "^0.8.0"
|
|
72
72
|
},
|
|
73
73
|
"volta": {
|
|
74
74
|
"extends": "../../../../../../package.json"
|
|
@@ -76,7 +76,12 @@
|
|
|
76
76
|
"ember-addon": {
|
|
77
77
|
"main": "addon-main.cjs",
|
|
78
78
|
"type": "addon",
|
|
79
|
-
"version": 2
|
|
79
|
+
"version": 2,
|
|
80
|
+
"externals": [
|
|
81
|
+
"@ember/-internals",
|
|
82
|
+
"@ember/-internals/metal",
|
|
83
|
+
"@glimmer/validator"
|
|
84
|
+
]
|
|
80
85
|
},
|
|
81
86
|
"ember": {
|
|
82
87
|
"edition": "octane"
|