@jsenv/navi 0.29.415 → 0.29.416
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 +43 -5
- package/dist/dev/jsenv_navi.js.map +3 -3
- package/dist/jsenv_navi.js +43 -5
- package/dist/jsenv_navi.js.map +3 -3
- package/docs/resource.md +7 -3
- package/docs/route_transitions.md +7 -4
- package/package.json +1 -1
package/dist/dev/jsenv_navi.js
CHANGED
|
@@ -24480,6 +24480,21 @@ ${[idKey, ...uniqueKeys].join(", ")}`,
|
|
|
24480
24480
|
}
|
|
24481
24481
|
return result;
|
|
24482
24482
|
};
|
|
24483
|
+
// A computed of the row with this id, one per id: what a render reads to
|
|
24484
|
+
// follow that row and no other. An upsert replaces only the items it changes
|
|
24485
|
+
// (see assign below), so a row nobody wrote keeps its object, and its
|
|
24486
|
+
// computed stays still while the rest of the store moves — read through
|
|
24487
|
+
// `select`, a render follows the whole store. Kept as long as the store,
|
|
24488
|
+
// like the rows it holds.
|
|
24489
|
+
const itemSignalById = new Map();
|
|
24490
|
+
const itemSignalForId = (id) => {
|
|
24491
|
+
let itemSignal = itemSignalById.get(id);
|
|
24492
|
+
if (!itemSignal) {
|
|
24493
|
+
itemSignal = computed(() => idMapSignal.value.get(id));
|
|
24494
|
+
itemSignalById.set(id, itemSignal);
|
|
24495
|
+
}
|
|
24496
|
+
return itemSignal;
|
|
24497
|
+
};
|
|
24483
24498
|
const upsert = (...args) => {
|
|
24484
24499
|
const mutationsMap = new Map(); // Map<itemId, propertyMutations>
|
|
24485
24500
|
const triggerPropertyMutations = () => {
|
|
@@ -24870,6 +24885,7 @@ ${[idKey, ...uniqueKeys].join(", ")}`,
|
|
|
24870
24885
|
arraySignal,
|
|
24871
24886
|
select,
|
|
24872
24887
|
selectAll,
|
|
24888
|
+
itemSignalForId,
|
|
24873
24889
|
upsert,
|
|
24874
24890
|
drop,
|
|
24875
24891
|
|
|
@@ -26035,12 +26051,34 @@ const createResource = (
|
|
|
26035
26051
|
idKey,
|
|
26036
26052
|
uniqueKeys,
|
|
26037
26053
|
|
|
26038
|
-
// Reactive reads, not hooks:
|
|
26039
|
-
//
|
|
26040
|
-
//
|
|
26054
|
+
// Reactive reads, not hooks: nothing hook-shaped inside, so a loop or a
|
|
26055
|
+
// condition is fine. Each subscribes the render that calls it to what it
|
|
26056
|
+
// returns: the rows asked for, each through a computed of that row (see
|
|
26057
|
+
// itemSignalForId in array_signal_store.js), or the whole store for
|
|
26058
|
+
// `useArray` — a card reading its own row stays still while the page next
|
|
26059
|
+
// to it loads rows of its own. `useAllByIds` skips the ids the store does
|
|
26060
|
+
// not hold.
|
|
26041
26061
|
useArray: () => store.arraySignal.value,
|
|
26042
|
-
useById: (id) => store.
|
|
26043
|
-
useAllByIds: (idArray) =>
|
|
26062
|
+
useById: (id) => store.itemSignalForId(id).value,
|
|
26063
|
+
useAllByIds: (idArray) => {
|
|
26064
|
+
const items = [];
|
|
26065
|
+
for (const idOrProps of idArray) {
|
|
26066
|
+
let id = idOrProps;
|
|
26067
|
+
if (isProps(idOrProps) && !Object.hasOwn(idOrProps, idKey)) {
|
|
26068
|
+
// Named by a unique key: which row that is can only be read off
|
|
26069
|
+
// the whole store.
|
|
26070
|
+
const item = store.select(idOrProps);
|
|
26071
|
+
id = item ? item[idKey] : undefined;
|
|
26072
|
+
} else if (isProps(idOrProps)) {
|
|
26073
|
+
id = idOrProps[idKey];
|
|
26074
|
+
}
|
|
26075
|
+
const item = store.itemSignalForId(id).value;
|
|
26076
|
+
if (item) {
|
|
26077
|
+
items.push(item);
|
|
26078
|
+
}
|
|
26079
|
+
}
|
|
26080
|
+
return items;
|
|
26081
|
+
},
|
|
26044
26082
|
|
|
26045
26083
|
withParams: undefined,
|
|
26046
26084
|
one: undefined,
|