@jsenv/navi 0.29.438 → 0.29.440

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.
@@ -38269,13 +38269,10 @@ let activeRouteActionsPrevious = new Set();
38269
38269
  * The route actions asking something for the page on screen: their route
38270
38270
  * matches and their params getter returns something — the running ones, not
38271
38271
  * every matching one, so an action bound to every page that asks only when a
38272
- * popup is open over it counts while it is open. Read to rerun what the page
38273
- * reads (the app back from the background), and by `keepPageOnScreen`.
38272
+ * popup is open over it counts while it is open. The page's code included (see
38273
+ * `activeRouteReadsSignal` for the set to rerun). Read by `keepPageOnScreen`.
38274
38274
  * The set is handed out again only when its members change.
38275
38275
  *
38276
- * A page's code is declared as a route action too; `action.meta.verb` says
38277
- * which ones read data.
38278
- *
38279
38276
  * @type {import("@preact/signals").ReadonlySignal<Set<object>>}
38280
38277
  */
38281
38278
  const activeRouteActionsSignal = computed(() => {
@@ -38292,6 +38289,36 @@ const activeRouteActionsSignal = computed(() => {
38292
38289
  return active;
38293
38290
  });
38294
38291
 
38292
+ let activeRouteReadsPrevious = new Set();
38293
+ /**
38294
+ * `activeRouteActionsSignal` without the page's code: what to rerun to read
38295
+ * the page on screen again, the app back from the background. A page's code
38296
+ * has nothing to read again — a module does not change until a deploy — and
38297
+ * rerunning it is not free: a page reading its code the delegated way
38298
+ * (`useAsyncData(CODE)` under a `<Loading>`) leaves the document for the frame
38299
+ * the import takes, and its lists lose their scroll position.
38300
+ *
38301
+ * Code is told by its answer: a function (the page component) or a module
38302
+ * namespace. An import that failed has none and stays in the set; rerun, it
38303
+ * fails again at once, since the document refuses a module it failed to fetch.
38304
+ *
38305
+ * @type {import("@preact/signals").ReadonlySignal<Set<object>>}
38306
+ */
38307
+ const activeRouteReadsSignal = computed(() => {
38308
+ const reads = new Set();
38309
+ for (const routeAction of activeRouteActionsSignal.value) {
38310
+ if (isCode(routeAction.valueSignal.value)) {
38311
+ continue;
38312
+ }
38313
+ reads.add(routeAction);
38314
+ }
38315
+ if (haveSameMembers(reads, activeRouteReadsPrevious)) {
38316
+ return activeRouteReadsPrevious;
38317
+ }
38318
+ activeRouteReadsPrevious = reads;
38319
+ return reads;
38320
+ });
38321
+
38295
38322
  /**
38296
38323
  * Binds an action to a route: it runs when the route matches, with the params
38297
38324
  * the effect reads off the address, runs again on a `reload()`, and is aborted
@@ -38448,6 +38475,17 @@ const anyMatchingRouteSignal = (routes) => {
38448
38475
  return anyMatchingSignal;
38449
38476
  };
38450
38477
 
38478
+ const isCode = (value) => {
38479
+ if (typeof value === "function") {
38480
+ return true;
38481
+ }
38482
+ return (
38483
+ value !== null &&
38484
+ typeof value === "object" &&
38485
+ value[Symbol.toStringTag] === "Module"
38486
+ );
38487
+ };
38488
+
38451
38489
  const rootActionOf = (action) => {
38452
38490
  if (action.isProxy) {
38453
38491
  return rootActionOf(getActionPrivateProperties(action).currentAction);
@@ -71299,9 +71337,16 @@ document.addEventListener(
71299
71337
  * progress. A write is an instant scroll, and the browser abandons for it any
71300
71338
  * scroll it is playing on its own, short of where that one was going: a key
71301
71339
  * (Home, PageDown, Space), a smooth `scrollTo` or `scrollIntoView`, the status
71302
- * bar tap on iOS, the fling a finger leaves behind once it lifts. A scroll
71303
- * following a hand is not abandoned: the wheel's next turn carries on, and on
71304
- * most engines a finger keeps dragging from wherever the write left it.
71340
+ * bar tap on iOS. A scroll following a hand is not abandoned: the wheel's next
71341
+ * turn carries on, and on most engines a finger keeps dragging from wherever
71342
+ * the write left it, and the fling it leaves behind once it lifts carries on
71343
+ * from there too (Chrome under DevTools' touch emulation: flings written to at
71344
+ * every move of a list's window went as far as flings never written to).
71345
+ *
71346
+ * A fling must not be taken for a scroll the browser plays on its own. A list
71347
+ * then leaves uncorrected, for the whole fling, the room its fillers lose above
71348
+ * the screen as its window slides: in wematch, cards jumping half a screen
71349
+ * several times per fling.
71305
71350
  *
71306
71351
  * Not on iOS. Its finger places the content from where the drag began, so a
71307
71352
  * write under it is undone at the finger's next move — or, when the finger
@@ -71309,11 +71354,15 @@ document.addEventListener(
71309
71354
  * stops on any write during its momentum, as the status bar's scroll to the
71310
71355
  * top does (Safari 26.5 on the simulator: flings of 1700px stopped 130 to 340px
71311
71356
  * after the lift, 3 in 3; a write 50ms before the lift stopped 2 flings in 3).
71312
- * No finger there is a hand a write could hold to. Chrome flings on through a
71313
- * write, and loses nothing by not getting one.
71314
- *
71315
- * A scroll is followed from its first "scroll" event to its "scrollend", and
71316
- * is a hand's while a finger is down, or when a wheel turned around the time it
71357
+ * No finger there is a hand a write could hold to, nor the fling it leaves.
71358
+ *
71359
+ * A scroll is followed from its first "scroll" event to its "scrollend". It is
71360
+ * a finger's while a finger is down, and still once the finger lifts if a
71361
+ * finger moved it around the time it started or since: the fling goes on in
71362
+ * the drag's own scroll, or in a scroll of its own that Chrome starts right
71363
+ * after the drag's "scrollend". What counts is a scroll the finger moved, not
71364
+ * a lift: a tap on a button calling a smooth `scrollTo` lifts a finger that
71365
+ * moved nothing. A scroll is a wheel's when a wheel turned around the time it
71317
71366
  * started or since. A finger is down from its touchstart to its touchend,
71318
71367
  * heard on what it touched: a list removes the items scrolled out of its window
71319
71368
  * while the finger is still on one of them, and the touchend of a removed
@@ -71327,6 +71376,10 @@ document.addEventListener(
71327
71376
  // next one. A turn further from it moved nothing (a wheel at an edge) and is no
71328
71377
  // hand on a scroll that came from elsewhere.
71329
71378
  const WHEEL_REACH = 100;
71379
+ // The fling Chrome plays as a scroll of its own starts a frame or two after the
71380
+ // drag's last move (DevTools' touch emulation, 4× CPU: 12ms after the drag's
71381
+ // "scrollend").
71382
+ const FLING_REACH = 150;
71330
71383
  // iOS's touch handling, the one engine whose finger drops writes (see above).
71331
71384
  const FINGER_KEEPS_WRITES = !window.CSS.supports(
71332
71385
  "-webkit-touch-callout",
@@ -71336,6 +71389,7 @@ const FINGER_KEEPS_WRITES = !window.CSS.supports(
71336
71389
  const flightMap = new WeakMap();
71337
71390
  let fingersDown = 0;
71338
71391
  let wheelTimeStamp = -Infinity;
71392
+ let fingerScrollTimeStamp = -Infinity;
71339
71393
 
71340
71394
  /**
71341
71395
  * @param {Element} scrollerEl
@@ -71346,7 +71400,10 @@ const wouldInterruptScroll = (scrollerEl) => {
71346
71400
  if (!flight) {
71347
71401
  return false;
71348
71402
  }
71349
- if (fingersDown > 0) {
71403
+ if (
71404
+ fingersDown > 0 ||
71405
+ fingerScrollTimeStamp > flight.timeStamp - FLING_REACH
71406
+ ) {
71350
71407
  return !FINGER_KEEPS_WRITES;
71351
71408
  }
71352
71409
  if (wheelTimeStamp > flight.timeStamp - WHEEL_REACH) {
@@ -71373,6 +71430,9 @@ if ("onscrollend" in window) {
71373
71430
  document.addEventListener(
71374
71431
  "scroll",
71375
71432
  (e) => {
71433
+ if (fingersDown > 0) {
71434
+ fingerScrollTimeStamp = e.timeStamp;
71435
+ }
71376
71436
  const scroller = asScroller(e.target);
71377
71437
  if (flightMap.has(scroller)) {
71378
71438
  return;
@@ -71703,7 +71763,13 @@ const createListItems = () => {
71703
71763
  // One, as a rule; a child that renders several items keeps them in the order
71704
71764
  // they first rendered, which is all it can be told.
71705
71765
  const ownerIdsBySlot = new Map();
71766
+ // What each run answers about the items it holds, drawn or not: where the
71767
+ // one of an id sits, which one sits at an index.
71706
71768
  const locatorByOwner = new Map();
71769
+ // The room each item took along the scroll axis the last time it was drawn,
71770
+ // by id: what a filler holds for it once it is not (see rememberItemRooms in
71771
+ // list.jsx). A number per item drawn while the list is mounted.
71772
+ const roomById = new Map();
71707
71773
  // The slots as the tree reads, first to last, and where each stands in it.
71708
71774
  // Rebuilt once a walk has changed the tree, read to place the owners.
71709
71775
  const slotWalk = [];
@@ -72052,6 +72118,7 @@ const createListItems = () => {
72052
72118
  holdViewStill: () => {},
72053
72119
  horizontal: false,
72054
72120
  virtualItemSizeSignal: null,
72121
+ roomById,
72055
72122
  renderSkeleton: undefined,
72056
72123
  // The children a walk stands over, in order — said in one call, before any
72057
72124
  // of them renders, so that what a child asks next is answered against the
@@ -72083,22 +72150,33 @@ const createListItems = () => {
72083
72150
  // Whether any run of items lives in this list: what makes a render window
72084
72151
  // mean anything (see List's renderBudget).
72085
72152
  hasRuns: () => locatorByOwner.size > 0,
72086
- setItemLocator: (ownerId, locate) => {
72087
- locatorByOwner.set(ownerId, locate);
72153
+ setItemLocator: (ownerId, locator) => {
72154
+ locatorByOwner.set(ownerId, locator);
72088
72155
  },
72089
72156
  dropItemLocator: (ownerId) => {
72090
72157
  locatorByOwner.delete(ownerId);
72091
72158
  },
72092
72159
  // Where the item named by that id sits, asked of whoever holds it.
72093
72160
  locateItem: (id) => {
72094
- for (const locate of locatorByOwner.values()) {
72095
- const index = locate(id);
72161
+ for (const locator of locatorByOwner.values()) {
72162
+ const index = locator.indexOf(id);
72096
72163
  if (index !== null) {
72097
72164
  return index;
72098
72165
  }
72099
72166
  }
72100
72167
  return null;
72101
72168
  },
72169
+ // The room the item at that index took when it was last drawn, or
72170
+ // undefined: never drawn, not held, or not an item of a run.
72171
+ roomAt: (index) => {
72172
+ for (const locator of locatorByOwner.values()) {
72173
+ const id = locator.idAt(index);
72174
+ if (id !== undefined) {
72175
+ return roomById.get(id);
72176
+ }
72177
+ }
72178
+ return undefined;
72179
+ },
72102
72180
  // The place the owner's items start at — read from a signal, so that the
72103
72181
  // owner is rendered again when it moves (see the top of this file). Asked
72104
72182
  // on every render, and answered without a second look for as long as the
@@ -74176,6 +74254,8 @@ const useListScrollSync = ({
74176
74254
  // state: the render moves it where the list is held (holdWindow) without a
74177
74255
  // commit of its own.
74178
74256
  const renderWindowRef = useRef(null);
74257
+ // A window was asked for that no render has drawn yet (see settleWindow).
74258
+ const windowAskedRef = useRef(false);
74179
74259
  const windowLeavesItemsOut = () => {
74180
74260
  const renderWindow = renderWindowRef.current;
74181
74261
  if (!renderWindow) {
@@ -74270,6 +74350,8 @@ const useListScrollSync = ({
74270
74350
  return;
74271
74351
  }
74272
74352
  captureAnchor();
74353
+ // What was measured is the room of an item alone on its line.
74354
+ listItems.roomById.clear();
74273
74355
  itemsPerLineRef.current = itemsPerLineNow;
74274
74356
  setItemsPerLine(itemsPerLineNow);
74275
74357
  };
@@ -74351,6 +74433,25 @@ const useListScrollSync = ({
74351
74433
  }
74352
74434
  }
74353
74435
  }
74436
+ // The items about to leave the window are still drawn: the room each takes
74437
+ // is kept, and the filler holding its place from then on holds exactly that
74438
+ // (see VirtualFiller). Nothing above the screen then changes as the window
74439
+ // slides, which matters most where the anchoring cannot write: a scroll in
74440
+ // flight (see holdAnchorStill). Every item drawn is read, since any may be
74441
+ // the next to leave. A room kept is the room of the last drawing: an item
74442
+ // that changed since is measured again when drawn again, and the anchoring
74443
+ // holds the view across the difference. Items laid side by side in a grid
74444
+ // share a line, which the fillers hold at the one size.
74445
+ const rememberItemRooms = () => {
74446
+ if (!ref.current || itemsPerLineRef.current !== 1) {
74447
+ return;
74448
+ }
74449
+ const listEl = getListEl();
74450
+ if (!listEl) {
74451
+ return;
74452
+ }
74453
+ readItemRooms(listEl, horizontal, listItems.roomById);
74454
+ };
74354
74455
  const updateRenderWindow = (newStart, newEnd, reason) => {
74355
74456
  const {
74356
74457
  start,
@@ -74359,12 +74460,14 @@ const useListScrollSync = ({
74359
74460
  if (newStart === start && newEnd === end) {
74360
74461
  return null;
74361
74462
  }
74463
+ rememberItemRooms();
74362
74464
  captureAnchor();
74363
74465
  const renderWindow = {
74364
74466
  start: newStart,
74365
74467
  end: newEnd
74366
74468
  };
74367
74469
  renderWindowRef.current = renderWindow;
74470
+ windowAskedRef.current = true;
74368
74471
  setRenderWindow(renderWindow);
74369
74472
  return renderWindow;
74370
74473
  };
@@ -74774,6 +74877,20 @@ const useListScrollSync = ({
74774
74877
  }
74775
74878
  const scrollerEl = getScroller();
74776
74879
  if (openAt === "end") {
74880
+ const total = listItems.totalSignal.peek();
74881
+ const {
74882
+ start,
74883
+ end
74884
+ } = renderWindowRef.current;
74885
+ if (end < total) {
74886
+ // The window was framed before the runs said how many items there are
74887
+ // (see holdWindow): the end of the document is the end of a filler.
74888
+ // Aimed at the last items first, like a named item.
74889
+ const windowSize = end - start;
74890
+ const wantedStart = total - windowSize < 0 ? 0 : total - windowSize;
74891
+ updateRenderWindow(wantedStart, total);
74892
+ return;
74893
+ }
74777
74894
  sendHeldScroll(horizontal ? scrollerEl.scrollWidth : scrollerEl.scrollHeight);
74778
74895
  return;
74779
74896
  }
@@ -74851,6 +74968,13 @@ const useListScrollSync = ({
74851
74968
  if (stage === "steady") {
74852
74969
  return;
74853
74970
  }
74971
+ if (windowAskedRef.current) {
74972
+ // The hold has just aimed the window where the list opens — its end, an
74973
+ // item it found — and the next commit draws it. Sized now, the window
74974
+ // would weigh the items there by the ones drawn here, nowhere near them:
74975
+ // the one-line items at the start of a thread opening on its cards.
74976
+ return;
74977
+ }
74854
74978
  const initialBudget = initialBudgetRef.current;
74855
74979
  if (initialBudget && !paintedRef.current) {
74856
74980
  if (stage === "picture") {
@@ -75191,9 +75315,9 @@ const useListScrollSync = ({
75191
75315
  if (wouldInterruptScroll(scrollerEl)) {
75192
75316
  // Nobody is looking at items standing still: they are passing by, on
75193
75317
  // their way somewhere the browser takes them (a key, a smooth scrollTo,
75194
- // the status bar, a fling). The write would stop that scroll short of
75195
- // where it was going. Left alone, the items drawn above push the rest by
75196
- // `drift` while all of it moves, and the scroll lands.
75318
+ // the status bar, a fling on iOS). The write would stop that scroll short
75319
+ // of where it was going. Left alone, the items drawn above push the rest
75320
+ // by `drift` while all of it moves, and the scroll lands.
75197
75321
  return;
75198
75322
  }
75199
75323
  scrolledByListRef.current = true;
@@ -75322,8 +75446,14 @@ const useListScrollSync = ({
75322
75446
  bandEnd = walkAfter(hold.index, screenSize - hold.above, pixelsOf).index;
75323
75447
  forward = true;
75324
75448
  } else {
75325
- bandStart = findBandStart(items, bandFrom, itemSize);
75326
- bandEnd = bandTo > bandFrom ? findBandEnd(items, bandTo, itemSize) : bandStart;
75449
+ // In the room a filler holds, an item is counted at what the filler
75450
+ // gives it.
75451
+ const fillerSizeOf = itemSize > 0 ? index => {
75452
+ const room = listItems.roomAt(index);
75453
+ return room === undefined ? itemSize : room;
75454
+ } : null;
75455
+ bandStart = findBandStart(items, bandFrom, fillerSizeOf, total);
75456
+ bandEnd = bandTo > bandFrom ? findBandEnd(items, bandTo, fillerSizeOf, total) : bandStart;
75327
75457
  forward = scrollDirectionRef.current > 0;
75328
75458
  }
75329
75459
  if (bandStart > total) {
@@ -75572,6 +75702,8 @@ const useListScrollSync = ({
75572
75702
  };
75573
75703
  }, [scrollerElResolved]);
75574
75704
  holdWindow();
75705
+ // Whatever was asked for until now is what this render draws.
75706
+ windowAskedRef.current = false;
75575
75707
  const {
75576
75708
  start: windowStart,
75577
75709
  end: windowEnd
@@ -76232,12 +76364,49 @@ const readWindowGeometry = (scrollerEl, listEl, horizontal) => {
76232
76364
  items
76233
76365
  };
76234
76366
  };
76367
+ // The room each item drawn takes along the scroll axis (see
76368
+ // rememberItemRooms): up to the next item when that one is drawn too, so that
76369
+ // what stands between them — a separator, the label of a group the next one
76370
+ // opens — is counted; its own box otherwise. A stand-in is not measured: it
76371
+ // takes the room it is given, not the room of its item.
76372
+ const readItemRooms = (listEl, horizontal, roomById) => {
76373
+ let previous = null;
76374
+ const keepRoom = (item, next) => {
76375
+ if (item.id === null) {
76376
+ return;
76377
+ }
76378
+ roomById.set(item.id, next && next.index === item.index + 1 ? next.from - item.from : item.to - item.from);
76379
+ };
76380
+ for (const itemEl of listEl.querySelectorAll(`[${LIST_ITEM_INDEX_ATTRIBUTE}]`)) {
76381
+ if (!isOwnItem(itemEl, listEl)) {
76382
+ continue;
76383
+ }
76384
+ const rect = itemEl.getBoundingClientRect();
76385
+ if (rect.width === 0 && rect.height === 0) {
76386
+ continue;
76387
+ }
76388
+ const item = {
76389
+ id: getItemName(itemEl),
76390
+ index: Number(itemEl.getAttribute(LIST_ITEM_INDEX_ATTRIBUTE)),
76391
+ from: horizontal ? rect.left : rect.top,
76392
+ to: horizontal ? rect.right : rect.bottom
76393
+ };
76394
+ if (previous) {
76395
+ keepRoom(previous, item);
76396
+ }
76397
+ previous = item;
76398
+ }
76399
+ if (previous) {
76400
+ keepRoom(previous, null);
76401
+ }
76402
+ };
76235
76403
  // The first item the screen shows from `position` on, and the item after the
76236
76404
  // last one it shows up to `position` (exclusive, like the window's end). An
76237
76405
  // item drawn is read off its box; in the room a filler holds for items not
76238
- // drawn, the item is counted at the size the filler gives each of them — the
76239
- // only way a scroll position there says which item it is.
76240
- const findBandStart = (items, position, itemSize) => {
76406
+ // drawn, each item is counted at the size the filler gives it (`sizeOf`) —
76407
+ // the only way a scroll position there says which item it is. Without a size
76408
+ // (`null`), the room a filler holds says nothing.
76409
+ const findBandStart = (items, position, sizeOf, total) => {
76241
76410
  let low = 0;
76242
76411
  let high = items.length;
76243
76412
  while (low < high) {
@@ -76251,29 +76420,28 @@ const findBandStart = (items, position, itemSize) => {
76251
76420
  const next = items[low];
76252
76421
  const previous = items[low - 1];
76253
76422
  if (!next) {
76254
- if (!itemSize) {
76423
+ if (!sizeOf) {
76255
76424
  return previous.index + 1;
76256
76425
  }
76257
- return previous.index + 1 + Math.floor((position - previous.to) / itemSize);
76426
+ return findIndexAfter(previous.index + 1, previous.to, position, sizeOf, total);
76258
76427
  }
76259
76428
  if (next.from <= position) {
76260
76429
  return next.index;
76261
76430
  }
76262
76431
  if (!previous) {
76263
- if (!itemSize) {
76432
+ if (!sizeOf) {
76264
76433
  return next.index;
76265
76434
  }
76266
- const index = next.index - Math.ceil((next.from - position) / itemSize);
76435
+ const index = findIndexBefore(next.index, next.from, position, sizeOf);
76267
76436
  return index < 0 ? 0 : index;
76268
76437
  }
76269
- if (!itemSize || next.index === previous.index + 1) {
76438
+ if (!sizeOf || next.index === previous.index + 1) {
76270
76439
  // Between two items that follow each other: a separator, a group label.
76271
76440
  return next.index;
76272
76441
  }
76273
- const index = previous.index + 1 + Math.floor((position - previous.to) / itemSize);
76274
- return index < next.index ? index : next.index;
76442
+ return findIndexAfter(previous.index + 1, previous.to, position, sizeOf, next.index);
76275
76443
  };
76276
- const findBandEnd = (items, position, itemSize) => {
76444
+ const findBandEnd = (items, position, sizeOf, total) => {
76277
76445
  let low = 0;
76278
76446
  let high = items.length;
76279
76447
  while (low < high) {
@@ -76287,24 +76455,53 @@ const findBandEnd = (items, position, itemSize) => {
76287
76455
  const previous = items[low - 1];
76288
76456
  const next = items[low];
76289
76457
  if (!previous) {
76290
- if (!itemSize) {
76458
+ if (!sizeOf) {
76291
76459
  return next.index;
76292
76460
  }
76293
- const index = next.index - Math.ceil((next.from - position) / itemSize) + 1;
76294
- return index < 0 ? 0 : index;
76461
+ return findIndexBefore(next.index, next.from, position, sizeOf) + 1;
76295
76462
  }
76296
76463
  if (previous.to >= position) {
76297
76464
  return previous.index + 1;
76298
76465
  }
76299
- if (!itemSize || next && next.index === previous.index + 1) {
76466
+ if (!sizeOf || next && next.index === previous.index + 1) {
76300
76467
  return previous.index + 1;
76301
76468
  }
76302
- const index = previous.index + 2 + Math.floor((position - previous.to) / itemSize);
76469
+ const index = findIndexAfter(previous.index + 1, previous.to, position, sizeOf, next ? next.index : total) + 1;
76303
76470
  if (next && index > next.index) {
76304
76471
  return next.index;
76305
76472
  }
76306
76473
  return index;
76307
76474
  };
76475
+ // The item whose room holds `position`, the rooms laid one after the other
76476
+ // from `from` on, starting with the item at `index` — `limit` when `position`
76477
+ // is past them all.
76478
+ const findIndexAfter = (index, from, position, sizeOf, limit) => {
76479
+ let at = from;
76480
+ let itemIndex = index;
76481
+ while (itemIndex < limit) {
76482
+ const size = sizeOf(itemIndex);
76483
+ if (at + size > position) {
76484
+ return itemIndex;
76485
+ }
76486
+ at += size;
76487
+ itemIndex++;
76488
+ }
76489
+ return limit;
76490
+ };
76491
+ // The same, the rooms laid back from `to`, ending with the item before the
76492
+ // one at `index` — -1 when `position` is before them all.
76493
+ const findIndexBefore = (index, to, position, sizeOf) => {
76494
+ let at = to;
76495
+ let itemIndex = index;
76496
+ while (at > position) {
76497
+ if (itemIndex === 0) {
76498
+ return -1;
76499
+ }
76500
+ itemIndex--;
76501
+ at -= sizeOf(itemIndex);
76502
+ }
76503
+ return itemIndex;
76504
+ };
76308
76505
  // How much the window holds on each side of the screen, in the budget's unit:
76309
76506
  // read off the items' boxes where they stand, or — while the list holds itself
76310
76507
  // on an item, and the screen is where that item is going to stand (see
@@ -76820,16 +77017,19 @@ const Fallback = ({
76820
77017
  // every item it draws must not be redrawn — every item of it — because the size
76821
77018
  // settled after the first commit.
76822
77019
  // It holds lines: the items side by side on one take its room together, and a
76823
- // last line left short takes it all the same.
77020
+ // last line left short takes it all the same. An item the list drew before
77021
+ // takes the room it took then instead (see rememberItemRooms).
76824
77022
  const VirtualFiller = ({
76825
77023
  edge,
76826
77024
  itemCount,
76827
77025
  itemsPerLine,
77026
+ itemsRemembered,
77027
+ roomRemembered,
76828
77028
  findChunks
76829
77029
  }) => {
76830
77030
  const listItems = useContext(ListItemsContext);
76831
77031
  const lineSize = listItems.virtualItemSizeSignal.value;
76832
- const sizeToFill = Math.ceil(itemCount / itemsPerLine) * lineSize;
77032
+ const sizeToFill = Math.ceil(itemCount / itemsPerLine) * lineSize - itemsRemembered * lineSize / itemsPerLine + roomRemembered;
76833
77033
  // A filler resizing moves what stands below it — the items on screen, when it
76834
77034
  // holds the room of items above them — and it resizes in a commit of its own
76835
77035
  // when the item size settles after the list has rendered: the list puts its
@@ -76847,14 +77047,14 @@ const VirtualFiller = ({
76847
77047
  "navi-virtual-filler": edge,
76848
77048
  "aria-hidden": true,
76849
77049
  style: {
76850
- "--size-to-fill": `${sizeToFill}px`,
76851
- "--x-find-line-size": findChunks ? `${lineSize / itemsPerLine}px` : undefined
77050
+ "--size-to-fill": `${sizeToFill}px`
76852
77051
  },
76853
77052
  children: findChunks && findChunks.map(chunk => jsx("div", {
76854
77053
  className: "navi_list_find_stand_in",
76855
77054
  hidden: "until-found",
76856
77055
  style: {
76857
- "--x-find-line-count": chunk.to - chunk.from
77056
+ "--x-find-line-count": chunk.to - chunk.from,
77057
+ "--x-find-line-size": `${chunk.room === undefined ? lineSize / itemsPerLine : chunk.room}px`
76858
77058
  },
76859
77059
  children: chunk.text
76860
77060
  }, `${chunk.from}_${chunk.to}`))
@@ -77744,16 +77944,51 @@ const useRunItems = (store, {
77744
77944
  // Where an item named from outside actually sits. Only the run can answer:
77745
77945
  // items it holds but does not draw are nowhere else — a list only knows the
77746
77946
  // items it has drawn (they register themselves, see ListItemUI).
77747
- listItems.setItemLocator(ownerId, id => {
77748
- let found = null;
77749
- store.eachHeld((item, rank) => {
77750
- const itemIndex = indexOfRank(rank);
77751
- if (found === null && idOf(item, itemIndex) === id) {
77752
- found = itemIndex;
77947
+ const idAt = itemIndex => {
77948
+ if (itemIndex < runStart || itemIndex >= runEnd) {
77949
+ return undefined;
77950
+ }
77951
+ const item = getItemAt(itemIndex);
77952
+ return item === undefined ? undefined : idOf(item, itemIndex);
77953
+ };
77954
+ listItems.setItemLocator(ownerId, {
77955
+ indexOf: id => {
77956
+ let found = null;
77957
+ store.eachHeld((item, rank) => {
77958
+ const itemIndex = indexOfRank(rank);
77959
+ if (found === null && idOf(item, itemIndex) === id) {
77960
+ found = itemIndex;
77961
+ }
77962
+ });
77963
+ return found;
77964
+ },
77965
+ idAt
77966
+ });
77967
+ // The room an item took when the list last drew it (see rememberItemRooms),
77968
+ // or undefined: a filler holds an item it never drew at the item size.
77969
+ const roomOf = itemIndex => {
77970
+ const id = idAt(itemIndex);
77971
+ return id === undefined ? undefined : listItems.roomById.get(id);
77972
+ };
77973
+ const readRemembered = (from, to) => {
77974
+ const remembered = {
77975
+ room: 0,
77976
+ count: 0
77977
+ };
77978
+ if (listItems.roomById.size === 0) {
77979
+ return remembered;
77980
+ }
77981
+ let itemIndex = from;
77982
+ while (itemIndex < to) {
77983
+ const room = roomOf(itemIndex);
77984
+ if (room !== undefined) {
77985
+ remembered.room += room;
77986
+ remembered.count++;
77753
77987
  }
77754
- });
77755
- return found;
77756
- });
77988
+ itemIndex++;
77989
+ }
77990
+ return remembered;
77991
+ };
77757
77992
  useLayoutEffect(() => {
77758
77993
  return () => {
77759
77994
  listItems.dropItemLocator(ownerId);
@@ -77929,7 +78164,9 @@ const useRunItems = (store, {
77929
78164
  };
77930
78165
  // The text of the items a filler stands for, cut in chunks aligned on the
77931
78166
  // run's own ranks: the window sliding changes the chunk at its edge and
77932
- // leaves the others as they are.
78167
+ // leaves the others as they are. A chunk's lines are all as tall as the
78168
+ // room its items take in the filler, so it also ends where that room
78169
+ // changes: a match is then found where its item will be drawn.
77933
78170
  const getFindChunks = (from, to) => {
77934
78171
  if (!findText) {
77935
78172
  return null;
@@ -77939,10 +78176,11 @@ const useRunItems = (store, {
77939
78176
  while (chunkFrom < to) {
77940
78177
  const chunkIndex = Math.floor(rankOf(chunkFrom) / FIND_CHUNK_ITEM_COUNT);
77941
78178
  const alignedTo = indexOfRank((chunkIndex + 1) * FIND_CHUNK_ITEM_COUNT);
77942
- const chunkTo = alignedTo < to ? alignedTo : to;
78179
+ const chunkEnd = alignedTo < to ? alignedTo : to;
78180
+ const room = roomOf(chunkFrom);
77943
78181
  const lines = [];
77944
78182
  let lineIndex = chunkFrom;
77945
- while (lineIndex < chunkTo) {
78183
+ while (lineIndex < chunkEnd && roomOf(lineIndex) === room) {
77946
78184
  const item = getItemAt(lineIndex);
77947
78185
  // An item not held has nothing to find, but keeps its line: the items
77948
78186
  // after it stay at their place.
@@ -77951,10 +78189,11 @@ const useRunItems = (store, {
77951
78189
  }
77952
78190
  chunks.push({
77953
78191
  from: chunkFrom,
77954
- to: chunkTo,
78192
+ to: lineIndex,
78193
+ room,
77955
78194
  text: lines.join("\n")
77956
78195
  });
77957
- chunkFrom = chunkTo;
78196
+ chunkFrom = lineIndex;
77958
78197
  }
77959
78198
  return chunks;
77960
78199
  };
@@ -77963,10 +78202,13 @@ const useRunItems = (store, {
77963
78202
  // one run, and what sits before or after it (a header, items given one by
77964
78203
  // one) is not virtualized at all.
77965
78204
  if (windowFrom > runStart) {
78205
+ const remembered = readRemembered(runStart, windowFrom);
77966
78206
  nodes.push(jsx(VirtualFiller, {
77967
78207
  edge: "before",
77968
78208
  itemCount: windowFrom - runStart,
77969
78209
  itemsPerLine: itemsPerLine,
78210
+ itemsRemembered: remembered.count,
78211
+ roomRemembered: remembered.room,
77970
78212
  findChunks: getFindChunks(runStart, windowFrom)
77971
78213
  }, "navi-list-filler-before"));
77972
78214
  }
@@ -78068,10 +78310,13 @@ const useRunItems = (store, {
78068
78310
  }
78069
78311
  closeGroup();
78070
78312
  if (runEnd > windowTo) {
78313
+ const remembered = readRemembered(windowTo, runEnd);
78071
78314
  nodes.push(jsx(VirtualFiller, {
78072
78315
  edge: "after",
78073
78316
  itemCount: runEnd - windowTo,
78074
78317
  itemsPerLine: itemsPerLine,
78318
+ itemsRemembered: remembered.count,
78319
+ roomRemembered: remembered.room,
78075
78320
  findChunks: getFindChunks(windowTo, runEnd)
78076
78321
  }, "navi-list-filler-after"));
78077
78322
  }
@@ -79006,19 +79251,20 @@ const ListResolved = /*#__PURE__*/createComponentResolver([ListFirstResolver, Li
79006
79251
  * source for is a page (see `<List.Items pageSize>`), whatever either says,
79007
79252
  * so the first picture costs no second request.
79008
79253
  * @param {number} [props.virtualItemSize]
79009
- * The room an item not drawn is held at, in px along the scroll axis: what
79010
- * the fillers hold for each item outside the render window, what a scroll
79011
- * position inside them is read with, and the least an item on its way takes
79012
- * (see `renderSkeleton`). Left out, it is the average of the items measured
79013
- * so far — once when the list mounts, again when a popup around it opens,
79014
- * and after each commit while items are held off screen. Given, it is the
79015
- * worst case: the size every item has, or, in a list whose items differ, the
79016
- * smallest an item can be (a thread of one-line items and cards: the
79017
- * one-line size) — an item guessed too small builds one more, an item
79018
- * guessed too big leaves a blank (see docs/scroll.md, "What the list knows,
79019
- * and what it guesses"). The items drawn are measured either way: the render
79020
- * window is sized on them. In a grid (`columns`), the size is a line's: a
79021
- * card's, which the items side by side on it share.
79254
+ * The room an item never drawn is held at, in px along the scroll axis: what
79255
+ * the fillers hold for it outside the render window, what a scroll position
79256
+ * inside them is read with, and the least an item on its way takes (see
79257
+ * `renderSkeleton`). An item the list has drawn is held at the room it took
79258
+ * then. Left out, it is the average of the items measured so far — once when
79259
+ * the list mounts, again when a popup around it opens, and after each commit
79260
+ * while items are held off screen. Given, it is the worst case: the size
79261
+ * every item has, or, in a list whose items differ, the smallest an item can
79262
+ * be (a thread of one-line items and cards: the one-line size) — an item
79263
+ * guessed too small builds one more, an item guessed too big leaves a blank
79264
+ * (see docs/scroll.md, "What the list knows, and what it guesses"). The items
79265
+ * drawn are measured either way: the render window is sized on them. In a
79266
+ * grid (`columns`), the size is a line's: a card's, which the items side by
79267
+ * side on it share, and the lines drawn are held at it too.
79022
79268
  * @param {"self"|"parent"|"document"|Element|{current: Element}} [props.scroller="self"]
79023
79269
  * Which box scrolls — and with it, which box the render window follows and
79024
79270
  * which box a scroll position is read from (`onScrolledChange`). `"self"`
@@ -94374,5 +94620,5 @@ const UserSvg = () => jsx("svg", {
94374
94620
  })
94375
94621
  });
94376
94622
 
94377
- export { ActionRenderer, ActiveKeyboardShortcuts, Address, Badge, BadgeCount, BadgeList, Binder, Box, Button, ButtonCopyToClipboard, CalloutStatusIcon, Caption, CardLayout, CheckSvg, CheckboxGroup, CloseSvg, Code, Col, Colgroup, Color, ConstructionSvg, ControlGroup, ControlSwap, DaySpin, Details, Dialog, Editable, ErrorBoundary, ErrorBoundaryContext, ExclamationSvg, Expandable, EyeClosedSvg, EyeSvg, Field, FixedBar, Form, Group, Head, HeartSvg, HomeSvg, Icon, Image, InfoSvg, Input, InputDuration, Interpolate, Label, Link, LinkAnchorSvg, LinkBlankTargetSvg, LinkCurrentSvg, List, ListItem, ListItemGroup, ListItems, Loading, LoadingDotsSvg, LoadingIndicator, LoadingIndicatorFluid, LoadingOutline, MessageBox, Meter, Nav, NaviDebug, NetworkPolicyError, NumberSpin, Paragraph, Picker, Popover, Popup, Quantity, RadioGroup, Route, RouteTransitionArea, RouteTravel, RowNumberCol, RowNumberTableCell, SVGMaskOverlay, SearchSvg, Select, SelectableInput, SelectionContext, Separator, SettingsSvg, SidePanel, Slide, SlideContainer, Spin, SpinGroup, SplitButton, StarSvg, Step, StepList, SummaryMarker, Svg, Table, TableCell, Tbody, Text, TextBox, Textarea, TextareaCharCount, Thead, Time, TimeRange, TimeRangeSpin, TimeRangeWheel, TimeSpin, TimeWheel, Title, Tr, UITransition, Unit, UserSvg, ViewportLayout, Wheel, WheelGroup, WheelItem, actionRunEffect, activeRouteActionsSignal, anyMatchingRouteSignal, applySearch, arraySignalMembership, canNavBackSignal, canNavForwardSignal, coarsePointerSignal, compareTwoJsValues, constraintFromValidityRule, createAction, createAvailableConstraint, createRequestCanceller, createSearch, createSelectionKeyboardShortcuts, createSlot, defineInteractionDetector, defineRouteDefaultTransition, defineRouteTransition, detectHorizontalOverflow, dispatchRequestSetUIState, enableDebugActions, enableDebugOnDocumentLoading, enableVirtualKeyboardOverlay, ensureDocumentStartViewTransition, errorIsDisplayed, filterTableSelection, getNowHours, getNowHoursRoundedToStep, isCellSelected, isColumnSelected, isNetworkPolicyError, isRowSelected, isScrolling, isToday, keepPageOnScreen, languagesSignal, localStorageSignal, markAsOutsideTextFlow, markErrorAsDisplayedBy, moveArrayItemByIndex, moveFocusTo, navBack, navForward, navIntegratedVia, navTo, naviI18n, openCallout, preloadUrl, rawUrlPart, registerGlobalConstraint, reload, rerunActions, resource, route, routeAction, routeFallback, scrollActivitySignal, setBaseUrl, setNetworkPolicy, setPreferredLanguage, setSupportedLanguages, setUrlTargetOptions, setupRoutes, smallTouchScreenSignal, stateSignal, stopLoad, stringifyTableSelectionValue, swapArrayItemByIndex, syncOwnedResourceToSignals, syncResourceToSignals, triggerNaviCommand, updateActions, useActionStatus, useArraySignalMembership, useAsyncData, useCalloutElement, useCalloutRequestClose, useCanNavBack, useCanNavForward, useCancelPrevious, useCellGridFromRows, useConstraintValidityState, useDependenciesDiff, useDisplayedLayoutEffect, useDocumentResource, useDocumentState, useDocumentUrl, useEditionController, useFocusGroup, useInputGroup, useKeyboardShortcuts, useNavState, useNetworkPolicyReason, useOrderedColumns, usePickerState, usePopupMode, useRouteStatus, useSearchText, useSelectableElement, useSelectionController, useSignalSync, useSlideContainer, useSlideValue, useStateArray, useTitleLevel, useTransitionCover, useUrlSearchParam, useUrlTargetId, valueInLocalStorage, windowWidthSignal };
94623
+ export { ActionRenderer, ActiveKeyboardShortcuts, Address, Badge, BadgeCount, BadgeList, Binder, Box, Button, ButtonCopyToClipboard, CalloutStatusIcon, Caption, CardLayout, CheckSvg, CheckboxGroup, CloseSvg, Code, Col, Colgroup, Color, ConstructionSvg, ControlGroup, ControlSwap, DaySpin, Details, Dialog, Editable, ErrorBoundary, ErrorBoundaryContext, ExclamationSvg, Expandable, EyeClosedSvg, EyeSvg, Field, FixedBar, Form, Group, Head, HeartSvg, HomeSvg, Icon, Image, InfoSvg, Input, InputDuration, Interpolate, Label, Link, LinkAnchorSvg, LinkBlankTargetSvg, LinkCurrentSvg, List, ListItem, ListItemGroup, ListItems, Loading, LoadingDotsSvg, LoadingIndicator, LoadingIndicatorFluid, LoadingOutline, MessageBox, Meter, Nav, NaviDebug, NetworkPolicyError, NumberSpin, Paragraph, Picker, Popover, Popup, Quantity, RadioGroup, Route, RouteTransitionArea, RouteTravel, RowNumberCol, RowNumberTableCell, SVGMaskOverlay, SearchSvg, Select, SelectableInput, SelectionContext, Separator, SettingsSvg, SidePanel, Slide, SlideContainer, Spin, SpinGroup, SplitButton, StarSvg, Step, StepList, SummaryMarker, Svg, Table, TableCell, Tbody, Text, TextBox, Textarea, TextareaCharCount, Thead, Time, TimeRange, TimeRangeSpin, TimeRangeWheel, TimeSpin, TimeWheel, Title, Tr, UITransition, Unit, UserSvg, ViewportLayout, Wheel, WheelGroup, WheelItem, actionRunEffect, activeRouteActionsSignal, activeRouteReadsSignal, anyMatchingRouteSignal, applySearch, arraySignalMembership, canNavBackSignal, canNavForwardSignal, coarsePointerSignal, compareTwoJsValues, constraintFromValidityRule, createAction, createAvailableConstraint, createRequestCanceller, createSearch, createSelectionKeyboardShortcuts, createSlot, defineInteractionDetector, defineRouteDefaultTransition, defineRouteTransition, detectHorizontalOverflow, dispatchRequestSetUIState, enableDebugActions, enableDebugOnDocumentLoading, enableVirtualKeyboardOverlay, ensureDocumentStartViewTransition, errorIsDisplayed, filterTableSelection, getNowHours, getNowHoursRoundedToStep, isCellSelected, isColumnSelected, isNetworkPolicyError, isRowSelected, isScrolling, isToday, keepPageOnScreen, languagesSignal, localStorageSignal, markAsOutsideTextFlow, markErrorAsDisplayedBy, moveArrayItemByIndex, moveFocusTo, navBack, navForward, navIntegratedVia, navTo, naviI18n, openCallout, preloadUrl, rawUrlPart, registerGlobalConstraint, reload, rerunActions, resource, route, routeAction, routeFallback, scrollActivitySignal, setBaseUrl, setNetworkPolicy, setPreferredLanguage, setSupportedLanguages, setUrlTargetOptions, setupRoutes, smallTouchScreenSignal, stateSignal, stopLoad, stringifyTableSelectionValue, swapArrayItemByIndex, syncOwnedResourceToSignals, syncResourceToSignals, triggerNaviCommand, updateActions, useActionStatus, useArraySignalMembership, useAsyncData, useCalloutElement, useCalloutRequestClose, useCanNavBack, useCanNavForward, useCancelPrevious, useCellGridFromRows, useConstraintValidityState, useDependenciesDiff, useDisplayedLayoutEffect, useDocumentResource, useDocumentState, useDocumentUrl, useEditionController, useFocusGroup, useInputGroup, useKeyboardShortcuts, useNavState, useNetworkPolicyReason, useOrderedColumns, usePickerState, usePopupMode, useRouteStatus, useSearchText, useSelectableElement, useSelectionController, useSignalSync, useSlideContainer, useSlideValue, useStateArray, useTitleLevel, useTransitionCover, useUrlSearchParam, useUrlTargetId, valueInLocalStorage, windowWidthSignal };
94378
94624
  //# sourceMappingURL=jsenv_navi.js.map