microboard-temp 0.13.28 → 0.13.30

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.
@@ -37812,36 +37812,39 @@ class Connector2 extends BaseItem {
37812
37812
  const point5 = this.startPoint;
37813
37813
  if (point5.pointType !== "Board") {
37814
37814
  point5.recalculatePoint();
37815
- this.smartJumpStartEdge();
37816
- this.updatePaths();
37817
- this.subject.publish(this);
37815
+ if (!this.smartJumpStartEdge()) {
37816
+ this.updatePaths();
37817
+ this.subject.publish(this);
37818
+ }
37818
37819
  }
37819
37820
  };
37820
37821
  observerEndPointItem = () => {
37821
37822
  const point5 = this.endPoint;
37822
37823
  if (point5.pointType !== "Board") {
37823
37824
  point5.recalculatePoint();
37824
- this.smartJumpStartEdge();
37825
- this.updatePaths();
37826
- this.subject.publish(this);
37825
+ if (!this.smartJumpStartEdge()) {
37826
+ this.updatePaths();
37827
+ this.subject.publish(this);
37828
+ }
37827
37829
  }
37828
37830
  };
37829
37831
  smartJumpStartEdge() {
37830
37832
  const start = this.startPoint;
37831
37833
  if (start.pointType !== "Fixed" && start.pointType !== "Floating")
37832
- return;
37833
- const startEdge = start.getEdge();
37834
- if (!startEdge)
37835
- return;
37834
+ return false;
37836
37835
  const item = start.item;
37837
37836
  const anchors = item.getSnapAnchorPoints?.();
37838
37837
  if (!anchors || anchors.length === 0)
37839
- return;
37838
+ return false;
37839
+ const EPS = 2;
37840
+ const isOnAnchor = anchors.some((a2) => Math.abs(a2.x - start.x) < EPS && Math.abs(a2.y - start.y) < EPS);
37841
+ if (!isOnAnchor)
37842
+ return false;
37840
37843
  const center = item.getMbr().getCenter();
37841
37844
  const dx = this.endPoint.x - center.x;
37842
37845
  const dy = this.endPoint.y - center.y;
37843
37846
  if (dx === 0 && dy === 0)
37844
- return;
37847
+ return false;
37845
37848
  let best = anchors[0];
37846
37849
  let bestDot = -Infinity;
37847
37850
  for (const anchor of anchors) {
@@ -37856,11 +37859,10 @@ class Connector2 extends BaseItem {
37856
37859
  best = anchor;
37857
37860
  }
37858
37861
  }
37859
- const bestRel = toRelativePoint(best, item);
37860
- const cur = start.relativePoint;
37861
- if (Math.abs(bestRel.x - cur.x) < 0.5 && Math.abs(bestRel.y - cur.y) < 0.5)
37862
- return;
37863
- this.startPoint = new FixedPoint(item, bestRel);
37862
+ if (Math.abs(best.x - start.x) < EPS && Math.abs(best.y - start.y) < EPS)
37863
+ return false;
37864
+ this.setStartPoint(new FixedPoint(item, toRelativePoint(best, item)));
37865
+ return true;
37864
37866
  }
37865
37867
  clearObservedItems() {
37866
37868
  const startPoint = this.getStartPoint();
package/dist/cjs/index.js CHANGED
@@ -37812,36 +37812,39 @@ class Connector2 extends BaseItem {
37812
37812
  const point5 = this.startPoint;
37813
37813
  if (point5.pointType !== "Board") {
37814
37814
  point5.recalculatePoint();
37815
- this.smartJumpStartEdge();
37816
- this.updatePaths();
37817
- this.subject.publish(this);
37815
+ if (!this.smartJumpStartEdge()) {
37816
+ this.updatePaths();
37817
+ this.subject.publish(this);
37818
+ }
37818
37819
  }
37819
37820
  };
37820
37821
  observerEndPointItem = () => {
37821
37822
  const point5 = this.endPoint;
37822
37823
  if (point5.pointType !== "Board") {
37823
37824
  point5.recalculatePoint();
37824
- this.smartJumpStartEdge();
37825
- this.updatePaths();
37826
- this.subject.publish(this);
37825
+ if (!this.smartJumpStartEdge()) {
37826
+ this.updatePaths();
37827
+ this.subject.publish(this);
37828
+ }
37827
37829
  }
37828
37830
  };
37829
37831
  smartJumpStartEdge() {
37830
37832
  const start = this.startPoint;
37831
37833
  if (start.pointType !== "Fixed" && start.pointType !== "Floating")
37832
- return;
37833
- const startEdge = start.getEdge();
37834
- if (!startEdge)
37835
- return;
37834
+ return false;
37836
37835
  const item = start.item;
37837
37836
  const anchors = item.getSnapAnchorPoints?.();
37838
37837
  if (!anchors || anchors.length === 0)
37839
- return;
37838
+ return false;
37839
+ const EPS = 2;
37840
+ const isOnAnchor = anchors.some((a2) => Math.abs(a2.x - start.x) < EPS && Math.abs(a2.y - start.y) < EPS);
37841
+ if (!isOnAnchor)
37842
+ return false;
37840
37843
  const center = item.getMbr().getCenter();
37841
37844
  const dx = this.endPoint.x - center.x;
37842
37845
  const dy = this.endPoint.y - center.y;
37843
37846
  if (dx === 0 && dy === 0)
37844
- return;
37847
+ return false;
37845
37848
  let best = anchors[0];
37846
37849
  let bestDot = -Infinity;
37847
37850
  for (const anchor of anchors) {
@@ -37856,11 +37859,10 @@ class Connector2 extends BaseItem {
37856
37859
  best = anchor;
37857
37860
  }
37858
37861
  }
37859
- const bestRel = toRelativePoint(best, item);
37860
- const cur = start.relativePoint;
37861
- if (Math.abs(bestRel.x - cur.x) < 0.5 && Math.abs(bestRel.y - cur.y) < 0.5)
37862
- return;
37863
- this.startPoint = new FixedPoint(item, bestRel);
37862
+ if (Math.abs(best.x - start.x) < EPS && Math.abs(best.y - start.y) < EPS)
37863
+ return false;
37864
+ this.setStartPoint(new FixedPoint(item, toRelativePoint(best, item)));
37865
+ return true;
37864
37866
  }
37865
37867
  clearObservedItems() {
37866
37868
  const startPoint = this.getStartPoint();
package/dist/cjs/node.js CHANGED
@@ -40285,36 +40285,39 @@ class Connector2 extends BaseItem {
40285
40285
  const point5 = this.startPoint;
40286
40286
  if (point5.pointType !== "Board") {
40287
40287
  point5.recalculatePoint();
40288
- this.smartJumpStartEdge();
40289
- this.updatePaths();
40290
- this.subject.publish(this);
40288
+ if (!this.smartJumpStartEdge()) {
40289
+ this.updatePaths();
40290
+ this.subject.publish(this);
40291
+ }
40291
40292
  }
40292
40293
  };
40293
40294
  observerEndPointItem = () => {
40294
40295
  const point5 = this.endPoint;
40295
40296
  if (point5.pointType !== "Board") {
40296
40297
  point5.recalculatePoint();
40297
- this.smartJumpStartEdge();
40298
- this.updatePaths();
40299
- this.subject.publish(this);
40298
+ if (!this.smartJumpStartEdge()) {
40299
+ this.updatePaths();
40300
+ this.subject.publish(this);
40301
+ }
40300
40302
  }
40301
40303
  };
40302
40304
  smartJumpStartEdge() {
40303
40305
  const start = this.startPoint;
40304
40306
  if (start.pointType !== "Fixed" && start.pointType !== "Floating")
40305
- return;
40306
- const startEdge = start.getEdge();
40307
- if (!startEdge)
40308
- return;
40307
+ return false;
40309
40308
  const item = start.item;
40310
40309
  const anchors = item.getSnapAnchorPoints?.();
40311
40310
  if (!anchors || anchors.length === 0)
40312
- return;
40311
+ return false;
40312
+ const EPS = 2;
40313
+ const isOnAnchor = anchors.some((a2) => Math.abs(a2.x - start.x) < EPS && Math.abs(a2.y - start.y) < EPS);
40314
+ if (!isOnAnchor)
40315
+ return false;
40313
40316
  const center = item.getMbr().getCenter();
40314
40317
  const dx = this.endPoint.x - center.x;
40315
40318
  const dy = this.endPoint.y - center.y;
40316
40319
  if (dx === 0 && dy === 0)
40317
- return;
40320
+ return false;
40318
40321
  let best = anchors[0];
40319
40322
  let bestDot = -Infinity;
40320
40323
  for (const anchor of anchors) {
@@ -40329,11 +40332,10 @@ class Connector2 extends BaseItem {
40329
40332
  best = anchor;
40330
40333
  }
40331
40334
  }
40332
- const bestRel = toRelativePoint(best, item);
40333
- const cur = start.relativePoint;
40334
- if (Math.abs(bestRel.x - cur.x) < 0.5 && Math.abs(bestRel.y - cur.y) < 0.5)
40335
- return;
40336
- this.startPoint = new FixedPoint(item, bestRel);
40335
+ if (Math.abs(best.x - start.x) < EPS && Math.abs(best.y - start.y) < EPS)
40336
+ return false;
40337
+ this.setStartPoint(new FixedPoint(item, toRelativePoint(best, item)));
40338
+ return true;
40337
40339
  }
40338
40340
  clearObservedItems() {
40339
40341
  const startPoint = this.getStartPoint();
@@ -37641,36 +37641,39 @@ class Connector2 extends BaseItem {
37641
37641
  const point5 = this.startPoint;
37642
37642
  if (point5.pointType !== "Board") {
37643
37643
  point5.recalculatePoint();
37644
- this.smartJumpStartEdge();
37645
- this.updatePaths();
37646
- this.subject.publish(this);
37644
+ if (!this.smartJumpStartEdge()) {
37645
+ this.updatePaths();
37646
+ this.subject.publish(this);
37647
+ }
37647
37648
  }
37648
37649
  };
37649
37650
  observerEndPointItem = () => {
37650
37651
  const point5 = this.endPoint;
37651
37652
  if (point5.pointType !== "Board") {
37652
37653
  point5.recalculatePoint();
37653
- this.smartJumpStartEdge();
37654
- this.updatePaths();
37655
- this.subject.publish(this);
37654
+ if (!this.smartJumpStartEdge()) {
37655
+ this.updatePaths();
37656
+ this.subject.publish(this);
37657
+ }
37656
37658
  }
37657
37659
  };
37658
37660
  smartJumpStartEdge() {
37659
37661
  const start = this.startPoint;
37660
37662
  if (start.pointType !== "Fixed" && start.pointType !== "Floating")
37661
- return;
37662
- const startEdge = start.getEdge();
37663
- if (!startEdge)
37664
- return;
37663
+ return false;
37665
37664
  const item = start.item;
37666
37665
  const anchors = item.getSnapAnchorPoints?.();
37667
37666
  if (!anchors || anchors.length === 0)
37668
- return;
37667
+ return false;
37668
+ const EPS = 2;
37669
+ const isOnAnchor = anchors.some((a2) => Math.abs(a2.x - start.x) < EPS && Math.abs(a2.y - start.y) < EPS);
37670
+ if (!isOnAnchor)
37671
+ return false;
37669
37672
  const center = item.getMbr().getCenter();
37670
37673
  const dx = this.endPoint.x - center.x;
37671
37674
  const dy = this.endPoint.y - center.y;
37672
37675
  if (dx === 0 && dy === 0)
37673
- return;
37676
+ return false;
37674
37677
  let best = anchors[0];
37675
37678
  let bestDot = -Infinity;
37676
37679
  for (const anchor of anchors) {
@@ -37685,11 +37688,10 @@ class Connector2 extends BaseItem {
37685
37688
  best = anchor;
37686
37689
  }
37687
37690
  }
37688
- const bestRel = toRelativePoint(best, item);
37689
- const cur = start.relativePoint;
37690
- if (Math.abs(bestRel.x - cur.x) < 0.5 && Math.abs(bestRel.y - cur.y) < 0.5)
37691
- return;
37692
- this.startPoint = new FixedPoint(item, bestRel);
37691
+ if (Math.abs(best.x - start.x) < EPS && Math.abs(best.y - start.y) < EPS)
37692
+ return false;
37693
+ this.setStartPoint(new FixedPoint(item, toRelativePoint(best, item)));
37694
+ return true;
37693
37695
  }
37694
37696
  clearObservedItems() {
37695
37697
  const startPoint = this.getStartPoint();
package/dist/esm/index.js CHANGED
@@ -37634,36 +37634,39 @@ class Connector2 extends BaseItem {
37634
37634
  const point5 = this.startPoint;
37635
37635
  if (point5.pointType !== "Board") {
37636
37636
  point5.recalculatePoint();
37637
- this.smartJumpStartEdge();
37638
- this.updatePaths();
37639
- this.subject.publish(this);
37637
+ if (!this.smartJumpStartEdge()) {
37638
+ this.updatePaths();
37639
+ this.subject.publish(this);
37640
+ }
37640
37641
  }
37641
37642
  };
37642
37643
  observerEndPointItem = () => {
37643
37644
  const point5 = this.endPoint;
37644
37645
  if (point5.pointType !== "Board") {
37645
37646
  point5.recalculatePoint();
37646
- this.smartJumpStartEdge();
37647
- this.updatePaths();
37648
- this.subject.publish(this);
37647
+ if (!this.smartJumpStartEdge()) {
37648
+ this.updatePaths();
37649
+ this.subject.publish(this);
37650
+ }
37649
37651
  }
37650
37652
  };
37651
37653
  smartJumpStartEdge() {
37652
37654
  const start = this.startPoint;
37653
37655
  if (start.pointType !== "Fixed" && start.pointType !== "Floating")
37654
- return;
37655
- const startEdge = start.getEdge();
37656
- if (!startEdge)
37657
- return;
37656
+ return false;
37658
37657
  const item = start.item;
37659
37658
  const anchors = item.getSnapAnchorPoints?.();
37660
37659
  if (!anchors || anchors.length === 0)
37661
- return;
37660
+ return false;
37661
+ const EPS = 2;
37662
+ const isOnAnchor = anchors.some((a2) => Math.abs(a2.x - start.x) < EPS && Math.abs(a2.y - start.y) < EPS);
37663
+ if (!isOnAnchor)
37664
+ return false;
37662
37665
  const center = item.getMbr().getCenter();
37663
37666
  const dx = this.endPoint.x - center.x;
37664
37667
  const dy = this.endPoint.y - center.y;
37665
37668
  if (dx === 0 && dy === 0)
37666
- return;
37669
+ return false;
37667
37670
  let best = anchors[0];
37668
37671
  let bestDot = -Infinity;
37669
37672
  for (const anchor of anchors) {
@@ -37678,11 +37681,10 @@ class Connector2 extends BaseItem {
37678
37681
  best = anchor;
37679
37682
  }
37680
37683
  }
37681
- const bestRel = toRelativePoint(best, item);
37682
- const cur = start.relativePoint;
37683
- if (Math.abs(bestRel.x - cur.x) < 0.5 && Math.abs(bestRel.y - cur.y) < 0.5)
37684
- return;
37685
- this.startPoint = new FixedPoint(item, bestRel);
37684
+ if (Math.abs(best.x - start.x) < EPS && Math.abs(best.y - start.y) < EPS)
37685
+ return false;
37686
+ this.setStartPoint(new FixedPoint(item, toRelativePoint(best, item)));
37687
+ return true;
37686
37688
  }
37687
37689
  clearObservedItems() {
37688
37690
  const startPoint = this.getStartPoint();
package/dist/esm/node.js CHANGED
@@ -40102,36 +40102,39 @@ class Connector2 extends BaseItem {
40102
40102
  const point5 = this.startPoint;
40103
40103
  if (point5.pointType !== "Board") {
40104
40104
  point5.recalculatePoint();
40105
- this.smartJumpStartEdge();
40106
- this.updatePaths();
40107
- this.subject.publish(this);
40105
+ if (!this.smartJumpStartEdge()) {
40106
+ this.updatePaths();
40107
+ this.subject.publish(this);
40108
+ }
40108
40109
  }
40109
40110
  };
40110
40111
  observerEndPointItem = () => {
40111
40112
  const point5 = this.endPoint;
40112
40113
  if (point5.pointType !== "Board") {
40113
40114
  point5.recalculatePoint();
40114
- this.smartJumpStartEdge();
40115
- this.updatePaths();
40116
- this.subject.publish(this);
40115
+ if (!this.smartJumpStartEdge()) {
40116
+ this.updatePaths();
40117
+ this.subject.publish(this);
40118
+ }
40117
40119
  }
40118
40120
  };
40119
40121
  smartJumpStartEdge() {
40120
40122
  const start = this.startPoint;
40121
40123
  if (start.pointType !== "Fixed" && start.pointType !== "Floating")
40122
- return;
40123
- const startEdge = start.getEdge();
40124
- if (!startEdge)
40125
- return;
40124
+ return false;
40126
40125
  const item = start.item;
40127
40126
  const anchors = item.getSnapAnchorPoints?.();
40128
40127
  if (!anchors || anchors.length === 0)
40129
- return;
40128
+ return false;
40129
+ const EPS = 2;
40130
+ const isOnAnchor = anchors.some((a2) => Math.abs(a2.x - start.x) < EPS && Math.abs(a2.y - start.y) < EPS);
40131
+ if (!isOnAnchor)
40132
+ return false;
40130
40133
  const center = item.getMbr().getCenter();
40131
40134
  const dx = this.endPoint.x - center.x;
40132
40135
  const dy = this.endPoint.y - center.y;
40133
40136
  if (dx === 0 && dy === 0)
40134
- return;
40137
+ return false;
40135
40138
  let best = anchors[0];
40136
40139
  let bestDot = -Infinity;
40137
40140
  for (const anchor of anchors) {
@@ -40146,11 +40149,10 @@ class Connector2 extends BaseItem {
40146
40149
  best = anchor;
40147
40150
  }
40148
40151
  }
40149
- const bestRel = toRelativePoint(best, item);
40150
- const cur = start.relativePoint;
40151
- if (Math.abs(bestRel.x - cur.x) < 0.5 && Math.abs(bestRel.y - cur.y) < 0.5)
40152
- return;
40153
- this.startPoint = new FixedPoint(item, bestRel);
40152
+ if (Math.abs(best.x - start.x) < EPS && Math.abs(best.y - start.y) < EPS)
40153
+ return false;
40154
+ this.setStartPoint(new FixedPoint(item, toRelativePoint(best, item)));
40155
+ return true;
40154
40156
  }
40155
40157
  clearObservedItems() {
40156
40158
  const startPoint = this.getStartPoint();
@@ -60,7 +60,8 @@ export declare class Connector extends BaseItem {
60
60
  /**
61
61
  * If the start point is attached to one of the 4 edge-center anchors, re-evaluate
62
62
  * which edge best faces the current end position and jump there to avoid sharp bends.
63
- * Purely local/visual no operation is emitted.
63
+ * Emits a setStartPoint operation so the jump is persisted and synced.
64
+ * Returns true if a jump was performed (caller should skip its own updatePaths/publish).
64
65
  */
65
66
  private smartJumpStartEdge;
66
67
  clearObservedItems(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microboard-temp",
3
- "version": "0.13.28",
3
+ "version": "0.13.30",
4
4
  "description": "A flexible interactive whiteboard library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",