mol_dump_lib 0.0.660 → 0.0.662

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/node.js CHANGED
@@ -3250,15 +3250,22 @@ var $;
3250
3250
  if (path.length === 0 && check(this))
3251
3251
  return yield [this];
3252
3252
  try {
3253
- for (const item of this.sub()) {
3254
- if (item instanceof $mol_view && check(item)) {
3255
- return yield [...path, this, item];
3256
- }
3253
+ const checked = new Set();
3254
+ const sub = this.sub();
3255
+ for (const item of sub) {
3256
+ if (!(item instanceof $mol_view))
3257
+ continue;
3258
+ if (!check(item))
3259
+ continue;
3260
+ checked.add(item);
3261
+ yield [...path, this, item];
3257
3262
  }
3258
- for (const item of this.sub()) {
3259
- if (item instanceof $mol_view) {
3260
- yield* item.view_find(check, [...path, this]);
3261
- }
3263
+ for (const item of sub) {
3264
+ if (!(item instanceof $mol_view))
3265
+ continue;
3266
+ if (checked.has(item))
3267
+ continue;
3268
+ yield* item.view_find(check, [...path, this]);
3262
3269
  }
3263
3270
  }
3264
3271
  catch (error) {
@@ -4484,6 +4491,12 @@ var $;
4484
4491
  (obj.style) = () => ({"paddingTop": (this.gap_after())});
4485
4492
  return obj;
4486
4493
  }
4494
+ item_height_min(id){
4495
+ return 1;
4496
+ }
4497
+ item_width_min(id){
4498
+ return 1;
4499
+ }
4487
4500
  view_window(){
4488
4501
  return [0, 0];
4489
4502
  }
@@ -4614,7 +4627,7 @@ var $;
4614
4627
  min = 0;
4615
4628
  top = Math.ceil(rect?.top ?? 0);
4616
4629
  while (min < (kids.length - 1)) {
4617
- const height = kids[min]?.minimal_height() ?? 0;
4630
+ const height = this.item_height_min(min);
4618
4631
  if (top + height >= limit_top)
4619
4632
  break;
4620
4633
  top += height;
@@ -4636,21 +4649,46 @@ var $;
4636
4649
  }
4637
4650
  while (anchoring && ((top2 > limit_top) && (min2 > 0))) {
4638
4651
  --min2;
4639
- top2 -= kids[min2]?.minimal_height() ?? 0;
4652
+ top2 -= this.item_height_min(min2);
4640
4653
  }
4641
4654
  while (bottom2 < limit_bottom && max2 < kids.length) {
4642
- bottom2 += kids[max2]?.minimal_height() ?? 0;
4655
+ bottom2 += this.item_height_min(max2);
4643
4656
  ++max2;
4644
4657
  }
4645
4658
  return [min2, max2];
4646
4659
  }
4660
+ item_height_min(index) {
4661
+ try {
4662
+ return this.sub()[index]?.minimal_height() ?? 0;
4663
+ }
4664
+ catch (error) {
4665
+ $mol_fail_log(error);
4666
+ return 0;
4667
+ }
4668
+ }
4669
+ row_width_min(index) {
4670
+ try {
4671
+ return this.sub()[index]?.minimal_width() ?? 0;
4672
+ }
4673
+ catch (error) {
4674
+ $mol_fail_log(error);
4675
+ return 0;
4676
+ }
4677
+ }
4647
4678
  gap_before() {
4648
- const skipped = this.sub().slice(0, this.view_window()[0]);
4649
- return Math.max(0, skipped.reduce((sum, view) => sum + (view?.minimal_height() ?? 0), 0));
4679
+ let gap = 0;
4680
+ const skipped = this.view_window()[0];
4681
+ for (let i = 0; i < skipped; ++i)
4682
+ gap += this.item_height_min(i);
4683
+ return gap;
4650
4684
  }
4651
4685
  gap_after() {
4652
- const skipped = this.sub().slice(this.view_window()[1]);
4653
- return Math.max(0, skipped.reduce((sum, view) => sum + (view?.minimal_height() ?? 0), 0));
4686
+ let gap = 0;
4687
+ const from = this.view_window()[1];
4688
+ const to = this.sub().length;
4689
+ for (let i = from; i < to; ++i)
4690
+ gap += this.item_height_min(i);
4691
+ return gap;
4654
4692
  }
4655
4693
  sub_visible() {
4656
4694
  return [
@@ -4660,15 +4698,18 @@ var $;
4660
4698
  ];
4661
4699
  }
4662
4700
  minimal_height() {
4663
- return this.sub().reduce((sum, view) => {
4664
- try {
4665
- return sum + (view?.minimal_height() ?? 0);
4666
- }
4667
- catch (error) {
4668
- $mol_fail_log(error);
4669
- return sum;
4670
- }
4671
- }, 0);
4701
+ let height = 0;
4702
+ const len = this.sub().length;
4703
+ for (let i = 0; i < len; ++i)
4704
+ height += this.item_height_min(i);
4705
+ return height;
4706
+ }
4707
+ minimal_width() {
4708
+ let width = 0;
4709
+ const len = this.sub().length;
4710
+ for (let i = 0; i < len; ++i)
4711
+ width = Math.max(width, this.item_width_min(i));
4712
+ return width;
4672
4713
  }
4673
4714
  force_render(path) {
4674
4715
  const kids = this.rows();
@@ -4700,6 +4741,9 @@ var $;
4700
4741
  __decorate([
4701
4742
  $mol_mem
4702
4743
  ], $mol_list.prototype, "minimal_height", null);
4744
+ __decorate([
4745
+ $mol_mem
4746
+ ], $mol_list.prototype, "minimal_width", null);
4703
4747
  $$.$mol_list = $mol_list;
4704
4748
  })($$ = $.$$ || ($.$$ = {}));
4705
4749
  })($ || ($ = {}));