@inditextech/weave-sdk 0.30.0 → 0.31.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
@@ -31,8 +31,6 @@ const __syncedstore_core = __toESM(require("@syncedstore/core"));
31
31
  const yjs = __toESM(require("yjs"));
32
32
  const react = __toESM(require("react"));
33
33
  const react_reconciler = __toESM(require("react-reconciler"));
34
- const konva_lib_shapes_Line = __toESM(require("konva/lib/shapes/Line"));
35
- const konva_lib_shapes_Circle = __toESM(require("konva/lib/shapes/Circle"));
36
34
 
37
35
  //#region ../../node_modules/emittery/maps.js
38
36
  const anyMap = new WeakMap();
@@ -15685,15 +15683,15 @@ var WeaveContextMenuPlugin = class extends WeavePlugin {
15685
15683
  }
15686
15684
  if (target !== stage && !clickOnTransformer) return;
15687
15685
  let nodes = [];
15688
- if (clickOnTransformer) {
15686
+ if (clickOnTransformer && selectionPlugin) {
15689
15687
  const transformer = selectionPlugin.getTransformer();
15690
15688
  nodes = transformer.getNodes().map((node) => {
15691
15689
  const nodeHandler = this.instance.getNodeHandler(node.getAttrs().nodeType);
15692
15690
  return {
15693
15691
  instance: node,
15694
- node: nodeHandler.serialize(node)
15692
+ node: nodeHandler?.serialize(node)
15695
15693
  };
15696
- }).filter((node) => node !== void 0);
15694
+ }).filter((node) => typeof node !== "undefined");
15697
15695
  }
15698
15696
  const containerRect = stage.container().getBoundingClientRect();
15699
15697
  const pointerPos = stage.getPointerPosition();
@@ -15826,10 +15824,12 @@ function moveNodeToContainer(instance, node) {
15826
15824
  node.y(node.y() - (layerToMoveAttrs.containerOffsetY ?? 0));
15827
15825
  node.movedToContainer(layerToMove);
15828
15826
  const nodeHandler = instance.getNodeHandler(node.getAttrs().nodeType);
15829
- const actualNode = nodeHandler.serialize(node);
15830
- instance.removeNode(actualNode);
15831
- instance.addNode(actualNode, layerToMoveAttrs.id);
15832
- return layerToMove;
15827
+ if (nodeHandler) {
15828
+ const actualNode = nodeHandler.serialize(node);
15829
+ instance.removeNode(actualNode);
15830
+ instance.addNode(actualNode, layerToMoveAttrs.id);
15831
+ return layerToMove;
15832
+ }
15833
15833
  }
15834
15834
  return void 0;
15835
15835
  }
@@ -15976,6 +15976,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
15976
15976
  }
15977
15977
  isPasting() {
15978
15978
  const copyPastePlugin = this.instance.getPlugin("copyPasteNodes");
15979
+ if (!copyPastePlugin) return false;
15979
15980
  return copyPastePlugin.isPasting();
15980
15981
  }
15981
15982
  isAreaSelecting() {
@@ -16086,6 +16087,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
16086
16087
  const layerToMove = moveNodeToContainer(this.instance, node);
16087
16088
  if (layerToMove) return resolve();
16088
16089
  const nodeHandler = this.instance.getNodeHandler(node.getAttrs().nodeType);
16090
+ if (!nodeHandler) return resolve();
16089
16091
  toUpdate.push(nodeHandler.serialize(node));
16090
16092
  resolve();
16091
16093
  }, 0);
@@ -16093,8 +16095,8 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
16093
16095
  };
16094
16096
  const promises = [];
16095
16097
  for (let i = 0; i < selectedNodes.length; i++) promises.push(nodeUpdatePromise(selectedNodes[i]));
16096
- Promise.all(promises).then(() => {
16097
- if (toUpdate.length > 0) this.instance.updateNodes(toUpdate);
16098
+ Promise.allSettled(promises).then((results) => {
16099
+ if (results.length > 0) this.instance.updateNodes(toUpdate);
16098
16100
  stage.container().style.cursor = actualCursor;
16099
16101
  });
16100
16102
  }
@@ -16111,17 +16113,17 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
16111
16113
  });
16112
16114
  this.initEvents();
16113
16115
  this.initialized = true;
16114
- this.instance.on("onActiveActionChange", (activeAction) => {
16116
+ this.instance.addEventListener("onActiveActionChange", (activeAction) => {
16115
16117
  if (typeof activeAction !== "undefined" && activeAction !== "selectionTool") {
16116
16118
  this.active = false;
16117
16119
  return;
16118
16120
  }
16119
16121
  this.active = true;
16120
16122
  });
16121
- this.instance.on("onStateChange", () => {
16123
+ this.instance.addEventListener("onStateChange", () => {
16122
16124
  this.triggerSelectedNodesEvent();
16123
16125
  });
16124
- this.instance.on("onNodeRemoved", (node) => {
16126
+ this.instance.addEventListener("onNodeRemoved", (node) => {
16125
16127
  const selectedNodes = this.getSelectedNodes();
16126
16128
  const newSelectedNodes = selectedNodes.filter((actNode) => {
16127
16129
  return actNode.getAttrs().id !== node.id;
@@ -16143,7 +16145,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
16143
16145
  const nodeHandler = this.instance.getNodeHandler(nodeType);
16144
16146
  return {
16145
16147
  instance: node,
16146
- node: nodeHandler.serialize(node)
16148
+ node: nodeHandler?.serialize(node)
16147
16149
  };
16148
16150
  });
16149
16151
  const usersSelectionPlugin = this.instance.getPlugin(WEAVE_USERS_SELECTION_KEY);
@@ -16154,8 +16156,8 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
16154
16156
  const selectedNodes = this.getSelectedNodes();
16155
16157
  const mappedSelectedNodes = selectedNodes.map((node) => {
16156
16158
  const handler = this.instance.getNodeHandler(node.getAttrs().nodeType);
16157
- return handler.serialize(node);
16158
- });
16159
+ return handler?.serialize(node);
16160
+ }).filter((node) => typeof node !== "undefined");
16159
16161
  this.instance.removeNodes(mappedSelectedNodes);
16160
16162
  this.tr.nodes([]);
16161
16163
  this.triggerSelectedNodesEvent();
@@ -16270,6 +16272,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
16270
16272
  });
16271
16273
  stage.on("click tap", (e) => {
16272
16274
  if (!this.enabled) return;
16275
+ if (this.instance.getActiveAction() !== "selectionTool") return;
16273
16276
  const contextMenuPlugin = this.instance.getPlugin("contextMenu");
16274
16277
  if (contextMenuPlugin && contextMenuPlugin.isContextMenuVisible()) {
16275
16278
  this.selecting = false;
@@ -16364,7 +16367,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
16364
16367
  const nodeHandler = this.instance.getNodeHandler(nodeType);
16365
16368
  return {
16366
16369
  instance: node,
16367
- node: nodeHandler.serialize(node)
16370
+ node: nodeHandler?.serialize(node)
16368
16371
  };
16369
16372
  });
16370
16373
  return selectedNodes;
@@ -16591,7 +16594,7 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
16591
16594
  }
16592
16595
  getNodesSelectionPlugin() {
16593
16596
  const nodesSelectionPlugin = this.instance.getPlugin("nodesSelection");
16594
- if (!nodesSelectionPlugin) throw new Error("Nodes selection plugin not found");
16597
+ if (!nodesSelectionPlugin) throw new Error("WeaveNodesSelectionPlugin plugin not found");
16595
16598
  return nodesSelectionPlugin;
16596
16599
  }
16597
16600
  enable() {
@@ -16641,6 +16644,7 @@ var WeaveNode = class {
16641
16644
  }
16642
16645
  getSelectionPlugin() {
16643
16646
  const selectionPlugin = this.instance.getPlugin("nodesSelection");
16647
+ if (!selectionPlugin) throw new Error("WeaveNodesSelectionPlugin plugin not found");
16644
16648
  return selectionPlugin;
16645
16649
  }
16646
16650
  isSelecting() {
@@ -16648,7 +16652,8 @@ var WeaveNode = class {
16648
16652
  }
16649
16653
  isPasting() {
16650
16654
  const copyPastePlugin = this.instance.getPlugin("copyPasteNodes");
16651
- return copyPastePlugin.isPasting();
16655
+ if (copyPastePlugin) return copyPastePlugin.isPasting();
16656
+ return false;
16652
16657
  }
16653
16658
  setupDefaultNodeAugmentation(node) {
16654
16659
  node.getTransformerProperties = () => {
@@ -16661,7 +16666,7 @@ var WeaveNode = class {
16661
16666
  isNodeSelected(ele) {
16662
16667
  const selectionPlugin = this.instance.getPlugin("nodesSelection");
16663
16668
  let selected = false;
16664
- if (selectionPlugin.getSelectedNodes().length === 1 && selectionPlugin.getSelectedNodes()[0].getAttrs().id === ele.getAttrs().id) selected = true;
16669
+ if (selectionPlugin && selectionPlugin.getSelectedNodes().length === 1 && selectionPlugin.getSelectedNodes()[0].getAttrs().id === ele.getAttrs().id) selected = true;
16665
16670
  return selected;
16666
16671
  }
16667
16672
  scaleReset(node) {
@@ -16692,7 +16697,7 @@ var WeaveNode = class {
16692
16697
  if (this.isSelecting() && this.isNodeSelected(node$1)) {
16693
16698
  this.scaleReset(node$1);
16694
16699
  const nodeHandler = this.instance.getNodeHandler(node$1.getAttrs().nodeType);
16695
- this.instance.updateNode(nodeHandler.serialize(node$1));
16700
+ if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(node$1));
16696
16701
  }
16697
16702
  };
16698
16703
  node.on("transform", (0, import_lodash.throttle)(handleTransform, 100));
@@ -16704,7 +16709,7 @@ var WeaveNode = class {
16704
16709
  if (nodesSnappingPlugin) nodesSnappingPlugin.cleanupEvaluateGuidelines();
16705
16710
  if (nodesSelectionPlugin) nodesSelectionPlugin.getTransformer().forceUpdate();
16706
16711
  const nodeHandler = this.instance.getNodeHandler(node$1.getAttrs().nodeType);
16707
- this.instance.updateNode(nodeHandler.serialize(node$1));
16712
+ if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(node$1));
16708
16713
  });
16709
16714
  node.on("dragstart", (e) => {
16710
16715
  const stage = this.instance.getStage();
@@ -16726,7 +16731,7 @@ var WeaveNode = class {
16726
16731
  const layerToMove = checkIfOverContainer(this.instance, e.target);
16727
16732
  if (layerToMove) layerToMove.fire(__inditextech_weave_types.WEAVE_NODE_CUSTOM_EVENTS.onTargetEnter, { bubbles: true });
16728
16733
  const nodeHandler = this.instance.getNodeHandler(node.getAttrs().nodeType);
16729
- this.instance.updateNode(nodeHandler.serialize(node));
16734
+ if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(node));
16730
16735
  }
16731
16736
  };
16732
16737
  node.on("dragmove", (0, import_lodash.throttle)(handleDragMove, 100));
@@ -16857,6 +16862,7 @@ var WeaveReconciler = class {
16857
16862
  this.logger = this.instance.getChildLogger("reconciler");
16858
16863
  }
16859
16864
  addNode(parentInstance, child) {
16865
+ if (!parentInstance || !child) return;
16860
16866
  const parentAttrs = parentInstance.getAttrs();
16861
16867
  const childInitialZIndex = child.getAttrs().initialZIndex;
16862
16868
  if (parentInstance instanceof konva.default.Stage && child instanceof konva.default.Layer) parentInstance.add(child);
@@ -17211,8 +17217,10 @@ var WeaveGroupsManager = class {
17211
17217
  });
17212
17218
  parentLayer?.add(groupInstance);
17213
17219
  const groupHandler = this.instance.getNodeHandler("group");
17214
- const groupNode = groupHandler.create(groupId, { draggable: true });
17215
- this.instance.addNode(groupNode, nodeId ?? parentNodeId);
17220
+ if (groupHandler) {
17221
+ const groupNode = groupHandler.create(groupId, { draggable: true });
17222
+ this.instance.addNode(groupNode, nodeId ?? parentNodeId);
17223
+ }
17216
17224
  const nodesWithZIndex = nodes.map((node) => {
17217
17225
  const instance = mainLayer?.findOne(`#${node.key}`);
17218
17226
  return {
@@ -17235,8 +17243,10 @@ var WeaveGroupsManager = class {
17235
17243
  konvaGroup.setAttr("id", v4_default());
17236
17244
  konvaGroup.setAttr("draggable", false);
17237
17245
  const handler = this.instance.getNodeHandler("group");
17238
- const stateNode = handler.serialize(konvaGroup);
17239
- this.instance.addNode(stateNode, groupId);
17246
+ if (handler) {
17247
+ const stateNode = handler.serialize(konvaGroup);
17248
+ this.instance.addNode(stateNode, groupId);
17249
+ }
17240
17250
  }
17241
17251
  continue;
17242
17252
  }
@@ -17251,18 +17261,20 @@ var WeaveGroupsManager = class {
17251
17261
  konvaNode.setAttr("id", v4_default());
17252
17262
  konvaNode.setAttr("draggable", false);
17253
17263
  const handler = this.instance.getNodeHandler(konvaNode.getAttrs().nodeType);
17254
- const stateNode = handler.serialize(konvaNode);
17255
- this.instance.addNode(stateNode, groupId);
17264
+ if (handler) {
17265
+ const stateNode = handler.serialize(konvaNode);
17266
+ this.instance.addNode(stateNode, groupId);
17267
+ }
17256
17268
  }
17257
17269
  }
17258
17270
  this.instance.removeNodes(sortedNodesByZIndex);
17259
17271
  groupInstance.destroy();
17260
17272
  setTimeout(() => {
17261
- const groupNode$1 = stage.findOne(`#${groupId}`);
17273
+ const groupNode = stage.findOne(`#${groupId}`);
17262
17274
  const selectionPlugin$1 = this.instance.getPlugin("nodesSelection");
17263
- if (groupNode$1 && selectionPlugin$1) {
17275
+ if (groupNode && selectionPlugin$1) {
17264
17276
  const tr = selectionPlugin$1.getTransformer();
17265
- selectionPlugin$1.setSelectedNodes([groupNode$1]);
17277
+ selectionPlugin$1.setSelectedNodes([groupNode]);
17266
17278
  tr.show();
17267
17279
  tr.forceUpdate();
17268
17280
  }
@@ -17302,13 +17314,17 @@ var WeaveGroupsManager = class {
17302
17314
  child.setAttr("draggable", true);
17303
17315
  newChildId = child.getAttrs().id;
17304
17316
  const handler = this.instance.getNodeHandler(child.getAttrs().nodeType);
17305
- const node = handler.serialize(child);
17306
- this.instance.addNode(node, nodeId ?? newLayer.getAttrs().id);
17317
+ if (handler) {
17318
+ const node = handler.serialize(child);
17319
+ this.instance.addNode(node, nodeId ?? newLayer.getAttrs().id);
17320
+ }
17307
17321
  child.destroy();
17308
17322
  }
17309
17323
  const groupHandler = this.instance.getNodeHandler("group");
17310
- const groupNode = groupHandler.serialize(konvaGroup);
17311
- this.instance.removeNode(groupNode);
17324
+ if (groupHandler) {
17325
+ const groupNode = groupHandler.serialize(konvaGroup);
17326
+ this.instance.removeNode(groupNode);
17327
+ }
17312
17328
  setTimeout(() => {
17313
17329
  const firstElement = newLayer.findOne(`#${newChildId}`);
17314
17330
  const selectionPlugin = this.instance.getPlugin("nodesSelection");
@@ -17580,8 +17596,10 @@ var WeaveCloningManager = class {
17580
17596
  const nodePos = node.getClientRect();
17581
17597
  if (nodePos.x < minPoint.x) minPoint.x = nodePos.x;
17582
17598
  if (nodePos.y < minPoint.y) minPoint.y = nodePos.y;
17583
- const serialized = nodeHandler.serialize(node);
17584
- serializedNodes.push(serialized);
17599
+ if (nodeHandler) {
17600
+ const serialized = nodeHandler.serialize(node);
17601
+ serializedNodes.push(serialized);
17602
+ }
17585
17603
  });
17586
17604
  newGroup.destroy();
17587
17605
  return {
@@ -17651,8 +17669,10 @@ var WeaveCloningManager = class {
17651
17669
  node.setAbsolutePosition(nodePos);
17652
17670
  node.rotation(nodeRotation);
17653
17671
  const handler = this.instance.getNodeHandler(node.getAttrs().nodeType);
17654
- const stateNode = handler.serialize(node);
17655
- this.instance.addNode(stateNode, targetContainer.getAttrs().id);
17672
+ if (handler) {
17673
+ const stateNode = handler.serialize(node);
17674
+ this.instance.addNode(stateNode, targetContainer.getAttrs().id);
17675
+ }
17656
17676
  node.destroy();
17657
17677
  }
17658
17678
  newGroup.destroy();
@@ -17869,30 +17889,38 @@ var WeaveZIndexManager = class {
17869
17889
  this.logger.debug(`Moving instance with id [${instance.getAttrs().id}], up one step of z-index`);
17870
17890
  instance.moveUp();
17871
17891
  const handler = this.instance.getNodeHandler(instance.getAttrs().nodeType);
17872
- const node = handler.serialize(instance);
17873
- this.instance.moveNode(node, __inditextech_weave_types.WEAVE_NODE_POSITION.UP);
17892
+ if (handler) {
17893
+ const node = handler.serialize(instance);
17894
+ this.instance.moveNode(node, __inditextech_weave_types.WEAVE_NODE_POSITION.UP);
17895
+ }
17874
17896
  }
17875
17897
  moveDown(instance) {
17876
17898
  this.logger.debug(`Moving instance with id [${instance.getAttrs().id}], down one step of z-index`);
17877
17899
  instance.moveDown();
17878
17900
  const handler = this.instance.getNodeHandler(instance.getAttrs().nodeType);
17879
- const node = handler.serialize(instance);
17880
- this.instance.moveNode(node, __inditextech_weave_types.WEAVE_NODE_POSITION.DOWN);
17901
+ if (handler) {
17902
+ const node = handler.serialize(instance);
17903
+ this.instance.moveNode(node, __inditextech_weave_types.WEAVE_NODE_POSITION.DOWN);
17904
+ }
17881
17905
  }
17882
17906
  sendToBack(instance) {
17883
17907
  this.logger.debug(`Moving instance with id [${instance.getAttrs().id}], to bottom of z-index`);
17884
17908
  instance.moveToBottom();
17885
17909
  const handler = this.instance.getNodeHandler(instance.getAttrs().nodeType);
17886
- const node = handler.serialize(instance);
17887
- this.instance.moveNode(node, __inditextech_weave_types.WEAVE_NODE_POSITION.BACK);
17910
+ if (handler) {
17911
+ const node = handler.serialize(instance);
17912
+ this.instance.moveNode(node, __inditextech_weave_types.WEAVE_NODE_POSITION.BACK);
17913
+ }
17888
17914
  }
17889
17915
  bringToFront(instance) {
17890
17916
  this.logger.debug(`Moving instance with id [${instance.getAttrs().id}], to top of z-index`);
17891
17917
  instance.moveToTop();
17892
17918
  const handler = this.instance.getNodeHandler(instance.getAttrs().nodeType);
17893
- const node = handler.serialize(instance);
17894
- this.instance.updateNode(node);
17895
- this.instance.moveNode(node, __inditextech_weave_types.WEAVE_NODE_POSITION.FRONT);
17919
+ if (handler) {
17920
+ const node = handler.serialize(instance);
17921
+ this.instance.updateNode(node);
17922
+ this.instance.moveNode(node, __inditextech_weave_types.WEAVE_NODE_POSITION.FRONT);
17923
+ }
17896
17924
  }
17897
17925
  };
17898
17926
 
@@ -18162,28 +18190,13 @@ var WeaveRegisterManager = class {
18162
18190
  return this.actionsHandlers;
18163
18191
  }
18164
18192
  getPlugin(pluginName) {
18165
- if (!this.plugins[pluginName]) {
18166
- const msg = `Plugin with name [${pluginName}] is not registered`;
18167
- this.logger.error(msg);
18168
- throw new Error(msg);
18169
- }
18170
- return this.plugins[pluginName];
18193
+ return this.plugins?.[pluginName];
18171
18194
  }
18172
18195
  getActionHandler(actionName) {
18173
- if (!this.actionsHandlers[actionName]) {
18174
- const msg = `Action handler with name [${actionName}] is not registered`;
18175
- this.logger.error(msg);
18176
- throw new Error(msg);
18177
- }
18178
- return this.actionsHandlers[actionName];
18196
+ return this.actionsHandlers?.[actionName];
18179
18197
  }
18180
18198
  getNodeHandler(nodeType) {
18181
- if (!this.nodesHandlers[nodeType]) {
18182
- const msg = `Node handler with type [${nodeType}] is not registered`;
18183
- this.logger.error(msg);
18184
- throw new Error(msg);
18185
- }
18186
- return this.nodesHandlers[nodeType];
18199
+ return this.nodesHandlers?.[nodeType];
18187
18200
  }
18188
18201
  registerPlugins() {
18189
18202
  const config = this.instance.getConfiguration();
@@ -18229,7 +18242,7 @@ var WeaveRegisterManager = class {
18229
18242
 
18230
18243
  //#endregion
18231
18244
  //#region package.json
18232
- var version = "0.30.0";
18245
+ var version = "0.31.0";
18233
18246
 
18234
18247
  //#endregion
18235
18248
  //#region src/managers/setup.ts
@@ -18349,11 +18362,7 @@ var WeaveActionsManager = class {
18349
18362
  }
18350
18363
  triggerAction(actionName, params) {
18351
18364
  const actionsHandlers = this.instance.getActionsHandlers();
18352
- if (!actionsHandlers[actionName]) {
18353
- const msg = `Action handler with name [${actionName}] not registered`;
18354
- this.logger.error(msg);
18355
- throw new Error(msg);
18356
- }
18365
+ if (!actionsHandlers[actionName]) return;
18357
18366
  if (typeof this.activeAction !== "undefined") this.cancelAction(this.activeAction);
18358
18367
  this.activeAction = actionName;
18359
18368
  const payload = actionsHandlers[actionName].trigger(this.cancelActionCallback(actionName), params);
@@ -18516,40 +18525,26 @@ var WeavePluginsManager = class {
18516
18525
  }
18517
18526
  enable(pluginName) {
18518
18527
  const plugins = this.instance.getPlugins();
18519
- if (!plugins[pluginName]) {
18520
- const msg = `Plugin with name [${pluginName}] not registered`;
18521
- this.logger.error(msg);
18522
- throw new Error(msg);
18523
- }
18524
- plugins[pluginName].enable?.();
18528
+ if (plugins[pluginName]) plugins[pluginName].enable();
18525
18529
  }
18526
18530
  disable(pluginName) {
18527
18531
  const plugins = this.instance.getPlugins();
18528
- if (!plugins[pluginName]) {
18529
- const msg = `Plugin with name [${pluginName}] not registered`;
18530
- this.logger.error(msg);
18531
- throw new Error(msg);
18532
- }
18533
- plugins[pluginName].disable?.();
18532
+ if (plugins[pluginName]) plugins[pluginName].disable();
18534
18533
  }
18535
18534
  isEnabled(pluginName) {
18536
18535
  const plugins = this.instance.getPlugins();
18537
- if (!plugins[pluginName]) {
18538
- const msg = `Plugin with name [${pluginName}] not registered`;
18539
- this.logger.error(msg);
18540
- throw new Error(msg);
18541
- }
18542
- return plugins[pluginName].isEnabled?.();
18536
+ if (plugins[pluginName]) return plugins[pluginName].isEnabled();
18537
+ return false;
18543
18538
  }
18544
18539
  };
18545
18540
 
18546
18541
  //#endregion
18547
18542
  //#region src/weave.ts
18548
- var Weave = class extends Emittery {
18543
+ var Weave = class {
18549
18544
  initialized = false;
18550
18545
  status = __inditextech_weave_types.WEAVE_INSTANCE_STATUS.IDLE;
18551
18546
  constructor(weaveConfig, stageConfig) {
18552
- super();
18547
+ this.emitter = new Emittery();
18553
18548
  konva.default.showWarnings = false;
18554
18549
  this.id = v4_default();
18555
18550
  this.initialized = false;
@@ -18636,7 +18631,7 @@ var Weave = class extends Emittery {
18636
18631
  }
18637
18632
  destroy() {
18638
18633
  this.moduleLogger.info(`Destroying the instance`);
18639
- this.clearListeners();
18634
+ this.emitter.clearListeners();
18640
18635
  this.status = __inditextech_weave_types.WEAVE_INSTANCE_STATUS.IDLE;
18641
18636
  this.emitEvent("onInstanceStatus", this.status);
18642
18637
  const store = this.storeManager.getStore();
@@ -18659,15 +18654,15 @@ var Weave = class extends Emittery {
18659
18654
  }
18660
18655
  emitEvent(event, payload) {
18661
18656
  this.moduleLogger.debug({ payload }, `Emitted event [${event}]`);
18662
- this.emit(event, payload);
18657
+ this.emitter.emit(event, payload);
18663
18658
  }
18664
18659
  addEventListener(event, callback) {
18665
18660
  this.moduleLogger.debug(`Listening event [${event}]`);
18666
- this.on(event, callback);
18661
+ this.emitter.on(event, callback);
18667
18662
  }
18668
18663
  removeEventListener(event, callback) {
18669
18664
  this.moduleLogger.debug(`Removing listening to event [${event}]`);
18670
- this.off(event, callback);
18665
+ this.emitter.off(event, callback);
18671
18666
  }
18672
18667
  getLogger() {
18673
18668
  return this.logger;
@@ -18930,6 +18925,7 @@ var WeaveLayerNode = class extends WeaveNode {
18930
18925
  const children = [...instance.getChildren()];
18931
18926
  for (const node of children) {
18932
18927
  const handler = this.instance.getNodeHandler(node.getAttr("nodeType"));
18928
+ if (!handler) continue;
18933
18929
  childrenMapped.push(handler.serialize(node));
18934
18930
  }
18935
18931
  return {
@@ -18984,6 +18980,7 @@ var WeaveGroupNode = class extends WeaveNode {
18984
18980
  const children = [...instance.getChildren()];
18985
18981
  for (const node of children) {
18986
18982
  const handler = this.instance.getNodeHandler(node.getAttr("nodeType"));
18983
+ if (!handler) continue;
18987
18984
  childrenMapped.push(handler.serialize(node));
18988
18985
  }
18989
18986
  return {
@@ -19179,6 +19176,7 @@ const TEXT_LAYOUT = {
19179
19176
  var WeaveTextNode = class extends WeaveNode {
19180
19177
  nodeType = WEAVE_TEXT_NODE_TYPE;
19181
19178
  editing = false;
19179
+ textArea = null;
19182
19180
  constructor(params) {
19183
19181
  super();
19184
19182
  const { config } = params ?? {};
@@ -19187,6 +19185,7 @@ var WeaveTextNode = class extends WeaveNode {
19187
19185
  ...config?.transform
19188
19186
  } };
19189
19187
  this.editing = false;
19188
+ this.textArea = null;
19190
19189
  }
19191
19190
  updateNode(nodeInstance) {
19192
19191
  const clonedText = nodeInstance.clone();
@@ -19224,14 +19223,11 @@ var WeaveTextNode = class extends WeaveNode {
19224
19223
  };
19225
19224
  text.on("transform", (0, import_lodash.throttle)(handleTextTransform, 50));
19226
19225
  window.addEventListener("keypress", (e) => {
19227
- if (e.key === "Enter" && this.instance.getActiveAction() === SELECTION_TOOL_ACTION_NAME && !this.editing) {
19226
+ if (e.key === "Enter" && this.instance.getActiveAction() === SELECTION_TOOL_ACTION_NAME && !this.editing && e.target !== this.textArea) {
19228
19227
  e.preventDefault();
19229
19228
  if (this.isSelecting() && this.isNodeSelected(text)) {
19230
19229
  const nodesSelectionPlugin = this.instance.getPlugin("nodesSelection");
19231
- if (nodesSelectionPlugin && nodesSelectionPlugin.getSelectedNodes().length === 1 && nodesSelectionPlugin.getSelectedNodes()[0].getAttrs().nodeType === WEAVE_TEXT_NODE_TYPE && !window.weaveTextEditing[nodesSelectionPlugin.getSelectedNodes()[0].id()]) {
19232
- e.preventDefault();
19233
- this.triggerEditMode(nodesSelectionPlugin.getSelectedNodes()[0]);
19234
- }
19230
+ if (nodesSelectionPlugin && nodesSelectionPlugin.getSelectedNodes().length === 1 && nodesSelectionPlugin.getSelectedNodes()[0].getAttrs().nodeType === WEAVE_TEXT_NODE_TYPE && !window.weaveTextEditing[nodesSelectionPlugin.getSelectedNodes()[0].id()]) this.triggerEditMode(nodesSelectionPlugin.getSelectedNodes()[0]);
19235
19231
  }
19236
19232
  }
19237
19233
  });
@@ -19345,6 +19341,25 @@ var WeaveTextNode = class extends WeaveNode {
19345
19341
  height
19346
19342
  };
19347
19343
  }
19344
+ mimicTextNode(textNode, textArea) {
19345
+ textArea.style.fontSize = textNode.fontSize() * textNode.getAbsoluteScale().x + "px";
19346
+ textArea.rows = textNode.text().split("\n").length;
19347
+ textArea.style.letterSpacing = `${textNode.letterSpacing()}`;
19348
+ textArea.style.opacity = `${textNode.getAttrs().opacity}`;
19349
+ textArea.style.lineHeight = `${textNode.lineHeight()}`;
19350
+ textArea.style.fontFamily = textNode.fontFamily();
19351
+ let fontWeight = "normal";
19352
+ let fontStyle = "normal";
19353
+ if ((textNode.fontStyle() ?? "normal").indexOf("bold") !== -1) fontWeight = "bold";
19354
+ if ((textNode.fontStyle() ?? "normal").indexOf("italic") !== -1) fontStyle = "italic";
19355
+ textArea.style.fontWeight = fontWeight;
19356
+ textArea.style.backgroundColor = "transparent";
19357
+ textArea.style.fontStyle = fontStyle;
19358
+ textArea.style.fontVariant = textNode.fontVariant();
19359
+ textArea.style.textDecoration = textNode.textDecoration();
19360
+ textArea.style.textAlign = textNode.align();
19361
+ textArea.style.color = `${textNode.fill()}`;
19362
+ }
19348
19363
  createTextAreaDOM(textNode, position) {
19349
19364
  const stage = this.instance.getStage();
19350
19365
  const textAreaSuperContainer = document.createElement("div");
@@ -19358,19 +19373,19 @@ var WeaveTextNode = class extends WeaveNode {
19358
19373
  textAreaSuperContainer.style.pointerEvents = "none";
19359
19374
  const textAreaContainer = document.createElement("div");
19360
19375
  textAreaContainer.id = `${textNode.id()}_container`;
19361
- const textArea = document.createElement("textarea");
19362
- textArea.id = textNode.id();
19363
- textAreaContainer.appendChild(textArea);
19376
+ this.textArea = document.createElement("textarea");
19377
+ this.textArea.id = textNode.id();
19378
+ textAreaContainer.appendChild(this.textArea);
19364
19379
  textAreaSuperContainer.appendChild(textAreaContainer);
19365
19380
  stage.container().appendChild(textAreaSuperContainer);
19366
19381
  textAreaContainer.style.pointerEvents = "auto";
19367
19382
  textAreaContainer.style.backgroundColor = "transparent";
19368
- textArea.style.pointerEvents = "auto";
19383
+ this.textArea.style.pointerEvents = "auto";
19369
19384
  this.instance.addEventListener("onZoomChange", this.onZoomChangeHandler(textNode).bind(this));
19370
19385
  this.instance.addEventListener("onStageMove", this.onStageMoveHandler(textNode).bind(this));
19371
19386
  window.weaveTextEditing[textNode.id()] = "editing";
19372
- textArea.value = textNode.text();
19373
- textArea.id = textNode.id();
19387
+ this.textArea.value = textNode.text();
19388
+ this.textArea.id = textNode.id();
19374
19389
  textAreaContainer.style.overflow = "hidden";
19375
19390
  textAreaContainer.style.display = "flex";
19376
19391
  textAreaContainer.style.justifyContent = "start";
@@ -19381,7 +19396,7 @@ var WeaveTextNode = class extends WeaveNode {
19381
19396
  textAreaContainer.style.top = position.y + "px";
19382
19397
  textAreaContainer.style.left = position.x + "px";
19383
19398
  if (!textNode.getAttrs().layout || textNode.getAttrs().layout === TEXT_LAYOUT.AUTO_ALL) {
19384
- textAreaContainer.style.width = textArea.scrollWidth + "px";
19399
+ textAreaContainer.style.width = this.textArea.scrollWidth + "px";
19385
19400
  textAreaContainer.style.height = (textNode.height() - textNode.padding() * 2) * textNode.getAbsoluteScale().x + 2 + "px";
19386
19401
  }
19387
19402
  if (textNode.getAttrs().layout === TEXT_LAYOUT.AUTO_HEIGHT) {
@@ -19392,54 +19407,40 @@ var WeaveTextNode = class extends WeaveNode {
19392
19407
  textAreaContainer.style.width = (textNode.width() - textNode.padding() * 2) * textNode.getAbsoluteScale().x + "px";
19393
19408
  textAreaContainer.style.height = (textNode.height() - textNode.padding() * 2) * textNode.getAbsoluteScale().x + 2 + "px";
19394
19409
  }
19395
- textArea.style.fontSize = textNode.fontSize() * textNode.getAbsoluteScale().x + "px";
19396
- textArea.rows = textNode.text().split("\n").length;
19397
19410
  textAreaContainer.style.border = "solid 1px #1e40af";
19398
- textArea.style.position = "absolute";
19399
- textArea.style.top = "0px";
19400
- textArea.style.left = "0px";
19401
- textArea.style.overscrollBehavior = "contains";
19402
- textArea.style.scrollBehavior = "auto";
19403
- textArea.style.caretColor = "black";
19404
- textArea.style.width = "100%";
19405
- textArea.style.letterSpacing = `${textNode.letterSpacing()}`;
19406
- textArea.style.minHeight = "auto";
19407
- textArea.style.margin = "0px";
19408
- textArea.style.padding = "0px";
19409
- textArea.style.boxSizing = "content-box";
19410
- textArea.style.overflow = "hidden";
19411
- textArea.style.background = "transparent";
19412
- textArea.style.border = "none";
19413
- textArea.style.outline = "none";
19414
- textArea.style.resize = "none";
19415
- textArea.style.lineHeight = `${textNode.lineHeight()}`;
19416
- textArea.style.fontFamily = textNode.fontFamily();
19417
- let fontWeight = "normal";
19418
- let fontStyle = "normal";
19419
- if ((textNode.fontStyle() ?? "normal").indexOf("bold") !== -1) fontWeight = "bold";
19420
- if ((textNode.fontStyle() ?? "normal").indexOf("italic") !== -1) fontStyle = "italic";
19421
- textArea.style.fontWeight = fontWeight;
19422
- textArea.style.backgroundColor = "transparent";
19423
- textArea.style.fontStyle = fontStyle;
19424
- textArea.style.fontVariant = textNode.fontVariant();
19425
- textArea.style.textDecoration = textNode.textDecoration();
19411
+ this.textArea.style.position = "absolute";
19412
+ this.textArea.style.top = "0px";
19413
+ this.textArea.style.left = "0px";
19414
+ this.textArea.style.overscrollBehavior = "contains";
19415
+ this.textArea.style.scrollBehavior = "auto";
19416
+ this.textArea.style.caretColor = "black";
19417
+ this.textArea.style.width = "100%";
19418
+ this.textArea.style.minHeight = "auto";
19419
+ this.textArea.style.margin = "0px";
19420
+ this.textArea.style.padding = "0px";
19421
+ this.textArea.style.boxSizing = "content-box";
19422
+ this.textArea.style.overflow = "hidden";
19423
+ this.textArea.style.background = "transparent";
19424
+ this.textArea.style.border = "none";
19425
+ this.textArea.style.outline = "none";
19426
+ this.textArea.style.resize = "none";
19427
+ this.textArea.style.backgroundColor = "transparent";
19426
19428
  textAreaContainer.style.transformOrigin = "left top";
19427
- textArea.style.textAlign = textNode.align();
19428
- textArea.style.color = `${textNode.fill()}`;
19429
- textArea.onfocus = () => {
19430
- this.textAreaDomResize(textAreaContainer, textArea, textNode);
19429
+ this.mimicTextNode(textNode, this.textArea);
19430
+ this.textArea.onfocus = () => {
19431
+ this.textAreaDomResize(textAreaContainer, this.textArea, textNode);
19431
19432
  };
19432
- textArea.onkeydown = () => {
19433
- this.textAreaDomResize(textAreaContainer, textArea, textNode);
19433
+ this.textArea.onkeydown = () => {
19434
+ this.textAreaDomResize(textAreaContainer, this.textArea, textNode);
19434
19435
  };
19435
- textArea.onkeyup = () => {
19436
- this.textAreaDomResize(textAreaContainer, textArea, textNode);
19436
+ this.textArea.onkeyup = () => {
19437
+ this.textAreaDomResize(textAreaContainer, this.textArea, textNode);
19437
19438
  };
19438
- textArea.onpaste = () => {
19439
- this.textAreaDomResize(textAreaContainer, textArea, textNode);
19439
+ this.textArea.onpaste = () => {
19440
+ this.textAreaDomResize(textAreaContainer, this.textArea, textNode);
19440
19441
  };
19441
- textArea.oninput = () => {
19442
- this.textAreaDomResize(textAreaContainer, textArea, textNode);
19442
+ this.textArea.oninput = () => {
19443
+ this.textAreaDomResize(textAreaContainer, this.textArea, textNode);
19443
19444
  };
19444
19445
  textAreaSuperContainer.addEventListener("scroll", () => {
19445
19446
  textAreaSuperContainer.scrollTop = 0;
@@ -19449,28 +19450,32 @@ var WeaveTextNode = class extends WeaveNode {
19449
19450
  textAreaContainer.scrollTop = 0;
19450
19451
  textAreaContainer.scrollLeft = 0;
19451
19452
  });
19452
- textArea.addEventListener("scroll", () => {
19453
- textArea.scrollTop = 0;
19454
- textArea.scrollLeft = 0;
19453
+ this.textArea.addEventListener("scroll", () => {
19454
+ if (!this.textArea) return;
19455
+ this.textArea.scrollTop = 0;
19456
+ this.textArea.scrollLeft = 0;
19455
19457
  });
19456
- const rotation = textNode.rotation();
19457
- let transform = "";
19458
- if (rotation) transform += "rotateZ(" + rotation + "deg)";
19458
+ const rotation = textNode.getAbsoluteRotation();
19459
+ if (rotation) {
19460
+ const transform$1 = "rotate(" + rotation + "deg)";
19461
+ textAreaContainer.style.transform = transform$1;
19462
+ }
19459
19463
  const measures = textNode.measureSize(textNode.text());
19460
19464
  const px = 0 * stage.scaleX();
19461
19465
  const py = 2 * (measures.fontBoundingBoxAscent - measures.hangingBaseline - measures.fontBoundingBoxDescent) * stage.scaleY();
19466
+ let transform = "";
19462
19467
  transform += "translateX(" + px + "px)";
19463
19468
  transform += "translateY(" + py + "px)";
19464
- textArea.style.transform = transform;
19469
+ this.textArea.style.transform = transform;
19465
19470
  const handleKeyDown = (e) => {
19466
- if (textArea && textNode && e.key === "Escape") {
19471
+ if (this.textArea && textNode && e.key === "Escape") {
19467
19472
  e.stopPropagation();
19468
19473
  if (!textNode.getAttrs().layout || textNode.getAttrs().layout === TEXT_LAYOUT.AUTO_ALL) {
19469
- const { width: textAreaWidth } = this.textRenderedSize(textArea.value, textNode);
19474
+ const { width: textAreaWidth } = this.textRenderedSize(this.textArea.value, textNode);
19470
19475
  textNode.width(textAreaWidth + 3.2);
19471
19476
  }
19472
- if (!textNode.getAttrs().layout || textNode.getAttrs().layout === TEXT_LAYOUT.AUTO_HEIGHT || textNode.getAttrs().layout === TEXT_LAYOUT.AUTO_ALL) textNode.height((textArea.scrollHeight + 1.6) * (1 / textNode.getAbsoluteScale().x));
19473
- textNode.text(textArea.value);
19477
+ if (!textNode.getAttrs().layout || textNode.getAttrs().layout === TEXT_LAYOUT.AUTO_HEIGHT || textNode.getAttrs().layout === TEXT_LAYOUT.AUTO_ALL) textNode.height((this.textArea.scrollHeight + 1.6) * (1 / textNode.getAbsoluteScale().x));
19478
+ textNode.text(this.textArea.value);
19474
19479
  this.removeTextAreaDOM(textNode);
19475
19480
  this.instance.removeEventListener("onZoomChange", this.onZoomChangeHandler(textNode).bind(this));
19476
19481
  this.instance.removeEventListener("onStageMove", this.onStageMoveHandler(textNode).bind(this));
@@ -19479,28 +19484,30 @@ var WeaveTextNode = class extends WeaveNode {
19479
19484
  }
19480
19485
  };
19481
19486
  const handleKeyUp = () => {
19482
- textNode.text(textArea.value);
19483
- if (textArea && textNode) {
19487
+ if (!this.textArea) return;
19488
+ textNode.text(this.textArea.value);
19489
+ if (this.textArea && textNode) {
19484
19490
  if (!textNode.getAttrs().layout || textNode.getAttrs().layout === TEXT_LAYOUT.AUTO_ALL || textNode.getAttrs().layout === TEXT_LAYOUT.AUTO_HEIGHT) {
19485
19491
  textAreaContainer.style.height = "auto";
19486
- textAreaContainer.style.height = textArea.scrollHeight + 1.6 * textNode.getAbsoluteScale().x + "px";
19492
+ textAreaContainer.style.height = this.textArea.scrollHeight + 1.6 * textNode.getAbsoluteScale().x + "px";
19487
19493
  }
19488
- this.textAreaDomResize(textAreaContainer, textArea, textNode);
19494
+ this.textAreaDomResize(textAreaContainer, this.textArea, textNode);
19489
19495
  }
19490
19496
  };
19491
- textArea.addEventListener("keydown", handleKeyDown);
19492
- textArea.addEventListener("keyup", handleKeyUp);
19493
- textArea.tabIndex = 1;
19494
- textArea.focus();
19497
+ this.textArea.addEventListener("keydown", handleKeyDown);
19498
+ this.textArea.addEventListener("keyup", handleKeyUp);
19499
+ this.textArea.tabIndex = 1;
19500
+ this.textArea.focus();
19495
19501
  const handleOutsideClick = (e) => {
19496
19502
  e.stopPropagation();
19503
+ if (!this.textArea) return;
19497
19504
  let clickedOnCanvas = false;
19498
19505
  if (e.target?.id !== `${textNode.id()}`) clickedOnCanvas = true;
19499
19506
  if (clickedOnCanvas) {
19500
- textNode.text(textArea.value);
19507
+ textNode.text(this.textArea.value);
19501
19508
  this.removeTextAreaDOM(textNode);
19502
- textArea.removeEventListener("keydown", handleKeyDown);
19503
- textArea.removeEventListener("keyup", handleKeyUp);
19509
+ this.textArea.removeEventListener("keydown", handleKeyDown);
19510
+ this.textArea.removeEventListener("keyup", handleKeyUp);
19504
19511
  window.removeEventListener("click", handleOutsideClick);
19505
19512
  window.removeEventListener("touchstart", handleOutsideClick);
19506
19513
  return;
@@ -19527,19 +19534,17 @@ var WeaveTextNode = class extends WeaveNode {
19527
19534
  if (textNode.getAttrs().verticalAlign === "top") textAreaContainer.style.alignItems = "start";
19528
19535
  if (textNode.getAttrs().verticalAlign === "middle") textAreaContainer.style.alignItems = "center";
19529
19536
  if (textNode.getAttrs().verticalAlign === "bottom") textAreaContainer.style.alignItems = "end";
19530
- textArea.style.fontSize = textNode.fontSize() * textNode.getAbsoluteScale().x + "px";
19531
- textArea.rows = textNode.text().split("\n").length;
19532
- textArea.style.lineHeight = `${textNode.lineHeight()}`;
19533
- textArea.style.fontFamily = textNode.fontFamily();
19534
- textArea.style.textAlign = textNode.align();
19535
- textArea.style.color = `${textNode.fill()}`;
19537
+ this.mimicTextNode(textNode, textArea);
19536
19538
  this.textAreaDomResize(textAreaContainer, textArea, textNode);
19537
19539
  this.textAreaDomResize(textAreaContainer, textArea, textNode);
19538
- const rotation = textNode.rotation();
19539
- let transform = "";
19540
- if (rotation) transform += "rotateZ(" + rotation + "deg)";
19540
+ const rotation = textNode.getAbsoluteRotation();
19541
+ if (rotation) {
19542
+ const transform$1 = "rotate(" + rotation + "deg)";
19543
+ textAreaContainer.style.transform = transform$1;
19544
+ }
19541
19545
  const px = 0;
19542
19546
  const py = -3 * stage.scaleY();
19547
+ let transform = "";
19543
19548
  transform += "translateX(" + px + "px)";
19544
19549
  transform += "translateY(" + py + "px)";
19545
19550
  textArea.style.transform = transform;
@@ -19681,7 +19686,7 @@ var WeaveImageToolAction = class extends WeaveAction {
19681
19686
  y: (mousePos?.y ?? 0) + 2
19682
19687
  });
19683
19688
  const nodeHandler = this.instance.getNodeHandler("rectangle");
19684
- this.instance.updateNode(nodeHandler.serialize(tempImage));
19689
+ if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(tempImage));
19685
19690
  }
19686
19691
  });
19687
19692
  this.initialized = true;
@@ -19727,20 +19732,22 @@ var WeaveImageToolAction = class extends WeaveAction {
19727
19732
  const nodeHandler = this.instance.getNodeHandler("image");
19728
19733
  this.tempImageId = v4_default();
19729
19734
  const aspectRatio = this.preloadImgs[this.imageId].width / this.preloadImgs[this.imageId].height;
19730
- const node = nodeHandler.create(this.tempImageId, {
19731
- x: (mousePos?.x ?? 0) + 5,
19732
- y: (mousePos?.y ?? 0) + 5,
19733
- width: 100 * aspectRatio,
19734
- height: 100,
19735
- opacity: 1,
19736
- adding: true,
19737
- imageURL: this.imageURL,
19738
- stroke: "#000000ff",
19739
- strokeWidth: 0,
19740
- strokeScaleEnabled: true,
19741
- listening: false
19742
- });
19743
- this.instance.addNode(node, this.container?.getAttrs().id);
19735
+ if (nodeHandler) {
19736
+ const node = nodeHandler.create(this.tempImageId, {
19737
+ x: (mousePos?.x ?? 0) + 5,
19738
+ y: (mousePos?.y ?? 0) + 5,
19739
+ width: 100 * aspectRatio,
19740
+ height: 100,
19741
+ opacity: 1,
19742
+ adding: true,
19743
+ imageURL: this.imageURL,
19744
+ stroke: "#000000ff",
19745
+ strokeWidth: 0,
19746
+ strokeScaleEnabled: true,
19747
+ listening: false
19748
+ });
19749
+ this.instance.addNode(node, this.container?.getAttrs().id);
19750
+ }
19744
19751
  }
19745
19752
  this.clickPoint = null;
19746
19753
  this.setState(IMAGE_TOOL_STATE.ADDING);
@@ -19756,27 +19763,29 @@ var WeaveImageToolAction = class extends WeaveAction {
19756
19763
  this.clickPoint = mousePoint;
19757
19764
  this.container = container;
19758
19765
  const nodeHandler = this.instance.getNodeHandler("image");
19759
- const node = nodeHandler.create(this.imageId, {
19760
- ...this.props,
19761
- x: this.clickPoint?.x ?? 0,
19762
- y: this.clickPoint?.y ?? 0,
19763
- opacity: 1,
19764
- adding: false,
19765
- imageURL: this.imageURL,
19766
- stroke: "#000000ff",
19767
- strokeWidth: 0,
19768
- strokeScaleEnabled: true,
19769
- imageWidth: this.preloadImgs[this.imageId].width,
19770
- imageHeight: this.preloadImgs[this.imageId].height,
19771
- imageInfo: {
19772
- width: this.preloadImgs[this.imageId].width,
19773
- height: this.preloadImgs[this.imageId].height
19774
- }
19775
- });
19776
- this.instance.addNode(node, this.container?.getAttrs().id);
19766
+ if (nodeHandler) {
19767
+ const node = nodeHandler.create(this.imageId, {
19768
+ ...this.props,
19769
+ x: this.clickPoint?.x ?? 0,
19770
+ y: this.clickPoint?.y ?? 0,
19771
+ opacity: 1,
19772
+ adding: false,
19773
+ imageURL: this.imageURL,
19774
+ stroke: "#000000ff",
19775
+ strokeWidth: 0,
19776
+ strokeScaleEnabled: true,
19777
+ imageWidth: this.preloadImgs[this.imageId].width,
19778
+ imageHeight: this.preloadImgs[this.imageId].height,
19779
+ imageInfo: {
19780
+ width: this.preloadImgs[this.imageId].width,
19781
+ height: this.preloadImgs[this.imageId].height
19782
+ }
19783
+ });
19784
+ this.instance.addNode(node, this.container?.getAttrs().id);
19785
+ }
19777
19786
  if (!position) {
19778
19787
  const imageNodeHandler = this.instance.getNodeHandler("image");
19779
- this.instance.removeNode(imageNodeHandler.serialize(tempImage));
19788
+ if (imageNodeHandler) this.instance.removeNode(imageNodeHandler.serialize(tempImage));
19780
19789
  }
19781
19790
  this.setState(IMAGE_TOOL_STATE.FINISHED);
19782
19791
  }
@@ -19802,7 +19811,7 @@ var WeaveImageToolAction = class extends WeaveAction {
19802
19811
  const tempImage = this.instance.getStage().findOne(`#${this.tempImageId}`);
19803
19812
  if (tempImage) {
19804
19813
  const nodeHandler = this.instance.getNodeHandler("rectangle");
19805
- this.instance.removeNode(nodeHandler.serialize(tempImage));
19814
+ if (nodeHandler) this.instance.removeNode(nodeHandler.serialize(tempImage));
19806
19815
  }
19807
19816
  const selectionPlugin = this.instance.getPlugin("nodesSelection");
19808
19817
  if (selectionPlugin) {
@@ -20437,7 +20446,7 @@ var WeaveImageNode = class extends WeaveNode {
20437
20446
  });
20438
20447
  this.updateImageCrop(imageProps);
20439
20448
  const nodeHandler = this.instance.getNodeHandler(image.getAttrs().nodeType);
20440
- this.instance.updateNode(nodeHandler.serialize(image));
20449
+ if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(image));
20441
20450
  }
20442
20451
  };
20443
20452
  if (imageProps.imageURL) imageObj.src = imageProps.imageURL;
@@ -21001,6 +21010,7 @@ var WeaveFrameNode = class extends WeaveNode {
21001
21010
  const children = [...frameInternal.getChildren()];
21002
21011
  for (const node of children) {
21003
21012
  const handler = this.instance.getNodeHandler(node.getAttr("nodeType"));
21013
+ if (!handler) continue;
21004
21014
  childrenMapped.push(handler.serialize(node));
21005
21015
  }
21006
21016
  }
@@ -22914,6 +22924,7 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
22914
22924
  if (!this.enabled) return;
22915
22925
  const stage = this.instance.getStage();
22916
22926
  const selectionPlugin = this.instance.getPlugin("nodesSelection");
22927
+ if (!selectionPlugin) return;
22917
22928
  const nodes = selectionPlugin.getTransformer().getNodes();
22918
22929
  if (nodes.length === 0) return;
22919
22930
  let zoomTransformer = stage.findOne("#zoomTransformer");
@@ -23031,11 +23042,12 @@ var WeaveZoomOutToolAction = class extends WeaveAction {
23031
23042
  return ZOOM_OUT_TOOL_ACTION_NAME;
23032
23043
  }
23033
23044
  getStageZoomPlugin() {
23034
- return this.instance.getPlugin("stageZoom");
23045
+ const stageZoomPlugin = this.instance.getPlugin("stageZoom");
23046
+ if (!stageZoomPlugin) throw new Error("WeaveZoomOutToolAction requires the WeaveStageZoomPlugin to be loaded");
23047
+ return stageZoomPlugin;
23035
23048
  }
23036
23049
  onInit() {
23037
- const stageZoomPlugin = this.getStageZoomPlugin();
23038
- if (!stageZoomPlugin) throw new Error("WeaveZoomOutToolAction requires the WeaveStageZoomPlugin to be loaded");
23050
+ this.getStageZoomPlugin();
23039
23051
  }
23040
23052
  trigger(cancelAction, params) {
23041
23053
  const stageZoomPlugin = this.getStageZoomPlugin();
@@ -23064,11 +23076,12 @@ var WeaveZoomInToolAction = class extends WeaveAction {
23064
23076
  return ZOOM_IN_TOOL_ACTION_NAME;
23065
23077
  }
23066
23078
  getStageZoomPlugin() {
23067
- return this.instance.getPlugin("stageZoom");
23079
+ const stageZoomPlugin = this.instance.getPlugin("stageZoom");
23080
+ if (!stageZoomPlugin) throw new Error("WeaveZoomInToolAction requires the WeaveStageZoomPlugin to be loaded");
23081
+ return stageZoomPlugin;
23068
23082
  }
23069
23083
  onInit() {
23070
- const stageZoomPlugin = this.getStageZoomPlugin();
23071
- if (!stageZoomPlugin) throw new Error("WeaveZoomInToolAction requires the WeaveStageZoomPlugin to be loaded");
23084
+ this.getStageZoomPlugin();
23072
23085
  }
23073
23086
  trigger(cancelAction, params) {
23074
23087
  const stageZoomPlugin = this.getStageZoomPlugin();
@@ -23097,15 +23110,16 @@ var WeaveFitToScreenToolAction = class extends WeaveAction {
23097
23110
  return FIT_TO_SCREEN_TOOL_ACTION_NAME;
23098
23111
  }
23099
23112
  getStageZoomPlugin() {
23100
- return this.instance.getPlugin("stageZoom");
23113
+ const stageZoomPlugin = this.instance.getPlugin("stageZoom");
23114
+ if (!stageZoomPlugin) throw new Error("WeaveFitToScreenToolAction requires the WeaveStageZoomPlugin to be loaded");
23115
+ return stageZoomPlugin;
23101
23116
  }
23102
23117
  onInit() {
23103
- const stageZoomPlugin = this.getStageZoomPlugin();
23104
- if (!stageZoomPlugin) throw new Error("WeaveFitToScreenToolAction requires the WeaveStageZoomPlugin to be loaded");
23118
+ this.getStageZoomPlugin();
23105
23119
  }
23106
23120
  trigger(cancelAction, params) {
23107
23121
  const stageZoomPlugin = this.getStageZoomPlugin();
23108
- stageZoomPlugin.fitToScreen();
23122
+ if (stageZoomPlugin) stageZoomPlugin.fitToScreen();
23109
23123
  this.previousAction = params.previousAction;
23110
23124
  this.cancelAction = cancelAction;
23111
23125
  this.cancelAction();
@@ -23129,16 +23143,18 @@ var WeaveFitToSelectionToolAction = class extends WeaveAction {
23129
23143
  return FIT_TO_SELECTION_TOOL_ACTION_NAME;
23130
23144
  }
23131
23145
  getNodesSelectionPlugin() {
23132
- return this.instance.getPlugin("nodesSelection");
23146
+ const nodesSelectionPlugin = this.instance.getPlugin("nodesSelection");
23147
+ if (!nodesSelectionPlugin) throw new Error("WeaveFitToSelectionToolAction requires the WeaveNodesSelectionPlugin to be loaded");
23148
+ return nodesSelectionPlugin;
23133
23149
  }
23134
23150
  getStageZoomPlugin() {
23135
- return this.instance.getPlugin("stageZoom");
23151
+ const stageZoomPlugin = this.instance.getPlugin("stageZoom");
23152
+ if (!stageZoomPlugin) throw new Error("WeaveFitToSelectionToolAction requires the WeaveStageZoomPlugin to be loaded");
23153
+ return stageZoomPlugin;
23136
23154
  }
23137
23155
  onInit() {
23138
- const stageZoomPlugin = this.getStageZoomPlugin();
23139
- if (!stageZoomPlugin) throw new Error("WeaveFitToSelectionTool requires the WeaveStageZoomPlugin to be loaded");
23140
- const nodesSelectionPlugin = this.getNodesSelectionPlugin();
23141
- if (!nodesSelectionPlugin) throw new Error("WeaveFitToSelectionTool requires the WeaveNodeSelectionPlugin to be loaded");
23156
+ this.getStageZoomPlugin();
23157
+ this.getNodesSelectionPlugin();
23142
23158
  }
23143
23159
  trigger(cancelAction, params) {
23144
23160
  const stageZoomPlugin = this.getStageZoomPlugin();
@@ -23302,8 +23318,10 @@ var WeaveEraserToolAction = class extends WeaveAction {
23302
23318
  if (!realNode) return;
23303
23319
  const nodeType = realNode.getAttrs().nodeType;
23304
23320
  const nodeHandler = this.instance.getNodeHandler(nodeType);
23305
- const nodeSerialized = nodeHandler.serialize(realNode);
23306
- this.instance.removeNode(nodeSerialized);
23321
+ if (nodeHandler) {
23322
+ const nodeSerialized = nodeHandler.serialize(realNode);
23323
+ this.instance.removeNode(nodeSerialized);
23324
+ }
23307
23325
  }
23308
23326
  });
23309
23327
  stage.container().addEventListener("keydown", (e) => {
@@ -23439,15 +23457,17 @@ var WeaveRectangleToolAction = class extends WeaveAction {
23439
23457
  this.container = container;
23440
23458
  this.rectId = v4_default();
23441
23459
  const nodeHandler = this.instance.getNodeHandler("rectangle");
23442
- const node = nodeHandler.create(this.rectId, {
23443
- ...this.props,
23444
- strokeScaleEnabled: true,
23445
- x: this.clickPoint?.x ?? 0,
23446
- y: this.clickPoint?.y ?? 0,
23447
- width: 0,
23448
- height: 0
23449
- });
23450
- this.instance.addNode(node, this.container?.getAttrs().id);
23460
+ if (nodeHandler) {
23461
+ const node = nodeHandler.create(this.rectId, {
23462
+ ...this.props,
23463
+ strokeScaleEnabled: true,
23464
+ x: this.clickPoint?.x ?? 0,
23465
+ y: this.clickPoint?.y ?? 0,
23466
+ width: 0,
23467
+ height: 0
23468
+ });
23469
+ this.instance.addNode(node, this.container?.getAttrs().id);
23470
+ }
23451
23471
  this.setState(RECTANGLE_TOOL_STATE.DEFINING_SIZE);
23452
23472
  }
23453
23473
  handleSettingSize() {
@@ -23474,7 +23494,7 @@ var WeaveRectangleToolAction = class extends WeaveAction {
23474
23494
  width: rectWidth,
23475
23495
  height: rectHeight
23476
23496
  });
23477
- this.instance.updateNode(nodeHandler.serialize(rectangle));
23497
+ if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(rectangle));
23478
23498
  }
23479
23499
  this.cancelAction();
23480
23500
  }
@@ -23490,7 +23510,7 @@ var WeaveRectangleToolAction = class extends WeaveAction {
23490
23510
  width: deltaX,
23491
23511
  height: deltaY
23492
23512
  });
23493
- this.instance.updateNode(nodeHandler.serialize(rectangle));
23513
+ if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(rectangle));
23494
23514
  }
23495
23515
  }
23496
23516
  trigger(cancelAction) {
@@ -23615,15 +23635,17 @@ var WeaveEllipseToolAction = class extends WeaveAction {
23615
23635
  this.container = container;
23616
23636
  this.ellipseId = v4_default();
23617
23637
  const nodeHandler = this.instance.getNodeHandler("ellipse");
23618
- const node = nodeHandler.create(this.ellipseId, {
23619
- ...this.props,
23620
- strokeScaleEnabled: true,
23621
- x: this.clickPoint?.x ?? 0 + this.props.radiusX,
23622
- y: this.clickPoint?.y ?? 0 + this.props.radiusY,
23623
- radiusX: 0,
23624
- radiusY: 0
23625
- });
23626
- this.instance.addNode(node, this.container?.getAttrs().id);
23638
+ if (nodeHandler) {
23639
+ const node = nodeHandler.create(this.ellipseId, {
23640
+ ...this.props,
23641
+ strokeScaleEnabled: true,
23642
+ x: this.clickPoint?.x ?? 0 + this.props.radiusX,
23643
+ y: this.clickPoint?.y ?? 0 + this.props.radiusY,
23644
+ radiusX: 0,
23645
+ radiusY: 0
23646
+ });
23647
+ this.instance.addNode(node, this.container?.getAttrs().id);
23648
+ }
23627
23649
  this.setState(ELLIPSE_TOOL_STATE.DEFINING_SIZE);
23628
23650
  }
23629
23651
  handleSettingSize() {
@@ -23650,7 +23672,7 @@ var WeaveEllipseToolAction = class extends WeaveAction {
23650
23672
  radiusX: ellipseRadiusX,
23651
23673
  radiusY: ellipseRadiusY
23652
23674
  });
23653
- this.instance.updateNode(nodeHandler.serialize(ellipse));
23675
+ if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(ellipse));
23654
23676
  }
23655
23677
  this.cancelAction();
23656
23678
  }
@@ -23676,7 +23698,7 @@ var WeaveEllipseToolAction = class extends WeaveAction {
23676
23698
  radiusX: deltaX,
23677
23699
  radiusY: deltaY
23678
23700
  });
23679
- this.instance.updateNode(nodeHandler.serialize(ellipse));
23701
+ if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(ellipse));
23680
23702
  }
23681
23703
  }
23682
23704
  trigger(cancelAction) {
@@ -23803,14 +23825,16 @@ var WeavePenToolAction = class extends WeaveAction {
23803
23825
  this.lineId = v4_default();
23804
23826
  this.tempLineId = v4_default();
23805
23827
  const nodeHandler = this.instance.getNodeHandler("line");
23806
- const node = nodeHandler.create(this.lineId, {
23807
- ...this.props,
23808
- strokeScaleEnabled: true,
23809
- x: this.clickPoint?.x ?? 0,
23810
- y: this.clickPoint?.y ?? 0,
23811
- points: [0, 0]
23812
- });
23813
- this.instance.addNode(node, this.container?.getAttrs().id);
23828
+ if (nodeHandler) {
23829
+ const node = nodeHandler.create(this.lineId, {
23830
+ ...this.props,
23831
+ strokeScaleEnabled: true,
23832
+ x: this.clickPoint?.x ?? 0,
23833
+ y: this.clickPoint?.y ?? 0,
23834
+ points: [0, 0]
23835
+ });
23836
+ this.instance.addNode(node, this.container?.getAttrs().id);
23837
+ }
23814
23838
  this.tempPoint = new konva.default.Circle({
23815
23839
  x: this.clickPoint?.x ?? 0,
23816
23840
  y: this.clickPoint?.y ?? 0,
@@ -23821,14 +23845,16 @@ var WeavePenToolAction = class extends WeaveAction {
23821
23845
  fill: "#cccccc"
23822
23846
  });
23823
23847
  this.measureContainer?.add(this.tempPoint);
23824
- const tempLine = nodeHandler.create(this.tempLineId, {
23825
- ...this.props,
23826
- x: this.clickPoint?.x ?? 0,
23827
- y: this.clickPoint?.y ?? 0,
23828
- strokeScaleEnabled: true,
23829
- points: [0, 0]
23830
- });
23831
- this.instance.addNode(tempLine, this.container?.getAttrs().id);
23848
+ if (nodeHandler) {
23849
+ const tempLine = nodeHandler.create(this.tempLineId, {
23850
+ ...this.props,
23851
+ x: this.clickPoint?.x ?? 0,
23852
+ y: this.clickPoint?.y ?? 0,
23853
+ strokeScaleEnabled: true,
23854
+ points: [0, 0]
23855
+ });
23856
+ this.instance.addNode(tempLine, this.container?.getAttrs().id);
23857
+ }
23832
23858
  this.tempNextPoint = new konva.default.Circle({
23833
23859
  x: this.clickPoint?.x ?? 0,
23834
23860
  y: this.clickPoint?.y ?? 0,
@@ -23854,7 +23880,7 @@ var WeavePenToolAction = class extends WeaveAction {
23854
23880
  points: newPoints
23855
23881
  });
23856
23882
  const nodeHandler = this.instance.getNodeHandler("line");
23857
- this.instance.updateNode(nodeHandler.serialize(tempMainLine));
23883
+ if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(tempMainLine));
23858
23884
  this.tempPoint.setAttrs({
23859
23885
  x: mousePoint.x,
23860
23886
  y: mousePoint.y
@@ -23869,7 +23895,7 @@ var WeavePenToolAction = class extends WeaveAction {
23869
23895
  y: mousePoint.y,
23870
23896
  points: [0, 0]
23871
23897
  });
23872
- this.instance.updateNode(nodeHandler.serialize(tempLine));
23898
+ if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(tempLine));
23873
23899
  }
23874
23900
  this.setState(PEN_TOOL_STATE.DEFINING_SIZE);
23875
23901
  }
@@ -23888,7 +23914,7 @@ var WeavePenToolAction = class extends WeaveAction {
23888
23914
  ]
23889
23915
  });
23890
23916
  const nodeHandler = this.instance.getNodeHandler("line");
23891
- this.instance.updateNode(nodeHandler.serialize(tempLine));
23917
+ if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(tempLine));
23892
23918
  this.tempNextPoint.setAttrs({
23893
23919
  x: mousePoint.x,
23894
23920
  y: mousePoint.y
@@ -23915,11 +23941,11 @@ var WeavePenToolAction = class extends WeaveAction {
23915
23941
  const tempMainLine = this.instance.getStage().findOne(`#${this.lineId}`);
23916
23942
  if (tempLine) {
23917
23943
  const nodeHandler = this.instance.getNodeHandler("line");
23918
- this.instance.removeNode(nodeHandler.serialize(tempLine));
23944
+ if (nodeHandler) this.instance.removeNode(nodeHandler.serialize(tempLine));
23919
23945
  }
23920
23946
  if (this.lineId && tempMainLine && tempMainLine.points().length < 4) {
23921
23947
  const nodeHandler = this.instance.getNodeHandler("line");
23922
- this.instance.removeNode(nodeHandler.serialize(tempMainLine));
23948
+ if (nodeHandler) this.instance.removeNode(nodeHandler.serialize(tempMainLine));
23923
23949
  }
23924
23950
  if (this.lineId && tempMainLine && tempMainLine.points().length >= 4) {
23925
23951
  const nodeHandler = this.instance.getNodeHandler("line");
@@ -23928,7 +23954,7 @@ var WeavePenToolAction = class extends WeaveAction {
23928
23954
  strokeWidth: 1,
23929
23955
  hitStrokeWidth: 16
23930
23956
  });
23931
- this.instance.updateNode(nodeHandler.serialize(tempMainLine));
23957
+ if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(tempMainLine));
23932
23958
  }
23933
23959
  const selectionPlugin = this.instance.getPlugin("nodesSelection");
23934
23960
  if (selectionPlugin) {
@@ -24027,14 +24053,16 @@ var WeaveBrushToolAction = class extends WeaveAction {
24027
24053
  this.measureContainer = measureContainer;
24028
24054
  this.strokeId = v4_default();
24029
24055
  const nodeHandler = this.instance.getNodeHandler("line");
24030
- const node = nodeHandler.create(this.strokeId, {
24031
- ...this.props,
24032
- strokeScaleEnabled: true,
24033
- x: this.clickPoint?.x ?? 0,
24034
- y: this.clickPoint?.y ?? 0,
24035
- points: [0, 0]
24036
- });
24037
- this.instance.addNode(node, this.container?.getAttrs().id);
24056
+ if (nodeHandler) {
24057
+ const node = nodeHandler.create(this.strokeId, {
24058
+ ...this.props,
24059
+ strokeScaleEnabled: true,
24060
+ x: this.clickPoint?.x ?? 0,
24061
+ y: this.clickPoint?.y ?? 0,
24062
+ points: [0, 0]
24063
+ });
24064
+ this.instance.addNode(node, this.container?.getAttrs().id);
24065
+ }
24038
24066
  this.setState(BRUSH_TOOL_STATE.DEFINE_STROKE);
24039
24067
  }
24040
24068
  handleEndStroke() {
@@ -24046,7 +24074,7 @@ var WeaveBrushToolAction = class extends WeaveAction {
24046
24074
  ...this.props,
24047
24075
  hitStrokeWidth: 10
24048
24076
  });
24049
- this.instance.updateNode(nodeHandler.serialize(tempStroke));
24077
+ if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(tempStroke));
24050
24078
  this.clickPoint = null;
24051
24079
  stage.container().tabIndex = 1;
24052
24080
  stage.container().focus();
@@ -24064,7 +24092,7 @@ var WeaveBrushToolAction = class extends WeaveAction {
24064
24092
  mousePoint.y - tempStroke.y()
24065
24093
  ]);
24066
24094
  const nodeHandler = this.instance.getNodeHandler("line");
24067
- this.instance.updateNode(nodeHandler.serialize(tempStroke));
24095
+ if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(tempStroke));
24068
24096
  }
24069
24097
  }
24070
24098
  trigger(cancel) {
@@ -24170,13 +24198,15 @@ var WeaveTextToolAction = class extends WeaveAction {
24170
24198
  this.container = container;
24171
24199
  this.textId = v4_default();
24172
24200
  const nodeHandler = this.instance.getNodeHandler("text");
24173
- const node = nodeHandler.create(this.textId, {
24174
- ...this.props,
24175
- x: this.clickPoint?.x ?? 0,
24176
- y: this.clickPoint?.y ?? 0,
24177
- draggable: true
24178
- });
24179
- this.instance.addNode(node, this.container?.getAttrs().id);
24201
+ if (nodeHandler) {
24202
+ const node = nodeHandler.create(this.textId, {
24203
+ ...this.props,
24204
+ x: this.clickPoint?.x ?? 0,
24205
+ y: this.clickPoint?.y ?? 0,
24206
+ draggable: true
24207
+ });
24208
+ this.instance.addNode(node, this.container?.getAttrs().id);
24209
+ }
24180
24210
  this.setState(TEXT_TOOL_STATE.FINISHED);
24181
24211
  this.cancelAction();
24182
24212
  }
@@ -24301,16 +24331,18 @@ var WeaveStarToolAction = class extends WeaveAction {
24301
24331
  this.container = container;
24302
24332
  this.starId = v4_default();
24303
24333
  const nodeHandler = this.instance.getNodeHandler("star");
24304
- const node = nodeHandler.create(this.starId, {
24305
- ...this.props,
24306
- strokeScaleEnabled: true,
24307
- x: this.clickPoint?.x ?? 0 + this.props.outerRadius,
24308
- y: this.clickPoint?.y ?? 0 + this.props.outerRadius,
24309
- numPoints: 5,
24310
- innerRadius: 0,
24311
- outerRadius: 0
24312
- });
24313
- this.instance.addNode(node, this.container?.getAttrs().id);
24334
+ if (nodeHandler) {
24335
+ const node = nodeHandler.create(this.starId, {
24336
+ ...this.props,
24337
+ strokeScaleEnabled: true,
24338
+ x: this.clickPoint?.x ?? 0 + this.props.outerRadius,
24339
+ y: this.clickPoint?.y ?? 0 + this.props.outerRadius,
24340
+ numPoints: 5,
24341
+ innerRadius: 0,
24342
+ outerRadius: 0
24343
+ });
24344
+ this.instance.addNode(node, this.container?.getAttrs().id);
24345
+ }
24314
24346
  this.setState(STAR_TOOL_STATE.DEFINING_SIZE);
24315
24347
  }
24316
24348
  handleSettingSize() {
@@ -24337,7 +24369,7 @@ var WeaveStarToolAction = class extends WeaveAction {
24337
24369
  outerRadius: starOuterRadius,
24338
24370
  innerRadius: starInnerRadius
24339
24371
  });
24340
- this.instance.updateNode(nodeHandler.serialize(star));
24372
+ if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(star));
24341
24373
  }
24342
24374
  this.cancelAction();
24343
24375
  }
@@ -24363,7 +24395,7 @@ var WeaveStarToolAction = class extends WeaveAction {
24363
24395
  outerRadius: deltaX,
24364
24396
  innerRadius: deltaY
24365
24397
  });
24366
- this.instance.updateNode(nodeHandler.serialize(star));
24398
+ if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(star));
24367
24399
  }
24368
24400
  }
24369
24401
  trigger(cancelAction) {
@@ -24496,14 +24528,16 @@ var WeaveArrowToolAction = class extends WeaveAction {
24496
24528
  this.tempArrowId = v4_default();
24497
24529
  const nodeHandler = this.instance.getNodeHandler("arrow");
24498
24530
  const lineNodeHandler = this.instance.getNodeHandler("line");
24499
- const node = lineNodeHandler.create(this.arrowId, {
24500
- ...this.props,
24501
- strokeScaleEnabled: true,
24502
- x: this.clickPoint?.x ?? 0,
24503
- y: this.clickPoint?.y ?? 0,
24504
- points: [0, 0]
24505
- });
24506
- this.instance.addNode(node, this.container?.getAttrs().id);
24531
+ if (lineNodeHandler) {
24532
+ const node = lineNodeHandler.create(this.arrowId, {
24533
+ ...this.props,
24534
+ strokeScaleEnabled: true,
24535
+ x: this.clickPoint?.x ?? 0,
24536
+ y: this.clickPoint?.y ?? 0,
24537
+ points: [0, 0]
24538
+ });
24539
+ this.instance.addNode(node, this.container?.getAttrs().id);
24540
+ }
24507
24541
  this.tempPoint = new konva.default.Circle({
24508
24542
  x: this.clickPoint?.x ?? 0,
24509
24543
  y: this.clickPoint?.y ?? 0,
@@ -24514,14 +24548,16 @@ var WeaveArrowToolAction = class extends WeaveAction {
24514
24548
  fill: "#cccccc"
24515
24549
  });
24516
24550
  this.measureContainer?.add(this.tempPoint);
24517
- const tempArrow = nodeHandler.create(this.tempArrowId, {
24518
- ...this.props,
24519
- x: this.clickPoint?.x ?? 0,
24520
- y: this.clickPoint?.y ?? 0,
24521
- strokeScaleEnabled: true,
24522
- points: [0, 0]
24523
- });
24524
- this.instance.addNode(tempArrow, this.container?.getAttrs().id);
24551
+ if (nodeHandler) {
24552
+ const tempArrow = nodeHandler.create(this.tempArrowId, {
24553
+ ...this.props,
24554
+ x: this.clickPoint?.x ?? 0,
24555
+ y: this.clickPoint?.y ?? 0,
24556
+ strokeScaleEnabled: true,
24557
+ points: [0, 0]
24558
+ });
24559
+ this.instance.addNode(tempArrow, this.container?.getAttrs().id);
24560
+ }
24525
24561
  this.tempNextPoint = new konva.default.Circle({
24526
24562
  x: this.clickPoint?.x ?? 0,
24527
24563
  y: this.clickPoint?.y ?? 0,
@@ -24548,7 +24584,7 @@ var WeaveArrowToolAction = class extends WeaveAction {
24548
24584
  });
24549
24585
  const nodeHandler = this.instance.getNodeHandler("arrow");
24550
24586
  const lineNodeHandler = this.instance.getNodeHandler("line");
24551
- this.instance.updateNode(lineNodeHandler.serialize(tempMainArrow));
24587
+ if (lineNodeHandler) this.instance.updateNode(lineNodeHandler.serialize(tempMainArrow));
24552
24588
  this.tempPoint.setAttrs({
24553
24589
  x: mousePoint.x,
24554
24590
  y: mousePoint.y
@@ -24563,7 +24599,7 @@ var WeaveArrowToolAction = class extends WeaveAction {
24563
24599
  y: mousePoint.y,
24564
24600
  points: [0, 0]
24565
24601
  });
24566
- this.instance.updateNode(nodeHandler.serialize(tempArrow));
24602
+ if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(tempArrow));
24567
24603
  }
24568
24604
  this.setState(ARROW_TOOL_STATE.DEFINING_SIZE);
24569
24605
  }
@@ -24582,7 +24618,7 @@ var WeaveArrowToolAction = class extends WeaveAction {
24582
24618
  ]
24583
24619
  });
24584
24620
  const nodeHandler = this.instance.getNodeHandler("arrow");
24585
- this.instance.updateNode(nodeHandler.serialize(tempArrow));
24621
+ if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(tempArrow));
24586
24622
  this.tempNextPoint.setAttrs({
24587
24623
  x: mousePoint.x,
24588
24624
  y: mousePoint.y
@@ -24609,24 +24645,26 @@ var WeaveArrowToolAction = class extends WeaveAction {
24609
24645
  const tempMainArrow = this.instance.getStage().findOne(`#${this.arrowId}`);
24610
24646
  if (tempArrow) {
24611
24647
  const nodeHandler = this.instance.getNodeHandler("arrow");
24612
- this.instance.removeNode(nodeHandler.serialize(tempArrow));
24648
+ if (nodeHandler) this.instance.removeNode(nodeHandler.serialize(tempArrow));
24613
24649
  }
24614
24650
  if (this.arrowId && tempMainArrow && tempMainArrow.points().length < 4) {
24615
24651
  const nodeHandler = this.instance.getNodeHandler("line");
24616
- this.instance.removeNode(nodeHandler.serialize(tempMainArrow));
24652
+ if (nodeHandler) this.instance.removeNode(nodeHandler.serialize(tempMainArrow));
24617
24653
  }
24618
24654
  if (this.arrowId && tempMainArrow && tempMainArrow.points().length >= 4) {
24619
24655
  const nodeHandler = this.instance.getNodeHandler("arrow");
24620
24656
  const lineNodeHandler = this.instance.getNodeHandler("line");
24621
- const finalArrow = nodeHandler.create(this.arrowId, {
24622
- ...tempMainArrow.getAttrs(),
24623
- ...this.props,
24624
- strokeScaleEnabled: true,
24625
- strokeWidth: 1,
24626
- hitStrokeWidth: 16
24627
- });
24628
- this.instance.removeNode(lineNodeHandler.serialize(tempMainArrow));
24629
- this.instance.addNode(finalArrow, this.container?.getAttrs().id);
24657
+ if (nodeHandler && lineNodeHandler) {
24658
+ const finalArrow = nodeHandler.create(this.arrowId, {
24659
+ ...tempMainArrow.getAttrs(),
24660
+ ...this.props,
24661
+ strokeScaleEnabled: true,
24662
+ strokeWidth: 1,
24663
+ hitStrokeWidth: 16
24664
+ });
24665
+ this.instance.removeNode(lineNodeHandler.serialize(tempMainArrow));
24666
+ this.instance.addNode(finalArrow, this.container?.getAttrs().id);
24667
+ }
24630
24668
  }
24631
24669
  const selectionPlugin = this.instance.getPlugin("nodesSelection");
24632
24670
  if (selectionPlugin) {
@@ -24737,14 +24775,16 @@ var WeaveRegularPolygonToolAction = class extends WeaveAction {
24737
24775
  this.container = container;
24738
24776
  this.regularPolygonId = v4_default();
24739
24777
  const nodeHandler = this.instance.getNodeHandler("regular-polygon");
24740
- const node = nodeHandler.create(this.regularPolygonId, {
24741
- ...this.props,
24742
- strokeScaleEnabled: true,
24743
- x: (this.clickPoint?.x ?? 0) + this.props.radius,
24744
- y: (this.clickPoint?.y ?? 0) + this.props.radius,
24745
- radius: 0
24746
- });
24747
- this.instance.addNode(node, this.container?.getAttrs().id);
24778
+ if (nodeHandler) {
24779
+ const node = nodeHandler.create(this.regularPolygonId, {
24780
+ ...this.props,
24781
+ strokeScaleEnabled: true,
24782
+ x: (this.clickPoint?.x ?? 0) + this.props.radius,
24783
+ y: (this.clickPoint?.y ?? 0) + this.props.radius,
24784
+ radius: 0
24785
+ });
24786
+ this.instance.addNode(node, this.container?.getAttrs().id);
24787
+ }
24748
24788
  this.setState(REGULAR_POLYGON_TOOL_STATE.DEFINING_SIZE);
24749
24789
  }
24750
24790
  handleSettingSize() {
@@ -24768,7 +24808,7 @@ var WeaveRegularPolygonToolAction = class extends WeaveAction {
24768
24808
  y: starPos.y + newRadius,
24769
24809
  radius: newRadius
24770
24810
  });
24771
- this.instance.updateNode(nodeHandler.serialize(regularPolygon));
24811
+ if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(regularPolygon));
24772
24812
  }
24773
24813
  this.cancelAction();
24774
24814
  }
@@ -24792,7 +24832,7 @@ var WeaveRegularPolygonToolAction = class extends WeaveAction {
24792
24832
  y: starPos.y + deltaX,
24793
24833
  radius: deltaX
24794
24834
  });
24795
- this.instance.updateNode(nodeHandler.serialize(regularPolygon));
24835
+ if (nodeHandler) this.instance.updateNode(nodeHandler.serialize(regularPolygon));
24796
24836
  }
24797
24837
  }
24798
24838
  trigger(cancelAction) {
@@ -24897,12 +24937,14 @@ var WeaveFrameToolAction = class extends WeaveAction {
24897
24937
  this.container = container;
24898
24938
  this.frameId = v4_default();
24899
24939
  const nodeHandler = this.instance.getNodeHandler("frame");
24900
- const node = nodeHandler.create(this.frameId, {
24901
- ...this.props,
24902
- x: this.clickPoint.x,
24903
- y: this.clickPoint.y
24904
- });
24905
- this.instance.addNode(node, this.container?.getAttrs().id);
24940
+ if (nodeHandler) {
24941
+ const node = nodeHandler.create(this.frameId, {
24942
+ ...this.props,
24943
+ x: this.clickPoint.x,
24944
+ y: this.clickPoint.y
24945
+ });
24946
+ this.instance.addNode(node, this.container?.getAttrs().id);
24947
+ }
24906
24948
  this.cancelAction?.();
24907
24949
  }
24908
24950
  trigger(cancelAction, params) {
@@ -25047,13 +25089,15 @@ const WEAVE_GRID_DEFAULT_SIZE = 50;
25047
25089
  const WEAVE_GRID_DEFAULT_TYPE = WEAVE_GRID_TYPES.LINES;
25048
25090
  const WEAVE_GRID_DEFAULT_COLOR = "rgba(0,0,0,0.2)";
25049
25091
  const WEAVE_GRID_DEFAULT_ORIGIN_COLOR = "rgba(255,0,0,0.2)";
25092
+ const WEAVE_GRID_DEFAULT_STROKE = .5;
25093
+ const WEAVE_GRID_DEFAULT_MAJOR_LINE_RATIO = 4;
25094
+ const WEAVE_GRID_DEFAULT_RADIUS = 1;
25095
+ const WEAVE_GRID_DEFAULT_MAJOR_DOT_RATIO = 2;
25096
+ const WEAVE_GRID_DEFAULT_MAJOR_EVERY = 10;
25050
25097
  const WEAVE_GRID_LAYER_ID = "gridLayer";
25051
25098
 
25052
25099
  //#endregion
25053
25100
  //#region src/plugins/stage-grid/stage-grid.ts
25054
- function isZeroOrClose(value, tolerance = 1e-6) {
25055
- return Math.abs(value) <= tolerance;
25056
- }
25057
25101
  var WeaveStageGridPlugin = class extends WeavePlugin {
25058
25102
  constructor(params) {
25059
25103
  super();
@@ -25138,111 +25182,167 @@ var WeaveStageGridPlugin = class extends WeavePlugin {
25138
25182
  const layer = stage.findOne(`#${WEAVE_GRID_LAYER_ID}`);
25139
25183
  return layer;
25140
25184
  }
25141
- renderGrid() {
25142
- const layer = this.getLayer();
25143
- if (!layer) return;
25144
- layer.destroyChildren();
25145
- if (!this.enabled) return;
25146
- switch (this.config.type) {
25147
- case WEAVE_GRID_TYPES.LINES:
25148
- this.renderGridLines();
25149
- break;
25150
- case WEAVE_GRID_TYPES.DOTS:
25151
- this.renderGridDots();
25152
- break;
25153
- default:
25154
- this.renderGridLines();
25155
- break;
25156
- }
25157
- }
25158
- round(number, step) {
25159
- return Math.round(number / step) * step;
25185
+ getAdaptiveSpacing(scale) {
25186
+ const baseGridSpacing = this.config.gridSize;
25187
+ const minPixelSpacing = 8;
25188
+ const maxPixelSpacing = 100;
25189
+ let spacing = baseGridSpacing;
25190
+ let pixelSpacing = spacing * scale;
25191
+ while (pixelSpacing < minPixelSpacing) {
25192
+ spacing *= 2;
25193
+ pixelSpacing = spacing * scale;
25194
+ }
25195
+ while (pixelSpacing > maxPixelSpacing && spacing > baseGridSpacing / 16) {
25196
+ spacing /= 2;
25197
+ pixelSpacing = spacing * scale;
25198
+ }
25199
+ const logFactor = Math.round(Math.log2(spacing / baseGridSpacing));
25200
+ const snappedSpacing = baseGridSpacing * Math.pow(2, logFactor);
25201
+ return snappedSpacing;
25202
+ }
25203
+ getAdjustedSpacing(startX, endX, startY, endY, baseSpacing = 50, maxDotsPerAxis = 500) {
25204
+ let spacing = baseSpacing;
25205
+ let dotCountX = Math.ceil((endX - startX) / spacing);
25206
+ let dotCountY = Math.ceil((endY - startY) / spacing);
25207
+ while ((dotCountX > maxDotsPerAxis || dotCountY > maxDotsPerAxis) && spacing < 1e6) {
25208
+ spacing *= 2;
25209
+ dotCountX = Math.ceil((endX - startX) / spacing);
25210
+ dotCountY = Math.ceil((endY - startY) / spacing);
25211
+ }
25212
+ return spacing;
25160
25213
  }
25161
25214
  renderGridLines() {
25162
- const layer = this.getLayer();
25163
- if (!layer) return;
25164
25215
  const stage = this.instance.getStage();
25165
- const stageXRound = this.round(stage.x(), this.config.gridSize) * -1;
25166
- const overflowX = this.round(10 * this.config.gridSize, this.config.gridSize);
25167
- const overflowY = this.round(10 * this.config.gridSize, this.config.gridSize);
25168
- const pointsX = [];
25169
- for (let i = stageXRound - overflowX; i < stageXRound + stage.width() + overflowX; i += this.config.gridSize) pointsX.push({
25170
- real: i / stage.scaleX(),
25171
- ref: i
25172
- });
25173
- const stageYRound = this.round(stage.y(), this.config.gridSize) * -1;
25174
- const pointsY = [];
25175
- for (let i = stageYRound - overflowY; i < stageYRound + stage.height() + overflowY; i += this.config.gridSize) pointsY.push({
25176
- real: i / stage.scaleY(),
25177
- ref: i
25178
- });
25179
- for (let index = 0; index < pointsX.length; index++) {
25180
- const { real: point, ref } = pointsX[index];
25181
- let color = this.config.gridColor;
25182
- if (point === 0) color = this.config.gridOriginColor;
25183
- layer.add(new konva_lib_shapes_Line.Line({
25216
+ const gridLayer = this.getLayer();
25217
+ if (!gridLayer) return;
25218
+ gridLayer.destroyChildren();
25219
+ if (!this.enabled) return;
25220
+ const scale = stage.scaleX();
25221
+ const spacing = this.getAdaptiveSpacing(scale);
25222
+ const invScale = (this.config.gridStroke ?? WEAVE_GRID_DEFAULT_STROKE) / scale;
25223
+ const offsetX = -stage.x() / stage.scaleX();
25224
+ const offsetY = -stage.y() / stage.scaleY();
25225
+ const margin = 2;
25226
+ const worldWidth = stage.width() * invScale;
25227
+ const worldHeight = stage.height() * invScale;
25228
+ const startX = Math.floor((offsetX - margin * worldWidth) / spacing) * spacing;
25229
+ const startY = Math.floor((offsetY - margin * worldHeight) / spacing) * spacing;
25230
+ const endX = offsetX + (1 + margin) * worldWidth;
25231
+ const endY = offsetY + (1 + margin) * worldHeight;
25232
+ const highlightEvery = this.config.gridMajorEvery ?? WEAVE_GRID_DEFAULT_MAJOR_EVERY;
25233
+ for (let x = startX; x <= endX; x += spacing) {
25234
+ const index = Math.round(x / spacing);
25235
+ const isHighlight = index % highlightEvery === 0;
25236
+ const isOrigin = Math.abs(x) < spacing / 2;
25237
+ const line = new konva.default.Line({
25184
25238
  points: [
25185
- point,
25186
- (-stage.y() - overflowY) / stage.scaleY(),
25187
- point,
25188
- (-stage.y() + stage.height() + overflowY) / stage.scaleY()
25239
+ x,
25240
+ startY,
25241
+ x,
25242
+ endY
25189
25243
  ],
25190
- stroke: color,
25191
- strokeWidth: (isZeroOrClose(ref % (10 * this.config.gridSize)) ? 2.5 : .5) / stage.scaleX(),
25244
+ stroke: isOrigin ? this.config.gridOriginColor : this.config.gridColor,
25245
+ strokeWidth: !isHighlight && !isOrigin ? invScale : invScale * (this.config.gridMajorRatio ?? WEAVE_GRID_DEFAULT_MAJOR_LINE_RATIO),
25192
25246
  listening: false
25193
- }));
25247
+ });
25248
+ gridLayer.add(line);
25194
25249
  }
25195
- for (let index = 0; index < pointsY.length; index++) {
25196
- const { real: point, ref } = pointsY[index];
25197
- let color = this.config.gridColor;
25198
- if (point === 0) color = this.config.gridOriginColor;
25199
- layer.add(new konva_lib_shapes_Line.Line({
25250
+ for (let y = startY; y <= endY; y += spacing) {
25251
+ const index = Math.round(y / spacing);
25252
+ const isHighlight = index % highlightEvery === 0;
25253
+ const isOrigin = Math.abs(y) < spacing / 2;
25254
+ const line = new konva.default.Line({
25200
25255
  points: [
25201
- (-stage.x() - overflowX) / stage.scaleX(),
25202
- point,
25203
- (-stage.x() + stage.width() + overflowX) / stage.scaleX(),
25204
- point
25256
+ startX,
25257
+ y,
25258
+ endX,
25259
+ y
25205
25260
  ],
25206
- stroke: color,
25207
- strokeWidth: (isZeroOrClose(ref % (10 * this.config.gridSize)) ? 2.5 : .5) / stage.scaleX(),
25261
+ stroke: isOrigin ? this.config.gridOriginColor : this.config.gridColor,
25262
+ strokeWidth: !isHighlight && !isOrigin ? invScale : invScale * 2,
25208
25263
  listening: false
25209
- }));
25264
+ });
25265
+ gridLayer.add(line);
25210
25266
  }
25211
25267
  }
25212
25268
  renderGridDots() {
25213
- const layer = this.getLayer();
25214
- if (!layer) return;
25215
25269
  const stage = this.instance.getStage();
25216
- const overflowX = 10 * this.config.gridSize;
25217
- const overflowY = 10 * this.config.gridSize;
25218
- const stageXRound = this.round(stage.x(), this.config.gridSize) * -1;
25219
- const pointsX = [];
25220
- for (let i = stageXRound - overflowX; i < stageXRound + stage.width() + overflowX; i += this.config.gridSize) pointsX.push({
25221
- real: i / stage.scaleX(),
25222
- ref: i
25223
- });
25224
- const stageYRound = this.round(stage.y(), this.config.gridSize) * -1;
25225
- const pointsY = [];
25226
- for (let i = stageYRound - overflowY; i < stageYRound + stage.height() + overflowY; i += this.config.gridSize) pointsY.push({
25227
- real: i / stage.scaleY(),
25228
- ref: i
25229
- });
25230
- for (let indexX = 0; indexX < pointsX.length; indexX++) {
25231
- const { real: pointX, ref: refX } = pointsX[indexX];
25232
- for (let indexY = 0; indexY < pointsY.length; indexY++) {
25233
- const { real: pointY, ref: refY } = pointsY[indexY];
25234
- let color = this.config.gridColor;
25235
- if (refX === 0 || refY === 0) color = this.config.gridOriginColor;
25236
- layer.add(new konva_lib_shapes_Circle.Circle({
25237
- x: pointX,
25238
- y: pointY,
25239
- radius: (pointX === 0 || pointY === 0 ? 2.5 : 1.5) / stage.scaleX(),
25240
- fill: color,
25241
- stroke: color,
25242
- strokeWidth: 0,
25243
- listening: false
25244
- }));
25245
- }
25270
+ const gridLayer = this.getLayer();
25271
+ if (!gridLayer) return;
25272
+ gridLayer.destroyChildren();
25273
+ if (!this.enabled) return;
25274
+ const scale = stage.scaleX();
25275
+ const spacing = this.getAdaptiveSpacing(scale);
25276
+ const invScale = (this.config.gridDotRadius ?? WEAVE_GRID_DEFAULT_RADIUS) / scale;
25277
+ const position = stage.position();
25278
+ const offsetX = -position.x * invScale;
25279
+ const offsetY = -position.y * invScale;
25280
+ const margin = 2;
25281
+ const worldWidth = stage.width() * invScale;
25282
+ const worldHeight = stage.height() * invScale;
25283
+ let startX = Math.floor((offsetX - margin * worldWidth) / spacing) * spacing;
25284
+ const endX = offsetX + (1 + margin) * worldWidth;
25285
+ let startY = Math.floor((offsetY - margin * worldHeight) / spacing) * spacing;
25286
+ const endY = offsetY + (1 + margin) * worldHeight;
25287
+ let adjustedSpacing = spacing;
25288
+ let dotCountX = Math.ceil((endX - startX) / adjustedSpacing);
25289
+ let dotCountY = Math.ceil((endY - startY) / adjustedSpacing);
25290
+ const maxDotsPerAxis = 500;
25291
+ while ((dotCountX > maxDotsPerAxis || dotCountY > maxDotsPerAxis) && adjustedSpacing < 1e6) {
25292
+ adjustedSpacing *= 2;
25293
+ dotCountX = Math.ceil((endX - startX) / adjustedSpacing);
25294
+ dotCountY = Math.ceil((endY - startY) / adjustedSpacing);
25295
+ }
25296
+ this.getAdjustedSpacing(startX, endX, startY, endY, spacing);
25297
+ startX = Math.floor((offsetX - margin * worldWidth) / adjustedSpacing) * adjustedSpacing;
25298
+ startY = Math.floor((offsetY - margin * worldHeight) / adjustedSpacing) * adjustedSpacing;
25299
+ const highlightEvery = this.config.gridMajorEvery ?? WEAVE_GRID_DEFAULT_MAJOR_EVERY;
25300
+ const majorColor = this.config.gridColor;
25301
+ const gridMajorRatio = this.config.gridMajorRatio ?? WEAVE_GRID_DEFAULT_MAJOR_DOT_RATIO;
25302
+ const majorShape = new konva.default.Shape({ sceneFunc: function(context) {
25303
+ context.beginPath();
25304
+ for (let x = startX; x <= endX; x += adjustedSpacing) for (let y = startY; y <= endY; y += adjustedSpacing) {
25305
+ if (Math.abs(x) < spacing / 2 || Math.abs(y) < spacing / 2) continue;
25306
+ const indexX = Math.round(x / spacing);
25307
+ const indexY = Math.round(y / spacing);
25308
+ const isHighlightX = indexX % highlightEvery === 0;
25309
+ const isHighlightY = indexY % highlightEvery === 0;
25310
+ const radius = !(isHighlightX || isHighlightY) ? invScale : invScale * gridMajorRatio;
25311
+ context.moveTo(x + radius, y);
25312
+ context.arc(x, y, radius, 0, Math.PI * 2, false);
25313
+ }
25314
+ context.fillStyle = majorColor;
25315
+ context.fill();
25316
+ } });
25317
+ gridLayer.add(majorShape);
25318
+ const originColor = this.config.gridOriginColor;
25319
+ const originShape = new konva.default.Shape({ sceneFunc: function(context) {
25320
+ context.beginPath();
25321
+ for (let x = startX; x <= endX; x += adjustedSpacing) {
25322
+ const radius = invScale * gridMajorRatio;
25323
+ context.moveTo(x + radius, 0);
25324
+ context.arc(x, 0, radius, 0, Math.PI * 2);
25325
+ }
25326
+ for (let y = startY; y <= endY; y += adjustedSpacing) {
25327
+ const radius = invScale * gridMajorRatio;
25328
+ if (Math.abs(y) < spacing / 2) continue;
25329
+ context.moveTo(0 + radius, y);
25330
+ context.arc(0, y, radius, 0, Math.PI * 2);
25331
+ }
25332
+ context.fillStyle = originColor;
25333
+ context.fill();
25334
+ } });
25335
+ gridLayer.add(originShape);
25336
+ }
25337
+ renderGrid() {
25338
+ switch (this.config.type) {
25339
+ case WEAVE_GRID_TYPES.LINES:
25340
+ this.renderGridLines();
25341
+ break;
25342
+ case WEAVE_GRID_TYPES.DOTS:
25343
+ this.renderGridDots();
25344
+ break;
25345
+ default: break;
25246
25346
  }
25247
25347
  }
25248
25348
  onRender() {
@@ -25367,7 +25467,7 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
25367
25467
  if (!this.enabled || !(this.isSpaceKeyPressed || this.isMouseMiddleButtonPressed || this.moveToolActive)) return;
25368
25468
  stage.x(stage.x() - deltaX);
25369
25469
  stage.y(stage.y() - deltaY);
25370
- this.instance.emit("onStageMove", void 0);
25470
+ this.instance.emitEvent("onStageMove");
25371
25471
  };
25372
25472
  stage.on("mousemove", (0, import_lodash.throttle)(handleMouseMove, 50));
25373
25473
  stage.on("touchstart", (e) => {
@@ -25390,14 +25490,14 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
25390
25490
  if (!this.enabled) return;
25391
25491
  stage.x(stage.x() - deltaX);
25392
25492
  stage.y(stage.y() - deltaY);
25393
- this.instance.emit("onStageMove", void 0);
25493
+ this.instance.emitEvent("onStageMove");
25394
25494
  });
25395
25495
  const handleWheel = (e) => {
25396
25496
  const stage$1 = this.instance.getStage();
25397
- if (!this.enabled || !stage$1.isFocused() || this.isCtrlOrMetaPressed || !this.isSpaceKeyPressed) return;
25497
+ if (!this.enabled || !stage$1.isFocused() || this.isCtrlOrMetaPressed) return;
25398
25498
  stage$1.x(stage$1.x() - e.deltaX);
25399
25499
  stage$1.y(stage$1.y() - e.deltaY);
25400
- this.instance.emit("onStageMove", void 0);
25500
+ this.instance.emitEvent("onStageMove");
25401
25501
  };
25402
25502
  window.addEventListener("wheel", (0, import_lodash.throttle)(handleWheel, 10));
25403
25503
  }
@@ -26284,8 +26384,13 @@ exports.WEAVE_FRAME_NODE_DEFAULT_CONFIG = WEAVE_FRAME_NODE_DEFAULT_CONFIG
26284
26384
  exports.WEAVE_FRAME_NODE_DEFAULT_PROPS = WEAVE_FRAME_NODE_DEFAULT_PROPS
26285
26385
  exports.WEAVE_FRAME_NODE_TYPE = WEAVE_FRAME_NODE_TYPE
26286
26386
  exports.WEAVE_GRID_DEFAULT_COLOR = WEAVE_GRID_DEFAULT_COLOR
26387
+ exports.WEAVE_GRID_DEFAULT_MAJOR_DOT_RATIO = WEAVE_GRID_DEFAULT_MAJOR_DOT_RATIO
26388
+ exports.WEAVE_GRID_DEFAULT_MAJOR_EVERY = WEAVE_GRID_DEFAULT_MAJOR_EVERY
26389
+ exports.WEAVE_GRID_DEFAULT_MAJOR_LINE_RATIO = WEAVE_GRID_DEFAULT_MAJOR_LINE_RATIO
26287
26390
  exports.WEAVE_GRID_DEFAULT_ORIGIN_COLOR = WEAVE_GRID_DEFAULT_ORIGIN_COLOR
26391
+ exports.WEAVE_GRID_DEFAULT_RADIUS = WEAVE_GRID_DEFAULT_RADIUS
26288
26392
  exports.WEAVE_GRID_DEFAULT_SIZE = WEAVE_GRID_DEFAULT_SIZE
26393
+ exports.WEAVE_GRID_DEFAULT_STROKE = WEAVE_GRID_DEFAULT_STROKE
26289
26394
  exports.WEAVE_GRID_DEFAULT_TYPE = WEAVE_GRID_DEFAULT_TYPE
26290
26395
  exports.WEAVE_GRID_LAYER_ID = WEAVE_GRID_LAYER_ID
26291
26396
  exports.WEAVE_GRID_TYPES = WEAVE_GRID_TYPES