@warp-drive-mirror/core 5.10.0-alpha.12 → 5.10.0-alpha.14
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 +32 -0
- package/dist/{unpkg/dev/-private-Dtj8O5W7.js → -private-CmNOwhK0.js} +3 -1
- package/dist/{-private-Dtj8O5W7.js.map → -private-CmNOwhK0.js.map} +1 -1
- package/dist/{-private-CjK1Dmuh.js → -private-Y-13dsHO.js} +545 -151
- package/dist/-private-Y-13dsHO.js.map +1 -0
- package/dist/{aliases-BWYW5EhX.d.ts → aliases-BQmAxXmb.d.ts} +4 -1
- package/dist/aliases-BQmAxXmb.d.ts.map +1 -0
- package/dist/build-config/babel-macros.d.ts +5 -0
- package/dist/build-config/canary-features.d.ts +5 -0
- package/dist/build-config/debugging.d.ts +59 -0
- package/dist/build-config/deprecations.d.ts +5 -0
- package/dist/build-config.d.ts +17 -0
- package/dist/{change-C7kqv2kW.d.ts → change-DClXcHvr.d.ts} +4 -2
- package/dist/change-DClXcHvr.d.ts.map +1 -0
- package/dist/{concepts-DFldVwEM.d.ts → concepts-DzuY5M1K.d.ts} +14 -5
- package/dist/concepts-DzuY5M1K.d.ts.map +1 -0
- package/dist/{configure-B_F639tN.d.ts → configure-CodrrdQr.d.ts} +57 -8
- package/dist/configure-CodrrdQr.d.ts.map +1 -0
- package/dist/configure.d.ts +10 -2
- package/dist/configure.js +2 -2
- package/dist/{document-Ca4ZZBd9.d.ts → document-Ni8Ns26t.d.ts} +22 -4
- package/dist/document-Ni8Ns26t.d.ts.map +1 -0
- package/dist/{error-0uD6GkNX.d.ts → error-APuUdUGk.d.ts} +4 -2
- package/dist/error-APuUdUGk.d.ts.map +1 -0
- package/dist/{fields-CnlWuUd5.d.ts → fields-D6173Q_a.d.ts} +126 -5
- package/dist/fields-D6173Q_a.d.ts.map +1 -0
- package/dist/graph/-private.d.ts +1 -1
- package/dist/graph/-private.js +2 -0
- package/dist/graph/-private.js.map +1 -1
- package/dist/{graph-DLqYXP2z.d.ts → graph-rjTyJ-gd.d.ts} +25 -5
- package/dist/graph-rjTyJ-gd.d.ts.map +1 -0
- package/dist/{identifier-DQnqOSJK.d.ts → identifier-B_tK3FUw.d.ts} +29 -4
- package/dist/identifier-B_tK3FUw.d.ts.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{internal-DBnp5uP6.d.ts → internal-BOC6nyCi.d.ts} +516 -41
- package/dist/internal-BOC6nyCi.d.ts.map +1 -0
- package/dist/{json-api-raw-C5APJHHB.d.ts → json-api-raw-BxzNsCg0.d.ts} +44 -2
- package/dist/json-api-raw-BxzNsCg0.d.ts.map +1 -0
- package/dist/{mutations-CqtoGB4t.d.ts → mutations-C81gbYjB.d.ts} +18 -2
- package/dist/mutations-C81gbYjB.d.ts.map +1 -0
- package/dist/{operations-D1qA6r0_.d.ts → operations-B4pQM7D6.d.ts} +39 -5
- package/dist/operations-B4pQM7D6.d.ts.map +1 -0
- package/dist/{params-DrEx3bf8.d.ts → params-dbHiSOMF.d.ts} +11 -1
- package/dist/params-dbHiSOMF.d.ts.map +1 -0
- package/dist/{raw-D5hnjiq7.d.ts → raw-CiC64nCY.d.ts} +10 -1
- package/dist/raw-CiC64nCY.d.ts.map +1 -0
- package/dist/reactive/-private.d.ts +1 -1
- package/dist/reactive/-private.js +1 -1
- package/dist/reactive.d.ts +277 -2
- package/dist/reactive.js +3 -3
- package/dist/{record-D3QQcaIR.d.ts → record-DDxPtzcY.d.ts} +22 -2
- package/dist/record-DDxPtzcY.d.ts.map +1 -0
- package/dist/{relationship-CmHzMPKf.d.ts → relationship-BlGIXgj4.d.ts} +10 -3
- package/dist/relationship-BlGIXgj4.d.ts.map +1 -0
- package/dist/{request-Di274pQz.js → request-DUGpwUhf.js} +45 -10
- package/dist/request-DUGpwUhf.js.map +1 -0
- package/dist/request.d.ts +9 -1
- package/dist/request.js +1 -1
- package/dist/signals/-leaked.d.ts +100 -4
- package/dist/signals/-leaked.d.ts.map +1 -1
- package/dist/signals/-leaked.js +1 -1
- package/dist/{src-B9WcEdYg.js → src-DDLNZD8D.js} +223 -22
- package/dist/src-DDLNZD8D.js.map +1 -0
- package/dist/store/-private.d.ts +1 -1
- package/dist/store/-private.js +1 -1
- package/dist/{store-DNF9Rgoh.js → store-lcyaxrpj.js} +16 -1
- package/dist/store-lcyaxrpj.js.map +1 -0
- package/dist/store.d.ts +6 -1
- package/dist/store.js +1 -1
- package/dist/{symbols-DjRDCeX0.d.ts → symbols-Cu9un1NR.d.ts} +10 -1
- package/dist/symbols-Cu9un1NR.d.ts.map +1 -0
- package/dist/types/-private.d.ts +1 -0
- package/dist/types/-private.js +1 -1
- package/dist/types/cache/aliases.d.ts +1 -1
- package/dist/types/cache/change.d.ts +1 -1
- package/dist/types/cache/mutations.d.ts +1 -1
- package/dist/types/cache/operations.d.ts +1 -1
- package/dist/types/cache/relationship.d.ts +6 -1
- package/dist/types/cache.d.ts +6 -1
- package/dist/types/graph.d.ts +6 -1
- package/dist/types/identifier.d.ts +1 -1
- package/dist/types/identifier.js +33 -3
- package/dist/types/identifier.js.map +1 -1
- package/dist/types/json/raw.d.ts +1 -1
- package/dist/types/params.d.ts +1 -1
- package/dist/types/record.d.ts +6 -1
- package/dist/types/record.js +25 -0
- package/dist/types/record.js.map +1 -1
- package/dist/types/request.d.ts +1 -1
- package/dist/types/request.js +80 -0
- package/dist/types/request.js.map +1 -1
- package/dist/types/runtime.d.ts +10 -5
- package/dist/types/runtime.d.ts.map +1 -1
- package/dist/types/runtime.js +7 -3
- package/dist/types/runtime.js.map +1 -1
- package/dist/types/schema/concepts.d.ts +6 -1
- package/dist/types/schema/fields.d.ts +1 -1
- package/dist/types/schema/fields.js +132 -3
- package/dist/types/schema/fields.js.map +1 -1
- package/dist/types/schema/schema-service.d.ts +6 -1
- package/dist/types/spec/document.d.ts +1 -1
- package/dist/types/spec/error.d.ts +5 -1
- package/dist/types/spec/json-api-raw.d.ts +6 -1
- package/dist/types/symbols.d.ts +1 -1
- package/dist/types/symbols.js +14 -0
- package/dist/types/symbols.js.map +1 -1
- package/dist/types/utils.d.ts +1 -1
- package/dist/types.d.ts +10 -2
- package/dist/unpkg/{dev-deprecated/-private-DrQgwtNS.js → dev/-private-BoKjsWc1.js} +545 -151
- package/dist/unpkg/dev/-private-BoKjsWc1.js.map +1 -0
- package/dist/{-private-Dtj8O5W7.js → unpkg/dev/-private-CmNOwhK0.js} +3 -1
- package/dist/unpkg/dev/{-private-Dtj8O5W7.js.map → -private-CmNOwhK0.js.map} +1 -1
- package/dist/unpkg/dev/configure.js +2 -2
- package/dist/unpkg/dev/graph/-private.js +2 -0
- 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-nAaeDlS9.js → dev/request-BQUGZTOj.js} +45 -10
- package/dist/unpkg/dev/request-BQUGZTOj.js.map +1 -0
- package/dist/unpkg/dev/request.js +1 -1
- package/dist/unpkg/dev/signals/-leaked.js +1 -1
- package/dist/unpkg/dev/{src-CkkrRFE1.js → src-DqRXbeNO.js} +214 -15
- package/dist/unpkg/dev/src-DqRXbeNO.js.map +1 -0
- package/dist/unpkg/dev/store/-private.js +1 -1
- package/dist/unpkg/dev/{store-BIFNM_fB.js → store-BUV8Pfi7.js} +16 -1
- package/dist/unpkg/dev/store-BUV8Pfi7.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/identifier.js +33 -3
- package/dist/unpkg/dev/types/identifier.js.map +1 -1
- package/dist/unpkg/dev/types/record.js +25 -0
- package/dist/unpkg/dev/types/record.js.map +1 -1
- package/dist/unpkg/dev/types/request.js +80 -0
- package/dist/unpkg/dev/types/request.js.map +1 -1
- package/dist/unpkg/dev/types/runtime.js +7 -3
- package/dist/unpkg/dev/types/runtime.js.map +1 -1
- package/dist/unpkg/dev/types/schema/fields.js +132 -3
- package/dist/unpkg/dev/types/schema/fields.js.map +1 -1
- package/dist/unpkg/dev/types/symbols.js +14 -0
- package/dist/unpkg/dev/types/symbols.js.map +1 -1
- package/dist/unpkg/{dev/-private-DrQgwtNS.js → dev-deprecated/-private-BoKjsWc1.js} +545 -151
- package/dist/unpkg/dev-deprecated/-private-BoKjsWc1.js.map +1 -0
- package/dist/unpkg/{prod-deprecated/-private-Dtj8O5W7.js → dev-deprecated/-private-CmNOwhK0.js} +3 -1
- package/dist/unpkg/dev-deprecated/{-private-Dtj8O5W7.js.map → -private-CmNOwhK0.js.map} +1 -1
- package/dist/unpkg/dev-deprecated/configure.js +2 -2
- package/dist/unpkg/dev-deprecated/graph/-private.js +2 -0
- 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-nAaeDlS9.js → dev-deprecated/request-BQUGZTOj.js} +45 -10
- package/dist/unpkg/dev-deprecated/request-BQUGZTOj.js.map +1 -0
- package/dist/unpkg/dev-deprecated/request.js +1 -1
- package/dist/unpkg/dev-deprecated/signals/-leaked.js +1 -1
- package/dist/unpkg/dev-deprecated/{src-oz6OaQXu.js → src-EY9o2zd6.js} +216 -15
- package/dist/unpkg/dev-deprecated/src-EY9o2zd6.js.map +1 -0
- package/dist/unpkg/dev-deprecated/store/-private.js +1 -1
- package/dist/unpkg/dev-deprecated/{store-X1WN7P_O.js → store-CCZBSe0p.js} +16 -1
- package/dist/unpkg/dev-deprecated/store-CCZBSe0p.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/identifier.js +33 -3
- package/dist/unpkg/dev-deprecated/types/identifier.js.map +1 -1
- package/dist/unpkg/dev-deprecated/types/record.js +25 -0
- package/dist/unpkg/dev-deprecated/types/record.js.map +1 -1
- package/dist/unpkg/dev-deprecated/types/request.js +80 -0
- package/dist/unpkg/dev-deprecated/types/request.js.map +1 -1
- package/dist/unpkg/dev-deprecated/types/runtime.js +7 -3
- package/dist/unpkg/dev-deprecated/types/runtime.js.map +1 -1
- package/dist/unpkg/dev-deprecated/types/schema/fields.js +132 -3
- package/dist/unpkg/dev-deprecated/types/schema/fields.js.map +1 -1
- package/dist/unpkg/dev-deprecated/types/symbols.js +14 -0
- package/dist/unpkg/dev-deprecated/types/symbols.js.map +1 -1
- package/dist/unpkg/prod/{-private-Dg1vsF-H.js → -private-CRDwlN1v.js} +518 -145
- package/dist/unpkg/prod/-private-CRDwlN1v.js.map +1 -0
- package/dist/unpkg/prod/-private-CmNOwhK0.js +24 -0
- package/dist/unpkg/prod/{-private-Dtj8O5W7.js.map → -private-CmNOwhK0.js.map} +1 -1
- package/dist/unpkg/prod/configure.js +2 -2
- package/dist/unpkg/prod/graph/-private.js +2 -0
- 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-DK7nNaAf.js → request-0h8eJko9.js} +45 -10
- package/dist/unpkg/prod/request-0h8eJko9.js.map +1 -0
- package/dist/unpkg/prod/request.js +1 -1
- package/dist/unpkg/prod/signals/-leaked.js +1 -1
- package/dist/unpkg/prod/{src-BGKCOL5L.js → src-Dagh1FmP.js} +214 -15
- package/dist/unpkg/prod/src-Dagh1FmP.js.map +1 -0
- package/dist/unpkg/prod/store/-private.js +1 -1
- package/dist/unpkg/{prod-deprecated/store-BWhmb7Ob.js → prod/store-CQOsqdST.js} +16 -1
- package/dist/unpkg/prod/store-CQOsqdST.js.map +1 -0
- package/dist/unpkg/prod/store.js +1 -1
- package/dist/unpkg/prod/types/-private.js +1 -1
- package/dist/unpkg/prod/types/identifier.js +33 -3
- package/dist/unpkg/prod/types/identifier.js.map +1 -1
- package/dist/unpkg/prod/types/record.js +25 -0
- package/dist/unpkg/prod/types/record.js.map +1 -1
- package/dist/unpkg/prod/types/request.js +80 -0
- package/dist/unpkg/prod/types/request.js.map +1 -1
- package/dist/unpkg/prod/types/runtime.js +7 -3
- package/dist/unpkg/prod/types/runtime.js.map +1 -1
- package/dist/unpkg/prod/types/schema/fields.js +132 -3
- package/dist/unpkg/prod/types/schema/fields.js.map +1 -1
- package/dist/unpkg/prod/types/symbols.js +14 -0
- package/dist/unpkg/prod/types/symbols.js.map +1 -1
- package/dist/unpkg/prod-deprecated/{-private-Dg1vsF-H.js → -private-CRDwlN1v.js} +518 -145
- package/dist/unpkg/prod-deprecated/-private-CRDwlN1v.js.map +1 -0
- package/dist/unpkg/{dev-deprecated/-private-Dtj8O5W7.js → prod-deprecated/-private-CmNOwhK0.js} +3 -1
- package/dist/unpkg/prod-deprecated/{-private-Dtj8O5W7.js.map → -private-CmNOwhK0.js.map} +1 -1
- package/dist/unpkg/prod-deprecated/configure.js +2 -2
- package/dist/unpkg/prod-deprecated/graph/-private.js +2 -0
- 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-DK7nNaAf.js → request-0h8eJko9.js} +45 -10
- package/dist/unpkg/prod-deprecated/request-0h8eJko9.js.map +1 -0
- package/dist/unpkg/prod-deprecated/request.js +1 -1
- package/dist/unpkg/prod-deprecated/signals/-leaked.js +1 -1
- package/dist/unpkg/prod-deprecated/{src-CGypdIsf.js → src-CvV5lz9D.js} +216 -15
- package/dist/unpkg/prod-deprecated/src-CvV5lz9D.js.map +1 -0
- package/dist/unpkg/prod-deprecated/store/-private.js +1 -1
- package/dist/unpkg/{prod/store-BWhmb7Ob.js → prod-deprecated/store-CQOsqdST.js} +16 -1
- package/dist/unpkg/prod-deprecated/store-CQOsqdST.js.map +1 -0
- package/dist/unpkg/prod-deprecated/store.js +1 -1
- package/dist/unpkg/prod-deprecated/types/-private.js +1 -1
- package/dist/unpkg/prod-deprecated/types/identifier.js +33 -3
- package/dist/unpkg/prod-deprecated/types/identifier.js.map +1 -1
- package/dist/unpkg/prod-deprecated/types/record.js +25 -0
- package/dist/unpkg/prod-deprecated/types/record.js.map +1 -1
- package/dist/unpkg/prod-deprecated/types/request.js +80 -0
- package/dist/unpkg/prod-deprecated/types/request.js.map +1 -1
- package/dist/unpkg/prod-deprecated/types/runtime.js +7 -3
- package/dist/unpkg/prod-deprecated/types/runtime.js.map +1 -1
- package/dist/unpkg/prod-deprecated/types/schema/fields.js +132 -3
- package/dist/unpkg/prod-deprecated/types/schema/fields.js.map +1 -1
- package/dist/unpkg/prod-deprecated/types/symbols.js +14 -0
- package/dist/unpkg/prod-deprecated/types/symbols.js.map +1 -1
- package/dist/{utils-BtURiy8l.d.ts → utils-CNmQoKm8.d.ts} +8 -1
- package/dist/utils-CNmQoKm8.d.ts.map +1 -0
- package/logos/README.md +1 -1
- package/package.json +5 -5
- package/dist/-private-CjK1Dmuh.js.map +0 -1
- package/dist/aliases-BWYW5EhX.d.ts.map +0 -1
- package/dist/change-C7kqv2kW.d.ts.map +0 -1
- package/dist/concepts-DFldVwEM.d.ts.map +0 -1
- package/dist/configure-B_F639tN.d.ts.map +0 -1
- package/dist/document-Ca4ZZBd9.d.ts.map +0 -1
- package/dist/error-0uD6GkNX.d.ts.map +0 -1
- package/dist/fields-CnlWuUd5.d.ts.map +0 -1
- package/dist/graph-DLqYXP2z.d.ts.map +0 -1
- package/dist/identifier-DQnqOSJK.d.ts.map +0 -1
- package/dist/internal-DBnp5uP6.d.ts.map +0 -1
- package/dist/json-api-raw-C5APJHHB.d.ts.map +0 -1
- package/dist/mutations-CqtoGB4t.d.ts.map +0 -1
- package/dist/operations-D1qA6r0_.d.ts.map +0 -1
- package/dist/params-DrEx3bf8.d.ts.map +0 -1
- package/dist/raw-D5hnjiq7.d.ts.map +0 -1
- package/dist/record-D3QQcaIR.d.ts.map +0 -1
- package/dist/relationship-CmHzMPKf.d.ts.map +0 -1
- package/dist/request-Di274pQz.js.map +0 -1
- package/dist/src-B9WcEdYg.js.map +0 -1
- package/dist/store-DNF9Rgoh.js.map +0 -1
- package/dist/symbols-DjRDCeX0.d.ts.map +0 -1
- package/dist/unpkg/dev/-private-DrQgwtNS.js.map +0 -1
- package/dist/unpkg/dev/request-nAaeDlS9.js.map +0 -1
- package/dist/unpkg/dev/src-CkkrRFE1.js.map +0 -1
- package/dist/unpkg/dev/store-BIFNM_fB.js.map +0 -1
- package/dist/unpkg/dev-deprecated/-private-DrQgwtNS.js.map +0 -1
- package/dist/unpkg/dev-deprecated/request-nAaeDlS9.js.map +0 -1
- package/dist/unpkg/dev-deprecated/src-oz6OaQXu.js.map +0 -1
- package/dist/unpkg/dev-deprecated/store-X1WN7P_O.js.map +0 -1
- package/dist/unpkg/prod/-private-Dg1vsF-H.js.map +0 -1
- package/dist/unpkg/prod/-private-Dtj8O5W7.js +0 -22
- package/dist/unpkg/prod/request-DK7nNaAf.js.map +0 -1
- package/dist/unpkg/prod/src-BGKCOL5L.js.map +0 -1
- package/dist/unpkg/prod/store-BWhmb7Ob.js.map +0 -1
- package/dist/unpkg/prod-deprecated/-private-Dg1vsF-H.js.map +0 -1
- package/dist/unpkg/prod-deprecated/request-DK7nNaAf.js.map +0 -1
- package/dist/unpkg/prod-deprecated/src-CGypdIsf.js.map +0 -1
- package/dist/unpkg/prod-deprecated/store-BWhmb7Ob.js.map +0 -1
- package/dist/utils-BtURiy8l.d.ts.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getOrSetGlobal, peekTransient, setTransient } from "./types/-private.js";
|
|
2
|
-
import { f as setPromiseResult, o as DOMError, u as getPromiseResult } from "./request-
|
|
2
|
+
import { f as setPromiseResult, o as DOMError, u as getPromiseResult } from "./request-DUGpwUhf.js";
|
|
3
3
|
import { getGlobalConfig, macroCondition } from "@embroider/macros";
|
|
4
4
|
|
|
5
5
|
//#region src/signals/reactivity/configure.ts
|
|
@@ -16,10 +16,12 @@ const OBJECT_SIGNAL = getOrSetGlobal("#{}", Symbol("#{}"));
|
|
|
16
16
|
* The hooks which MUST be configured in order to use reactive arrays,
|
|
17
17
|
* resources and documents with framework specfic signals or TC39 signals.
|
|
18
18
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
19
|
+
* To support multiple frameworks on the same page, import
|
|
20
|
+
* `@warp-drive-mirror/alien-signals/install` before each framework's `install` entry
|
|
21
|
+
* point. Its hooks implement {@link SignalHooks.register}, so each framework's
|
|
22
|
+
* hooks, passed to {@link registerSignals}, are added to its signals graph
|
|
23
|
+
* instead of replacing it, and its memos stay up to date for every framework.
|
|
24
|
+
* See [Using Ember and React on the Same Page](/guides/the-manual/cookbook/multiple-frameworks-on-one-page.md).
|
|
23
25
|
*
|
|
24
26
|
* Unlike many signals implementations, WarpDrive does not wrap values as
|
|
25
27
|
* signals directly, but instead uses signals to alert the reactive layer
|
|
@@ -34,6 +36,8 @@ const OBJECT_SIGNAL = getOrSetGlobal("#{}", Symbol("#{}"));
|
|
|
34
36
|
* scenarios you may also be interested in integrating with the {@link NotificationManager}
|
|
35
37
|
* more directly.
|
|
36
38
|
*
|
|
39
|
+
* @summary The create, consume, notify, and memo hooks a framework or TC39 signals implementation
|
|
40
|
+
* supplies to `setupSignals` to make WarpDrive data reactive.
|
|
37
41
|
* @public
|
|
38
42
|
*/
|
|
39
43
|
/**
|
|
@@ -49,11 +53,14 @@ const OBJECT_SIGNAL = getOrSetGlobal("#{}", Symbol("#{}"));
|
|
|
49
53
|
* }
|
|
50
54
|
* ```
|
|
51
55
|
*
|
|
56
|
+
* @summary The options passed to the `setupSignals` callback, including the well-known key WarpDrive
|
|
57
|
+
* uses for an array's contents signal.
|
|
52
58
|
* @public
|
|
53
59
|
*/
|
|
54
60
|
/**
|
|
55
|
-
* Configures the signals implementation to use
|
|
56
|
-
*
|
|
61
|
+
* Configures the signals implementation to use, replacing any configured
|
|
62
|
+
* before. To add a framework's hooks alongside those of other frameworks, use
|
|
63
|
+
* {@link registerSignals} instead.
|
|
57
64
|
*
|
|
58
65
|
* See {@link HooksOptions} for the options passed to the provided function
|
|
59
66
|
* when called.
|
|
@@ -61,6 +68,8 @@ const OBJECT_SIGNAL = getOrSetGlobal("#{}", Symbol("#{}"));
|
|
|
61
68
|
* See {@link SignalHooks} for the implementation the callback function should
|
|
62
69
|
* return.
|
|
63
70
|
*
|
|
71
|
+
* @summary Registers the signal hooks WarpDrive uses for reactivity, built by a callback that receives
|
|
72
|
+
* `HooksOptions`.
|
|
64
73
|
* @public
|
|
65
74
|
* @param buildConfig - a function that takes options and returns a configuration object
|
|
66
75
|
*/
|
|
@@ -69,6 +78,33 @@ function setupSignals(buildConfig) {
|
|
|
69
78
|
setTransient("signalHooks", hooks);
|
|
70
79
|
}
|
|
71
80
|
/**
|
|
81
|
+
* Adds the hooks built by `buildConfig` to the configured signals implementation if it composes
|
|
82
|
+
* other implementations, such as `@warp-drive-mirror/alien-signals`, and otherwise configures them with
|
|
83
|
+
* {@link setupSignals}.
|
|
84
|
+
*
|
|
85
|
+
* A framework's `install` entry point calls this rather than `setupSignals`, so that importing
|
|
86
|
+
* `@warp-drive-mirror/alien-signals/install` first lets every framework on the page share its signals
|
|
87
|
+
* and memos.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```ts
|
|
91
|
+
* import { registerSignals } from '@warp-drive-mirror/core/configure';
|
|
92
|
+
*
|
|
93
|
+
* registerSignals(buildSignalConfig);
|
|
94
|
+
* ```
|
|
95
|
+
*
|
|
96
|
+
* @summary Registers signal hooks with the configured composing implementation, or configures
|
|
97
|
+
* them with `setupSignals` when there is none.
|
|
98
|
+
* @since 5.10.0
|
|
99
|
+
* @public
|
|
100
|
+
* @param buildConfig - a function that takes options and returns a configuration object
|
|
101
|
+
*/
|
|
102
|
+
function registerSignals(buildConfig) {
|
|
103
|
+
const signalHooks = peekTransient("signalHooks");
|
|
104
|
+
if (signalHooks?.register) signalHooks.register(buildConfig);
|
|
105
|
+
else setupSignals(buildConfig);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
72
108
|
* Internal method for consuming the configured `createSignal` hook
|
|
73
109
|
*
|
|
74
110
|
* @private
|
|
@@ -615,6 +651,8 @@ async function watchStream(stream, loadingState) {
|
|
|
615
651
|
* reactive properties that can be used to build UIs that respond
|
|
616
652
|
* to the progress of a request.
|
|
617
653
|
*
|
|
654
|
+
* @summary Reactive download progress for a request, such as bytes loaded and timing, built by lazily
|
|
655
|
+
* reading its response stream.
|
|
618
656
|
* @hideconstructor
|
|
619
657
|
*/
|
|
620
658
|
var RequestLoadingState = class {
|
|
@@ -833,9 +871,11 @@ defineNonEnumerableSignal(RequestLoadingState.prototype, "_lastPacketTime", 0);
|
|
|
833
871
|
*
|
|
834
872
|
*/
|
|
835
873
|
/**
|
|
836
|
-
* The state of a request
|
|
837
|
-
*
|
|
838
|
-
* cancelled
|
|
874
|
+
* The state of a request that was aborted before it settled.
|
|
875
|
+
*
|
|
876
|
+
* A cancelled request has `status: 'cancelled'` and its `reason` is an
|
|
877
|
+
* `AbortError`. `isError` is also `true`, as for a {@link RejectedRequest},
|
|
878
|
+
* so check `status` or `isCancelled` to tell the two apart.
|
|
839
879
|
*
|
|
840
880
|
*/
|
|
841
881
|
/**
|
|
@@ -869,6 +909,8 @@ defineNonEnumerableSignal(RequestLoadingState.prototype, "_lastPacketTime", 0);
|
|
|
869
909
|
* - {@link RejectedRequest}
|
|
870
910
|
* - {@link CancelledRequest}
|
|
871
911
|
*
|
|
912
|
+
* @summary The reactive pending, fulfilled, rejected, or cancelled state of a request `Future`, as
|
|
913
|
+
* returned by `getRequestState`.
|
|
872
914
|
*/
|
|
873
915
|
const RequestStateProto = {};
|
|
874
916
|
function performRefresh(requester, request, isReload) {
|
|
@@ -923,7 +965,7 @@ function createRequestState(future) {
|
|
|
923
965
|
if (state.isError) {
|
|
924
966
|
promiseState.error = state.result;
|
|
925
967
|
promiseState.reason = state.result;
|
|
926
|
-
promiseState.status = "rejected";
|
|
968
|
+
promiseState.status = isAbortError(state.result) ? "cancelled" : "rejected";
|
|
927
969
|
promiseState.isError = true;
|
|
928
970
|
promiseState.isPending = false;
|
|
929
971
|
promiseState.isLoading = false;
|
|
@@ -959,7 +1001,7 @@ function createRequestState(future) {
|
|
|
959
1001
|
});
|
|
960
1002
|
promiseState.error = error;
|
|
961
1003
|
promiseState.reason = error;
|
|
962
|
-
promiseState.status = "rejected";
|
|
1004
|
+
promiseState.status = isAbortError(error) ? "cancelled" : "rejected";
|
|
963
1005
|
promiseState.isError = true;
|
|
964
1006
|
promiseState.isPending = false;
|
|
965
1007
|
promiseState.isLoading = false;
|
|
@@ -971,6 +1013,26 @@ function createRequestState(future) {
|
|
|
971
1013
|
/**
|
|
972
1014
|
* `getRequestState` can be used in both JavaScript and Template contexts.
|
|
973
1015
|
*
|
|
1016
|
+
* It returns a {@link RequestState}: a reactive object that updates as the
|
|
1017
|
+
* request advances. Calling it again with the same {@link Future} returns the
|
|
1018
|
+
* same object. Check `status` to narrow it to one of four states:
|
|
1019
|
+
*
|
|
1020
|
+
* - {@link PendingRequest} (`'pending'`) is the initial state, before the
|
|
1021
|
+
* request settles.
|
|
1022
|
+
* - {@link ResolvedRequest} (`'fulfilled'`) holds the response content on `value`.
|
|
1023
|
+
* - {@link RejectedRequest} (`'rejected'`) holds the error on `reason`.
|
|
1024
|
+
* - {@link CancelledRequest} (`'cancelled'`) is a request that was aborted.
|
|
1025
|
+
* `isError` is also `true` for a cancelled request, so check `status` or
|
|
1026
|
+
* `isCancelled` rather than `isError` if you handle it differently.
|
|
1027
|
+
*
|
|
1028
|
+
* Every state also exposes a {@link RequestLoadingState} on `loadingState`
|
|
1029
|
+
* for tracking the progress of the response stream.
|
|
1030
|
+
*
|
|
1031
|
+
* The [Reactive Control Flow](/guides/the-manual/reactivity/control-flow) guide shows
|
|
1032
|
+
* how to render request states with it, and
|
|
1033
|
+
* [Using The Response](/guides/the-manual/requests/using-the-response) covers the
|
|
1034
|
+
* `Future` it reads.
|
|
1035
|
+
*
|
|
974
1036
|
* ```ts
|
|
975
1037
|
* import { getRequestState } from '@warp-drive-mirror/ember';
|
|
976
1038
|
*
|
|
@@ -1017,6 +1079,10 @@ function createRequestState(future) {
|
|
|
1017
1079
|
* which offers a number of additional capabilities for requests *beyond* what
|
|
1018
1080
|
* `RequestState` provides.
|
|
1019
1081
|
*
|
|
1082
|
+
* @param future - the request {@link Future} to track, as returned by `store.request` or `requestManager.request`
|
|
1083
|
+
* @return the cached {@link RequestState} for `future`
|
|
1084
|
+
* @summary Returns a cached, reactive state object tracking a request `Future` through pending, success,
|
|
1085
|
+
* error, and cancellation.
|
|
1020
1086
|
*/
|
|
1021
1087
|
function getRequestState(future) {
|
|
1022
1088
|
let state = RequestCache.get(future);
|
|
@@ -1092,28 +1158,47 @@ function isNeverString(val) {
|
|
|
1092
1158
|
/**
|
|
1093
1159
|
* The individual autorefresh strategies a {@link RequestSubscription}
|
|
1094
1160
|
* may combine, see {@link AutorefreshBehaviorCombos}.
|
|
1161
|
+
*
|
|
1162
|
+
* @summary One autorefresh trigger for a request subscription: on reconnecting (`online`), on a timer
|
|
1163
|
+
* (`interval`), or on store invalidation (`invalid`).
|
|
1095
1164
|
*/
|
|
1096
1165
|
/**
|
|
1097
1166
|
* The value accepted by {@link SubscriptionArgs.autorefresh}: either a
|
|
1098
1167
|
* boolean, a single {@link AutorefreshBehaviorType}, or a comma-separated
|
|
1099
1168
|
* combination of up to three of them.
|
|
1169
|
+
*
|
|
1170
|
+
* @summary The accepted values for a request subscription's `autorefresh` option: a boolean or a
|
|
1171
|
+
* comma-separated mix of `online`, `interval`, and `invalid`.
|
|
1100
1172
|
*/
|
|
1101
1173
|
/**
|
|
1102
1174
|
* Utilities to assist in recovering from the error.
|
|
1175
|
+
*
|
|
1176
|
+
* @summary The online and visibility state plus a `retry` function that a request subscription exposes
|
|
1177
|
+
* for recovering from a failed request.
|
|
1103
1178
|
*/
|
|
1104
1179
|
/** @deprecated use {@link RecoveryFeatures} */
|
|
1105
1180
|
/**
|
|
1106
1181
|
* Utilities for keeping the request fresh
|
|
1182
|
+
*
|
|
1183
|
+
* @summary The online, visibility, and refreshing state plus `refresh`, `reload`, and `abort` functions a
|
|
1184
|
+
* request subscription exposes alongside successful content.
|
|
1107
1185
|
*/
|
|
1108
1186
|
/**
|
|
1109
1187
|
* The args accepted by the `<Request />` component.
|
|
1188
|
+
*
|
|
1189
|
+
* @summary The arguments of the `<Request />` component: the request or query to run, autorefresh
|
|
1190
|
+
* options, and an optional store or subscription.
|
|
1110
1191
|
*/
|
|
1111
1192
|
/**
|
|
1112
1193
|
* The args accepted by a {@link RequestSubscription}.
|
|
1194
|
+
*
|
|
1195
|
+
* @summary Options for a request subscription: the request or query to monitor and its autorefresh settings.
|
|
1113
1196
|
*/
|
|
1114
1197
|
/**
|
|
1115
1198
|
* A reactive class
|
|
1116
1199
|
*
|
|
1200
|
+
* @summary Reactive subscription that monitors a request or query, tracking online, visibility and refresh state and
|
|
1201
|
+
* handling autorefresh, reload and retry.
|
|
1117
1202
|
* @hideconstructor
|
|
1118
1203
|
*/
|
|
1119
1204
|
var RequestSubscription = class {
|
|
@@ -1544,6 +1629,9 @@ function isStore(store) {
|
|
|
1544
1629
|
/**
|
|
1545
1630
|
* Creates a {@link RequestSubscription}, the reactive class powering the
|
|
1546
1631
|
* `<Request />` component's autorefresh, retry, and refresh behaviors.
|
|
1632
|
+
*
|
|
1633
|
+
* @summary Creates a reactive subscription to a request or query that tracks its state and handles
|
|
1634
|
+
* autorefresh, retry, and refresh.
|
|
1547
1635
|
*/
|
|
1548
1636
|
function createRequestSubscription(store, args) {
|
|
1549
1637
|
return new RequestSubscription(store, args);
|
|
@@ -1610,6 +1698,8 @@ function getHref(link) {
|
|
|
1610
1698
|
* }
|
|
1611
1699
|
* ```
|
|
1612
1700
|
*
|
|
1701
|
+
* @summary Experimental: one page of a paginated collection, exposing its request, loading and error status, data,
|
|
1702
|
+
* and links to neighboring pages.
|
|
1613
1703
|
* @since 5.9.0
|
|
1614
1704
|
* @public
|
|
1615
1705
|
* @hideconstructor
|
|
@@ -1792,63 +1882,209 @@ var PageCache = class {
|
|
|
1792
1882
|
decorateMethodV2(this.prototype, "isLinked", [memoized]);
|
|
1793
1883
|
}
|
|
1794
1884
|
async load(request) {
|
|
1885
|
+
this.request = request;
|
|
1886
|
+
this.state = getRequestState(this.request);
|
|
1887
|
+
let content;
|
|
1888
|
+
try {
|
|
1889
|
+
content = (await this.request).content;
|
|
1890
|
+
} catch {
|
|
1891
|
+
return null;
|
|
1892
|
+
}
|
|
1893
|
+
this.applyDocument(content);
|
|
1894
|
+
return content;
|
|
1895
|
+
}
|
|
1896
|
+
/**
|
|
1897
|
+
* Re-applies an already-loaded page from a newer request for the same page
|
|
1898
|
+
* (a reload, or a route-driven navigation back to it). The newer document is
|
|
1899
|
+
* authoritative: its links and page hints replace the ones recorded from
|
|
1900
|
+
* the earlier load, and the collection total is updated from it. The page
|
|
1901
|
+
* keeps its current request until the newer one resolves, so a page on
|
|
1902
|
+
* screen does not flash a loading state; a rejected request leaves the
|
|
1903
|
+
* page untouched.
|
|
1904
|
+
*
|
|
1905
|
+
* @internal
|
|
1906
|
+
*/
|
|
1907
|
+
async update(request) {
|
|
1908
|
+
const state = getRequestState(request);
|
|
1909
|
+
let content;
|
|
1795
1910
|
try {
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1911
|
+
content = (await request).content;
|
|
1912
|
+
} catch {
|
|
1913
|
+
return null;
|
|
1914
|
+
}
|
|
1915
|
+
this.request = request;
|
|
1916
|
+
this.state = state;
|
|
1917
|
+
this.applyDocument(content);
|
|
1918
|
+
return content;
|
|
1919
|
+
}
|
|
1920
|
+
/**
|
|
1921
|
+
* Records a loaded document's links and page number, and links this page
|
|
1922
|
+
* into the shared page graph.
|
|
1923
|
+
*
|
|
1924
|
+
* The document is authoritative for what it states: a link it names
|
|
1925
|
+
* explicitly (including an explicit `null`) overwrites whatever a neighbor
|
|
1926
|
+
* or an earlier load of this page recorded, and a link it omits is kept.
|
|
1927
|
+
* `next`/`prev` name the adjacent pages; `first`/`last` name the ends of
|
|
1928
|
+
* the collection, beyond which nothing may remain linked.
|
|
1929
|
+
*
|
|
1930
|
+
* For a numbered collection the document must also agree with the page
|
|
1931
|
+
* numbers: `next` is the page after this one, `prev` the page before, a
|
|
1932
|
+
* page without `prev` is page 1, a page without `next` is the last page,
|
|
1933
|
+
* `first` is page 1 and `last` is page `totalPages`. A document that
|
|
1934
|
+
* contradicts this is a server (or collection-mixing) bug and is asserted
|
|
1935
|
+
* in development, before anything is recorded from it. A cursor collection
|
|
1936
|
+
* has no numbers, so there its links are the only authority.
|
|
1937
|
+
*
|
|
1938
|
+
* @internal
|
|
1939
|
+
*/
|
|
1940
|
+
applyDocument(content) {
|
|
1941
|
+
const links = content?.links ?? {};
|
|
1942
|
+
const self = getHref(content?.links?.self);
|
|
1943
|
+
const first = getHref(content?.links?.first);
|
|
1944
|
+
const last = getHref(content?.links?.last);
|
|
1945
|
+
const next = getHref(content?.links?.next);
|
|
1946
|
+
const prev = getHref(content?.links?.prev);
|
|
1947
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) && ((test) => {
|
|
1948
|
+
if (!test) throw new Error("Expected the page to have a self link");
|
|
1949
|
+
})(self);
|
|
1950
|
+
const { currentPage, totalPages } = this.manager.readPageHints(content);
|
|
1951
|
+
const firstPage = first ? this.manager.getPageCache(first) : null;
|
|
1952
|
+
const lastPage = last ? this.manager.getPageCache(last) : null;
|
|
1953
|
+
const prevPage = prev ? this.manager.getPageCache(prev) : null;
|
|
1954
|
+
const nextPage = next ? this.manager.getPageCache(next) : null;
|
|
1955
|
+
if (this.manager.isNumbered) {
|
|
1956
|
+
const ownNumber = (page) => page === this ? currentPage : page.pageNumber;
|
|
1804
1957
|
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) && ((test) => {
|
|
1805
|
-
if (!test) throw new Error(
|
|
1806
|
-
})(
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
}
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1958
|
+
if (!test) throw new Error(`Page ${self} is page ${currentPage} but the collection has ${totalPages} pages: it lies beyond the collection total`);
|
|
1959
|
+
})(!currentPage || !totalPages || currentPage <= totalPages);
|
|
1960
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) && ((test) => {
|
|
1961
|
+
if (!test) throw new Error(`Page ${self} is page ${currentPage} and has no prev link but is not the first page`);
|
|
1962
|
+
})(!("prev" in links && !prev && currentPage > 1));
|
|
1963
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) && ((test) => {
|
|
1964
|
+
if (!test) throw new Error(`Page ${self} is page ${currentPage} of ${totalPages} and has no next link but is not the last page`);
|
|
1965
|
+
})(!("next" in links && !next && currentPage > 0 && totalPages > 0 && currentPage < totalPages));
|
|
1966
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) && ((test) => {
|
|
1967
|
+
if (!test) throw new Error(`Page ${self} is page ${currentPage} but its next link names page ${nextPage ? ownNumber(nextPage) : 0}, expected page ${currentPage + 1}`);
|
|
1968
|
+
})(!nextPage || !currentPage || !ownNumber(nextPage) || ownNumber(nextPage) === currentPage + 1);
|
|
1969
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) && ((test) => {
|
|
1970
|
+
if (!test) throw new Error(`Page ${self} is page ${currentPage} but its prev link names page ${prevPage ? ownNumber(prevPage) : 0}, expected page ${currentPage - 1}`);
|
|
1971
|
+
})(!prevPage || !currentPage || !ownNumber(prevPage) || ownNumber(prevPage) === currentPage - 1);
|
|
1972
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) && ((test) => {
|
|
1973
|
+
if (!test) throw new Error(`Page ${self} has a first link that names page ${firstPage ? ownNumber(firstPage) : 0}, expected page 1`);
|
|
1974
|
+
})(!firstPage || !ownNumber(firstPage) || ownNumber(firstPage) === 1);
|
|
1975
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) && ((test) => {
|
|
1976
|
+
if (!test) throw new Error(`Page ${self} has a last link that names page ${lastPage ? ownNumber(lastPage) : 0}, expected the last page ${totalPages}`);
|
|
1977
|
+
})(!lastPage || !totalPages || !ownNumber(lastPage) || ownNumber(lastPage) === totalPages);
|
|
1978
|
+
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) && ((test) => {
|
|
1979
|
+
if (!test) throw new Error(`Page ${self} has a first link to ${first} but that first page has a page linked before it`);
|
|
1980
|
+
})(!firstPage?.before);
|
|
1981
|
+
}
|
|
1982
|
+
if (currentPage) this.pageNumber = currentPage;
|
|
1983
|
+
this.manager.totalPages = totalPages;
|
|
1984
|
+
const stated = {};
|
|
1985
|
+
if ("first" in links) stated.first = first;
|
|
1986
|
+
if ("last" in links) stated.last = last;
|
|
1987
|
+
if ("next" in links) stated.next = next;
|
|
1988
|
+
if ("prev" in links) stated.prev = prev;
|
|
1989
|
+
this.updateLinks(stated);
|
|
1990
|
+
if ("next" in links && !next) {
|
|
1991
|
+
const after = this.after;
|
|
1992
|
+
this.detachAfter();
|
|
1993
|
+
if (after?.prevLink === self) after.updateLinks({ prev: null });
|
|
1994
|
+
}
|
|
1995
|
+
if ("prev" in links && !prev) {
|
|
1996
|
+
const before = this.before;
|
|
1997
|
+
this.detachBefore();
|
|
1998
|
+
if (before?.nextLink === self) before.updateLinks({ next: null });
|
|
1999
|
+
}
|
|
2000
|
+
if (lastPage) {
|
|
2001
|
+
lastPage.detachAfter();
|
|
2002
|
+
lastPage.updateLinks({ next: null });
|
|
2003
|
+
}
|
|
2004
|
+
if (firstPage) {
|
|
2005
|
+
firstPage.detachBefore();
|
|
2006
|
+
firstPage.updateLinks({ prev: null });
|
|
2007
|
+
}
|
|
2008
|
+
if (firstPage) {
|
|
2009
|
+
firstPage.setPageNumber(1);
|
|
2010
|
+
if (firstPage !== this && !firstPage.after) this.linkFirst(firstPage);
|
|
2011
|
+
}
|
|
2012
|
+
if (lastPage) {
|
|
2013
|
+
lastPage.setPageNumber(this.manager.totalPages);
|
|
2014
|
+
if (lastPage !== this && !lastPage.before) this.linkLast(lastPage);
|
|
2015
|
+
}
|
|
2016
|
+
if (nextPage) {
|
|
2017
|
+
nextPage.setPageNumber(this.pageNumber + 1);
|
|
2018
|
+
nextPage.updateLinks({ prev: self });
|
|
2019
|
+
}
|
|
2020
|
+
if (prevPage) {
|
|
2021
|
+
prevPage.setPageNumber(this.pageNumber - 1);
|
|
2022
|
+
prevPage.updateLinks({ next: self });
|
|
2023
|
+
}
|
|
2024
|
+
if (nextPage && this.after && this.after !== nextPage && this.after.pageNumber <= nextPage.pageNumber) this.detachAfter();
|
|
2025
|
+
if (prevPage && this.before && this.before !== prevPage && this.before.pageNumber >= prevPage.pageNumber) this.detachBefore();
|
|
2026
|
+
if (this.isLinked) {
|
|
2027
|
+
if (prevPage) prevPage.updateLinkage({ after: this });
|
|
2028
|
+
if (nextPage) nextPage.updateLinkage({ before: this });
|
|
2029
|
+
} else if (prevPage?.isLinked) {
|
|
2030
|
+
this.updateLinkage({ before: prevPage });
|
|
2031
|
+
if (nextPage) nextPage.updateLinkage({ before: this });
|
|
2032
|
+
} else if (nextPage?.isLinked) {
|
|
2033
|
+
this.updateLinkage({ after: nextPage });
|
|
2034
|
+
if (prevPage) prevPage.updateLinkage({ after: this });
|
|
2035
|
+
} else if ((prevPage || nextPage) && (firstPage || lastPage)) this.lookupLinkage(firstPage, lastPage);
|
|
2036
|
+
else if (prevPage || nextPage) this.updateLinkage({
|
|
2037
|
+
before: prevPage,
|
|
2038
|
+
after: nextPage
|
|
2039
|
+
});
|
|
2040
|
+
}
|
|
2041
|
+
/** @internal */
|
|
2042
|
+
detachAfter() {
|
|
2043
|
+
const after = this.after;
|
|
2044
|
+
if (after) {
|
|
2045
|
+
if (after.before === this) after.setBefore(null);
|
|
2046
|
+
this.setAfter(null);
|
|
2047
|
+
}
|
|
1850
2048
|
}
|
|
1851
2049
|
/** @internal */
|
|
2050
|
+
detachBefore() {
|
|
2051
|
+
const before = this.before;
|
|
2052
|
+
if (before) {
|
|
2053
|
+
if (before.after === this) before.setAfter(null);
|
|
2054
|
+
this.setBefore(null);
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
/**
|
|
2058
|
+
* Links an unlinked `first` page before the earliest page reachable
|
|
2059
|
+
* backwards from this one that must follow it.
|
|
2060
|
+
*
|
|
2061
|
+
* @internal
|
|
2062
|
+
*/
|
|
2063
|
+
linkFirst(firstPage) {
|
|
2064
|
+
let head = this;
|
|
2065
|
+
while (head.before && head.before !== firstPage && (!head.before.pageNumber || head.before.pageNumber > firstPage.pageNumber)) head = head.before;
|
|
2066
|
+
firstPage.updateLinkage({ after: head });
|
|
2067
|
+
}
|
|
2068
|
+
/**
|
|
2069
|
+
* Links an unlinked `last` page after the furthest page reachable forwards
|
|
2070
|
+
* from this one that must precede it.
|
|
2071
|
+
*
|
|
2072
|
+
* @internal
|
|
2073
|
+
*/
|
|
2074
|
+
linkLast(lastPage) {
|
|
2075
|
+
let tail = this;
|
|
2076
|
+
while (tail.after && tail.after !== lastPage && (!tail.after.pageNumber || !lastPage.pageNumber || tail.after.pageNumber < lastPage.pageNumber)) tail = tail.after;
|
|
2077
|
+
lastPage.updateLinkage({ before: tail });
|
|
2078
|
+
}
|
|
2079
|
+
/**
|
|
2080
|
+
* Places this page between `before` and `after` in the graph (a missing side
|
|
2081
|
+
* is taken from the given side's current neighbor, so a single side splices
|
|
2082
|
+
* this page in). Pointers this page or the displaced neighbors held to their
|
|
2083
|
+
* old positions are cleared first, so a page moved within the graph never
|
|
2084
|
+
* leaves a dangling link behind that could close a cycle.
|
|
2085
|
+
*
|
|
2086
|
+
* @internal
|
|
2087
|
+
*/
|
|
1852
2088
|
updateLinkage({ before, after }) {
|
|
1853
2089
|
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) && ((test) => {
|
|
1854
2090
|
if (!test) throw new Error("Expected at least one of before or after page states to link to this page");
|
|
@@ -1856,10 +2092,16 @@ var PageCache = class {
|
|
|
1856
2092
|
const leftSide = before ?? after?.before;
|
|
1857
2093
|
const rightSide = after ?? before?.after;
|
|
1858
2094
|
if (leftSide && leftSide !== this) {
|
|
2095
|
+
if (this.before !== leftSide) this.detachBefore();
|
|
2096
|
+
const displaced = leftSide.after;
|
|
2097
|
+
if (displaced && displaced !== this && displaced !== rightSide && displaced.before === leftSide) displaced.setBefore(null);
|
|
1859
2098
|
leftSide.setAfter(this);
|
|
1860
2099
|
this.setBefore(leftSide);
|
|
1861
2100
|
}
|
|
1862
2101
|
if (rightSide && rightSide !== this) {
|
|
2102
|
+
if (this.after !== rightSide) this.detachAfter();
|
|
2103
|
+
const displaced = rightSide.before;
|
|
2104
|
+
if (displaced && displaced !== this && displaced !== leftSide && displaced.after === rightSide) displaced.setAfter(null);
|
|
1863
2105
|
rightSide.setBefore(this);
|
|
1864
2106
|
this.setAfter(rightSide);
|
|
1865
2107
|
}
|
|
@@ -1899,16 +2141,18 @@ var PageCache = class {
|
|
|
1899
2141
|
})(page !== this);
|
|
1900
2142
|
this.after = page;
|
|
1901
2143
|
}
|
|
1902
|
-
/**
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
if (
|
|
1911
|
-
if (
|
|
2144
|
+
/**
|
|
2145
|
+
* Records the given links. Only the keys present are applied, so a caller
|
|
2146
|
+
* states exactly what it knows: an explicit `null` clears a link, an
|
|
2147
|
+
* omitted key leaves the recorded link alone.
|
|
2148
|
+
*
|
|
2149
|
+
* @internal
|
|
2150
|
+
*/
|
|
2151
|
+
updateLinks = (links) => {
|
|
2152
|
+
if ("prev" in links) this.prevLink = links.prev ?? null;
|
|
2153
|
+
if ("next" in links) this.nextLink = links.next ?? null;
|
|
2154
|
+
if ("first" in links) this.firstLink = links.first ?? null;
|
|
2155
|
+
if ("last" in links) this.lastLink = links.last ?? null;
|
|
1912
2156
|
};
|
|
1913
2157
|
/** @internal */
|
|
1914
2158
|
setPageNumber = (pageNumber) => {
|
|
@@ -1934,6 +2178,8 @@ const PaginationCacheMap = /* @__PURE__ */ new Map();
|
|
|
1934
2178
|
* collection must provide the same function reference — define it once at module
|
|
1935
2179
|
* scope and import it everywhere.
|
|
1936
2180
|
*
|
|
2181
|
+
* @summary Experimental: a function you pass to `<Paginate />` that reads `currentPage` and `totalPages` from a
|
|
2182
|
+
* loaded document when they are not in the default `meta` locations.
|
|
1937
2183
|
* @since 5.9.0
|
|
1938
2184
|
* @public
|
|
1939
2185
|
*/
|
|
@@ -1942,6 +2188,8 @@ const PaginationCacheMap = /* @__PURE__ */ new Map();
|
|
|
1942
2188
|
* document `meta`, matching the behavior used before `pageHints` was configurable.
|
|
1943
2189
|
* Used whenever the consumer does not provide a `pageHints` function.
|
|
1944
2190
|
*
|
|
2191
|
+
* @summary Experimental: the fallback page-hints function, reading `meta.page` or `meta.currentPage` and
|
|
2192
|
+
* `meta.totalPages` from a document, with `0` meaning unknown.
|
|
1945
2193
|
* @since 5.9.0
|
|
1946
2194
|
* @public
|
|
1947
2195
|
*/
|
|
@@ -1961,6 +2209,8 @@ const defaultPageHints = (document) => {
|
|
|
1961
2209
|
* interact with — the cache itself is plumbing shared between the pagination
|
|
1962
2210
|
* classes.
|
|
1963
2211
|
*
|
|
2212
|
+
* @summary Experimental: the shared, app-wide store of loaded pages, page order, and `totalPages` for one paginated
|
|
2213
|
+
* collection, keyed by its `first` or `self` link.
|
|
1964
2214
|
* @since 5.9.0
|
|
1965
2215
|
* @public
|
|
1966
2216
|
* @hideconstructor
|
|
@@ -2055,17 +2305,28 @@ var PaginationCache = class {
|
|
|
2055
2305
|
}
|
|
2056
2306
|
return page;
|
|
2057
2307
|
}
|
|
2058
|
-
/**
|
|
2059
|
-
|
|
2308
|
+
/**
|
|
2309
|
+
* Loads the page at `url` with `request` when it is not loaded (or its load
|
|
2310
|
+
* failed), or re-applies `request`'s document when it is a newer request
|
|
2311
|
+
* for an already-loaded page (a reload, or navigating back to it: the newer
|
|
2312
|
+
* document is authoritative for the page's links and the collection total,
|
|
2313
|
+
* which may have changed since the first load).
|
|
2314
|
+
*
|
|
2315
|
+
* Resolves to the page once that has settled. A rejected request settles
|
|
2316
|
+
* too — it is surfaced through the page's state, not thrown. The promise
|
|
2317
|
+
* rejects only when the document contradicts the collection (see
|
|
2318
|
+
* {@link PageCache.applyDocument}), so the caller that triggered the load
|
|
2319
|
+
* is the one that hears about it.
|
|
2320
|
+
*
|
|
2321
|
+
* @internal
|
|
2322
|
+
*/
|
|
2323
|
+
async loadPage(url, request) {
|
|
2060
2324
|
const page = this.getPageCache(url);
|
|
2061
2325
|
if ((!page.isLoaded || page.isError) && request) {
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
page.
|
|
2066
|
-
this.updateFirstPage(page);
|
|
2067
|
-
if (document) this.totalPages = this.getTotalPages(document);
|
|
2068
|
-
});
|
|
2326
|
+
await page.load(request);
|
|
2327
|
+
this.updateFirstPage(page);
|
|
2328
|
+
} else if (request && page.isSuccess && request !== page.request) {
|
|
2329
|
+
if (await page.update(request)) this.updateFirstPage(page);
|
|
2069
2330
|
}
|
|
2070
2331
|
return page;
|
|
2071
2332
|
}
|
|
@@ -2075,10 +2336,6 @@ var PaginationCache = class {
|
|
|
2075
2336
|
while (maybeFirstPage.before) maybeFirstPage = maybeFirstPage.before;
|
|
2076
2337
|
if (!this.firstPage || this.firstPage.pageNumber > maybeFirstPage.pageNumber) this.firstPage = maybeFirstPage;
|
|
2077
2338
|
}
|
|
2078
|
-
/** @internal */
|
|
2079
|
-
getTotalPages(document) {
|
|
2080
|
-
return this.readPageHints(document).totalPages;
|
|
2081
|
-
}
|
|
2082
2339
|
/**
|
|
2083
2340
|
* Every page known to the shared graph, in order — loaded pages and pages
|
|
2084
2341
|
* known only from links — across all components sharing the collection.
|
|
@@ -2094,14 +2351,13 @@ var PaginationCache = class {
|
|
|
2094
2351
|
* ```
|
|
2095
2352
|
*/
|
|
2096
2353
|
get pages() {
|
|
2097
|
-
const
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
} };
|
|
2354
|
+
const pages = [];
|
|
2355
|
+
let page = this.firstPage;
|
|
2356
|
+
while (page) {
|
|
2357
|
+
pages.push(page);
|
|
2358
|
+
page = page.after;
|
|
2359
|
+
}
|
|
2360
|
+
return pages;
|
|
2105
2361
|
}
|
|
2106
2362
|
/**
|
|
2107
2363
|
* The items of every loaded page in the shared graph, flattened into one
|
|
@@ -2115,10 +2371,9 @@ var PaginationCache = class {
|
|
|
2115
2371
|
decorateMethodV2(this.prototype, "pages", [memoized]);
|
|
2116
2372
|
}
|
|
2117
2373
|
get data() {
|
|
2118
|
-
const
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
} };
|
|
2374
|
+
const items = [];
|
|
2375
|
+
for (const page of this.pages) if (page.data) items.push(...page.data);
|
|
2376
|
+
return items;
|
|
2122
2377
|
}
|
|
2123
2378
|
static {
|
|
2124
2379
|
decorateMethodV2(this.prototype, "data", [memoized]);
|
|
@@ -2129,6 +2384,8 @@ var PaginationCache = class {
|
|
|
2129
2384
|
* `first` or `self` link). Returns the same instance for the same key for the
|
|
2130
2385
|
* lifetime of the module.
|
|
2131
2386
|
*
|
|
2387
|
+
* @summary Experimental: returns the shared pagination cache for a collection's `first` or `self` link, creating it
|
|
2388
|
+
* on first use.
|
|
2132
2389
|
* @since 5.9.0
|
|
2133
2390
|
* @public
|
|
2134
2391
|
*/
|
|
@@ -2145,6 +2402,7 @@ function getPaginationCache(key) {
|
|
|
2145
2402
|
* Primarily intended for test isolation, since the cache is keyed by url and
|
|
2146
2403
|
* otherwise persists for the lifetime of the module.
|
|
2147
2404
|
*
|
|
2405
|
+
* @summary Experimental: discards every shared pagination cache, mainly so tests start from a clean state.
|
|
2148
2406
|
* @since 5.9.0
|
|
2149
2407
|
* @public
|
|
2150
2408
|
*/
|
|
@@ -2161,25 +2419,40 @@ function clearPaginationCache() {
|
|
|
2161
2419
|
*
|
|
2162
2420
|
* - `'paged'` — single-page view, see {@link PagedPaginationState}.
|
|
2163
2421
|
* - `'infinite'` — accumulated view, see {@link InfinitePaginationState}.
|
|
2422
|
+
*
|
|
2423
|
+
* @summary Experimental: the `@mode` value of `<Paginate />`, either `'paged'` for a single-page view or
|
|
2424
|
+
* `'infinite'` for an accumulated view, which selects the yielded pagination API.
|
|
2164
2425
|
*/
|
|
2165
2426
|
/**
|
|
2166
2427
|
* The part of a {@link PaginationState} available to both navigation surfaces.
|
|
2428
|
+
*
|
|
2429
|
+
* @summary Experimental: the pagination state members available in both paged and infinite mode, namely
|
|
2430
|
+
* `totalPages` and `adoptPage`.
|
|
2167
2431
|
*/
|
|
2168
2432
|
/**
|
|
2169
2433
|
* The paged (single-page view) surface of a {@link PaginationState}: render
|
|
2170
2434
|
* {@link PaginationState.activePageRequest | activePageRequest}, navigate with
|
|
2171
2435
|
* {@link PaginationState.loadPage | loadPage}. This is what the `<Paginate />`
|
|
2172
2436
|
* component yields in `'paged'` mode (the default).
|
|
2437
|
+
*
|
|
2438
|
+
* @summary Experimental: the pagination state `<Paginate />` yields in paged mode, exposing the active page, its
|
|
2439
|
+
* request, and `loadPage` for navigating to a page by URL.
|
|
2173
2440
|
*/
|
|
2174
2441
|
/**
|
|
2175
2442
|
* The infinite (accumulated view) surface of a {@link PaginationState}: render
|
|
2176
2443
|
* {@link PaginationState.data | data}, grow it with
|
|
2177
2444
|
* {@link PaginationState.loadNext | loadNext}/{@link PaginationState.loadPrev | loadPrev}.
|
|
2178
2445
|
* This is what the `<Paginate />` component yields in `'infinite'` mode.
|
|
2446
|
+
*
|
|
2447
|
+
* @summary Experimental: the pagination state `<Paginate />` yields in infinite mode, exposing the accumulated
|
|
2448
|
+
* items and pages plus `loadNext` and `loadPrev` to extend them.
|
|
2179
2449
|
*/
|
|
2180
2450
|
/**
|
|
2181
2451
|
* Resolves a {@link PaginateMode} to the surface it exposes, so a component
|
|
2182
2452
|
* generic over the mode can yield only that surface.
|
|
2453
|
+
*
|
|
2454
|
+
* @summary Experimental: resolves a pagination mode to its state type, the infinite-mode state for `'infinite'`
|
|
2455
|
+
* and the paged-mode state otherwise.
|
|
2183
2456
|
*/
|
|
2184
2457
|
/**
|
|
2185
2458
|
* The per-component, local pagination state. It houses the state that is unique
|
|
@@ -2203,6 +2476,8 @@ function clearPaginationCache() {
|
|
|
2203
2476
|
* Instances are created via {@link getPaginationState} (or by the `<Paginate />`
|
|
2204
2477
|
* component on your behalf), never constructed directly.
|
|
2205
2478
|
*
|
|
2479
|
+
* @summary Experimental: one component's pagination state over a shared collection, tracking the active page and
|
|
2480
|
+
* the loaded run and providing paged and infinite navigation.
|
|
2206
2481
|
* @since 5.9.0
|
|
2207
2482
|
* @public
|
|
2208
2483
|
* @hideconstructor
|
|
@@ -2233,10 +2508,23 @@ var PaginationState = class {
|
|
|
2233
2508
|
* them backward/forward. Both seed to {@link initialPage}; a purely paged
|
|
2234
2509
|
* consumer never extends them, so they stay put and are effectively unused.
|
|
2235
2510
|
*
|
|
2511
|
+
* Only ever written through {@link extendRun} and {@link restartRun}, which
|
|
2512
|
+
* keep {@link runMembers} in step.
|
|
2513
|
+
*
|
|
2236
2514
|
* @internal
|
|
2237
2515
|
*/
|
|
2238
2516
|
/** @internal */
|
|
2239
2517
|
/**
|
|
2518
|
+
* Every page this component has loaded into its run — what the frontier
|
|
2519
|
+
* spanned each time it moved. Bounds the walk in {@link pages}: the shared
|
|
2520
|
+
* graph may relink a page in the run to one that another component sharing
|
|
2521
|
+
* the collection loaded, and that page is not part of this run until it is
|
|
2522
|
+
* loaded through here. Untracked bookkeeping — it only changes together with
|
|
2523
|
+
* the frontier signals, which carry the notification.
|
|
2524
|
+
*
|
|
2525
|
+
* @internal
|
|
2526
|
+
*/
|
|
2527
|
+
/**
|
|
2240
2528
|
* The request of the latest {@link adoptPage} call — only that call may
|
|
2241
2529
|
* commit. Later calls (or a {@link loadPage} navigation) claim the slot,
|
|
2242
2530
|
* superseding in-flight adoptions so the newest navigation always wins.
|
|
@@ -2249,6 +2537,7 @@ var PaginationState = class {
|
|
|
2249
2537
|
this.request = request;
|
|
2250
2538
|
this.pageHints = pageHints;
|
|
2251
2539
|
this._adoptTarget = null;
|
|
2540
|
+
this.runMembers = /* @__PURE__ */ new Set();
|
|
2252
2541
|
this.setup();
|
|
2253
2542
|
}
|
|
2254
2543
|
/**
|
|
@@ -2297,21 +2586,44 @@ var PaginationState = class {
|
|
|
2297
2586
|
* same collection to different extents each see only what they have scrolled
|
|
2298
2587
|
* through. For every page known to the whole collection, see
|
|
2299
2588
|
* {@link PaginationCache.pages}.
|
|
2589
|
+
*
|
|
2590
|
+
* The run is walked through the shared graph, so it ends early when a page
|
|
2591
|
+
* that was in it no longer follows the page before it — a reload that showed
|
|
2592
|
+
* the collection now ends sooner, or that its next cursor moved. It also ends
|
|
2593
|
+
* before a page this component never loaded: a reload may relink a page in
|
|
2594
|
+
* the run to one another component sharing the collection scrolled to, and
|
|
2595
|
+
* that page joins this run only through {@link loadNext}.
|
|
2300
2596
|
*/
|
|
2301
2597
|
static {
|
|
2302
2598
|
decorateMethodV2(this.prototype, "totalPages", [memoized]);
|
|
2303
2599
|
}
|
|
2304
2600
|
get pages() {
|
|
2305
|
-
const
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
}
|
|
2601
|
+
const pages = [];
|
|
2602
|
+
const end = this.frontierEnd;
|
|
2603
|
+
let page = this.frontierStart;
|
|
2604
|
+
while (page) {
|
|
2605
|
+
pages.push(page);
|
|
2606
|
+
if (page === end) break;
|
|
2607
|
+
const next = page.after;
|
|
2608
|
+
if (!next?.isSuccess || !this.runMembers.has(next)) break;
|
|
2609
|
+
page = next;
|
|
2610
|
+
}
|
|
2611
|
+
return pages;
|
|
2612
|
+
}
|
|
2613
|
+
/**
|
|
2614
|
+
* The last page of the run {@link pages} walks — the forward frontier, or
|
|
2615
|
+
* the page before the first one that no longer follows in the graph or that
|
|
2616
|
+
* this component never loaded.
|
|
2617
|
+
*
|
|
2618
|
+
* @internal
|
|
2619
|
+
*/
|
|
2620
|
+
static {
|
|
2621
|
+
decorateMethodV2(this.prototype, "pages", [memoized]);
|
|
2622
|
+
}
|
|
2623
|
+
get runEnd() {
|
|
2624
|
+
let end = null;
|
|
2625
|
+
for (const page of this.pages) end = page;
|
|
2626
|
+
return end;
|
|
2315
2627
|
}
|
|
2316
2628
|
/**
|
|
2317
2629
|
* The accumulated items across the loaded run, from the backward frontier to
|
|
@@ -2336,13 +2648,12 @@ var PaginationState = class {
|
|
|
2336
2648
|
* ```
|
|
2337
2649
|
*/
|
|
2338
2650
|
static {
|
|
2339
|
-
decorateMethodV2(this.prototype, "
|
|
2651
|
+
decorateMethodV2(this.prototype, "runEnd", [memoized]);
|
|
2340
2652
|
}
|
|
2341
2653
|
get data() {
|
|
2342
|
-
const
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
} };
|
|
2654
|
+
const items = [];
|
|
2655
|
+
for (const page of this.pages) if (page.data) items.push(...page.data);
|
|
2656
|
+
return items;
|
|
2346
2657
|
}
|
|
2347
2658
|
/**
|
|
2348
2659
|
* Whether a page exists after the forward frontier — i.e. there is more to load
|
|
@@ -2358,7 +2669,7 @@ var PaginationState = class {
|
|
|
2358
2669
|
decorateMethodV2(this.prototype, "data", [memoized]);
|
|
2359
2670
|
}
|
|
2360
2671
|
get hasNext() {
|
|
2361
|
-
return Boolean(this.
|
|
2672
|
+
return Boolean(this.runEnd?.nextLink);
|
|
2362
2673
|
}
|
|
2363
2674
|
/**
|
|
2364
2675
|
* Whether a page exists before the backward frontier.
|
|
@@ -2373,7 +2684,10 @@ var PaginationState = class {
|
|
|
2373
2684
|
* The request for the page just after the forward frontier, for the infinite
|
|
2374
2685
|
* surface. `null` until {@link loadNext} fires it (so a `<Request>` wrapping it
|
|
2375
2686
|
* renders its idle block), the in-flight `Future` while that page loads, then
|
|
2376
|
-
* `null` again once the frontier advances onto it. Also `null` at end-of-list
|
|
2687
|
+
* `null` again once the frontier advances onto it. Also `null` at end-of-list,
|
|
2688
|
+
* and while the page sits loaded in the shared cache (another component
|
|
2689
|
+
* scrolled to it) but outside this run — {@link loadNext} then joins it
|
|
2690
|
+
* without a request of its own.
|
|
2377
2691
|
*
|
|
2378
2692
|
* ```gts
|
|
2379
2693
|
* {{#if pages.hasNext}}
|
|
@@ -2388,9 +2702,9 @@ var PaginationState = class {
|
|
|
2388
2702
|
decorateMethodV2(this.prototype, "hasPrevious", [memoized]);
|
|
2389
2703
|
}
|
|
2390
2704
|
get nextRequest() {
|
|
2391
|
-
const url = this.
|
|
2705
|
+
const url = this.runEnd?.nextLink;
|
|
2392
2706
|
if (!url) return null;
|
|
2393
|
-
return this.
|
|
2707
|
+
return this.pendingRequest(url);
|
|
2394
2708
|
}
|
|
2395
2709
|
/**
|
|
2396
2710
|
* The request for the page just before the backward frontier. Mirror of
|
|
@@ -2402,12 +2716,24 @@ var PaginationState = class {
|
|
|
2402
2716
|
get previousRequest() {
|
|
2403
2717
|
const url = this.frontierStart?.prevLink;
|
|
2404
2718
|
if (!url) return null;
|
|
2405
|
-
return this.
|
|
2719
|
+
return this.pendingRequest(url);
|
|
2406
2720
|
}
|
|
2407
|
-
/**
|
|
2721
|
+
/**
|
|
2722
|
+
* The request of the page at `url` unless it already succeeded, in which
|
|
2723
|
+
* case there is nothing pending: the page either sits in this run, or joins
|
|
2724
|
+
* it on the next {@link loadNext}/{@link loadPrev} without a new request.
|
|
2725
|
+
*
|
|
2726
|
+
* @internal
|
|
2727
|
+
*/
|
|
2408
2728
|
static {
|
|
2409
2729
|
decorateMethodV2(this.prototype, "previousRequest", [memoized]);
|
|
2410
2730
|
}
|
|
2731
|
+
pendingRequest(url) {
|
|
2732
|
+
const page = this.paginationCache?.getPageCache(url);
|
|
2733
|
+
if (!page || page.isSuccess) return null;
|
|
2734
|
+
return page.request ?? null;
|
|
2735
|
+
}
|
|
2736
|
+
/** @internal */
|
|
2411
2737
|
async setup() {
|
|
2412
2738
|
let document;
|
|
2413
2739
|
try {
|
|
@@ -2424,9 +2750,31 @@ var PaginationState = class {
|
|
|
2424
2750
|
const cache = getPaginationCache(firstLink ?? selfLink ?? "");
|
|
2425
2751
|
cache.installPageHints(this.pageHints);
|
|
2426
2752
|
this.paginationCache = cache;
|
|
2427
|
-
|
|
2428
|
-
this.activePage = this.initialPage =
|
|
2429
|
-
this.
|
|
2753
|
+
const page = cache.getPageCache(selfLink);
|
|
2754
|
+
this.activePage = this.initialPage = page;
|
|
2755
|
+
this.restartRun(page);
|
|
2756
|
+
await cache.loadPage(selfLink, this.request);
|
|
2757
|
+
}
|
|
2758
|
+
/**
|
|
2759
|
+
* Moves the frontier onto a page adjacent to the run, recording it as a
|
|
2760
|
+
* member.
|
|
2761
|
+
*
|
|
2762
|
+
* @internal
|
|
2763
|
+
*/
|
|
2764
|
+
extendRun(dir, page) {
|
|
2765
|
+
this.runMembers.add(page);
|
|
2766
|
+
if (dir === "next") this.frontierEnd = page;
|
|
2767
|
+
else this.frontierStart = page;
|
|
2768
|
+
}
|
|
2769
|
+
/**
|
|
2770
|
+
* Restarts the run at a single page, forgetting every earlier member.
|
|
2771
|
+
*
|
|
2772
|
+
* @internal
|
|
2773
|
+
*/
|
|
2774
|
+
restartRun(page) {
|
|
2775
|
+
this.runMembers.clear();
|
|
2776
|
+
this.runMembers.add(page);
|
|
2777
|
+
this.frontierStart = this.frontierEnd = page;
|
|
2430
2778
|
}
|
|
2431
2779
|
/**
|
|
2432
2780
|
* Commits a resolved, membership-proven page into this state, making it the
|
|
@@ -2443,9 +2791,9 @@ var PaginationState = class {
|
|
|
2443
2791
|
_activate(page, url) {
|
|
2444
2792
|
this.activePage = page;
|
|
2445
2793
|
for (const existing of this.pages) if (existing === page) return;
|
|
2446
|
-
if (this.
|
|
2447
|
-
else if (this.frontierStart?.prevLink === url) this.
|
|
2448
|
-
else this.
|
|
2794
|
+
if (this.runEnd?.nextLink === url) this.extendRun("next", page);
|
|
2795
|
+
else if (this.frontierStart?.prevLink === url) this.extendRun("prev", page);
|
|
2796
|
+
else this.restartRun(page);
|
|
2449
2797
|
}
|
|
2450
2798
|
/**
|
|
2451
2799
|
* Adopts an externally-issued request into this pagination, making its page
|
|
@@ -2476,6 +2824,10 @@ var PaginationState = class {
|
|
|
2476
2824
|
* - this state has not finished setting up its own collection yet
|
|
2477
2825
|
* - the call was superseded by a newer navigation
|
|
2478
2826
|
*
|
|
2827
|
+
* In development, a document that contradicts the collection's page
|
|
2828
|
+
* numbers (a `next` that skips a page, a `first` that is not page 1, ...)
|
|
2829
|
+
* rejects instead of resolving: the graph is not updated from it.
|
|
2830
|
+
*
|
|
2479
2831
|
* ```ts
|
|
2480
2832
|
* const pages = getPaginationState(initialRequest);
|
|
2481
2833
|
* // later, e.g. in a route model hook reacting to a ?page= param:
|
|
@@ -2505,12 +2857,7 @@ var PaginationState = class {
|
|
|
2505
2857
|
if (!test) throw new Error("Expected the adopted document to have a self link");
|
|
2506
2858
|
})(selfLink);
|
|
2507
2859
|
if (!selfLink || (firstLink ?? selfLink) !== cache.key) return null;
|
|
2508
|
-
const page = cache.loadPage(selfLink, request);
|
|
2509
|
-
try {
|
|
2510
|
-
await page.request;
|
|
2511
|
-
} catch {
|
|
2512
|
-
return null;
|
|
2513
|
-
}
|
|
2860
|
+
const page = await cache.loadPage(selfLink, request);
|
|
2514
2861
|
if (this._adoptTarget !== request) return null;
|
|
2515
2862
|
this._activate(page, selfLink);
|
|
2516
2863
|
return page.value;
|
|
@@ -2557,7 +2904,7 @@ var PaginationState = class {
|
|
|
2557
2904
|
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) && ((test) => {
|
|
2558
2905
|
if (!test) throw new Error("Expected the pagination cache to be set up before loading a page");
|
|
2559
2906
|
})(cache);
|
|
2560
|
-
const frontier = dir === "next" ? this.
|
|
2907
|
+
const frontier = dir === "next" ? this.runEnd : this.frontierStart;
|
|
2561
2908
|
const url = dir === "next" ? frontier?.nextLink : frontier?.prevLink;
|
|
2562
2909
|
if (!url) return null;
|
|
2563
2910
|
const page = cache.getPageCache(url);
|
|
@@ -2570,15 +2917,12 @@ var PaginationState = class {
|
|
|
2570
2917
|
method: "GET",
|
|
2571
2918
|
url
|
|
2572
2919
|
});
|
|
2573
|
-
cache.loadPage(url, request);
|
|
2574
|
-
}
|
|
2575
|
-
try {
|
|
2920
|
+
await cache.loadPage(url, request);
|
|
2921
|
+
} else try {
|
|
2576
2922
|
await page.request;
|
|
2577
|
-
} catch {
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
if (dir === "next") this.frontierEnd = page;
|
|
2581
|
-
else this.frontierStart = page;
|
|
2923
|
+
} catch {}
|
|
2924
|
+
if (!page.isSuccess) return null;
|
|
2925
|
+
this.extendRun(dir, page);
|
|
2582
2926
|
return page.value;
|
|
2583
2927
|
};
|
|
2584
2928
|
/**
|
|
@@ -2597,7 +2941,9 @@ var PaginationState = class {
|
|
|
2597
2941
|
* On failure the page stays active and {@link activePageRequest} resolves to
|
|
2598
2942
|
* it, so a wrapping `<Request>` renders its error block. Calling again (for
|
|
2599
2943
|
* example clicking the page's link a second time) retries: the failed page
|
|
2600
|
-
* is re-requested with a forced reload.
|
|
2944
|
+
* is re-requested with a forced reload. In development, a document that
|
|
2945
|
+
* contradicts the collection's page numbers rejects instead (see
|
|
2946
|
+
* {@link adoptPage}).
|
|
2601
2947
|
*
|
|
2602
2948
|
* ```gts
|
|
2603
2949
|
* <EachLink @pages={{pages}}>
|
|
@@ -2624,12 +2970,8 @@ var PaginationState = class {
|
|
|
2624
2970
|
method: "GET",
|
|
2625
2971
|
url
|
|
2626
2972
|
});
|
|
2627
|
-
cache.loadPage(url, request);
|
|
2628
|
-
|
|
2629
|
-
await page.request;
|
|
2630
|
-
} catch {
|
|
2631
|
-
return null;
|
|
2632
|
-
}
|
|
2973
|
+
await cache.loadPage(url, request);
|
|
2974
|
+
if (!page.isSuccess) return null;
|
|
2633
2975
|
}
|
|
2634
2976
|
return page.value;
|
|
2635
2977
|
};
|
|
@@ -2656,6 +2998,8 @@ const PaginationStateCache = /* @__PURE__ */ new WeakMap();
|
|
|
2656
2998
|
* await pages.loadNext();
|
|
2657
2999
|
* ```
|
|
2658
3000
|
*
|
|
3001
|
+
* @summary Experimental: returns the pagination state for a request, creating it on first call and returning the
|
|
3002
|
+
* same instance for the same request thereafter.
|
|
2659
3003
|
* @since 5.9.0
|
|
2660
3004
|
* @public
|
|
2661
3005
|
*/
|
|
@@ -2689,6 +3033,8 @@ const PaginationLinksCache = /* @__PURE__ */ new WeakMap();
|
|
|
2689
3033
|
* </EachLink>
|
|
2690
3034
|
* ```
|
|
2691
3035
|
*
|
|
3036
|
+
* @summary Experimental: a numbered page link with its page number, whether it is current, its distance from the
|
|
3037
|
+
* active page, and `setActive` to load and show that page.
|
|
2692
3038
|
* @since 5.9.0
|
|
2693
3039
|
* @public
|
|
2694
3040
|
* @hideconstructor
|
|
@@ -2738,6 +3084,8 @@ var RealPaginationLink = class {
|
|
|
2738
3084
|
* </EachLink>
|
|
2739
3085
|
* ```
|
|
2740
3086
|
*
|
|
3087
|
+
* @summary Experimental: a non-navigable gap marker in numbered pagination links, standing in for a range of
|
|
3088
|
+
* not-yet-loaded pages, usually shown as an ellipsis.
|
|
2741
3089
|
* @since 5.9.0
|
|
2742
3090
|
* @public
|
|
2743
3091
|
* @hideconstructor
|
|
@@ -2790,6 +3138,8 @@ var PlaceholderPaginationLink = class {
|
|
|
2790
3138
|
* </EachLink>
|
|
2791
3139
|
* ```
|
|
2792
3140
|
*
|
|
3141
|
+
* @summary Experimental: a `first`, `prev`, `next`, or `last` link relative to the active page, with `setActive`
|
|
3142
|
+
* to load it, and the only kind of link cursor-based pagination has.
|
|
2793
3143
|
* @since 5.9.0
|
|
2794
3144
|
* @public
|
|
2795
3145
|
* @hideconstructor
|
|
@@ -2841,6 +3191,9 @@ var RelationalPaginationLink = class {
|
|
|
2841
3191
|
* }
|
|
2842
3192
|
* }
|
|
2843
3193
|
* ```
|
|
3194
|
+
*
|
|
3195
|
+
* @summary Experimental: an entry in the numbered pagination links list, either a navigable numbered link or a
|
|
3196
|
+
* placeholder for a gap, told apart by `isReal`.
|
|
2844
3197
|
*/
|
|
2845
3198
|
/**
|
|
2846
3199
|
* The reactive set of navigation links derived from a {@link PaginationState}.
|
|
@@ -2870,6 +3223,8 @@ var RelationalPaginationLink = class {
|
|
|
2870
3223
|
* - {@link PlaceholderPaginationLink}
|
|
2871
3224
|
* - {@link RelationalPaginationLink}
|
|
2872
3225
|
*
|
|
3226
|
+
* @summary Experimental: the reactive navigation links for a pagination state, with numbered links and gap
|
|
3227
|
+
* placeholders plus `first`, `prev`, `next`, and `last` links for the active page.
|
|
2873
3228
|
* @since 5.9.0
|
|
2874
3229
|
* @public
|
|
2875
3230
|
* @hideconstructor
|
|
@@ -2981,6 +3336,8 @@ var PaginationLinks = class {
|
|
|
2981
3336
|
* }
|
|
2982
3337
|
* ```
|
|
2983
3338
|
*
|
|
3339
|
+
* @summary Experimental: returns the navigation links for a paged pagination state, creating them on first call and
|
|
3340
|
+
* returning the same instance for the same state.
|
|
2984
3341
|
* @since 5.9.0
|
|
2985
3342
|
* @public
|
|
2986
3343
|
*/
|
|
@@ -2998,29 +3355,46 @@ function getPaginationLinks(state) {
|
|
|
2998
3355
|
/**
|
|
2999
3356
|
* The content features available in both pagination modes: the state and
|
|
3000
3357
|
* controls of the initial request.
|
|
3358
|
+
*
|
|
3359
|
+
* @summary Experimental: the request status flags and controls, like `isRefreshing`, `refresh`, and `reload`,
|
|
3360
|
+
* that `<Paginate />` yields to its content block in both modes.
|
|
3001
3361
|
*/
|
|
3002
3362
|
/**
|
|
3003
3363
|
* The content features yielded in `'paged'` mode: navigation happens by
|
|
3004
3364
|
* loading a specific page.
|
|
3365
|
+
*
|
|
3366
|
+
* @summary Experimental: the request controls `<Paginate />` yields to its content block in paged mode, adding
|
|
3367
|
+
* `loadPage` to navigate to a page by URL.
|
|
3005
3368
|
*/
|
|
3006
3369
|
/**
|
|
3007
3370
|
* The content features yielded in `'infinite'` mode: navigation happens by
|
|
3008
3371
|
* extending the loaded run at either end.
|
|
3372
|
+
*
|
|
3373
|
+
* @summary Experimental: the request controls `<Paginate />` yields to its content block in infinite mode, adding
|
|
3374
|
+
* `loadNext` and `loadPrev` to extend the loaded pages.
|
|
3009
3375
|
*/
|
|
3010
3376
|
/**
|
|
3011
3377
|
* The full set of content features a {@link PaginationSubscription} builds —
|
|
3012
3378
|
* both modes' surfaces. The `<Paginate />` component narrows this to one mode
|
|
3013
3379
|
* via {@link PaginationContentFeaturesFor} before yielding.
|
|
3380
|
+
*
|
|
3381
|
+
* @summary Experimental: the combined paged and infinite content features a pagination subscription builds, before
|
|
3382
|
+
* `<Paginate />` narrows them to one mode.
|
|
3014
3383
|
*/
|
|
3015
3384
|
/**
|
|
3016
3385
|
* Resolves a {@link PaginateMode} to the content features it exposes. Mirror of
|
|
3017
3386
|
* {@link PaginationStateFor}.
|
|
3387
|
+
*
|
|
3388
|
+
* @summary Experimental: resolves a pagination mode to the content features `<Paginate />` yields, the infinite
|
|
3389
|
+
* set for `'infinite'` and the paged set otherwise.
|
|
3018
3390
|
*/
|
|
3019
3391
|
/**
|
|
3020
3392
|
* Lifecycle glue for the `<Paginate />` component. Owns the initial
|
|
3021
3393
|
* {@link RequestSubscription} (loading/error state, autorefresh, disposal) and
|
|
3022
3394
|
* the per-component {@link PaginationState} that it hands to the component.
|
|
3023
3395
|
*
|
|
3396
|
+
* @summary Experimental: the lifecycle core of `<Paginate />`, owning the initial request subscription and the
|
|
3397
|
+
* component's pagination state.
|
|
3024
3398
|
* @since 5.9.0
|
|
3025
3399
|
* @public
|
|
3026
3400
|
* @hideconstructor
|
|
@@ -3282,6 +3656,8 @@ defineSignal(PaginationSubscription.prototype, "_navRequest", null);
|
|
|
3282
3656
|
* subscription[DISPOSE](); // tear down when the owning component unmounts
|
|
3283
3657
|
* ```
|
|
3284
3658
|
*
|
|
3659
|
+
* @summary Experimental: creates the subscription that manages a `<Paginate />` component's initial request
|
|
3660
|
+
* lifecycle and pagination state, for managing that lifecycle yourself.
|
|
3285
3661
|
* @since 5.9.0
|
|
3286
3662
|
* @public
|
|
3287
3663
|
*/
|
|
@@ -3313,6 +3689,8 @@ function _DISPOSE$1() {
|
|
|
3313
3689
|
* `<Paginate />` component, so they stay in sync as pages load and the active
|
|
3314
3690
|
* page changes.
|
|
3315
3691
|
*
|
|
3692
|
+
* @summary Experimental: the framework-agnostic lifecycle core of a pagination links component such as
|
|
3693
|
+
* `<EachLink />`, exposing the navigation links for a paged pagination state.
|
|
3316
3694
|
* @since 5.9.0
|
|
3317
3695
|
* @public
|
|
3318
3696
|
* @hideconstructor
|
|
@@ -3354,6 +3732,8 @@ var PaginationLinksSubscription = class {
|
|
|
3354
3732
|
* subscription[DISPOSE](); // tear down when the owning component unmounts
|
|
3355
3733
|
* ```
|
|
3356
3734
|
*
|
|
3735
|
+
* @summary Experimental: creates the subscription a pagination links component such as `<EachLink />` uses to
|
|
3736
|
+
* derive navigation links from a paged pagination state.
|
|
3357
3737
|
* @since 5.9.0
|
|
3358
3738
|
* @public
|
|
3359
3739
|
*/
|
|
@@ -3375,18 +3755,24 @@ const PromiseCache = /* @__PURE__ */ new WeakMap();
|
|
|
3375
3755
|
* The state of a promise in the "pending"
|
|
3376
3756
|
* state. This is the default initial state.
|
|
3377
3757
|
*
|
|
3758
|
+
* @summary The `getPromiseState` state for a promise that has not yet settled, with `isPending` true and
|
|
3759
|
+
* no value or reason.
|
|
3378
3760
|
*/
|
|
3379
3761
|
/**
|
|
3380
3762
|
* The state of a promise in the "fulfilled" state.
|
|
3381
3763
|
* This is the state of a promise that has resolved
|
|
3382
3764
|
* successfully.
|
|
3383
3765
|
*
|
|
3766
|
+
* @summary The `getPromiseState` state for a promise that resolved, with `isSuccess` true and the
|
|
3767
|
+
* resolved `value`.
|
|
3384
3768
|
*/
|
|
3385
3769
|
/**
|
|
3386
3770
|
* The state of a promise in the "rejected" state.
|
|
3387
3771
|
* This is the state of a promise that has rejected
|
|
3388
3772
|
* with an error.
|
|
3389
3773
|
*
|
|
3774
|
+
* @summary The `getPromiseState` state for a promise that rejected, with `isError` true and the
|
|
3775
|
+
* rejection `reason`.
|
|
3390
3776
|
*/
|
|
3391
3777
|
/**
|
|
3392
3778
|
* The state of a promise. This is the type that is returned
|
|
@@ -3397,6 +3783,8 @@ const PromiseCache = /* @__PURE__ */ new WeakMap();
|
|
|
3397
3783
|
* - {@link ResolvedPromise}
|
|
3398
3784
|
* - {@link RejectedPromise}
|
|
3399
3785
|
*
|
|
3786
|
+
* @summary The reactive pending, fulfilled, or rejected state of a promise, as returned by
|
|
3787
|
+
* `getPromiseState`.
|
|
3400
3788
|
*/
|
|
3401
3789
|
const PromiseStateProto = {};
|
|
3402
3790
|
defineSignal(PromiseStateProto, "reason", null);
|
|
@@ -3462,6 +3850,9 @@ function getPromise(promise) {
|
|
|
3462
3850
|
/**
|
|
3463
3851
|
* Returns a reactive state-machine for the provided promise or awaitable.
|
|
3464
3852
|
*
|
|
3853
|
+
* The [Async as Reactive State](/guides/the-manual/reactivity/derivation) guide shows
|
|
3854
|
+
* how to use it in place of tracked loading and error state.
|
|
3855
|
+
*
|
|
3465
3856
|
* Repeat calls to `getPromiseState` with the same promise will return the same state object
|
|
3466
3857
|
* making is safe and easy to use in templates and JavaScript code to produce reactive
|
|
3467
3858
|
* behaviors around promises.
|
|
@@ -3511,6 +3902,9 @@ function getPromise(promise) {
|
|
|
3511
3902
|
* If looking to use in a template, consider also the `<Await />` component.
|
|
3512
3903
|
*
|
|
3513
3904
|
* See also {@link PromiseState}
|
|
3905
|
+
*
|
|
3906
|
+
* @summary Returns a cached, reactive state object tracking whether a promise is pending, fulfilled, or
|
|
3907
|
+
* rejected, for use in JS or templates.
|
|
3514
3908
|
*/
|
|
3515
3909
|
function getPromiseState(promise) {
|
|
3516
3910
|
macroCondition(getGlobalConfig().WarpDriveMirror.env.DEBUG) && ((test) => {
|
|
@@ -3526,5 +3920,5 @@ function getPromiseState(promise) {
|
|
|
3526
3920
|
}
|
|
3527
3921
|
|
|
3528
3922
|
//#endregion
|
|
3529
|
-
export { ARRAY_SIGNAL as A, createInternalMemo as C, notifyInternalSignal as D, makeInitializer as E,
|
|
3530
|
-
//# sourceMappingURL=-private-
|
|
3923
|
+
export { ARRAY_SIGNAL as A, createInternalMemo as C, notifyInternalSignal as D, makeInitializer as E, willSyncFlushWatchers as F, registerSignals as M, setupSignals as N, peekInternalSignal as O, waitFor as P, consumeInternalSignal as S, getOrCreateInternalSignal as T, entangleSignal as _, getPaginationState as a, signal as b, getPaginationCache as c, getRequestState as d, createSignalDescriptor as f, entangleInitiallyStaleSignal as g, defineSignal as h, getPaginationLinks as i, OBJECT_SIGNAL as j, withSignalStore as k, DISPOSE as l, defineNonEnumerableSignal as m, createPaginationLinksSubscription as n, clearPaginationCache as o, defineGate as p, createPaginationSubscription as r, defaultPageHints as s, getPromiseState as t, createRequestSubscription as u, gate as v, createInternalSignal as w, Signals as x, memoized as y };
|
|
3924
|
+
//# sourceMappingURL=-private-Y-13dsHO.js.map
|