bobe 0.0.27 → 0.0.29

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) {
@@ -223,6 +225,7 @@ class Interpreter {
223
225
  prev: null
224
226
  }, (ctxProvider.__logicType & LogicalBit ? NodeSort.Logic : 0) | NodeSort.CtxProvider);
225
227
  }
228
+ const rootLen = stack.length;
226
229
  const ctx = this.ctx = {
227
230
  realParent: root,
228
231
  prevSibling: before,
@@ -262,7 +265,7 @@ class Interpreter {
262
265
  continue;
263
266
  }
264
267
  if (ctx.current) {
265
- if (stack.length === 2 && !ctx.prevSibling) {
268
+ if (stack.length === rootLen && !ctx.prevSibling) {
266
269
  ctx.prevSibling = before;
267
270
  }
268
271
  this.handleInsert(ctx.realParent, ctx.current, ctx.prevSibling);
@@ -540,9 +543,9 @@ class Interpreter {
540
543
  }
541
544
  if (s > e1) {
542
545
  if (s <= e2) {
543
- const lastAfter = children.at(-1)?.realAfter || forNode.realBefore;
546
+ const firstBefore = s > 0 ? children.at(-1)?.realAfter || forNode.realBefore : forNode.realBefore;
544
547
  for (let i = e2; i >= s; i--) {
545
- this.insertForItem(forNode, i, data, newChildren, lastAfter, snapshotForUpdate);
548
+ this.insertForItem(forNode, i, data, newChildren, firstBefore, snapshotForUpdate);
546
549
  }
547
550
  }
548
551
  } else if (s > e2) {
@@ -665,6 +668,9 @@ class Interpreter {
665
668
  if (indexName) {
666
669
  child.data[indexName] = i;
667
670
  }
671
+ } else {
672
+ indexName = indexName || KEY_INDEX;
673
+ child.data[indexName] = i;
668
674
  }
669
675
  }
670
676
  forItemId = 0;
@@ -694,9 +700,10 @@ class Interpreter {
694
700
  getItemData(forNode, i, parentData) {
695
701
  const arr = forNode.arr,
696
702
  itemExp = forNode.itemExp,
697
- indexName = forNode.indexName,
698
703
  vars = forNode.vars,
699
- arrSignal = forNode.arrSignal;
704
+ arrSignal = forNode.arrSignal,
705
+ getKey = forNode.getKey;
706
+ let indexName = forNode.indexName;
700
707
  let data;
701
708
  if (typeof itemExp === 'string') {
702
709
  data = aoye.deepSignal(indexName ? {
@@ -706,13 +713,16 @@ class Interpreter {
706
713
  [itemExp]: arr[i]
707
714
  }, aoye.getPulling());
708
715
  } else {
709
- data = aoye.deepSignal(indexName ? {
716
+ indexName = indexName ?? KEY_INDEX;
717
+ const rawData = {
710
718
  [indexName]: i
711
- } : {}, aoye.getPulling());
712
- const computedData = new aoye.Computed(() => itemExp(arrSignal.get()[i]));
719
+ };
720
+ data = aoye.deepSignal(rawData, aoye.getPulling());
721
+ const computedData = new aoye.Computed(() => itemExp(arrSignal.get()[getKey ? data[indexName] : i]));
713
722
  const cells = data[aoye.Keys.Meta].cells;
714
723
  for (let i = 0; i < vars.length; i++) {
715
724
  const name = vars[i];
725
+ rawData[name] = undefined;
716
726
  cells.set(name, new aoye.Computed(() => computedData.get()[name]));
717
727
  }
718
728
  }
@@ -722,7 +732,7 @@ class Interpreter {
722
732
  getData() {
723
733
  const _this$ctx$stack$peekB = this.ctx.stack.peekByType(NodeSort.CtxProvider),
724
734
  node = _this$ctx$stack$peekB.node;
725
- return node.data || node.owner.data;
735
+ return node.data;
726
736
  }
727
737
  onePropParsed(data, node, key, value, valueIsMapKey, isFn, hookI) {
728
738
  if (isFn) {
@@ -810,7 +820,8 @@ class Interpreter {
810
820
  preCond: preIsCond ? prevSibling : null,
811
821
  isFirstRender: true,
812
822
  effect: null,
813
- owner
823
+ owner,
824
+ data
814
825
  };
815
826
  let signal;
816
827
  switch (keyWord.value) {