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.mjs 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
  })($ || ($ = {}));
package/node.test.js CHANGED
@@ -3241,15 +3241,22 @@ var $;
3241
3241
  if (path.length === 0 && check(this))
3242
3242
  return yield [this];
3243
3243
  try {
3244
- for (const item of this.sub()) {
3245
- if (item instanceof $mol_view && check(item)) {
3246
- return yield [...path, this, item];
3247
- }
3244
+ const checked = new Set();
3245
+ const sub = this.sub();
3246
+ for (const item of sub) {
3247
+ if (!(item instanceof $mol_view))
3248
+ continue;
3249
+ if (!check(item))
3250
+ continue;
3251
+ checked.add(item);
3252
+ yield [...path, this, item];
3248
3253
  }
3249
- for (const item of this.sub()) {
3250
- if (item instanceof $mol_view) {
3251
- yield* item.view_find(check, [...path, this]);
3252
- }
3254
+ for (const item of sub) {
3255
+ if (!(item instanceof $mol_view))
3256
+ continue;
3257
+ if (checked.has(item))
3258
+ continue;
3259
+ yield* item.view_find(check, [...path, this]);
3253
3260
  }
3254
3261
  }
3255
3262
  catch (error) {
@@ -4475,6 +4482,12 @@ var $;
4475
4482
  (obj.style) = () => ({"paddingTop": (this.gap_after())});
4476
4483
  return obj;
4477
4484
  }
4485
+ item_height_min(id){
4486
+ return 1;
4487
+ }
4488
+ item_width_min(id){
4489
+ return 1;
4490
+ }
4478
4491
  view_window(){
4479
4492
  return [0, 0];
4480
4493
  }
@@ -4605,7 +4618,7 @@ var $;
4605
4618
  min = 0;
4606
4619
  top = Math.ceil(rect?.top ?? 0);
4607
4620
  while (min < (kids.length - 1)) {
4608
- const height = kids[min]?.minimal_height() ?? 0;
4621
+ const height = this.item_height_min(min);
4609
4622
  if (top + height >= limit_top)
4610
4623
  break;
4611
4624
  top += height;
@@ -4627,21 +4640,46 @@ var $;
4627
4640
  }
4628
4641
  while (anchoring && ((top2 > limit_top) && (min2 > 0))) {
4629
4642
  --min2;
4630
- top2 -= kids[min2]?.minimal_height() ?? 0;
4643
+ top2 -= this.item_height_min(min2);
4631
4644
  }
4632
4645
  while (bottom2 < limit_bottom && max2 < kids.length) {
4633
- bottom2 += kids[max2]?.minimal_height() ?? 0;
4646
+ bottom2 += this.item_height_min(max2);
4634
4647
  ++max2;
4635
4648
  }
4636
4649
  return [min2, max2];
4637
4650
  }
4651
+ item_height_min(index) {
4652
+ try {
4653
+ return this.sub()[index]?.minimal_height() ?? 0;
4654
+ }
4655
+ catch (error) {
4656
+ $mol_fail_log(error);
4657
+ return 0;
4658
+ }
4659
+ }
4660
+ row_width_min(index) {
4661
+ try {
4662
+ return this.sub()[index]?.minimal_width() ?? 0;
4663
+ }
4664
+ catch (error) {
4665
+ $mol_fail_log(error);
4666
+ return 0;
4667
+ }
4668
+ }
4638
4669
  gap_before() {
4639
- const skipped = this.sub().slice(0, this.view_window()[0]);
4640
- return Math.max(0, skipped.reduce((sum, view) => sum + (view?.minimal_height() ?? 0), 0));
4670
+ let gap = 0;
4671
+ const skipped = this.view_window()[0];
4672
+ for (let i = 0; i < skipped; ++i)
4673
+ gap += this.item_height_min(i);
4674
+ return gap;
4641
4675
  }
4642
4676
  gap_after() {
4643
- const skipped = this.sub().slice(this.view_window()[1]);
4644
- return Math.max(0, skipped.reduce((sum, view) => sum + (view?.minimal_height() ?? 0), 0));
4677
+ let gap = 0;
4678
+ const from = this.view_window()[1];
4679
+ const to = this.sub().length;
4680
+ for (let i = from; i < to; ++i)
4681
+ gap += this.item_height_min(i);
4682
+ return gap;
4645
4683
  }
4646
4684
  sub_visible() {
4647
4685
  return [
@@ -4651,15 +4689,18 @@ var $;
4651
4689
  ];
4652
4690
  }
4653
4691
  minimal_height() {
4654
- return this.sub().reduce((sum, view) => {
4655
- try {
4656
- return sum + (view?.minimal_height() ?? 0);
4657
- }
4658
- catch (error) {
4659
- $mol_fail_log(error);
4660
- return sum;
4661
- }
4662
- }, 0);
4692
+ let height = 0;
4693
+ const len = this.sub().length;
4694
+ for (let i = 0; i < len; ++i)
4695
+ height += this.item_height_min(i);
4696
+ return height;
4697
+ }
4698
+ minimal_width() {
4699
+ let width = 0;
4700
+ const len = this.sub().length;
4701
+ for (let i = 0; i < len; ++i)
4702
+ width = Math.max(width, this.item_width_min(i));
4703
+ return width;
4663
4704
  }
4664
4705
  force_render(path) {
4665
4706
  const kids = this.rows();
@@ -4691,6 +4732,9 @@ var $;
4691
4732
  __decorate([
4692
4733
  $mol_mem
4693
4734
  ], $mol_list.prototype, "minimal_height", null);
4735
+ __decorate([
4736
+ $mol_mem
4737
+ ], $mol_list.prototype, "minimal_width", null);
4694
4738
  $$.$mol_list = $mol_list;
4695
4739
  })($$ = $.$$ || ($.$$ = {}));
4696
4740
  })($ || ($ = {}));