@sovereignbase/convergent-replicated-list 1.3.4 → 1.3.6

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/index.cjs CHANGED
@@ -294,8 +294,17 @@ function trySpliceReplacement(crListReplica, insertedEntries, reparentedEntries,
294
294
  } else if (_optionalChain([crListReplica, 'access', _23 => _23.childrenMap, 'access', _24 => _24.get, 'call', _25 => _25(inserted.uuidv7), 'optionalAccess', _26 => _26.length])) {
295
295
  return false;
296
296
  }
297
- if (_optionalChain([predecessor, 'optionalAccess', _27 => _27.next]) !== next) return false;
298
- if (!predecessor && crListReplica.cursor !== next) return false;
297
+ if (predecessor) {
298
+ if (predecessor.next !== next) return false;
299
+ } else {
300
+ let reachable = 0;
301
+ let current2 = next;
302
+ while (current2) {
303
+ reachable++;
304
+ current2 = current2.next;
305
+ }
306
+ if (reachable !== crListReplica.parentMap.size - 1) return false;
307
+ }
299
308
  const expectedIndex = predecessor ? predecessor.index + 1 : 0;
300
309
  void linkEntryBetween(predecessor, inserted, next);
301
310
  let current = inserted;
@@ -312,6 +321,48 @@ function trySpliceReplacement(crListReplica, insertedEntries, reparentedEntries,
312
321
  return true;
313
322
  }
314
323
 
324
+ // src/.helpers/trySpliceSiblingInsert/index.ts
325
+ function trySpliceSiblingInsert(crListReplica, insertedEntries, reparentedEntries, tombstoneCount) {
326
+ if (tombstoneCount !== 0 || insertedEntries.length !== 1 || reparentedEntries.length !== 0)
327
+ return false;
328
+ const inserted = insertedEntries[0];
329
+ if (inserted.predecessor === "\0") return false;
330
+ if (_optionalChain([crListReplica, 'access', _27 => _27.childrenMap, 'access', _28 => _28.get, 'call', _29 => _29(inserted.uuidv7), 'optionalAccess', _30 => _30.length])) return false;
331
+ const predecessor = crListReplica.parentMap.get(inserted.predecessor);
332
+ const siblings = crListReplica.childrenMap.get(inserted.predecessor);
333
+ if (!predecessor || !siblings || siblings.length < 2) return false;
334
+ void siblings.sort((a, b) => a.uuidv7 > b.uuidv7 ? 1 : -1);
335
+ const siblingIndex = siblings.indexOf(inserted);
336
+ if (siblingIndex === -1) return false;
337
+ const lastSibling = siblings[siblings.length - 1];
338
+ if (lastSibling !== inserted && lastSibling.next) return false;
339
+ const previousSibling = siblings[siblingIndex - 1];
340
+ const nextSibling = siblings[siblingIndex + 1];
341
+ if (_optionalChain([previousSibling, 'optionalAccess', _31 => _31.uuidv7])) {
342
+ if (_optionalChain([crListReplica, 'access', _32 => _32.childrenMap, 'access', _33 => _33.get, 'call', _34 => _34(previousSibling.uuidv7), 'optionalAccess', _35 => _35.length]))
343
+ return false;
344
+ if (previousSibling.next !== nextSibling) return false;
345
+ } else if (predecessor.next !== nextSibling) {
346
+ return false;
347
+ }
348
+ const prev = _nullishCoalesce(previousSibling, () => ( predecessor));
349
+ const next = nextSibling;
350
+ if (next && next.prev !== prev) return false;
351
+ void linkEntryBetween(prev, inserted, next);
352
+ let current = inserted;
353
+ let index = prev.index + 1;
354
+ while (current) {
355
+ current.index = index;
356
+ index++;
357
+ current = current.next;
358
+ }
359
+ crListReplica.index = /* @__PURE__ */ new Map([[inserted.index, inserted]]);
360
+ crListReplica.cursor = inserted;
361
+ crListReplica.cursorIndex = inserted.index;
362
+ crListReplica.size = crListReplica.parentMap.size;
363
+ return true;
364
+ }
365
+
315
366
  // src/core/crud/create/index.ts
316
367
 
317
368
  function __create(snapshot) {
@@ -343,11 +394,11 @@ function __create(snapshot) {
343
394
  );
344
395
  if (!linkedListEntry) continue;
345
396
  void attachEntryToIndexes(crListReplica, linkedListEntry);
346
- if (canUseLinearProjection && linkedListEntry.predecessor === (_nullishCoalesce(_optionalChain([previous, 'optionalAccess', _28 => _28.uuidv7]), () => ( "\0")))) {
397
+ if (canUseLinearProjection && linkedListEntry.predecessor === (_nullishCoalesce(_optionalChain([previous, 'optionalAccess', _36 => _36.uuidv7]), () => ( "\0")))) {
347
398
  linkedListEntry.index = crListReplica.parentMap.size - 1;
348
399
  void linkEntryBetween(previous, linkedListEntry, void 0);
349
400
  previous = linkedListEntry;
350
- void _optionalChain([crListReplica, 'access', _29 => _29.index, 'optionalAccess', _30 => _30.set, 'call', _31 => _31(linkedListEntry.index, linkedListEntry)]);
401
+ void _optionalChain([crListReplica, 'access', _37 => _37.index, 'optionalAccess', _38 => _38.set, 'call', _39 => _39(linkedListEntry.index, linkedListEntry)]);
351
402
  continue;
352
403
  }
353
404
  canUseLinearProjection = false;
@@ -366,7 +417,7 @@ function __create(snapshot) {
366
417
  function __read(targetIndex, crListReplica) {
367
418
  try {
368
419
  void seekCursorToIndex(targetIndex, crListReplica);
369
- return _optionalChain([crListReplica, 'access', _32 => _32.cursor, 'optionalAccess', _33 => _33.value]);
420
+ return _optionalChain([crListReplica, 'access', _40 => _40.cursor, 'optionalAccess', _41 => _41.value]);
370
421
  } catch (e) {
371
422
  return void 0;
372
423
  }
@@ -385,6 +436,7 @@ function __update(listIndex, listValues, crListReplica, mode) {
385
436
  if (listValues.length === 0) return false;
386
437
  const change = {};
387
438
  const delta = { values: [], tombstones: [] };
439
+ let displacedEntry;
388
440
  for (const listValue of listValues) {
389
441
  const v7 = _uuid.v7.call(void 0, );
390
442
  const linkedListEntry = {
@@ -402,7 +454,7 @@ function __update(listIndex, listValues, crListReplica, mode) {
402
454
  crListReplica.cursor = linkedListEntry;
403
455
  crListReplica.cursorIndex = linkedListEntry.index;
404
456
  void attachEntryToIndexes(crListReplica, linkedListEntry, delta);
405
- _optionalChain([crListReplica, 'access', _34 => _34.index, 'optionalAccess', _35 => _35.set, 'call', _36 => _36(linkedListEntry.index, linkedListEntry)]);
457
+ _optionalChain([crListReplica, 'access', _42 => _42.index, 'optionalAccess', _43 => _43.set, 'call', _44 => _44(linkedListEntry.index, linkedListEntry)]);
406
458
  change[linkedListEntry.index] = linkedListEntry.value;
407
459
  break;
408
460
  }
@@ -418,7 +470,7 @@ function __update(listIndex, listValues, crListReplica, mode) {
418
470
  void attachEntryToIndexes(crListReplica, linkedListEntry, delta);
419
471
  crListReplica.cursor = linkedListEntry;
420
472
  crListReplica.cursorIndex = linkedListEntry.index;
421
- void _optionalChain([crListReplica, 'access', _37 => _37.index, 'optionalAccess', _38 => _38.set, 'call', _39 => _39(linkedListEntry.index, linkedListEntry)]);
473
+ void _optionalChain([crListReplica, 'access', _45 => _45.index, 'optionalAccess', _46 => _46.set, 'call', _47 => _47(linkedListEntry.index, linkedListEntry)]);
422
474
  change[linkedListEntry.index] = linkedListEntry.value;
423
475
  break;
424
476
  }
@@ -433,25 +485,37 @@ function __update(listIndex, listValues, crListReplica, mode) {
433
485
  linkedListEntry,
434
486
  entryToOverwrite.next
435
487
  );
436
- if (entryToOverwrite.next) {
437
- if (entryToOverwrite.next.predecessor === entryToOverwrite.uuidv7) {
438
- void moveEntryToPredecessor(
439
- crListReplica,
440
- entryToOverwrite.next,
441
- linkedListEntry.uuidv7,
442
- delta
443
- );
488
+ if (_optionalChain([entryToOverwrite, 'access', _48 => _48.next, 'optionalAccess', _49 => _49.predecessor]) === entryToOverwrite.uuidv7) {
489
+ const overwriteNext = entryToOverwrite.next;
490
+ const owSibs = crListReplica.childrenMap.get(
491
+ overwriteNext.predecessor
492
+ );
493
+ if (owSibs) {
494
+ const i = owSibs.indexOf(overwriteNext);
495
+ if (i !== -1) owSibs.splice(i, 1);
444
496
  }
497
+ overwriteNext.predecessor = linkedListEntry.uuidv7;
498
+ const newSibs = crListReplica.childrenMap.get(linkedListEntry.uuidv7);
499
+ if (newSibs) newSibs.push(overwriteNext);
500
+ else
501
+ crListReplica.childrenMap.set(linkedListEntry.uuidv7, [
502
+ overwriteNext
503
+ ]);
504
+ _optionalChain([delta, 'access', _50 => _50.values, 'optionalAccess', _51 => _51.push, 'call', _52 => _52({
505
+ uuidv7: overwriteNext.uuidv7,
506
+ value: overwriteNext.value,
507
+ predecessor: overwriteNext.predecessor
508
+ })]);
445
509
  }
446
510
  void attachEntryToIndexes(crListReplica, linkedListEntry, delta);
447
511
  void crListReplica.tombstones.add(entryToOverwrite.uuidv7);
448
- void _optionalChain([delta, 'access', _40 => _40.tombstones, 'optionalAccess', _41 => _41.push, 'call', _42 => _42(entryToOverwrite.uuidv7)]);
512
+ void _optionalChain([delta, 'access', _53 => _53.tombstones, 'optionalAccess', _54 => _54.push, 'call', _55 => _55(entryToOverwrite.uuidv7)]);
449
513
  void detachEntryFromIndexes(crListReplica, entryToOverwrite);
450
514
  entryToOverwrite.next = void 0;
451
515
  entryToOverwrite.prev = void 0;
452
516
  crListReplica.cursor = linkedListEntry;
453
517
  crListReplica.cursorIndex = actualIndex;
454
- void _optionalChain([crListReplica, 'access', _43 => _43.index, 'optionalAccess', _44 => _44.set, 'call', _45 => _45(linkedListEntry.index, linkedListEntry)]);
518
+ void _optionalChain([crListReplica, 'access', _56 => _56.index, 'optionalAccess', _57 => _57.set, 'call', _58 => _58(linkedListEntry.index, linkedListEntry)]);
455
519
  change[actualIndex] = linkedListEntry.value;
456
520
  break;
457
521
  }
@@ -460,7 +524,7 @@ function __update(listIndex, listValues, crListReplica, mode) {
460
524
  crListReplica.cursor = linkedListEntry;
461
525
  crListReplica.cursorIndex = linkedListEntry.index;
462
526
  void attachEntryToIndexes(crListReplica, linkedListEntry, delta);
463
- void _optionalChain([crListReplica, 'access', _46 => _46.index, 'optionalAccess', _47 => _47.set, 'call', _48 => _48(linkedListEntry.index, linkedListEntry)]);
527
+ void _optionalChain([crListReplica, 'access', _59 => _59.index, 'optionalAccess', _60 => _60.set, 'call', _61 => _61(linkedListEntry.index, linkedListEntry)]);
464
528
  change[linkedListEntry.index] = linkedListEntry.value;
465
529
  break;
466
530
  }
@@ -475,21 +539,25 @@ function __update(listIndex, listValues, crListReplica, mode) {
475
539
  linkedListEntry.index = actualIndex + 1;
476
540
  linkedListEntry.predecessor = crListReplica.cursor.uuidv7;
477
541
  void linkEntryBetween(crListReplica.cursor, linkedListEntry, next);
478
- if (next) {
479
- if (next.predecessor === crListReplica.cursor.uuidv7) {
480
- void moveEntryToPredecessor(
481
- crListReplica,
482
- next,
483
- linkedListEntry.uuidv7,
484
- delta
485
- );
542
+ if (next && next.predecessor === crListReplica.cursor.uuidv7) {
543
+ if (!displacedEntry) {
544
+ displacedEntry = next;
545
+ const sibs = crListReplica.childrenMap.get(next.predecessor);
546
+ if (sibs) {
547
+ const i = sibs.indexOf(next);
548
+ if (i !== -1) sibs.splice(i, 1);
549
+ }
486
550
  }
551
+ displacedEntry.predecessor = linkedListEntry.uuidv7;
487
552
  }
488
553
  void attachEntryToIndexes(crListReplica, linkedListEntry, delta);
489
554
  crListReplica.cursor = linkedListEntry;
490
555
  crListReplica.cursorIndex = linkedListEntry.index;
491
- if (next) crListReplica.index = /* @__PURE__ */ new Map();
492
- void _optionalChain([crListReplica, 'access', _49 => _49.index, 'optionalAccess', _50 => _50.set, 'call', _51 => _51(linkedListEntry.index, linkedListEntry)]);
556
+ if (next) {
557
+ if (crListReplica.index) crListReplica.index.clear();
558
+ else crListReplica.index = /* @__PURE__ */ new Map();
559
+ }
560
+ void _optionalChain([crListReplica, 'access', _62 => _62.index, 'optionalAccess', _63 => _63.set, 'call', _64 => _64(linkedListEntry.index, linkedListEntry)]);
493
561
  change[linkedListEntry.index] = linkedListEntry.value;
494
562
  break;
495
563
  }
@@ -498,7 +566,7 @@ function __update(listIndex, listValues, crListReplica, mode) {
498
566
  crListReplica.cursor = linkedListEntry;
499
567
  crListReplica.cursorIndex = linkedListEntry.index;
500
568
  void attachEntryToIndexes(crListReplica, linkedListEntry, delta);
501
- void _optionalChain([crListReplica, 'access', _52 => _52.index, 'optionalAccess', _53 => _53.set, 'call', _54 => _54(linkedListEntry.index, linkedListEntry)]);
569
+ void _optionalChain([crListReplica, 'access', _65 => _65.index, 'optionalAccess', _66 => _66.set, 'call', _67 => _67(linkedListEntry.index, linkedListEntry)]);
502
570
  change[linkedListEntry.index] = linkedListEntry.value;
503
571
  mode = "after";
504
572
  listIndex = linkedListEntry.index - 1;
@@ -509,21 +577,27 @@ function __update(listIndex, listValues, crListReplica, mode) {
509
577
  const actualIndex = _nullishCoalesce(crListReplica.cursorIndex, () => ( listIndex));
510
578
  const prev = crListReplica.cursor.prev;
511
579
  linkedListEntry.index = actualIndex;
512
- linkedListEntry.predecessor = _nullishCoalesce(_optionalChain([prev, 'optionalAccess', _55 => _55.uuidv7]), () => ( "\0"));
580
+ linkedListEntry.predecessor = _nullishCoalesce(_optionalChain([prev, 'optionalAccess', _68 => _68.uuidv7]), () => ( "\0"));
513
581
  void linkEntryBetween(prev, linkedListEntry, crListReplica.cursor);
514
582
  if (crListReplica.cursor.predecessor === linkedListEntry.predecessor) {
515
- void moveEntryToPredecessor(
516
- crListReplica,
517
- crListReplica.cursor,
518
- linkedListEntry.uuidv7,
519
- delta
520
- );
583
+ if (!displacedEntry) {
584
+ displacedEntry = crListReplica.cursor;
585
+ const sibs = crListReplica.childrenMap.get(
586
+ crListReplica.cursor.predecessor
587
+ );
588
+ if (sibs) {
589
+ const i = sibs.indexOf(crListReplica.cursor);
590
+ if (i !== -1) sibs.splice(i, 1);
591
+ }
592
+ }
593
+ displacedEntry.predecessor = linkedListEntry.uuidv7;
521
594
  }
522
595
  void attachEntryToIndexes(crListReplica, linkedListEntry, delta);
523
596
  crListReplica.cursor = linkedListEntry;
524
597
  crListReplica.cursorIndex = actualIndex;
525
- crListReplica.index = /* @__PURE__ */ new Map();
526
- void _optionalChain([crListReplica, 'access', _56 => _56.index, 'optionalAccess', _57 => _57.set, 'call', _58 => _58(linkedListEntry.index, linkedListEntry)]);
598
+ if (crListReplica.index) crListReplica.index.clear();
599
+ else crListReplica.index = /* @__PURE__ */ new Map();
600
+ void _optionalChain([crListReplica, 'access', _69 => _69.index, 'optionalAccess', _70 => _70.set, 'call', _71 => _71(linkedListEntry.index, linkedListEntry)]);
527
601
  change[actualIndex] = linkedListEntry.value;
528
602
  mode = "after";
529
603
  listIndex = linkedListEntry.index - 1;
@@ -533,6 +607,19 @@ function __update(listIndex, listValues, crListReplica, mode) {
533
607
  crListReplica.size = crListReplica.parentMap.size;
534
608
  listIndex++;
535
609
  }
610
+ if (displacedEntry) {
611
+ const sibs = crListReplica.childrenMap.get(displacedEntry.predecessor);
612
+ if (sibs) sibs.push(displacedEntry);
613
+ else
614
+ crListReplica.childrenMap.set(displacedEntry.predecessor, [
615
+ displacedEntry
616
+ ]);
617
+ _optionalChain([delta, 'access', _72 => _72.values, 'optionalAccess', _73 => _73.push, 'call', _74 => _74({
618
+ uuidv7: displacedEntry.uuidv7,
619
+ value: displacedEntry.value,
620
+ predecessor: displacedEntry.predecessor
621
+ })]);
622
+ }
536
623
  return { change, delta };
537
624
  }
538
625
 
@@ -550,7 +637,7 @@ function __delete(crListReplica, startIndex, endIndex) {
550
637
  void seekCursorToIndex(listIndex, crListReplica);
551
638
  if (!crListReplica.cursor) return false;
552
639
  let current = crListReplica.cursor;
553
- const predecessor = _nullishCoalesce(_optionalChain([current, 'access', _59 => _59.prev, 'optionalAccess', _60 => _60.uuidv7]), () => ( "\0"));
640
+ const predecessor = _nullishCoalesce(_optionalChain([current, 'access', _75 => _75.prev, 'optionalAccess', _76 => _76.uuidv7]), () => ( "\0"));
554
641
  const deletedIds = /* @__PURE__ */ new Set();
555
642
  let deleted = 0;
556
643
  let currentIndex = _nullishCoalesce(crListReplica.cursorIndex, () => ( listIndex));
@@ -558,7 +645,7 @@ function __delete(crListReplica, startIndex, endIndex) {
558
645
  const next = current.next;
559
646
  change[currentIndex] = void 0;
560
647
  void deletedIds.add(current.uuidv7);
561
- void _optionalChain([crListReplica, 'access', _61 => _61.index, 'optionalAccess', _62 => _62.delete, 'call', _63 => _63(currentIndex)]);
648
+ void _optionalChain([crListReplica, 'access', _77 => _77.index, 'optionalAccess', _78 => _78.delete, 'call', _79 => _79(currentIndex)]);
562
649
  void deleteLiveEntry(crListReplica, current, delta);
563
650
  current = next;
564
651
  currentIndex++;
@@ -578,7 +665,7 @@ function __delete(crListReplica, startIndex, endIndex) {
578
665
  void deleteLiveEntry(crListReplica, current, delta);
579
666
  void linkEntryBetween(prev, replacement, next);
580
667
  void attachEntryToIndexes(crListReplica, replacement, delta);
581
- if (_optionalChain([next, 'optionalAccess', _64 => _64.predecessor]) === current.uuidv7)
668
+ if (_optionalChain([next, 'optionalAccess', _80 => _80.predecessor]) === current.uuidv7)
582
669
  void moveEntryToPredecessor(
583
670
  crListReplica,
584
671
  next,
@@ -624,7 +711,7 @@ function __merge(crListReplica, crListDelta) {
624
711
  crListReplica.cursorIndex = linkedListEntry.index;
625
712
  void attachEntryToIndexes(crListReplica, linkedListEntry);
626
713
  crListReplica.size = crListReplica.parentMap.size;
627
- void _optionalChain([crListReplica, 'access', _65 => _65.index, 'optionalAccess', _66 => _66.set, 'call', _67 => _67(linkedListEntry.index, linkedListEntry)]);
714
+ void _optionalChain([crListReplica, 'access', _81 => _81.index, 'optionalAccess', _82 => _82.set, 'call', _83 => _83(linkedListEntry.index, linkedListEntry)]);
628
715
  return { [linkedListEntry.index]: linkedListEntry.value };
629
716
  }
630
717
  }
@@ -638,19 +725,19 @@ function __merge(crListReplica, crListDelta) {
638
725
  const wasTail = linkedListEntry.next === void 0;
639
726
  const wasCursor = crListReplica.cursor === linkedListEntry;
640
727
  void newTombsIndices.push(linkedListEntry.index);
641
- void _optionalChain([crListReplica, 'access', _68 => _68.index, 'optionalAccess', _69 => _69.delete, 'call', _70 => _70(linkedListEntry.index)]);
728
+ void _optionalChain([crListReplica, 'access', _84 => _84.index, 'optionalAccess', _85 => _85.delete, 'call', _86 => _86(linkedListEntry.index)]);
642
729
  void deleteLiveEntry(crListReplica, linkedListEntry);
643
730
  tailTombstoneMovedCursor = wasTail && wasCursor;
644
731
  needsRelink = true;
645
732
  }
646
733
  }
647
734
  }
648
- if (!Object.hasOwn(crListDelta, "values") || !Array.isArray(crListDelta.values)) {
735
+ if (!Object.hasOwn(crListDelta, "values") || !Array.isArray(crListDelta.values) || crListDelta.values.length === 0 && tailTombstoneMovedCursor) {
649
736
  if (newTombsIndices.length === 0) return false;
650
737
  if (newTombsIndices.length === 1 && tailTombstoneMovedCursor) {
651
738
  if (crListReplica.cursor) {
652
739
  crListReplica.cursorIndex = crListReplica.size - 1;
653
- void _optionalChain([crListReplica, 'access', _71 => _71.index, 'optionalAccess', _72 => _72.set, 'call', _73 => _73(
740
+ void _optionalChain([crListReplica, 'access', _87 => _87.index, 'optionalAccess', _88 => _88.set, 'call', _89 => _89(
654
741
  crListReplica.cursorIndex,
655
742
  crListReplica.cursor
656
743
  )]);
@@ -697,7 +784,7 @@ function __merge(crListReplica, crListDelta) {
697
784
  crListReplica.cursor = linkedListEntry;
698
785
  crListReplica.cursorIndex = linkedListEntry.index;
699
786
  crListReplica.size = crListReplica.parentMap.size;
700
- void _optionalChain([crListReplica, 'access', _74 => _74.index, 'optionalAccess', _75 => _75.set, 'call', _76 => _76(linkedListEntry.index, linkedListEntry)]);
787
+ void _optionalChain([crListReplica, 'access', _90 => _90.index, 'optionalAccess', _91 => _91.set, 'call', _92 => _92(linkedListEntry.index, linkedListEntry)]);
701
788
  } else {
702
789
  needsRelink = true;
703
790
  }
@@ -708,13 +795,18 @@ function __merge(crListReplica, crListDelta) {
708
795
  crListReplica.cursor = linkedListEntry;
709
796
  crListReplica.cursorIndex = linkedListEntry.index;
710
797
  crListReplica.size = crListReplica.parentMap.size;
711
- void _optionalChain([crListReplica, 'access', _77 => _77.index, 'optionalAccess', _78 => _78.set, 'call', _79 => _79(linkedListEntry.index, linkedListEntry)]);
798
+ void _optionalChain([crListReplica, 'access', _93 => _93.index, 'optionalAccess', _94 => _94.set, 'call', _95 => _95(linkedListEntry.index, linkedListEntry)]);
712
799
  } else {
713
800
  needsRelink = true;
714
801
  }
715
802
  }
716
803
  if (needsRelink) {
717
- if (!trySpliceInsertedParent(crListReplica, newVals, reparentedVals) && !trySpliceReplacement(
804
+ if (!trySpliceSiblingInsert(
805
+ crListReplica,
806
+ newVals,
807
+ reparentedVals,
808
+ newTombsIndices.length
809
+ ) && !trySpliceInsertedParent(crListReplica, newVals, reparentedVals) && !trySpliceReplacement(
718
810
  crListReplica,
719
811
  newVals,
720
812
  reparentedVals,
@@ -868,32 +960,32 @@ var CRList = class {
868
960
  return this.state.size;
869
961
  }
870
962
  /**
871
- * Inserts a value before an index.
963
+ * Inserts values before an index.
872
964
  *
873
- * If `beforeIndex` is omitted, the value is inserted at the start of the list.
965
+ * If `beforeIndex` is omitted, values are inserted at the start of the list.
874
966
  *
875
- * @param value - The value to insert.
967
+ * @param values - Values to insert.
876
968
  * @param beforeIndex - The index to insert before.
877
969
  */
878
- prepend(value, beforeIndex) {
879
- const result = __update(_nullishCoalesce(beforeIndex, () => ( 0)), [value], this.state, "before");
970
+ prepend(values, beforeIndex) {
971
+ const result = __update(_nullishCoalesce(beforeIndex, () => ( 0)), values, this.state, "before");
880
972
  if (!result) return;
881
973
  const { delta, change } = result;
882
974
  if (delta) void dispatchCRListEvent(this.eventTarget, "delta", delta);
883
975
  if (change) void dispatchCRListEvent(this.eventTarget, "change", change);
884
976
  }
885
977
  /**
886
- * Inserts a value after an index.
978
+ * Inserts values after an index.
887
979
  *
888
- * If `afterIndex` is omitted, the value is appended at the end of the list.
980
+ * If `afterIndex` is omitted, values are appended at the end of the list.
889
981
  *
890
- * @param value - The value to insert.
982
+ * @param values - Values to insert.
891
983
  * @param afterIndex - The index to insert after.
892
984
  */
893
- append(value, afterIndex) {
985
+ append(values, afterIndex) {
894
986
  const result = __update(
895
987
  _nullishCoalesce(afterIndex, () => ( this.state.size)),
896
- [value],
988
+ values,
897
989
  this.state,
898
990
  "after"
899
991
  );
@@ -903,12 +995,26 @@ var CRList = class {
903
995
  if (change) void dispatchCRListEvent(this.eventTarget, "change", change);
904
996
  }
905
997
  /**
906
- * Removes the entry at an index.
998
+ * Overwrites entries starting at an index.
999
+ *
1000
+ * @param index - The index to start overwriting at.
1001
+ * @param values - Values to write.
1002
+ */
1003
+ update(index, values) {
1004
+ const result = __update(index, values, this.state, "overwrite");
1005
+ if (!result) return;
1006
+ const { delta, change } = result;
1007
+ if (delta) void dispatchCRListEvent(this.eventTarget, "delta", delta);
1008
+ if (change) void dispatchCRListEvent(this.eventTarget, "change", change);
1009
+ }
1010
+ /**
1011
+ * Removes one or more entries starting at an index.
907
1012
  *
908
- * @param index - The index to remove.
1013
+ * @param index - The first index to remove.
1014
+ * @param count - Number of entries to remove. Defaults to `1`.
909
1015
  */
910
- remove(index) {
911
- const result = __delete(this.state, index, index + 1);
1016
+ remove(index, count = 1) {
1017
+ const result = __delete(this.state, index, index + count);
912
1018
  if (!result) return;
913
1019
  const { delta, change } = result;
914
1020
  if (delta) void dispatchCRListEvent(this.eventTarget, "delta", delta);
@@ -924,8 +1030,8 @@ var CRList = class {
924
1030
  * @param thisArg - Optional `this` value for the predicate.
925
1031
  */
926
1032
  find(predicate, thisArg) {
927
- let linkedListEntry = _nullishCoalesce(_optionalChain([this, 'access', _80 => _80.state, 'access', _81 => _81.index, 'optionalAccess', _82 => _82.get, 'call', _83 => _83(0)]), () => ( this.state.cursor));
928
- while (_optionalChain([linkedListEntry, 'optionalAccess', _84 => _84.prev])) linkedListEntry = linkedListEntry.prev;
1033
+ let linkedListEntry = _nullishCoalesce(_optionalChain([this, 'access', _96 => _96.state, 'access', _97 => _97.index, 'optionalAccess', _98 => _98.get, 'call', _99 => _99(0)]), () => ( this.state.cursor));
1034
+ while (_optionalChain([linkedListEntry, 'optionalAccess', _100 => _100.prev])) linkedListEntry = linkedListEntry.prev;
929
1035
  let index = 0;
930
1036
  while (linkedListEntry) {
931
1037
  if (predicate.call(thisArg, linkedListEntry.value, index, this))
@@ -1035,8 +1141,8 @@ var CRList = class {
1035
1141
  * Iterates over current live values in index order.
1036
1142
  */
1037
1143
  *[Symbol.iterator]() {
1038
- let linkedListEntry = _nullishCoalesce(_optionalChain([this, 'access', _85 => _85.state, 'access', _86 => _86.index, 'optionalAccess', _87 => _87.get, 'call', _88 => _88(0)]), () => ( this.state.cursor));
1039
- while (_optionalChain([linkedListEntry, 'optionalAccess', _89 => _89.prev])) linkedListEntry = linkedListEntry.prev;
1144
+ let linkedListEntry = _nullishCoalesce(_optionalChain([this, 'access', _101 => _101.state, 'access', _102 => _102.index, 'optionalAccess', _103 => _103.get, 'call', _104 => _104(0)]), () => ( this.state.cursor));
1145
+ while (_optionalChain([linkedListEntry, 'optionalAccess', _105 => _105.prev])) linkedListEntry = linkedListEntry.prev;
1040
1146
  while (linkedListEntry) {
1041
1147
  yield linkedListEntry.value;
1042
1148
  linkedListEntry = linkedListEntry.next;
@@ -1052,8 +1158,8 @@ var CRList = class {
1052
1158
  * @param thisArg - Optional `this` value for the callback.
1053
1159
  */
1054
1160
  forEach(callback, thisArg) {
1055
- let linkedListEntry = _nullishCoalesce(_optionalChain([this, 'access', _90 => _90.state, 'access', _91 => _91.index, 'optionalAccess', _92 => _92.get, 'call', _93 => _93(0)]), () => ( this.state.cursor));
1056
- while (_optionalChain([linkedListEntry, 'optionalAccess', _94 => _94.prev])) linkedListEntry = linkedListEntry.prev;
1161
+ let linkedListEntry = _nullishCoalesce(_optionalChain([this, 'access', _106 => _106.state, 'access', _107 => _107.index, 'optionalAccess', _108 => _108.get, 'call', _109 => _109(0)]), () => ( this.state.cursor));
1162
+ while (_optionalChain([linkedListEntry, 'optionalAccess', _110 => _110.prev])) linkedListEntry = linkedListEntry.prev;
1057
1163
  let index = 0;
1058
1164
  while (linkedListEntry) {
1059
1165
  void callback.call(thisArg, linkedListEntry.value, index, this);