@warp-drive/core 5.9.0-beta.1 → 5.9.0-beta.2
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/dist/{unpkg/dev-deprecated/-private-DL4tfrv9.js → -private-BYn1Vh-L.js} +2 -2
- package/dist/{-private-b1g4dhl0.js.map → -private-BYn1Vh-L.js.map} +1 -1
- package/dist/{-private-DMzvF_Q6.js → -private-CyhhcK1a.js} +2 -2
- package/dist/-private-CyhhcK1a.js.map +1 -0
- package/dist/-private-zrP4VGAf.js +3530 -0
- package/dist/-private-zrP4VGAf.js.map +1 -0
- package/{declarations/concepts-LHsLJZMl.d.ts → dist/concepts-DFldVwEM.d.ts} +2 -2
- package/{declarations/concepts-LHsLJZMl.d.ts.map → dist/concepts-DFldVwEM.d.ts.map} +1 -1
- package/dist/configure.js +1 -1
- package/dist/graph/-private.d.ts +2 -0
- package/dist/graph/-private.js +46 -33
- package/dist/graph/-private.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -1
- package/{declarations/internal-Cz-893zD.d.ts → dist/internal-DtWOpxrR.d.ts} +2763 -2271
- package/dist/internal-DtWOpxrR.d.ts.map +1 -0
- package/dist/reactive/-private.d.ts +2 -0
- package/dist/reactive/-private.js +1 -1
- package/dist/reactive.d.ts +2 -0
- package/dist/reactive.js +3 -3
- package/{declarations → dist}/record-D3QQcaIR.d.ts.map +1 -1
- package/dist/{request--vRFALbQ.js → request-7BJFgSu_.js} +2 -2
- package/dist/request-7BJFgSu_.js.map +1 -0
- package/dist/request.d.ts +2 -0
- package/dist/request.js +1 -1
- package/dist/signals/-leaked.d.ts +1060 -0
- package/dist/signals/-leaked.d.ts.map +1 -0
- package/dist/signals/-leaked.js +2 -2
- package/dist/{src-Dex_phWI.js → src-BOAWJH_S.js} +192 -53
- package/dist/src-BOAWJH_S.js.map +1 -0
- package/dist/store/-private.d.ts +2 -0
- package/dist/store/-private.js +1 -1
- package/dist/store-DNF9Rgoh.js.map +1 -1
- package/dist/store.d.ts +2 -0
- package/{declarations → dist}/types/-private.d.ts +1 -1
- package/{declarations → dist}/types/-private.d.ts.map +1 -1
- package/dist/types/-private.js +1 -1
- package/dist/types/cache.d.ts +2 -0
- package/dist/types/record.js.map +1 -1
- package/dist/types/request.d.ts +2 -0
- package/dist/types/request.js +1 -1
- package/dist/types/request.js.map +1 -1
- package/dist/types/runtime.js +1 -1
- package/dist/types/schema/concepts.d.ts +2 -0
- package/dist/types/schema/fields.js.map +1 -1
- package/dist/types/schema/schema-service.d.ts +2 -0
- package/dist/types/symbols.js +1 -1
- package/dist/types/symbols.js.map +1 -1
- package/{declarations → dist}/types.d.ts +1 -1
- package/dist/unpkg/dev/-private-BoSTJwp9.js +3519 -0
- package/dist/unpkg/dev/-private-BoSTJwp9.js.map +1 -0
- package/dist/{-private-b1g4dhl0.js → unpkg/dev/-private-CUkeqUhO.js} +2 -2
- package/dist/unpkg/{dev-deprecated/-private-DL4tfrv9.js.map → dev/-private-CUkeqUhO.js.map} +1 -1
- package/dist/unpkg/{dev-deprecated/-private-2RfQ2761.js → dev/-private-D6Tw25AD.js} +2 -2
- package/dist/unpkg/dev/-private-D6Tw25AD.js.map +1 -0
- package/dist/unpkg/dev/configure.js +1 -1
- package/dist/unpkg/dev/graph/-private.js +46 -33
- package/dist/unpkg/dev/graph/-private.js.map +1 -1
- package/dist/unpkg/dev/index.js +1 -1
- package/dist/unpkg/dev/reactive/-private.js +1 -1
- package/dist/unpkg/dev/reactive.js +3 -3
- package/dist/unpkg/{dev-deprecated/request-DAuXbfYi.js → dev/request-CwjpJB3r.js} +2 -2
- package/dist/unpkg/dev/request-CwjpJB3r.js.map +1 -0
- package/dist/unpkg/dev/request.js +1 -1
- package/dist/unpkg/dev/{runtime-EoVKAhTv.js → runtime-DoDtzXJb.js} +2 -2
- package/dist/unpkg/dev/runtime-DoDtzXJb.js.map +1 -0
- package/dist/unpkg/dev/signals/-leaked.js +2 -2
- package/dist/unpkg/dev/{src-Bxlr_vue.js → src-CP6e_ozt.js} +194 -55
- package/dist/unpkg/dev/src-CP6e_ozt.js.map +1 -0
- package/dist/unpkg/dev/store/-private.js +1 -1
- package/dist/unpkg/{dev-deprecated/store-TcP2H4Af.js → dev/store-DamE3C4y.js} +2 -2
- package/dist/unpkg/dev/store-DamE3C4y.js.map +1 -0
- package/dist/unpkg/dev/store.js +1 -1
- package/dist/unpkg/dev/types/-private.js +1 -1
- package/dist/unpkg/dev/types/record.js.map +1 -1
- package/dist/unpkg/dev/types/request.js +1 -1
- package/dist/unpkg/dev/types/request.js.map +1 -1
- package/dist/unpkg/dev/types/runtime.js +1 -1
- package/dist/unpkg/dev/types/schema/fields.js.map +1 -1
- package/dist/unpkg/dev/types/symbols.js +1 -1
- package/dist/unpkg/dev/types/symbols.js.map +1 -1
- package/dist/unpkg/dev-deprecated/-private-BoSTJwp9.js +3519 -0
- package/dist/unpkg/dev-deprecated/-private-BoSTJwp9.js.map +1 -0
- package/dist/unpkg/{dev/-private-DL4tfrv9.js → dev-deprecated/-private-CUkeqUhO.js} +2 -2
- package/dist/unpkg/{prod/-private-Z9i0icpE.js.map → dev-deprecated/-private-CUkeqUhO.js.map} +1 -1
- package/dist/unpkg/{dev/-private-2RfQ2761.js → dev-deprecated/-private-D6Tw25AD.js} +2 -2
- package/dist/unpkg/dev-deprecated/-private-D6Tw25AD.js.map +1 -0
- package/dist/unpkg/dev-deprecated/configure.js +1 -1
- package/dist/unpkg/dev-deprecated/graph/-private.js +47 -34
- package/dist/unpkg/dev-deprecated/graph/-private.js.map +1 -1
- package/dist/unpkg/dev-deprecated/index.js +1 -1
- package/dist/unpkg/dev-deprecated/reactive/-private.js +1 -1
- package/dist/unpkg/dev-deprecated/reactive.js +3 -3
- package/dist/unpkg/{dev/request-DAuXbfYi.js → dev-deprecated/request-CwjpJB3r.js} +2 -2
- package/dist/unpkg/dev-deprecated/request-CwjpJB3r.js.map +1 -0
- package/dist/unpkg/dev-deprecated/request.js +1 -1
- package/dist/unpkg/dev-deprecated/{runtime-BacZMq1r.js → runtime-CPL2BGgT.js} +2 -2
- package/dist/unpkg/dev-deprecated/runtime-CPL2BGgT.js.map +1 -0
- package/dist/unpkg/dev-deprecated/signals/-leaked.js +2 -2
- package/dist/unpkg/dev-deprecated/{src-DEl2Ca3T.js → src-De8OV58h.js} +195 -56
- package/dist/unpkg/dev-deprecated/src-De8OV58h.js.map +1 -0
- package/dist/unpkg/dev-deprecated/store/-private.js +1 -1
- package/dist/unpkg/{dev/store-DmiFvT1B.js → dev-deprecated/store-Bsdz5mRe.js} +2 -2
- package/dist/unpkg/dev-deprecated/store-Bsdz5mRe.js.map +1 -0
- package/dist/unpkg/dev-deprecated/store.js +1 -1
- package/dist/unpkg/dev-deprecated/types/-private.js +1 -1
- package/dist/unpkg/dev-deprecated/types/record.js.map +1 -1
- package/dist/unpkg/dev-deprecated/types/request.js +1 -1
- package/dist/unpkg/dev-deprecated/types/request.js.map +1 -1
- package/dist/unpkg/dev-deprecated/types/runtime.js +1 -1
- package/dist/unpkg/dev-deprecated/types/schema/fields.js.map +1 -1
- package/dist/unpkg/dev-deprecated/types/symbols.js +1 -1
- package/dist/unpkg/dev-deprecated/types/symbols.js.map +1 -1
- package/dist/unpkg/prod/-private-B36B1ztP.js +22 -0
- package/dist/unpkg/{prod-deprecated/-private-Z9i0icpE.js.map → prod/-private-B36B1ztP.js.map} +1 -1
- package/dist/unpkg/prod/-private-DHco-h0q.js +3294 -0
- package/dist/unpkg/prod/-private-DHco-h0q.js.map +1 -0
- package/dist/unpkg/prod/{-private-BK71-uXR.js → -private-Dhl123OI.js} +2 -2
- package/dist/unpkg/prod/-private-Dhl123OI.js.map +1 -0
- package/dist/unpkg/prod/configure.js +1 -1
- package/dist/unpkg/prod/graph/-private.js +45 -32
- package/dist/unpkg/prod/graph/-private.js.map +1 -1
- package/dist/unpkg/prod/index.js +1 -1
- package/dist/unpkg/prod/reactive/-private.js +1 -1
- package/dist/unpkg/prod/reactive.js +3 -3
- package/dist/unpkg/prod/{request-BcJNzSgv.js → request-BBdC1Sz7.js} +2 -2
- package/dist/unpkg/prod/request-BBdC1Sz7.js.map +1 -0
- package/dist/unpkg/prod/request.js +1 -1
- package/dist/unpkg/prod/signals/-leaked.js +2 -2
- package/dist/unpkg/prod/{src-Dzz-j6pp.js → src-nFHlZgKa.js} +196 -53
- package/dist/unpkg/prod/src-nFHlZgKa.js.map +1 -0
- package/dist/unpkg/prod/store/-private.js +1 -1
- package/dist/unpkg/prod/store-BWhmb7Ob.js.map +1 -1
- package/dist/unpkg/prod/types/-private.js +1 -1
- package/dist/unpkg/prod/types/record.js.map +1 -1
- package/dist/unpkg/prod/types/request.js +1 -1
- package/dist/unpkg/prod/types/request.js.map +1 -1
- package/dist/unpkg/prod/types/runtime.js +1 -1
- package/dist/unpkg/prod/types/schema/fields.js.map +1 -1
- package/dist/unpkg/prod/types/symbols.js +1 -1
- package/dist/unpkg/prod/types/symbols.js.map +1 -1
- package/dist/unpkg/prod-deprecated/{-private-Z9i0icpE.js → -private-B36B1ztP.js} +2 -2
- package/dist/unpkg/{dev/-private-DL4tfrv9.js.map → prod-deprecated/-private-B36B1ztP.js.map} +1 -1
- package/dist/unpkg/prod-deprecated/-private-DHco-h0q.js +3294 -0
- package/dist/unpkg/prod-deprecated/-private-DHco-h0q.js.map +1 -0
- package/dist/unpkg/prod-deprecated/{-private-BK71-uXR.js → -private-Dhl123OI.js} +2 -2
- package/dist/unpkg/prod-deprecated/-private-Dhl123OI.js.map +1 -0
- package/dist/unpkg/prod-deprecated/configure.js +1 -1
- package/dist/unpkg/prod-deprecated/graph/-private.js +46 -35
- package/dist/unpkg/prod-deprecated/graph/-private.js.map +1 -1
- package/dist/unpkg/prod-deprecated/index.js +1 -1
- package/dist/unpkg/prod-deprecated/reactive/-private.js +1 -1
- package/dist/unpkg/prod-deprecated/reactive.js +3 -3
- package/dist/unpkg/prod-deprecated/{request-BcJNzSgv.js → request-BBdC1Sz7.js} +2 -2
- package/dist/unpkg/prod-deprecated/request-BBdC1Sz7.js.map +1 -0
- package/dist/unpkg/prod-deprecated/request.js +1 -1
- package/dist/unpkg/prod-deprecated/signals/-leaked.js +2 -2
- package/dist/unpkg/prod-deprecated/{src-BOifHFQ5.js → src-Cku5ymUJ.js} +197 -54
- package/dist/unpkg/prod-deprecated/src-Cku5ymUJ.js.map +1 -0
- package/dist/unpkg/prod-deprecated/store/-private.js +1 -1
- package/dist/unpkg/prod-deprecated/store-BWhmb7Ob.js.map +1 -1
- package/dist/unpkg/prod-deprecated/types/-private.js +1 -1
- package/dist/unpkg/prod-deprecated/types/record.js.map +1 -1
- package/dist/unpkg/prod-deprecated/types/request.js +1 -1
- package/dist/unpkg/prod-deprecated/types/request.js.map +1 -1
- package/dist/unpkg/prod-deprecated/types/runtime.js +1 -1
- package/dist/unpkg/prod-deprecated/types/schema/fields.js.map +1 -1
- package/dist/unpkg/prod-deprecated/types/symbols.js +1 -1
- package/dist/unpkg/prod-deprecated/types/symbols.js.map +1 -1
- package/package.json +15 -19
- package/declarations/graph/-private.d.ts +0 -2
- package/declarations/index.d.ts +0 -2
- package/declarations/internal-Cz-893zD.d.ts.map +0 -1
- package/declarations/reactive/-private.d.ts +0 -2
- package/declarations/reactive.d.ts +0 -2
- package/declarations/request.d.ts +0 -2
- package/declarations/signals/-leaked.d.ts +0 -63
- package/declarations/signals/-leaked.d.ts.map +0 -1
- package/declarations/store/-private.d.ts +0 -2
- package/declarations/store.d.ts +0 -8358
- package/declarations/store.d.ts.map +0 -1
- package/declarations/types/cache.d.ts +0 -2
- package/declarations/types/request.d.ts +0 -2
- package/declarations/types/schema/concepts.d.ts +0 -2
- package/declarations/types/schema/schema-service.d.ts +0 -2
- package/dist/-private-DMzvF_Q6.js.map +0 -1
- package/dist/-private-HjaQ1wp1.js +0 -1695
- package/dist/-private-HjaQ1wp1.js.map +0 -1
- package/dist/request--vRFALbQ.js.map +0 -1
- package/dist/src-Dex_phWI.js.map +0 -1
- package/dist/unpkg/dev/-private-2RfQ2761.js.map +0 -1
- package/dist/unpkg/dev/-private-CM1zxNws.js +0 -1684
- package/dist/unpkg/dev/-private-CM1zxNws.js.map +0 -1
- package/dist/unpkg/dev/request-DAuXbfYi.js.map +0 -1
- package/dist/unpkg/dev/runtime-EoVKAhTv.js.map +0 -1
- package/dist/unpkg/dev/src-Bxlr_vue.js.map +0 -1
- package/dist/unpkg/dev/store-DmiFvT1B.js.map +0 -1
- package/dist/unpkg/dev-deprecated/-private-2RfQ2761.js.map +0 -1
- package/dist/unpkg/dev-deprecated/-private-CM1zxNws.js +0 -1684
- package/dist/unpkg/dev-deprecated/-private-CM1zxNws.js.map +0 -1
- package/dist/unpkg/dev-deprecated/request-DAuXbfYi.js.map +0 -1
- package/dist/unpkg/dev-deprecated/runtime-BacZMq1r.js.map +0 -1
- package/dist/unpkg/dev-deprecated/src-DEl2Ca3T.js.map +0 -1
- package/dist/unpkg/dev-deprecated/store-TcP2H4Af.js.map +0 -1
- package/dist/unpkg/prod/-private-BK71-uXR.js.map +0 -1
- package/dist/unpkg/prod/-private-TNaS5Piv.js +0 -1494
- package/dist/unpkg/prod/-private-TNaS5Piv.js.map +0 -1
- package/dist/unpkg/prod/-private-Z9i0icpE.js +0 -22
- package/dist/unpkg/prod/request-BcJNzSgv.js.map +0 -1
- package/dist/unpkg/prod/src-Dzz-j6pp.js.map +0 -1
- package/dist/unpkg/prod-deprecated/-private-BK71-uXR.js.map +0 -1
- package/dist/unpkg/prod-deprecated/-private-TNaS5Piv.js +0 -1494
- package/dist/unpkg/prod-deprecated/-private-TNaS5Piv.js.map +0 -1
- package/dist/unpkg/prod-deprecated/request-BcJNzSgv.js.map +0 -1
- package/dist/unpkg/prod-deprecated/src-BOifHFQ5.js.map +0 -1
- /package/{declarations → dist}/aliases-BWYW5EhX.d.ts +0 -0
- /package/{declarations → dist}/aliases-BWYW5EhX.d.ts.map +0 -0
- /package/{declarations → dist}/build-config/babel-macros.d.ts +0 -0
- /package/{declarations → dist}/build-config/canary-features.d.ts +0 -0
- /package/{declarations → dist}/build-config/debugging.d.ts +0 -0
- /package/{declarations → dist}/build-config/deprecations.d.ts +0 -0
- /package/{declarations → dist}/build-config/env.d.ts +0 -0
- /package/{declarations → dist}/build-config/macros.d.ts +0 -0
- /package/{declarations → dist}/build-config.d.ts +0 -0
- /package/{declarations → dist}/change-C7kqv2kW.d.ts +0 -0
- /package/{declarations → dist}/change-C7kqv2kW.d.ts.map +0 -0
- /package/{declarations → dist}/configure-B_F639tN.d.ts +0 -0
- /package/{declarations → dist}/configure-B_F639tN.d.ts.map +0 -0
- /package/{declarations → dist}/configure.d.ts +0 -0
- /package/{declarations → dist}/document-BEn91SwT.d.ts +0 -0
- /package/{declarations → dist}/document-BEn91SwT.d.ts.map +0 -0
- /package/{declarations → dist}/error-50OSEhsF.d.ts +0 -0
- /package/{declarations → dist}/error-50OSEhsF.d.ts.map +0 -0
- /package/{declarations → dist}/fields-FM7peCiM.d.ts +0 -0
- /package/{declarations → dist}/fields-FM7peCiM.d.ts.map +0 -0
- /package/{declarations → dist}/graph-DLqYXP2z.d.ts +0 -0
- /package/{declarations → dist}/graph-DLqYXP2z.d.ts.map +0 -0
- /package/{declarations → dist}/identifier-DQnqOSJK.d.ts +0 -0
- /package/{declarations → dist}/identifier-DQnqOSJK.d.ts.map +0 -0
- /package/{declarations → dist}/json-api-raw-C5APJHHB.d.ts +0 -0
- /package/{declarations → dist}/json-api-raw-C5APJHHB.d.ts.map +0 -0
- /package/{declarations → dist}/mutations-CqtoGB4t.d.ts +0 -0
- /package/{declarations → dist}/mutations-CqtoGB4t.d.ts.map +0 -0
- /package/{declarations → dist}/operations-D1qA6r0_.d.ts +0 -0
- /package/{declarations → dist}/operations-D1qA6r0_.d.ts.map +0 -0
- /package/{declarations → dist}/params-DrEx3bf8.d.ts +0 -0
- /package/{declarations → dist}/params-DrEx3bf8.d.ts.map +0 -0
- /package/{declarations → dist}/raw-D5hnjiq7.d.ts +0 -0
- /package/{declarations → dist}/raw-D5hnjiq7.d.ts.map +0 -0
- /package/{declarations → dist}/record-D3QQcaIR.d.ts +0 -0
- /package/{declarations → dist}/relationship-CmHzMPKf.d.ts +0 -0
- /package/{declarations → dist}/relationship-CmHzMPKf.d.ts.map +0 -0
- /package/{declarations → dist}/symbols-DjRDCeX0.d.ts +0 -0
- /package/{declarations → dist}/symbols-DjRDCeX0.d.ts.map +0 -0
- /package/{declarations → dist}/types/cache/aliases.d.ts +0 -0
- /package/{declarations → dist}/types/cache/change.d.ts +0 -0
- /package/{declarations → dist}/types/cache/mutations.d.ts +0 -0
- /package/{declarations → dist}/types/cache/operations.d.ts +0 -0
- /package/{declarations → dist}/types/cache/relationship.d.ts +0 -0
- /package/{declarations → dist}/types/graph.d.ts +0 -0
- /package/{declarations → dist}/types/identifier.d.ts +0 -0
- /package/{declarations → dist}/types/json/raw.d.ts +0 -0
- /package/{declarations → dist}/types/params.d.ts +0 -0
- /package/{declarations → dist}/types/record.d.ts +0 -0
- /package/{declarations → dist}/types/runtime.d.ts +0 -0
- /package/{declarations → dist}/types/runtime.d.ts.map +0 -0
- /package/{declarations → dist}/types/schema/fields.d.ts +0 -0
- /package/{declarations → dist}/types/schema/fields.type-test.d.ts +0 -0
- /package/{declarations → dist}/types/spec/document.d.ts +0 -0
- /package/{declarations → dist}/types/spec/error.d.ts +0 -0
- /package/{declarations → dist}/types/spec/json-api-raw.d.ts +0 -0
- /package/{declarations → dist}/types/symbols.d.ts +0 -0
- /package/{declarations → dist}/types/utils.d.ts +0 -0
- /package/{declarations → dist}/utils/string.d.ts +0 -0
- /package/{declarations → dist}/utils/string.d.ts.map +0 -0
- /package/{declarations → dist}/utils-BtURiy8l.d.ts +0 -0
- /package/{declarations → dist}/utils-BtURiy8l.d.ts.map +0 -0
|
@@ -1,1494 +0,0 @@
|
|
|
1
|
-
import { a as setTransient, r as peekTransient, t as getOrSetGlobal } from "./-private-BK71-uXR.js";
|
|
2
|
-
import { f as setPromiseResult, o as DOMError, u as getPromiseResult } from "./request-BcJNzSgv.js";
|
|
3
|
-
|
|
4
|
-
//#region src/signals/reactivity/configure.ts
|
|
5
|
-
const ARRAY_SIGNAL = getOrSetGlobal("#[]", Symbol("#[]"));
|
|
6
|
-
const OBJECT_SIGNAL = getOrSetGlobal("#{}", Symbol("#{}"));
|
|
7
|
-
/**
|
|
8
|
-
* An Opaque type that represents a framework specific or TC39 signal.
|
|
9
|
-
*
|
|
10
|
-
* It may be an array of signals or a single signal.
|
|
11
|
-
*
|
|
12
|
-
* @private
|
|
13
|
-
*/
|
|
14
|
-
/**
|
|
15
|
-
* The hooks which MUST be configured in order to use reactive arrays,
|
|
16
|
-
* resources and documents with framework specfic signals or TC39 signals.
|
|
17
|
-
*
|
|
18
|
-
* Support for multiple frameworks simultaneously can be done via
|
|
19
|
-
* this abstraction by returning multiple signals from the `createSignal`
|
|
20
|
-
* method, and consuming the correct one via the correct framework via
|
|
21
|
-
* the `consumeSignal` and `notifySignal` methods.
|
|
22
|
-
*
|
|
23
|
-
* Unlike many signals implementations, WarpDrive does not wrap values as
|
|
24
|
-
* signals directly, but instead uses signals to alert the reactive layer
|
|
25
|
-
* to changes in the underlying cache. E.g. a signal is associated to a value,
|
|
26
|
-
* but does not serve as the cache for that value directly. We refer to this as
|
|
27
|
-
* a "gate", the pattern has also been called "side-signals".
|
|
28
|
-
*
|
|
29
|
-
* A no-op implementation is allowed, though it may lead to performance issues
|
|
30
|
-
* in locations that use createMemo as no memoization would be done. This is
|
|
31
|
-
* typically desirable only when integrating with a framework that does its own
|
|
32
|
-
* memoization and does not integrate with any signals-like primitive. For these
|
|
33
|
-
* scenarios you may also be interested in integrating with the {@link NotificationManager}
|
|
34
|
-
* more directly.
|
|
35
|
-
*
|
|
36
|
-
* @public
|
|
37
|
-
*/
|
|
38
|
-
/**
|
|
39
|
-
* Contains information a {@link SignalHooks} implementation may want
|
|
40
|
-
* to use, such as the specialized key used for the signal
|
|
41
|
-
* representing an array's contents / length.
|
|
42
|
-
*
|
|
43
|
-
* ```ts
|
|
44
|
-
* interface HooksOptions {
|
|
45
|
-
* wellknown: {
|
|
46
|
-
* Array: symbol | string;
|
|
47
|
-
* }
|
|
48
|
-
* }
|
|
49
|
-
* ```
|
|
50
|
-
*
|
|
51
|
-
* @public
|
|
52
|
-
*/
|
|
53
|
-
/**
|
|
54
|
-
* Configures the signals implementation to use. Supports multiple
|
|
55
|
-
* implementations simultaneously.
|
|
56
|
-
*
|
|
57
|
-
* See {@link HooksOptions} for the options passed to the provided function
|
|
58
|
-
* when called.
|
|
59
|
-
*
|
|
60
|
-
* See {@link SignalHooks} for the implementation the callback function should
|
|
61
|
-
* return.
|
|
62
|
-
*
|
|
63
|
-
* @public
|
|
64
|
-
* @param buildConfig - a function that takes options and returns a configuration object
|
|
65
|
-
*/
|
|
66
|
-
function setupSignals(buildConfig) {
|
|
67
|
-
const hooks = buildConfig({ wellknown: { Array: ARRAY_SIGNAL } });
|
|
68
|
-
setTransient("signalHooks", hooks);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Internal method for consuming the configured `createSignal` hook
|
|
72
|
-
*
|
|
73
|
-
* @private
|
|
74
|
-
*/
|
|
75
|
-
function createSignal(obj, key) {
|
|
76
|
-
return peekTransient("signalHooks").createSignal(obj, key);
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Internal method for consuming the configured `consumeSignal` hook
|
|
80
|
-
*
|
|
81
|
-
* @private
|
|
82
|
-
*/
|
|
83
|
-
function consumeSignal(signal) {
|
|
84
|
-
return peekTransient("signalHooks").consumeSignal(signal);
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Internal method for consuming the configured `notifySignal` hook
|
|
88
|
-
*
|
|
89
|
-
* @private
|
|
90
|
-
*/
|
|
91
|
-
function notifySignal(signal) {
|
|
92
|
-
return peekTransient("signalHooks").notifySignal(signal);
|
|
93
|
-
}
|
|
94
|
-
function createMemo(object, key, fn) {
|
|
95
|
-
return peekTransient("signalHooks").createMemo(object, key, fn);
|
|
96
|
-
}
|
|
97
|
-
function willSyncFlushWatchers() {
|
|
98
|
-
return peekTransient("signalHooks").willSyncFlushWatchers();
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Wraps `promise` using the configured {@link SignalHooks.waitFor}, if any,
|
|
102
|
-
* for things like test-waiters. Returns `promise` unchanged if no
|
|
103
|
-
* `waitFor` hook is configured.
|
|
104
|
-
*/
|
|
105
|
-
function waitFor(promise) {
|
|
106
|
-
const signalHooks = peekTransient("signalHooks");
|
|
107
|
-
if (signalHooks?.waitFor) return signalHooks.waitFor(promise);
|
|
108
|
-
return promise;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
//#endregion
|
|
112
|
-
//#region src/signals/reactivity/internal.ts
|
|
113
|
-
const INITIALIZER_PROTO = { isInitializer: true };
|
|
114
|
-
/**
|
|
115
|
-
* Wraps `fn` so that a signal can recognize it as a lazy initializer
|
|
116
|
-
* for its value rather than the value itself, deferring the call to
|
|
117
|
-
* `fn` until the signal is first accessed.
|
|
118
|
-
*/
|
|
119
|
-
function makeInitializer(fn) {
|
|
120
|
-
return Object.assign(Object.create(INITIALIZER_PROTO), { value: fn });
|
|
121
|
-
}
|
|
122
|
-
function isInitializer(obj) {
|
|
123
|
-
return typeof obj === "object" && obj !== null && Object.getPrototypeOf(obj) === INITIALIZER_PROTO;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* A WarpDriveSignal is a wrapper around a framework specific or TC39 signal
|
|
127
|
-
* that enables us to store and manage the signal in a universal way.
|
|
128
|
-
*
|
|
129
|
-
* WarpDrive uses signals to manage three separate concepts:
|
|
130
|
-
*
|
|
131
|
-
* - as a `storage` for a value local to the object that we want to be reactive
|
|
132
|
-
* (see `@local` schema field for an example)
|
|
133
|
-
* - as a `gate` for a memoized getter that we want to act as a reactive property
|
|
134
|
-
* but whose value is computed/pulled from a non-reactive source elsewhere
|
|
135
|
-
* and whose latest value is stored in the signal
|
|
136
|
-
* (see `field` schema field for an example)
|
|
137
|
-
* - as a `gate` with a manually managed value updated on pull when `isStale` is true
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
* It offers
|
|
141
|
-
*
|
|
142
|
-
* - a non-reactive way to access/update the current value
|
|
143
|
-
* - a non-reactive way to mark the signal as dirtied
|
|
144
|
-
* - a non-reactive way to store content for why the signal was dirtied
|
|
145
|
-
* - access to the underlying Signal(s) in-use
|
|
146
|
-
*
|
|
147
|
-
* For debugging:
|
|
148
|
-
* - the "key" or "name" of the signal
|
|
149
|
-
* - the "object identity" or "context" to which the signal is attached
|
|
150
|
-
*
|
|
151
|
-
* @private
|
|
152
|
-
*/
|
|
153
|
-
/**
|
|
154
|
-
* We attach signals to their context object via
|
|
155
|
-
* a Map attached to the object via this symbol.
|
|
156
|
-
*
|
|
157
|
-
* This allows us to store multiple signals
|
|
158
|
-
* on the same object with smaller memory
|
|
159
|
-
* overhead and no WeakMap lookups.
|
|
160
|
-
*
|
|
161
|
-
* Performance sensitive objects should
|
|
162
|
-
* pre-warm their shape by assigning this
|
|
163
|
-
* during initialization.
|
|
164
|
-
*
|
|
165
|
-
* ```ts
|
|
166
|
-
* initializeSignalStore(obj);
|
|
167
|
-
* ```
|
|
168
|
-
*
|
|
169
|
-
* @private
|
|
170
|
-
*/
|
|
171
|
-
const Signals = getOrSetGlobal("Signals", Symbol("Signals"));
|
|
172
|
-
/**
|
|
173
|
-
* A type util to recast the object as having a signal store.
|
|
174
|
-
*
|
|
175
|
-
* @private
|
|
176
|
-
*/
|
|
177
|
-
function upgradeWithSignals(obj) {}
|
|
178
|
-
/**
|
|
179
|
-
* A util that will create a signal store on the object
|
|
180
|
-
* if it does not already exist and returns the associated
|
|
181
|
-
* signal store.
|
|
182
|
-
*
|
|
183
|
-
* @private
|
|
184
|
-
*/
|
|
185
|
-
function withSignalStore(obj) {
|
|
186
|
-
/* @__PURE__ */ upgradeWithSignals(obj);
|
|
187
|
-
if (!obj[Signals]) initializeSignalStore(obj);
|
|
188
|
-
return obj[Signals];
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* A util that will create a signal store on the object
|
|
192
|
-
* if it does not already exist.
|
|
193
|
-
*
|
|
194
|
-
* Useful for pre-warming the shape of an object to ensure
|
|
195
|
-
* a key-transition to add it is not required later.
|
|
196
|
-
*
|
|
197
|
-
* @private
|
|
198
|
-
*/
|
|
199
|
-
function initializeSignalStore(obj) {
|
|
200
|
-
/* @__PURE__ */ upgradeWithSignals(obj);
|
|
201
|
-
obj[Signals] = /* @__PURE__ */ new Map();
|
|
202
|
-
}
|
|
203
|
-
function createInternalSignal(signals, obj, key, initialValue) {
|
|
204
|
-
const warpDriveSignal = {
|
|
205
|
-
key,
|
|
206
|
-
context: obj,
|
|
207
|
-
signal: createSignal(obj, key),
|
|
208
|
-
value: isInitializer(initialValue) ? initialValue.value.call(obj) : initialValue,
|
|
209
|
-
isStale: false
|
|
210
|
-
};
|
|
211
|
-
signals.set(key, warpDriveSignal);
|
|
212
|
-
return warpDriveSignal;
|
|
213
|
-
}
|
|
214
|
-
function getOrCreateInternalSignal(signals, obj, key, initialValue) {
|
|
215
|
-
let signal = peekInternalSignal(signals, key);
|
|
216
|
-
if (!signal) signal = createInternalSignal(signals, obj, key, initialValue);
|
|
217
|
-
return signal;
|
|
218
|
-
}
|
|
219
|
-
function createInternalMemo(signals, object, key, fn) {
|
|
220
|
-
{
|
|
221
|
-
const memo = createMemo(object, key, fn);
|
|
222
|
-
signals.set(key, memo);
|
|
223
|
-
return memo;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Looks up the {@link WarpDriveSignal} stored for `key` in `signals`,
|
|
228
|
-
* if one has already been created, without creating or consuming it.
|
|
229
|
-
*/
|
|
230
|
-
function peekInternalSignal(signals, key) {
|
|
231
|
-
return signals?.get(key);
|
|
232
|
-
}
|
|
233
|
-
function consumeInternalSignal(signal) {
|
|
234
|
-
TrackingFrame?.signals.add(signal);
|
|
235
|
-
consumeSignal(signal.signal);
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* Marks `signal` as stale and notifies its underlying framework/TC39
|
|
239
|
-
* signal, scheduling any of its consumers for re-render/re-computation.
|
|
240
|
-
*/
|
|
241
|
-
function notifyInternalSignal(signal) {
|
|
242
|
-
if (signal) {
|
|
243
|
-
signal.isStale = true;
|
|
244
|
-
notifySignal(signal.signal);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
let TrackingFrame = null;
|
|
248
|
-
|
|
249
|
-
//#endregion
|
|
250
|
-
//#region src/signals/reactivity/signal.ts
|
|
251
|
-
/**
|
|
252
|
-
* Creates a signal for the key/object pairing and subscribes to the signal.
|
|
253
|
-
*
|
|
254
|
-
* Use when you need to ensure a signal exists and is subscribed to.
|
|
255
|
-
*
|
|
256
|
-
* @private
|
|
257
|
-
*/
|
|
258
|
-
function entangleSignal(signals, obj, key, initialValue) {
|
|
259
|
-
let internalSignal = peekInternalSignal(signals, key);
|
|
260
|
-
if (!internalSignal) internalSignal = createInternalSignal(signals, obj, key, initialValue);
|
|
261
|
-
consumeInternalSignal(internalSignal);
|
|
262
|
-
return internalSignal;
|
|
263
|
-
}
|
|
264
|
-
function entangleInitiallyStaleSignal(signals, obj, key, initialValue) {
|
|
265
|
-
let internalSignal = peekInternalSignal(signals, key);
|
|
266
|
-
if (!internalSignal) {
|
|
267
|
-
internalSignal = createInternalSignal(signals, obj, key, initialValue);
|
|
268
|
-
internalSignal.isStale = true;
|
|
269
|
-
}
|
|
270
|
-
consumeInternalSignal(internalSignal);
|
|
271
|
-
return internalSignal;
|
|
272
|
-
}
|
|
273
|
-
function createSignalDescriptor(key, intialValue) {
|
|
274
|
-
return {
|
|
275
|
-
enumerable: true,
|
|
276
|
-
configurable: false,
|
|
277
|
-
get() {
|
|
278
|
-
const internalSignal = entangleSignal(withSignalStore(this), this, key, intialValue);
|
|
279
|
-
internalSignal.isStale = false;
|
|
280
|
-
return internalSignal.value;
|
|
281
|
-
},
|
|
282
|
-
set(value) {
|
|
283
|
-
const signals = withSignalStore(this);
|
|
284
|
-
const internalSignal = getOrCreateInternalSignal(signals, this, key, intialValue);
|
|
285
|
-
if (internalSignal.value !== value) {
|
|
286
|
-
internalSignal.value = value;
|
|
287
|
-
notifyInternalSignal(internalSignal);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
};
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* define an enumerable signal property.
|
|
294
|
-
*
|
|
295
|
-
* Akin to Object.defineProperty.
|
|
296
|
-
*
|
|
297
|
-
* The signal will be lazily created when accessed and scoped to the
|
|
298
|
-
* instance of the object.
|
|
299
|
-
*
|
|
300
|
-
* @private
|
|
301
|
-
*/
|
|
302
|
-
function defineSignal(obj, key, v) {
|
|
303
|
-
Object.defineProperty(obj, key, createSignalDescriptor(key, v));
|
|
304
|
-
}
|
|
305
|
-
/**
|
|
306
|
-
* Define a non-enumerable signal property.
|
|
307
|
-
*
|
|
308
|
-
* @private
|
|
309
|
-
*/
|
|
310
|
-
function defineNonEnumerableSignal(obj, key, v) {
|
|
311
|
-
const desc = createSignalDescriptor(key, v);
|
|
312
|
-
desc.enumerable = false;
|
|
313
|
-
Object.defineProperty(obj, key, desc);
|
|
314
|
-
}
|
|
315
|
-
/**
|
|
316
|
-
* Decorator version of creating a signal.
|
|
317
|
-
*/
|
|
318
|
-
function signal(target, key, descriptor) {
|
|
319
|
-
return createSignalDescriptor(key, descriptor.initializer ? makeInitializer(descriptor.initializer) : null);
|
|
320
|
-
}
|
|
321
|
-
/**
|
|
322
|
-
* Decorator version of creating a memoized getter
|
|
323
|
-
*/
|
|
324
|
-
function memoized(target, key, descriptor) {
|
|
325
|
-
const getter = descriptor.get;
|
|
326
|
-
descriptor.get = function() {
|
|
327
|
-
const signals = withSignalStore(this);
|
|
328
|
-
let memoSignal = signals.get(key);
|
|
329
|
-
if (!memoSignal) memoSignal = createInternalMemo(signals, this, key, getter.bind(this));
|
|
330
|
-
return memoSignal();
|
|
331
|
-
};
|
|
332
|
-
return descriptor;
|
|
333
|
-
}
|
|
334
|
-
/**
|
|
335
|
-
* Decorator version of creating a gate.
|
|
336
|
-
*
|
|
337
|
-
* @private
|
|
338
|
-
*/
|
|
339
|
-
function gate(_target, key, desc) {
|
|
340
|
-
const getter = desc.get;
|
|
341
|
-
const setter = desc.set;
|
|
342
|
-
const isLocal = desc.isLocal;
|
|
343
|
-
desc.get = function() {
|
|
344
|
-
const signals = withSignalStore(this);
|
|
345
|
-
let internalSignal = peekInternalSignal(signals, key);
|
|
346
|
-
if (!internalSignal) internalSignal = createInternalSignal(signals, this, key, getter.call(this));
|
|
347
|
-
else if (internalSignal.isStale) {
|
|
348
|
-
internalSignal.isStale = false;
|
|
349
|
-
internalSignal.value = getter.call(this);
|
|
350
|
-
}
|
|
351
|
-
consumeInternalSignal(internalSignal);
|
|
352
|
-
return internalSignal.value;
|
|
353
|
-
};
|
|
354
|
-
if (setter) desc.set = function(v) {
|
|
355
|
-
const signals = withSignalStore(this);
|
|
356
|
-
let internalSignal = peekInternalSignal(signals, key);
|
|
357
|
-
if (!internalSignal) {
|
|
358
|
-
internalSignal = createInternalSignal(signals, this, key, void 0);
|
|
359
|
-
internalSignal.isStale = true;
|
|
360
|
-
}
|
|
361
|
-
setter.call(this, v);
|
|
362
|
-
if (isLocal) {
|
|
363
|
-
internalSignal.isStale = true;
|
|
364
|
-
notifyInternalSignal(internalSignal);
|
|
365
|
-
}
|
|
366
|
-
};
|
|
367
|
-
return desc;
|
|
368
|
-
}
|
|
369
|
-
/**
|
|
370
|
-
* Defines a reactive "gated" property on `obj` using `desc` as its
|
|
371
|
-
* getter/setter descriptor.
|
|
372
|
-
*
|
|
373
|
-
* Unlike a signal defined with {@link defineSignal}, a gated property's
|
|
374
|
-
* consumers are not notified when the property is set, since its update
|
|
375
|
-
* is expected to be controlled externally (for instance, by a signal it
|
|
376
|
-
* derives its value from) unless the descriptor opts into being locally
|
|
377
|
-
* managed.
|
|
378
|
-
*
|
|
379
|
-
* Akin to `Object.defineProperty`.
|
|
380
|
-
*
|
|
381
|
-
* @private
|
|
382
|
-
*/
|
|
383
|
-
function defineGate(obj, key, desc) {
|
|
384
|
-
const options = Object.assign({
|
|
385
|
-
enumerable: true,
|
|
386
|
-
configurable: false
|
|
387
|
-
}, gate(obj, key, desc));
|
|
388
|
-
Object.defineProperty(obj, key, options);
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
//#endregion
|
|
392
|
-
//#region src/signals/request-state.ts
|
|
393
|
-
const RequestCache = /* @__PURE__ */ new WeakMap();
|
|
394
|
-
function isAbortError(error) {
|
|
395
|
-
return error instanceof DOMError && error.name === "AbortError";
|
|
396
|
-
}
|
|
397
|
-
function upgradeLoadingState(state) {
|
|
398
|
-
return state;
|
|
399
|
-
}
|
|
400
|
-
async function watchStream(stream, loadingState) {
|
|
401
|
-
const state = upgradeLoadingState(loadingState);
|
|
402
|
-
const reader = stream.getReader();
|
|
403
|
-
let bytesLoaded = 0;
|
|
404
|
-
let shouldForward = state._stream !== null && state._stream.readable.locked;
|
|
405
|
-
let isForwarding = shouldForward;
|
|
406
|
-
let writer = state._stream?.writable.getWriter();
|
|
407
|
-
const buffer = [];
|
|
408
|
-
state._isPending = false;
|
|
409
|
-
state._isStarted = true;
|
|
410
|
-
state._startTime = performance.now();
|
|
411
|
-
while (true) {
|
|
412
|
-
const { value, done } = await reader.read();
|
|
413
|
-
if (done) break;
|
|
414
|
-
bytesLoaded += value.byteLength;
|
|
415
|
-
state._bytesLoaded = bytesLoaded;
|
|
416
|
-
state._lastPacketTime = performance.now();
|
|
417
|
-
shouldForward = shouldForward || state._stream !== null && state._stream.readable.locked;
|
|
418
|
-
if (shouldForward) {
|
|
419
|
-
if (!isForwarding) {
|
|
420
|
-
isForwarding = true;
|
|
421
|
-
writer = state._stream.writable.getWriter();
|
|
422
|
-
for (const item of buffer) {
|
|
423
|
-
await writer.ready;
|
|
424
|
-
await writer.write(item);
|
|
425
|
-
}
|
|
426
|
-
buffer.length = 0;
|
|
427
|
-
}
|
|
428
|
-
await writer.ready;
|
|
429
|
-
await writer.write(value);
|
|
430
|
-
} else buffer.push(value);
|
|
431
|
-
}
|
|
432
|
-
if (isForwarding) {
|
|
433
|
-
await writer.ready;
|
|
434
|
-
await writer.close();
|
|
435
|
-
} else if (state._stream) {
|
|
436
|
-
await state._stream.readable.cancel("The Stream Has Already Ended");
|
|
437
|
-
state._stream = null;
|
|
438
|
-
}
|
|
439
|
-
state._endTime = performance.now();
|
|
440
|
-
state._isComplete = true;
|
|
441
|
-
state._isStarted = false;
|
|
442
|
-
}
|
|
443
|
-
/**
|
|
444
|
-
* Lazily consumes the stream of a request, providing a number of
|
|
445
|
-
* reactive properties that can be used to build UIs that respond
|
|
446
|
-
* to the progress of a request.
|
|
447
|
-
*
|
|
448
|
-
* @hideconstructor
|
|
449
|
-
*/
|
|
450
|
-
var RequestLoadingState = class {
|
|
451
|
-
/** @internal */
|
|
452
|
-
/** @internal */
|
|
453
|
-
/** @internal */
|
|
454
|
-
/** @internal */
|
|
455
|
-
/** @internal */
|
|
456
|
-
/** @internal */
|
|
457
|
-
/** @internal */
|
|
458
|
-
/** @internal */
|
|
459
|
-
/** @internal */
|
|
460
|
-
/** @internal */
|
|
461
|
-
/** @internal */
|
|
462
|
-
/** @internal */
|
|
463
|
-
_stream = null;
|
|
464
|
-
/** @internal */
|
|
465
|
-
_future;
|
|
466
|
-
/** @internal */
|
|
467
|
-
_triggered = false;
|
|
468
|
-
/** @internal */
|
|
469
|
-
_trigger() {
|
|
470
|
-
if (this._triggered) return;
|
|
471
|
-
this._triggered = true;
|
|
472
|
-
const promise = this._future.getStream();
|
|
473
|
-
if (promise.sizeHint) this._sizeHint = promise.sizeHint;
|
|
474
|
-
this.promise = promise.then((stream) => {
|
|
475
|
-
if (!stream) {
|
|
476
|
-
this._isPending = false;
|
|
477
|
-
this._isComplete = true;
|
|
478
|
-
return;
|
|
479
|
-
}
|
|
480
|
-
return watchStream(stream, this);
|
|
481
|
-
}, (error) => {
|
|
482
|
-
this._isPending = false;
|
|
483
|
-
this._isStarted = false;
|
|
484
|
-
if (isAbortError(error)) {
|
|
485
|
-
this._isCancelled = true;
|
|
486
|
-
this._isComplete = true;
|
|
487
|
-
}
|
|
488
|
-
this._isErrored = true;
|
|
489
|
-
this._error = error;
|
|
490
|
-
});
|
|
491
|
-
}
|
|
492
|
-
/**
|
|
493
|
-
* Resolves once the stream has finished being consumed, or rejects
|
|
494
|
-
* if the request errors. `null` until first accessed.
|
|
495
|
-
*/
|
|
496
|
-
promise = null;
|
|
497
|
-
/**
|
|
498
|
-
* Whether the stream has not yet started being consumed.
|
|
499
|
-
*/
|
|
500
|
-
get isPending() {
|
|
501
|
-
this._trigger();
|
|
502
|
-
return this._isPending;
|
|
503
|
-
}
|
|
504
|
-
/**
|
|
505
|
-
* The total size of the response in bytes, if known ahead of time
|
|
506
|
-
* (via a `Content-Length` header or similar).
|
|
507
|
-
*/
|
|
508
|
-
get sizeHint() {
|
|
509
|
-
this._trigger();
|
|
510
|
-
return this._sizeHint;
|
|
511
|
-
}
|
|
512
|
-
/**
|
|
513
|
-
* A readable stream of the response content. Accessing this property
|
|
514
|
-
* begins consumption of the underlying request stream.
|
|
515
|
-
*/
|
|
516
|
-
get stream() {
|
|
517
|
-
this._trigger();
|
|
518
|
-
if (!this._stream) {
|
|
519
|
-
if (this._isComplete || this._isCancelled || this._isErrored) return null;
|
|
520
|
-
this._stream = new TransformStream();
|
|
521
|
-
}
|
|
522
|
-
return this._stream.readable;
|
|
523
|
-
}
|
|
524
|
-
/**
|
|
525
|
-
* Whether the stream has started being consumed but has not yet completed.
|
|
526
|
-
*/
|
|
527
|
-
get isStarted() {
|
|
528
|
-
this._trigger();
|
|
529
|
-
return this._isStarted;
|
|
530
|
-
}
|
|
531
|
-
/**
|
|
532
|
-
* The number of bytes loaded so far.
|
|
533
|
-
*/
|
|
534
|
-
get bytesLoaded() {
|
|
535
|
-
this._trigger();
|
|
536
|
-
return this._bytesLoaded;
|
|
537
|
-
}
|
|
538
|
-
/**
|
|
539
|
-
* The `performance.now()` timestamp at which the stream started being consumed.
|
|
540
|
-
*/
|
|
541
|
-
get startTime() {
|
|
542
|
-
this._trigger();
|
|
543
|
-
return this._startTime;
|
|
544
|
-
}
|
|
545
|
-
/**
|
|
546
|
-
* The `performance.now()` timestamp at which the stream finished being consumed.
|
|
547
|
-
*/
|
|
548
|
-
get endTime() {
|
|
549
|
-
this._trigger();
|
|
550
|
-
return this._endTime;
|
|
551
|
-
}
|
|
552
|
-
/**
|
|
553
|
-
* The `performance.now()` timestamp at which the last chunk of data was received.
|
|
554
|
-
*/
|
|
555
|
-
get lastPacketTime() {
|
|
556
|
-
this._trigger();
|
|
557
|
-
return this._lastPacketTime;
|
|
558
|
-
}
|
|
559
|
-
/**
|
|
560
|
-
* Whether the stream has finished being consumed.
|
|
561
|
-
*/
|
|
562
|
-
get isComplete() {
|
|
563
|
-
this._trigger();
|
|
564
|
-
return this._isComplete;
|
|
565
|
-
}
|
|
566
|
-
/**
|
|
567
|
-
* Whether the request was aborted before the stream finished being consumed.
|
|
568
|
-
*/
|
|
569
|
-
get isCancelled() {
|
|
570
|
-
this._trigger();
|
|
571
|
-
return this._isCancelled;
|
|
572
|
-
}
|
|
573
|
-
/**
|
|
574
|
-
* Whether an error occurred while consuming the stream.
|
|
575
|
-
*/
|
|
576
|
-
get isErrored() {
|
|
577
|
-
this._trigger();
|
|
578
|
-
return this._isErrored;
|
|
579
|
-
}
|
|
580
|
-
/**
|
|
581
|
-
* The error that occurred while consuming the stream, if any.
|
|
582
|
-
*/
|
|
583
|
-
get error() {
|
|
584
|
-
this._trigger();
|
|
585
|
-
return this._error;
|
|
586
|
-
}
|
|
587
|
-
/**
|
|
588
|
-
* The number of milliseconds elapsed since the stream started being
|
|
589
|
-
* consumed, using the last packet time (or end time, once complete)
|
|
590
|
-
* as the endpoint.
|
|
591
|
-
*/
|
|
592
|
-
get elapsedTime() {
|
|
593
|
-
return (this.endTime || this.lastPacketTime) - this.startTime;
|
|
594
|
-
}
|
|
595
|
-
/**
|
|
596
|
-
* The ratio (0 to 1) of {@link RequestLoadingState.bytesLoaded | bytesLoaded}
|
|
597
|
-
* to {@link RequestLoadingState.sizeHint | sizeHint}, or `0` if no size hint is available.
|
|
598
|
-
*/
|
|
599
|
-
get completedRatio() {
|
|
600
|
-
return this.sizeHint ? this.bytesLoaded / this.sizeHint : 0;
|
|
601
|
-
}
|
|
602
|
-
/**
|
|
603
|
-
* The inverse of {@link RequestLoadingState.completedRatio | completedRatio}.
|
|
604
|
-
*/
|
|
605
|
-
get remainingRatio() {
|
|
606
|
-
return 1 - this.completedRatio;
|
|
607
|
-
}
|
|
608
|
-
/**
|
|
609
|
-
* The total number of milliseconds elapsed between
|
|
610
|
-
* {@link RequestLoadingState.startTime | startTime} and {@link RequestLoadingState.endTime | endTime}.
|
|
611
|
-
*/
|
|
612
|
-
get duration() {
|
|
613
|
-
return this.endTime - this.startTime;
|
|
614
|
-
}
|
|
615
|
-
/**
|
|
616
|
-
* The average download speed in bytes per second.
|
|
617
|
-
*/
|
|
618
|
-
get speed() {
|
|
619
|
-
return this.bytesLoaded / (this.elapsedTime / 1e3);
|
|
620
|
-
}
|
|
621
|
-
constructor(future) {
|
|
622
|
-
this._future = future;
|
|
623
|
-
}
|
|
624
|
-
/**
|
|
625
|
-
* Aborts the underlying request.
|
|
626
|
-
*/
|
|
627
|
-
abort = () => {
|
|
628
|
-
this._future.abort();
|
|
629
|
-
};
|
|
630
|
-
};
|
|
631
|
-
defineNonEnumerableSignal(RequestLoadingState.prototype, "_isPending", true);
|
|
632
|
-
defineNonEnumerableSignal(RequestLoadingState.prototype, "_isStarted", false);
|
|
633
|
-
defineNonEnumerableSignal(RequestLoadingState.prototype, "_isComplete", false);
|
|
634
|
-
defineNonEnumerableSignal(RequestLoadingState.prototype, "_isCancelled", false);
|
|
635
|
-
defineNonEnumerableSignal(RequestLoadingState.prototype, "_isErrored", false);
|
|
636
|
-
defineNonEnumerableSignal(RequestLoadingState.prototype, "_error", null);
|
|
637
|
-
defineNonEnumerableSignal(RequestLoadingState.prototype, "_sizeHint", 0);
|
|
638
|
-
defineNonEnumerableSignal(RequestLoadingState.prototype, "_bytesLoaded", 0);
|
|
639
|
-
defineNonEnumerableSignal(RequestLoadingState.prototype, "_startTime", 0);
|
|
640
|
-
defineNonEnumerableSignal(RequestLoadingState.prototype, "_endTime", 0);
|
|
641
|
-
defineNonEnumerableSignal(RequestLoadingState.prototype, "_lastPacketTime", 0);
|
|
642
|
-
/**
|
|
643
|
-
* The state of a request in the "pending"
|
|
644
|
-
* state. This is the default initial state.
|
|
645
|
-
*
|
|
646
|
-
* Extends the {@link PendingPromise} interface.
|
|
647
|
-
*
|
|
648
|
-
*/
|
|
649
|
-
/**
|
|
650
|
-
* The state of a request in the "fulfilled" state.
|
|
651
|
-
* This is the state of a request that has resolved
|
|
652
|
-
* successfully.
|
|
653
|
-
*
|
|
654
|
-
* Extends the {@link ResolvedPromise} interface.
|
|
655
|
-
*
|
|
656
|
-
*/
|
|
657
|
-
/**
|
|
658
|
-
* The state of a request in the "rejected" state.
|
|
659
|
-
* This is the state of a request that has rejected
|
|
660
|
-
* with an error.
|
|
661
|
-
*
|
|
662
|
-
* Extends the {@link RejectedPromise} interface.
|
|
663
|
-
*
|
|
664
|
-
*/
|
|
665
|
-
/**
|
|
666
|
-
* The state of a request in the "cancelled" state.
|
|
667
|
-
* This is the state of a promise that has been
|
|
668
|
-
* cancelled.
|
|
669
|
-
*
|
|
670
|
-
*/
|
|
671
|
-
/**
|
|
672
|
-
* RequestState extends the concept of {@link PromiseState} to provide a reactive
|
|
673
|
-
* wrapper for a request {@link Future} which allows you write declarative code
|
|
674
|
-
* around a Future's control flow.
|
|
675
|
-
*
|
|
676
|
-
* It is useful in both Template and JavaScript contexts, allowing you
|
|
677
|
-
* to quickly derive behaviors and data from pending, error and success
|
|
678
|
-
* states.
|
|
679
|
-
*
|
|
680
|
-
* The key difference between a {@link Promise} and a Future is that Futures provide
|
|
681
|
-
* access to a {@link ReadableStream | stream} of their content, the {@link RequestKey} of the request (if any)
|
|
682
|
-
* as well as the ability to attempt to {@link Future.abort | abort} the request.
|
|
683
|
-
*
|
|
684
|
-
* ```ts
|
|
685
|
-
* interface Future<T> extends Promise<T>> {
|
|
686
|
-
* getStream(): Promise<ReadableStream>;
|
|
687
|
-
* abort(): void;
|
|
688
|
-
* lid: RequestKey | null;
|
|
689
|
-
* }
|
|
690
|
-
* ```
|
|
691
|
-
*
|
|
692
|
-
* These additional APIs allow us to craft even richer state experiences.
|
|
693
|
-
*
|
|
694
|
-
* To get the state of a request, use {@link getRequestState}.
|
|
695
|
-
*
|
|
696
|
-
* See also:
|
|
697
|
-
* - {@link PendingRequest}
|
|
698
|
-
* - {@link ResolvedRequest}
|
|
699
|
-
* - {@link RejectedRequest}
|
|
700
|
-
* - {@link CancelledRequest}
|
|
701
|
-
*
|
|
702
|
-
*/
|
|
703
|
-
const RequestStateProto = {};
|
|
704
|
-
function performRefresh(requester, request, isReload) {
|
|
705
|
-
const req = Object.assign({}, request);
|
|
706
|
-
const cacheOptions = Object.assign({}, req.cacheOptions);
|
|
707
|
-
if (isReload) cacheOptions.reload = true;
|
|
708
|
-
else if (isReload === false) {
|
|
709
|
-
delete cacheOptions.reload;
|
|
710
|
-
cacheOptions.backgroundReload = true;
|
|
711
|
-
} else {
|
|
712
|
-
delete cacheOptions.backgroundReload;
|
|
713
|
-
delete cacheOptions.reload;
|
|
714
|
-
}
|
|
715
|
-
req.cacheOptions = cacheOptions;
|
|
716
|
-
return requester.request(req);
|
|
717
|
-
}
|
|
718
|
-
defineSignal(RequestStateProto, "reason", null);
|
|
719
|
-
defineSignal(RequestStateProto, "value", null);
|
|
720
|
-
defineSignal(RequestStateProto, "result", null);
|
|
721
|
-
defineSignal(RequestStateProto, "error", null);
|
|
722
|
-
defineSignal(RequestStateProto, "status", "pending");
|
|
723
|
-
defineSignal(RequestStateProto, "isPending", true);
|
|
724
|
-
defineSignal(RequestStateProto, "isLoading", true);
|
|
725
|
-
defineSignal(RequestStateProto, "isSuccess", false);
|
|
726
|
-
defineSignal(RequestStateProto, "isError", false);
|
|
727
|
-
defineSignal(RequestStateProto, "request", null);
|
|
728
|
-
defineSignal(RequestStateProto, "response", null);
|
|
729
|
-
Object.defineProperty(RequestStateProto, "isCancelled", { get() {
|
|
730
|
-
return this.isError && isAbortError(this.reason);
|
|
731
|
-
} });
|
|
732
|
-
Object.defineProperty(RequestStateProto, "loadingState", { get() {
|
|
733
|
-
if (!this._loadingState) this._loadingState = new RequestLoadingState(this._request);
|
|
734
|
-
return this._loadingState;
|
|
735
|
-
} });
|
|
736
|
-
function createRequestState(future) {
|
|
737
|
-
const state = getPromiseResult(future);
|
|
738
|
-
const promiseState = Object.create(RequestStateProto);
|
|
739
|
-
promiseState._request = future;
|
|
740
|
-
promiseState.reload = () => {
|
|
741
|
-
return performRefresh(future.requester, promiseState.request, true);
|
|
742
|
-
};
|
|
743
|
-
promiseState.refresh = (usePolicy = false) => {
|
|
744
|
-
return performRefresh(future.requester, promiseState.request, usePolicy === true ? null : false);
|
|
745
|
-
};
|
|
746
|
-
if (state) {
|
|
747
|
-
if (state.isError) {
|
|
748
|
-
promiseState.error = state.result;
|
|
749
|
-
promiseState.reason = state.result;
|
|
750
|
-
promiseState.status = "rejected";
|
|
751
|
-
promiseState.isError = true;
|
|
752
|
-
promiseState.isPending = false;
|
|
753
|
-
promiseState.isLoading = false;
|
|
754
|
-
promiseState.request = state.result.request;
|
|
755
|
-
promiseState.response = state.result.response;
|
|
756
|
-
} else {
|
|
757
|
-
promiseState.result = state.result.content;
|
|
758
|
-
promiseState.value = state.result.content;
|
|
759
|
-
promiseState.status = "fulfilled";
|
|
760
|
-
promiseState.isSuccess = true;
|
|
761
|
-
promiseState.isPending = false;
|
|
762
|
-
promiseState.isLoading = false;
|
|
763
|
-
promiseState.request = state.result.request;
|
|
764
|
-
promiseState.response = state.result.response;
|
|
765
|
-
}
|
|
766
|
-
} else future.then((result) => {
|
|
767
|
-
setPromiseResult(future, {
|
|
768
|
-
isError: false,
|
|
769
|
-
result
|
|
770
|
-
});
|
|
771
|
-
promiseState.result = result.content;
|
|
772
|
-
promiseState.value = result.content;
|
|
773
|
-
promiseState.status = "fulfilled";
|
|
774
|
-
promiseState.isSuccess = true;
|
|
775
|
-
promiseState.isPending = false;
|
|
776
|
-
promiseState.isLoading = false;
|
|
777
|
-
promiseState.request = result.request;
|
|
778
|
-
promiseState.response = result.response;
|
|
779
|
-
}, (error) => {
|
|
780
|
-
setPromiseResult(future, {
|
|
781
|
-
isError: true,
|
|
782
|
-
result: error
|
|
783
|
-
});
|
|
784
|
-
promiseState.error = error;
|
|
785
|
-
promiseState.reason = error;
|
|
786
|
-
promiseState.status = "rejected";
|
|
787
|
-
promiseState.isError = true;
|
|
788
|
-
promiseState.isPending = false;
|
|
789
|
-
promiseState.isLoading = false;
|
|
790
|
-
promiseState.request = error.request;
|
|
791
|
-
promiseState.response = error.response;
|
|
792
|
-
});
|
|
793
|
-
return promiseState;
|
|
794
|
-
}
|
|
795
|
-
/**
|
|
796
|
-
* `getRequestState` can be used in both JavaScript and Template contexts.
|
|
797
|
-
*
|
|
798
|
-
* ```ts
|
|
799
|
-
* import { getRequestState } from '@warp-drive/ember';
|
|
800
|
-
*
|
|
801
|
-
* const state = getRequestState(future);
|
|
802
|
-
* ```
|
|
803
|
-
*
|
|
804
|
-
* For instance, we could write a getter on a component that updates whenever
|
|
805
|
-
* the request state advances or the future changes, by combining the function
|
|
806
|
-
* with the use of `@cached`
|
|
807
|
-
*
|
|
808
|
-
* ```ts
|
|
809
|
-
* class Component {
|
|
810
|
-
* @cached
|
|
811
|
-
* get title() {
|
|
812
|
-
* const state = getRequestState(this.args.request);
|
|
813
|
-
* if (state.isPending) {
|
|
814
|
-
* return 'loading...';
|
|
815
|
-
* }
|
|
816
|
-
* if (state.isError) { return null; }
|
|
817
|
-
* return state.result.title;
|
|
818
|
-
* }
|
|
819
|
-
* }
|
|
820
|
-
* ```
|
|
821
|
-
*
|
|
822
|
-
* Or in a template as a helper:
|
|
823
|
-
*
|
|
824
|
-
* ```gjs
|
|
825
|
-
* import { getRequestState } from '@warp-drive/ember';
|
|
826
|
-
*
|
|
827
|
-
* <template>
|
|
828
|
-
* {{#let (getRequestState @request) as |state|}}
|
|
829
|
-
* {{#if state.isPending}}
|
|
830
|
-
* <Spinner />
|
|
831
|
-
* {{else if state.isError}}
|
|
832
|
-
* <ErrorForm @error={{state.error}} />
|
|
833
|
-
* {{else}}
|
|
834
|
-
* <h1>{{state.result.title}}</h1>
|
|
835
|
-
* {{/if}}
|
|
836
|
-
* {{/let}}
|
|
837
|
-
* </template>
|
|
838
|
-
* ```
|
|
839
|
-
*
|
|
840
|
-
* If looking to use in a template, consider also the `<Request />` component
|
|
841
|
-
* which offers a number of additional capabilities for requests *beyond* what
|
|
842
|
-
* `RequestState` provides.
|
|
843
|
-
*
|
|
844
|
-
*/
|
|
845
|
-
function getRequestState(future) {
|
|
846
|
-
let state = RequestCache.get(future);
|
|
847
|
-
if (!state) {
|
|
848
|
-
state = createRequestState(future);
|
|
849
|
-
RequestCache.set(future, state);
|
|
850
|
-
}
|
|
851
|
-
return state;
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
//#endregion
|
|
855
|
-
//#region ../../node_modules/.pnpm/decorat_5005bbc272376d25df08203abab44e2f/node_modules/decorator-transforms/dist/runtime-BPCpkOf1.js
|
|
856
|
-
function decorateMethodV2(prototype, prop, decorators) {
|
|
857
|
-
let desc = { ...Object.getOwnPropertyDescriptor(prototype, prop) };
|
|
858
|
-
for (let decorator of decorators) desc = decorator(prototype, prop, desc) || desc;
|
|
859
|
-
if (desc.initializer !== void 0) {
|
|
860
|
-
desc.value = desc.initializer ? desc.initializer.call(prototype) : void 0;
|
|
861
|
-
desc.initializer = void 0;
|
|
862
|
-
}
|
|
863
|
-
Object.defineProperty(prototype, prop, desc);
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
//#endregion
|
|
867
|
-
//#region src/signals/request-subscription.ts
|
|
868
|
-
const DEFAULT_DEADLINE = 3e4;
|
|
869
|
-
/**
|
|
870
|
-
* A symbol used to dispose of a {@link RequestSubscription} when the
|
|
871
|
-
* component or context using it is torn down.
|
|
872
|
-
*/
|
|
873
|
-
const DISPOSE = Symbol.dispose || Symbol.for("dispose");
|
|
874
|
-
/**
|
|
875
|
-
* The individual autorefresh strategies a {@link RequestSubscription}
|
|
876
|
-
* may combine, see {@link AutorefreshBehaviorCombos}.
|
|
877
|
-
*/
|
|
878
|
-
/**
|
|
879
|
-
* The value accepted by {@link SubscriptionArgs.autorefresh}: either a
|
|
880
|
-
* boolean, a single {@link AutorefreshBehaviorType}, or a comma-separated
|
|
881
|
-
* combination of up to three of them.
|
|
882
|
-
*/
|
|
883
|
-
/**
|
|
884
|
-
* Utilities to assist in recovering from the error.
|
|
885
|
-
*/
|
|
886
|
-
/** @deprecated use {@link RecoveryFeatures} */
|
|
887
|
-
/**
|
|
888
|
-
* Utilities for keeping the request fresh
|
|
889
|
-
*/
|
|
890
|
-
/**
|
|
891
|
-
* The args accepted by the `<Request />` component.
|
|
892
|
-
*/
|
|
893
|
-
/**
|
|
894
|
-
* The args accepted by a {@link RequestSubscription}.
|
|
895
|
-
*/
|
|
896
|
-
/**
|
|
897
|
-
* A reactive class
|
|
898
|
-
*
|
|
899
|
-
* @hideconstructor
|
|
900
|
-
*/
|
|
901
|
-
var RequestSubscription = class {
|
|
902
|
-
/**
|
|
903
|
-
* Whether the browser reports that the network is online.
|
|
904
|
-
*/
|
|
905
|
-
/**
|
|
906
|
-
* Whether the browser reports that the tab is hidden.
|
|
907
|
-
*/
|
|
908
|
-
/**
|
|
909
|
-
* Whether the component is currently refreshing the request.
|
|
910
|
-
*/
|
|
911
|
-
/**
|
|
912
|
-
* The most recent blocking request that was made, typically
|
|
913
|
-
* the result of a reload.
|
|
914
|
-
*
|
|
915
|
-
* This will never be the original request passed as an arg to
|
|
916
|
-
* the component.
|
|
917
|
-
*
|
|
918
|
-
* @internal
|
|
919
|
-
*/
|
|
920
|
-
/**
|
|
921
|
-
* The most recent request that was made, typically due to either a
|
|
922
|
-
* reload or a refresh.
|
|
923
|
-
*
|
|
924
|
-
* This will never be the original request passed as an arg to
|
|
925
|
-
* the component.
|
|
926
|
-
*
|
|
927
|
-
* @internal
|
|
928
|
-
*/
|
|
929
|
-
/**
|
|
930
|
-
* The time at which the network was reported as offline.
|
|
931
|
-
*
|
|
932
|
-
* @internal
|
|
933
|
-
*/
|
|
934
|
-
/** @internal */
|
|
935
|
-
/** @internal */
|
|
936
|
-
/** @internal */
|
|
937
|
-
/** @internal */
|
|
938
|
-
/** @internal */
|
|
939
|
-
/**
|
|
940
|
-
* The event listener for network status changes,
|
|
941
|
-
* cached to use the reference for removal.
|
|
942
|
-
*
|
|
943
|
-
* @internal
|
|
944
|
-
*/
|
|
945
|
-
/**
|
|
946
|
-
* The event listener for visibility status changes,
|
|
947
|
-
* cached to use the reference for removal.
|
|
948
|
-
*
|
|
949
|
-
* @internal
|
|
950
|
-
*/
|
|
951
|
-
/**
|
|
952
|
-
* The last request passed as an arg to the component,
|
|
953
|
-
* cached for comparison.
|
|
954
|
-
*
|
|
955
|
-
* @internal
|
|
956
|
-
*/
|
|
957
|
-
/**
|
|
958
|
-
* The last query passed as an arg to the component,
|
|
959
|
-
* cached for comparison.
|
|
960
|
-
*
|
|
961
|
-
* @internal
|
|
962
|
-
*/
|
|
963
|
-
/** @internal */
|
|
964
|
-
/** @internal */
|
|
965
|
-
/** @internal */
|
|
966
|
-
/**
|
|
967
|
-
* The Store this subscription subscribes to or the RequestManager
|
|
968
|
-
* which issues this request.
|
|
969
|
-
*/
|
|
970
|
-
/**
|
|
971
|
-
* The Store or RequestManager that the last subscription is attached to.
|
|
972
|
-
*
|
|
973
|
-
* This differs from 'store' because a <Request /> may be passed a
|
|
974
|
-
* request originating from a different store than the <Request />
|
|
975
|
-
* component would use if it were to issue the request itself.
|
|
976
|
-
*
|
|
977
|
-
* @internal
|
|
978
|
-
*/
|
|
979
|
-
_requester;
|
|
980
|
-
constructor(store, args) {
|
|
981
|
-
this._args = args;
|
|
982
|
-
this.store = store;
|
|
983
|
-
this._subscribedTo = null;
|
|
984
|
-
this._subscription = null;
|
|
985
|
-
this._intervalStart = null;
|
|
986
|
-
this._invalidated = false;
|
|
987
|
-
this._nextInterval = null;
|
|
988
|
-
this._requester = null;
|
|
989
|
-
this.isDestroyed = false;
|
|
990
|
-
this[DISPOSE] = _DISPOSE;
|
|
991
|
-
this._installListeners();
|
|
992
|
-
this._beginPolling();
|
|
993
|
-
}
|
|
994
|
-
/**
|
|
995
|
-
* @internal
|
|
996
|
-
*/
|
|
997
|
-
async _beginPolling() {
|
|
998
|
-
try {
|
|
999
|
-
if (!this.isIdle) await this.request;
|
|
1000
|
-
} catch {} finally {
|
|
1001
|
-
if (!this.isDestroyed) this._scheduleInterval();
|
|
1002
|
-
}
|
|
1003
|
-
}
|
|
1004
|
-
/**
|
|
1005
|
-
* Whether neither a `request` nor a `query` arg was provided, and so
|
|
1006
|
-
* this subscription has nothing to fetch or monitor.
|
|
1007
|
-
*/
|
|
1008
|
-
get isIdle() {
|
|
1009
|
-
const { request, query } = this._args;
|
|
1010
|
-
return Boolean(!request && !query);
|
|
1011
|
-
}
|
|
1012
|
-
/**
|
|
1013
|
-
* The set of {@link AutorefreshBehaviorType}s this subscription is
|
|
1014
|
-
* configured to autorefresh for, derived from {@link SubscriptionArgs.autorefresh}.
|
|
1015
|
-
*/
|
|
1016
|
-
static {
|
|
1017
|
-
decorateMethodV2(this.prototype, "isIdle", [memoized]);
|
|
1018
|
-
}
|
|
1019
|
-
get autorefreshTypes() {
|
|
1020
|
-
const { autorefresh } = this._args;
|
|
1021
|
-
let types;
|
|
1022
|
-
if (autorefresh === true) types = ["online", "invalid"];
|
|
1023
|
-
else if (typeof autorefresh === "string") types = autorefresh.split(",");
|
|
1024
|
-
else types = [];
|
|
1025
|
-
return new Set(types);
|
|
1026
|
-
}
|
|
1027
|
-
/** @internal */
|
|
1028
|
-
static {
|
|
1029
|
-
decorateMethodV2(this.prototype, "autorefreshTypes", [memoized]);
|
|
1030
|
-
}
|
|
1031
|
-
async _scheduleInterval() {
|
|
1032
|
-
const { autorefreshThreshold } = this._args;
|
|
1033
|
-
if (typeof window === "undefined" || !(typeof autorefreshThreshold === "number" && autorefreshThreshold > 0) || !this.autorefreshTypes.has("interval") || this._intervalStart !== null) return;
|
|
1034
|
-
if (this._latestRequest) {
|
|
1035
|
-
try {
|
|
1036
|
-
await this._latestRequest;
|
|
1037
|
-
} catch {}
|
|
1038
|
-
if (this.isDestroyed) return;
|
|
1039
|
-
}
|
|
1040
|
-
this._intervalStart = Date.now();
|
|
1041
|
-
this._nextInterval = setTimeout(() => {
|
|
1042
|
-
this._maybeUpdate();
|
|
1043
|
-
}, autorefreshThreshold);
|
|
1044
|
-
}
|
|
1045
|
-
/** @internal */
|
|
1046
|
-
_clearInterval() {
|
|
1047
|
-
if (this._nextInterval) {
|
|
1048
|
-
clearTimeout(this._nextInterval);
|
|
1049
|
-
this._intervalStart = null;
|
|
1050
|
-
}
|
|
1051
|
-
}
|
|
1052
|
-
/**
|
|
1053
|
-
* @internal
|
|
1054
|
-
*/
|
|
1055
|
-
_updateSubscriptions() {
|
|
1056
|
-
if (this.isIdle) return;
|
|
1057
|
-
const requestId = this._request.lid;
|
|
1058
|
-
if (this._subscribedTo === requestId) return;
|
|
1059
|
-
this._removeSubscriptions();
|
|
1060
|
-
const store = this._getRequester();
|
|
1061
|
-
this._requester = store;
|
|
1062
|
-
if (requestId && isStore(store)) {
|
|
1063
|
-
this._subscribedTo = requestId;
|
|
1064
|
-
this._subscription = store.notifications.subscribe(requestId, (_id, op) => {
|
|
1065
|
-
if (this._isUpdating) return;
|
|
1066
|
-
switch (op) {
|
|
1067
|
-
case "invalidated":
|
|
1068
|
-
if (this.autorefreshTypes.has("invalid")) {
|
|
1069
|
-
this._invalidated = true;
|
|
1070
|
-
this._maybeUpdate();
|
|
1071
|
-
}
|
|
1072
|
-
break;
|
|
1073
|
-
case "state": {
|
|
1074
|
-
const priority = store.requestManager._deduped.get(requestId)?.priority;
|
|
1075
|
-
const state = this.reqState;
|
|
1076
|
-
if (!priority) this.isRefreshing = false;
|
|
1077
|
-
else if (priority.blocking && !state.isLoading) {
|
|
1078
|
-
this.isRefreshing = false;
|
|
1079
|
-
this._maybeUpdate("policy", true);
|
|
1080
|
-
} else this.isRefreshing = true;
|
|
1081
|
-
}
|
|
1082
|
-
}
|
|
1083
|
-
});
|
|
1084
|
-
}
|
|
1085
|
-
}
|
|
1086
|
-
/**
|
|
1087
|
-
* @internal
|
|
1088
|
-
*/
|
|
1089
|
-
_removeSubscriptions() {
|
|
1090
|
-
const store = this._requester;
|
|
1091
|
-
if (this._subscription && store && isStore(store)) {
|
|
1092
|
-
store.notifications.unsubscribe(this._subscription);
|
|
1093
|
-
this._subscribedTo = null;
|
|
1094
|
-
this._subscription = null;
|
|
1095
|
-
this._requester = null;
|
|
1096
|
-
}
|
|
1097
|
-
}
|
|
1098
|
-
/**
|
|
1099
|
-
* Install the event listeners for network and visibility changes.
|
|
1100
|
-
*
|
|
1101
|
-
* This is only done in environments that provide a fully-featured global
|
|
1102
|
-
* `window` and/or `document`. Some non-DOM environments (e.g. React Native,
|
|
1103
|
-
* SSR/Node, workers) may provide a `window` global without the APIs we
|
|
1104
|
-
* rely on here (or no `window`/`document` at all), in which case we skip
|
|
1105
|
-
* attaching the corresponding listeners rather than throwing.
|
|
1106
|
-
*
|
|
1107
|
-
* @internal
|
|
1108
|
-
*/
|
|
1109
|
-
_installListeners() {
|
|
1110
|
-
const hasWindow = typeof window !== "undefined";
|
|
1111
|
-
const hasDocument = typeof document !== "undefined";
|
|
1112
|
-
const hasWindowEvents = hasWindow && typeof window.addEventListener === "function";
|
|
1113
|
-
const hasDocumentEvents = hasDocument && typeof document.addEventListener === "function";
|
|
1114
|
-
this.isOnline = hasWindow && typeof window.navigator?.onLine === "boolean" ? window.navigator.onLine : true;
|
|
1115
|
-
this._unavailableStart = this.isOnline ? null : Date.now();
|
|
1116
|
-
this.isHidden = hasDocument && typeof document.visibilityState === "string" && document.visibilityState === "hidden";
|
|
1117
|
-
if (hasWindowEvents) {
|
|
1118
|
-
this._onlineChanged = (event) => {
|
|
1119
|
-
this.isOnline = event.type === "online";
|
|
1120
|
-
if (event.type === "offline" && this._unavailableStart === null) this._unavailableStart = Date.now();
|
|
1121
|
-
this._maybeUpdate();
|
|
1122
|
-
};
|
|
1123
|
-
window.addEventListener("online", this._onlineChanged, {
|
|
1124
|
-
passive: true,
|
|
1125
|
-
capture: true
|
|
1126
|
-
});
|
|
1127
|
-
window.addEventListener("offline", this._onlineChanged, {
|
|
1128
|
-
passive: true,
|
|
1129
|
-
capture: true
|
|
1130
|
-
});
|
|
1131
|
-
}
|
|
1132
|
-
if (hasDocumentEvents) {
|
|
1133
|
-
this._backgroundChanged = () => {
|
|
1134
|
-
const isHidden = document.visibilityState === "hidden";
|
|
1135
|
-
this.isHidden = isHidden;
|
|
1136
|
-
if (isHidden && this._unavailableStart === null) this._unavailableStart = Date.now();
|
|
1137
|
-
this._maybeUpdate();
|
|
1138
|
-
};
|
|
1139
|
-
document.addEventListener("visibilitychange", this._backgroundChanged, {
|
|
1140
|
-
passive: true,
|
|
1141
|
-
capture: true
|
|
1142
|
-
});
|
|
1143
|
-
}
|
|
1144
|
-
}
|
|
1145
|
-
/**
|
|
1146
|
-
* If the network is online and the tab is visible, either reload or refresh the request
|
|
1147
|
-
* based on the component's configuration and the requested update mode.
|
|
1148
|
-
*
|
|
1149
|
-
* Valid modes are:
|
|
1150
|
-
*
|
|
1151
|
-
* - `'reload'`: Force a reload of the request.
|
|
1152
|
-
* - `'refresh'`: Refresh the request in the background.
|
|
1153
|
-
* - `'policy'`: Make the request, letting the store's configured CachePolicy decide whether to reload, refresh, or do nothing.
|
|
1154
|
-
* - `undefined`: Make the request using the component's autorefreshBehavior setting if the autorefreshThreshold has passed.
|
|
1155
|
-
*
|
|
1156
|
-
* @internal
|
|
1157
|
-
*/
|
|
1158
|
-
_maybeUpdate(mode, silent) {
|
|
1159
|
-
if (this.isIdle) return;
|
|
1160
|
-
const { reqState } = this;
|
|
1161
|
-
if (reqState.isPending) return;
|
|
1162
|
-
if (!Boolean(this.isOnline && !this.isHidden && (mode || this.autorefreshTypes.size))) {
|
|
1163
|
-
if (!silent && mode && mode !== "_invalidated") throw new Error(`Reload not available: the network is not online or the tab is hidden`);
|
|
1164
|
-
return;
|
|
1165
|
-
}
|
|
1166
|
-
const { autorefreshTypes } = this;
|
|
1167
|
-
let shouldAttempt = this._invalidated || Boolean(mode);
|
|
1168
|
-
if (!shouldAttempt && autorefreshTypes.has("online")) {
|
|
1169
|
-
const { _unavailableStart } = this;
|
|
1170
|
-
const { autorefreshThreshold } = this._args;
|
|
1171
|
-
const deadline = typeof autorefreshThreshold === "number" ? autorefreshThreshold : DEFAULT_DEADLINE;
|
|
1172
|
-
shouldAttempt = Boolean(_unavailableStart && Date.now() - _unavailableStart > deadline);
|
|
1173
|
-
}
|
|
1174
|
-
if (!shouldAttempt && autorefreshTypes.has("interval")) {
|
|
1175
|
-
const { _intervalStart } = this;
|
|
1176
|
-
const { autorefreshThreshold } = this._args;
|
|
1177
|
-
if (_intervalStart && typeof autorefreshThreshold === "number" && autorefreshThreshold > 0) shouldAttempt = Boolean(Date.now() - _intervalStart >= autorefreshThreshold);
|
|
1178
|
-
}
|
|
1179
|
-
this._unavailableStart = null;
|
|
1180
|
-
this._invalidated = false;
|
|
1181
|
-
if (shouldAttempt) {
|
|
1182
|
-
this._clearInterval();
|
|
1183
|
-
this._isUpdating = true;
|
|
1184
|
-
const val = (mode === "_invalidated" ? null : mode) ?? this._args.autorefreshBehavior ?? "policy";
|
|
1185
|
-
const requester = this._getRequester();
|
|
1186
|
-
if (!reqState._request.requester) reqState._request.requester = requester;
|
|
1187
|
-
switch (val) {
|
|
1188
|
-
case "reload":
|
|
1189
|
-
this._latestRequest = reqState.reload();
|
|
1190
|
-
break;
|
|
1191
|
-
case "refresh":
|
|
1192
|
-
this._latestRequest = reqState.refresh();
|
|
1193
|
-
break;
|
|
1194
|
-
case "policy": this._latestRequest = reqState.refresh(true);
|
|
1195
|
-
}
|
|
1196
|
-
if (val !== "refresh") this._localRequest = this._latestRequest;
|
|
1197
|
-
this._scheduleInterval();
|
|
1198
|
-
this._latestRequest.finally(() => {
|
|
1199
|
-
this._isUpdating = false;
|
|
1200
|
-
});
|
|
1201
|
-
}
|
|
1202
|
-
}
|
|
1203
|
-
/**
|
|
1204
|
-
* @internal
|
|
1205
|
-
*/
|
|
1206
|
-
_getRequester() {
|
|
1207
|
-
if (this._args.request?.requester) return this._args.request.requester;
|
|
1208
|
-
return this.store;
|
|
1209
|
-
}
|
|
1210
|
-
/**
|
|
1211
|
-
* Retry the request, reloading it from the server.
|
|
1212
|
-
*/
|
|
1213
|
-
retry = async () => {
|
|
1214
|
-
this._maybeUpdate("reload");
|
|
1215
|
-
await this._localRequest;
|
|
1216
|
-
};
|
|
1217
|
-
/**
|
|
1218
|
-
* Refresh the request, updating it in the background.
|
|
1219
|
-
*/
|
|
1220
|
-
refresh = async () => {
|
|
1221
|
-
this._maybeUpdate("refresh");
|
|
1222
|
-
await this._latestRequest;
|
|
1223
|
-
};
|
|
1224
|
-
/**
|
|
1225
|
-
* features to yield to the error slot of a component
|
|
1226
|
-
*/
|
|
1227
|
-
get errorFeatures() {
|
|
1228
|
-
return {
|
|
1229
|
-
isHidden: this.isHidden,
|
|
1230
|
-
isOnline: this.isOnline,
|
|
1231
|
-
retry: this.retry
|
|
1232
|
-
};
|
|
1233
|
-
}
|
|
1234
|
-
/**
|
|
1235
|
-
* features to yield to the content slot of a component
|
|
1236
|
-
*/
|
|
1237
|
-
static {
|
|
1238
|
-
decorateMethodV2(this.prototype, "errorFeatures", [memoized]);
|
|
1239
|
-
}
|
|
1240
|
-
get contentFeatures() {
|
|
1241
|
-
const feat = {
|
|
1242
|
-
isHidden: this.isHidden,
|
|
1243
|
-
isOnline: this.isOnline,
|
|
1244
|
-
reload: this.retry,
|
|
1245
|
-
refresh: this.refresh,
|
|
1246
|
-
isRefreshing: this.isRefreshing,
|
|
1247
|
-
latestRequest: this._latestRequest
|
|
1248
|
-
};
|
|
1249
|
-
if (feat.isRefreshing) feat.abort = () => {
|
|
1250
|
-
this._latestRequest?.abort();
|
|
1251
|
-
};
|
|
1252
|
-
return feat;
|
|
1253
|
-
}
|
|
1254
|
-
/**
|
|
1255
|
-
* @internal
|
|
1256
|
-
*/
|
|
1257
|
-
static {
|
|
1258
|
-
decorateMethodV2(this.prototype, "contentFeatures", [memoized]);
|
|
1259
|
-
}
|
|
1260
|
-
get _request() {
|
|
1261
|
-
const { request, query } = this._args;
|
|
1262
|
-
const { _localRequest, _originalRequest, _originalQuery } = this;
|
|
1263
|
-
if (_localRequest && request === _originalRequest && query === _originalQuery) return _localRequest;
|
|
1264
|
-
this._originalQuery = query;
|
|
1265
|
-
this._originalRequest = request;
|
|
1266
|
-
if (request) return request;
|
|
1267
|
-
return this.store.request(query);
|
|
1268
|
-
}
|
|
1269
|
-
/**
|
|
1270
|
-
* The {@link Future} this subscription is currently monitoring, and
|
|
1271
|
-
* (re-)subscribes to notifications for as a side effect of access.
|
|
1272
|
-
*/
|
|
1273
|
-
static {
|
|
1274
|
-
decorateMethodV2(this.prototype, "_request", [memoized]);
|
|
1275
|
-
}
|
|
1276
|
-
get request() {
|
|
1277
|
-
{
|
|
1278
|
-
const request = this._request;
|
|
1279
|
-
this._updateSubscriptions();
|
|
1280
|
-
return request;
|
|
1281
|
-
}
|
|
1282
|
-
}
|
|
1283
|
-
/**
|
|
1284
|
-
* The {@link RequestState} for {@link RequestSubscription.request | request}.
|
|
1285
|
-
*/
|
|
1286
|
-
static {
|
|
1287
|
-
decorateMethodV2(this.prototype, "request", [memoized]);
|
|
1288
|
-
}
|
|
1289
|
-
get reqState() {
|
|
1290
|
-
return getRequestState(this.request);
|
|
1291
|
-
}
|
|
1292
|
-
/**
|
|
1293
|
-
* The resolved content of the request, once it has succeeded.
|
|
1294
|
-
*/
|
|
1295
|
-
get result() {
|
|
1296
|
-
return this.reqState.result;
|
|
1297
|
-
}
|
|
1298
|
-
};
|
|
1299
|
-
defineSignal(RequestSubscription.prototype, "isOnline", true);
|
|
1300
|
-
defineSignal(RequestSubscription.prototype, "isHidden", false);
|
|
1301
|
-
defineSignal(RequestSubscription.prototype, "isRefreshing", false);
|
|
1302
|
-
defineSignal(RequestSubscription.prototype, "_localRequest", void 0);
|
|
1303
|
-
defineSignal(RequestSubscription.prototype, "_latestRequest", void 0);
|
|
1304
|
-
function isStore(store) {
|
|
1305
|
-
return "requestManager" in store;
|
|
1306
|
-
}
|
|
1307
|
-
/**
|
|
1308
|
-
* Creates a {@link RequestSubscription}, the reactive class powering the
|
|
1309
|
-
* `<Request />` component's autorefresh, retry, and refresh behaviors.
|
|
1310
|
-
*/
|
|
1311
|
-
function createRequestSubscription(store, args) {
|
|
1312
|
-
return new RequestSubscription(store, args);
|
|
1313
|
-
}
|
|
1314
|
-
function upgradeSubscription(sub) {
|
|
1315
|
-
return sub;
|
|
1316
|
-
}
|
|
1317
|
-
function _DISPOSE() {
|
|
1318
|
-
const self = upgradeSubscription(this);
|
|
1319
|
-
self.isDestroyed = true;
|
|
1320
|
-
self._removeSubscriptions();
|
|
1321
|
-
self._clearInterval();
|
|
1322
|
-
if (self._onlineChanged && typeof window !== "undefined" && typeof window.removeEventListener === "function") {
|
|
1323
|
-
window.removeEventListener("online", self._onlineChanged, {
|
|
1324
|
-
passive: true,
|
|
1325
|
-
capture: true
|
|
1326
|
-
});
|
|
1327
|
-
window.removeEventListener("offline", self._onlineChanged, {
|
|
1328
|
-
passive: true,
|
|
1329
|
-
capture: true
|
|
1330
|
-
});
|
|
1331
|
-
}
|
|
1332
|
-
if (self._backgroundChanged && typeof document !== "undefined" && typeof document.removeEventListener === "function") document.removeEventListener("visibilitychange", self._backgroundChanged, {
|
|
1333
|
-
passive: true,
|
|
1334
|
-
capture: true
|
|
1335
|
-
});
|
|
1336
|
-
}
|
|
1337
|
-
|
|
1338
|
-
//#endregion
|
|
1339
|
-
//#region src/signals/promise-state.ts
|
|
1340
|
-
const PromiseCache = /* @__PURE__ */ new WeakMap();
|
|
1341
|
-
/**
|
|
1342
|
-
* The state of a promise in the "pending"
|
|
1343
|
-
* state. This is the default initial state.
|
|
1344
|
-
*
|
|
1345
|
-
*/
|
|
1346
|
-
/**
|
|
1347
|
-
* The state of a promise in the "fulfilled" state.
|
|
1348
|
-
* This is the state of a promise that has resolved
|
|
1349
|
-
* successfully.
|
|
1350
|
-
*
|
|
1351
|
-
*/
|
|
1352
|
-
/**
|
|
1353
|
-
* The state of a promise in the "rejected" state.
|
|
1354
|
-
* This is the state of a promise that has rejected
|
|
1355
|
-
* with an error.
|
|
1356
|
-
*
|
|
1357
|
-
*/
|
|
1358
|
-
/**
|
|
1359
|
-
* The state of a promise. This is the type that is returned
|
|
1360
|
-
* from `getPromiseState`.
|
|
1361
|
-
*
|
|
1362
|
-
* See also:
|
|
1363
|
-
* - {@link PendingPromise}
|
|
1364
|
-
* - {@link ResolvedPromise}
|
|
1365
|
-
* - {@link RejectedPromise}
|
|
1366
|
-
*
|
|
1367
|
-
*/
|
|
1368
|
-
const PromiseStateProto = {};
|
|
1369
|
-
defineSignal(PromiseStateProto, "reason", null);
|
|
1370
|
-
defineSignal(PromiseStateProto, "value", null);
|
|
1371
|
-
defineSignal(PromiseStateProto, "result", null);
|
|
1372
|
-
defineSignal(PromiseStateProto, "error", null);
|
|
1373
|
-
defineSignal(PromiseStateProto, "status", "pending");
|
|
1374
|
-
defineSignal(PromiseStateProto, "isPending", true);
|
|
1375
|
-
defineSignal(PromiseStateProto, "isLoading", true);
|
|
1376
|
-
defineSignal(PromiseStateProto, "isSuccess", false);
|
|
1377
|
-
defineSignal(PromiseStateProto, "isError", false);
|
|
1378
|
-
function createPromiseState(promise) {
|
|
1379
|
-
const state = getPromiseResult(promise);
|
|
1380
|
-
const promiseState = Object.create(PromiseStateProto);
|
|
1381
|
-
if (state) {
|
|
1382
|
-
if (state.isError) {
|
|
1383
|
-
promiseState.error = state.result;
|
|
1384
|
-
promiseState.reason = state.result;
|
|
1385
|
-
promiseState.status = "rejected";
|
|
1386
|
-
promiseState.isError = true;
|
|
1387
|
-
promiseState.isPending = false;
|
|
1388
|
-
promiseState.isLoading = false;
|
|
1389
|
-
} else {
|
|
1390
|
-
promiseState.result = state.result;
|
|
1391
|
-
promiseState.value = state.result;
|
|
1392
|
-
promiseState.status = "fulfilled";
|
|
1393
|
-
promiseState.isSuccess = true;
|
|
1394
|
-
promiseState.isPending = false;
|
|
1395
|
-
promiseState.isLoading = false;
|
|
1396
|
-
}
|
|
1397
|
-
} else promise.then((result) => {
|
|
1398
|
-
setPromiseResult(promise, {
|
|
1399
|
-
isError: false,
|
|
1400
|
-
result
|
|
1401
|
-
});
|
|
1402
|
-
promiseState.result = result;
|
|
1403
|
-
promiseState.value = result;
|
|
1404
|
-
promiseState.status = "fulfilled";
|
|
1405
|
-
promiseState.isSuccess = true;
|
|
1406
|
-
promiseState.isPending = false;
|
|
1407
|
-
promiseState.isLoading = false;
|
|
1408
|
-
}, (error) => {
|
|
1409
|
-
setPromiseResult(promise, {
|
|
1410
|
-
isError: true,
|
|
1411
|
-
result: error
|
|
1412
|
-
});
|
|
1413
|
-
promiseState.error = error;
|
|
1414
|
-
promiseState.reason = error;
|
|
1415
|
-
promiseState.status = "rejected";
|
|
1416
|
-
promiseState.isError = true;
|
|
1417
|
-
promiseState.isPending = false;
|
|
1418
|
-
promiseState.isLoading = false;
|
|
1419
|
-
});
|
|
1420
|
-
return promiseState;
|
|
1421
|
-
}
|
|
1422
|
-
const LegacyPromiseProxy = Symbol.for("LegacyPromiseProxy");
|
|
1423
|
-
function isLegacyAwaitable(promise) {
|
|
1424
|
-
return LegacyPromiseProxy in promise && "promise" in promise && promise[LegacyPromiseProxy] === true;
|
|
1425
|
-
}
|
|
1426
|
-
function getPromise(promise) {
|
|
1427
|
-
return isLegacyAwaitable(promise) ? promise.promise : promise;
|
|
1428
|
-
}
|
|
1429
|
-
/**
|
|
1430
|
-
* Returns a reactive state-machine for the provided promise or awaitable.
|
|
1431
|
-
*
|
|
1432
|
-
* Repeat calls to `getPromiseState` with the same promise will return the same state object
|
|
1433
|
-
* making is safe and easy to use in templates and JavaScript code to produce reactive
|
|
1434
|
-
* behaviors around promises.
|
|
1435
|
-
*
|
|
1436
|
-
* `getPromiseState` can be used in both JavaScript and Template contexts.
|
|
1437
|
-
*
|
|
1438
|
-
* ```ts
|
|
1439
|
-
* import { getPromiseState } from '@warp-drive/ember';
|
|
1440
|
-
*
|
|
1441
|
-
* const state = getPromiseState(promise);
|
|
1442
|
-
* ```
|
|
1443
|
-
*
|
|
1444
|
-
* For instance, we could write a getter on a component that updates whenever
|
|
1445
|
-
* the promise state advances or the promise changes, by combining the function
|
|
1446
|
-
* with the use of `@cached`
|
|
1447
|
-
*
|
|
1448
|
-
* ```ts
|
|
1449
|
-
* class Component {
|
|
1450
|
-
* @cached
|
|
1451
|
-
* get title() {
|
|
1452
|
-
* const state = getPromiseState(this.args.request);
|
|
1453
|
-
* if (state.isPending) {
|
|
1454
|
-
* return 'loading...';
|
|
1455
|
-
* }
|
|
1456
|
-
* if (state.isError) { return null; }
|
|
1457
|
-
* return state.result.title;
|
|
1458
|
-
* }
|
|
1459
|
-
* }
|
|
1460
|
-
* ```
|
|
1461
|
-
*
|
|
1462
|
-
* Or in a template as a helper:
|
|
1463
|
-
*
|
|
1464
|
-
* ```gjs
|
|
1465
|
-
* import { getPromiseState } from '@warp-drive/ember';
|
|
1466
|
-
*
|
|
1467
|
-
* <template>
|
|
1468
|
-
* {{#let (getPromiseState @request) as |state|}}
|
|
1469
|
-
* {{#if state.isPending}} <Spinner />
|
|
1470
|
-
* {{else if state.isError}} <ErrorForm @error={{state.error}} />
|
|
1471
|
-
* {{else}}
|
|
1472
|
-
* <h1>{{state.result.title}}</h1>
|
|
1473
|
-
* {{/if}}
|
|
1474
|
-
* {{/let}}
|
|
1475
|
-
* </template>
|
|
1476
|
-
* ```
|
|
1477
|
-
*
|
|
1478
|
-
* If looking to use in a template, consider also the `<Await />` component.
|
|
1479
|
-
*
|
|
1480
|
-
* See also {@link PromiseState}
|
|
1481
|
-
*/
|
|
1482
|
-
function getPromiseState(promise) {
|
|
1483
|
-
const _promise = getPromise(promise);
|
|
1484
|
-
let state = PromiseCache.get(_promise);
|
|
1485
|
-
if (!state) {
|
|
1486
|
-
state = createPromiseState(_promise);
|
|
1487
|
-
PromiseCache.set(_promise, state);
|
|
1488
|
-
}
|
|
1489
|
-
return state;
|
|
1490
|
-
}
|
|
1491
|
-
|
|
1492
|
-
//#endregion
|
|
1493
|
-
export { ARRAY_SIGNAL as C, willSyncFlushWatchers as D, waitFor as E, withSignalStore as S, setupSignals as T, createInternalSignal as _, createSignalDescriptor as a, notifyInternalSignal as b, defineSignal as c, gate as d, memoized as f, createInternalMemo as g, consumeInternalSignal as h, getRequestState as i, entangleInitiallyStaleSignal as l, Signals as m, DISPOSE as n, defineGate as o, signal as p, createRequestSubscription as r, defineNonEnumerableSignal as s, getPromiseState as t, entangleSignal as u, getOrCreateInternalSignal as v, OBJECT_SIGNAL as w, peekInternalSignal as x, makeInitializer as y };
|
|
1494
|
-
//# sourceMappingURL=-private-TNaS5Piv.js.map
|