@inditextech/weave-sdk 3.9.1 → 3.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/sdk.js CHANGED
@@ -18834,7 +18834,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
18834
18834
  const nodesSelected = tr.nodes();
18835
18835
  if (nodesSelected.length === 1) {
18836
18836
  const node = nodesSelected[0];
18837
- stage.container().style.cursor = node.defineMousePointer() ?? "grab";
18837
+ stage.container().style.cursor = (typeof node?.defineMousePointer === "function" ? node.defineMousePointer() : null) ?? "grab";
18838
18838
  } else stage.container().style.cursor = "grab";
18839
18839
  });
18840
18840
  tr.on("mouseout", (e) => {
@@ -18891,8 +18891,9 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
18891
18891
  let selectedNodes = [];
18892
18892
  tr.on("dragstart", (e) => {
18893
18893
  this.dragInProcess = true;
18894
+ if (!e?.evt) return;
18894
18895
  let isWheelMousePressed = false;
18895
- if (e.evt.button === 1) isWheelMousePressed = true;
18896
+ if (e.evt?.button === 1) isWheelMousePressed = true;
18896
18897
  const mainLayer = this.instance.getMainLayer();
18897
18898
  if (!mainLayer) return;
18898
18899
  initialPos = {
@@ -18929,7 +18930,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
18929
18930
  y: e.target.y()
18930
18931
  };
18931
18932
  let isWheelMousePressed = false;
18932
- if (e.evt.button === 1) isWheelMousePressed = true;
18933
+ if (e.evt?.button === 1) isWheelMousePressed = true;
18933
18934
  e.cancelBubble = true;
18934
18935
  if (initialPos) {
18935
18936
  const moved = this.checkMovedDrag(initialPos, actualPos);
@@ -19272,8 +19273,8 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
19272
19273
  this.handledClickOrTap = false;
19273
19274
  this.pointers[e.evt.pointerId] = e.evt;
19274
19275
  if (e.evt.pointerType === "touch" && Object.keys(this.pointers).length > 1) return;
19275
- if (e.evt.pointerType === "mouse" && e.evt.button !== 0) return;
19276
- if (e.evt.pointerType === "pen" && e.evt.pressure <= .05) return;
19276
+ if (e.evt.pointerType === "mouse" && e.evt?.button !== 0) return;
19277
+ if (e.evt.pointerType === "pen" && e.evt?.pressure <= .05) return;
19277
19278
  if (!this.initialized) return;
19278
19279
  if (!this.active) return;
19279
19280
  if (stage.mode() !== WEAVE_STAGE_DEFAULT_MODE) return;
@@ -19326,8 +19327,9 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
19326
19327
  this.panLoopId = requestAnimationFrame(() => this.panLoop());
19327
19328
  });
19328
19329
  const handleMouseMove = (e) => {
19330
+ if (!e?.evt) return;
19329
19331
  const moved = this.checkMoved(e);
19330
- if (e.evt.buttons === 0) return;
19332
+ if (e.evt?.buttons === 0) return;
19331
19333
  if (e.evt.pointerType === "touch" && Object.keys(this.pointers).length > 1) return;
19332
19334
  if (!this.initialized) return;
19333
19335
  if (!this.active) return;
@@ -19497,7 +19499,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
19497
19499
  this.hideHoverState();
19498
19500
  const selectedGroup = getTargetedNode(this.instance);
19499
19501
  if (!this.initialized) return;
19500
- if (e.evt.pointerType === "mouse" && e.evt.button && e.evt.button !== 0) return;
19502
+ if (e.evt.pointerType === "mouse" && e.evt?.button && e.evt?.button !== 0) return;
19501
19503
  let areNodesSelected = false;
19502
19504
  let nodeTargeted = selectedGroup && !(selectedGroup.getAttrs().active ?? false) ? selectedGroup : e.target;
19503
19505
  if (e.target === this.instance.getStage()) {
@@ -19560,7 +19562,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
19560
19562
  if (areNodesSelected) {
19561
19563
  stage.container().tabIndex = 1;
19562
19564
  stage.container().focus();
19563
- stage.container().style.cursor = nodeTargeted.defineMousePointer() ?? "grab";
19565
+ stage.container().style.cursor = (typeof nodeTargeted?.defineMousePointer === "function" ? nodeTargeted.defineMousePointer() : null) ?? "grab";
19564
19566
  }
19565
19567
  this.triggerSelectedNodesEvent();
19566
19568
  }
@@ -19728,6 +19730,10 @@ const WEAVE_COPY_PASTE_CONFIG_DEFAULT = {
19728
19730
  }
19729
19731
  };
19730
19732
 
19733
+ //#endregion
19734
+ //#region src/actions/fit-to-selection-tool/constants.ts
19735
+ const FIT_TO_SELECTION_TOOL_ACTION_NAME = "fitToSelectionTool";
19736
+
19731
19737
  //#endregion
19732
19738
  //#region src/plugins/copy-paste-nodes/copy-paste-nodes.ts
19733
19739
  var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
@@ -19939,8 +19945,8 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
19939
19945
  }
19940
19946
  const nodesSelectionPlugin = this.getNodesSelectionPlugin();
19941
19947
  nodesSelectionPlugin?.setSelectedNodes(realNodes);
19942
- this.instance?.triggerAction("fitToSelectionTool", {
19943
- previousAction: "selectionTool",
19948
+ this.instance?.triggerAction(FIT_TO_SELECTION_TOOL_ACTION_NAME, {
19949
+ previousAction: SELECTION_TOOL_ACTION_NAME,
19944
19950
  smartZoom: true
19945
19951
  });
19946
19952
  this.instance.emitEvent("onPaste", {
@@ -20215,6 +20221,33 @@ const augmentKonvaNodeClass = (config) => {
20215
20221
  Konva.Node.prototype.closeCrop = function() {};
20216
20222
  Konva.Node.prototype.resetCrop = function() {};
20217
20223
  Konva.Node.prototype.dblClick = function() {};
20224
+ Konva.Node.prototype.allowedAnchors = function() {
20225
+ return [];
20226
+ };
20227
+ Konva.Node.prototype.isSelectable = function() {
20228
+ return true;
20229
+ };
20230
+ Konva.Node.prototype.handleMouseover = function() {};
20231
+ Konva.Node.prototype.handleMouseout = function() {};
20232
+ Konva.Node.prototype.handleSelectNode = function() {};
20233
+ Konva.Node.prototype.handleDeselectNode = function() {};
20234
+ Konva.Node.prototype.defineMousePointer = function() {
20235
+ return "default";
20236
+ };
20237
+ Konva.Node.prototype.canBeHovered = function() {
20238
+ return false;
20239
+ };
20240
+ Konva.Node.prototype.canDrag = function() {
20241
+ return false;
20242
+ };
20243
+ Konva.Node.prototype.canMoveToContainer = function() {
20244
+ return false;
20245
+ };
20246
+ Konva.Node.prototype.getNodeAnchors = function() {
20247
+ return [];
20248
+ };
20249
+ Konva.Node.prototype.lockMutex = function() {};
20250
+ Konva.Node.prototype.releaseMutex = function() {};
20218
20251
  };
20219
20252
  var WeaveNode = class {
20220
20253
  async register(instance) {
@@ -20506,10 +20539,11 @@ var WeaveNode = class {
20506
20539
  node.off("dragstart");
20507
20540
  node.on("dragstart", (e) => {
20508
20541
  const nodeTarget = e.target;
20542
+ if (!e.evt) return;
20509
20543
  let isWheelMousePressed = false;
20510
- if (e.evt.button === 1) isWheelMousePressed = true;
20544
+ if (e.evt?.button === 1) isWheelMousePressed = true;
20511
20545
  this.getNodesSelectionFeedbackPlugin()?.hideSelectionHalo(nodeTarget);
20512
- const canMove = nodeTarget?.canDrag() ?? false;
20546
+ const canMove = typeof nodeTarget?.canDrag === "function" ? nodeTarget.canDrag() : false;
20513
20547
  if (!canMove) {
20514
20548
  nodeTarget.stopDrag();
20515
20549
  return;
@@ -20561,7 +20595,7 @@ var WeaveNode = class {
20561
20595
  nodesSelectionPlugin?.setSelectedNodes([]);
20562
20596
  requestAnimationFrame(() => {
20563
20597
  nodesSelectionPlugin?.setSelectedNodes(this.instance.getCloningManager().getClones());
20564
- clone?.startDrag(e.evt);
20598
+ if (clone?.getStage()) clone.startDrag(e.evt);
20565
20599
  });
20566
20600
  }
20567
20601
  if (this.getNodesSelectionPlugin()?.getSelectedNodes().length === 1) this.instance.setMutexLock({
@@ -20572,7 +20606,7 @@ var WeaveNode = class {
20572
20606
  const handleDragMove = (e) => {
20573
20607
  const nodeTarget = e.target;
20574
20608
  let isWheelMousePressed = false;
20575
- if (e.evt.button === 1) isWheelMousePressed = true;
20609
+ if (e.evt?.button === 1) isWheelMousePressed = true;
20576
20610
  e.cancelBubble = true;
20577
20611
  if (e.evt?.buttons === 0) {
20578
20612
  nodeTarget.stopDrag();
@@ -20764,12 +20798,12 @@ var WeaveNode = class {
20764
20798
  }
20765
20799
  if (isNodeSelectionEnabled && this.isSelecting() && !this.isNodeSelected(realNode) && !this.isPasting() && isTargetable && !(isLocked || isMutexLocked) && stage.mode() === WEAVE_STAGE_DEFAULT_MODE) {
20766
20800
  showHover = true;
20767
- stage.container().style.cursor = realNode?.defineMousePointer() ?? "pointer";
20801
+ stage.container().style.cursor = (typeof node?.defineMousePointer === "function" ? node.defineMousePointer() : null) ?? "pointer";
20768
20802
  cancelBubble = true;
20769
20803
  }
20770
20804
  if (isNodeSelectionEnabled && this.isSelecting() && this.isNodeSelected(realNode) && !this.isPasting() && isTargetable && !(isLocked || isMutexLocked) && stage.mode() === WEAVE_STAGE_DEFAULT_MODE) {
20771
20805
  showHover = true;
20772
- stage.container().style.cursor = realNode?.defineMousePointer() ?? "grab";
20806
+ stage.container().style.cursor = (typeof node?.defineMousePointer === "function" ? node.defineMousePointer() : null) ?? "grab";
20773
20807
  cancelBubble = true;
20774
20808
  }
20775
20809
  if (!isTargetable) cancelBubble = true;
@@ -22041,7 +22075,7 @@ var WeaveRegisterManager = class {
22041
22075
 
22042
22076
  //#endregion
22043
22077
  //#region package.json
22044
- var version = "3.9.1";
22078
+ var version = "3.9.2";
22045
22079
 
22046
22080
  //#endregion
22047
22081
  //#region src/managers/setup.ts
@@ -24219,6 +24253,7 @@ function loadImageSource(image, options) {
24219
24253
  }
24220
24254
  async function downscaleImageFile(file, ratio) {
24221
24255
  const bitmap = await createImageBitmap(file);
24256
+ if (bitmap.width === 0) throw new Error("Invalid image", { cause: "InvalidImage" });
24222
24257
  const width = Math.round(bitmap.width * ratio);
24223
24258
  const height = Math.round(bitmap.height * ratio);
24224
24259
  const canvas = document.createElement("canvas");
@@ -24235,13 +24270,19 @@ function getImageSizeFromFile(file) {
24235
24270
  const img = new Image();
24236
24271
  const url = URL.createObjectURL(file);
24237
24272
  img.onload = () => {
24273
+ if (img.naturalWidth === 0) {
24274
+ reject(new Error("Invalid image", { cause: "InvalidImage" }));
24275
+ return;
24276
+ }
24238
24277
  resolve({
24239
24278
  width: img.naturalWidth,
24240
24279
  height: img.naturalHeight
24241
24280
  });
24242
24281
  URL.revokeObjectURL(url);
24243
24282
  };
24244
- img.onerror = reject;
24283
+ img.onerror = () => {
24284
+ reject(new Error("Invalid image", { cause: "InvalidImage" }));
24285
+ };
24245
24286
  img.src = url;
24246
24287
  });
24247
24288
  }
@@ -24265,6 +24306,10 @@ const downscaleImageFromURL = (url, options) => {
24265
24306
  const img = new Image();
24266
24307
  img.crossOrigin = crossOrigin;
24267
24308
  img.onload = () => {
24309
+ if (img.naturalWidth === 0) {
24310
+ reject(new Error("Invalid image", { cause: "InvalidImage" }));
24311
+ return;
24312
+ }
24268
24313
  const ratio = Math.min(maxWidth / img.width, maxHeight / img.height, 1);
24269
24314
  const width = Math.round(img.width * ratio);
24270
24315
  const height = Math.round(img.height * ratio);
@@ -24275,7 +24320,9 @@ const downscaleImageFromURL = (url, options) => {
24275
24320
  ctx.drawImage(img, 0, 0, width, height);
24276
24321
  resolve(canvas.toDataURL(type));
24277
24322
  };
24278
- img.onerror = reject;
24323
+ img.onerror = () => {
24324
+ reject(new Error("Invalid image", { cause: "InvalidImage" }));
24325
+ };
24279
24326
  img.src = url;
24280
24327
  });
24281
24328
  };
@@ -27033,15 +27080,24 @@ var WeaveImageNode = class extends WeaveNode {
27033
27080
  const imageURLToLoad = imageURL ?? "http://localhost/false-image";
27034
27081
  this.imageFallback[imageId] = Konva.Util.createImageElement();
27035
27082
  this.imageFallback[imageId].crossOrigin = this.config.crossOrigin;
27036
- this.imageFallback[imageId].onerror = (error) => {
27083
+ this.imageFallback[imageId].onerror = () => {
27037
27084
  this.imageState[imageId] = {
27038
27085
  status: "error-fallback",
27039
27086
  loaded: false,
27040
27087
  error: true
27041
27088
  };
27042
- onError(error);
27089
+ onError(new Error(`Failed to load fallback image from provided URL`, { cause: "ErrorLoadingFallbackImage" }));
27043
27090
  };
27044
27091
  this.imageFallback[imageId].onload = async () => {
27092
+ if (this.imageFallback[imageId].width === 0) {
27093
+ this.imageState[imageId] = {
27094
+ status: "error-fallback",
27095
+ loaded: false,
27096
+ error: true
27097
+ };
27098
+ onError(new Error(`Invalid fallback image provided`, { cause: "InvalidFallbackImage" }));
27099
+ return;
27100
+ }
27045
27101
  this.imageState[imageId] = {
27046
27102
  status: "loading",
27047
27103
  loaded: true,
@@ -27068,15 +27124,19 @@ var WeaveImageNode = class extends WeaveNode {
27068
27124
  }
27069
27125
  this.imageSource[imageId] = Konva.Util.createImageElement();
27070
27126
  this.imageSource[imageId].crossOrigin = this.config.crossOrigin;
27071
- this.imageSource[imageId].onerror = (error) => {
27127
+ this.imageSource[imageId].onerror = () => {
27072
27128
  if (!loadingTryout) {
27073
27129
  const stage = this.instance.getStage();
27074
27130
  const image = stage.findOne(`#${imageId}`);
27075
27131
  if (image) this.setErrorState(imageId, image);
27076
27132
  }
27077
- onError(error);
27133
+ onError(new Error(`Failed to load image from provided URL`, { cause: "ErrorLoadingImage" }));
27078
27134
  };
27079
27135
  this.imageSource[imageId].onload = async () => {
27136
+ if (this.imageSource[imageId].width === 0) {
27137
+ onError(new Error(`Invalid image provided`, { cause: "InvalidImage" }));
27138
+ return;
27139
+ }
27080
27140
  const stage = this.instance.getStage();
27081
27141
  if (!this.instance.isServerSide()) stage.container().style.cursor = "pointer";
27082
27142
  this.imageState[imageId] = {
@@ -27168,14 +27228,16 @@ var WeaveImageNode = class extends WeaveNode {
27168
27228
  }
27169
27229
  },
27170
27230
  onError: (error) => {
27171
- if (!this.config.useFallbackImage) {
27231
+ let isInvalidImage = false;
27232
+ if (error.cause === "InvalidImage") isInvalidImage = true;
27233
+ if (!this.config.useFallbackImage && !isInvalidImage) {
27172
27234
  const tryoutAttempts = this.imageTryoutAttempts[id] ?? 0;
27173
27235
  if (tryoutAttempts - 1 < this.config.imageLoading.maxRetryAttempts) {
27174
27236
  this.loadImageTryout(id);
27175
27237
  return;
27176
27238
  } else this.setErrorState(id, image);
27177
27239
  }
27178
- if (loadTryout) {
27240
+ if (loadTryout && !isInvalidImage) {
27179
27241
  const tryoutAttempts = this.imageTryoutAttempts[id] ?? 0;
27180
27242
  if (tryoutAttempts - 1 < this.config.imageLoading.maxRetryAttempts) {
27181
27243
  this.loadImageTryout(id);
@@ -27188,12 +27250,7 @@ var WeaveImageNode = class extends WeaveNode {
27188
27250
  return;
27189
27251
  }
27190
27252
  this.setErrorState(id, image);
27191
- image.setAttrs({ image: void 0 });
27192
- console.error("Error loading image", error);
27193
27253
  this.resolveAsyncElement(id);
27194
- imagePlaceholder?.setAttrs({ visible: true });
27195
- internalImage?.setAttrs({ visible: false });
27196
- this.cacheNode(image);
27197
27254
  }
27198
27255
  }, loadTryout);
27199
27256
  }
@@ -29685,8 +29742,7 @@ var WeaveVideoNode = class extends WeaveNode {
29685
29742
  this.videoPlaceholder[id] = Konva.Util.createImageElement();
29686
29743
  this.videoPlaceholder[id].crossOrigin = this.config.crossOrigin;
29687
29744
  this.videoPlaceholder[id].src = realVideoPlaceholderURL;
29688
- this.videoPlaceholder[id].onerror = (error) => {
29689
- console.error("Error loading video placeholder", realVideoPlaceholderURL, error);
29745
+ this.videoPlaceholder[id].onerror = () => {
29690
29746
  this.resolveAsyncElement(id);
29691
29747
  };
29692
29748
  this.videoPlaceholder[id].onload = () => {
@@ -32724,13 +32780,13 @@ var WeaveZoomOutToolAction = class extends WeaveAction {
32724
32780
  const stageZoomPlugin = this.getStageZoomPlugin();
32725
32781
  if (!stageZoomPlugin.canZoomOut()) return;
32726
32782
  stageZoomPlugin.zoomOut();
32727
- this.previousAction = params.previousAction;
32783
+ this.previousAction = params?.previousAction;
32728
32784
  this.cancelAction = cancelAction;
32729
32785
  this.cancelAction();
32730
32786
  }
32731
32787
  cleanup() {
32732
32788
  const stage = this.instance.getStage();
32733
- if (this.previousAction !== void 0) this.instance.triggerAction(this.previousAction);
32789
+ if (this.previousAction) this.instance.triggerAction(this.previousAction);
32734
32790
  stage.container().style.cursor = "default";
32735
32791
  }
32736
32792
  };
@@ -32762,13 +32818,13 @@ var WeaveZoomInToolAction = class extends WeaveAction {
32762
32818
  const stageZoomPlugin = this.getStageZoomPlugin();
32763
32819
  if (!stageZoomPlugin.canZoomIn()) return;
32764
32820
  stageZoomPlugin.zoomIn();
32765
- this.previousAction = params.previousAction;
32821
+ this.previousAction = params?.previousAction;
32766
32822
  this.cancelAction = cancelAction;
32767
32823
  this.cancelAction();
32768
32824
  }
32769
32825
  cleanup() {
32770
32826
  const stage = this.instance.getStage();
32771
- if (this.previousAction !== void 0) this.instance.triggerAction(this.previousAction);
32827
+ if (this.previousAction) this.instance.triggerAction(this.previousAction);
32772
32828
  stage.container().style.cursor = "default";
32773
32829
  }
32774
32830
  };
@@ -32799,21 +32855,17 @@ var WeaveFitToScreenToolAction = class extends WeaveAction {
32799
32855
  trigger(cancelAction, params) {
32800
32856
  const stageZoomPlugin = this.getStageZoomPlugin();
32801
32857
  if (stageZoomPlugin) stageZoomPlugin.fitToScreen({ overrideZoom: params?.overrideZoom ?? true });
32802
- this.previousAction = params.previousAction;
32858
+ this.previousAction = params?.previousAction;
32803
32859
  this.cancelAction = cancelAction;
32804
32860
  this.cancelAction();
32805
32861
  }
32806
32862
  cleanup() {
32807
32863
  const stage = this.instance.getStage();
32808
- if (this.previousAction !== void 0) this.instance.triggerAction(this.previousAction);
32864
+ if (this.previousAction) this.instance.triggerAction(this.previousAction);
32809
32865
  stage.container().style.cursor = "default";
32810
32866
  }
32811
32867
  };
32812
32868
 
32813
- //#endregion
32814
- //#region src/actions/fit-to-selection-tool/constants.ts
32815
- const FIT_TO_SELECTION_TOOL_ACTION_NAME = "fitToSelectionTool";
32816
-
32817
32869
  //#endregion
32818
32870
  //#region src/actions/fit-to-selection-tool/fit-to-selection-tool.ts
32819
32871
  var WeaveFitToSelectionToolAction = class extends WeaveAction {
@@ -32845,13 +32897,13 @@ var WeaveFitToSelectionToolAction = class extends WeaveAction {
32845
32897
  smartZoom: params?.smartZoom ?? false,
32846
32898
  overrideZoom: params?.overrideZoom ?? true
32847
32899
  });
32848
- this.previousAction = params.previousAction;
32900
+ this.previousAction = params?.previousAction;
32849
32901
  this.cancelAction = cancelAction;
32850
32902
  this.cancelAction();
32851
32903
  }
32852
32904
  cleanup() {
32853
32905
  const stage = this.instance.getStage();
32854
- if (this.previousAction !== void 0) this.instance.triggerAction(this.previousAction);
32906
+ if (this.previousAction) this.instance.triggerAction(this.previousAction);
32855
32907
  stage.container().style.cursor = "default";
32856
32908
  }
32857
32909
  };
@@ -34135,7 +34187,7 @@ var WeaveBrushToolAction = class extends WeaveAction {
34135
34187
  if (this.state !== BRUSH_TOOL_STATE.IDLE) return;
34136
34188
  if (this.getZoomPlugin()?.isPinching()) return;
34137
34189
  if (this.isSpacePressed) return;
34138
- if (e.evt.button !== 0) return;
34190
+ if (e?.evt?.button !== 0) return;
34139
34191
  const pointPressure = this.getEventPressure(e);
34140
34192
  this.handleStartStroke(pointPressure);
34141
34193
  e.evt.stopPropagation();
@@ -37946,13 +37998,13 @@ var WeaveStageGridPlugin = class extends WeavePlugin {
37946
37998
  });
37947
37999
  stage.on("pointerdown", (e) => {
37948
38000
  const activeAction = this.instance.getActiveAction();
37949
- if (e && e.evt.button === 0 && activeAction === MOVE_TOOL_ACTION_NAME) this.moveToolActive = true;
37950
- if (e && (e.evt.button === 2 || e.evt.buttons === 4)) this.isMouseMiddleButtonPressed = true;
38001
+ if (e && e?.evt?.button === 0 && activeAction === MOVE_TOOL_ACTION_NAME) this.moveToolActive = true;
38002
+ if (e && (e?.evt?.button === 2 || e?.evt?.buttons === 4)) this.isMouseMiddleButtonPressed = true;
37951
38003
  });
37952
38004
  stage.on("pointerup", (e) => {
37953
38005
  const activeAction = this.instance.getActiveAction();
37954
- if (e && e.evt.button === 0 && activeAction === MOVE_TOOL_ACTION_NAME) this.moveToolActive = false;
37955
- if (e && (e.evt.button === 1 || e.evt.buttons === 0)) this.isMouseMiddleButtonPressed = false;
38006
+ if (e && e?.evt?.button === 0 && activeAction === MOVE_TOOL_ACTION_NAME) this.moveToolActive = false;
38007
+ if (e && (e?.evt?.button === 1 || e?.evt?.buttons === 0)) this.isMouseMiddleButtonPressed = false;
37956
38008
  });
37957
38009
  const handleMouseMove = () => {
37958
38010
  if (!this.enabled || !(this.isSpaceKeyPressed || this.isMouseMiddleButtonPressed || this.moveToolActive)) return;
@@ -38273,16 +38325,16 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
38273
38325
  let lastPos = null;
38274
38326
  stage.on("pointerdown", (e) => {
38275
38327
  this.pointers.set(e.evt.pointerId, {
38276
- x: e.evt.clientX,
38277
- y: e.evt.clientY
38328
+ x: e?.evt?.clientX ?? 0,
38329
+ y: e?.evt?.clientY ?? 0
38278
38330
  });
38279
38331
  if (this.pointers.size > 1) return;
38280
38332
  const activeAction = this.instance.getActiveAction();
38281
38333
  this.enableMove = false;
38282
38334
  if (activeAction === MOVE_TOOL_ACTION_NAME) this.moveToolActive = true;
38283
- if (e.evt.pointerType === "mouse" && e.evt.buttons === 1) this.isMouseLeftButtonPressed = true;
38284
- if (e.evt.pointerType === "mouse" && e.evt.buttons === 4) this.isMouseMiddleButtonPressed = true;
38285
- const isTouchOrPen = ["touch", "pen"].includes(e.evt.pointerType);
38335
+ if (e.evt.pointerType === "mouse" && e?.evt?.buttons === 1) this.isMouseLeftButtonPressed = true;
38336
+ if (e.evt.pointerType === "mouse" && e?.evt?.buttons === 4) this.isMouseMiddleButtonPressed = true;
38337
+ const isTouchOrPen = ["touch", "pen"].includes(e?.evt?.pointerType);
38286
38338
  if (this.enabled && (this.isSpaceKeyPressed || this.moveToolActive && (this.isMouseLeftButtonPressed || isTouchOrPen) || this.isMouseMiddleButtonPressed)) this.enableMove = true;
38287
38339
  if (this.enableMove) {
38288
38340
  this.isDragging = true;
@@ -38291,7 +38343,7 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
38291
38343
  }
38292
38344
  });
38293
38345
  stage.on("pointercancel", (e) => {
38294
- this.pointers.delete(e.evt.pointerId);
38346
+ if (e?.evt?.pointerId) this.pointers.delete(e.evt.pointerId);
38295
38347
  lastPos = null;
38296
38348
  });
38297
38349
  const handleMouseMove = (e) => {