@inditextech/weave-sdk 0.23.0 → 0.24.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.cjs CHANGED
@@ -16362,11 +16362,13 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
16362
16362
  if (!this.enabled) return;
16363
16363
  try {
16364
16364
  const continueToPaste = await this.readClipboardData();
16365
- if (!continueToPaste) {
16366
- this.instance.emitEvent("onPaste", new Error("Invalid elements to paste"));
16367
- return;
16365
+ if (continueToPaste) {
16366
+ const position = this.instance.getStage().getPointerPosition();
16367
+ if (position) {
16368
+ this.state = COPY_PASTE_NODES_PLUGIN_STATE.PASTING;
16369
+ this.handlePaste(position);
16370
+ }
16368
16371
  }
16369
- this.performPaste();
16370
16372
  } catch (ex) {
16371
16373
  this.instance.emitEvent("onPaste", ex);
16372
16374
  }
@@ -16374,11 +16376,17 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
16374
16376
  const items = await navigator.clipboard.read();
16375
16377
  if (items && items.length === 1) {
16376
16378
  const item = items[0];
16377
- this.instance.emitEvent("onPasteExternal", item);
16379
+ this.instance.getStage().setPointersPositions(e);
16380
+ const position = this.instance.getStage().getPointerPosition();
16381
+ if (position) this.instance.emitEvent("onPasteExternal", {
16382
+ position,
16383
+ item
16384
+ });
16378
16385
  }
16379
16386
  } catch (ex) {
16380
16387
  this.instance.emitEvent("onPaste", ex);
16381
16388
  }
16389
+ stage.container().focus();
16382
16390
  return;
16383
16391
  }
16384
16392
  if (e.key === "Escape") {
@@ -16386,14 +16394,6 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
16386
16394
  return;
16387
16395
  }
16388
16396
  });
16389
- stage.on("click tap", (e) => {
16390
- e.evt.preventDefault();
16391
- if (this.state === COPY_PASTE_NODES_PLUGIN_STATE.IDLE) return;
16392
- if (this.state === COPY_PASTE_NODES_PLUGIN_STATE.PASTING) {
16393
- this.handlePaste();
16394
- return;
16395
- }
16396
- });
16397
16397
  }
16398
16398
  mapToPasteNodes() {
16399
16399
  const nodesSelectionPlugin = this.getNodesSelectionPlugin();
@@ -16414,9 +16414,9 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
16414
16414
  if (child.props.children) this.recursivelyUpdateKeys(child.props.children);
16415
16415
  }
16416
16416
  }
16417
- handlePaste() {
16417
+ handlePaste(position) {
16418
16418
  if (this.toPaste) {
16419
- const { mousePoint, container } = this.instance.getMousePointer();
16419
+ const { mousePoint, container } = this.instance.getMousePointer(position);
16420
16420
  for (const element of Object.keys(this.toPaste.weave)) {
16421
16421
  const node = this.toPaste.weave[element];
16422
16422
  if (node.props.children) this.recursivelyUpdateKeys(node.props.children);
@@ -16463,23 +16463,28 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
16463
16463
  }
16464
16464
  }
16465
16465
  }
16466
- performPaste() {
16467
- if (!this.enabled) return;
16468
- const stage = this.instance.getStage();
16469
- stage.container().style.cursor = "crosshair";
16470
- stage.container().focus();
16471
- this.state = COPY_PASTE_NODES_PLUGIN_STATE.PASTING;
16472
- }
16473
16466
  async copy() {
16474
16467
  await this.performCopy();
16475
16468
  }
16476
- async paste() {
16477
- const continueToPaste = await this.readClipboardData();
16478
- if (!continueToPaste) {
16479
- this.instance.emitEvent("onPaste", new Error("Invalid elements to paste"));
16480
- return;
16469
+ async paste(position) {
16470
+ try {
16471
+ const continueToPaste = await this.readClipboardData();
16472
+ if (continueToPaste) this.handlePaste(position);
16473
+ } catch (ex) {
16474
+ this.instance.emitEvent("onPaste", ex);
16475
+ }
16476
+ try {
16477
+ const items = await navigator.clipboard.read();
16478
+ if (items && items.length === 1) {
16479
+ const item = items[0];
16480
+ if (position) this.instance.emitEvent("onPasteExternal", {
16481
+ position,
16482
+ item
16483
+ });
16484
+ }
16485
+ } catch (ex) {
16486
+ this.instance.emitEvent("onPaste", ex);
16481
16487
  }
16482
- this.performPaste();
16483
16488
  }
16484
16489
  getSelectedNodes() {
16485
16490
  return this.mapToPasteNodes();
@@ -16509,12 +16514,12 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
16509
16514
 
16510
16515
  //#endregion
16511
16516
  //#region src/nodes/node.ts
16512
- const setStageDefaultConfiguration = () => {
16517
+ const augmentKonvaStageClass = () => {
16513
16518
  konva.default.Stage.prototype.isMouseWheelPressed = function() {
16514
16519
  return false;
16515
16520
  };
16516
16521
  };
16517
- const setNodesDefaultConfiguration = (config) => {
16522
+ const augmentKonvaNodeClass = (config) => {
16518
16523
  const { transform } = config ?? {};
16519
16524
  konva.default.Node.prototype.getTransformerProperties = function() {
16520
16525
  return {
@@ -16550,6 +16555,14 @@ var WeaveNode = class {
16550
16555
  const copyPastePlugin = this.instance.getPlugin("copyPasteNodes");
16551
16556
  return copyPastePlugin.isPasting();
16552
16557
  }
16558
+ setupDefaultNodeAugmentation(node) {
16559
+ node.getTransformerProperties = () => {
16560
+ return __inditextech_weave_types.WEAVE_DEFAULT_TRANSFORM_PROPERTIES;
16561
+ };
16562
+ node.movedToContainer = () => {};
16563
+ node.updatePosition = () => {};
16564
+ node.resetCrop = () => {};
16565
+ }
16553
16566
  isNodeSelected(ele) {
16554
16567
  const selectionPlugin = this.instance.getPlugin("nodesSelection");
16555
16568
  let selected = false;
@@ -17399,32 +17412,8 @@ var WeaveCloningManager = class {
17399
17412
  this.logger = this.instance.getChildLogger("cloning-manager");
17400
17413
  this.logger.debug("Cloning manager created");
17401
17414
  }
17402
- allInstancesInSameParent(nodes) {
17403
- if (nodes.length === 0) return {
17404
- allInSame: false,
17405
- nodeId: void 0,
17406
- parentId: void 0
17407
- };
17408
- let allInSame = true;
17409
- const parentId = nodes[0]?.getParent()?.getAttrs().id;
17410
- const nodeId = nodes[0]?.getParent()?.getAttrs().nodeId;
17411
- for (const node of nodes) {
17412
- const nodeParentId = node?.getParent()?.getAttrs().id;
17413
- if (nodeParentId !== parentId) {
17414
- allInSame = false;
17415
- break;
17416
- }
17417
- }
17418
- return {
17419
- allInSame,
17420
- nodeId,
17421
- parentId
17422
- };
17423
- }
17424
17415
  nodesToGroupSerialized(instancesToClone) {
17425
17416
  if (instancesToClone.length === 0) return;
17426
- const { allInSame } = this.allInstancesInSameParent(instancesToClone);
17427
- if (!allInSame) return;
17428
17417
  const groupId = v4_default();
17429
17418
  const newGroup = new konva.default.Group({ id: groupId });
17430
17419
  const nodesWithZIndex = instancesToClone.map((node) => ({
@@ -17441,6 +17430,21 @@ var WeaveCloningManager = class {
17441
17430
  });
17442
17431
  const nodePos$1 = clonedNode$1.getAbsolutePosition();
17443
17432
  const nodeRotation$1 = clonedNode$1.getAbsoluteRotation();
17433
+ const parent$1 = node.getParent();
17434
+ if (node.getAttrs().nodeId) {
17435
+ const realParent = this.instance.getStage().findOne(`#${node.getAttrs().nodeId}`);
17436
+ if (realParent) {
17437
+ nodePos$1.x += realParent.x();
17438
+ nodePos$1.y += realParent.y();
17439
+ }
17440
+ }
17441
+ if (parent$1 && parent$1.getAttrs().nodeId) {
17442
+ const realParent = this.instance.getStage().findOne(`#${parent$1.getAttrs().nodeId}`);
17443
+ if (realParent) {
17444
+ nodePos$1.x += realParent.x();
17445
+ nodePos$1.y += realParent.y();
17446
+ }
17447
+ }
17444
17448
  clonedNode$1.moveTo(newGroup);
17445
17449
  clonedNode$1.zIndex(index);
17446
17450
  clonedNode$1.setAbsolutePosition(nodePos$1);
@@ -17450,6 +17454,21 @@ var WeaveCloningManager = class {
17450
17454
  const clonedNode = node.clone({ id: v4_default() });
17451
17455
  const nodePos = clonedNode.getAbsolutePosition();
17452
17456
  const nodeRotation = clonedNode.getAbsoluteRotation();
17457
+ const parent = node.getParent();
17458
+ if (node.getAttrs().nodeId) {
17459
+ const realParent = this.instance.getStage().findOne(`#${node.getAttrs().nodeId}`);
17460
+ if (realParent) {
17461
+ nodePos.x += realParent.x();
17462
+ nodePos.y += realParent.y();
17463
+ }
17464
+ }
17465
+ if (parent && parent.getAttrs().nodeId) {
17466
+ const realParent = this.instance.getStage().findOne(`#${parent.getAttrs().nodeId}`);
17467
+ if (realParent) {
17468
+ nodePos.x += realParent.x();
17469
+ nodePos.y += realParent.y();
17470
+ }
17471
+ }
17453
17472
  clonedNode.moveTo(newGroup);
17454
17473
  clonedNode.zIndex(index);
17455
17474
  clonedNode.setAbsolutePosition(nodePos);
@@ -17463,10 +17482,8 @@ var WeaveCloningManager = class {
17463
17482
  newGroup.getChildren().forEach((node) => {
17464
17483
  const nodeHandler = this.instance.getNodeHandler(node.getAttrs().nodeType);
17465
17484
  const nodePos = node.getClientRect();
17466
- if (nodePos.x < minPoint.x || nodePos.y < minPoint.y) {
17467
- minPoint.x = nodePos.x;
17468
- minPoint.y = nodePos.y;
17469
- }
17485
+ if (nodePos.x < minPoint.x) minPoint.x = nodePos.x;
17486
+ if (nodePos.y < minPoint.y) minPoint.y = nodePos.y;
17470
17487
  const serialized = nodeHandler.serialize(node);
17471
17488
  serializedNodes.push(serialized);
17472
17489
  });
@@ -17479,8 +17496,6 @@ var WeaveCloningManager = class {
17479
17496
  cloneNodes(instancesToClone, targetContainer, onPoint) {
17480
17497
  if (instancesToClone.length === 0) return;
17481
17498
  if (!targetContainer) return;
17482
- const { allInSame } = this.allInstancesInSameParent(instancesToClone);
17483
- if (!allInSame) return;
17484
17499
  const groupId = v4_default();
17485
17500
  const newGroup = new konva.default.Group({ id: groupId });
17486
17501
  targetContainer.add(newGroup);
@@ -17498,6 +17513,14 @@ var WeaveCloningManager = class {
17498
17513
  });
17499
17514
  const nodePos$1 = clonedNode$1.getAbsolutePosition();
17500
17515
  const nodeRotation$1 = clonedNode$1.getAbsoluteRotation();
17516
+ const parent$1 = node.getParent();
17517
+ if (parent$1 && parent$1.getAttrs().nodeId && !parent$1.getAttrs().containerId) {
17518
+ const realParent = this.instance.getStage().findOne(`#${parent$1.getAttrs().nodeId}`);
17519
+ if (realParent) {
17520
+ nodePos$1.x += realParent.x();
17521
+ nodePos$1.y += realParent.y();
17522
+ }
17523
+ }
17501
17524
  clonedNode$1.moveTo(newGroup);
17502
17525
  clonedNode$1.zIndex(index);
17503
17526
  clonedNode$1.setAbsolutePosition(nodePos$1);
@@ -17507,6 +17530,14 @@ var WeaveCloningManager = class {
17507
17530
  const clonedNode = node.clone({ id: v4_default() });
17508
17531
  const nodePos = clonedNode.getAbsolutePosition();
17509
17532
  const nodeRotation = clonedNode.getAbsoluteRotation();
17533
+ const parent = node.getParent();
17534
+ if (parent && parent.getAttrs().nodeId && !parent.getAttrs().containerId) {
17535
+ const realParent = this.instance.getStage().findOne(`#${parent.getAttrs().nodeId}`);
17536
+ if (realParent) {
17537
+ nodePos.x += realParent.x();
17538
+ nodePos.y += realParent.y();
17539
+ }
17540
+ }
17510
17541
  clonedNode.moveTo(newGroup);
17511
17542
  clonedNode.zIndex(index);
17512
17543
  clonedNode.setAbsolutePosition(nodePos);
@@ -18102,7 +18133,7 @@ var WeaveRegisterManager = class {
18102
18133
 
18103
18134
  //#endregion
18104
18135
  //#region package.json
18105
- var version = "0.23.0";
18136
+ var version = "0.24.0";
18106
18137
 
18107
18138
  //#endregion
18108
18139
  //#region src/managers/setup.ts
@@ -18513,7 +18544,8 @@ var Weave = class extends Emittery {
18513
18544
  this.status = __inditextech_weave_types.WEAVE_INSTANCE_STATUS.STARTING;
18514
18545
  this.emitEvent("onInstanceStatus", this.status);
18515
18546
  this.registerManager.registerNodesHandlers();
18516
- this.setNodesDefaultConfiguration();
18547
+ this.augmentKonvaStageClass();
18548
+ this.augmentKonvaNodeClass();
18517
18549
  this.registerManager.registerPlugins();
18518
18550
  this.registerManager.registerActionsHandlers();
18519
18551
  this.storeManager.registerStore(this.config.store);
@@ -18543,11 +18575,11 @@ var Weave = class extends Emittery {
18543
18575
  getConfiguration() {
18544
18576
  return this.config;
18545
18577
  }
18546
- setStageDefaultConfiguration() {
18547
- setStageDefaultConfiguration();
18578
+ augmentKonvaStageClass() {
18579
+ augmentKonvaStageClass();
18548
18580
  }
18549
- setNodesDefaultConfiguration(config) {
18550
- setNodesDefaultConfiguration(config);
18581
+ augmentKonvaNodeClass(config) {
18582
+ augmentKonvaNodeClass(config);
18551
18583
  }
18552
18584
  emitEvent(event, payload) {
18553
18585
  this.moduleLogger.debug({ payload }, `Emitted event [${event}]`);
@@ -18848,6 +18880,7 @@ var WeaveGroupNode = class extends WeaveNode {
18848
18880
  ...props,
18849
18881
  name: "node"
18850
18882
  });
18883
+ this.setupDefaultNodeAugmentation(group);
18851
18884
  group.getTransformerProperties = () => {
18852
18885
  return this.config.transform;
18853
18886
  };
@@ -18901,6 +18934,7 @@ var WeaveRectangleNode = class extends WeaveNode {
18901
18934
  ...props,
18902
18935
  name: "node"
18903
18936
  });
18937
+ this.setupDefaultNodeAugmentation(rectangle);
18904
18938
  rectangle.getTransformerProperties = () => {
18905
18939
  return this.config.transform;
18906
18940
  };
@@ -18931,13 +18965,14 @@ var WeaveEllipseNode = class extends WeaveNode {
18931
18965
  } };
18932
18966
  }
18933
18967
  onRender(props) {
18934
- const rectangle = new konva.default.Ellipse({
18968
+ const ellipse = new konva.default.Ellipse({
18935
18969
  ...props,
18936
18970
  name: "node",
18937
18971
  radiusX: props.radiusX,
18938
18972
  radiusY: props.radiusY
18939
18973
  });
18940
- rectangle.getTransformerProperties = () => {
18974
+ this.setupDefaultNodeAugmentation(ellipse);
18975
+ ellipse.getTransformerProperties = () => {
18941
18976
  const stage = this.instance.getStage();
18942
18977
  const node = stage.findOne(`#${props.id}`);
18943
18978
  if (node && node.getAttrs().keepAspectRatio) return {
@@ -18952,8 +18987,8 @@ var WeaveEllipseNode = class extends WeaveNode {
18952
18987
  };
18953
18988
  return this.config.transform;
18954
18989
  };
18955
- this.setupDefaultNodeEvents(rectangle);
18956
- return rectangle;
18990
+ this.setupDefaultNodeEvents(ellipse);
18991
+ return ellipse;
18957
18992
  }
18958
18993
  onUpdate(nodeInstance, nextProps) {
18959
18994
  nodeInstance.setAttrs({ ...nextProps });
@@ -18994,6 +19029,7 @@ var WeaveLineNode = class extends WeaveNode {
18994
19029
  ...props,
18995
19030
  name: "node"
18996
19031
  });
19032
+ this.setupDefaultNodeAugmentation(line);
18997
19033
  line.getTransformerProperties = () => {
18998
19034
  return this.config.transform;
18999
19035
  };
@@ -19077,6 +19113,7 @@ var WeaveTextNode = class extends WeaveNode {
19077
19113
  ...props,
19078
19114
  name: "node"
19079
19115
  });
19116
+ this.setupDefaultNodeAugmentation(text);
19080
19117
  text.getTransformerProperties = () => {
19081
19118
  const stage = this.instance.getStage();
19082
19119
  const actualText = stage.findOne(`#${text.id()}`);
@@ -19482,9 +19519,14 @@ var WeaveImageToolAction = class extends WeaveAction {
19482
19519
  };
19483
19520
  }
19484
19521
  onInit() {
19485
- this.instance.addEventListener("onStageDrop", () => {
19522
+ this.instance.addEventListener("onStageDrop", (e) => {
19486
19523
  if (window.weaveDragImageURL) {
19487
- this.instance.triggerAction("imageTool", { imageURL: window.weaveDragImageURL });
19524
+ this.instance.getStage().setPointersPositions(e);
19525
+ const position = this.instance.getStage().getPointerPosition();
19526
+ this.instance.triggerAction("imageTool", {
19527
+ imageURL: window.weaveDragImageURL,
19528
+ position
19529
+ });
19488
19530
  window.weaveDragImageURL = void 0;
19489
19531
  }
19490
19532
  });
@@ -19524,7 +19566,7 @@ var WeaveImageToolAction = class extends WeaveAction {
19524
19566
  setState(state) {
19525
19567
  this.state = state;
19526
19568
  }
19527
- loadImage(imageURL) {
19569
+ loadImage(imageURL, position) {
19528
19570
  const stage = this.instance.getStage();
19529
19571
  stage.container().style.cursor = "crosshair";
19530
19572
  stage.container().focus();
@@ -19542,7 +19584,7 @@ var WeaveImageToolAction = class extends WeaveAction {
19542
19584
  width: this.preloadImgs[this.imageId].width,
19543
19585
  height: this.preloadImgs[this.imageId].height
19544
19586
  };
19545
- this.addImageNode();
19587
+ this.addImageNode(position);
19546
19588
  };
19547
19589
  this.preloadImgs[this.imageId].onerror = () => {
19548
19590
  this.instance.emitEvent("onImageLoadEnd", new Error("Error loading image"));
@@ -19551,10 +19593,15 @@ var WeaveImageToolAction = class extends WeaveAction {
19551
19593
  this.preloadImgs[this.imageId].src = imageURL;
19552
19594
  this.instance.emitEvent("onImageLoadStart");
19553
19595
  }
19554
- addImageNode() {
19596
+ addImageNode(position) {
19555
19597
  const stage = this.instance.getStage();
19556
19598
  stage.container().style.cursor = "crosshair";
19557
19599
  stage.container().focus();
19600
+ if (position) {
19601
+ this.handleAdding(position);
19602
+ this.setState(IMAGE_TOOL_STATE.ADDING);
19603
+ return;
19604
+ }
19558
19605
  if (this.imageId) {
19559
19606
  const mousePos = stage.getRelativePointerPosition();
19560
19607
  const nodeHandler = this.instance.getNodeHandler("image");
@@ -19578,13 +19625,14 @@ var WeaveImageToolAction = class extends WeaveAction {
19578
19625
  this.clickPoint = null;
19579
19626
  this.setState(IMAGE_TOOL_STATE.ADDING);
19580
19627
  }
19581
- addImage() {
19628
+ addImage(position) {
19629
+ if (position) this.clickPoint = position;
19582
19630
  this.setState(IMAGE_TOOL_STATE.UPLOADING);
19583
19631
  }
19584
- handleAdding() {
19632
+ handleAdding(position) {
19585
19633
  const tempImage = this.instance.getStage().findOne(`#${this.tempImageId}`);
19586
- if (this.imageId && this.imageURL && this.preloadImgs[this.imageId] && tempImage) {
19587
- const { mousePoint, container } = this.instance.getMousePointer();
19634
+ if (this.imageId && this.imageURL && this.preloadImgs[this.imageId] && (!position && tempImage || position)) {
19635
+ const { mousePoint, container } = this.instance.getMousePointer(position);
19588
19636
  this.clickPoint = mousePoint;
19589
19637
  this.container = container;
19590
19638
  const nodeHandler = this.instance.getNodeHandler("image");
@@ -19606,8 +19654,10 @@ var WeaveImageToolAction = class extends WeaveAction {
19606
19654
  }
19607
19655
  });
19608
19656
  this.instance.addNode(node, this.container?.getAttrs().id);
19609
- const imageNodeHandler = this.instance.getNodeHandler("image");
19610
- this.instance.removeNode(imageNodeHandler.serialize(tempImage));
19657
+ if (!position) {
19658
+ const imageNodeHandler = this.instance.getNodeHandler("image");
19659
+ this.instance.removeNode(imageNodeHandler.serialize(tempImage));
19660
+ }
19611
19661
  this.setState(IMAGE_TOOL_STATE.FINISHED);
19612
19662
  }
19613
19663
  this.cancelAction();
@@ -19619,7 +19669,7 @@ var WeaveImageToolAction = class extends WeaveAction {
19619
19669
  const selectionPlugin = this.instance.getPlugin("nodesSelection");
19620
19670
  if (selectionPlugin) selectionPlugin.setSelectedNodes([]);
19621
19671
  if (params?.imageURL) {
19622
- this.loadImage(params.imageURL);
19672
+ this.loadImage(params.imageURL, params?.position ?? void 0);
19623
19673
  return;
19624
19674
  }
19625
19675
  this.props = this.initProps();
@@ -20001,6 +20051,7 @@ var WeaveImageNode = class extends WeaveNode {
20001
20051
  id,
20002
20052
  name: "node"
20003
20053
  });
20054
+ this.setupDefaultNodeAugmentation(image);
20004
20055
  image.movedToContainer = () => {
20005
20056
  const stage = this.instance.getStage();
20006
20057
  const image$1 = stage.findOne(`#${id}`);
@@ -20307,6 +20358,7 @@ var WeaveStarNode = class extends WeaveNode {
20307
20358
  innerRadius: props.innerRadius,
20308
20359
  outerRadius: props.outerRadius
20309
20360
  });
20361
+ this.setupDefaultNodeAugmentation(star);
20310
20362
  star.getTransformerProperties = () => {
20311
20363
  const stage = this.instance.getStage();
20312
20364
  const node = stage.findOne(`#${props.id}`);
@@ -20365,6 +20417,7 @@ var WeaveArrowNode = class extends WeaveNode {
20365
20417
  name: "node",
20366
20418
  points: props.points
20367
20419
  });
20420
+ this.setupDefaultNodeAugmentation(line);
20368
20421
  line.getTransformerProperties = () => {
20369
20422
  return this.config.transform;
20370
20423
  };
@@ -20420,6 +20473,7 @@ var WeaveRegularPolygonNode = class extends WeaveNode {
20420
20473
  sides: props.sides,
20421
20474
  radius: props.radius
20422
20475
  });
20476
+ this.setupDefaultNodeAugmentation(regularPolygon);
20423
20477
  regularPolygon.getTransformerProperties = () => {
20424
20478
  return {
20425
20479
  ...this.config.transform,
@@ -20593,6 +20647,7 @@ var WeaveFrameNode = class extends WeaveNode {
20593
20647
  draggable: false,
20594
20648
  clip: void 0
20595
20649
  });
20650
+ this.setupDefaultNodeAugmentation(frame);
20596
20651
  const frameInternalGroup = new konva.default.Group({
20597
20652
  id: `${id}-selector`,
20598
20653
  x: 0,
@@ -22362,8 +22417,8 @@ var WeaveStarToolAction = class extends WeaveAction {
22362
22417
  stroke: "#000000ff",
22363
22418
  strokeWidth: 1,
22364
22419
  numPoints: 5,
22365
- innerRadius: 70,
22366
- outerRadius: 184,
22420
+ innerRadius: 35,
22421
+ outerRadius: 92,
22367
22422
  keepAspectRatio: false
22368
22423
  };
22369
22424
  }
@@ -23429,7 +23484,7 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
23429
23484
  }
23430
23485
  });
23431
23486
  window.addEventListener("keyup", (e) => {
23432
- if (e.ctrlKey || e.metaKey) this.isCtrlOrMetaPressed = false;
23487
+ if (e.key === "Meta" || e.key === "Control") this.isCtrlOrMetaPressed = false;
23433
23488
  if (e.code === "Space") {
23434
23489
  this.isSpaceKeyPressed = false;
23435
23490
  this.disableMove();
@@ -23510,12 +23565,13 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
23510
23565
  stage.y(stage.y() - deltaY);
23511
23566
  this.instance.emit("onStageMove", void 0);
23512
23567
  });
23513
- window.addEventListener("wheel", (e) => {
23568
+ const handleWheel = (e) => {
23514
23569
  if (!this.enabled || !this.overStage || this.isCtrlOrMetaPressed || this.isSpaceKeyPressed || this.isMouseMiddleButtonPressed) return;
23515
23570
  stage.x(stage.x() - e.deltaX);
23516
23571
  stage.y(stage.y() - e.deltaY);
23517
23572
  this.instance.emit("onStageMove", void 0);
23518
- });
23573
+ };
23574
+ window.addEventListener("wheel", (0, import_lodash.throttle)(handleWheel, 10));
23519
23575
  }
23520
23576
  enable() {
23521
23577
  this.enabled = true;
@@ -23596,6 +23652,12 @@ var WeaveConnectedUsersPlugin = class extends WeavePlugin {
23596
23652
  const userInfo = this.config.getUser();
23597
23653
  store.setAwarenessInfo(WEAVE_CONNECTED_USER_INFO_KEY, userInfo);
23598
23654
  this.instance.emitEvent("onConnectedUsersChange", { [userInfo.name]: userInfo });
23655
+ this.instance.addEventListener("onConnectionStatusChange", (status) => {
23656
+ if (status === "connected") {
23657
+ const userInfo$1 = this.config.getUser();
23658
+ store.setAwarenessInfo(WEAVE_CONNECTED_USER_INFO_KEY, userInfo$1);
23659
+ } else store.setAwarenessInfo(WEAVE_CONNECTED_USER_INFO_KEY, void 0);
23660
+ });
23599
23661
  this.instance.addEventListener("onAwarenessChange", (changes) => {
23600
23662
  if (!this.enabled) {
23601
23663
  this.connectedUsers = {};
@@ -23834,6 +23896,9 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
23834
23896
  onInit() {
23835
23897
  const store = this.instance.getStore();
23836
23898
  const stage = this.instance.getStage();
23899
+ this.instance.addEventListener("onConnectionStatusChange", (status) => {
23900
+ if (status === "disconnected") store.setAwarenessInfo(WEAVE_USER_POINTER_KEY, void 0);
23901
+ });
23837
23902
  this.instance.addEventListener("onAwarenessChange", (changes) => {
23838
23903
  const selfUser = this.config.getUser();
23839
23904
  const allActiveUsers = [];
@@ -23852,6 +23917,9 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
23852
23917
  };
23853
23918
  }
23854
23919
  }
23920
+ const allPointers = Object.keys(this.usersPointers);
23921
+ const inactiveUsers = allPointers.filter((user) => !allActiveUsers.includes(user));
23922
+ for (let i = 0; i < inactiveUsers.length; i++) delete this.usersPointers[inactiveUsers[i]];
23855
23923
  this.renderPointers();
23856
23924
  });
23857
23925
  stage.on("dragmove", (e) => {
package/dist/sdk.d.cts CHANGED
@@ -291,6 +291,7 @@ declare abstract class WeaveNode implements WeaveNodeBase {
291
291
  getSelectionPlugin(): WeaveNodesSelectionPlugin;
292
292
  isSelecting(): boolean;
293
293
  isPasting(): boolean;
294
+ setupDefaultNodeAugmentation(node: Konva.Node): void;
294
295
  isNodeSelected(ele: Konva.Node): boolean;
295
296
  protected scaleReset(node: Konva.Node): void;
296
297
  setupDefaultNodeEvents(node: Konva.Node): void;
@@ -413,8 +414,8 @@ declare class Weave extends Emittery {
413
414
  destroy(): void;
414
415
  getId(): string;
415
416
  getConfiguration(): WeaveConfig;
416
- setStageDefaultConfiguration(): void;
417
- setNodesDefaultConfiguration(config?: WeaveNodeConfiguration): void;
417
+ augmentKonvaStageClass(): void;
418
+ augmentKonvaNodeClass(config?: WeaveNodeConfiguration): void;
418
419
  emitEvent<T>(event: string, payload?: T): void;
419
420
  addEventListener<T>(event: string, callback: (payload: T) => void): void;
420
421
  removeEventListener<T>(event: string, callback: (payload: T) => void): void;
@@ -1364,6 +1365,7 @@ type WeaveImageToolActionOnStartLoadImageEvent = undefined;
1364
1365
  type WeaveImageToolActionOnEndLoadImageEvent = Error | undefined;
1365
1366
  type WeaveImageToolActionTriggerParams = {
1366
1367
  imageURL?: string;
1368
+ position?: Vector2d;
1367
1369
  };
1368
1370
  type WeaveImageToolActionTriggerReturn = {
1369
1371
  finishUploadCallback: (imageURL: string) => void;
@@ -2050,7 +2052,10 @@ type WeaveCopyPasteNodesPluginStateKeys = keyof typeof COPY_PASTE_NODES_PLUGIN_S
2050
2052
  type WeaveCopyPasteNodesPluginState = (typeof COPY_PASTE_NODES_PLUGIN_STATE)[WeaveCopyPasteNodesPluginStateKeys];
2051
2053
  type WeaveCopyPasteNodesPluginOnCopyEvent = Error | undefined;
2052
2054
  type WeaveCopyPasteNodesPluginOnPasteEvent = Error | undefined;
2053
- type WeaveCopyPasteNodesPluginOnPasteExternalEvent = ClipboardItem;
2055
+ type WeaveCopyPasteNodesPluginOnPasteExternalEvent = {
2056
+ item: ClipboardItem;
2057
+ position: Vector2d;
2058
+ };
2054
2059
  type WeavePasteModel = {
2055
2060
  weaveInstanceId: string;
2056
2061
  weave: Record<string, WeaveStateElement>;
@@ -2081,9 +2086,8 @@ declare class WeaveCopyPasteNodesPlugin extends WeavePlugin {
2081
2086
  private recursivelyUpdateKeys;
2082
2087
  private handlePaste;
2083
2088
  private performCopy;
2084
- private performPaste;
2085
2089
  copy(): Promise<void>;
2086
- paste(): Promise<void>;
2090
+ paste(position: Vector2d): Promise<void>;
2087
2091
  getSelectedNodes(): WeaveToPasteNode[];
2088
2092
  isPasting(): boolean;
2089
2093
  private cancel;