microboard-temp 0.13.45 → 0.13.46
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/dist/cjs/browser.js +31 -7
- package/dist/cjs/index.js +31 -7
- package/dist/cjs/node.js +31 -7
- package/dist/esm/browser.js +31 -7
- package/dist/esm/index.js +31 -7
- package/dist/esm/node.js +31 -7
- package/dist/types/ForceGraph/ForceGraphEngine.d.ts +3 -0
- package/package.json +1 -1
package/dist/cjs/browser.js
CHANGED
|
@@ -60675,11 +60675,28 @@ class ForceGraphEngine {
|
|
|
60675
60675
|
syncTimer = null;
|
|
60676
60676
|
lastSyncedPositions = new Map;
|
|
60677
60677
|
activeComponents = new Map;
|
|
60678
|
+
isPhysicsEmit = false;
|
|
60678
60679
|
TICK_MS = 33;
|
|
60679
60680
|
SYNC_MS = 300;
|
|
60680
60681
|
MIN_MOVE_PX = 0.05;
|
|
60681
60682
|
constructor(board) {
|
|
60682
60683
|
this.board = board;
|
|
60684
|
+
board.events.subject.subscribe((event) => {
|
|
60685
|
+
if (this.isPhysicsEmit)
|
|
60686
|
+
return;
|
|
60687
|
+
const op = event.body?.operation;
|
|
60688
|
+
if (!op || op.class !== "Transformation" || op.method !== "applyMatrix")
|
|
60689
|
+
return;
|
|
60690
|
+
for (const { id, matrix } of op.items) {
|
|
60691
|
+
const last = this.lastSyncedPositions.get(id);
|
|
60692
|
+
if (last) {
|
|
60693
|
+
this.lastSyncedPositions.set(id, {
|
|
60694
|
+
x: last.x + matrix.translateX,
|
|
60695
|
+
y: last.y + matrix.translateY
|
|
60696
|
+
});
|
|
60697
|
+
}
|
|
60698
|
+
}
|
|
60699
|
+
});
|
|
60683
60700
|
}
|
|
60684
60701
|
enableForGraph(startNodeId) {
|
|
60685
60702
|
if (this.isNodeInActiveGraph(startNodeId))
|
|
@@ -60907,8 +60924,8 @@ class ForceGraphEngine {
|
|
|
60907
60924
|
}
|
|
60908
60925
|
vel.vx = (vel.vx + (ax.get(id) ?? 0)) * conf.FG_DAMPING;
|
|
60909
60926
|
vel.vy = (vel.vy + (ay.get(id) ?? 0)) * conf.FG_DAMPING;
|
|
60910
|
-
totalEnergy += Math.abs(vel.vx) + Math.abs(vel.vy);
|
|
60911
60927
|
if (Math.abs(vel.vx) >= this.MIN_MOVE_PX || Math.abs(vel.vy) >= this.MIN_MOVE_PX) {
|
|
60928
|
+
totalEnergy += Math.abs(vel.vx) + Math.abs(vel.vy);
|
|
60912
60929
|
item.transformation.applyMatrixSilent({
|
|
60913
60930
|
translateX: vel.vx,
|
|
60914
60931
|
translateY: vel.vy,
|
|
@@ -60930,26 +60947,33 @@ class ForceGraphEngine {
|
|
|
60930
60947
|
const nodes = this.getNodes().filter((item) => activeIds.has(item.getId()) && !draggedIds.has(item.getId()) && !(item.parent !== "Board" && draggedIds.has(item.parent)));
|
|
60931
60948
|
if (nodes.length === 0)
|
|
60932
60949
|
return;
|
|
60933
|
-
const
|
|
60950
|
+
const toSend = [];
|
|
60951
|
+
for (const item of nodes) {
|
|
60934
60952
|
const id = item.getId();
|
|
60935
60953
|
const pos = item.transformation.getTranslation();
|
|
60936
60954
|
const last = this.lastSyncedPositions.get(id);
|
|
60937
60955
|
const dx = last ? pos.x - last.x : 0;
|
|
60938
60956
|
const dy = last ? pos.y - last.y : 0;
|
|
60939
|
-
|
|
60940
|
-
|
|
60941
|
-
|
|
60942
|
-
|
|
60957
|
+
if (Math.abs(dx) > 0.5 || Math.abs(dy) > 0.5) {
|
|
60958
|
+
toSend.push({ id, dx, dy, x: pos.x, y: pos.y });
|
|
60959
|
+
}
|
|
60960
|
+
}
|
|
60961
|
+
if (toSend.length === 0)
|
|
60943
60962
|
return;
|
|
60963
|
+
for (const { id, x, y } of toSend) {
|
|
60964
|
+
this.lastSyncedPositions.set(id, { x, y });
|
|
60965
|
+
}
|
|
60944
60966
|
const operation = {
|
|
60945
60967
|
class: "Transformation",
|
|
60946
60968
|
method: "applyMatrix",
|
|
60947
|
-
items:
|
|
60969
|
+
items: toSend.map(({ id, dx, dy }) => ({
|
|
60948
60970
|
id,
|
|
60949
60971
|
matrix: { translateX: dx, translateY: dy, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
|
|
60950
60972
|
}))
|
|
60951
60973
|
};
|
|
60974
|
+
this.isPhysicsEmit = true;
|
|
60952
60975
|
this.board.events.emit(operation);
|
|
60976
|
+
this.isPhysicsEmit = false;
|
|
60953
60977
|
}
|
|
60954
60978
|
}
|
|
60955
60979
|
|
package/dist/cjs/index.js
CHANGED
|
@@ -60675,11 +60675,28 @@ class ForceGraphEngine {
|
|
|
60675
60675
|
syncTimer = null;
|
|
60676
60676
|
lastSyncedPositions = new Map;
|
|
60677
60677
|
activeComponents = new Map;
|
|
60678
|
+
isPhysicsEmit = false;
|
|
60678
60679
|
TICK_MS = 33;
|
|
60679
60680
|
SYNC_MS = 300;
|
|
60680
60681
|
MIN_MOVE_PX = 0.05;
|
|
60681
60682
|
constructor(board) {
|
|
60682
60683
|
this.board = board;
|
|
60684
|
+
board.events.subject.subscribe((event) => {
|
|
60685
|
+
if (this.isPhysicsEmit)
|
|
60686
|
+
return;
|
|
60687
|
+
const op = event.body?.operation;
|
|
60688
|
+
if (!op || op.class !== "Transformation" || op.method !== "applyMatrix")
|
|
60689
|
+
return;
|
|
60690
|
+
for (const { id, matrix } of op.items) {
|
|
60691
|
+
const last = this.lastSyncedPositions.get(id);
|
|
60692
|
+
if (last) {
|
|
60693
|
+
this.lastSyncedPositions.set(id, {
|
|
60694
|
+
x: last.x + matrix.translateX,
|
|
60695
|
+
y: last.y + matrix.translateY
|
|
60696
|
+
});
|
|
60697
|
+
}
|
|
60698
|
+
}
|
|
60699
|
+
});
|
|
60683
60700
|
}
|
|
60684
60701
|
enableForGraph(startNodeId) {
|
|
60685
60702
|
if (this.isNodeInActiveGraph(startNodeId))
|
|
@@ -60907,8 +60924,8 @@ class ForceGraphEngine {
|
|
|
60907
60924
|
}
|
|
60908
60925
|
vel.vx = (vel.vx + (ax.get(id) ?? 0)) * conf.FG_DAMPING;
|
|
60909
60926
|
vel.vy = (vel.vy + (ay.get(id) ?? 0)) * conf.FG_DAMPING;
|
|
60910
|
-
totalEnergy += Math.abs(vel.vx) + Math.abs(vel.vy);
|
|
60911
60927
|
if (Math.abs(vel.vx) >= this.MIN_MOVE_PX || Math.abs(vel.vy) >= this.MIN_MOVE_PX) {
|
|
60928
|
+
totalEnergy += Math.abs(vel.vx) + Math.abs(vel.vy);
|
|
60912
60929
|
item.transformation.applyMatrixSilent({
|
|
60913
60930
|
translateX: vel.vx,
|
|
60914
60931
|
translateY: vel.vy,
|
|
@@ -60930,26 +60947,33 @@ class ForceGraphEngine {
|
|
|
60930
60947
|
const nodes = this.getNodes().filter((item) => activeIds.has(item.getId()) && !draggedIds.has(item.getId()) && !(item.parent !== "Board" && draggedIds.has(item.parent)));
|
|
60931
60948
|
if (nodes.length === 0)
|
|
60932
60949
|
return;
|
|
60933
|
-
const
|
|
60950
|
+
const toSend = [];
|
|
60951
|
+
for (const item of nodes) {
|
|
60934
60952
|
const id = item.getId();
|
|
60935
60953
|
const pos = item.transformation.getTranslation();
|
|
60936
60954
|
const last = this.lastSyncedPositions.get(id);
|
|
60937
60955
|
const dx = last ? pos.x - last.x : 0;
|
|
60938
60956
|
const dy = last ? pos.y - last.y : 0;
|
|
60939
|
-
|
|
60940
|
-
|
|
60941
|
-
|
|
60942
|
-
|
|
60957
|
+
if (Math.abs(dx) > 0.5 || Math.abs(dy) > 0.5) {
|
|
60958
|
+
toSend.push({ id, dx, dy, x: pos.x, y: pos.y });
|
|
60959
|
+
}
|
|
60960
|
+
}
|
|
60961
|
+
if (toSend.length === 0)
|
|
60943
60962
|
return;
|
|
60963
|
+
for (const { id, x, y } of toSend) {
|
|
60964
|
+
this.lastSyncedPositions.set(id, { x, y });
|
|
60965
|
+
}
|
|
60944
60966
|
const operation = {
|
|
60945
60967
|
class: "Transformation",
|
|
60946
60968
|
method: "applyMatrix",
|
|
60947
|
-
items:
|
|
60969
|
+
items: toSend.map(({ id, dx, dy }) => ({
|
|
60948
60970
|
id,
|
|
60949
60971
|
matrix: { translateX: dx, translateY: dy, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
|
|
60950
60972
|
}))
|
|
60951
60973
|
};
|
|
60974
|
+
this.isPhysicsEmit = true;
|
|
60952
60975
|
this.board.events.emit(operation);
|
|
60976
|
+
this.isPhysicsEmit = false;
|
|
60953
60977
|
}
|
|
60954
60978
|
}
|
|
60955
60979
|
|
package/dist/cjs/node.js
CHANGED
|
@@ -63150,11 +63150,28 @@ class ForceGraphEngine {
|
|
|
63150
63150
|
syncTimer = null;
|
|
63151
63151
|
lastSyncedPositions = new Map;
|
|
63152
63152
|
activeComponents = new Map;
|
|
63153
|
+
isPhysicsEmit = false;
|
|
63153
63154
|
TICK_MS = 33;
|
|
63154
63155
|
SYNC_MS = 300;
|
|
63155
63156
|
MIN_MOVE_PX = 0.05;
|
|
63156
63157
|
constructor(board) {
|
|
63157
63158
|
this.board = board;
|
|
63159
|
+
board.events.subject.subscribe((event) => {
|
|
63160
|
+
if (this.isPhysicsEmit)
|
|
63161
|
+
return;
|
|
63162
|
+
const op = event.body?.operation;
|
|
63163
|
+
if (!op || op.class !== "Transformation" || op.method !== "applyMatrix")
|
|
63164
|
+
return;
|
|
63165
|
+
for (const { id, matrix } of op.items) {
|
|
63166
|
+
const last = this.lastSyncedPositions.get(id);
|
|
63167
|
+
if (last) {
|
|
63168
|
+
this.lastSyncedPositions.set(id, {
|
|
63169
|
+
x: last.x + matrix.translateX,
|
|
63170
|
+
y: last.y + matrix.translateY
|
|
63171
|
+
});
|
|
63172
|
+
}
|
|
63173
|
+
}
|
|
63174
|
+
});
|
|
63158
63175
|
}
|
|
63159
63176
|
enableForGraph(startNodeId) {
|
|
63160
63177
|
if (this.isNodeInActiveGraph(startNodeId))
|
|
@@ -63382,8 +63399,8 @@ class ForceGraphEngine {
|
|
|
63382
63399
|
}
|
|
63383
63400
|
vel.vx = (vel.vx + (ax.get(id) ?? 0)) * conf.FG_DAMPING;
|
|
63384
63401
|
vel.vy = (vel.vy + (ay.get(id) ?? 0)) * conf.FG_DAMPING;
|
|
63385
|
-
totalEnergy += Math.abs(vel.vx) + Math.abs(vel.vy);
|
|
63386
63402
|
if (Math.abs(vel.vx) >= this.MIN_MOVE_PX || Math.abs(vel.vy) >= this.MIN_MOVE_PX) {
|
|
63403
|
+
totalEnergy += Math.abs(vel.vx) + Math.abs(vel.vy);
|
|
63387
63404
|
item.transformation.applyMatrixSilent({
|
|
63388
63405
|
translateX: vel.vx,
|
|
63389
63406
|
translateY: vel.vy,
|
|
@@ -63405,26 +63422,33 @@ class ForceGraphEngine {
|
|
|
63405
63422
|
const nodes = this.getNodes().filter((item) => activeIds.has(item.getId()) && !draggedIds.has(item.getId()) && !(item.parent !== "Board" && draggedIds.has(item.parent)));
|
|
63406
63423
|
if (nodes.length === 0)
|
|
63407
63424
|
return;
|
|
63408
|
-
const
|
|
63425
|
+
const toSend = [];
|
|
63426
|
+
for (const item of nodes) {
|
|
63409
63427
|
const id = item.getId();
|
|
63410
63428
|
const pos = item.transformation.getTranslation();
|
|
63411
63429
|
const last = this.lastSyncedPositions.get(id);
|
|
63412
63430
|
const dx = last ? pos.x - last.x : 0;
|
|
63413
63431
|
const dy = last ? pos.y - last.y : 0;
|
|
63414
|
-
|
|
63415
|
-
|
|
63416
|
-
|
|
63417
|
-
|
|
63432
|
+
if (Math.abs(dx) > 0.5 || Math.abs(dy) > 0.5) {
|
|
63433
|
+
toSend.push({ id, dx, dy, x: pos.x, y: pos.y });
|
|
63434
|
+
}
|
|
63435
|
+
}
|
|
63436
|
+
if (toSend.length === 0)
|
|
63418
63437
|
return;
|
|
63438
|
+
for (const { id, x, y } of toSend) {
|
|
63439
|
+
this.lastSyncedPositions.set(id, { x, y });
|
|
63440
|
+
}
|
|
63419
63441
|
const operation = {
|
|
63420
63442
|
class: "Transformation",
|
|
63421
63443
|
method: "applyMatrix",
|
|
63422
|
-
items:
|
|
63444
|
+
items: toSend.map(({ id, dx, dy }) => ({
|
|
63423
63445
|
id,
|
|
63424
63446
|
matrix: { translateX: dx, translateY: dy, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
|
|
63425
63447
|
}))
|
|
63426
63448
|
};
|
|
63449
|
+
this.isPhysicsEmit = true;
|
|
63427
63450
|
this.board.events.emit(operation);
|
|
63451
|
+
this.isPhysicsEmit = false;
|
|
63428
63452
|
}
|
|
63429
63453
|
}
|
|
63430
63454
|
|
package/dist/esm/browser.js
CHANGED
|
@@ -60418,11 +60418,28 @@ class ForceGraphEngine {
|
|
|
60418
60418
|
syncTimer = null;
|
|
60419
60419
|
lastSyncedPositions = new Map;
|
|
60420
60420
|
activeComponents = new Map;
|
|
60421
|
+
isPhysicsEmit = false;
|
|
60421
60422
|
TICK_MS = 33;
|
|
60422
60423
|
SYNC_MS = 300;
|
|
60423
60424
|
MIN_MOVE_PX = 0.05;
|
|
60424
60425
|
constructor(board) {
|
|
60425
60426
|
this.board = board;
|
|
60427
|
+
board.events.subject.subscribe((event) => {
|
|
60428
|
+
if (this.isPhysicsEmit)
|
|
60429
|
+
return;
|
|
60430
|
+
const op = event.body?.operation;
|
|
60431
|
+
if (!op || op.class !== "Transformation" || op.method !== "applyMatrix")
|
|
60432
|
+
return;
|
|
60433
|
+
for (const { id, matrix } of op.items) {
|
|
60434
|
+
const last = this.lastSyncedPositions.get(id);
|
|
60435
|
+
if (last) {
|
|
60436
|
+
this.lastSyncedPositions.set(id, {
|
|
60437
|
+
x: last.x + matrix.translateX,
|
|
60438
|
+
y: last.y + matrix.translateY
|
|
60439
|
+
});
|
|
60440
|
+
}
|
|
60441
|
+
}
|
|
60442
|
+
});
|
|
60426
60443
|
}
|
|
60427
60444
|
enableForGraph(startNodeId) {
|
|
60428
60445
|
if (this.isNodeInActiveGraph(startNodeId))
|
|
@@ -60650,8 +60667,8 @@ class ForceGraphEngine {
|
|
|
60650
60667
|
}
|
|
60651
60668
|
vel.vx = (vel.vx + (ax.get(id) ?? 0)) * conf.FG_DAMPING;
|
|
60652
60669
|
vel.vy = (vel.vy + (ay.get(id) ?? 0)) * conf.FG_DAMPING;
|
|
60653
|
-
totalEnergy += Math.abs(vel.vx) + Math.abs(vel.vy);
|
|
60654
60670
|
if (Math.abs(vel.vx) >= this.MIN_MOVE_PX || Math.abs(vel.vy) >= this.MIN_MOVE_PX) {
|
|
60671
|
+
totalEnergy += Math.abs(vel.vx) + Math.abs(vel.vy);
|
|
60655
60672
|
item.transformation.applyMatrixSilent({
|
|
60656
60673
|
translateX: vel.vx,
|
|
60657
60674
|
translateY: vel.vy,
|
|
@@ -60673,26 +60690,33 @@ class ForceGraphEngine {
|
|
|
60673
60690
|
const nodes = this.getNodes().filter((item) => activeIds.has(item.getId()) && !draggedIds.has(item.getId()) && !(item.parent !== "Board" && draggedIds.has(item.parent)));
|
|
60674
60691
|
if (nodes.length === 0)
|
|
60675
60692
|
return;
|
|
60676
|
-
const
|
|
60693
|
+
const toSend = [];
|
|
60694
|
+
for (const item of nodes) {
|
|
60677
60695
|
const id = item.getId();
|
|
60678
60696
|
const pos = item.transformation.getTranslation();
|
|
60679
60697
|
const last = this.lastSyncedPositions.get(id);
|
|
60680
60698
|
const dx = last ? pos.x - last.x : 0;
|
|
60681
60699
|
const dy = last ? pos.y - last.y : 0;
|
|
60682
|
-
|
|
60683
|
-
|
|
60684
|
-
|
|
60685
|
-
|
|
60700
|
+
if (Math.abs(dx) > 0.5 || Math.abs(dy) > 0.5) {
|
|
60701
|
+
toSend.push({ id, dx, dy, x: pos.x, y: pos.y });
|
|
60702
|
+
}
|
|
60703
|
+
}
|
|
60704
|
+
if (toSend.length === 0)
|
|
60686
60705
|
return;
|
|
60706
|
+
for (const { id, x, y } of toSend) {
|
|
60707
|
+
this.lastSyncedPositions.set(id, { x, y });
|
|
60708
|
+
}
|
|
60687
60709
|
const operation = {
|
|
60688
60710
|
class: "Transformation",
|
|
60689
60711
|
method: "applyMatrix",
|
|
60690
|
-
items:
|
|
60712
|
+
items: toSend.map(({ id, dx, dy }) => ({
|
|
60691
60713
|
id,
|
|
60692
60714
|
matrix: { translateX: dx, translateY: dy, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
|
|
60693
60715
|
}))
|
|
60694
60716
|
};
|
|
60717
|
+
this.isPhysicsEmit = true;
|
|
60695
60718
|
this.board.events.emit(operation);
|
|
60719
|
+
this.isPhysicsEmit = false;
|
|
60696
60720
|
}
|
|
60697
60721
|
}
|
|
60698
60722
|
|
package/dist/esm/index.js
CHANGED
|
@@ -60411,11 +60411,28 @@ class ForceGraphEngine {
|
|
|
60411
60411
|
syncTimer = null;
|
|
60412
60412
|
lastSyncedPositions = new Map;
|
|
60413
60413
|
activeComponents = new Map;
|
|
60414
|
+
isPhysicsEmit = false;
|
|
60414
60415
|
TICK_MS = 33;
|
|
60415
60416
|
SYNC_MS = 300;
|
|
60416
60417
|
MIN_MOVE_PX = 0.05;
|
|
60417
60418
|
constructor(board) {
|
|
60418
60419
|
this.board = board;
|
|
60420
|
+
board.events.subject.subscribe((event) => {
|
|
60421
|
+
if (this.isPhysicsEmit)
|
|
60422
|
+
return;
|
|
60423
|
+
const op = event.body?.operation;
|
|
60424
|
+
if (!op || op.class !== "Transformation" || op.method !== "applyMatrix")
|
|
60425
|
+
return;
|
|
60426
|
+
for (const { id, matrix } of op.items) {
|
|
60427
|
+
const last = this.lastSyncedPositions.get(id);
|
|
60428
|
+
if (last) {
|
|
60429
|
+
this.lastSyncedPositions.set(id, {
|
|
60430
|
+
x: last.x + matrix.translateX,
|
|
60431
|
+
y: last.y + matrix.translateY
|
|
60432
|
+
});
|
|
60433
|
+
}
|
|
60434
|
+
}
|
|
60435
|
+
});
|
|
60419
60436
|
}
|
|
60420
60437
|
enableForGraph(startNodeId) {
|
|
60421
60438
|
if (this.isNodeInActiveGraph(startNodeId))
|
|
@@ -60643,8 +60660,8 @@ class ForceGraphEngine {
|
|
|
60643
60660
|
}
|
|
60644
60661
|
vel.vx = (vel.vx + (ax.get(id) ?? 0)) * conf.FG_DAMPING;
|
|
60645
60662
|
vel.vy = (vel.vy + (ay.get(id) ?? 0)) * conf.FG_DAMPING;
|
|
60646
|
-
totalEnergy += Math.abs(vel.vx) + Math.abs(vel.vy);
|
|
60647
60663
|
if (Math.abs(vel.vx) >= this.MIN_MOVE_PX || Math.abs(vel.vy) >= this.MIN_MOVE_PX) {
|
|
60664
|
+
totalEnergy += Math.abs(vel.vx) + Math.abs(vel.vy);
|
|
60648
60665
|
item.transformation.applyMatrixSilent({
|
|
60649
60666
|
translateX: vel.vx,
|
|
60650
60667
|
translateY: vel.vy,
|
|
@@ -60666,26 +60683,33 @@ class ForceGraphEngine {
|
|
|
60666
60683
|
const nodes = this.getNodes().filter((item) => activeIds.has(item.getId()) && !draggedIds.has(item.getId()) && !(item.parent !== "Board" && draggedIds.has(item.parent)));
|
|
60667
60684
|
if (nodes.length === 0)
|
|
60668
60685
|
return;
|
|
60669
|
-
const
|
|
60686
|
+
const toSend = [];
|
|
60687
|
+
for (const item of nodes) {
|
|
60670
60688
|
const id = item.getId();
|
|
60671
60689
|
const pos = item.transformation.getTranslation();
|
|
60672
60690
|
const last = this.lastSyncedPositions.get(id);
|
|
60673
60691
|
const dx = last ? pos.x - last.x : 0;
|
|
60674
60692
|
const dy = last ? pos.y - last.y : 0;
|
|
60675
|
-
|
|
60676
|
-
|
|
60677
|
-
|
|
60678
|
-
|
|
60693
|
+
if (Math.abs(dx) > 0.5 || Math.abs(dy) > 0.5) {
|
|
60694
|
+
toSend.push({ id, dx, dy, x: pos.x, y: pos.y });
|
|
60695
|
+
}
|
|
60696
|
+
}
|
|
60697
|
+
if (toSend.length === 0)
|
|
60679
60698
|
return;
|
|
60699
|
+
for (const { id, x, y } of toSend) {
|
|
60700
|
+
this.lastSyncedPositions.set(id, { x, y });
|
|
60701
|
+
}
|
|
60680
60702
|
const operation = {
|
|
60681
60703
|
class: "Transformation",
|
|
60682
60704
|
method: "applyMatrix",
|
|
60683
|
-
items:
|
|
60705
|
+
items: toSend.map(({ id, dx, dy }) => ({
|
|
60684
60706
|
id,
|
|
60685
60707
|
matrix: { translateX: dx, translateY: dy, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
|
|
60686
60708
|
}))
|
|
60687
60709
|
};
|
|
60710
|
+
this.isPhysicsEmit = true;
|
|
60688
60711
|
this.board.events.emit(operation);
|
|
60712
|
+
this.isPhysicsEmit = false;
|
|
60689
60713
|
}
|
|
60690
60714
|
}
|
|
60691
60715
|
|
package/dist/esm/node.js
CHANGED
|
@@ -62875,11 +62875,28 @@ class ForceGraphEngine {
|
|
|
62875
62875
|
syncTimer = null;
|
|
62876
62876
|
lastSyncedPositions = new Map;
|
|
62877
62877
|
activeComponents = new Map;
|
|
62878
|
+
isPhysicsEmit = false;
|
|
62878
62879
|
TICK_MS = 33;
|
|
62879
62880
|
SYNC_MS = 300;
|
|
62880
62881
|
MIN_MOVE_PX = 0.05;
|
|
62881
62882
|
constructor(board) {
|
|
62882
62883
|
this.board = board;
|
|
62884
|
+
board.events.subject.subscribe((event) => {
|
|
62885
|
+
if (this.isPhysicsEmit)
|
|
62886
|
+
return;
|
|
62887
|
+
const op = event.body?.operation;
|
|
62888
|
+
if (!op || op.class !== "Transformation" || op.method !== "applyMatrix")
|
|
62889
|
+
return;
|
|
62890
|
+
for (const { id, matrix } of op.items) {
|
|
62891
|
+
const last = this.lastSyncedPositions.get(id);
|
|
62892
|
+
if (last) {
|
|
62893
|
+
this.lastSyncedPositions.set(id, {
|
|
62894
|
+
x: last.x + matrix.translateX,
|
|
62895
|
+
y: last.y + matrix.translateY
|
|
62896
|
+
});
|
|
62897
|
+
}
|
|
62898
|
+
}
|
|
62899
|
+
});
|
|
62883
62900
|
}
|
|
62884
62901
|
enableForGraph(startNodeId) {
|
|
62885
62902
|
if (this.isNodeInActiveGraph(startNodeId))
|
|
@@ -63107,8 +63124,8 @@ class ForceGraphEngine {
|
|
|
63107
63124
|
}
|
|
63108
63125
|
vel.vx = (vel.vx + (ax.get(id) ?? 0)) * conf.FG_DAMPING;
|
|
63109
63126
|
vel.vy = (vel.vy + (ay.get(id) ?? 0)) * conf.FG_DAMPING;
|
|
63110
|
-
totalEnergy += Math.abs(vel.vx) + Math.abs(vel.vy);
|
|
63111
63127
|
if (Math.abs(vel.vx) >= this.MIN_MOVE_PX || Math.abs(vel.vy) >= this.MIN_MOVE_PX) {
|
|
63128
|
+
totalEnergy += Math.abs(vel.vx) + Math.abs(vel.vy);
|
|
63112
63129
|
item.transformation.applyMatrixSilent({
|
|
63113
63130
|
translateX: vel.vx,
|
|
63114
63131
|
translateY: vel.vy,
|
|
@@ -63130,26 +63147,33 @@ class ForceGraphEngine {
|
|
|
63130
63147
|
const nodes = this.getNodes().filter((item) => activeIds.has(item.getId()) && !draggedIds.has(item.getId()) && !(item.parent !== "Board" && draggedIds.has(item.parent)));
|
|
63131
63148
|
if (nodes.length === 0)
|
|
63132
63149
|
return;
|
|
63133
|
-
const
|
|
63150
|
+
const toSend = [];
|
|
63151
|
+
for (const item of nodes) {
|
|
63134
63152
|
const id = item.getId();
|
|
63135
63153
|
const pos = item.transformation.getTranslation();
|
|
63136
63154
|
const last = this.lastSyncedPositions.get(id);
|
|
63137
63155
|
const dx = last ? pos.x - last.x : 0;
|
|
63138
63156
|
const dy = last ? pos.y - last.y : 0;
|
|
63139
|
-
|
|
63140
|
-
|
|
63141
|
-
|
|
63142
|
-
|
|
63157
|
+
if (Math.abs(dx) > 0.5 || Math.abs(dy) > 0.5) {
|
|
63158
|
+
toSend.push({ id, dx, dy, x: pos.x, y: pos.y });
|
|
63159
|
+
}
|
|
63160
|
+
}
|
|
63161
|
+
if (toSend.length === 0)
|
|
63143
63162
|
return;
|
|
63163
|
+
for (const { id, x, y } of toSend) {
|
|
63164
|
+
this.lastSyncedPositions.set(id, { x, y });
|
|
63165
|
+
}
|
|
63144
63166
|
const operation = {
|
|
63145
63167
|
class: "Transformation",
|
|
63146
63168
|
method: "applyMatrix",
|
|
63147
|
-
items:
|
|
63169
|
+
items: toSend.map(({ id, dx, dy }) => ({
|
|
63148
63170
|
id,
|
|
63149
63171
|
matrix: { translateX: dx, translateY: dy, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
|
|
63150
63172
|
}))
|
|
63151
63173
|
};
|
|
63174
|
+
this.isPhysicsEmit = true;
|
|
63152
63175
|
this.board.events.emit(operation);
|
|
63176
|
+
this.isPhysicsEmit = false;
|
|
63153
63177
|
}
|
|
63154
63178
|
}
|
|
63155
63179
|
|
|
@@ -8,6 +8,9 @@ export declare class ForceGraphEngine {
|
|
|
8
8
|
/** Active components: componentId → { nodeIds, targetGap }
|
|
9
9
|
* componentId is the nodeId that was passed to enableForGraph(). */
|
|
10
10
|
private activeComponents;
|
|
11
|
+
/** Set to true while we are emitting a physics sync operation, so the
|
|
12
|
+
* board-event subscription below doesn't double-update lastSyncedPositions. */
|
|
13
|
+
private isPhysicsEmit;
|
|
11
14
|
private readonly TICK_MS;
|
|
12
15
|
private readonly SYNC_MS;
|
|
13
16
|
private readonly MIN_MOVE_PX;
|