@jsenv/navi 0.30.10 → 0.30.12
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/dev/jsenv_navi.js +69 -8
- package/dist/dev/jsenv_navi.js.map +6 -6
- package/dist/jsenv_navi.js +68 -8
- package/dist/jsenv_navi.js.map +6 -6
- package/docs/actions.md +8 -2
- package/package.json +1 -1
package/dist/dev/jsenv_navi.js
CHANGED
|
@@ -3977,6 +3977,7 @@ const actionWeakMap = new WeakMap();
|
|
|
3977
3977
|
* long is this still true?" belongs to the question: a court list is good for
|
|
3978
3978
|
* the session, a count of people watching grows on its own and is worth a few
|
|
3979
3979
|
* minutes, a payment status is worth nothing at all.
|
|
3980
|
+
* A resource declares it for its reads: `resource()`'s `keep`.
|
|
3980
3981
|
* @param {Array<Object | { resource: Object, on: string[] }> | (() => Array<Object | { resource: Object, on: string[] }>)} [rootOptions.dependencies] -
|
|
3981
3982
|
* the resources whose writes make the answer out of date — a count, a
|
|
3982
3983
|
* summary, anything read that is no row of a resource. After a listed write
|
|
@@ -4562,9 +4563,10 @@ const createAction = (callback, rootOptions = {}) => {
|
|
|
4562
4563
|
}
|
|
4563
4564
|
}
|
|
4564
4565
|
runningStateSignal.value = RUNNING;
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4566
|
+
// What fills the instance says what it holds: an answer only a
|
|
4567
|
+
// prerun asked for is one nothing on screen has read yet, and the
|
|
4568
|
+
// run that asks for it next is promoted onto it (see updateActions).
|
|
4569
|
+
isPrerunSignal.value = isPrerun;
|
|
4568
4570
|
});
|
|
4569
4571
|
|
|
4570
4572
|
const args = [];
|
|
@@ -5375,10 +5377,16 @@ const actionRunEffect = (
|
|
|
5375
5377
|
runUnwatched(() =>
|
|
5376
5378
|
actionTarget.run({ reason: "params restored from falsy state" }),
|
|
5377
5379
|
);
|
|
5378
|
-
} else if (
|
|
5380
|
+
} else if (
|
|
5381
|
+
getActionPrivateProperties(actionTarget).keepsAnswers ||
|
|
5382
|
+
actionTarget.isPrerunSignal.peek()
|
|
5383
|
+
) {
|
|
5379
5384
|
// The lookup that moved the binding here already reset an answer
|
|
5380
5385
|
// older than its `keep`: what the instance holds is still good, and
|
|
5381
|
-
// a prerun still out is joined rather than asked again.
|
|
5386
|
+
// a prerun still out is joined rather than asked again. So is an
|
|
5387
|
+
// answer only a prerun asked for, kept or not: asked ahead for this
|
|
5388
|
+
// very arrival (a <RouteTravel prefetch> neighbour), nothing has read
|
|
5389
|
+
// it yet, and the run promotes it.
|
|
5382
5390
|
runUnwatched(() => actionTarget.run({ reason: "params modified" }));
|
|
5383
5391
|
} else {
|
|
5384
5392
|
runUnwatched(() => actionTarget.rerun({ reason: "params modified" }));
|
|
@@ -29173,6 +29181,16 @@ const createResourceLifecycleManager = () => {
|
|
|
29173
29181
|
}
|
|
29174
29182
|
}
|
|
29175
29183
|
|
|
29184
|
+
// A head start the write made stale is dropped, not asked again: nothing
|
|
29185
|
+
// on screen reads it, and its owner, finding it idle, asks on arriving
|
|
29186
|
+
// instead of promoting what left before the write.
|
|
29187
|
+
for (const action of actionsToRerun) {
|
|
29188
|
+
if (action.isPrerunSignal.peek()) {
|
|
29189
|
+
actionsToRerun.delete(action);
|
|
29190
|
+
actionsToReset.add(action);
|
|
29191
|
+
}
|
|
29192
|
+
}
|
|
29193
|
+
|
|
29176
29194
|
return {
|
|
29177
29195
|
actionsToRerun,
|
|
29178
29196
|
actionsToReset,
|
|
@@ -29260,9 +29278,8 @@ const createResourceLifecycleManager = () => {
|
|
|
29260
29278
|
// A read to ask again after a write: answered before it landed, or still out —
|
|
29261
29279
|
// an answer that left before the write is as stale as a completed one, and
|
|
29262
29280
|
// would replace what the write put in the store (a rerun aborts it and asks
|
|
29263
|
-
// again). A head start is its owner's to ask.
|
|
29281
|
+
// again). A head start is its owner's to ask (findEffectOnActions resets it).
|
|
29264
29282
|
const isAnsweredOrAsking = (action, triggeringAction) =>
|
|
29265
|
-
!action.isPrerun &&
|
|
29266
29283
|
(action.completed || action.runningState === RUNNING) &&
|
|
29267
29284
|
action !== triggeringAction;
|
|
29268
29285
|
// A write named in `writes` says for itself which reads of its own resource it
|
|
@@ -29994,6 +30011,7 @@ const RESOURCE_OPTIONS = new Set([
|
|
|
29994
30011
|
"idKey",
|
|
29995
30012
|
"uniqueKeys",
|
|
29996
30013
|
"rerunOn",
|
|
30014
|
+
"keep",
|
|
29997
30015
|
"dependencies",
|
|
29998
30016
|
"persist",
|
|
29999
30017
|
"writes",
|
|
@@ -30067,7 +30085,7 @@ const SCOPED_MANY_OPTIONS = new Set([
|
|
|
30067
30085
|
* "What a read shows while its params move").
|
|
30068
30086
|
*
|
|
30069
30087
|
* @param {string} name - resource name, used in action names and error messages
|
|
30070
|
-
* @param {Object} restCallbacks - `{ idKey, uniqueKeys, rerunOn, dependencies, persist, writes, GET, GET_MANY, GET_RANGE, POST, POST_MANY, PUT, PUT_MANY, PATCH, PATCH_MANY, DELETE, DELETE_MANY }`
|
|
30088
|
+
* @param {Object} restCallbacks - `{ idKey, uniqueKeys, rerunOn, keep, dependencies, persist, writes, GET, GET_MANY, GET_RANGE, POST, POST_MANY, PUT, PUT_MANY, PATCH, PATCH_MANY, DELETE, DELETE_MANY }`
|
|
30071
30089
|
* @param {string} [restCallbacks.idKey] - primary key property, defaults to `"id"`
|
|
30072
30090
|
* @param {string[]} [restCallbacks.uniqueKeys] - alternate keys the store can find an item by (e.g. `"username"`)
|
|
30073
30091
|
* @param {Array<Object | { resource: Object, on?: string[], reads?: Array<"GET" | "GET_MANY" | "GET_RANGE"> }> | (() => Array<Object | { resource: Object, on?: string[], reads?: Array<"GET" | "GET_MANY" | "GET_RANGE"> }>)} [restCallbacks.dependencies] -
|
|
@@ -30091,6 +30109,22 @@ const SCOPED_MANY_OPTIONS = new Set([
|
|
|
30091
30109
|
* follows `rerunOn` for its verb. A name a verb takes, or one the resource
|
|
30092
30110
|
* already exposes (`withParams`, `store`…), throws. A `.scopedOne()` or
|
|
30093
30111
|
* `.scopedMany()` takes `writes` too, `.scopedMany()` with the plural verbs.
|
|
30112
|
+
* @param {{ GET?: { ms?: number, max?: number }, GET_MANY?: { ms?: number, max?: number } }} [restCallbacks.keep] -
|
|
30113
|
+
* how long an answer of a read is trusted, coming back to the same params
|
|
30114
|
+
* within `ms` asking nothing. Left out, coming back asks again: the right
|
|
30115
|
+
* default for anything that moves on its own (a count of registrations), and
|
|
30116
|
+
* worth declaring for what barely does (a description, a finished
|
|
30117
|
+
* tournament). The store keeps the rows either way, and a `GET` draws the row
|
|
30118
|
+
* it holds while its request is out, so a kept answer and a fresh one look
|
|
30119
|
+
* alike: what `keep` saves is the request. Keyed by read, so a list can be
|
|
30120
|
+
* trusted for less time than an item. The rules are createAction's `keep`:
|
|
30121
|
+
* `ms` counts from the moment the answer landed, `max` caps the answers held
|
|
30122
|
+
* at once (the least recently looked-at going first), and past either the
|
|
30123
|
+
* read is asked again. A write that reruns the read (`rerunOn`,
|
|
30124
|
+
* `dependencies`) reruns a kept answer too, and the new one counts its `ms`
|
|
30125
|
+
* again. A `withParams()` scope keeps as its resource does, `max` counted per
|
|
30126
|
+
* scope; the reads of a relation are questions of their own and keep
|
|
30127
|
+
* nothing. `GET_RANGE` throws: a range reader holds no answer to keep.
|
|
30094
30128
|
* @param {{ signal: import("@preact/signals").Signal, when?: () => boolean }} [restCallbacks.persist] -
|
|
30095
30129
|
* mirrors the rows `GET` lands with into `signal` — a `stateSignal` with
|
|
30096
30130
|
* `persists: true` and `type: "object"` keeps them across a reload, whose
|
|
@@ -30131,6 +30165,7 @@ const resource = (name, restCallbacks = {}) => {
|
|
|
30131
30165
|
idKey = "id",
|
|
30132
30166
|
uniqueKeys = [],
|
|
30133
30167
|
rerunOn,
|
|
30168
|
+
keep,
|
|
30134
30169
|
dependencies,
|
|
30135
30170
|
persist,
|
|
30136
30171
|
writes,
|
|
@@ -30150,6 +30185,9 @@ const resource = (name, restCallbacks = {}) => {
|
|
|
30150
30185
|
{
|
|
30151
30186
|
warnUnknownOptions(`resource(${name})`, restCallbacks, RESOURCE_OPTIONS);
|
|
30152
30187
|
}
|
|
30188
|
+
if (keep) {
|
|
30189
|
+
assertKeepNamesReads(name, keep);
|
|
30190
|
+
}
|
|
30153
30191
|
const declarationSite = getDeclarationSite();
|
|
30154
30192
|
const setupCallbackSet = new Set();
|
|
30155
30193
|
const addItemSetup = (callback) => {
|
|
@@ -30274,6 +30312,7 @@ const resource = (name, restCallbacks = {}) => {
|
|
|
30274
30312
|
findItemForGet,
|
|
30275
30313
|
persistence,
|
|
30276
30314
|
declarationSite,
|
|
30315
|
+
keep,
|
|
30277
30316
|
});
|
|
30278
30317
|
return createResource(name, {
|
|
30279
30318
|
idKey,
|
|
@@ -31607,6 +31646,7 @@ const createRestActionFactoryForRoot = (
|
|
|
31607
31646
|
findItemForGet,
|
|
31608
31647
|
persistence,
|
|
31609
31648
|
declarationSite,
|
|
31649
|
+
keep = {},
|
|
31610
31650
|
},
|
|
31611
31651
|
) => {
|
|
31612
31652
|
const createActionForRoot = (
|
|
@@ -31708,6 +31748,7 @@ const createRestActionFactoryForRoot = (
|
|
|
31708
31748
|
: undefined,
|
|
31709
31749
|
// Another params' answer is another row.
|
|
31710
31750
|
inheritData: verb !== "GET",
|
|
31751
|
+
keep: verb === "GET" ? keep.GET : undefined,
|
|
31711
31752
|
completeSideEffect: onActionComplete,
|
|
31712
31753
|
});
|
|
31713
31754
|
if (verb === "GET") {
|
|
@@ -31739,6 +31780,7 @@ const createRestActionFactoryForRoot = (
|
|
|
31739
31780
|
// A binding moving to new params hands over the previous answer: a list
|
|
31740
31781
|
// standing in for the next one beats a skeleton.
|
|
31741
31782
|
inheritData: true,
|
|
31783
|
+
keep: verb === "GET" ? keep.GET_MANY : undefined,
|
|
31742
31784
|
// The rows the page kept from the previous document (kept_reads.js),
|
|
31743
31785
|
// drawn while the request is out when nothing was handed over.
|
|
31744
31786
|
provisionalValue:
|
|
@@ -31821,6 +31863,24 @@ const applyNetworkPolicy = (
|
|
|
31821
31863
|
};
|
|
31822
31864
|
};
|
|
31823
31865
|
|
|
31866
|
+
// What can never be kept throws, as a rerunOn that never fires does: a range
|
|
31867
|
+
// reader holds no answer, its lists ask again for the window they draw.
|
|
31868
|
+
const KEEP_READS = ["GET", "GET_MANY"];
|
|
31869
|
+
const assertKeepNamesReads = (name, keep) => {
|
|
31870
|
+
for (const read of Object.keys(keep)) {
|
|
31871
|
+
if (read === "GET_RANGE") {
|
|
31872
|
+
throw new Error(
|
|
31873
|
+
`resource(${name}): keep.GET_RANGE keeps nothing — a range reader holds no answer, its lists ask again for the window they draw`,
|
|
31874
|
+
);
|
|
31875
|
+
}
|
|
31876
|
+
if (!KEEP_READS.includes(read)) {
|
|
31877
|
+
throw new Error(
|
|
31878
|
+
`resource(${name}): keep.${read} is not a read that keeps an answer — keep takes GET and GET_MANY`,
|
|
31879
|
+
);
|
|
31880
|
+
}
|
|
31881
|
+
}
|
|
31882
|
+
};
|
|
31883
|
+
|
|
31824
31884
|
// A `dependencies` given as a function is read before the first request
|
|
31825
31885
|
// leaves (see item_lifecycle_manager.js).
|
|
31826
31886
|
const readLazyDependenciesFirst = (restCallback) => {
|
|
@@ -85872,6 +85932,7 @@ const css$w = /* css */`@property --list-group-label-height {
|
|
|
85872
85932
|
|
|
85873
85933
|
&[data-continued] {
|
|
85874
85934
|
margin-top: calc(-1 * var(--x-list-gap, 0px));
|
|
85935
|
+
grid-template-columns: minmax(0, 1fr);
|
|
85875
85936
|
display: grid;
|
|
85876
85937
|
|
|
85877
85938
|
& > .navi_list_item_group_label, & > .navi_list_item_group_list {
|