bobe 0.0.27 → 0.0.28

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/bobe.cjs.js CHANGED
@@ -196,6 +196,8 @@ function macInc(arr) {
196
196
  return candyLast;
197
197
  }
198
198
 
199
+ const KEY_INDEX = '__BOBE_KEY_INDEX';
200
+
199
201
  const _excluded = ["dentStack", "isFirstToken"];
200
202
  class Interpreter {
201
203
  constructor(tokenizer) {
@@ -540,9 +542,9 @@ class Interpreter {
540
542
  }
541
543
  if (s > e1) {
542
544
  if (s <= e2) {
543
- const lastAfter = children.at(-1)?.realAfter || forNode.realBefore;
545
+ const firstBefore = s > 0 ? children.at(-1)?.realAfter || forNode.realBefore : forNode.realBefore;
544
546
  for (let i = e2; i >= s; i--) {
545
- this.insertForItem(forNode, i, data, newChildren, lastAfter, snapshotForUpdate);
547
+ this.insertForItem(forNode, i, data, newChildren, firstBefore, snapshotForUpdate);
546
548
  }
547
549
  }
548
550
  } else if (s > e2) {
@@ -665,6 +667,9 @@ class Interpreter {
665
667
  if (indexName) {
666
668
  child.data[indexName] = i;
667
669
  }
670
+ } else {
671
+ indexName = indexName || KEY_INDEX;
672
+ child.data[indexName] = i;
668
673
  }
669
674
  }
670
675
  forItemId = 0;
@@ -694,9 +699,10 @@ class Interpreter {
694
699
  getItemData(forNode, i, parentData) {
695
700
  const arr = forNode.arr,
696
701
  itemExp = forNode.itemExp,
697
- indexName = forNode.indexName,
698
702
  vars = forNode.vars,
699
- arrSignal = forNode.arrSignal;
703
+ arrSignal = forNode.arrSignal,
704
+ getKey = forNode.getKey;
705
+ let indexName = forNode.indexName;
700
706
  let data;
701
707
  if (typeof itemExp === 'string') {
702
708
  data = aoye.deepSignal(indexName ? {
@@ -706,13 +712,16 @@ class Interpreter {
706
712
  [itemExp]: arr[i]
707
713
  }, aoye.getPulling());
708
714
  } else {
709
- data = aoye.deepSignal(indexName ? {
715
+ indexName = indexName ?? KEY_INDEX;
716
+ const rawData = {
710
717
  [indexName]: i
711
- } : {}, aoye.getPulling());
712
- const computedData = new aoye.Computed(() => itemExp(arrSignal.get()[i]));
718
+ };
719
+ data = aoye.deepSignal(rawData, aoye.getPulling());
720
+ const computedData = new aoye.Computed(() => itemExp(arrSignal.get()[getKey ? data[indexName] : i]));
713
721
  const cells = data[aoye.Keys.Meta].cells;
714
722
  for (let i = 0; i < vars.length; i++) {
715
723
  const name = vars[i];
724
+ rawData[name] = undefined;
716
725
  cells.set(name, new aoye.Computed(() => computedData.get()[name]));
717
726
  }
718
727
  }