microboard-temp 0.13.45 → 0.13.47
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 +44 -13
- package/dist/cjs/index.js +44 -13
- package/dist/cjs/node.js +44 -13
- package/dist/esm/browser.js +44 -13
- package/dist/esm/index.js +44 -13
- package/dist/esm/node.js +44 -13
- package/dist/types/ForceGraph/ForceGraphEngine.d.ts +3 -0
- package/package.json +1 -1
package/dist/cjs/browser.js
CHANGED
|
@@ -60511,6 +60511,8 @@ class GravityEngine {
|
|
|
60511
60511
|
return false;
|
|
60512
60512
|
if (item.parent !== "Board" && draggedIds.has(item.parent))
|
|
60513
60513
|
return false;
|
|
60514
|
+
if (this.board.isNodeInForceGraph(item.getId()))
|
|
60515
|
+
return false;
|
|
60514
60516
|
return true;
|
|
60515
60517
|
});
|
|
60516
60518
|
if (items.length < 1)
|
|
@@ -60613,25 +60615,30 @@ class GravityEngine {
|
|
|
60613
60615
|
return false;
|
|
60614
60616
|
if (item.parent !== "Board" && draggedIds.has(item.parent))
|
|
60615
60617
|
return false;
|
|
60618
|
+
if (this.board.isNodeInForceGraph(item.getId()))
|
|
60619
|
+
return false;
|
|
60616
60620
|
return true;
|
|
60617
60621
|
});
|
|
60618
60622
|
if (items.length === 0)
|
|
60619
60623
|
return;
|
|
60620
|
-
const
|
|
60624
|
+
const toSend = [];
|
|
60625
|
+
for (const item of items) {
|
|
60621
60626
|
const id = item.getId();
|
|
60622
60627
|
const pos = item.transformation.getTranslation();
|
|
60623
60628
|
const last = this.lastSyncedPositions.get(id);
|
|
60624
60629
|
const dx = last ? pos.x - last.x : 0;
|
|
60625
60630
|
const dy = last ? pos.y - last.y : 0;
|
|
60626
|
-
|
|
60627
|
-
|
|
60628
|
-
|
|
60629
|
-
|
|
60631
|
+
if (Math.abs(dx) > 0.5 || Math.abs(dy) > 0.5) {
|
|
60632
|
+
toSend.push({ id, dx, dy });
|
|
60633
|
+
this.lastSyncedPositions.set(id, { x: pos.x, y: pos.y });
|
|
60634
|
+
}
|
|
60635
|
+
}
|
|
60636
|
+
if (toSend.length === 0)
|
|
60630
60637
|
return;
|
|
60631
60638
|
const operation = {
|
|
60632
60639
|
class: "Transformation",
|
|
60633
60640
|
method: "applyMatrix",
|
|
60634
|
-
items:
|
|
60641
|
+
items: toSend.map(({ id, dx, dy }) => ({
|
|
60635
60642
|
id,
|
|
60636
60643
|
matrix: { translateX: dx, translateY: dy, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
|
|
60637
60644
|
}))
|
|
@@ -60675,11 +60682,28 @@ class ForceGraphEngine {
|
|
|
60675
60682
|
syncTimer = null;
|
|
60676
60683
|
lastSyncedPositions = new Map;
|
|
60677
60684
|
activeComponents = new Map;
|
|
60685
|
+
isPhysicsEmit = false;
|
|
60678
60686
|
TICK_MS = 33;
|
|
60679
60687
|
SYNC_MS = 300;
|
|
60680
60688
|
MIN_MOVE_PX = 0.05;
|
|
60681
60689
|
constructor(board) {
|
|
60682
60690
|
this.board = board;
|
|
60691
|
+
board.events.subject.subscribe((event) => {
|
|
60692
|
+
if (this.isPhysicsEmit)
|
|
60693
|
+
return;
|
|
60694
|
+
const op = event.body?.operation;
|
|
60695
|
+
if (!op || op.class !== "Transformation" || op.method !== "applyMatrix")
|
|
60696
|
+
return;
|
|
60697
|
+
for (const { id, matrix } of op.items) {
|
|
60698
|
+
const last = this.lastSyncedPositions.get(id);
|
|
60699
|
+
if (last) {
|
|
60700
|
+
this.lastSyncedPositions.set(id, {
|
|
60701
|
+
x: last.x + matrix.translateX,
|
|
60702
|
+
y: last.y + matrix.translateY
|
|
60703
|
+
});
|
|
60704
|
+
}
|
|
60705
|
+
}
|
|
60706
|
+
});
|
|
60683
60707
|
}
|
|
60684
60708
|
enableForGraph(startNodeId) {
|
|
60685
60709
|
if (this.isNodeInActiveGraph(startNodeId))
|
|
@@ -60907,8 +60931,8 @@ class ForceGraphEngine {
|
|
|
60907
60931
|
}
|
|
60908
60932
|
vel.vx = (vel.vx + (ax.get(id) ?? 0)) * conf.FG_DAMPING;
|
|
60909
60933
|
vel.vy = (vel.vy + (ay.get(id) ?? 0)) * conf.FG_DAMPING;
|
|
60910
|
-
totalEnergy += Math.abs(vel.vx) + Math.abs(vel.vy);
|
|
60911
60934
|
if (Math.abs(vel.vx) >= this.MIN_MOVE_PX || Math.abs(vel.vy) >= this.MIN_MOVE_PX) {
|
|
60935
|
+
totalEnergy += Math.abs(vel.vx) + Math.abs(vel.vy);
|
|
60912
60936
|
item.transformation.applyMatrixSilent({
|
|
60913
60937
|
translateX: vel.vx,
|
|
60914
60938
|
translateY: vel.vy,
|
|
@@ -60930,26 +60954,33 @@ class ForceGraphEngine {
|
|
|
60930
60954
|
const nodes = this.getNodes().filter((item) => activeIds.has(item.getId()) && !draggedIds.has(item.getId()) && !(item.parent !== "Board" && draggedIds.has(item.parent)));
|
|
60931
60955
|
if (nodes.length === 0)
|
|
60932
60956
|
return;
|
|
60933
|
-
const
|
|
60957
|
+
const toSend = [];
|
|
60958
|
+
for (const item of nodes) {
|
|
60934
60959
|
const id = item.getId();
|
|
60935
60960
|
const pos = item.transformation.getTranslation();
|
|
60936
60961
|
const last = this.lastSyncedPositions.get(id);
|
|
60937
60962
|
const dx = last ? pos.x - last.x : 0;
|
|
60938
60963
|
const dy = last ? pos.y - last.y : 0;
|
|
60939
|
-
|
|
60940
|
-
|
|
60941
|
-
|
|
60942
|
-
|
|
60964
|
+
if (Math.abs(dx) > 0.5 || Math.abs(dy) > 0.5) {
|
|
60965
|
+
toSend.push({ id, dx, dy, x: pos.x, y: pos.y });
|
|
60966
|
+
}
|
|
60967
|
+
}
|
|
60968
|
+
if (toSend.length === 0)
|
|
60943
60969
|
return;
|
|
60970
|
+
for (const { id, x, y } of toSend) {
|
|
60971
|
+
this.lastSyncedPositions.set(id, { x, y });
|
|
60972
|
+
}
|
|
60944
60973
|
const operation = {
|
|
60945
60974
|
class: "Transformation",
|
|
60946
60975
|
method: "applyMatrix",
|
|
60947
|
-
items:
|
|
60976
|
+
items: toSend.map(({ id, dx, dy }) => ({
|
|
60948
60977
|
id,
|
|
60949
60978
|
matrix: { translateX: dx, translateY: dy, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
|
|
60950
60979
|
}))
|
|
60951
60980
|
};
|
|
60981
|
+
this.isPhysicsEmit = true;
|
|
60952
60982
|
this.board.events.emit(operation);
|
|
60983
|
+
this.isPhysicsEmit = false;
|
|
60953
60984
|
}
|
|
60954
60985
|
}
|
|
60955
60986
|
|
package/dist/cjs/index.js
CHANGED
|
@@ -60511,6 +60511,8 @@ class GravityEngine {
|
|
|
60511
60511
|
return false;
|
|
60512
60512
|
if (item.parent !== "Board" && draggedIds.has(item.parent))
|
|
60513
60513
|
return false;
|
|
60514
|
+
if (this.board.isNodeInForceGraph(item.getId()))
|
|
60515
|
+
return false;
|
|
60514
60516
|
return true;
|
|
60515
60517
|
});
|
|
60516
60518
|
if (items.length < 1)
|
|
@@ -60613,25 +60615,30 @@ class GravityEngine {
|
|
|
60613
60615
|
return false;
|
|
60614
60616
|
if (item.parent !== "Board" && draggedIds.has(item.parent))
|
|
60615
60617
|
return false;
|
|
60618
|
+
if (this.board.isNodeInForceGraph(item.getId()))
|
|
60619
|
+
return false;
|
|
60616
60620
|
return true;
|
|
60617
60621
|
});
|
|
60618
60622
|
if (items.length === 0)
|
|
60619
60623
|
return;
|
|
60620
|
-
const
|
|
60624
|
+
const toSend = [];
|
|
60625
|
+
for (const item of items) {
|
|
60621
60626
|
const id = item.getId();
|
|
60622
60627
|
const pos = item.transformation.getTranslation();
|
|
60623
60628
|
const last = this.lastSyncedPositions.get(id);
|
|
60624
60629
|
const dx = last ? pos.x - last.x : 0;
|
|
60625
60630
|
const dy = last ? pos.y - last.y : 0;
|
|
60626
|
-
|
|
60627
|
-
|
|
60628
|
-
|
|
60629
|
-
|
|
60631
|
+
if (Math.abs(dx) > 0.5 || Math.abs(dy) > 0.5) {
|
|
60632
|
+
toSend.push({ id, dx, dy });
|
|
60633
|
+
this.lastSyncedPositions.set(id, { x: pos.x, y: pos.y });
|
|
60634
|
+
}
|
|
60635
|
+
}
|
|
60636
|
+
if (toSend.length === 0)
|
|
60630
60637
|
return;
|
|
60631
60638
|
const operation = {
|
|
60632
60639
|
class: "Transformation",
|
|
60633
60640
|
method: "applyMatrix",
|
|
60634
|
-
items:
|
|
60641
|
+
items: toSend.map(({ id, dx, dy }) => ({
|
|
60635
60642
|
id,
|
|
60636
60643
|
matrix: { translateX: dx, translateY: dy, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
|
|
60637
60644
|
}))
|
|
@@ -60675,11 +60682,28 @@ class ForceGraphEngine {
|
|
|
60675
60682
|
syncTimer = null;
|
|
60676
60683
|
lastSyncedPositions = new Map;
|
|
60677
60684
|
activeComponents = new Map;
|
|
60685
|
+
isPhysicsEmit = false;
|
|
60678
60686
|
TICK_MS = 33;
|
|
60679
60687
|
SYNC_MS = 300;
|
|
60680
60688
|
MIN_MOVE_PX = 0.05;
|
|
60681
60689
|
constructor(board) {
|
|
60682
60690
|
this.board = board;
|
|
60691
|
+
board.events.subject.subscribe((event) => {
|
|
60692
|
+
if (this.isPhysicsEmit)
|
|
60693
|
+
return;
|
|
60694
|
+
const op = event.body?.operation;
|
|
60695
|
+
if (!op || op.class !== "Transformation" || op.method !== "applyMatrix")
|
|
60696
|
+
return;
|
|
60697
|
+
for (const { id, matrix } of op.items) {
|
|
60698
|
+
const last = this.lastSyncedPositions.get(id);
|
|
60699
|
+
if (last) {
|
|
60700
|
+
this.lastSyncedPositions.set(id, {
|
|
60701
|
+
x: last.x + matrix.translateX,
|
|
60702
|
+
y: last.y + matrix.translateY
|
|
60703
|
+
});
|
|
60704
|
+
}
|
|
60705
|
+
}
|
|
60706
|
+
});
|
|
60683
60707
|
}
|
|
60684
60708
|
enableForGraph(startNodeId) {
|
|
60685
60709
|
if (this.isNodeInActiveGraph(startNodeId))
|
|
@@ -60907,8 +60931,8 @@ class ForceGraphEngine {
|
|
|
60907
60931
|
}
|
|
60908
60932
|
vel.vx = (vel.vx + (ax.get(id) ?? 0)) * conf.FG_DAMPING;
|
|
60909
60933
|
vel.vy = (vel.vy + (ay.get(id) ?? 0)) * conf.FG_DAMPING;
|
|
60910
|
-
totalEnergy += Math.abs(vel.vx) + Math.abs(vel.vy);
|
|
60911
60934
|
if (Math.abs(vel.vx) >= this.MIN_MOVE_PX || Math.abs(vel.vy) >= this.MIN_MOVE_PX) {
|
|
60935
|
+
totalEnergy += Math.abs(vel.vx) + Math.abs(vel.vy);
|
|
60912
60936
|
item.transformation.applyMatrixSilent({
|
|
60913
60937
|
translateX: vel.vx,
|
|
60914
60938
|
translateY: vel.vy,
|
|
@@ -60930,26 +60954,33 @@ class ForceGraphEngine {
|
|
|
60930
60954
|
const nodes = this.getNodes().filter((item) => activeIds.has(item.getId()) && !draggedIds.has(item.getId()) && !(item.parent !== "Board" && draggedIds.has(item.parent)));
|
|
60931
60955
|
if (nodes.length === 0)
|
|
60932
60956
|
return;
|
|
60933
|
-
const
|
|
60957
|
+
const toSend = [];
|
|
60958
|
+
for (const item of nodes) {
|
|
60934
60959
|
const id = item.getId();
|
|
60935
60960
|
const pos = item.transformation.getTranslation();
|
|
60936
60961
|
const last = this.lastSyncedPositions.get(id);
|
|
60937
60962
|
const dx = last ? pos.x - last.x : 0;
|
|
60938
60963
|
const dy = last ? pos.y - last.y : 0;
|
|
60939
|
-
|
|
60940
|
-
|
|
60941
|
-
|
|
60942
|
-
|
|
60964
|
+
if (Math.abs(dx) > 0.5 || Math.abs(dy) > 0.5) {
|
|
60965
|
+
toSend.push({ id, dx, dy, x: pos.x, y: pos.y });
|
|
60966
|
+
}
|
|
60967
|
+
}
|
|
60968
|
+
if (toSend.length === 0)
|
|
60943
60969
|
return;
|
|
60970
|
+
for (const { id, x, y } of toSend) {
|
|
60971
|
+
this.lastSyncedPositions.set(id, { x, y });
|
|
60972
|
+
}
|
|
60944
60973
|
const operation = {
|
|
60945
60974
|
class: "Transformation",
|
|
60946
60975
|
method: "applyMatrix",
|
|
60947
|
-
items:
|
|
60976
|
+
items: toSend.map(({ id, dx, dy }) => ({
|
|
60948
60977
|
id,
|
|
60949
60978
|
matrix: { translateX: dx, translateY: dy, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
|
|
60950
60979
|
}))
|
|
60951
60980
|
};
|
|
60981
|
+
this.isPhysicsEmit = true;
|
|
60952
60982
|
this.board.events.emit(operation);
|
|
60983
|
+
this.isPhysicsEmit = false;
|
|
60953
60984
|
}
|
|
60954
60985
|
}
|
|
60955
60986
|
|
package/dist/cjs/node.js
CHANGED
|
@@ -62986,6 +62986,8 @@ class GravityEngine {
|
|
|
62986
62986
|
return false;
|
|
62987
62987
|
if (item.parent !== "Board" && draggedIds.has(item.parent))
|
|
62988
62988
|
return false;
|
|
62989
|
+
if (this.board.isNodeInForceGraph(item.getId()))
|
|
62990
|
+
return false;
|
|
62989
62991
|
return true;
|
|
62990
62992
|
});
|
|
62991
62993
|
if (items.length < 1)
|
|
@@ -63088,25 +63090,30 @@ class GravityEngine {
|
|
|
63088
63090
|
return false;
|
|
63089
63091
|
if (item.parent !== "Board" && draggedIds.has(item.parent))
|
|
63090
63092
|
return false;
|
|
63093
|
+
if (this.board.isNodeInForceGraph(item.getId()))
|
|
63094
|
+
return false;
|
|
63091
63095
|
return true;
|
|
63092
63096
|
});
|
|
63093
63097
|
if (items.length === 0)
|
|
63094
63098
|
return;
|
|
63095
|
-
const
|
|
63099
|
+
const toSend = [];
|
|
63100
|
+
for (const item of items) {
|
|
63096
63101
|
const id = item.getId();
|
|
63097
63102
|
const pos = item.transformation.getTranslation();
|
|
63098
63103
|
const last = this.lastSyncedPositions.get(id);
|
|
63099
63104
|
const dx = last ? pos.x - last.x : 0;
|
|
63100
63105
|
const dy = last ? pos.y - last.y : 0;
|
|
63101
|
-
|
|
63102
|
-
|
|
63103
|
-
|
|
63104
|
-
|
|
63106
|
+
if (Math.abs(dx) > 0.5 || Math.abs(dy) > 0.5) {
|
|
63107
|
+
toSend.push({ id, dx, dy });
|
|
63108
|
+
this.lastSyncedPositions.set(id, { x: pos.x, y: pos.y });
|
|
63109
|
+
}
|
|
63110
|
+
}
|
|
63111
|
+
if (toSend.length === 0)
|
|
63105
63112
|
return;
|
|
63106
63113
|
const operation = {
|
|
63107
63114
|
class: "Transformation",
|
|
63108
63115
|
method: "applyMatrix",
|
|
63109
|
-
items:
|
|
63116
|
+
items: toSend.map(({ id, dx, dy }) => ({
|
|
63110
63117
|
id,
|
|
63111
63118
|
matrix: { translateX: dx, translateY: dy, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
|
|
63112
63119
|
}))
|
|
@@ -63150,11 +63157,28 @@ class ForceGraphEngine {
|
|
|
63150
63157
|
syncTimer = null;
|
|
63151
63158
|
lastSyncedPositions = new Map;
|
|
63152
63159
|
activeComponents = new Map;
|
|
63160
|
+
isPhysicsEmit = false;
|
|
63153
63161
|
TICK_MS = 33;
|
|
63154
63162
|
SYNC_MS = 300;
|
|
63155
63163
|
MIN_MOVE_PX = 0.05;
|
|
63156
63164
|
constructor(board) {
|
|
63157
63165
|
this.board = board;
|
|
63166
|
+
board.events.subject.subscribe((event) => {
|
|
63167
|
+
if (this.isPhysicsEmit)
|
|
63168
|
+
return;
|
|
63169
|
+
const op = event.body?.operation;
|
|
63170
|
+
if (!op || op.class !== "Transformation" || op.method !== "applyMatrix")
|
|
63171
|
+
return;
|
|
63172
|
+
for (const { id, matrix } of op.items) {
|
|
63173
|
+
const last = this.lastSyncedPositions.get(id);
|
|
63174
|
+
if (last) {
|
|
63175
|
+
this.lastSyncedPositions.set(id, {
|
|
63176
|
+
x: last.x + matrix.translateX,
|
|
63177
|
+
y: last.y + matrix.translateY
|
|
63178
|
+
});
|
|
63179
|
+
}
|
|
63180
|
+
}
|
|
63181
|
+
});
|
|
63158
63182
|
}
|
|
63159
63183
|
enableForGraph(startNodeId) {
|
|
63160
63184
|
if (this.isNodeInActiveGraph(startNodeId))
|
|
@@ -63382,8 +63406,8 @@ class ForceGraphEngine {
|
|
|
63382
63406
|
}
|
|
63383
63407
|
vel.vx = (vel.vx + (ax.get(id) ?? 0)) * conf.FG_DAMPING;
|
|
63384
63408
|
vel.vy = (vel.vy + (ay.get(id) ?? 0)) * conf.FG_DAMPING;
|
|
63385
|
-
totalEnergy += Math.abs(vel.vx) + Math.abs(vel.vy);
|
|
63386
63409
|
if (Math.abs(vel.vx) >= this.MIN_MOVE_PX || Math.abs(vel.vy) >= this.MIN_MOVE_PX) {
|
|
63410
|
+
totalEnergy += Math.abs(vel.vx) + Math.abs(vel.vy);
|
|
63387
63411
|
item.transformation.applyMatrixSilent({
|
|
63388
63412
|
translateX: vel.vx,
|
|
63389
63413
|
translateY: vel.vy,
|
|
@@ -63405,26 +63429,33 @@ class ForceGraphEngine {
|
|
|
63405
63429
|
const nodes = this.getNodes().filter((item) => activeIds.has(item.getId()) && !draggedIds.has(item.getId()) && !(item.parent !== "Board" && draggedIds.has(item.parent)));
|
|
63406
63430
|
if (nodes.length === 0)
|
|
63407
63431
|
return;
|
|
63408
|
-
const
|
|
63432
|
+
const toSend = [];
|
|
63433
|
+
for (const item of nodes) {
|
|
63409
63434
|
const id = item.getId();
|
|
63410
63435
|
const pos = item.transformation.getTranslation();
|
|
63411
63436
|
const last = this.lastSyncedPositions.get(id);
|
|
63412
63437
|
const dx = last ? pos.x - last.x : 0;
|
|
63413
63438
|
const dy = last ? pos.y - last.y : 0;
|
|
63414
|
-
|
|
63415
|
-
|
|
63416
|
-
|
|
63417
|
-
|
|
63439
|
+
if (Math.abs(dx) > 0.5 || Math.abs(dy) > 0.5) {
|
|
63440
|
+
toSend.push({ id, dx, dy, x: pos.x, y: pos.y });
|
|
63441
|
+
}
|
|
63442
|
+
}
|
|
63443
|
+
if (toSend.length === 0)
|
|
63418
63444
|
return;
|
|
63445
|
+
for (const { id, x, y } of toSend) {
|
|
63446
|
+
this.lastSyncedPositions.set(id, { x, y });
|
|
63447
|
+
}
|
|
63419
63448
|
const operation = {
|
|
63420
63449
|
class: "Transformation",
|
|
63421
63450
|
method: "applyMatrix",
|
|
63422
|
-
items:
|
|
63451
|
+
items: toSend.map(({ id, dx, dy }) => ({
|
|
63423
63452
|
id,
|
|
63424
63453
|
matrix: { translateX: dx, translateY: dy, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
|
|
63425
63454
|
}))
|
|
63426
63455
|
};
|
|
63456
|
+
this.isPhysicsEmit = true;
|
|
63427
63457
|
this.board.events.emit(operation);
|
|
63458
|
+
this.isPhysicsEmit = false;
|
|
63428
63459
|
}
|
|
63429
63460
|
}
|
|
63430
63461
|
|
package/dist/esm/browser.js
CHANGED
|
@@ -60254,6 +60254,8 @@ class GravityEngine {
|
|
|
60254
60254
|
return false;
|
|
60255
60255
|
if (item.parent !== "Board" && draggedIds.has(item.parent))
|
|
60256
60256
|
return false;
|
|
60257
|
+
if (this.board.isNodeInForceGraph(item.getId()))
|
|
60258
|
+
return false;
|
|
60257
60259
|
return true;
|
|
60258
60260
|
});
|
|
60259
60261
|
if (items.length < 1)
|
|
@@ -60356,25 +60358,30 @@ class GravityEngine {
|
|
|
60356
60358
|
return false;
|
|
60357
60359
|
if (item.parent !== "Board" && draggedIds.has(item.parent))
|
|
60358
60360
|
return false;
|
|
60361
|
+
if (this.board.isNodeInForceGraph(item.getId()))
|
|
60362
|
+
return false;
|
|
60359
60363
|
return true;
|
|
60360
60364
|
});
|
|
60361
60365
|
if (items.length === 0)
|
|
60362
60366
|
return;
|
|
60363
|
-
const
|
|
60367
|
+
const toSend = [];
|
|
60368
|
+
for (const item of items) {
|
|
60364
60369
|
const id = item.getId();
|
|
60365
60370
|
const pos = item.transformation.getTranslation();
|
|
60366
60371
|
const last = this.lastSyncedPositions.get(id);
|
|
60367
60372
|
const dx = last ? pos.x - last.x : 0;
|
|
60368
60373
|
const dy = last ? pos.y - last.y : 0;
|
|
60369
|
-
|
|
60370
|
-
|
|
60371
|
-
|
|
60372
|
-
|
|
60374
|
+
if (Math.abs(dx) > 0.5 || Math.abs(dy) > 0.5) {
|
|
60375
|
+
toSend.push({ id, dx, dy });
|
|
60376
|
+
this.lastSyncedPositions.set(id, { x: pos.x, y: pos.y });
|
|
60377
|
+
}
|
|
60378
|
+
}
|
|
60379
|
+
if (toSend.length === 0)
|
|
60373
60380
|
return;
|
|
60374
60381
|
const operation = {
|
|
60375
60382
|
class: "Transformation",
|
|
60376
60383
|
method: "applyMatrix",
|
|
60377
|
-
items:
|
|
60384
|
+
items: toSend.map(({ id, dx, dy }) => ({
|
|
60378
60385
|
id,
|
|
60379
60386
|
matrix: { translateX: dx, translateY: dy, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
|
|
60380
60387
|
}))
|
|
@@ -60418,11 +60425,28 @@ class ForceGraphEngine {
|
|
|
60418
60425
|
syncTimer = null;
|
|
60419
60426
|
lastSyncedPositions = new Map;
|
|
60420
60427
|
activeComponents = new Map;
|
|
60428
|
+
isPhysicsEmit = false;
|
|
60421
60429
|
TICK_MS = 33;
|
|
60422
60430
|
SYNC_MS = 300;
|
|
60423
60431
|
MIN_MOVE_PX = 0.05;
|
|
60424
60432
|
constructor(board) {
|
|
60425
60433
|
this.board = board;
|
|
60434
|
+
board.events.subject.subscribe((event) => {
|
|
60435
|
+
if (this.isPhysicsEmit)
|
|
60436
|
+
return;
|
|
60437
|
+
const op = event.body?.operation;
|
|
60438
|
+
if (!op || op.class !== "Transformation" || op.method !== "applyMatrix")
|
|
60439
|
+
return;
|
|
60440
|
+
for (const { id, matrix } of op.items) {
|
|
60441
|
+
const last = this.lastSyncedPositions.get(id);
|
|
60442
|
+
if (last) {
|
|
60443
|
+
this.lastSyncedPositions.set(id, {
|
|
60444
|
+
x: last.x + matrix.translateX,
|
|
60445
|
+
y: last.y + matrix.translateY
|
|
60446
|
+
});
|
|
60447
|
+
}
|
|
60448
|
+
}
|
|
60449
|
+
});
|
|
60426
60450
|
}
|
|
60427
60451
|
enableForGraph(startNodeId) {
|
|
60428
60452
|
if (this.isNodeInActiveGraph(startNodeId))
|
|
@@ -60650,8 +60674,8 @@ class ForceGraphEngine {
|
|
|
60650
60674
|
}
|
|
60651
60675
|
vel.vx = (vel.vx + (ax.get(id) ?? 0)) * conf.FG_DAMPING;
|
|
60652
60676
|
vel.vy = (vel.vy + (ay.get(id) ?? 0)) * conf.FG_DAMPING;
|
|
60653
|
-
totalEnergy += Math.abs(vel.vx) + Math.abs(vel.vy);
|
|
60654
60677
|
if (Math.abs(vel.vx) >= this.MIN_MOVE_PX || Math.abs(vel.vy) >= this.MIN_MOVE_PX) {
|
|
60678
|
+
totalEnergy += Math.abs(vel.vx) + Math.abs(vel.vy);
|
|
60655
60679
|
item.transformation.applyMatrixSilent({
|
|
60656
60680
|
translateX: vel.vx,
|
|
60657
60681
|
translateY: vel.vy,
|
|
@@ -60673,26 +60697,33 @@ class ForceGraphEngine {
|
|
|
60673
60697
|
const nodes = this.getNodes().filter((item) => activeIds.has(item.getId()) && !draggedIds.has(item.getId()) && !(item.parent !== "Board" && draggedIds.has(item.parent)));
|
|
60674
60698
|
if (nodes.length === 0)
|
|
60675
60699
|
return;
|
|
60676
|
-
const
|
|
60700
|
+
const toSend = [];
|
|
60701
|
+
for (const item of nodes) {
|
|
60677
60702
|
const id = item.getId();
|
|
60678
60703
|
const pos = item.transformation.getTranslation();
|
|
60679
60704
|
const last = this.lastSyncedPositions.get(id);
|
|
60680
60705
|
const dx = last ? pos.x - last.x : 0;
|
|
60681
60706
|
const dy = last ? pos.y - last.y : 0;
|
|
60682
|
-
|
|
60683
|
-
|
|
60684
|
-
|
|
60685
|
-
|
|
60707
|
+
if (Math.abs(dx) > 0.5 || Math.abs(dy) > 0.5) {
|
|
60708
|
+
toSend.push({ id, dx, dy, x: pos.x, y: pos.y });
|
|
60709
|
+
}
|
|
60710
|
+
}
|
|
60711
|
+
if (toSend.length === 0)
|
|
60686
60712
|
return;
|
|
60713
|
+
for (const { id, x, y } of toSend) {
|
|
60714
|
+
this.lastSyncedPositions.set(id, { x, y });
|
|
60715
|
+
}
|
|
60687
60716
|
const operation = {
|
|
60688
60717
|
class: "Transformation",
|
|
60689
60718
|
method: "applyMatrix",
|
|
60690
|
-
items:
|
|
60719
|
+
items: toSend.map(({ id, dx, dy }) => ({
|
|
60691
60720
|
id,
|
|
60692
60721
|
matrix: { translateX: dx, translateY: dy, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
|
|
60693
60722
|
}))
|
|
60694
60723
|
};
|
|
60724
|
+
this.isPhysicsEmit = true;
|
|
60695
60725
|
this.board.events.emit(operation);
|
|
60726
|
+
this.isPhysicsEmit = false;
|
|
60696
60727
|
}
|
|
60697
60728
|
}
|
|
60698
60729
|
|
package/dist/esm/index.js
CHANGED
|
@@ -60247,6 +60247,8 @@ class GravityEngine {
|
|
|
60247
60247
|
return false;
|
|
60248
60248
|
if (item.parent !== "Board" && draggedIds.has(item.parent))
|
|
60249
60249
|
return false;
|
|
60250
|
+
if (this.board.isNodeInForceGraph(item.getId()))
|
|
60251
|
+
return false;
|
|
60250
60252
|
return true;
|
|
60251
60253
|
});
|
|
60252
60254
|
if (items.length < 1)
|
|
@@ -60349,25 +60351,30 @@ class GravityEngine {
|
|
|
60349
60351
|
return false;
|
|
60350
60352
|
if (item.parent !== "Board" && draggedIds.has(item.parent))
|
|
60351
60353
|
return false;
|
|
60354
|
+
if (this.board.isNodeInForceGraph(item.getId()))
|
|
60355
|
+
return false;
|
|
60352
60356
|
return true;
|
|
60353
60357
|
});
|
|
60354
60358
|
if (items.length === 0)
|
|
60355
60359
|
return;
|
|
60356
|
-
const
|
|
60360
|
+
const toSend = [];
|
|
60361
|
+
for (const item of items) {
|
|
60357
60362
|
const id = item.getId();
|
|
60358
60363
|
const pos = item.transformation.getTranslation();
|
|
60359
60364
|
const last = this.lastSyncedPositions.get(id);
|
|
60360
60365
|
const dx = last ? pos.x - last.x : 0;
|
|
60361
60366
|
const dy = last ? pos.y - last.y : 0;
|
|
60362
|
-
|
|
60363
|
-
|
|
60364
|
-
|
|
60365
|
-
|
|
60367
|
+
if (Math.abs(dx) > 0.5 || Math.abs(dy) > 0.5) {
|
|
60368
|
+
toSend.push({ id, dx, dy });
|
|
60369
|
+
this.lastSyncedPositions.set(id, { x: pos.x, y: pos.y });
|
|
60370
|
+
}
|
|
60371
|
+
}
|
|
60372
|
+
if (toSend.length === 0)
|
|
60366
60373
|
return;
|
|
60367
60374
|
const operation = {
|
|
60368
60375
|
class: "Transformation",
|
|
60369
60376
|
method: "applyMatrix",
|
|
60370
|
-
items:
|
|
60377
|
+
items: toSend.map(({ id, dx, dy }) => ({
|
|
60371
60378
|
id,
|
|
60372
60379
|
matrix: { translateX: dx, translateY: dy, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
|
|
60373
60380
|
}))
|
|
@@ -60411,11 +60418,28 @@ class ForceGraphEngine {
|
|
|
60411
60418
|
syncTimer = null;
|
|
60412
60419
|
lastSyncedPositions = new Map;
|
|
60413
60420
|
activeComponents = new Map;
|
|
60421
|
+
isPhysicsEmit = false;
|
|
60414
60422
|
TICK_MS = 33;
|
|
60415
60423
|
SYNC_MS = 300;
|
|
60416
60424
|
MIN_MOVE_PX = 0.05;
|
|
60417
60425
|
constructor(board) {
|
|
60418
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
|
+
});
|
|
60419
60443
|
}
|
|
60420
60444
|
enableForGraph(startNodeId) {
|
|
60421
60445
|
if (this.isNodeInActiveGraph(startNodeId))
|
|
@@ -60643,8 +60667,8 @@ class ForceGraphEngine {
|
|
|
60643
60667
|
}
|
|
60644
60668
|
vel.vx = (vel.vx + (ax.get(id) ?? 0)) * conf.FG_DAMPING;
|
|
60645
60669
|
vel.vy = (vel.vy + (ay.get(id) ?? 0)) * conf.FG_DAMPING;
|
|
60646
|
-
totalEnergy += Math.abs(vel.vx) + Math.abs(vel.vy);
|
|
60647
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);
|
|
60648
60672
|
item.transformation.applyMatrixSilent({
|
|
60649
60673
|
translateX: vel.vx,
|
|
60650
60674
|
translateY: vel.vy,
|
|
@@ -60666,26 +60690,33 @@ class ForceGraphEngine {
|
|
|
60666
60690
|
const nodes = this.getNodes().filter((item) => activeIds.has(item.getId()) && !draggedIds.has(item.getId()) && !(item.parent !== "Board" && draggedIds.has(item.parent)));
|
|
60667
60691
|
if (nodes.length === 0)
|
|
60668
60692
|
return;
|
|
60669
|
-
const
|
|
60693
|
+
const toSend = [];
|
|
60694
|
+
for (const item of nodes) {
|
|
60670
60695
|
const id = item.getId();
|
|
60671
60696
|
const pos = item.transformation.getTranslation();
|
|
60672
60697
|
const last = this.lastSyncedPositions.get(id);
|
|
60673
60698
|
const dx = last ? pos.x - last.x : 0;
|
|
60674
60699
|
const dy = last ? pos.y - last.y : 0;
|
|
60675
|
-
|
|
60676
|
-
|
|
60677
|
-
|
|
60678
|
-
|
|
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)
|
|
60679
60705
|
return;
|
|
60706
|
+
for (const { id, x, y } of toSend) {
|
|
60707
|
+
this.lastSyncedPositions.set(id, { x, y });
|
|
60708
|
+
}
|
|
60680
60709
|
const operation = {
|
|
60681
60710
|
class: "Transformation",
|
|
60682
60711
|
method: "applyMatrix",
|
|
60683
|
-
items:
|
|
60712
|
+
items: toSend.map(({ id, dx, dy }) => ({
|
|
60684
60713
|
id,
|
|
60685
60714
|
matrix: { translateX: dx, translateY: dy, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
|
|
60686
60715
|
}))
|
|
60687
60716
|
};
|
|
60717
|
+
this.isPhysicsEmit = true;
|
|
60688
60718
|
this.board.events.emit(operation);
|
|
60719
|
+
this.isPhysicsEmit = false;
|
|
60689
60720
|
}
|
|
60690
60721
|
}
|
|
60691
60722
|
|
package/dist/esm/node.js
CHANGED
|
@@ -62711,6 +62711,8 @@ class GravityEngine {
|
|
|
62711
62711
|
return false;
|
|
62712
62712
|
if (item.parent !== "Board" && draggedIds.has(item.parent))
|
|
62713
62713
|
return false;
|
|
62714
|
+
if (this.board.isNodeInForceGraph(item.getId()))
|
|
62715
|
+
return false;
|
|
62714
62716
|
return true;
|
|
62715
62717
|
});
|
|
62716
62718
|
if (items.length < 1)
|
|
@@ -62813,25 +62815,30 @@ class GravityEngine {
|
|
|
62813
62815
|
return false;
|
|
62814
62816
|
if (item.parent !== "Board" && draggedIds.has(item.parent))
|
|
62815
62817
|
return false;
|
|
62818
|
+
if (this.board.isNodeInForceGraph(item.getId()))
|
|
62819
|
+
return false;
|
|
62816
62820
|
return true;
|
|
62817
62821
|
});
|
|
62818
62822
|
if (items.length === 0)
|
|
62819
62823
|
return;
|
|
62820
|
-
const
|
|
62824
|
+
const toSend = [];
|
|
62825
|
+
for (const item of items) {
|
|
62821
62826
|
const id = item.getId();
|
|
62822
62827
|
const pos = item.transformation.getTranslation();
|
|
62823
62828
|
const last = this.lastSyncedPositions.get(id);
|
|
62824
62829
|
const dx = last ? pos.x - last.x : 0;
|
|
62825
62830
|
const dy = last ? pos.y - last.y : 0;
|
|
62826
|
-
|
|
62827
|
-
|
|
62828
|
-
|
|
62829
|
-
|
|
62831
|
+
if (Math.abs(dx) > 0.5 || Math.abs(dy) > 0.5) {
|
|
62832
|
+
toSend.push({ id, dx, dy });
|
|
62833
|
+
this.lastSyncedPositions.set(id, { x: pos.x, y: pos.y });
|
|
62834
|
+
}
|
|
62835
|
+
}
|
|
62836
|
+
if (toSend.length === 0)
|
|
62830
62837
|
return;
|
|
62831
62838
|
const operation = {
|
|
62832
62839
|
class: "Transformation",
|
|
62833
62840
|
method: "applyMatrix",
|
|
62834
|
-
items:
|
|
62841
|
+
items: toSend.map(({ id, dx, dy }) => ({
|
|
62835
62842
|
id,
|
|
62836
62843
|
matrix: { translateX: dx, translateY: dy, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
|
|
62837
62844
|
}))
|
|
@@ -62875,11 +62882,28 @@ class ForceGraphEngine {
|
|
|
62875
62882
|
syncTimer = null;
|
|
62876
62883
|
lastSyncedPositions = new Map;
|
|
62877
62884
|
activeComponents = new Map;
|
|
62885
|
+
isPhysicsEmit = false;
|
|
62878
62886
|
TICK_MS = 33;
|
|
62879
62887
|
SYNC_MS = 300;
|
|
62880
62888
|
MIN_MOVE_PX = 0.05;
|
|
62881
62889
|
constructor(board) {
|
|
62882
62890
|
this.board = board;
|
|
62891
|
+
board.events.subject.subscribe((event) => {
|
|
62892
|
+
if (this.isPhysicsEmit)
|
|
62893
|
+
return;
|
|
62894
|
+
const op = event.body?.operation;
|
|
62895
|
+
if (!op || op.class !== "Transformation" || op.method !== "applyMatrix")
|
|
62896
|
+
return;
|
|
62897
|
+
for (const { id, matrix } of op.items) {
|
|
62898
|
+
const last = this.lastSyncedPositions.get(id);
|
|
62899
|
+
if (last) {
|
|
62900
|
+
this.lastSyncedPositions.set(id, {
|
|
62901
|
+
x: last.x + matrix.translateX,
|
|
62902
|
+
y: last.y + matrix.translateY
|
|
62903
|
+
});
|
|
62904
|
+
}
|
|
62905
|
+
}
|
|
62906
|
+
});
|
|
62883
62907
|
}
|
|
62884
62908
|
enableForGraph(startNodeId) {
|
|
62885
62909
|
if (this.isNodeInActiveGraph(startNodeId))
|
|
@@ -63107,8 +63131,8 @@ class ForceGraphEngine {
|
|
|
63107
63131
|
}
|
|
63108
63132
|
vel.vx = (vel.vx + (ax.get(id) ?? 0)) * conf.FG_DAMPING;
|
|
63109
63133
|
vel.vy = (vel.vy + (ay.get(id) ?? 0)) * conf.FG_DAMPING;
|
|
63110
|
-
totalEnergy += Math.abs(vel.vx) + Math.abs(vel.vy);
|
|
63111
63134
|
if (Math.abs(vel.vx) >= this.MIN_MOVE_PX || Math.abs(vel.vy) >= this.MIN_MOVE_PX) {
|
|
63135
|
+
totalEnergy += Math.abs(vel.vx) + Math.abs(vel.vy);
|
|
63112
63136
|
item.transformation.applyMatrixSilent({
|
|
63113
63137
|
translateX: vel.vx,
|
|
63114
63138
|
translateY: vel.vy,
|
|
@@ -63130,26 +63154,33 @@ class ForceGraphEngine {
|
|
|
63130
63154
|
const nodes = this.getNodes().filter((item) => activeIds.has(item.getId()) && !draggedIds.has(item.getId()) && !(item.parent !== "Board" && draggedIds.has(item.parent)));
|
|
63131
63155
|
if (nodes.length === 0)
|
|
63132
63156
|
return;
|
|
63133
|
-
const
|
|
63157
|
+
const toSend = [];
|
|
63158
|
+
for (const item of nodes) {
|
|
63134
63159
|
const id = item.getId();
|
|
63135
63160
|
const pos = item.transformation.getTranslation();
|
|
63136
63161
|
const last = this.lastSyncedPositions.get(id);
|
|
63137
63162
|
const dx = last ? pos.x - last.x : 0;
|
|
63138
63163
|
const dy = last ? pos.y - last.y : 0;
|
|
63139
|
-
|
|
63140
|
-
|
|
63141
|
-
|
|
63142
|
-
|
|
63164
|
+
if (Math.abs(dx) > 0.5 || Math.abs(dy) > 0.5) {
|
|
63165
|
+
toSend.push({ id, dx, dy, x: pos.x, y: pos.y });
|
|
63166
|
+
}
|
|
63167
|
+
}
|
|
63168
|
+
if (toSend.length === 0)
|
|
63143
63169
|
return;
|
|
63170
|
+
for (const { id, x, y } of toSend) {
|
|
63171
|
+
this.lastSyncedPositions.set(id, { x, y });
|
|
63172
|
+
}
|
|
63144
63173
|
const operation = {
|
|
63145
63174
|
class: "Transformation",
|
|
63146
63175
|
method: "applyMatrix",
|
|
63147
|
-
items:
|
|
63176
|
+
items: toSend.map(({ id, dx, dy }) => ({
|
|
63148
63177
|
id,
|
|
63149
63178
|
matrix: { translateX: dx, translateY: dy, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 }
|
|
63150
63179
|
}))
|
|
63151
63180
|
};
|
|
63181
|
+
this.isPhysicsEmit = true;
|
|
63152
63182
|
this.board.events.emit(operation);
|
|
63183
|
+
this.isPhysicsEmit = false;
|
|
63153
63184
|
}
|
|
63154
63185
|
}
|
|
63155
63186
|
|
|
@@ -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;
|