@inditextech/weave-sdk 4.0.1 → 4.1.1
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/sdk.js +115 -42
- package/dist/sdk.node.js +115 -42
- package/dist/sdk.node.stats.html +1 -1
- package/dist/sdk.stats.html +1 -1
- package/dist/types.d.ts +27 -18
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +115 -42
- package/dist/types.js.map +1 -1
- package/dist/types.stats.html +1 -1
- package/package.json +5 -3
package/dist/sdk.node.js
CHANGED
|
@@ -4,6 +4,7 @@ import pino from "pino";
|
|
|
4
4
|
import { WEAVE_ASYNC_STATUS, WEAVE_AWARENESS_LAYER_ID, WEAVE_EXPORT_BACKGROUND_COLOR, WEAVE_EXPORT_FORMATS, WEAVE_EXPORT_RETURN_FORMAT, WEAVE_INSTANCE_STATUS, WEAVE_KONVA_BACKEND, WEAVE_LOG_LEVEL, WEAVE_NODE_CHANGE_TYPE, WEAVE_NODE_CUSTOM_EVENTS, WEAVE_NODE_LAYER_ID, WEAVE_NODE_POSITION, WEAVE_STORE_CONNECTION_STATUS, WEAVE_UTILITY_LAYER_ID } from "@inditextech/weave-types";
|
|
5
5
|
import { getYjsDoc, getYjsValue, observeDeep, syncedStore } from "@syncedstore/core";
|
|
6
6
|
import * as Y from "yjs";
|
|
7
|
+
import simplify from "simplify-js";
|
|
7
8
|
import "konva/lib/types";
|
|
8
9
|
import "konva/lib/Stage";
|
|
9
10
|
|
|
@@ -17870,7 +17871,8 @@ function moveNodeToContainerNT(instance, node, containerToMove, originalNode, or
|
|
|
17870
17871
|
const actualContainerAttrs = nodeActualContainer.getAttrs();
|
|
17871
17872
|
let layerToMove = void 0;
|
|
17872
17873
|
if (actualContainerAttrs.id !== containerToMove.getAttrs().id && !invalidOriginsTypes.includes(node.getAttrs().nodeType)) layerToMove = containerToMove;
|
|
17873
|
-
|
|
17874
|
+
const nodeHandler = instance.getNodeHandler(node.getAttrs().nodeType);
|
|
17875
|
+
if (layerToMove && actualContainerAttrs.id !== layerToMove.getAttrs().id && actualContainerAttrs.id !== layerToMove.getAttrs().containerId && nodeHandler) {
|
|
17874
17876
|
const layerToMoveAttrs = layerToMove.getAttrs();
|
|
17875
17877
|
const nodePos = node.getAbsolutePosition();
|
|
17876
17878
|
const nodeRotation = node.getAbsoluteRotation();
|
|
@@ -17879,7 +17881,6 @@ function moveNodeToContainerNT(instance, node, containerToMove, originalNode, or
|
|
|
17879
17881
|
node.rotation(nodeRotation);
|
|
17880
17882
|
node.x(node.x() - (layerToMoveAttrs.containerOffsetX ?? 0));
|
|
17881
17883
|
node.y(node.y() - (layerToMoveAttrs.containerOffsetY ?? 0));
|
|
17882
|
-
node.destroy();
|
|
17883
17884
|
const newNode = node.clone();
|
|
17884
17885
|
instance.emitEvent("onNodeMovedToContainer", {
|
|
17885
17886
|
node: newNode,
|
|
@@ -17887,17 +17888,15 @@ function moveNodeToContainerNT(instance, node, containerToMove, originalNode, or
|
|
|
17887
17888
|
originalNode,
|
|
17888
17889
|
originalContainer
|
|
17889
17890
|
});
|
|
17890
|
-
const
|
|
17891
|
-
|
|
17892
|
-
|
|
17893
|
-
|
|
17894
|
-
|
|
17895
|
-
|
|
17896
|
-
|
|
17897
|
-
|
|
17898
|
-
|
|
17899
|
-
return true;
|
|
17900
|
-
}
|
|
17891
|
+
const actualNodeState = nodeHandler.serialize(node);
|
|
17892
|
+
const newNodeState = nodeHandler.serialize(newNode);
|
|
17893
|
+
node.destroy();
|
|
17894
|
+
instance.removeNodeNT(actualNodeState, { emitUserChangeEvent: false });
|
|
17895
|
+
instance.addNodeNT(newNodeState, layerToMoveAttrs.id, {
|
|
17896
|
+
emitUserChangeEvent: false,
|
|
17897
|
+
overrideUserChangeType: WEAVE_NODE_CHANGE_TYPE.UPDATE
|
|
17898
|
+
});
|
|
17899
|
+
return true;
|
|
17901
17900
|
}
|
|
17902
17901
|
return false;
|
|
17903
17902
|
}
|
|
@@ -19429,10 +19428,10 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19429
19428
|
}
|
|
19430
19429
|
const isStage = e.target instanceof Konva.Stage;
|
|
19431
19430
|
const isTransformer = e.target?.getParent() instanceof Konva.Transformer;
|
|
19432
|
-
const
|
|
19431
|
+
const canBeTargeted = e.target.getAttrs().canBeTargeted !== false;
|
|
19433
19432
|
const isContainerEmptyArea = e.target.getAttrs().isContainerPrincipal !== void 0 && !e.target.getAttrs().isContainerPrincipal;
|
|
19434
19433
|
if (isTransformer) return;
|
|
19435
|
-
if (!isStage && !isContainerEmptyArea &&
|
|
19434
|
+
if (!isStage && !isContainerEmptyArea && canBeTargeted) {
|
|
19436
19435
|
this.selecting = false;
|
|
19437
19436
|
this.stopPanLoop();
|
|
19438
19437
|
this.hideSelectorArea();
|
|
@@ -20532,6 +20531,9 @@ var WeaveNode = class {
|
|
|
20532
20531
|
mutexUserId: void 0
|
|
20533
20532
|
});
|
|
20534
20533
|
};
|
|
20534
|
+
const isLocked = node.getAttrs().locked ?? false;
|
|
20535
|
+
if (isLocked) node.listening(false);
|
|
20536
|
+
else node.listening(true);
|
|
20535
20537
|
}
|
|
20536
20538
|
isNodeSelected(ele) {
|
|
20537
20539
|
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
@@ -20905,27 +20907,27 @@ var WeaveNode = class {
|
|
|
20905
20907
|
const activeAction = this.instance.getActiveAction();
|
|
20906
20908
|
const isNodeSelectionEnabled = this.getSelectionPlugin()?.isEnabled();
|
|
20907
20909
|
const realNode = this.instance.getInstanceRecursive(node);
|
|
20908
|
-
const
|
|
20909
|
-
const isLocked =
|
|
20910
|
+
const canBeTargeted = realNode.getAttrs().canBeTargeted !== false;
|
|
20911
|
+
const isLocked = realNode.getAttrs().locked ?? false;
|
|
20910
20912
|
const isMutexLocked = realNode.getAttrs().mutexLocked && realNode.getAttrs().mutexUserId !== user.id;
|
|
20911
20913
|
if ([MOVE_TOOL_ACTION_NAME].includes(activeAction ?? "")) return false;
|
|
20912
20914
|
let showHover = false;
|
|
20913
20915
|
let cancelBubble = false;
|
|
20914
|
-
if (isNodeSelectionEnabled && this.isSelecting() && !this.isNodeSelected(realNode) && !this.isPasting() && (isLocked || isMutexLocked)) {
|
|
20916
|
+
if (isNodeSelectionEnabled && this.isSelecting() && !this.isNodeSelected(realNode) && !this.isPasting() && realNode.hasName("node") && (isLocked || isMutexLocked)) {
|
|
20915
20917
|
stage.container().style.cursor = "default";
|
|
20916
20918
|
cancelBubble = true;
|
|
20917
20919
|
}
|
|
20918
|
-
if (isNodeSelectionEnabled && this.isSelecting() && !this.isNodeSelected(realNode) && !this.isPasting() &&
|
|
20920
|
+
if (isNodeSelectionEnabled && this.isSelecting() && !this.isNodeSelected(realNode) && !this.isPasting() && canBeTargeted && realNode.hasName("node") && !(isLocked || isMutexLocked) && stage.mode() === WEAVE_STAGE_DEFAULT_MODE) {
|
|
20919
20921
|
showHover = true;
|
|
20920
|
-
stage.container().style.cursor = (typeof
|
|
20922
|
+
stage.container().style.cursor = (typeof realNode?.defineMousePointer === "function" ? realNode.defineMousePointer() : null) ?? "pointer";
|
|
20921
20923
|
cancelBubble = true;
|
|
20922
20924
|
}
|
|
20923
|
-
if (isNodeSelectionEnabled && this.isSelecting() && this.isNodeSelected(realNode) && !this.isPasting() &&
|
|
20925
|
+
if (isNodeSelectionEnabled && this.isSelecting() && this.isNodeSelected(realNode) && !this.isPasting() && realNode.hasName("node") && canBeTargeted && !(isLocked || isMutexLocked) && stage.mode() === WEAVE_STAGE_DEFAULT_MODE) {
|
|
20924
20926
|
showHover = true;
|
|
20925
|
-
stage.container().style.cursor = (typeof
|
|
20927
|
+
stage.container().style.cursor = (typeof realNode?.defineMousePointer === "function" ? realNode.defineMousePointer() : null) ?? "grab";
|
|
20926
20928
|
cancelBubble = true;
|
|
20927
20929
|
}
|
|
20928
|
-
if (!
|
|
20930
|
+
if (!canBeTargeted) cancelBubble = true;
|
|
20929
20931
|
if (this.isPasting()) {
|
|
20930
20932
|
stage.container().style.cursor = "crosshair";
|
|
20931
20933
|
cancelBubble = true;
|
|
@@ -21013,7 +21015,12 @@ var WeaveNode = class {
|
|
|
21013
21015
|
}
|
|
21014
21016
|
lock(instance) {
|
|
21015
21017
|
if (instance.getAttrs().nodeType !== this.getNodeType()) return;
|
|
21016
|
-
instance.
|
|
21018
|
+
const isListening = instance.listening();
|
|
21019
|
+
instance.setAttrs({
|
|
21020
|
+
locked: true,
|
|
21021
|
+
listening: false,
|
|
21022
|
+
previousListening: isListening
|
|
21023
|
+
});
|
|
21017
21024
|
this.instance.updateNode(this.serialize(instance));
|
|
21018
21025
|
const selectionPlugin = this.getSelectionPlugin();
|
|
21019
21026
|
if (selectionPlugin) {
|
|
@@ -21031,7 +21038,12 @@ var WeaveNode = class {
|
|
|
21031
21038
|
let realInstance = instance;
|
|
21032
21039
|
if (instance.getAttrs().nodeId) realInstance = this.instance.getStage().findOne(`#${instance.getAttrs().nodeId}`);
|
|
21033
21040
|
if (!realInstance) return;
|
|
21034
|
-
realInstance.
|
|
21041
|
+
const previousListening = realInstance.getAttrs().previousListening ?? true;
|
|
21042
|
+
realInstance.setAttrs({
|
|
21043
|
+
locked: false,
|
|
21044
|
+
listening: previousListening,
|
|
21045
|
+
previousListening: void 0
|
|
21046
|
+
});
|
|
21035
21047
|
this.instance.updateNode(this.serialize(realInstance));
|
|
21036
21048
|
this.setupDefaultNodeEvents(realInstance);
|
|
21037
21049
|
const stage = this.instance.getStage();
|
|
@@ -22186,7 +22198,7 @@ var WeaveRegisterManager = class {
|
|
|
22186
22198
|
|
|
22187
22199
|
//#endregion
|
|
22188
22200
|
//#region package.json
|
|
22189
|
-
var version = "4.
|
|
22201
|
+
var version = "4.1.1";
|
|
22190
22202
|
|
|
22191
22203
|
//#endregion
|
|
22192
22204
|
//#region src/managers/setup.ts
|
|
@@ -24337,6 +24349,7 @@ async function downscaleImageFile(file, ratio) {
|
|
|
24337
24349
|
ctx.drawImage(bitmap, 0, 0, width, height);
|
|
24338
24350
|
return new Promise((resolve) => {
|
|
24339
24351
|
canvas.toBlob((blob) => resolve(blob), file.type, .9);
|
|
24352
|
+
canvas.remove();
|
|
24340
24353
|
});
|
|
24341
24354
|
}
|
|
24342
24355
|
function getImageSizeFromFile(file) {
|
|
@@ -24392,7 +24405,9 @@ const downscaleImageFromURL = (url, options) => {
|
|
|
24392
24405
|
canvas.height = height;
|
|
24393
24406
|
const ctx = canvas.getContext("2d");
|
|
24394
24407
|
ctx.drawImage(img, 0, 0, width, height);
|
|
24395
|
-
|
|
24408
|
+
const dataURL = canvas.toDataURL(type);
|
|
24409
|
+
canvas.remove();
|
|
24410
|
+
resolve(dataURL);
|
|
24396
24411
|
};
|
|
24397
24412
|
img.onerror = () => {
|
|
24398
24413
|
reject(new Error("Invalid image", { cause: "InvalidImage" }));
|
|
@@ -24454,7 +24469,8 @@ var WeaveStageNode = class extends WeaveNode {
|
|
|
24454
24469
|
globalEventsInitialized = false;
|
|
24455
24470
|
initialize = void 0;
|
|
24456
24471
|
onRender(props) {
|
|
24457
|
-
|
|
24472
|
+
let stage = this.instance.getStage();
|
|
24473
|
+
if (!stage) stage = new Konva.Stage({
|
|
24458
24474
|
...props,
|
|
24459
24475
|
mode: "default"
|
|
24460
24476
|
});
|
|
@@ -26626,6 +26642,7 @@ const doPreloadCursors = async (cursorsToPreload, setCursor, getFallbackCursor,
|
|
|
26626
26642
|
const ctx = canvas.getContext("2d");
|
|
26627
26643
|
ctx?.drawImage(img, 0, 0);
|
|
26628
26644
|
const dataURL = canvas.toDataURL("image/png");
|
|
26645
|
+
canvas.remove();
|
|
26629
26646
|
const tokens = value.split(" ");
|
|
26630
26647
|
tokens[0] = `url(${dataURL})`;
|
|
26631
26648
|
setCursor(state, tokens.join(" "));
|
|
@@ -28182,7 +28199,7 @@ var WeaveFrameNode = class extends WeaveNode {
|
|
|
28182
28199
|
strokeScaleEnabled: true,
|
|
28183
28200
|
listening: true,
|
|
28184
28201
|
draggable: false,
|
|
28185
|
-
|
|
28202
|
+
canBeTargeted: false
|
|
28186
28203
|
});
|
|
28187
28204
|
frameInternal.clip({
|
|
28188
28205
|
x: 0 * frameInternal.scaleX(),
|
|
@@ -28441,8 +28458,8 @@ var WeaveStrokeNode = class extends WeaveNode {
|
|
|
28441
28458
|
const segLen = Math.hypot(dx, dy) || 1;
|
|
28442
28459
|
const nx = -dy / segLen;
|
|
28443
28460
|
const ny = dx / segLen;
|
|
28444
|
-
const w0 = baseW * p0.pressure / 2;
|
|
28445
|
-
const w1 = baseW * p1.pressure / 2;
|
|
28461
|
+
const w0 = Math.max(baseW * p0.pressure / 2, .5);
|
|
28462
|
+
const w1 = Math.max(baseW * p1.pressure / 2, .5);
|
|
28446
28463
|
let traveled = 0;
|
|
28447
28464
|
while (traveled < segLen) {
|
|
28448
28465
|
const step = Math.min(dashRemaining, segLen - traveled);
|
|
@@ -29510,7 +29527,7 @@ var WeaveCommentNode = class extends WeaveNode {
|
|
|
29510
29527
|
const commentNode = new Konva.Group({
|
|
29511
29528
|
...commentParams,
|
|
29512
29529
|
name: "comment",
|
|
29513
|
-
|
|
29530
|
+
canBeTargeted: false,
|
|
29514
29531
|
isExpanded: false,
|
|
29515
29532
|
commentAction: null,
|
|
29516
29533
|
listening: true,
|
|
@@ -29521,7 +29538,7 @@ var WeaveCommentNode = class extends WeaveNode {
|
|
|
29521
29538
|
id: `${id}-bg`,
|
|
29522
29539
|
x: 0,
|
|
29523
29540
|
y: -heightContracted,
|
|
29524
|
-
|
|
29541
|
+
canBeTargeted: false,
|
|
29525
29542
|
fill: commentParams.userBackgroundColor ?? "#0000FF",
|
|
29526
29543
|
stroke: this.config.style.stroke,
|
|
29527
29544
|
strokeWidth: this.config.style.strokeWidth,
|
|
@@ -34520,6 +34537,11 @@ const BRUSH_TOOL_DEFAULT_CONFIG = { interpolationSteps: 10 };
|
|
|
34520
34537
|
var WeaveBrushToolAction = class extends WeaveAction {
|
|
34521
34538
|
initialized = false;
|
|
34522
34539
|
isSpacePressed = false;
|
|
34540
|
+
penActive = false;
|
|
34541
|
+
lastSmoothedPressure = .5;
|
|
34542
|
+
lastPointerPos = null;
|
|
34543
|
+
lastPointerTime = 0;
|
|
34544
|
+
predictedCount = 0;
|
|
34523
34545
|
onPropsChange = void 0;
|
|
34524
34546
|
onInit = void 0;
|
|
34525
34547
|
constructor(params) {
|
|
@@ -34549,11 +34571,29 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34549
34571
|
};
|
|
34550
34572
|
}
|
|
34551
34573
|
getEventPressure(e) {
|
|
34552
|
-
|
|
34553
|
-
|
|
34574
|
+
const now$2 = performance.now();
|
|
34575
|
+
let velocity = 0;
|
|
34576
|
+
if (this.lastPointerPos && now$2 - this.lastPointerTime > 0) {
|
|
34577
|
+
const dx = e.evt.clientX - this.lastPointerPos.x;
|
|
34578
|
+
const dy = e.evt.clientY - this.lastPointerPos.y;
|
|
34579
|
+
velocity = Math.hypot(dx, dy) / (now$2 - this.lastPointerTime) * 1e3;
|
|
34580
|
+
}
|
|
34581
|
+
this.lastPointerPos = {
|
|
34582
|
+
x: e.evt.clientX,
|
|
34583
|
+
y: e.evt.clientY
|
|
34584
|
+
};
|
|
34585
|
+
this.lastPointerTime = now$2;
|
|
34586
|
+
const alpha = Math.min(Math.max(velocity / 1500, .15), .6);
|
|
34587
|
+
let raw;
|
|
34588
|
+
if (e.evt.pointerType === "pen") raw = e.evt.pressure || .5;
|
|
34589
|
+
else raw = .5;
|
|
34590
|
+
this.lastSmoothedPressure = alpha * raw + (1 - alpha) * this.lastSmoothedPressure;
|
|
34591
|
+
return Math.max(this.lastSmoothedPressure, .15);
|
|
34554
34592
|
}
|
|
34555
34593
|
setupEvents() {
|
|
34556
34594
|
const stage = this.instance.getStage();
|
|
34595
|
+
this.prevTouchAction = stage.container().style.touchAction;
|
|
34596
|
+
stage.container().style.touchAction = "none";
|
|
34557
34597
|
window.addEventListener("keyup", (e) => {
|
|
34558
34598
|
if (e.code === "Space" && this.instance.getActiveAction() === BRUSH_TOOL_ACTION_NAME) this.isSpacePressed = false;
|
|
34559
34599
|
}, { signal: this.instance.getEventsController()?.signal });
|
|
@@ -34579,6 +34619,8 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34579
34619
|
if (this.getZoomPlugin()?.isPinching()) return;
|
|
34580
34620
|
if (this.isSpacePressed) return;
|
|
34581
34621
|
if (e?.evt?.button !== 0) return;
|
|
34622
|
+
if (e.evt.pointerType === "touch" && this.penActive) return;
|
|
34623
|
+
if (e.evt.pointerType === "pen") this.penActive = true;
|
|
34582
34624
|
const pointPressure = this.getEventPressure(e);
|
|
34583
34625
|
this.handleStartStroke(pointPressure);
|
|
34584
34626
|
e.evt.stopPropagation();
|
|
@@ -34589,12 +34631,27 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34589
34631
|
this.setCursor();
|
|
34590
34632
|
if (this.state !== BRUSH_TOOL_STATE.DEFINE_STROKE) return;
|
|
34591
34633
|
if (this.getZoomPlugin()?.isPinching()) return;
|
|
34592
|
-
const
|
|
34593
|
-
|
|
34634
|
+
const coalescedEvents = e.evt.getCoalescedEvents ? e.evt.getCoalescedEvents() : [];
|
|
34635
|
+
if (coalescedEvents.length > 1) {
|
|
34636
|
+
for (const ce of coalescedEvents) {
|
|
34637
|
+
const pointPressure = ce.pointerType === "pen" && typeof ce.pressure === "number" ? ce.pressure : .5;
|
|
34638
|
+
this.handleMovement(pointPressure, void 0, false);
|
|
34639
|
+
}
|
|
34640
|
+
const predictedEvents = e.evt.getPredictedEvents ? e.evt.getPredictedEvents() : [];
|
|
34641
|
+
if (predictedEvents.length > 0) {
|
|
34642
|
+
const last = predictedEvents[predictedEvents.length - 1];
|
|
34643
|
+
const predPressure = last.pointerType === "pen" && typeof last.pressure === "number" ? last.pressure : .5;
|
|
34644
|
+
this.handleMovement(predPressure, last, true);
|
|
34645
|
+
}
|
|
34646
|
+
} else {
|
|
34647
|
+
const pointPressure = this.getEventPressure(e);
|
|
34648
|
+
this.handleMovement(pointPressure, void 0, false);
|
|
34649
|
+
}
|
|
34594
34650
|
e.evt.stopPropagation();
|
|
34595
34651
|
};
|
|
34596
34652
|
stage.on("pointermove", handlePointerMove);
|
|
34597
34653
|
const handlePointerUp = (e) => {
|
|
34654
|
+
this.penActive = false;
|
|
34598
34655
|
if (this.state !== BRUSH_TOOL_STATE.DEFINE_STROKE) return;
|
|
34599
34656
|
if (this.getZoomPlugin()?.isPinching()) return;
|
|
34600
34657
|
this.handleEndStroke();
|
|
@@ -34631,6 +34688,10 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34631
34688
|
};
|
|
34632
34689
|
}
|
|
34633
34690
|
handleStartStroke(pressure) {
|
|
34691
|
+
this.lastSmoothedPressure = .5;
|
|
34692
|
+
this.lastPointerPos = null;
|
|
34693
|
+
this.lastPointerTime = 0;
|
|
34694
|
+
this.predictedCount = 0;
|
|
34634
34695
|
const { mousePoint, container, measureContainer } = this.instance.getMousePointer();
|
|
34635
34696
|
this.clickPoint = mousePoint;
|
|
34636
34697
|
this.container = container;
|
|
@@ -34659,17 +34720,25 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34659
34720
|
}
|
|
34660
34721
|
this.setState(BRUSH_TOOL_STATE.DEFINE_STROKE);
|
|
34661
34722
|
}
|
|
34662
|
-
handleMovement(pressure) {
|
|
34723
|
+
handleMovement(pressure, predictedEvent, isPredicted = false) {
|
|
34663
34724
|
if (this.state !== BRUSH_TOOL_STATE.DEFINE_STROKE) return;
|
|
34725
|
+
const stage = this.instance.getStage();
|
|
34664
34726
|
const tempStroke = this.instance.getStage().findOne(`#${this.strokeId}`);
|
|
34665
34727
|
if (this.measureContainer && tempStroke) {
|
|
34728
|
+
if (predictedEvent) stage.setPointersPositions(predictedEvent);
|
|
34666
34729
|
const { mousePoint } = this.instance.getMousePointerRelativeToContainer(this.measureContainer);
|
|
34667
34730
|
const currentPoint = {
|
|
34668
34731
|
x: mousePoint.x - tempStroke.x(),
|
|
34669
34732
|
y: mousePoint.y - tempStroke.y(),
|
|
34670
34733
|
pressure
|
|
34671
34734
|
};
|
|
34672
|
-
|
|
34735
|
+
let newStrokeElements = [...tempStroke.getAttrs().strokeElements];
|
|
34736
|
+
if (!isPredicted && this.predictedCount > 0) {
|
|
34737
|
+
newStrokeElements = newStrokeElements.slice(0, -1 * this.predictedCount);
|
|
34738
|
+
this.predictedCount = 0;
|
|
34739
|
+
}
|
|
34740
|
+
newStrokeElements.push(currentPoint);
|
|
34741
|
+
if (isPredicted) this.predictedCount++;
|
|
34673
34742
|
const box = this.getBoundingBox(newStrokeElements);
|
|
34674
34743
|
tempStroke.setAttrs({
|
|
34675
34744
|
width: box.width,
|
|
@@ -34689,17 +34758,22 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34689
34758
|
if (nodeHandler) {
|
|
34690
34759
|
const box = this.getBoundingBox(tempStroke.getAttrs().strokeElements);
|
|
34691
34760
|
let newStrokeElements = [...tempStroke.getAttrs().strokeElements];
|
|
34761
|
+
if (this.predictedCount > 0) {
|
|
34762
|
+
newStrokeElements = newStrokeElements.slice(0, -1 * this.predictedCount);
|
|
34763
|
+
this.predictedCount = 0;
|
|
34764
|
+
}
|
|
34692
34765
|
newStrokeElements = newStrokeElements.map((point) => ({
|
|
34693
34766
|
...point,
|
|
34694
34767
|
x: point.x - box.x,
|
|
34695
34768
|
y: point.y - box.y
|
|
34696
34769
|
}));
|
|
34770
|
+
const compressedPoints = simplify(newStrokeElements, 1, true);
|
|
34697
34771
|
tempStroke.setAttrs({
|
|
34698
34772
|
width: box.width,
|
|
34699
34773
|
height: box.height,
|
|
34700
34774
|
x: box.x,
|
|
34701
34775
|
y: box.y,
|
|
34702
|
-
strokeElements:
|
|
34776
|
+
strokeElements: compressedPoints
|
|
34703
34777
|
});
|
|
34704
34778
|
const realNode = this.instance.getStage().findOne(`#${tempStroke.getAttrs().id}`);
|
|
34705
34779
|
if (realNode) realNode.destroy();
|
|
@@ -34735,6 +34809,7 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34735
34809
|
}
|
|
34736
34810
|
cleanup() {
|
|
34737
34811
|
const stage = this.instance.getStage();
|
|
34812
|
+
stage.container().style.touchAction = this.prevTouchAction;
|
|
34738
34813
|
stage.container().style.cursor = "default";
|
|
34739
34814
|
this.instance.emitEvent("onAddedBrush");
|
|
34740
34815
|
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
|
@@ -39756,10 +39831,8 @@ var WeaveStageMinimapPlugin = class extends WeavePlugin {
|
|
|
39756
39831
|
skipStroke: true
|
|
39757
39832
|
});
|
|
39758
39833
|
if (box.width === 0 || box.height === 0) return;
|
|
39759
|
-
console.log("update minimap viewport reference", this.minimapStage);
|
|
39760
39834
|
const width = this.minimapStage?.width();
|
|
39761
39835
|
const height = this.minimapStage?.height();
|
|
39762
|
-
console.log("update minimap viewport reference", width, height);
|
|
39763
39836
|
const fitScale = Math.min(width / box.width, height / box.height);
|
|
39764
39837
|
const centerOffset = {
|
|
39765
39838
|
x: (width - box.width * fitScale) / 2,
|