@inditextech/weave-sdk 4.0.1 → 4.1.0
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 +69 -10
- package/dist/sdk.node.js +69 -10
- package/dist/sdk.node.stats.html +1 -1
- package/dist/sdk.stats.html +1 -1
- package/dist/types.d.ts +9 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +69 -10
- package/dist/types.js.map +1 -1
- package/dist/types.stats.html +1 -1
- package/package.json +5 -3
package/dist/sdk.js
CHANGED
|
@@ -4,6 +4,7 @@ import { WEAVE_ASYNC_STATUS, WEAVE_AWARENESS_LAYER_ID, WEAVE_EXPORT_BACKGROUND_C
|
|
|
4
4
|
import { getYjsDoc, getYjsValue, observeDeep, syncedStore } from "@syncedstore/core";
|
|
5
5
|
import * as Y$1 from "yjs";
|
|
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
|
|
|
@@ -22187,7 +22188,7 @@ var WeaveRegisterManager = class {
|
|
|
22187
22188
|
|
|
22188
22189
|
//#endregion
|
|
22189
22190
|
//#region package.json
|
|
22190
|
-
var version = "4.0
|
|
22191
|
+
var version = "4.1.0";
|
|
22191
22192
|
|
|
22192
22193
|
//#endregion
|
|
22193
22194
|
//#region src/managers/setup.ts
|
|
@@ -28442,8 +28443,8 @@ var WeaveStrokeNode = class extends WeaveNode {
|
|
|
28442
28443
|
const segLen = Math.hypot(dx, dy) || 1;
|
|
28443
28444
|
const nx = -dy / segLen;
|
|
28444
28445
|
const ny = dx / segLen;
|
|
28445
|
-
const w0 = baseW * p0.pressure / 2;
|
|
28446
|
-
const w1 = baseW * p1.pressure / 2;
|
|
28446
|
+
const w0 = Math.max(baseW * p0.pressure / 2, .5);
|
|
28447
|
+
const w1 = Math.max(baseW * p1.pressure / 2, .5);
|
|
28447
28448
|
let traveled = 0;
|
|
28448
28449
|
while (traveled < segLen) {
|
|
28449
28450
|
const step = Math.min(dashRemaining, segLen - traveled);
|
|
@@ -34521,6 +34522,11 @@ const BRUSH_TOOL_DEFAULT_CONFIG = { interpolationSteps: 10 };
|
|
|
34521
34522
|
var WeaveBrushToolAction = class extends WeaveAction {
|
|
34522
34523
|
initialized = false;
|
|
34523
34524
|
isSpacePressed = false;
|
|
34525
|
+
penActive = false;
|
|
34526
|
+
lastSmoothedPressure = .5;
|
|
34527
|
+
lastPointerPos = null;
|
|
34528
|
+
lastPointerTime = 0;
|
|
34529
|
+
predictedCount = 0;
|
|
34524
34530
|
onPropsChange = void 0;
|
|
34525
34531
|
onInit = void 0;
|
|
34526
34532
|
constructor(params) {
|
|
@@ -34550,11 +34556,29 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34550
34556
|
};
|
|
34551
34557
|
}
|
|
34552
34558
|
getEventPressure(e) {
|
|
34553
|
-
|
|
34554
|
-
|
|
34559
|
+
const now$2 = performance.now();
|
|
34560
|
+
let velocity = 0;
|
|
34561
|
+
if (this.lastPointerPos && now$2 - this.lastPointerTime > 0) {
|
|
34562
|
+
const dx = e.evt.clientX - this.lastPointerPos.x;
|
|
34563
|
+
const dy = e.evt.clientY - this.lastPointerPos.y;
|
|
34564
|
+
velocity = Math.hypot(dx, dy) / (now$2 - this.lastPointerTime) * 1e3;
|
|
34565
|
+
}
|
|
34566
|
+
this.lastPointerPos = {
|
|
34567
|
+
x: e.evt.clientX,
|
|
34568
|
+
y: e.evt.clientY
|
|
34569
|
+
};
|
|
34570
|
+
this.lastPointerTime = now$2;
|
|
34571
|
+
const alpha = Math.min(Math.max(velocity / 1500, .15), .6);
|
|
34572
|
+
let raw;
|
|
34573
|
+
if (e.evt.pointerType === "pen") raw = e.evt.pressure || .5;
|
|
34574
|
+
else raw = .5;
|
|
34575
|
+
this.lastSmoothedPressure = alpha * raw + (1 - alpha) * this.lastSmoothedPressure;
|
|
34576
|
+
return Math.max(this.lastSmoothedPressure, .15);
|
|
34555
34577
|
}
|
|
34556
34578
|
setupEvents() {
|
|
34557
34579
|
const stage = this.instance.getStage();
|
|
34580
|
+
this.prevTouchAction = stage.container().style.touchAction;
|
|
34581
|
+
stage.container().style.touchAction = "none";
|
|
34558
34582
|
window.addEventListener("keyup", (e) => {
|
|
34559
34583
|
if (e.code === "Space" && this.instance.getActiveAction() === BRUSH_TOOL_ACTION_NAME) this.isSpacePressed = false;
|
|
34560
34584
|
}, { signal: this.instance.getEventsController()?.signal });
|
|
@@ -34580,6 +34604,8 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34580
34604
|
if (this.getZoomPlugin()?.isPinching()) return;
|
|
34581
34605
|
if (this.isSpacePressed) return;
|
|
34582
34606
|
if (e?.evt?.button !== 0) return;
|
|
34607
|
+
if (e.evt.pointerType === "touch" && this.penActive) return;
|
|
34608
|
+
if (e.evt.pointerType === "pen") this.penActive = true;
|
|
34583
34609
|
const pointPressure = this.getEventPressure(e);
|
|
34584
34610
|
this.handleStartStroke(pointPressure);
|
|
34585
34611
|
e.evt.stopPropagation();
|
|
@@ -34590,12 +34616,27 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34590
34616
|
this.setCursor();
|
|
34591
34617
|
if (this.state !== BRUSH_TOOL_STATE.DEFINE_STROKE) return;
|
|
34592
34618
|
if (this.getZoomPlugin()?.isPinching()) return;
|
|
34593
|
-
const
|
|
34594
|
-
|
|
34619
|
+
const coalescedEvents = e.evt.getCoalescedEvents ? e.evt.getCoalescedEvents() : [];
|
|
34620
|
+
if (coalescedEvents.length > 1) {
|
|
34621
|
+
for (const ce of coalescedEvents) {
|
|
34622
|
+
const pointPressure = ce.pointerType === "pen" && typeof ce.pressure === "number" ? ce.pressure : .5;
|
|
34623
|
+
this.handleMovement(pointPressure, void 0, false);
|
|
34624
|
+
}
|
|
34625
|
+
const predictedEvents = e.evt.getPredictedEvents ? e.evt.getPredictedEvents() : [];
|
|
34626
|
+
if (predictedEvents.length > 0) {
|
|
34627
|
+
const last = predictedEvents[predictedEvents.length - 1];
|
|
34628
|
+
const predPressure = last.pointerType === "pen" && typeof last.pressure === "number" ? last.pressure : .5;
|
|
34629
|
+
this.handleMovement(predPressure, last, true);
|
|
34630
|
+
}
|
|
34631
|
+
} else {
|
|
34632
|
+
const pointPressure = this.getEventPressure(e);
|
|
34633
|
+
this.handleMovement(pointPressure, void 0, false);
|
|
34634
|
+
}
|
|
34595
34635
|
e.evt.stopPropagation();
|
|
34596
34636
|
};
|
|
34597
34637
|
stage.on("pointermove", handlePointerMove);
|
|
34598
34638
|
const handlePointerUp = (e) => {
|
|
34639
|
+
this.penActive = false;
|
|
34599
34640
|
if (this.state !== BRUSH_TOOL_STATE.DEFINE_STROKE) return;
|
|
34600
34641
|
if (this.getZoomPlugin()?.isPinching()) return;
|
|
34601
34642
|
this.handleEndStroke();
|
|
@@ -34632,6 +34673,10 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34632
34673
|
};
|
|
34633
34674
|
}
|
|
34634
34675
|
handleStartStroke(pressure) {
|
|
34676
|
+
this.lastSmoothedPressure = .5;
|
|
34677
|
+
this.lastPointerPos = null;
|
|
34678
|
+
this.lastPointerTime = 0;
|
|
34679
|
+
this.predictedCount = 0;
|
|
34635
34680
|
const { mousePoint, container, measureContainer } = this.instance.getMousePointer();
|
|
34636
34681
|
this.clickPoint = mousePoint;
|
|
34637
34682
|
this.container = container;
|
|
@@ -34660,17 +34705,25 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34660
34705
|
}
|
|
34661
34706
|
this.setState(BRUSH_TOOL_STATE.DEFINE_STROKE);
|
|
34662
34707
|
}
|
|
34663
|
-
handleMovement(pressure) {
|
|
34708
|
+
handleMovement(pressure, predictedEvent, isPredicted = false) {
|
|
34664
34709
|
if (this.state !== BRUSH_TOOL_STATE.DEFINE_STROKE) return;
|
|
34710
|
+
const stage = this.instance.getStage();
|
|
34665
34711
|
const tempStroke = this.instance.getStage().findOne(`#${this.strokeId}`);
|
|
34666
34712
|
if (this.measureContainer && tempStroke) {
|
|
34713
|
+
if (predictedEvent) stage.setPointersPositions(predictedEvent);
|
|
34667
34714
|
const { mousePoint } = this.instance.getMousePointerRelativeToContainer(this.measureContainer);
|
|
34668
34715
|
const currentPoint = {
|
|
34669
34716
|
x: mousePoint.x - tempStroke.x(),
|
|
34670
34717
|
y: mousePoint.y - tempStroke.y(),
|
|
34671
34718
|
pressure
|
|
34672
34719
|
};
|
|
34673
|
-
|
|
34720
|
+
let newStrokeElements = [...tempStroke.getAttrs().strokeElements];
|
|
34721
|
+
if (!isPredicted && this.predictedCount > 0) {
|
|
34722
|
+
newStrokeElements = newStrokeElements.slice(0, -1 * this.predictedCount);
|
|
34723
|
+
this.predictedCount = 0;
|
|
34724
|
+
}
|
|
34725
|
+
newStrokeElements.push(currentPoint);
|
|
34726
|
+
if (isPredicted) this.predictedCount++;
|
|
34674
34727
|
const box = this.getBoundingBox(newStrokeElements);
|
|
34675
34728
|
tempStroke.setAttrs({
|
|
34676
34729
|
width: box.width,
|
|
@@ -34690,17 +34743,22 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34690
34743
|
if (nodeHandler) {
|
|
34691
34744
|
const box = this.getBoundingBox(tempStroke.getAttrs().strokeElements);
|
|
34692
34745
|
let newStrokeElements = [...tempStroke.getAttrs().strokeElements];
|
|
34746
|
+
if (this.predictedCount > 0) {
|
|
34747
|
+
newStrokeElements = newStrokeElements.slice(0, -1 * this.predictedCount);
|
|
34748
|
+
this.predictedCount = 0;
|
|
34749
|
+
}
|
|
34693
34750
|
newStrokeElements = newStrokeElements.map((point) => ({
|
|
34694
34751
|
...point,
|
|
34695
34752
|
x: point.x - box.x,
|
|
34696
34753
|
y: point.y - box.y
|
|
34697
34754
|
}));
|
|
34755
|
+
const compressedPoints = simplify(newStrokeElements, 1, true);
|
|
34698
34756
|
tempStroke.setAttrs({
|
|
34699
34757
|
width: box.width,
|
|
34700
34758
|
height: box.height,
|
|
34701
34759
|
x: box.x,
|
|
34702
34760
|
y: box.y,
|
|
34703
|
-
strokeElements:
|
|
34761
|
+
strokeElements: compressedPoints
|
|
34704
34762
|
});
|
|
34705
34763
|
const realNode = this.instance.getStage().findOne(`#${tempStroke.getAttrs().id}`);
|
|
34706
34764
|
if (realNode) realNode.destroy();
|
|
@@ -34736,6 +34794,7 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34736
34794
|
}
|
|
34737
34795
|
cleanup() {
|
|
34738
34796
|
const stage = this.instance.getStage();
|
|
34797
|
+
stage.container().style.touchAction = this.prevTouchAction;
|
|
34739
34798
|
stage.container().style.cursor = "default";
|
|
34740
34799
|
this.instance.emitEvent("onAddedBrush");
|
|
34741
34800
|
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|
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
|
|
|
@@ -22186,7 +22187,7 @@ var WeaveRegisterManager = class {
|
|
|
22186
22187
|
|
|
22187
22188
|
//#endregion
|
|
22188
22189
|
//#region package.json
|
|
22189
|
-
var version = "4.0
|
|
22190
|
+
var version = "4.1.0";
|
|
22190
22191
|
|
|
22191
22192
|
//#endregion
|
|
22192
22193
|
//#region src/managers/setup.ts
|
|
@@ -28441,8 +28442,8 @@ var WeaveStrokeNode = class extends WeaveNode {
|
|
|
28441
28442
|
const segLen = Math.hypot(dx, dy) || 1;
|
|
28442
28443
|
const nx = -dy / segLen;
|
|
28443
28444
|
const ny = dx / segLen;
|
|
28444
|
-
const w0 = baseW * p0.pressure / 2;
|
|
28445
|
-
const w1 = baseW * p1.pressure / 2;
|
|
28445
|
+
const w0 = Math.max(baseW * p0.pressure / 2, .5);
|
|
28446
|
+
const w1 = Math.max(baseW * p1.pressure / 2, .5);
|
|
28446
28447
|
let traveled = 0;
|
|
28447
28448
|
while (traveled < segLen) {
|
|
28448
28449
|
const step = Math.min(dashRemaining, segLen - traveled);
|
|
@@ -34520,6 +34521,11 @@ const BRUSH_TOOL_DEFAULT_CONFIG = { interpolationSteps: 10 };
|
|
|
34520
34521
|
var WeaveBrushToolAction = class extends WeaveAction {
|
|
34521
34522
|
initialized = false;
|
|
34522
34523
|
isSpacePressed = false;
|
|
34524
|
+
penActive = false;
|
|
34525
|
+
lastSmoothedPressure = .5;
|
|
34526
|
+
lastPointerPos = null;
|
|
34527
|
+
lastPointerTime = 0;
|
|
34528
|
+
predictedCount = 0;
|
|
34523
34529
|
onPropsChange = void 0;
|
|
34524
34530
|
onInit = void 0;
|
|
34525
34531
|
constructor(params) {
|
|
@@ -34549,11 +34555,29 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34549
34555
|
};
|
|
34550
34556
|
}
|
|
34551
34557
|
getEventPressure(e) {
|
|
34552
|
-
|
|
34553
|
-
|
|
34558
|
+
const now$2 = performance.now();
|
|
34559
|
+
let velocity = 0;
|
|
34560
|
+
if (this.lastPointerPos && now$2 - this.lastPointerTime > 0) {
|
|
34561
|
+
const dx = e.evt.clientX - this.lastPointerPos.x;
|
|
34562
|
+
const dy = e.evt.clientY - this.lastPointerPos.y;
|
|
34563
|
+
velocity = Math.hypot(dx, dy) / (now$2 - this.lastPointerTime) * 1e3;
|
|
34564
|
+
}
|
|
34565
|
+
this.lastPointerPos = {
|
|
34566
|
+
x: e.evt.clientX,
|
|
34567
|
+
y: e.evt.clientY
|
|
34568
|
+
};
|
|
34569
|
+
this.lastPointerTime = now$2;
|
|
34570
|
+
const alpha = Math.min(Math.max(velocity / 1500, .15), .6);
|
|
34571
|
+
let raw;
|
|
34572
|
+
if (e.evt.pointerType === "pen") raw = e.evt.pressure || .5;
|
|
34573
|
+
else raw = .5;
|
|
34574
|
+
this.lastSmoothedPressure = alpha * raw + (1 - alpha) * this.lastSmoothedPressure;
|
|
34575
|
+
return Math.max(this.lastSmoothedPressure, .15);
|
|
34554
34576
|
}
|
|
34555
34577
|
setupEvents() {
|
|
34556
34578
|
const stage = this.instance.getStage();
|
|
34579
|
+
this.prevTouchAction = stage.container().style.touchAction;
|
|
34580
|
+
stage.container().style.touchAction = "none";
|
|
34557
34581
|
window.addEventListener("keyup", (e) => {
|
|
34558
34582
|
if (e.code === "Space" && this.instance.getActiveAction() === BRUSH_TOOL_ACTION_NAME) this.isSpacePressed = false;
|
|
34559
34583
|
}, { signal: this.instance.getEventsController()?.signal });
|
|
@@ -34579,6 +34603,8 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34579
34603
|
if (this.getZoomPlugin()?.isPinching()) return;
|
|
34580
34604
|
if (this.isSpacePressed) return;
|
|
34581
34605
|
if (e?.evt?.button !== 0) return;
|
|
34606
|
+
if (e.evt.pointerType === "touch" && this.penActive) return;
|
|
34607
|
+
if (e.evt.pointerType === "pen") this.penActive = true;
|
|
34582
34608
|
const pointPressure = this.getEventPressure(e);
|
|
34583
34609
|
this.handleStartStroke(pointPressure);
|
|
34584
34610
|
e.evt.stopPropagation();
|
|
@@ -34589,12 +34615,27 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34589
34615
|
this.setCursor();
|
|
34590
34616
|
if (this.state !== BRUSH_TOOL_STATE.DEFINE_STROKE) return;
|
|
34591
34617
|
if (this.getZoomPlugin()?.isPinching()) return;
|
|
34592
|
-
const
|
|
34593
|
-
|
|
34618
|
+
const coalescedEvents = e.evt.getCoalescedEvents ? e.evt.getCoalescedEvents() : [];
|
|
34619
|
+
if (coalescedEvents.length > 1) {
|
|
34620
|
+
for (const ce of coalescedEvents) {
|
|
34621
|
+
const pointPressure = ce.pointerType === "pen" && typeof ce.pressure === "number" ? ce.pressure : .5;
|
|
34622
|
+
this.handleMovement(pointPressure, void 0, false);
|
|
34623
|
+
}
|
|
34624
|
+
const predictedEvents = e.evt.getPredictedEvents ? e.evt.getPredictedEvents() : [];
|
|
34625
|
+
if (predictedEvents.length > 0) {
|
|
34626
|
+
const last = predictedEvents[predictedEvents.length - 1];
|
|
34627
|
+
const predPressure = last.pointerType === "pen" && typeof last.pressure === "number" ? last.pressure : .5;
|
|
34628
|
+
this.handleMovement(predPressure, last, true);
|
|
34629
|
+
}
|
|
34630
|
+
} else {
|
|
34631
|
+
const pointPressure = this.getEventPressure(e);
|
|
34632
|
+
this.handleMovement(pointPressure, void 0, false);
|
|
34633
|
+
}
|
|
34594
34634
|
e.evt.stopPropagation();
|
|
34595
34635
|
};
|
|
34596
34636
|
stage.on("pointermove", handlePointerMove);
|
|
34597
34637
|
const handlePointerUp = (e) => {
|
|
34638
|
+
this.penActive = false;
|
|
34598
34639
|
if (this.state !== BRUSH_TOOL_STATE.DEFINE_STROKE) return;
|
|
34599
34640
|
if (this.getZoomPlugin()?.isPinching()) return;
|
|
34600
34641
|
this.handleEndStroke();
|
|
@@ -34631,6 +34672,10 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34631
34672
|
};
|
|
34632
34673
|
}
|
|
34633
34674
|
handleStartStroke(pressure) {
|
|
34675
|
+
this.lastSmoothedPressure = .5;
|
|
34676
|
+
this.lastPointerPos = null;
|
|
34677
|
+
this.lastPointerTime = 0;
|
|
34678
|
+
this.predictedCount = 0;
|
|
34634
34679
|
const { mousePoint, container, measureContainer } = this.instance.getMousePointer();
|
|
34635
34680
|
this.clickPoint = mousePoint;
|
|
34636
34681
|
this.container = container;
|
|
@@ -34659,17 +34704,25 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34659
34704
|
}
|
|
34660
34705
|
this.setState(BRUSH_TOOL_STATE.DEFINE_STROKE);
|
|
34661
34706
|
}
|
|
34662
|
-
handleMovement(pressure) {
|
|
34707
|
+
handleMovement(pressure, predictedEvent, isPredicted = false) {
|
|
34663
34708
|
if (this.state !== BRUSH_TOOL_STATE.DEFINE_STROKE) return;
|
|
34709
|
+
const stage = this.instance.getStage();
|
|
34664
34710
|
const tempStroke = this.instance.getStage().findOne(`#${this.strokeId}`);
|
|
34665
34711
|
if (this.measureContainer && tempStroke) {
|
|
34712
|
+
if (predictedEvent) stage.setPointersPositions(predictedEvent);
|
|
34666
34713
|
const { mousePoint } = this.instance.getMousePointerRelativeToContainer(this.measureContainer);
|
|
34667
34714
|
const currentPoint = {
|
|
34668
34715
|
x: mousePoint.x - tempStroke.x(),
|
|
34669
34716
|
y: mousePoint.y - tempStroke.y(),
|
|
34670
34717
|
pressure
|
|
34671
34718
|
};
|
|
34672
|
-
|
|
34719
|
+
let newStrokeElements = [...tempStroke.getAttrs().strokeElements];
|
|
34720
|
+
if (!isPredicted && this.predictedCount > 0) {
|
|
34721
|
+
newStrokeElements = newStrokeElements.slice(0, -1 * this.predictedCount);
|
|
34722
|
+
this.predictedCount = 0;
|
|
34723
|
+
}
|
|
34724
|
+
newStrokeElements.push(currentPoint);
|
|
34725
|
+
if (isPredicted) this.predictedCount++;
|
|
34673
34726
|
const box = this.getBoundingBox(newStrokeElements);
|
|
34674
34727
|
tempStroke.setAttrs({
|
|
34675
34728
|
width: box.width,
|
|
@@ -34689,17 +34742,22 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34689
34742
|
if (nodeHandler) {
|
|
34690
34743
|
const box = this.getBoundingBox(tempStroke.getAttrs().strokeElements);
|
|
34691
34744
|
let newStrokeElements = [...tempStroke.getAttrs().strokeElements];
|
|
34745
|
+
if (this.predictedCount > 0) {
|
|
34746
|
+
newStrokeElements = newStrokeElements.slice(0, -1 * this.predictedCount);
|
|
34747
|
+
this.predictedCount = 0;
|
|
34748
|
+
}
|
|
34692
34749
|
newStrokeElements = newStrokeElements.map((point) => ({
|
|
34693
34750
|
...point,
|
|
34694
34751
|
x: point.x - box.x,
|
|
34695
34752
|
y: point.y - box.y
|
|
34696
34753
|
}));
|
|
34754
|
+
const compressedPoints = simplify(newStrokeElements, 1, true);
|
|
34697
34755
|
tempStroke.setAttrs({
|
|
34698
34756
|
width: box.width,
|
|
34699
34757
|
height: box.height,
|
|
34700
34758
|
x: box.x,
|
|
34701
34759
|
y: box.y,
|
|
34702
|
-
strokeElements:
|
|
34760
|
+
strokeElements: compressedPoints
|
|
34703
34761
|
});
|
|
34704
34762
|
const realNode = this.instance.getStage().findOne(`#${tempStroke.getAttrs().id}`);
|
|
34705
34763
|
if (realNode) realNode.destroy();
|
|
@@ -34735,6 +34793,7 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34735
34793
|
}
|
|
34736
34794
|
cleanup() {
|
|
34737
34795
|
const stage = this.instance.getStage();
|
|
34796
|
+
stage.container().style.touchAction = this.prevTouchAction;
|
|
34738
34797
|
stage.container().style.cursor = "default";
|
|
34739
34798
|
this.instance.emitEvent("onAddedBrush");
|
|
34740
34799
|
const selectionPlugin = this.instance.getPlugin("nodesSelection");
|