microboard-temp 0.13.22 → 0.13.24

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.
@@ -54661,10 +54661,20 @@ class ForceGraphEngine {
54661
54661
  hasActiveComponents() {
54662
54662
  return this.activeComponents.size > 0;
54663
54663
  }
54664
+ flushSync() {
54665
+ this.syncPositions();
54666
+ }
54664
54667
  wake() {
54665
- if (this.activeComponents.size > 0 && this.tickTimer === null) {
54666
- this.tickTimer = setInterval(() => this.tick(), this.TICK_MS);
54668
+ if (this.activeComponents.size === 0)
54669
+ return;
54670
+ const activeIds = this.getActiveNodeIds();
54671
+ for (const item of this.board.items.listAll()) {
54672
+ if (!activeIds.has(item.getId()))
54673
+ continue;
54674
+ const pos = item.transformation.getTranslation();
54675
+ this.lastSyncedPositions.set(item.getId(), { x: pos.x, y: pos.y });
54667
54676
  }
54677
+ this.ensureRunning();
54668
54678
  }
54669
54679
  stop() {
54670
54680
  this.stopTimers();
@@ -54750,8 +54760,17 @@ class ForceGraphEngine {
54750
54760
  tick() {
54751
54761
  const dt = this.TICK_MS / 1000;
54752
54762
  const activeIds = this.getActiveNodeIds();
54763
+ const selectedIds = new Set(this.board.selection.list().map((i) => i.getId()));
54753
54764
  const allNodes = this.getNodes();
54754
- const nodes = allNodes.filter((item) => activeIds.has(item.getId()));
54765
+ const nodes = allNodes.filter((item) => {
54766
+ if (!activeIds.has(item.getId()))
54767
+ return false;
54768
+ if (selectedIds.has(item.getId()))
54769
+ return false;
54770
+ if (item.parent !== "Board" && selectedIds.has(item.parent))
54771
+ return false;
54772
+ return true;
54773
+ });
54755
54774
  if (nodes.length < 1)
54756
54775
  return;
54757
54776
  const snapMap = new Map;
@@ -54850,14 +54869,14 @@ class ForceGraphEngine {
54850
54869
  }
54851
54870
  }
54852
54871
  if (totalEnergy < conf.FG_SLEEP_THRESHOLD && this.tickTimer !== null) {
54853
- clearInterval(this.tickTimer);
54854
- this.tickTimer = null;
54872
+ this.stopTimers();
54855
54873
  this.syncPositions();
54856
54874
  }
54857
54875
  }
54858
54876
  syncPositions() {
54859
54877
  const activeIds = this.getActiveNodeIds();
54860
- const nodes = this.getNodes().filter((item) => activeIds.has(item.getId()));
54878
+ const selectedIds = new Set(this.board.selection.list().map((i) => i.getId()));
54879
+ const nodes = this.getNodes().filter((item) => activeIds.has(item.getId()) && !selectedIds.has(item.getId()) && !(item.parent !== "Board" && selectedIds.has(item.parent)));
54861
54880
  if (nodes.length === 0)
54862
54881
  return;
54863
54882
  const movedItems = nodes.map((item) => {
@@ -55979,6 +55998,9 @@ class Board {
55979
55998
  setForceGraphGap(nodeId, gap) {
55980
55999
  this.forceGraph?.setComponentTargetGap(nodeId, gap);
55981
56000
  }
56001
+ syncForceGraph() {
56002
+ this.forceGraph?.flushSync();
56003
+ }
55982
56004
  wakeForceGraph() {
55983
56005
  this.forceGraph?.wake();
55984
56006
  }
package/dist/cjs/index.js CHANGED
@@ -54661,10 +54661,20 @@ class ForceGraphEngine {
54661
54661
  hasActiveComponents() {
54662
54662
  return this.activeComponents.size > 0;
54663
54663
  }
54664
+ flushSync() {
54665
+ this.syncPositions();
54666
+ }
54664
54667
  wake() {
54665
- if (this.activeComponents.size > 0 && this.tickTimer === null) {
54666
- this.tickTimer = setInterval(() => this.tick(), this.TICK_MS);
54668
+ if (this.activeComponents.size === 0)
54669
+ return;
54670
+ const activeIds = this.getActiveNodeIds();
54671
+ for (const item of this.board.items.listAll()) {
54672
+ if (!activeIds.has(item.getId()))
54673
+ continue;
54674
+ const pos = item.transformation.getTranslation();
54675
+ this.lastSyncedPositions.set(item.getId(), { x: pos.x, y: pos.y });
54667
54676
  }
54677
+ this.ensureRunning();
54668
54678
  }
54669
54679
  stop() {
54670
54680
  this.stopTimers();
@@ -54750,8 +54760,17 @@ class ForceGraphEngine {
54750
54760
  tick() {
54751
54761
  const dt = this.TICK_MS / 1000;
54752
54762
  const activeIds = this.getActiveNodeIds();
54763
+ const selectedIds = new Set(this.board.selection.list().map((i) => i.getId()));
54753
54764
  const allNodes = this.getNodes();
54754
- const nodes = allNodes.filter((item) => activeIds.has(item.getId()));
54765
+ const nodes = allNodes.filter((item) => {
54766
+ if (!activeIds.has(item.getId()))
54767
+ return false;
54768
+ if (selectedIds.has(item.getId()))
54769
+ return false;
54770
+ if (item.parent !== "Board" && selectedIds.has(item.parent))
54771
+ return false;
54772
+ return true;
54773
+ });
54755
54774
  if (nodes.length < 1)
54756
54775
  return;
54757
54776
  const snapMap = new Map;
@@ -54850,14 +54869,14 @@ class ForceGraphEngine {
54850
54869
  }
54851
54870
  }
54852
54871
  if (totalEnergy < conf.FG_SLEEP_THRESHOLD && this.tickTimer !== null) {
54853
- clearInterval(this.tickTimer);
54854
- this.tickTimer = null;
54872
+ this.stopTimers();
54855
54873
  this.syncPositions();
54856
54874
  }
54857
54875
  }
54858
54876
  syncPositions() {
54859
54877
  const activeIds = this.getActiveNodeIds();
54860
- const nodes = this.getNodes().filter((item) => activeIds.has(item.getId()));
54878
+ const selectedIds = new Set(this.board.selection.list().map((i) => i.getId()));
54879
+ const nodes = this.getNodes().filter((item) => activeIds.has(item.getId()) && !selectedIds.has(item.getId()) && !(item.parent !== "Board" && selectedIds.has(item.parent)));
54861
54880
  if (nodes.length === 0)
54862
54881
  return;
54863
54882
  const movedItems = nodes.map((item) => {
@@ -55979,6 +55998,9 @@ class Board {
55979
55998
  setForceGraphGap(nodeId, gap) {
55980
55999
  this.forceGraph?.setComponentTargetGap(nodeId, gap);
55981
56000
  }
56001
+ syncForceGraph() {
56002
+ this.forceGraph?.flushSync();
56003
+ }
55982
56004
  wakeForceGraph() {
55983
56005
  this.forceGraph?.wake();
55984
56006
  }
package/dist/cjs/node.js CHANGED
@@ -57134,10 +57134,20 @@ class ForceGraphEngine {
57134
57134
  hasActiveComponents() {
57135
57135
  return this.activeComponents.size > 0;
57136
57136
  }
57137
+ flushSync() {
57138
+ this.syncPositions();
57139
+ }
57137
57140
  wake() {
57138
- if (this.activeComponents.size > 0 && this.tickTimer === null) {
57139
- this.tickTimer = setInterval(() => this.tick(), this.TICK_MS);
57141
+ if (this.activeComponents.size === 0)
57142
+ return;
57143
+ const activeIds = this.getActiveNodeIds();
57144
+ for (const item of this.board.items.listAll()) {
57145
+ if (!activeIds.has(item.getId()))
57146
+ continue;
57147
+ const pos = item.transformation.getTranslation();
57148
+ this.lastSyncedPositions.set(item.getId(), { x: pos.x, y: pos.y });
57140
57149
  }
57150
+ this.ensureRunning();
57141
57151
  }
57142
57152
  stop() {
57143
57153
  this.stopTimers();
@@ -57223,8 +57233,17 @@ class ForceGraphEngine {
57223
57233
  tick() {
57224
57234
  const dt = this.TICK_MS / 1000;
57225
57235
  const activeIds = this.getActiveNodeIds();
57236
+ const selectedIds = new Set(this.board.selection.list().map((i) => i.getId()));
57226
57237
  const allNodes = this.getNodes();
57227
- const nodes = allNodes.filter((item) => activeIds.has(item.getId()));
57238
+ const nodes = allNodes.filter((item) => {
57239
+ if (!activeIds.has(item.getId()))
57240
+ return false;
57241
+ if (selectedIds.has(item.getId()))
57242
+ return false;
57243
+ if (item.parent !== "Board" && selectedIds.has(item.parent))
57244
+ return false;
57245
+ return true;
57246
+ });
57228
57247
  if (nodes.length < 1)
57229
57248
  return;
57230
57249
  const snapMap = new Map;
@@ -57323,14 +57342,14 @@ class ForceGraphEngine {
57323
57342
  }
57324
57343
  }
57325
57344
  if (totalEnergy < conf.FG_SLEEP_THRESHOLD && this.tickTimer !== null) {
57326
- clearInterval(this.tickTimer);
57327
- this.tickTimer = null;
57345
+ this.stopTimers();
57328
57346
  this.syncPositions();
57329
57347
  }
57330
57348
  }
57331
57349
  syncPositions() {
57332
57350
  const activeIds = this.getActiveNodeIds();
57333
- const nodes = this.getNodes().filter((item) => activeIds.has(item.getId()));
57351
+ const selectedIds = new Set(this.board.selection.list().map((i) => i.getId()));
57352
+ const nodes = this.getNodes().filter((item) => activeIds.has(item.getId()) && !selectedIds.has(item.getId()) && !(item.parent !== "Board" && selectedIds.has(item.parent)));
57334
57353
  if (nodes.length === 0)
57335
57354
  return;
57336
57355
  const movedItems = nodes.map((item) => {
@@ -58452,6 +58471,9 @@ class Board {
58452
58471
  setForceGraphGap(nodeId, gap) {
58453
58472
  this.forceGraph?.setComponentTargetGap(nodeId, gap);
58454
58473
  }
58474
+ syncForceGraph() {
58475
+ this.forceGraph?.flushSync();
58476
+ }
58455
58477
  wakeForceGraph() {
58456
58478
  this.forceGraph?.wake();
58457
58479
  }
@@ -54490,10 +54490,20 @@ class ForceGraphEngine {
54490
54490
  hasActiveComponents() {
54491
54491
  return this.activeComponents.size > 0;
54492
54492
  }
54493
+ flushSync() {
54494
+ this.syncPositions();
54495
+ }
54493
54496
  wake() {
54494
- if (this.activeComponents.size > 0 && this.tickTimer === null) {
54495
- this.tickTimer = setInterval(() => this.tick(), this.TICK_MS);
54497
+ if (this.activeComponents.size === 0)
54498
+ return;
54499
+ const activeIds = this.getActiveNodeIds();
54500
+ for (const item of this.board.items.listAll()) {
54501
+ if (!activeIds.has(item.getId()))
54502
+ continue;
54503
+ const pos = item.transformation.getTranslation();
54504
+ this.lastSyncedPositions.set(item.getId(), { x: pos.x, y: pos.y });
54496
54505
  }
54506
+ this.ensureRunning();
54497
54507
  }
54498
54508
  stop() {
54499
54509
  this.stopTimers();
@@ -54579,8 +54589,17 @@ class ForceGraphEngine {
54579
54589
  tick() {
54580
54590
  const dt = this.TICK_MS / 1000;
54581
54591
  const activeIds = this.getActiveNodeIds();
54592
+ const selectedIds = new Set(this.board.selection.list().map((i) => i.getId()));
54582
54593
  const allNodes = this.getNodes();
54583
- const nodes = allNodes.filter((item) => activeIds.has(item.getId()));
54594
+ const nodes = allNodes.filter((item) => {
54595
+ if (!activeIds.has(item.getId()))
54596
+ return false;
54597
+ if (selectedIds.has(item.getId()))
54598
+ return false;
54599
+ if (item.parent !== "Board" && selectedIds.has(item.parent))
54600
+ return false;
54601
+ return true;
54602
+ });
54584
54603
  if (nodes.length < 1)
54585
54604
  return;
54586
54605
  const snapMap = new Map;
@@ -54679,14 +54698,14 @@ class ForceGraphEngine {
54679
54698
  }
54680
54699
  }
54681
54700
  if (totalEnergy < conf.FG_SLEEP_THRESHOLD && this.tickTimer !== null) {
54682
- clearInterval(this.tickTimer);
54683
- this.tickTimer = null;
54701
+ this.stopTimers();
54684
54702
  this.syncPositions();
54685
54703
  }
54686
54704
  }
54687
54705
  syncPositions() {
54688
54706
  const activeIds = this.getActiveNodeIds();
54689
- const nodes = this.getNodes().filter((item) => activeIds.has(item.getId()));
54707
+ const selectedIds = new Set(this.board.selection.list().map((i) => i.getId()));
54708
+ const nodes = this.getNodes().filter((item) => activeIds.has(item.getId()) && !selectedIds.has(item.getId()) && !(item.parent !== "Board" && selectedIds.has(item.parent)));
54690
54709
  if (nodes.length === 0)
54691
54710
  return;
54692
54711
  const movedItems = nodes.map((item) => {
@@ -55808,6 +55827,9 @@ class Board {
55808
55827
  setForceGraphGap(nodeId, gap) {
55809
55828
  this.forceGraph?.setComponentTargetGap(nodeId, gap);
55810
55829
  }
55830
+ syncForceGraph() {
55831
+ this.forceGraph?.flushSync();
55832
+ }
55811
55833
  wakeForceGraph() {
55812
55834
  this.forceGraph?.wake();
55813
55835
  }
package/dist/esm/index.js CHANGED
@@ -54483,10 +54483,20 @@ class ForceGraphEngine {
54483
54483
  hasActiveComponents() {
54484
54484
  return this.activeComponents.size > 0;
54485
54485
  }
54486
+ flushSync() {
54487
+ this.syncPositions();
54488
+ }
54486
54489
  wake() {
54487
- if (this.activeComponents.size > 0 && this.tickTimer === null) {
54488
- this.tickTimer = setInterval(() => this.tick(), this.TICK_MS);
54490
+ if (this.activeComponents.size === 0)
54491
+ return;
54492
+ const activeIds = this.getActiveNodeIds();
54493
+ for (const item of this.board.items.listAll()) {
54494
+ if (!activeIds.has(item.getId()))
54495
+ continue;
54496
+ const pos = item.transformation.getTranslation();
54497
+ this.lastSyncedPositions.set(item.getId(), { x: pos.x, y: pos.y });
54489
54498
  }
54499
+ this.ensureRunning();
54490
54500
  }
54491
54501
  stop() {
54492
54502
  this.stopTimers();
@@ -54572,8 +54582,17 @@ class ForceGraphEngine {
54572
54582
  tick() {
54573
54583
  const dt = this.TICK_MS / 1000;
54574
54584
  const activeIds = this.getActiveNodeIds();
54585
+ const selectedIds = new Set(this.board.selection.list().map((i) => i.getId()));
54575
54586
  const allNodes = this.getNodes();
54576
- const nodes = allNodes.filter((item) => activeIds.has(item.getId()));
54587
+ const nodes = allNodes.filter((item) => {
54588
+ if (!activeIds.has(item.getId()))
54589
+ return false;
54590
+ if (selectedIds.has(item.getId()))
54591
+ return false;
54592
+ if (item.parent !== "Board" && selectedIds.has(item.parent))
54593
+ return false;
54594
+ return true;
54595
+ });
54577
54596
  if (nodes.length < 1)
54578
54597
  return;
54579
54598
  const snapMap = new Map;
@@ -54672,14 +54691,14 @@ class ForceGraphEngine {
54672
54691
  }
54673
54692
  }
54674
54693
  if (totalEnergy < conf.FG_SLEEP_THRESHOLD && this.tickTimer !== null) {
54675
- clearInterval(this.tickTimer);
54676
- this.tickTimer = null;
54694
+ this.stopTimers();
54677
54695
  this.syncPositions();
54678
54696
  }
54679
54697
  }
54680
54698
  syncPositions() {
54681
54699
  const activeIds = this.getActiveNodeIds();
54682
- const nodes = this.getNodes().filter((item) => activeIds.has(item.getId()));
54700
+ const selectedIds = new Set(this.board.selection.list().map((i) => i.getId()));
54701
+ const nodes = this.getNodes().filter((item) => activeIds.has(item.getId()) && !selectedIds.has(item.getId()) && !(item.parent !== "Board" && selectedIds.has(item.parent)));
54683
54702
  if (nodes.length === 0)
54684
54703
  return;
54685
54704
  const movedItems = nodes.map((item) => {
@@ -55801,6 +55820,9 @@ class Board {
55801
55820
  setForceGraphGap(nodeId, gap) {
55802
55821
  this.forceGraph?.setComponentTargetGap(nodeId, gap);
55803
55822
  }
55823
+ syncForceGraph() {
55824
+ this.forceGraph?.flushSync();
55825
+ }
55804
55826
  wakeForceGraph() {
55805
55827
  this.forceGraph?.wake();
55806
55828
  }
package/dist/esm/node.js CHANGED
@@ -56951,10 +56951,20 @@ class ForceGraphEngine {
56951
56951
  hasActiveComponents() {
56952
56952
  return this.activeComponents.size > 0;
56953
56953
  }
56954
+ flushSync() {
56955
+ this.syncPositions();
56956
+ }
56954
56957
  wake() {
56955
- if (this.activeComponents.size > 0 && this.tickTimer === null) {
56956
- this.tickTimer = setInterval(() => this.tick(), this.TICK_MS);
56958
+ if (this.activeComponents.size === 0)
56959
+ return;
56960
+ const activeIds = this.getActiveNodeIds();
56961
+ for (const item of this.board.items.listAll()) {
56962
+ if (!activeIds.has(item.getId()))
56963
+ continue;
56964
+ const pos = item.transformation.getTranslation();
56965
+ this.lastSyncedPositions.set(item.getId(), { x: pos.x, y: pos.y });
56957
56966
  }
56967
+ this.ensureRunning();
56958
56968
  }
56959
56969
  stop() {
56960
56970
  this.stopTimers();
@@ -57040,8 +57050,17 @@ class ForceGraphEngine {
57040
57050
  tick() {
57041
57051
  const dt = this.TICK_MS / 1000;
57042
57052
  const activeIds = this.getActiveNodeIds();
57053
+ const selectedIds = new Set(this.board.selection.list().map((i) => i.getId()));
57043
57054
  const allNodes = this.getNodes();
57044
- const nodes = allNodes.filter((item) => activeIds.has(item.getId()));
57055
+ const nodes = allNodes.filter((item) => {
57056
+ if (!activeIds.has(item.getId()))
57057
+ return false;
57058
+ if (selectedIds.has(item.getId()))
57059
+ return false;
57060
+ if (item.parent !== "Board" && selectedIds.has(item.parent))
57061
+ return false;
57062
+ return true;
57063
+ });
57045
57064
  if (nodes.length < 1)
57046
57065
  return;
57047
57066
  const snapMap = new Map;
@@ -57140,14 +57159,14 @@ class ForceGraphEngine {
57140
57159
  }
57141
57160
  }
57142
57161
  if (totalEnergy < conf.FG_SLEEP_THRESHOLD && this.tickTimer !== null) {
57143
- clearInterval(this.tickTimer);
57144
- this.tickTimer = null;
57162
+ this.stopTimers();
57145
57163
  this.syncPositions();
57146
57164
  }
57147
57165
  }
57148
57166
  syncPositions() {
57149
57167
  const activeIds = this.getActiveNodeIds();
57150
- const nodes = this.getNodes().filter((item) => activeIds.has(item.getId()));
57168
+ const selectedIds = new Set(this.board.selection.list().map((i) => i.getId()));
57169
+ const nodes = this.getNodes().filter((item) => activeIds.has(item.getId()) && !selectedIds.has(item.getId()) && !(item.parent !== "Board" && selectedIds.has(item.parent)));
57151
57170
  if (nodes.length === 0)
57152
57171
  return;
57153
57172
  const movedItems = nodes.map((item) => {
@@ -58269,6 +58288,9 @@ class Board {
58269
58288
  setForceGraphGap(nodeId, gap) {
58270
58289
  this.forceGraph?.setComponentTargetGap(nodeId, gap);
58271
58290
  }
58291
+ syncForceGraph() {
58292
+ this.forceGraph?.flushSync();
58293
+ }
58272
58294
  wakeForceGraph() {
58273
58295
  this.forceGraph?.wake();
58274
58296
  }
@@ -150,6 +150,8 @@ export declare class Board {
150
150
  getForceGraphGap(nodeId: string): number | undefined;
151
151
  /** Set the connector target gap (px) for the component containing `nodeId`. */
152
152
  setForceGraphGap(nodeId: string, gap: number): void;
153
+ /** Flush pending physics positions to the server immediately (call before drag starts). */
154
+ syncForceGraph(): void;
153
155
  /** Call after dragging a node to re-wake the physics engine if it was sleeping. */
154
156
  wakeForceGraph(): void;
155
157
  }
@@ -30,7 +30,17 @@ export declare class ForceGraphEngine {
30
30
  /** Update the target gap (connector length) for the component containing `nodeId` and re-wake. */
31
31
  setComponentTargetGap(nodeId: string, gap: number): void;
32
32
  hasActiveComponents(): boolean;
33
- /** Re-wake physics after a node is manually dragged. */
33
+ /**
34
+ * Flush pending physics positions immediately.
35
+ * Call BEFORE a manual drag starts so the server knows the current physics position
36
+ * before the drag delta is applied on top of it.
37
+ */
38
+ flushSync(): void;
39
+ /**
40
+ * Re-wake physics after a manual drag ends.
41
+ * Resets sync baseline to the post-drag position so the drag delta
42
+ * (already sent by the normal operation system) is not double-counted.
43
+ */
34
44
  wake(): void;
35
45
  /** Full stop — called when Board destroys the engine. */
36
46
  stop(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "microboard-temp",
3
- "version": "0.13.22",
3
+ "version": "0.13.24",
4
4
  "description": "A flexible interactive whiteboard library",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",