@jsenv/navi 0.30.11 → 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 +46 -1
- package/dist/dev/jsenv_navi.js.map +4 -4
- package/dist/jsenv_navi.js +45 -1
- package/dist/jsenv_navi.js.map +4 -4
- package/docs/actions.md +3 -0
- 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
|
|
@@ -30010,6 +30011,7 @@ const RESOURCE_OPTIONS = new Set([
|
|
|
30010
30011
|
"idKey",
|
|
30011
30012
|
"uniqueKeys",
|
|
30012
30013
|
"rerunOn",
|
|
30014
|
+
"keep",
|
|
30013
30015
|
"dependencies",
|
|
30014
30016
|
"persist",
|
|
30015
30017
|
"writes",
|
|
@@ -30083,7 +30085,7 @@ const SCOPED_MANY_OPTIONS = new Set([
|
|
|
30083
30085
|
* "What a read shows while its params move").
|
|
30084
30086
|
*
|
|
30085
30087
|
* @param {string} name - resource name, used in action names and error messages
|
|
30086
|
-
* @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 }`
|
|
30087
30089
|
* @param {string} [restCallbacks.idKey] - primary key property, defaults to `"id"`
|
|
30088
30090
|
* @param {string[]} [restCallbacks.uniqueKeys] - alternate keys the store can find an item by (e.g. `"username"`)
|
|
30089
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] -
|
|
@@ -30107,6 +30109,22 @@ const SCOPED_MANY_OPTIONS = new Set([
|
|
|
30107
30109
|
* follows `rerunOn` for its verb. A name a verb takes, or one the resource
|
|
30108
30110
|
* already exposes (`withParams`, `store`…), throws. A `.scopedOne()` or
|
|
30109
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.
|
|
30110
30128
|
* @param {{ signal: import("@preact/signals").Signal, when?: () => boolean }} [restCallbacks.persist] -
|
|
30111
30129
|
* mirrors the rows `GET` lands with into `signal` — a `stateSignal` with
|
|
30112
30130
|
* `persists: true` and `type: "object"` keeps them across a reload, whose
|
|
@@ -30147,6 +30165,7 @@ const resource = (name, restCallbacks = {}) => {
|
|
|
30147
30165
|
idKey = "id",
|
|
30148
30166
|
uniqueKeys = [],
|
|
30149
30167
|
rerunOn,
|
|
30168
|
+
keep,
|
|
30150
30169
|
dependencies,
|
|
30151
30170
|
persist,
|
|
30152
30171
|
writes,
|
|
@@ -30166,6 +30185,9 @@ const resource = (name, restCallbacks = {}) => {
|
|
|
30166
30185
|
{
|
|
30167
30186
|
warnUnknownOptions(`resource(${name})`, restCallbacks, RESOURCE_OPTIONS);
|
|
30168
30187
|
}
|
|
30188
|
+
if (keep) {
|
|
30189
|
+
assertKeepNamesReads(name, keep);
|
|
30190
|
+
}
|
|
30169
30191
|
const declarationSite = getDeclarationSite();
|
|
30170
30192
|
const setupCallbackSet = new Set();
|
|
30171
30193
|
const addItemSetup = (callback) => {
|
|
@@ -30290,6 +30312,7 @@ const resource = (name, restCallbacks = {}) => {
|
|
|
30290
30312
|
findItemForGet,
|
|
30291
30313
|
persistence,
|
|
30292
30314
|
declarationSite,
|
|
30315
|
+
keep,
|
|
30293
30316
|
});
|
|
30294
30317
|
return createResource(name, {
|
|
30295
30318
|
idKey,
|
|
@@ -31623,6 +31646,7 @@ const createRestActionFactoryForRoot = (
|
|
|
31623
31646
|
findItemForGet,
|
|
31624
31647
|
persistence,
|
|
31625
31648
|
declarationSite,
|
|
31649
|
+
keep = {},
|
|
31626
31650
|
},
|
|
31627
31651
|
) => {
|
|
31628
31652
|
const createActionForRoot = (
|
|
@@ -31724,6 +31748,7 @@ const createRestActionFactoryForRoot = (
|
|
|
31724
31748
|
: undefined,
|
|
31725
31749
|
// Another params' answer is another row.
|
|
31726
31750
|
inheritData: verb !== "GET",
|
|
31751
|
+
keep: verb === "GET" ? keep.GET : undefined,
|
|
31727
31752
|
completeSideEffect: onActionComplete,
|
|
31728
31753
|
});
|
|
31729
31754
|
if (verb === "GET") {
|
|
@@ -31755,6 +31780,7 @@ const createRestActionFactoryForRoot = (
|
|
|
31755
31780
|
// A binding moving to new params hands over the previous answer: a list
|
|
31756
31781
|
// standing in for the next one beats a skeleton.
|
|
31757
31782
|
inheritData: true,
|
|
31783
|
+
keep: verb === "GET" ? keep.GET_MANY : undefined,
|
|
31758
31784
|
// The rows the page kept from the previous document (kept_reads.js),
|
|
31759
31785
|
// drawn while the request is out when nothing was handed over.
|
|
31760
31786
|
provisionalValue:
|
|
@@ -31837,6 +31863,24 @@ const applyNetworkPolicy = (
|
|
|
31837
31863
|
};
|
|
31838
31864
|
};
|
|
31839
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
|
+
|
|
31840
31884
|
// A `dependencies` given as a function is read before the first request
|
|
31841
31885
|
// leaves (see item_lifecycle_manager.js).
|
|
31842
31886
|
const readLazyDependenciesFirst = (restCallback) => {
|
|
@@ -85888,6 +85932,7 @@ const css$w = /* css */`@property --list-group-label-height {
|
|
|
85888
85932
|
|
|
85889
85933
|
&[data-continued] {
|
|
85890
85934
|
margin-top: calc(-1 * var(--x-list-gap, 0px));
|
|
85935
|
+
grid-template-columns: minmax(0, 1fr);
|
|
85891
85936
|
display: grid;
|
|
85892
85937
|
|
|
85893
85938
|
& > .navi_list_item_group_label, & > .navi_list_item_group_list {
|