@warp-drive-mirror/ember 5.7.0-alpha.3 → 5.7.0-alpha.30
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 +43 -6
- package/package.json +24 -19
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,12 @@
|
|
|
1
1
|
import { service } from '@ember/service';
|
|
2
2
|
import Component from '@glimmer/component';
|
|
3
|
+
import { cached } from '@glimmer/tracking';
|
|
3
4
|
import { macroCondition, moduleExists, importSync, getGlobalConfig } from '@embroider/macros';
|
|
4
5
|
import { getPromiseState, DISPOSE, createRequestSubscription } from '@warp-drive-mirror/core/store/-private';
|
|
5
|
-
export { getPromiseState, getRequestState } from '@warp-drive-mirror/core/store/-private';
|
|
6
|
+
export { createRequestSubscription, getPromiseState, getRequestState } from '@warp-drive-mirror/core/store/-private';
|
|
6
7
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
7
8
|
import { setComponentTemplate } from '@ember/component';
|
|
9
|
+
import templateOnly from '@ember/component/template-only';
|
|
8
10
|
|
|
9
11
|
const and = (x, y) => Boolean(x && y);
|
|
10
12
|
/**
|
|
@@ -129,6 +131,20 @@ function decorateFieldV2(prototype, prop, decorators, initializer) {
|
|
|
129
131
|
deferDecorator(prototype, prop, desc);
|
|
130
132
|
}
|
|
131
133
|
}
|
|
134
|
+
function decorateMethodV2(prototype, prop, decorators) {
|
|
135
|
+
const origDesc = Object.getOwnPropertyDescriptor(prototype, prop);
|
|
136
|
+
let desc = {
|
|
137
|
+
...origDesc
|
|
138
|
+
};
|
|
139
|
+
for (let decorator of decorators) {
|
|
140
|
+
desc = decorator(prototype, prop, desc) || desc;
|
|
141
|
+
}
|
|
142
|
+
if (desc.initializer !== void 0) {
|
|
143
|
+
desc.value = desc.initializer ? desc.initializer.call(prototype) : void 0;
|
|
144
|
+
desc.initializer = void 0;
|
|
145
|
+
}
|
|
146
|
+
Object.defineProperty(prototype, prop, desc);
|
|
147
|
+
}
|
|
132
148
|
function initializeDeferredDecorator(target, prop) {
|
|
133
149
|
let desc = findDeferredDecorator(target.constructor, prop);
|
|
134
150
|
if (desc) {
|
|
@@ -158,6 +174,9 @@ if (macroCondition(moduleExists('ember-provide-consume-context'))) {
|
|
|
158
174
|
} = importSync('ember-provide-consume-context');
|
|
159
175
|
consume = contextConsume;
|
|
160
176
|
}
|
|
177
|
+
const DefaultChrome = setComponentTemplate(precompileTemplate("{{yield}}", {
|
|
178
|
+
strictMode: true
|
|
179
|
+
}), templateOnly());
|
|
161
180
|
/**
|
|
162
181
|
* The `<Request />` component is a powerful tool for managing data fetching and
|
|
163
182
|
* state in your Ember application. It provides a declarative approach to reactive
|
|
@@ -372,7 +391,6 @@ if (macroCondition(moduleExists('ember-provide-consume-context'))) {
|
|
|
372
391
|
* same, only one actual request will be made.
|
|
373
392
|
*
|
|
374
393
|
*
|
|
375
|
-
* @class <Request />
|
|
376
394
|
* @public
|
|
377
395
|
*/
|
|
378
396
|
class Request extends Component {
|
|
@@ -403,21 +421,40 @@ class Request extends Component {
|
|
|
403
421
|
const {
|
|
404
422
|
store
|
|
405
423
|
} = this;
|
|
406
|
-
|
|
424
|
+
const {
|
|
425
|
+
subscription
|
|
426
|
+
} = this.args;
|
|
427
|
+
if (_state && (_state.store !== store || subscription)) {
|
|
407
428
|
_state[DISPOSE]();
|
|
408
429
|
_state = null;
|
|
409
430
|
}
|
|
431
|
+
if (subscription) {
|
|
432
|
+
return subscription;
|
|
433
|
+
}
|
|
410
434
|
if (!_state) {
|
|
411
435
|
this._state = _state = createRequestSubscription(store, this.args);
|
|
412
436
|
}
|
|
413
437
|
return _state;
|
|
414
438
|
}
|
|
439
|
+
/**
|
|
440
|
+
* The chrome component to use for rendering the request.
|
|
441
|
+
*
|
|
442
|
+
* @private
|
|
443
|
+
*/
|
|
444
|
+
get Chrome() {
|
|
445
|
+
return this.args.chrome || DefaultChrome;
|
|
446
|
+
}
|
|
447
|
+
static {
|
|
448
|
+
decorateMethodV2(this.prototype, "Chrome", [cached]);
|
|
449
|
+
}
|
|
415
450
|
willDestroy() {
|
|
416
|
-
this._state
|
|
417
|
-
|
|
451
|
+
if (this._state) {
|
|
452
|
+
this._state[DISPOSE]();
|
|
453
|
+
this._state = null;
|
|
454
|
+
}
|
|
418
455
|
}
|
|
419
456
|
static {
|
|
420
|
-
setComponentTemplate(precompileTemplate("\n {{#if (and this.state.isIdle (has-block \"idle\"))}}\n
|
|
457
|
+
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
458
|
strictMode: true,
|
|
422
459
|
scope: () => ({
|
|
423
460
|
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-alpha.
|
|
4
|
+
"version": "5.7.0-alpha.30",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Chris Thoburn <runspired@users.noreply.github.com>",
|
|
7
7
|
"repository": {
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"ember-provide-consume-context": "^0.7.0"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@embroider/macros": "^1.
|
|
41
|
-
"@warp-drive-mirror/core": "5.7.0-alpha.
|
|
40
|
+
"@embroider/macros": "^1.18.1",
|
|
41
|
+
"@warp-drive-mirror/core": "5.7.0-alpha.30"
|
|
42
42
|
},
|
|
43
43
|
"peerDependenciesMeta": {
|
|
44
44
|
"ember-provide-consume-context": {
|
|
@@ -46,28 +46,28 @@
|
|
|
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.0",
|
|
50
|
+
"@babel/plugin-transform-typescript": "^7.28.0",
|
|
51
|
+
"@babel/preset-env": "^7.28.0",
|
|
52
|
+
"@babel/preset-typescript": "^7.27.1",
|
|
53
|
+
"@babel/runtime": "^7.28.2",
|
|
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": "^7.1.
|
|
60
|
+
"@embroider/addon-dev": "^7.1.5",
|
|
61
61
|
"@ember/test-helpers": "5.2.0",
|
|
62
62
|
"@ember/test-waiters": "^4.1.0",
|
|
63
|
-
"@warp-drive/internal-config": "5.7.0-alpha.
|
|
64
|
-
"@warp-drive-mirror/core": "5.7.0-alpha.
|
|
63
|
+
"@warp-drive/internal-config": "5.7.0-alpha.30",
|
|
64
|
+
"@warp-drive-mirror/core": "5.7.0-alpha.30",
|
|
65
65
|
"babel-plugin-ember-template-compilation": "^2.4.1",
|
|
66
66
|
"ember-template-imports": "^4.3.0",
|
|
67
|
-
"ember-source": "~6.
|
|
67
|
+
"ember-source": "~6.6.0",
|
|
68
68
|
"rollup": "^4.40.0",
|
|
69
|
-
"typescript": "^5.
|
|
70
|
-
"vite": "^7.
|
|
69
|
+
"typescript": "^5.9.2",
|
|
70
|
+
"vite": "^7.1.2",
|
|
71
71
|
"ember-provide-consume-context": "^0.7.0"
|
|
72
72
|
},
|
|
73
73
|
"volta": {
|
|
@@ -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"
|