@warp-drive/core 5.6.0-alpha.18 → 5.6.0-alpha.5
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 +7 -8
- package/declarations/index.d.ts +3 -14
- package/declarations/index.d.ts.map +1 -0
- package/declarations/request/-private/context.d.ts +35 -34
- package/declarations/request/-private/context.d.ts.map +1 -0
- package/declarations/request/-private/debug.d.ts +3 -2
- package/declarations/request/-private/debug.d.ts.map +1 -0
- package/declarations/request/-private/fetch.d.ts +36 -24
- package/declarations/request/-private/fetch.d.ts.map +1 -0
- package/declarations/request/-private/future.d.ts +4 -3
- package/declarations/request/-private/future.d.ts.map +1 -0
- package/declarations/request/-private/manager.d.ts +132 -159
- package/declarations/request/-private/manager.d.ts.map +1 -0
- package/declarations/request/-private/promise-cache.d.ts +13 -21
- package/declarations/request/-private/promise-cache.d.ts.map +1 -0
- package/declarations/request/-private/types.d.ts +123 -124
- package/declarations/request/-private/types.d.ts.map +1 -0
- package/declarations/request/-private/utils.d.ts +9 -8
- package/declarations/request/-private/utils.d.ts.map +1 -0
- package/declarations/request.d.ts +433 -5
- package/declarations/request.d.ts.map +1 -0
- package/declarations/types/-private.d.ts +8 -16
- package/declarations/types/-private.d.ts.map +1 -0
- package/declarations/types/cache/aliases.d.ts +1 -11
- package/declarations/types/cache/aliases.d.ts.map +1 -0
- package/declarations/types/cache/change.d.ts +5 -4
- package/declarations/types/cache/change.d.ts.map +1 -0
- package/declarations/types/cache/mutations.d.ts +28 -51
- package/declarations/types/cache/mutations.d.ts.map +1 -0
- package/declarations/types/cache/operations.d.ts +47 -60
- package/declarations/types/cache/operations.d.ts.map +1 -0
- package/declarations/types/cache/relationship.d.ts +9 -11
- package/declarations/types/cache/relationship.d.ts.map +1 -0
- package/declarations/types/cache.d.ts +484 -495
- package/declarations/types/cache.d.ts.map +1 -0
- package/declarations/types/graph.d.ts +40 -31
- package/declarations/types/graph.d.ts.map +1 -0
- package/declarations/types/identifier.d.ts +82 -83
- package/declarations/types/identifier.d.ts.map +1 -0
- package/declarations/types/json/raw.d.ts +2 -1
- package/declarations/types/json/raw.d.ts.map +1 -0
- package/declarations/types/params.d.ts +5 -4
- package/declarations/types/params.d.ts.map +1 -0
- package/declarations/types/record.d.ts +76 -117
- package/declarations/types/record.d.ts.map +1 -0
- package/declarations/types/record.type-test.d.ts +2 -0
- package/declarations/types/record.type-test.d.ts.map +1 -0
- package/declarations/types/request.d.ts +266 -289
- package/declarations/types/request.d.ts.map +1 -0
- package/declarations/types/request.type-test.d.ts +2 -0
- package/declarations/types/request.type-test.d.ts.map +1 -0
- package/declarations/types/runtime.d.ts +9 -8
- package/declarations/types/runtime.d.ts.map +1 -0
- package/declarations/types/schema/concepts.d.ts +13 -19
- package/declarations/types/schema/concepts.d.ts.map +1 -0
- package/declarations/types/schema/fields.d.ts +1741 -1712
- package/declarations/types/schema/fields.d.ts.map +1 -0
- package/declarations/types/schema/fields.type-test.d.ts +1 -0
- package/declarations/types/schema/fields.type-test.d.ts.map +1 -0
- package/declarations/types/spec/document.d.ts +22 -28
- package/declarations/types/spec/document.d.ts.map +1 -0
- package/declarations/types/spec/error.d.ts +17 -16
- package/declarations/types/spec/error.d.ts.map +1 -0
- package/declarations/types/spec/json-api-raw.d.ts +102 -102
- package/declarations/types/spec/json-api-raw.d.ts.map +1 -0
- package/declarations/types/symbols.d.ts +75 -74
- package/declarations/types/symbols.d.ts.map +1 -0
- package/declarations/types/utils.d.ts +5 -5
- package/declarations/types/utils.d.ts.map +1 -0
- package/declarations/types.d.ts +7 -10
- package/declarations/types.d.ts.map +1 -0
- package/dist/{context-COmAnXUQ.js → context-DE5sFezZ.js} +2 -2
- package/dist/context-DE5sFezZ.js.map +1 -0
- package/dist/index.js +104 -37
- package/dist/index.js.map +1 -0
- package/dist/request.js +1 -1
- package/dist/request.js.map +1 -0
- package/dist/types/-private.js +3 -3
- package/dist/types/-private.js.map +1 -0
- package/dist/types/cache/aliases.js.map +1 -0
- package/dist/types/cache/change.js.map +1 -0
- package/dist/types/cache/mutations.js.map +1 -0
- package/dist/types/cache/operations.js.map +1 -0
- package/dist/types/cache/relationship.js.map +1 -0
- package/dist/types/cache.js.map +1 -0
- package/dist/types/graph.js.map +1 -0
- package/dist/types/identifier.js.map +1 -0
- package/dist/types/json/raw.js.map +1 -0
- package/dist/types/params.js.map +1 -0
- package/dist/types/record.js +1 -1
- package/dist/types/record.js.map +1 -0
- package/dist/types/request.js +2 -2
- package/dist/types/request.js.map +1 -0
- package/dist/types/runtime.js +1 -1
- package/dist/types/runtime.js.map +1 -0
- package/dist/types/schema/concepts.js.map +1 -0
- package/dist/types/schema/fields.js +41 -8
- package/dist/types/schema/fields.js.map +1 -0
- package/dist/types/schema/fields.type-test.js.map +1 -0
- package/dist/types/spec/document.js.map +1 -0
- package/dist/types/spec/error.js.map +1 -0
- package/dist/types/spec/json-api-raw.js.map +1 -0
- package/dist/types/symbols.js +3 -3
- package/dist/types/symbols.js.map +1 -0
- package/dist/types/utils.js.map +1 -0
- package/dist/types.js.map +1 -0
- package/package.json +8 -11
- package/cjs-dist/addon-shim.cjs +0 -1
- package/cjs-dist/cjs-set-config.cjs +0 -1
- package/declarations/build-config/babel-macros.d.ts +0 -1
- package/declarations/build-config/canary-features.d.ts +0 -1
- package/declarations/build-config/debugging.d.ts +0 -1
- package/declarations/build-config/deprecations.d.ts +0 -1
- package/declarations/build-config/env.d.ts +0 -1
- package/declarations/build-config/macros.d.ts +0 -1
- package/declarations/build-config.d.ts +0 -1
- package/declarations/configure.d.ts +0 -7
- package/declarations/graph/-private/-diff.d.ts +0 -32
- package/declarations/graph/-private/-edge-definition.d.ts +0 -148
- package/declarations/graph/-private/-state.d.ts +0 -96
- package/declarations/graph/-private/-utils.d.ts +0 -31
- package/declarations/graph/-private/coerce-id.d.ts +0 -10
- package/declarations/graph/-private/debug/assert-polymorphic-type.d.ts +0 -18
- package/declarations/graph/-private/edges/collection.d.ts +0 -39
- package/declarations/graph/-private/edges/implicit.d.ts +0 -43
- package/declarations/graph/-private/edges/resource.d.ts +0 -24
- package/declarations/graph/-private/graph.d.ts +0 -90
- package/declarations/graph/-private/normalize-link.d.ts +0 -8
- package/declarations/graph/-private/operations/add-to-related-records.d.ts +0 -4
- package/declarations/graph/-private/operations/merge-identifier.d.ts +0 -3
- package/declarations/graph/-private/operations/remove-from-related-records.d.ts +0 -4
- package/declarations/graph/-private/operations/replace-related-record.d.ts +0 -3
- package/declarations/graph/-private/operations/replace-related-records.d.ts +0 -62
- package/declarations/graph/-private/operations/update-relationship.d.ts +0 -13
- package/declarations/graph/-private.d.ts +0 -13
- package/declarations/reactive/-private/document.d.ts +0 -146
- package/declarations/reactive/-private/fields/compute.d.ts +0 -43
- package/declarations/reactive/-private/fields/extension.d.ts +0 -8
- package/declarations/reactive/-private/fields/managed-array.d.ts +0 -22
- package/declarations/reactive/-private/fields/managed-object.d.ts +0 -21
- package/declarations/reactive/-private/fields/many-array-manager.d.ts +0 -19
- package/declarations/reactive/-private/hooks.d.ts +0 -5
- package/declarations/reactive/-private/record.d.ts +0 -64
- package/declarations/reactive/-private/schema.d.ts +0 -271
- package/declarations/reactive/-private/symbols.d.ts +0 -36
- package/declarations/reactive/-private.d.ts +0 -1
- package/declarations/reactive.d.ts +0 -4
- package/declarations/store/-private/cache-handler/handler.d.ts +0 -62
- package/declarations/store/-private/cache-handler/types.d.ts +0 -98
- package/declarations/store/-private/cache-handler/utils.d.ts +0 -32
- package/declarations/store/-private/caches/cache-utils.d.ts +0 -12
- package/declarations/store/-private/caches/identifier-cache.d.ts +0 -304
- package/declarations/store/-private/caches/instance-cache.d.ts +0 -65
- package/declarations/store/-private/caches/resource-utils.d.ts +0 -9
- package/declarations/store/-private/debug/utils.d.ts +0 -6
- package/declarations/store/-private/default-cache-policy.d.ts +0 -384
- package/declarations/store/-private/legacy-model-support/record-reference.d.ts +0 -159
- package/declarations/store/-private/legacy-model-support/shim-model-class.d.ts +0 -17
- package/declarations/store/-private/managers/cache-capabilities-manager.d.ts +0 -25
- package/declarations/store/-private/managers/cache-manager.d.ts +0 -443
- package/declarations/store/-private/managers/notification-manager.d.ts +0 -98
- package/declarations/store/-private/managers/record-array-manager.d.ts +0 -97
- package/declarations/store/-private/network/request-cache.d.ts +0 -107
- package/declarations/store/-private/new-core-tmp/promise-state.d.ts +0 -263
- package/declarations/store/-private/new-core-tmp/reactivity/configure.d.ts +0 -176
- package/declarations/store/-private/new-core-tmp/reactivity/internal.d.ts +0 -169
- package/declarations/store/-private/new-core-tmp/reactivity/signal.d.ts +0 -35
- package/declarations/store/-private/new-core-tmp/request-state.d.ts +0 -277
- package/declarations/store/-private/new-core-tmp/request-subscription.d.ts +0 -261
- package/declarations/store/-private/record-arrays/identifier-array.d.ts +0 -147
- package/declarations/store/-private/record-arrays/many-array.d.ts +0 -197
- package/declarations/store/-private/record-arrays/native-proxy-type-fix.d.ts +0 -126
- package/declarations/store/-private/store-service.d.ts +0 -1605
- package/declarations/store/-private/utils/coerce-id.d.ts +0 -10
- package/declarations/store/-private/utils/construct-resource.d.ts +0 -6
- package/declarations/store/-private/utils/is-non-empty-string.d.ts +0 -1
- package/declarations/store/-private/utils/normalize-model-name.d.ts +0 -1
- package/declarations/store/-private/utils/uuid-polyfill.d.ts +0 -1
- package/declarations/store/-private.d.ts +0 -31
- package/declarations/store/-types/q/cache-capabilities-manager.d.ts +0 -99
- package/declarations/store/-types/q/ds-model.d.ts +0 -21
- package/declarations/store/-types/q/identifier.d.ts +0 -20
- package/declarations/store/-types/q/record-instance.d.ts +0 -23
- package/declarations/store/-types/q/schema-service.d.ts +0 -354
- package/declarations/store/-types/q/store.d.ts +0 -32
- package/declarations/store.d.ts +0 -1
- package/declarations/utils/string.d.ts +0 -48
- package/dist/build-config/babel-macros.js +0 -1
- package/dist/build-config/canary-features.js +0 -1
- package/dist/build-config/debugging.js +0 -1
- package/dist/build-config/deprecations.js +0 -1
- package/dist/build-config/env.js +0 -1
- package/dist/build-config/macros.js +0 -1
- package/dist/build-config.js +0 -1
- package/dist/configure-B48bFHOl.js +0 -181
- package/dist/configure.js +0 -1
- package/dist/graph/-private.js +0 -3372
- package/dist/handler-C2T-IyJK.js +0 -339
- package/dist/reactive/-private.js +0 -1
- package/dist/reactive.js +0 -1988
- package/dist/request-state-CjLph1LP.js +0 -8139
- package/dist/store/-private.js +0 -3
- package/dist/store.js +0 -545
- package/dist/symbols-SIstXMLI.js +0 -44
- package/dist/utils/string.js +0 -92
- package/logos/NCC-1701-a-blue.svg +0 -4
- package/logos/NCC-1701-a-gold.svg +0 -4
- package/logos/NCC-1701-a-gold_100.svg +0 -1
- package/logos/NCC-1701-a-gold_base-64.txt +0 -1
- package/logos/NCC-1701-a.svg +0 -4
- package/logos/README.md +0 -4
- package/logos/docs-badge.svg +0 -2
- package/logos/ember-data-logo-dark.svg +0 -12
- package/logos/ember-data-logo-light.svg +0 -12
- package/logos/github-header.svg +0 -444
- package/logos/social1.png +0 -0
- package/logos/social2.png +0 -0
- package/logos/warp-drive-logo-dark.svg +0 -4
- package/logos/warp-drive-logo-gold.svg +0 -4
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { SignalStore, WarpDriveSignal } from "./internal.js";
|
|
2
|
-
/**
|
|
3
|
-
* Creates a signal for the key/object pairing and subscribes to the signal.
|
|
4
|
-
*
|
|
5
|
-
* Use when you need to ensure a signal exists and is subscribed to.
|
|
6
|
-
*
|
|
7
|
-
* @internal
|
|
8
|
-
*/
|
|
9
|
-
export declare function entangleSignal<T extends object>(signals: SignalStore, obj: T, key: string | symbol, initialValue: unknown): WarpDriveSignal;
|
|
10
|
-
/**
|
|
11
|
-
* define an enumerable signal property.
|
|
12
|
-
*
|
|
13
|
-
* Akin to Object.defineProperty.
|
|
14
|
-
*
|
|
15
|
-
* The signal will be lazily created when accessed and scoped to the
|
|
16
|
-
* instance of the object.
|
|
17
|
-
*
|
|
18
|
-
* @internal
|
|
19
|
-
*/
|
|
20
|
-
export declare function defineSignal<T extends object>(obj: T, key: string, v?: unknown): void;
|
|
21
|
-
/**
|
|
22
|
-
* Define a non-enumerable signal property.
|
|
23
|
-
*
|
|
24
|
-
* @internal
|
|
25
|
-
*/
|
|
26
|
-
export declare function defineNonEnumerableSignal<T extends object>(obj: T, key: string, v?: unknown): void;
|
|
27
|
-
export declare function memoized<
|
|
28
|
-
T extends object,
|
|
29
|
-
K extends keyof T & string
|
|
30
|
-
>(target: T, key: K, descriptor: PropertyDescriptor): PropertyDescriptor;
|
|
31
|
-
export declare function gate<
|
|
32
|
-
T extends object,
|
|
33
|
-
K extends keyof T & string
|
|
34
|
-
>(_target: T, key: K, desc: PropertyDescriptor): PropertyDescriptor;
|
|
35
|
-
export declare function defineGate<T extends object>(obj: T, key: string, desc: PropertyDescriptor): void;
|
|
@@ -1,277 +0,0 @@
|
|
|
1
|
-
import type { Future } from "../../../request.js";
|
|
2
|
-
import type { ImmutableRequestInfo, ResponseInfo, StructuredErrorDocument } from "../../../types/request.js";
|
|
3
|
-
import type { PendingPromise, RejectedPromise, ResolvedPromise } from "./promise-state.js";
|
|
4
|
-
/**
|
|
5
|
-
* Lazily consumes the stream of a request, providing a number of
|
|
6
|
-
* reactive properties that can be used to build UIs that respond
|
|
7
|
-
* to the progress of a request.
|
|
8
|
-
*
|
|
9
|
-
*/
|
|
10
|
-
export declare class RequestLoadingState {
|
|
11
|
-
private _sizeHint;
|
|
12
|
-
private _bytesLoaded;
|
|
13
|
-
private _startTime;
|
|
14
|
-
private _endTime;
|
|
15
|
-
private _lastPacketTime;
|
|
16
|
-
private _isPending;
|
|
17
|
-
private _isStarted;
|
|
18
|
-
private _isComplete;
|
|
19
|
-
private _isCancelled;
|
|
20
|
-
private _isErrored;
|
|
21
|
-
private _error;
|
|
22
|
-
private _stream;
|
|
23
|
-
private _future;
|
|
24
|
-
private _triggered;
|
|
25
|
-
private _trigger;
|
|
26
|
-
promise: Promise<void> | null;
|
|
27
|
-
get isPending(): boolean;
|
|
28
|
-
get sizeHint(): number;
|
|
29
|
-
get stream(): ReadableStream | null;
|
|
30
|
-
get isStarted(): boolean;
|
|
31
|
-
get bytesLoaded(): number;
|
|
32
|
-
get startTime(): number;
|
|
33
|
-
get endTime(): number;
|
|
34
|
-
get lastPacketTime(): number;
|
|
35
|
-
get isComplete(): boolean;
|
|
36
|
-
get isCancelled(): boolean;
|
|
37
|
-
get isErrored(): boolean;
|
|
38
|
-
get error(): Error | null;
|
|
39
|
-
get elapsedTime(): number;
|
|
40
|
-
get completedRatio(): number;
|
|
41
|
-
get remainingRatio(): number;
|
|
42
|
-
get duration(): number;
|
|
43
|
-
get speed(): number;
|
|
44
|
-
constructor(future: Future<unknown>);
|
|
45
|
-
abort: () => void;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* The state of a request in the "pending"
|
|
49
|
-
* state. This is the default initial state.
|
|
50
|
-
*
|
|
51
|
-
* Extends the {@link PendingPromise} interface.
|
|
52
|
-
*
|
|
53
|
-
*/
|
|
54
|
-
export interface PendingRequest extends PendingPromise {
|
|
55
|
-
/**
|
|
56
|
-
* Whether the request is cancelled.
|
|
57
|
-
*
|
|
58
|
-
*/
|
|
59
|
-
isCancelled: false;
|
|
60
|
-
loadingState: RequestLoadingState;
|
|
61
|
-
request: null;
|
|
62
|
-
response: null;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* The state of a request in the "fulfilled" state.
|
|
66
|
-
* This is the state of a request that has resolved
|
|
67
|
-
* successfully.
|
|
68
|
-
*
|
|
69
|
-
* Extends the {@link ResolvedPromise} interface.
|
|
70
|
-
*
|
|
71
|
-
*/
|
|
72
|
-
export interface ResolvedRequest<
|
|
73
|
-
RT,
|
|
74
|
-
T
|
|
75
|
-
> extends ResolvedPromise<RT> {
|
|
76
|
-
/**
|
|
77
|
-
* Whether the request is cancelled.
|
|
78
|
-
*
|
|
79
|
-
*/
|
|
80
|
-
isCancelled: false;
|
|
81
|
-
loadingState: RequestLoadingState;
|
|
82
|
-
request: ImmutableRequestInfo<RT, T> | null;
|
|
83
|
-
response: Response | ResponseInfo | null;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* The state of a request in the "rejected" state.
|
|
87
|
-
* This is the state of a request that has rejected
|
|
88
|
-
* with an error.
|
|
89
|
-
*
|
|
90
|
-
* Extends the {@link RejectedPromise} interface.
|
|
91
|
-
*
|
|
92
|
-
*/
|
|
93
|
-
export interface RejectedRequest<
|
|
94
|
-
RT,
|
|
95
|
-
T,
|
|
96
|
-
E extends StructuredErrorDocument = StructuredErrorDocument
|
|
97
|
-
> extends RejectedPromise<E> {
|
|
98
|
-
/**
|
|
99
|
-
* Whether the request is cancelled.
|
|
100
|
-
*
|
|
101
|
-
*/
|
|
102
|
-
isCancelled: false;
|
|
103
|
-
loadingState: RequestLoadingState;
|
|
104
|
-
request: ImmutableRequestInfo<RT, T> | null;
|
|
105
|
-
response: Response | ResponseInfo | null;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* The state of a request in the "cancelled" state.
|
|
109
|
-
* This is the state of a promise that has been
|
|
110
|
-
* cancelled.
|
|
111
|
-
*
|
|
112
|
-
*/
|
|
113
|
-
export interface CancelledRequest<
|
|
114
|
-
RT,
|
|
115
|
-
T,
|
|
116
|
-
E extends StructuredErrorDocument = StructuredErrorDocument
|
|
117
|
-
> {
|
|
118
|
-
/**
|
|
119
|
-
* The status of the request.
|
|
120
|
-
*
|
|
121
|
-
*/
|
|
122
|
-
status: "cancelled";
|
|
123
|
-
/**
|
|
124
|
-
* Whether the request is pending.
|
|
125
|
-
*
|
|
126
|
-
*/
|
|
127
|
-
isPending: false;
|
|
128
|
-
/**
|
|
129
|
-
* Whether the request is pending.
|
|
130
|
-
*
|
|
131
|
-
*/
|
|
132
|
-
isLoading: false;
|
|
133
|
-
/**
|
|
134
|
-
* Whether the request has resolved
|
|
135
|
-
* successfully.
|
|
136
|
-
*
|
|
137
|
-
*/
|
|
138
|
-
isSuccess: false;
|
|
139
|
-
/**
|
|
140
|
-
* Whether the request has rejected
|
|
141
|
-
* with an error.
|
|
142
|
-
*
|
|
143
|
-
*/
|
|
144
|
-
isError: true;
|
|
145
|
-
/**
|
|
146
|
-
* Once the request has resolved, this will
|
|
147
|
-
* be the value the request resolved to.
|
|
148
|
-
*
|
|
149
|
-
*/
|
|
150
|
-
value: null;
|
|
151
|
-
/**
|
|
152
|
-
* Once the request has resolved, this will
|
|
153
|
-
* be the value the request resolved to.
|
|
154
|
-
*
|
|
155
|
-
* @deprecated use `value` instead
|
|
156
|
-
*/
|
|
157
|
-
result: null;
|
|
158
|
-
/**
|
|
159
|
-
* Once the request has rejected, this will
|
|
160
|
-
* be the error the request rejected with.
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
* @deprecated use `reason` instead
|
|
164
|
-
*/
|
|
165
|
-
error: E;
|
|
166
|
-
/**
|
|
167
|
-
* Once the request has rejected, this will
|
|
168
|
-
* be the error the request rejected with.
|
|
169
|
-
*
|
|
170
|
-
*/
|
|
171
|
-
reason: E;
|
|
172
|
-
/**
|
|
173
|
-
* Whether the request is cancelled.
|
|
174
|
-
*
|
|
175
|
-
*/
|
|
176
|
-
isCancelled: true;
|
|
177
|
-
loadingState: RequestLoadingState;
|
|
178
|
-
request: ImmutableRequestInfo<RT, T> | null;
|
|
179
|
-
response: Response | ResponseInfo | null;
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* RequestState extends the concept of PromiseState to provide a reactive
|
|
183
|
-
* wrapper for a request `Future` which allows you write declarative code
|
|
184
|
-
* around a Future's control flow.
|
|
185
|
-
*
|
|
186
|
-
* It is useful in both Template and JavaScript contexts, allowing you
|
|
187
|
-
* to quickly derive behaviors and data from pending, error and success
|
|
188
|
-
* states.
|
|
189
|
-
*
|
|
190
|
-
* The key difference between a Promise and a Future is that Futures provide
|
|
191
|
-
* access to a stream of their content, the identity of the request (if any)
|
|
192
|
-
* as well as the ability to attempt to abort the request.
|
|
193
|
-
*
|
|
194
|
-
* ```ts
|
|
195
|
-
* interface Future<T> extends Promise<T>> {
|
|
196
|
-
* getStream(): Promise<ReadableStream>;
|
|
197
|
-
* abort(): void;
|
|
198
|
-
* lid: StableDocumentIdentifier | null;
|
|
199
|
-
* }
|
|
200
|
-
* ```
|
|
201
|
-
*
|
|
202
|
-
* These additional APIs allow us to craft even richer state experiences.
|
|
203
|
-
*
|
|
204
|
-
* To get the state of a request, use `getRequestState`.
|
|
205
|
-
*
|
|
206
|
-
* See also:
|
|
207
|
-
* - {@link PendingRequest}
|
|
208
|
-
* - {@link ResolvedRequest}
|
|
209
|
-
* - {@link RejectedRequest}
|
|
210
|
-
* - {@link CancelledRequest}
|
|
211
|
-
*
|
|
212
|
-
*/
|
|
213
|
-
export type RequestCacheRequestState<
|
|
214
|
-
RT = unknown,
|
|
215
|
-
T = unknown,
|
|
216
|
-
E extends StructuredErrorDocument = StructuredErrorDocument
|
|
217
|
-
> = PendingRequest | ResolvedRequest<RT, T> | RejectedRequest<RT, T, E> | CancelledRequest<RT, T, E>;
|
|
218
|
-
export declare function createRequestState<
|
|
219
|
-
RT,
|
|
220
|
-
T,
|
|
221
|
-
E
|
|
222
|
-
>(future: Future<RT>): Readonly<RequestCacheRequestState<RT, T, StructuredErrorDocument<E>>>;
|
|
223
|
-
/**
|
|
224
|
-
* `getRequestState` can be used in both JavaScript and Template contexts.
|
|
225
|
-
*
|
|
226
|
-
* ```ts
|
|
227
|
-
* import { getRequestState } from '@warp-drive/ember';
|
|
228
|
-
*
|
|
229
|
-
* const state = getRequestState(future);
|
|
230
|
-
* ```
|
|
231
|
-
*
|
|
232
|
-
* For instance, we could write a getter on a component that updates whenever
|
|
233
|
-
* the request state advances or the future changes, by combining the function
|
|
234
|
-
* with the use of `@cached`
|
|
235
|
-
*
|
|
236
|
-
* ```ts
|
|
237
|
-
* class Component {
|
|
238
|
-
* @cached
|
|
239
|
-
* get title() {
|
|
240
|
-
* const state = getRequestState(this.args.request);
|
|
241
|
-
* if (state.isPending) {
|
|
242
|
-
* return 'loading...';
|
|
243
|
-
* }
|
|
244
|
-
* if (state.isError) { return null; }
|
|
245
|
-
* return state.result.title;
|
|
246
|
-
* }
|
|
247
|
-
* }
|
|
248
|
-
* ```
|
|
249
|
-
*
|
|
250
|
-
* Or in a template as a helper:
|
|
251
|
-
*
|
|
252
|
-
* ```gjs
|
|
253
|
-
* import { getRequestState } from '@warp-drive/ember';
|
|
254
|
-
*
|
|
255
|
-
* <template>
|
|
256
|
-
* {{#let (getRequestState @request) as |state|}}
|
|
257
|
-
* {{#if state.isPending}}
|
|
258
|
-
* <Spinner />
|
|
259
|
-
* {{else if state.isError}}
|
|
260
|
-
* <ErrorForm @error={{state.error}} />
|
|
261
|
-
* {{else}}
|
|
262
|
-
* <h1>{{state.result.title}}</h1>
|
|
263
|
-
* {{/if}}
|
|
264
|
-
* {{/let}}
|
|
265
|
-
* </template>
|
|
266
|
-
* ```
|
|
267
|
-
*
|
|
268
|
-
* If looking to use in a template, consider also the `<Request />` component
|
|
269
|
-
* which offers a numbe of additional capabilities for requests *beyond* what
|
|
270
|
-
* `RequestState` provides.
|
|
271
|
-
*
|
|
272
|
-
*/
|
|
273
|
-
export declare function getRequestState<
|
|
274
|
-
RT,
|
|
275
|
-
T,
|
|
276
|
-
E
|
|
277
|
-
>(future: Future<RT>): Readonly<RequestCacheRequestState<RT, T, StructuredErrorDocument<E>>>;
|
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
import type { RequestManager, Store, StoreRequestInput } from "../../../index.js";
|
|
2
|
-
import type { Future } from "../../../request.js";
|
|
3
|
-
import type { StructuredErrorDocument } from "../../../types/request.js";
|
|
4
|
-
import type { RequestState } from "../../-private.js";
|
|
5
|
-
export declare const DISPOSE: "(symbol) dispose";
|
|
6
|
-
interface ErrorFeatures {
|
|
7
|
-
isHidden: boolean;
|
|
8
|
-
isOnline: boolean;
|
|
9
|
-
retry: () => Promise<void>;
|
|
10
|
-
}
|
|
11
|
-
type AutorefreshBehaviorType = "online" | "interval" | "invalid";
|
|
12
|
-
type AutorefreshBehaviorCombos = boolean | AutorefreshBehaviorType | `${AutorefreshBehaviorType},${AutorefreshBehaviorType}` | `${AutorefreshBehaviorType},${AutorefreshBehaviorType},${AutorefreshBehaviorType}`;
|
|
13
|
-
type ContentFeatures<RT> = {
|
|
14
|
-
isOnline: boolean;
|
|
15
|
-
isHidden: boolean;
|
|
16
|
-
isRefreshing: boolean;
|
|
17
|
-
refresh: () => Promise<void>;
|
|
18
|
-
reload: () => Promise<void>;
|
|
19
|
-
abort?: () => void;
|
|
20
|
-
latestRequest?: Future<RT>;
|
|
21
|
-
};
|
|
22
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
23
|
-
export interface SubscriptionArgs<
|
|
24
|
-
RT,
|
|
25
|
-
T,
|
|
26
|
-
E
|
|
27
|
-
> {
|
|
28
|
-
/**
|
|
29
|
-
* The request to monitor. This should be a `Future` instance returned
|
|
30
|
-
* by either the `store.request` or `store.requestManager.request` methods.
|
|
31
|
-
*
|
|
32
|
-
*/
|
|
33
|
-
request?: Future<RT>;
|
|
34
|
-
/**
|
|
35
|
-
* A query to use for the request. This should be an object that can be
|
|
36
|
-
* passed to `store.request`. Use this in place of `@request` if you would
|
|
37
|
-
* like the component to also initiate the request.
|
|
38
|
-
*
|
|
39
|
-
*/
|
|
40
|
-
query?: StoreRequestInput<RT, T>;
|
|
41
|
-
/**
|
|
42
|
-
* The autorefresh behavior for the request. This can be a boolean, or any
|
|
43
|
-
* combination of the following values: `'online'`, `'interval'`, `'invalid'`.
|
|
44
|
-
*
|
|
45
|
-
* - `'online'`: Refresh the request when the browser comes back online
|
|
46
|
-
* - `'interval'`: Refresh the request at a specified interval
|
|
47
|
-
* - `'invalid'`: Refresh the request when the store emits an invalidation
|
|
48
|
-
*
|
|
49
|
-
* If `true`, this is equivalent to `'online,invalid'`.
|
|
50
|
-
*
|
|
51
|
-
* Defaults to `false`.
|
|
52
|
-
*
|
|
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
|
-
*/
|
|
65
|
-
autorefreshThreshold?: number;
|
|
66
|
-
/**
|
|
67
|
-
* The behavior of the request initiated by autorefresh. This can be one of
|
|
68
|
-
* the following values:
|
|
69
|
-
*
|
|
70
|
-
* - `'refresh'`: Refresh the request in the background
|
|
71
|
-
* - `'reload'`: Force a reload of the request
|
|
72
|
-
* - `'policy'` (**default**): Let the store's configured CachePolicy decide whether to
|
|
73
|
-
* reload, refresh, or do nothing.
|
|
74
|
-
*
|
|
75
|
-
* Defaults to `'policy'`.
|
|
76
|
-
*
|
|
77
|
-
*/
|
|
78
|
-
autorefreshBehavior?: "refresh" | "reload" | "policy";
|
|
79
|
-
}
|
|
80
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
81
|
-
export interface RequestSubscription<
|
|
82
|
-
RT,
|
|
83
|
-
T,
|
|
84
|
-
E
|
|
85
|
-
> {
|
|
86
|
-
/**
|
|
87
|
-
* The method to call when the component this subscription is attached to
|
|
88
|
-
* unmounts.
|
|
89
|
-
*/
|
|
90
|
-
[DISPOSE](): void;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* A reactive class
|
|
94
|
-
*
|
|
95
|
-
* @hideconstructor
|
|
96
|
-
*/
|
|
97
|
-
export declare class RequestSubscription<
|
|
98
|
-
RT,
|
|
99
|
-
T,
|
|
100
|
-
E
|
|
101
|
-
> {
|
|
102
|
-
/**
|
|
103
|
-
* Whether the browser reports that the network is online.
|
|
104
|
-
*/
|
|
105
|
-
isOnline: boolean;
|
|
106
|
-
/**
|
|
107
|
-
* Whether the browser reports that the tab is hidden.
|
|
108
|
-
*/
|
|
109
|
-
isHidden: boolean;
|
|
110
|
-
/**
|
|
111
|
-
* Whether the component is currently refreshing the request.
|
|
112
|
-
*/
|
|
113
|
-
isRefreshing: boolean;
|
|
114
|
-
/**
|
|
115
|
-
* The most recent blocking request that was made, typically
|
|
116
|
-
* the result of a reload.
|
|
117
|
-
*
|
|
118
|
-
* This will never be the original request passed as an arg to
|
|
119
|
-
* the component.
|
|
120
|
-
*
|
|
121
|
-
* @internal
|
|
122
|
-
*/
|
|
123
|
-
private _localRequest;
|
|
124
|
-
/**
|
|
125
|
-
* The most recent request that was made, typically due to either a
|
|
126
|
-
* reload or a refresh.
|
|
127
|
-
*
|
|
128
|
-
* This will never be the original request passed as an arg to
|
|
129
|
-
* the component.
|
|
130
|
-
*
|
|
131
|
-
* @internal
|
|
132
|
-
*/
|
|
133
|
-
private _latestRequest;
|
|
134
|
-
/**
|
|
135
|
-
* The time at which the network was reported as offline.
|
|
136
|
-
*
|
|
137
|
-
* @internal
|
|
138
|
-
*/
|
|
139
|
-
private _unavailableStart;
|
|
140
|
-
/** @internal */
|
|
141
|
-
private _intervalStart;
|
|
142
|
-
/** @internal */
|
|
143
|
-
private _nextInterval;
|
|
144
|
-
/** @internal */
|
|
145
|
-
private _invalidated;
|
|
146
|
-
/** @internal */
|
|
147
|
-
private _isUpdating;
|
|
148
|
-
/** @internal */
|
|
149
|
-
private isDestroyed;
|
|
150
|
-
/**
|
|
151
|
-
* The event listener for network status changes,
|
|
152
|
-
* cached to use the reference for removal.
|
|
153
|
-
*
|
|
154
|
-
* @internal
|
|
155
|
-
*/
|
|
156
|
-
private _onlineChanged;
|
|
157
|
-
/**
|
|
158
|
-
* The event listener for visibility status changes,
|
|
159
|
-
* cached to use the reference for removal.
|
|
160
|
-
*
|
|
161
|
-
* @internal
|
|
162
|
-
*/
|
|
163
|
-
private _backgroundChanged;
|
|
164
|
-
/**
|
|
165
|
-
* The last request passed as an arg to the component,
|
|
166
|
-
* cached for comparison.
|
|
167
|
-
*
|
|
168
|
-
* @internal
|
|
169
|
-
*/
|
|
170
|
-
private _originalRequest;
|
|
171
|
-
/**
|
|
172
|
-
* The last query passed as an arg to the component,
|
|
173
|
-
* cached for comparison.
|
|
174
|
-
*
|
|
175
|
-
* @internal
|
|
176
|
-
*/
|
|
177
|
-
private _originalQuery;
|
|
178
|
-
/** @internal */
|
|
179
|
-
private _subscription;
|
|
180
|
-
/** @internal */
|
|
181
|
-
private _subscribedTo;
|
|
182
|
-
/** @internal */
|
|
183
|
-
private _args;
|
|
184
|
-
/** @internal */
|
|
185
|
-
store: Store | RequestManager;
|
|
186
|
-
constructor(store: Store | RequestManager, args: SubscriptionArgs<RT, T, E>);
|
|
187
|
-
/**
|
|
188
|
-
* @internal
|
|
189
|
-
*/
|
|
190
|
-
private _beginPolling;
|
|
191
|
-
get isIdle(): boolean;
|
|
192
|
-
get autorefreshTypes(): Set<AutorefreshBehaviorType>;
|
|
193
|
-
// we only run this function on component creation
|
|
194
|
-
// and when an update is triggered, so it does not
|
|
195
|
-
// react to changes in the autorefreshThreshold
|
|
196
|
-
// or autorefresh args.
|
|
197
|
-
//
|
|
198
|
-
// if we need to react to those changes, we can
|
|
199
|
-
// use a modifier or internal component or some
|
|
200
|
-
// such to trigger a re-run of this function.
|
|
201
|
-
private _scheduleInterval;
|
|
202
|
-
private _clearInterval;
|
|
203
|
-
/**
|
|
204
|
-
* @internal
|
|
205
|
-
*/
|
|
206
|
-
private _updateSubscriptions;
|
|
207
|
-
/**
|
|
208
|
-
* @internal
|
|
209
|
-
*/
|
|
210
|
-
private _removeSubscriptions;
|
|
211
|
-
/**
|
|
212
|
-
* Install the event listeners for network and visibility changes.
|
|
213
|
-
* This is only done in browser environments with a global `window`.
|
|
214
|
-
*
|
|
215
|
-
* @internal
|
|
216
|
-
*/
|
|
217
|
-
private _installListeners;
|
|
218
|
-
/**
|
|
219
|
-
* If the network is online and the tab is visible, either reload or refresh the request
|
|
220
|
-
* based on the component's configuration and the requested update mode.
|
|
221
|
-
*
|
|
222
|
-
* Valid modes are:
|
|
223
|
-
*
|
|
224
|
-
* - `'reload'`: Force a reload of the request.
|
|
225
|
-
* - `'refresh'`: Refresh the request in the background.
|
|
226
|
-
* - `'policy'`: Make the request, letting the store's configured CachePolicy decide whether to reload, refresh, or do nothing.
|
|
227
|
-
* - `undefined`: Make the request using the component's autorefreshBehavior setting if the autorefreshThreshold has passed.
|
|
228
|
-
*
|
|
229
|
-
* @internal
|
|
230
|
-
*/
|
|
231
|
-
private _maybeUpdate;
|
|
232
|
-
/**
|
|
233
|
-
* Retry the request, reloading it from the server.
|
|
234
|
-
*/
|
|
235
|
-
retry: () => Promise<void>;
|
|
236
|
-
/**
|
|
237
|
-
* Refresh the request, updating it in the background.
|
|
238
|
-
*/
|
|
239
|
-
refresh: () => Promise<void>;
|
|
240
|
-
/**
|
|
241
|
-
* features to yield to the error slot of a component
|
|
242
|
-
*/
|
|
243
|
-
get errorFeatures(): ErrorFeatures;
|
|
244
|
-
/**
|
|
245
|
-
* features to yield to the content slot of a component
|
|
246
|
-
*/
|
|
247
|
-
get contentFeatures(): ContentFeatures<RT>;
|
|
248
|
-
/**
|
|
249
|
-
* @internal
|
|
250
|
-
*/
|
|
251
|
-
get _request(): Future<RT>;
|
|
252
|
-
get request(): Future<RT>;
|
|
253
|
-
get reqState(): RequestState<RT, T, StructuredErrorDocument<E>>;
|
|
254
|
-
get result(): RT;
|
|
255
|
-
}
|
|
256
|
-
export declare function createRequestSubscription<
|
|
257
|
-
RT,
|
|
258
|
-
T,
|
|
259
|
-
E
|
|
260
|
-
>(store: Store | RequestManager, args: SubscriptionArgs<RT, T, E>): RequestSubscription<RT, T, E>;
|
|
261
|
-
export {};
|