microboard-temp 0.5.151 → 0.5.152

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.
@@ -20853,8 +20853,14 @@ class SpatialIndex {
20853
20853
  }
20854
20854
  change = (item) => {
20855
20855
  this.itemsIndex.change(item);
20856
- this.Mbr = new Mbr;
20857
- this.itemsArray.forEach((i) => this.Mbr.combine([i.getMbrWithChildren()]));
20856
+ if (this.itemsArray.length === 0) {
20857
+ this.Mbr = new Mbr;
20858
+ } else {
20859
+ this.Mbr = this.itemsArray[0].getMbrWithChildren().copy();
20860
+ for (let i = 1;i < this.itemsArray.length; i++) {
20861
+ this.Mbr.combine([this.itemsArray[i].getMbrWithChildren()]);
20862
+ }
20863
+ }
20858
20864
  this.subject.publish(this.items);
20859
20865
  };
20860
20866
  remove(item) {
@@ -20867,8 +20873,14 @@ class SpatialIndex {
20867
20873
  }
20868
20874
  this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
20869
20875
  this.itemsIndex.remove(item);
20870
- this.Mbr = new Mbr;
20871
- this.itemsArray.forEach((item2) => this.Mbr.combine([item2.getMbrWithChildren()]));
20876
+ if (this.itemsArray.length === 0) {
20877
+ this.Mbr = new Mbr;
20878
+ } else {
20879
+ this.Mbr = this.itemsArray[0].getMbrWithChildren().copy();
20880
+ for (let i = 1;i < this.itemsArray.length; i++) {
20881
+ this.Mbr.combine([this.itemsArray[i].getMbrWithChildren()]);
20882
+ }
20883
+ }
20872
20884
  this.subject.publish(this.items);
20873
20885
  }
20874
20886
  copy() {
@@ -21177,6 +21189,22 @@ class Items {
21177
21189
  getMbr() {
21178
21190
  return this.index.getMbr();
21179
21191
  }
21192
+ getFilteredMbr() {
21193
+ const MAX_ITEM_SIZE = 1e6;
21194
+ const items = this.listAll();
21195
+ let mbr = null;
21196
+ for (const item of items) {
21197
+ const itemMbr = item.getMbr();
21198
+ if (itemMbr.getWidth() < MAX_ITEM_SIZE && itemMbr.getHeight() < MAX_ITEM_SIZE) {
21199
+ if (mbr === null) {
21200
+ mbr = itemMbr.copy();
21201
+ } else {
21202
+ mbr.combine([itemMbr]);
21203
+ }
21204
+ }
21205
+ }
21206
+ return mbr ?? this.getMbr();
21207
+ }
21180
21208
  getInView() {
21181
21209
  const { left, top, right, bottom } = this.view.getMbr();
21182
21210
  return this.index.getRectsEnclosedOrCrossed(left, top, right, bottom);
@@ -57082,7 +57110,7 @@ function onBoardLoad(board) {
57082
57110
  const hasItemsInBoard = board.items.listAll().length !== 0;
57083
57111
  const isItemsOutOfView = board.items.getItemsInView().length === 0 || !cameraSnapshot;
57084
57112
  if (isItemsOutOfView && hasItemsInBoard) {
57085
- board.camera.zoomToFit(board.items.getMbr());
57113
+ board.camera.zoomToFit(board.items.getFilteredMbr());
57086
57114
  }
57087
57115
  if (!hasItemsInBoard) {
57088
57116
  board.camera.zoomToViewCenter(1);
package/dist/cjs/index.js CHANGED
@@ -20853,8 +20853,14 @@ class SpatialIndex {
20853
20853
  }
20854
20854
  change = (item) => {
20855
20855
  this.itemsIndex.change(item);
20856
- this.Mbr = new Mbr;
20857
- this.itemsArray.forEach((i) => this.Mbr.combine([i.getMbrWithChildren()]));
20856
+ if (this.itemsArray.length === 0) {
20857
+ this.Mbr = new Mbr;
20858
+ } else {
20859
+ this.Mbr = this.itemsArray[0].getMbrWithChildren().copy();
20860
+ for (let i = 1;i < this.itemsArray.length; i++) {
20861
+ this.Mbr.combine([this.itemsArray[i].getMbrWithChildren()]);
20862
+ }
20863
+ }
20858
20864
  this.subject.publish(this.items);
20859
20865
  };
20860
20866
  remove(item) {
@@ -20867,8 +20873,14 @@ class SpatialIndex {
20867
20873
  }
20868
20874
  this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
20869
20875
  this.itemsIndex.remove(item);
20870
- this.Mbr = new Mbr;
20871
- this.itemsArray.forEach((item2) => this.Mbr.combine([item2.getMbrWithChildren()]));
20876
+ if (this.itemsArray.length === 0) {
20877
+ this.Mbr = new Mbr;
20878
+ } else {
20879
+ this.Mbr = this.itemsArray[0].getMbrWithChildren().copy();
20880
+ for (let i = 1;i < this.itemsArray.length; i++) {
20881
+ this.Mbr.combine([this.itemsArray[i].getMbrWithChildren()]);
20882
+ }
20883
+ }
20872
20884
  this.subject.publish(this.items);
20873
20885
  }
20874
20886
  copy() {
@@ -21177,6 +21189,22 @@ class Items {
21177
21189
  getMbr() {
21178
21190
  return this.index.getMbr();
21179
21191
  }
21192
+ getFilteredMbr() {
21193
+ const MAX_ITEM_SIZE = 1e6;
21194
+ const items = this.listAll();
21195
+ let mbr = null;
21196
+ for (const item of items) {
21197
+ const itemMbr = item.getMbr();
21198
+ if (itemMbr.getWidth() < MAX_ITEM_SIZE && itemMbr.getHeight() < MAX_ITEM_SIZE) {
21199
+ if (mbr === null) {
21200
+ mbr = itemMbr.copy();
21201
+ } else {
21202
+ mbr.combine([itemMbr]);
21203
+ }
21204
+ }
21205
+ }
21206
+ return mbr ?? this.getMbr();
21207
+ }
21180
21208
  getInView() {
21181
21209
  const { left, top, right, bottom } = this.view.getMbr();
21182
21210
  return this.index.getRectsEnclosedOrCrossed(left, top, right, bottom);
@@ -57082,7 +57110,7 @@ function onBoardLoad(board) {
57082
57110
  const hasItemsInBoard = board.items.listAll().length !== 0;
57083
57111
  const isItemsOutOfView = board.items.getItemsInView().length === 0 || !cameraSnapshot;
57084
57112
  if (isItemsOutOfView && hasItemsInBoard) {
57085
- board.camera.zoomToFit(board.items.getMbr());
57113
+ board.camera.zoomToFit(board.items.getFilteredMbr());
57086
57114
  }
57087
57115
  if (!hasItemsInBoard) {
57088
57116
  board.camera.zoomToViewCenter(1);
package/dist/cjs/node.js CHANGED
@@ -23325,8 +23325,14 @@ class SpatialIndex {
23325
23325
  }
23326
23326
  change = (item) => {
23327
23327
  this.itemsIndex.change(item);
23328
- this.Mbr = new Mbr;
23329
- this.itemsArray.forEach((i) => this.Mbr.combine([i.getMbrWithChildren()]));
23328
+ if (this.itemsArray.length === 0) {
23329
+ this.Mbr = new Mbr;
23330
+ } else {
23331
+ this.Mbr = this.itemsArray[0].getMbrWithChildren().copy();
23332
+ for (let i = 1;i < this.itemsArray.length; i++) {
23333
+ this.Mbr.combine([this.itemsArray[i].getMbrWithChildren()]);
23334
+ }
23335
+ }
23330
23336
  this.subject.publish(this.items);
23331
23337
  };
23332
23338
  remove(item) {
@@ -23339,8 +23345,14 @@ class SpatialIndex {
23339
23345
  }
23340
23346
  this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
23341
23347
  this.itemsIndex.remove(item);
23342
- this.Mbr = new Mbr;
23343
- this.itemsArray.forEach((item2) => this.Mbr.combine([item2.getMbrWithChildren()]));
23348
+ if (this.itemsArray.length === 0) {
23349
+ this.Mbr = new Mbr;
23350
+ } else {
23351
+ this.Mbr = this.itemsArray[0].getMbrWithChildren().copy();
23352
+ for (let i = 1;i < this.itemsArray.length; i++) {
23353
+ this.Mbr.combine([this.itemsArray[i].getMbrWithChildren()]);
23354
+ }
23355
+ }
23344
23356
  this.subject.publish(this.items);
23345
23357
  }
23346
23358
  copy() {
@@ -23649,6 +23661,22 @@ class Items {
23649
23661
  getMbr() {
23650
23662
  return this.index.getMbr();
23651
23663
  }
23664
+ getFilteredMbr() {
23665
+ const MAX_ITEM_SIZE = 1e6;
23666
+ const items = this.listAll();
23667
+ let mbr = null;
23668
+ for (const item of items) {
23669
+ const itemMbr = item.getMbr();
23670
+ if (itemMbr.getWidth() < MAX_ITEM_SIZE && itemMbr.getHeight() < MAX_ITEM_SIZE) {
23671
+ if (mbr === null) {
23672
+ mbr = itemMbr.copy();
23673
+ } else {
23674
+ mbr.combine([itemMbr]);
23675
+ }
23676
+ }
23677
+ }
23678
+ return mbr ?? this.getMbr();
23679
+ }
23652
23680
  getInView() {
23653
23681
  const { left, top, right, bottom } = this.view.getMbr();
23654
23682
  return this.index.getRectsEnclosedOrCrossed(left, top, right, bottom);
@@ -59555,7 +59583,7 @@ function onBoardLoad(board) {
59555
59583
  const hasItemsInBoard = board.items.listAll().length !== 0;
59556
59584
  const isItemsOutOfView = board.items.getItemsInView().length === 0 || !cameraSnapshot;
59557
59585
  if (isItemsOutOfView && hasItemsInBoard) {
59558
- board.camera.zoomToFit(board.items.getMbr());
59586
+ board.camera.zoomToFit(board.items.getFilteredMbr());
59559
59587
  }
59560
59588
  if (!hasItemsInBoard) {
59561
59589
  board.camera.zoomToViewCenter(1);
@@ -20696,8 +20696,14 @@ class SpatialIndex {
20696
20696
  }
20697
20697
  change = (item) => {
20698
20698
  this.itemsIndex.change(item);
20699
- this.Mbr = new Mbr;
20700
- this.itemsArray.forEach((i) => this.Mbr.combine([i.getMbrWithChildren()]));
20699
+ if (this.itemsArray.length === 0) {
20700
+ this.Mbr = new Mbr;
20701
+ } else {
20702
+ this.Mbr = this.itemsArray[0].getMbrWithChildren().copy();
20703
+ for (let i = 1;i < this.itemsArray.length; i++) {
20704
+ this.Mbr.combine([this.itemsArray[i].getMbrWithChildren()]);
20705
+ }
20706
+ }
20701
20707
  this.subject.publish(this.items);
20702
20708
  };
20703
20709
  remove(item) {
@@ -20710,8 +20716,14 @@ class SpatialIndex {
20710
20716
  }
20711
20717
  this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
20712
20718
  this.itemsIndex.remove(item);
20713
- this.Mbr = new Mbr;
20714
- this.itemsArray.forEach((item2) => this.Mbr.combine([item2.getMbrWithChildren()]));
20719
+ if (this.itemsArray.length === 0) {
20720
+ this.Mbr = new Mbr;
20721
+ } else {
20722
+ this.Mbr = this.itemsArray[0].getMbrWithChildren().copy();
20723
+ for (let i = 1;i < this.itemsArray.length; i++) {
20724
+ this.Mbr.combine([this.itemsArray[i].getMbrWithChildren()]);
20725
+ }
20726
+ }
20715
20727
  this.subject.publish(this.items);
20716
20728
  }
20717
20729
  copy() {
@@ -21020,6 +21032,22 @@ class Items {
21020
21032
  getMbr() {
21021
21033
  return this.index.getMbr();
21022
21034
  }
21035
+ getFilteredMbr() {
21036
+ const MAX_ITEM_SIZE = 1e6;
21037
+ const items = this.listAll();
21038
+ let mbr = null;
21039
+ for (const item of items) {
21040
+ const itemMbr = item.getMbr();
21041
+ if (itemMbr.getWidth() < MAX_ITEM_SIZE && itemMbr.getHeight() < MAX_ITEM_SIZE) {
21042
+ if (mbr === null) {
21043
+ mbr = itemMbr.copy();
21044
+ } else {
21045
+ mbr.combine([itemMbr]);
21046
+ }
21047
+ }
21048
+ }
21049
+ return mbr ?? this.getMbr();
21050
+ }
21023
21051
  getInView() {
21024
21052
  const { left, top, right, bottom } = this.view.getMbr();
21025
21053
  return this.index.getRectsEnclosedOrCrossed(left, top, right, bottom);
@@ -56925,7 +56953,7 @@ function onBoardLoad(board) {
56925
56953
  const hasItemsInBoard = board.items.listAll().length !== 0;
56926
56954
  const isItemsOutOfView = board.items.getItemsInView().length === 0 || !cameraSnapshot;
56927
56955
  if (isItemsOutOfView && hasItemsInBoard) {
56928
- board.camera.zoomToFit(board.items.getMbr());
56956
+ board.camera.zoomToFit(board.items.getFilteredMbr());
56929
56957
  }
56930
56958
  if (!hasItemsInBoard) {
56931
56959
  board.camera.zoomToViewCenter(1);
package/dist/esm/index.js CHANGED
@@ -20689,8 +20689,14 @@ class SpatialIndex {
20689
20689
  }
20690
20690
  change = (item) => {
20691
20691
  this.itemsIndex.change(item);
20692
- this.Mbr = new Mbr;
20693
- this.itemsArray.forEach((i) => this.Mbr.combine([i.getMbrWithChildren()]));
20692
+ if (this.itemsArray.length === 0) {
20693
+ this.Mbr = new Mbr;
20694
+ } else {
20695
+ this.Mbr = this.itemsArray[0].getMbrWithChildren().copy();
20696
+ for (let i = 1;i < this.itemsArray.length; i++) {
20697
+ this.Mbr.combine([this.itemsArray[i].getMbrWithChildren()]);
20698
+ }
20699
+ }
20694
20700
  this.subject.publish(this.items);
20695
20701
  };
20696
20702
  remove(item) {
@@ -20703,8 +20709,14 @@ class SpatialIndex {
20703
20709
  }
20704
20710
  this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
20705
20711
  this.itemsIndex.remove(item);
20706
- this.Mbr = new Mbr;
20707
- this.itemsArray.forEach((item2) => this.Mbr.combine([item2.getMbrWithChildren()]));
20712
+ if (this.itemsArray.length === 0) {
20713
+ this.Mbr = new Mbr;
20714
+ } else {
20715
+ this.Mbr = this.itemsArray[0].getMbrWithChildren().copy();
20716
+ for (let i = 1;i < this.itemsArray.length; i++) {
20717
+ this.Mbr.combine([this.itemsArray[i].getMbrWithChildren()]);
20718
+ }
20719
+ }
20708
20720
  this.subject.publish(this.items);
20709
20721
  }
20710
20722
  copy() {
@@ -21013,6 +21025,22 @@ class Items {
21013
21025
  getMbr() {
21014
21026
  return this.index.getMbr();
21015
21027
  }
21028
+ getFilteredMbr() {
21029
+ const MAX_ITEM_SIZE = 1e6;
21030
+ const items = this.listAll();
21031
+ let mbr = null;
21032
+ for (const item of items) {
21033
+ const itemMbr = item.getMbr();
21034
+ if (itemMbr.getWidth() < MAX_ITEM_SIZE && itemMbr.getHeight() < MAX_ITEM_SIZE) {
21035
+ if (mbr === null) {
21036
+ mbr = itemMbr.copy();
21037
+ } else {
21038
+ mbr.combine([itemMbr]);
21039
+ }
21040
+ }
21041
+ }
21042
+ return mbr ?? this.getMbr();
21043
+ }
21016
21044
  getInView() {
21017
21045
  const { left, top, right, bottom } = this.view.getMbr();
21018
21046
  return this.index.getRectsEnclosedOrCrossed(left, top, right, bottom);
@@ -56918,7 +56946,7 @@ function onBoardLoad(board) {
56918
56946
  const hasItemsInBoard = board.items.listAll().length !== 0;
56919
56947
  const isItemsOutOfView = board.items.getItemsInView().length === 0 || !cameraSnapshot;
56920
56948
  if (isItemsOutOfView && hasItemsInBoard) {
56921
- board.camera.zoomToFit(board.items.getMbr());
56949
+ board.camera.zoomToFit(board.items.getFilteredMbr());
56922
56950
  }
56923
56951
  if (!hasItemsInBoard) {
56924
56952
  board.camera.zoomToViewCenter(1);
package/dist/esm/node.js CHANGED
@@ -23156,8 +23156,14 @@ class SpatialIndex {
23156
23156
  }
23157
23157
  change = (item) => {
23158
23158
  this.itemsIndex.change(item);
23159
- this.Mbr = new Mbr;
23160
- this.itemsArray.forEach((i) => this.Mbr.combine([i.getMbrWithChildren()]));
23159
+ if (this.itemsArray.length === 0) {
23160
+ this.Mbr = new Mbr;
23161
+ } else {
23162
+ this.Mbr = this.itemsArray[0].getMbrWithChildren().copy();
23163
+ for (let i = 1;i < this.itemsArray.length; i++) {
23164
+ this.Mbr.combine([this.itemsArray[i].getMbrWithChildren()]);
23165
+ }
23166
+ }
23161
23167
  this.subject.publish(this.items);
23162
23168
  };
23163
23169
  remove(item) {
@@ -23170,8 +23176,14 @@ class SpatialIndex {
23170
23176
  }
23171
23177
  this.itemsArray.splice(this.itemsArray.indexOf(item), 1);
23172
23178
  this.itemsIndex.remove(item);
23173
- this.Mbr = new Mbr;
23174
- this.itemsArray.forEach((item2) => this.Mbr.combine([item2.getMbrWithChildren()]));
23179
+ if (this.itemsArray.length === 0) {
23180
+ this.Mbr = new Mbr;
23181
+ } else {
23182
+ this.Mbr = this.itemsArray[0].getMbrWithChildren().copy();
23183
+ for (let i = 1;i < this.itemsArray.length; i++) {
23184
+ this.Mbr.combine([this.itemsArray[i].getMbrWithChildren()]);
23185
+ }
23186
+ }
23175
23187
  this.subject.publish(this.items);
23176
23188
  }
23177
23189
  copy() {
@@ -23480,6 +23492,22 @@ class Items {
23480
23492
  getMbr() {
23481
23493
  return this.index.getMbr();
23482
23494
  }
23495
+ getFilteredMbr() {
23496
+ const MAX_ITEM_SIZE = 1e6;
23497
+ const items = this.listAll();
23498
+ let mbr = null;
23499
+ for (const item of items) {
23500
+ const itemMbr = item.getMbr();
23501
+ if (itemMbr.getWidth() < MAX_ITEM_SIZE && itemMbr.getHeight() < MAX_ITEM_SIZE) {
23502
+ if (mbr === null) {
23503
+ mbr = itemMbr.copy();
23504
+ } else {
23505
+ mbr.combine([itemMbr]);
23506
+ }
23507
+ }
23508
+ }
23509
+ return mbr ?? this.getMbr();
23510
+ }
23483
23511
  getInView() {
23484
23512
  const { left, top, right, bottom } = this.view.getMbr();
23485
23513
  return this.index.getRectsEnclosedOrCrossed(left, top, right, bottom);
@@ -59386,7 +59414,7 @@ function onBoardLoad(board) {
59386
59414
  const hasItemsInBoard = board.items.listAll().length !== 0;
59387
59415
  const isItemsOutOfView = board.items.getItemsInView().length === 0 || !cameraSnapshot;
59388
59416
  if (isItemsOutOfView && hasItemsInBoard) {
59389
- board.camera.zoomToFit(board.items.getMbr());
59417
+ board.camera.zoomToFit(board.items.getFilteredMbr());
59390
59418
  }
59391
59419
  if (!hasItemsInBoard) {
59392
59420
  board.camera.zoomToViewCenter(1);
@@ -62,6 +62,7 @@ export declare class Items {
62
62
  getGroupItemsEnclosedOrCrossed(left: number, top: number, right: number, bottom: number): BaseItem[];
63
63
  getUnderPoint(point: Point, tolerance?: number): Item[];
64
64
  getMbr(): Mbr;
65
+ getFilteredMbr(): Mbr;
65
66
  getInView(): Item[];
66
67
  getItemsInView(): Item[];
67
68
  getGroupItemsInView(): BaseItem[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microboard-temp",
3
- "version": "0.5.151",
3
+ "version": "0.5.152",
4
4
  "description": "A flexible interactive whiteboard library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",