@inditextech/weave-sdk 3.9.0 → 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/types.js CHANGED
@@ -32,13 +32,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
32
32
  }) : target, mod));
33
33
 
34
34
  //#endregion
35
- //#region node_modules/emittery/maps.js
35
+ //#region ../../node_modules/emittery/maps.js
36
36
  const anyMap = new WeakMap();
37
37
  const eventsMap = new WeakMap();
38
38
  const producersMap = new WeakMap();
39
39
 
40
40
  //#endregion
41
- //#region node_modules/emittery/index.js
41
+ //#region ../../node_modules/emittery/index.js
42
42
  const anyProducer = Symbol("anyProducer");
43
43
  const resolvedPromise = Promise.resolve();
44
44
  const listenerAdded = Symbol("listenerAdded");
@@ -442,11 +442,11 @@ var require_lodash = __commonJS({ "../../node_modules/lodash/lodash.js"(exports,
442
442
  /** Used as a safe reference for `undefined` in pre-ES5 environments. */
443
443
  var undefined$1;
444
444
  /** Used as the semantic version number. */
445
- var VERSION = "4.17.21";
445
+ var VERSION = "4.18.1";
446
446
  /** Used as the size to enable large array optimizations. */
447
447
  var LARGE_ARRAY_SIZE$1 = 200;
448
448
  /** Error message constants. */
449
- var CORE_ERROR_TEXT = "Unsupported core-js use. Try https://npms.io/search?q=ponyfill.", FUNC_ERROR_TEXT$2 = "Expected a function", INVALID_TEMPL_VAR_ERROR_TEXT = "Invalid `variable` option passed into `_.template`";
449
+ var CORE_ERROR_TEXT = "Unsupported core-js use. Try https://npms.io/search?q=ponyfill.", FUNC_ERROR_TEXT$2 = "Expected a function", INVALID_TEMPL_VAR_ERROR_TEXT = "Invalid `variable` option passed into `_.template`", INVALID_TEMPL_IMPORTS_ERROR_TEXT = "Invalid `imports` option passed into `_.template`";
450
450
  /** Used to stand-in for `undefined` hash values. */
451
451
  var HASH_UNDEFINED$2 = "__lodash_hash_undefined__";
452
452
  /** Used as the maximum memoize cache size. */
@@ -1886,6 +1886,10 @@ var require_lodash = __commonJS({ "../../node_modules/lodash/lodash.js"(exports,
1886
1886
  * embedded Ruby (ERB) as well as ES2015 template strings. Change the
1887
1887
  * following template settings to use alternative delimiters.
1888
1888
  *
1889
+ * **Security:** See
1890
+ * [threat model](https://github.com/lodash/lodash/blob/main/threat-model.md)
1891
+ * — `_.template` is insecure and will be removed in v5.
1892
+ *
1889
1893
  * @static
1890
1894
  * @memberOf _
1891
1895
  * @type {Object}
@@ -2288,7 +2292,7 @@ var require_lodash = __commonJS({ "../../node_modules/lodash/lodash.js"(exports,
2288
2292
  * @name has
2289
2293
  * @memberOf SetCache
2290
2294
  * @param {*} value The value to search for.
2291
- * @returns {number} Returns `true` if `value` is found, else `false`.
2295
+ * @returns {boolean} Returns `true` if `value` is found, else `false`.
2292
2296
  */
2293
2297
  function setCacheHas(value) {
2294
2298
  return this.__data__.has(value);
@@ -3826,8 +3830,15 @@ var require_lodash = __commonJS({ "../../node_modules/lodash/lodash.js"(exports,
3826
3830
  */
3827
3831
  function baseUnset(object, path) {
3828
3832
  path = castPath(path, object);
3829
- object = parent(object, path);
3830
- return object == null || delete object[toKey(last(path))];
3833
+ var index = -1, length = path.length;
3834
+ if (!length) return true;
3835
+ while (++index < length) {
3836
+ var key = toKey(path[index]);
3837
+ if (key === "__proto__" && !hasOwnProperty$9.call(object, "__proto__")) return false;
3838
+ if ((key === "constructor" || key === "prototype") && index < length - 1) return false;
3839
+ }
3840
+ var obj = parent(object, path);
3841
+ return obj == null || delete obj[toKey(last(path))];
3831
3842
  }
3832
3843
  /**
3833
3844
  * The base implementation of `_.update`.
@@ -5731,7 +5742,7 @@ var require_lodash = __commonJS({ "../../node_modules/lodash/lodash.js"(exports,
5731
5742
  }
5732
5743
  /**
5733
5744
  * Creates an array with all falsey values removed. The values `false`, `null`,
5734
- * `0`, `""`, `undefined`, and `NaN` are falsey.
5745
+ * `0`, `-0`, `0n`, `""`, `undefined`, and `NaN` are falsy.
5735
5746
  *
5736
5747
  * @static
5737
5748
  * @memberOf _
@@ -6209,7 +6220,7 @@ var require_lodash = __commonJS({ "../../node_modules/lodash/lodash.js"(exports,
6209
6220
  var index = -1, length = pairs == null ? 0 : pairs.length, result$1 = {};
6210
6221
  while (++index < length) {
6211
6222
  var pair = pairs[index];
6212
- result$1[pair[0]] = pair[1];
6223
+ baseAssignValue$4(result$1, pair[0], pair[1]);
6213
6224
  }
6214
6225
  return result$1;
6215
6226
  }
@@ -12312,6 +12323,8 @@ var require_lodash = __commonJS({ "../../node_modules/lodash/lodash.js"(exports,
12312
12323
  * **Note:** JavaScript follows the IEEE-754 standard for resolving
12313
12324
  * floating-point values which can produce unexpected results.
12314
12325
  *
12326
+ * **Note:** If `lower` is greater than `upper`, the values are swapped.
12327
+ *
12315
12328
  * @static
12316
12329
  * @memberOf _
12317
12330
  * @since 0.7.0
@@ -12325,9 +12338,16 @@ var require_lodash = __commonJS({ "../../node_modules/lodash/lodash.js"(exports,
12325
12338
  * _.random(0, 5);
12326
12339
  * // => an integer between 0 and 5
12327
12340
  *
12341
+ * // when lower is greater than upper the values are swapped
12342
+ * _.random(5, 0);
12343
+ * // => an integer between 0 and 5
12344
+ *
12328
12345
  * _.random(5);
12329
12346
  * // => also an integer between 0 and 5
12330
12347
  *
12348
+ * _.random(-5);
12349
+ * // => an integer between -5 and 0
12350
+ *
12331
12351
  * _.random(5, true);
12332
12352
  * // => a floating-point number between 0 and 5
12333
12353
  *
@@ -12860,6 +12880,10 @@ var require_lodash = __commonJS({ "../../node_modules/lodash/lodash.js"(exports,
12860
12880
  * properties may be accessed as free variables in the template. If a setting
12861
12881
  * object is given, it takes precedence over `_.templateSettings` values.
12862
12882
  *
12883
+ * **Security:** `_.template` is insecure and should not be used. It will be
12884
+ * removed in Lodash v5. Avoid untrusted input. See
12885
+ * [threat model](https://github.com/lodash/lodash/blob/main/threat-model.md).
12886
+ *
12863
12887
  * **Note:** In the development build `_.template` utilizes
12864
12888
  * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
12865
12889
  * for easier debugging.
@@ -12961,8 +12985,11 @@ var require_lodash = __commonJS({ "../../node_modules/lodash/lodash.js"(exports,
12961
12985
  var settings = lodash.templateSettings;
12962
12986
  if (guard && isIterateeCall$2(string, options, guard)) options = undefined$1;
12963
12987
  string = toString(string);
12964
- options = assignInWith({}, options, settings, customDefaultsAssignIn);
12965
- var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn), importsKeys = keys(imports), importsValues = baseValues(imports, importsKeys);
12988
+ options = assignWith({}, options, settings, customDefaultsAssignIn);
12989
+ var imports = assignWith({}, options.imports, settings.imports, customDefaultsAssignIn), importsKeys = keys(imports), importsValues = baseValues(imports, importsKeys);
12990
+ arrayEach(importsKeys, function(key) {
12991
+ if (reForbiddenIdentifierChars.test(key)) throw new Error$1(INVALID_TEMPL_IMPORTS_ERROR_TEXT);
12992
+ });
12966
12993
  var isEscaping, isEvaluating, index = 0, interpolate = options.interpolate || reNoMatch, source = "__p += '";
12967
12994
  var reDelimiters = RegExp$1((options.escape || reNoMatch).source + "|" + interpolate.source + "|" + (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + "|" + (options.evaluate || reNoMatch).source + "|$", "g");
12968
12995
  var sourceURL = "//# sourceURL=" + (hasOwnProperty$9.call(options, "sourceURL") ? (options.sourceURL + "").replace(/\s/g, " ") : "lodash.templateSources[" + ++templateCounter + "]") + "\n";
@@ -18807,7 +18834,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
18807
18834
  const nodesSelected = tr.nodes();
18808
18835
  if (nodesSelected.length === 1) {
18809
18836
  const node = nodesSelected[0];
18810
- stage.container().style.cursor = node.defineMousePointer() ?? "grab";
18837
+ stage.container().style.cursor = (typeof node?.defineMousePointer === "function" ? node.defineMousePointer() : null) ?? "grab";
18811
18838
  } else stage.container().style.cursor = "grab";
18812
18839
  });
18813
18840
  tr.on("mouseout", (e) => {
@@ -18864,8 +18891,9 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
18864
18891
  let selectedNodes = [];
18865
18892
  tr.on("dragstart", (e) => {
18866
18893
  this.dragInProcess = true;
18894
+ if (!e?.evt) return;
18867
18895
  let isWheelMousePressed = false;
18868
- if (e.evt.button === 1) isWheelMousePressed = true;
18896
+ if (e.evt?.button === 1) isWheelMousePressed = true;
18869
18897
  const mainLayer = this.instance.getMainLayer();
18870
18898
  if (!mainLayer) return;
18871
18899
  initialPos = {
@@ -18902,7 +18930,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
18902
18930
  y: e.target.y()
18903
18931
  };
18904
18932
  let isWheelMousePressed = false;
18905
- if (e.evt.button === 1) isWheelMousePressed = true;
18933
+ if (e.evt?.button === 1) isWheelMousePressed = true;
18906
18934
  e.cancelBubble = true;
18907
18935
  if (initialPos) {
18908
18936
  const moved = this.checkMovedDrag(initialPos, actualPos);
@@ -19245,8 +19273,8 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
19245
19273
  this.handledClickOrTap = false;
19246
19274
  this.pointers[e.evt.pointerId] = e.evt;
19247
19275
  if (e.evt.pointerType === "touch" && Object.keys(this.pointers).length > 1) return;
19248
- if (e.evt.pointerType === "mouse" && e.evt.button !== 0) return;
19249
- 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;
19250
19278
  if (!this.initialized) return;
19251
19279
  if (!this.active) return;
19252
19280
  if (stage.mode() !== WEAVE_STAGE_DEFAULT_MODE) return;
@@ -19299,8 +19327,9 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
19299
19327
  this.panLoopId = requestAnimationFrame(() => this.panLoop());
19300
19328
  });
19301
19329
  const handleMouseMove = (e) => {
19330
+ if (!e?.evt) return;
19302
19331
  const moved = this.checkMoved(e);
19303
- if (e.evt.buttons === 0) return;
19332
+ if (e.evt?.buttons === 0) return;
19304
19333
  if (e.evt.pointerType === "touch" && Object.keys(this.pointers).length > 1) return;
19305
19334
  if (!this.initialized) return;
19306
19335
  if (!this.active) return;
@@ -19470,7 +19499,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
19470
19499
  this.hideHoverState();
19471
19500
  const selectedGroup = getTargetedNode(this.instance);
19472
19501
  if (!this.initialized) return;
19473
- 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;
19474
19503
  let areNodesSelected = false;
19475
19504
  let nodeTargeted = selectedGroup && !(selectedGroup.getAttrs().active ?? false) ? selectedGroup : e.target;
19476
19505
  if (e.target === this.instance.getStage()) {
@@ -19533,7 +19562,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
19533
19562
  if (areNodesSelected) {
19534
19563
  stage.container().tabIndex = 1;
19535
19564
  stage.container().focus();
19536
- stage.container().style.cursor = nodeTargeted.defineMousePointer() ?? "grab";
19565
+ stage.container().style.cursor = (typeof nodeTargeted?.defineMousePointer === "function" ? nodeTargeted.defineMousePointer() : null) ?? "grab";
19537
19566
  }
19538
19567
  this.triggerSelectedNodesEvent();
19539
19568
  }
@@ -19701,6 +19730,10 @@ const WEAVE_COPY_PASTE_CONFIG_DEFAULT = {
19701
19730
  }
19702
19731
  };
19703
19732
 
19733
+ //#endregion
19734
+ //#region src/actions/fit-to-selection-tool/constants.ts
19735
+ const FIT_TO_SELECTION_TOOL_ACTION_NAME = "fitToSelectionTool";
19736
+
19704
19737
  //#endregion
19705
19738
  //#region src/plugins/copy-paste-nodes/copy-paste-nodes.ts
19706
19739
  var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
@@ -19912,8 +19945,8 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
19912
19945
  }
19913
19946
  const nodesSelectionPlugin = this.getNodesSelectionPlugin();
19914
19947
  nodesSelectionPlugin?.setSelectedNodes(realNodes);
19915
- this.instance?.triggerAction("fitToSelectionTool", {
19916
- previousAction: "selectionTool",
19948
+ this.instance?.triggerAction(FIT_TO_SELECTION_TOOL_ACTION_NAME, {
19949
+ previousAction: SELECTION_TOOL_ACTION_NAME,
19917
19950
  smartZoom: true
19918
19951
  });
19919
19952
  this.instance.emitEvent("onPaste", {
@@ -20188,6 +20221,33 @@ const augmentKonvaNodeClass = (config) => {
20188
20221
  Konva.Node.prototype.closeCrop = function() {};
20189
20222
  Konva.Node.prototype.resetCrop = function() {};
20190
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() {};
20191
20251
  };
20192
20252
  var WeaveNode = class {
20193
20253
  async register(instance) {
@@ -20479,10 +20539,11 @@ var WeaveNode = class {
20479
20539
  node.off("dragstart");
20480
20540
  node.on("dragstart", (e) => {
20481
20541
  const nodeTarget = e.target;
20542
+ if (!e.evt) return;
20482
20543
  let isWheelMousePressed = false;
20483
- if (e.evt.button === 1) isWheelMousePressed = true;
20544
+ if (e.evt?.button === 1) isWheelMousePressed = true;
20484
20545
  this.getNodesSelectionFeedbackPlugin()?.hideSelectionHalo(nodeTarget);
20485
- const canMove = nodeTarget?.canDrag() ?? false;
20546
+ const canMove = typeof nodeTarget?.canDrag === "function" ? nodeTarget.canDrag() : false;
20486
20547
  if (!canMove) {
20487
20548
  nodeTarget.stopDrag();
20488
20549
  return;
@@ -20534,7 +20595,7 @@ var WeaveNode = class {
20534
20595
  nodesSelectionPlugin?.setSelectedNodes([]);
20535
20596
  requestAnimationFrame(() => {
20536
20597
  nodesSelectionPlugin?.setSelectedNodes(this.instance.getCloningManager().getClones());
20537
- clone?.startDrag(e.evt);
20598
+ if (clone?.getStage()) clone.startDrag(e.evt);
20538
20599
  });
20539
20600
  }
20540
20601
  if (this.getNodesSelectionPlugin()?.getSelectedNodes().length === 1) this.instance.setMutexLock({
@@ -20545,7 +20606,7 @@ var WeaveNode = class {
20545
20606
  const handleDragMove = (e) => {
20546
20607
  const nodeTarget = e.target;
20547
20608
  let isWheelMousePressed = false;
20548
- if (e.evt.button === 1) isWheelMousePressed = true;
20609
+ if (e.evt?.button === 1) isWheelMousePressed = true;
20549
20610
  e.cancelBubble = true;
20550
20611
  if (e.evt?.buttons === 0) {
20551
20612
  nodeTarget.stopDrag();
@@ -20737,12 +20798,12 @@ var WeaveNode = class {
20737
20798
  }
20738
20799
  if (isNodeSelectionEnabled && this.isSelecting() && !this.isNodeSelected(realNode) && !this.isPasting() && isTargetable && !(isLocked || isMutexLocked) && stage.mode() === WEAVE_STAGE_DEFAULT_MODE) {
20739
20800
  showHover = true;
20740
- stage.container().style.cursor = realNode?.defineMousePointer() ?? "pointer";
20801
+ stage.container().style.cursor = (typeof node?.defineMousePointer === "function" ? node.defineMousePointer() : null) ?? "pointer";
20741
20802
  cancelBubble = true;
20742
20803
  }
20743
20804
  if (isNodeSelectionEnabled && this.isSelecting() && this.isNodeSelected(realNode) && !this.isPasting() && isTargetable && !(isLocked || isMutexLocked) && stage.mode() === WEAVE_STAGE_DEFAULT_MODE) {
20744
20805
  showHover = true;
20745
- stage.container().style.cursor = realNode?.defineMousePointer() ?? "grab";
20806
+ stage.container().style.cursor = (typeof node?.defineMousePointer === "function" ? node.defineMousePointer() : null) ?? "grab";
20746
20807
  cancelBubble = true;
20747
20808
  }
20748
20809
  if (!isTargetable) cancelBubble = true;
@@ -22025,7 +22086,7 @@ var WeaveRegisterManager = class {
22025
22086
 
22026
22087
  //#endregion
22027
22088
  //#region package.json
22028
- var version = "3.9.0";
22089
+ var version = "3.9.2";
22029
22090
 
22030
22091
  //#endregion
22031
22092
  //#region src/managers/setup.ts
@@ -24203,6 +24264,7 @@ function loadImageSource(image, options) {
24203
24264
  }
24204
24265
  async function downscaleImageFile(file, ratio) {
24205
24266
  const bitmap = await createImageBitmap(file);
24267
+ if (bitmap.width === 0) throw new Error("Invalid image", { cause: "InvalidImage" });
24206
24268
  const width = Math.round(bitmap.width * ratio);
24207
24269
  const height = Math.round(bitmap.height * ratio);
24208
24270
  const canvas = document.createElement("canvas");
@@ -24219,13 +24281,19 @@ function getImageSizeFromFile(file) {
24219
24281
  const img = new Image();
24220
24282
  const url = URL.createObjectURL(file);
24221
24283
  img.onload = () => {
24284
+ if (img.naturalWidth === 0) {
24285
+ reject(new Error("Invalid image", { cause: "InvalidImage" }));
24286
+ return;
24287
+ }
24222
24288
  resolve({
24223
24289
  width: img.naturalWidth,
24224
24290
  height: img.naturalHeight
24225
24291
  });
24226
24292
  URL.revokeObjectURL(url);
24227
24293
  };
24228
- img.onerror = reject;
24294
+ img.onerror = () => {
24295
+ reject(new Error("Invalid image", { cause: "InvalidImage" }));
24296
+ };
24229
24297
  img.src = url;
24230
24298
  });
24231
24299
  }
@@ -24249,6 +24317,10 @@ const downscaleImageFromURL = (url, options) => {
24249
24317
  const img = new Image();
24250
24318
  img.crossOrigin = crossOrigin;
24251
24319
  img.onload = () => {
24320
+ if (img.naturalWidth === 0) {
24321
+ reject(new Error("Invalid image", { cause: "InvalidImage" }));
24322
+ return;
24323
+ }
24252
24324
  const ratio = Math.min(maxWidth / img.width, maxHeight / img.height, 1);
24253
24325
  const width = Math.round(img.width * ratio);
24254
24326
  const height = Math.round(img.height * ratio);
@@ -24259,7 +24331,9 @@ const downscaleImageFromURL = (url, options) => {
24259
24331
  ctx.drawImage(img, 0, 0, width, height);
24260
24332
  resolve(canvas.toDataURL(type));
24261
24333
  };
24262
- img.onerror = reject;
24334
+ img.onerror = () => {
24335
+ reject(new Error("Invalid image", { cause: "InvalidImage" }));
24336
+ };
24263
24337
  img.src = url;
24264
24338
  });
24265
24339
  };
@@ -27017,15 +27091,24 @@ var WeaveImageNode = class extends WeaveNode {
27017
27091
  const imageURLToLoad = imageURL ?? "http://localhost/false-image";
27018
27092
  this.imageFallback[imageId] = Konva.Util.createImageElement();
27019
27093
  this.imageFallback[imageId].crossOrigin = this.config.crossOrigin;
27020
- this.imageFallback[imageId].onerror = (error) => {
27094
+ this.imageFallback[imageId].onerror = () => {
27021
27095
  this.imageState[imageId] = {
27022
27096
  status: "error-fallback",
27023
27097
  loaded: false,
27024
27098
  error: true
27025
27099
  };
27026
- onError(error);
27100
+ onError(new Error(`Failed to load fallback image from provided URL`, { cause: "ErrorLoadingFallbackImage" }));
27027
27101
  };
27028
27102
  this.imageFallback[imageId].onload = async () => {
27103
+ if (this.imageFallback[imageId].width === 0) {
27104
+ this.imageState[imageId] = {
27105
+ status: "error-fallback",
27106
+ loaded: false,
27107
+ error: true
27108
+ };
27109
+ onError(new Error(`Invalid fallback image provided`, { cause: "InvalidFallbackImage" }));
27110
+ return;
27111
+ }
27029
27112
  this.imageState[imageId] = {
27030
27113
  status: "loading",
27031
27114
  loaded: true,
@@ -27052,15 +27135,19 @@ var WeaveImageNode = class extends WeaveNode {
27052
27135
  }
27053
27136
  this.imageSource[imageId] = Konva.Util.createImageElement();
27054
27137
  this.imageSource[imageId].crossOrigin = this.config.crossOrigin;
27055
- this.imageSource[imageId].onerror = (error) => {
27138
+ this.imageSource[imageId].onerror = () => {
27056
27139
  if (!loadingTryout) {
27057
27140
  const stage = this.instance.getStage();
27058
27141
  const image = stage.findOne(`#${imageId}`);
27059
27142
  if (image) this.setErrorState(imageId, image);
27060
27143
  }
27061
- onError(error);
27144
+ onError(new Error(`Failed to load image from provided URL`, { cause: "ErrorLoadingImage" }));
27062
27145
  };
27063
27146
  this.imageSource[imageId].onload = async () => {
27147
+ if (this.imageSource[imageId].width === 0) {
27148
+ onError(new Error(`Invalid image provided`, { cause: "InvalidImage" }));
27149
+ return;
27150
+ }
27064
27151
  const stage = this.instance.getStage();
27065
27152
  if (!this.instance.isServerSide()) stage.container().style.cursor = "pointer";
27066
27153
  this.imageState[imageId] = {
@@ -27152,14 +27239,16 @@ var WeaveImageNode = class extends WeaveNode {
27152
27239
  }
27153
27240
  },
27154
27241
  onError: (error) => {
27155
- if (!this.config.useFallbackImage) {
27242
+ let isInvalidImage = false;
27243
+ if (error.cause === "InvalidImage") isInvalidImage = true;
27244
+ if (!this.config.useFallbackImage && !isInvalidImage) {
27156
27245
  const tryoutAttempts = this.imageTryoutAttempts[id] ?? 0;
27157
27246
  if (tryoutAttempts - 1 < this.config.imageLoading.maxRetryAttempts) {
27158
27247
  this.loadImageTryout(id);
27159
27248
  return;
27160
27249
  } else this.setErrorState(id, image);
27161
27250
  }
27162
- if (loadTryout) {
27251
+ if (loadTryout && !isInvalidImage) {
27163
27252
  const tryoutAttempts = this.imageTryoutAttempts[id] ?? 0;
27164
27253
  if (tryoutAttempts - 1 < this.config.imageLoading.maxRetryAttempts) {
27165
27254
  this.loadImageTryout(id);
@@ -27172,12 +27261,7 @@ var WeaveImageNode = class extends WeaveNode {
27172
27261
  return;
27173
27262
  }
27174
27263
  this.setErrorState(id, image);
27175
- image.setAttrs({ image: void 0 });
27176
- console.error("Error loading image", error);
27177
27264
  this.resolveAsyncElement(id);
27178
- imagePlaceholder?.setAttrs({ visible: true });
27179
- internalImage?.setAttrs({ visible: false });
27180
- this.cacheNode(image);
27181
27265
  }
27182
27266
  }, loadTryout);
27183
27267
  }
@@ -29669,8 +29753,7 @@ var WeaveVideoNode = class extends WeaveNode {
29669
29753
  this.videoPlaceholder[id] = Konva.Util.createImageElement();
29670
29754
  this.videoPlaceholder[id].crossOrigin = this.config.crossOrigin;
29671
29755
  this.videoPlaceholder[id].src = realVideoPlaceholderURL;
29672
- this.videoPlaceholder[id].onerror = (error) => {
29673
- console.error("Error loading video placeholder", realVideoPlaceholderURL, error);
29756
+ this.videoPlaceholder[id].onerror = () => {
29674
29757
  this.resolveAsyncElement(id);
29675
29758
  };
29676
29759
  this.videoPlaceholder[id].onload = () => {
@@ -32708,13 +32791,13 @@ var WeaveZoomOutToolAction = class extends WeaveAction {
32708
32791
  const stageZoomPlugin = this.getStageZoomPlugin();
32709
32792
  if (!stageZoomPlugin.canZoomOut()) return;
32710
32793
  stageZoomPlugin.zoomOut();
32711
- this.previousAction = params.previousAction;
32794
+ this.previousAction = params?.previousAction;
32712
32795
  this.cancelAction = cancelAction;
32713
32796
  this.cancelAction();
32714
32797
  }
32715
32798
  cleanup() {
32716
32799
  const stage = this.instance.getStage();
32717
- if (this.previousAction !== void 0) this.instance.triggerAction(this.previousAction);
32800
+ if (this.previousAction) this.instance.triggerAction(this.previousAction);
32718
32801
  stage.container().style.cursor = "default";
32719
32802
  }
32720
32803
  };
@@ -32746,13 +32829,13 @@ var WeaveZoomInToolAction = class extends WeaveAction {
32746
32829
  const stageZoomPlugin = this.getStageZoomPlugin();
32747
32830
  if (!stageZoomPlugin.canZoomIn()) return;
32748
32831
  stageZoomPlugin.zoomIn();
32749
- this.previousAction = params.previousAction;
32832
+ this.previousAction = params?.previousAction;
32750
32833
  this.cancelAction = cancelAction;
32751
32834
  this.cancelAction();
32752
32835
  }
32753
32836
  cleanup() {
32754
32837
  const stage = this.instance.getStage();
32755
- if (this.previousAction !== void 0) this.instance.triggerAction(this.previousAction);
32838
+ if (this.previousAction) this.instance.triggerAction(this.previousAction);
32756
32839
  stage.container().style.cursor = "default";
32757
32840
  }
32758
32841
  };
@@ -32783,21 +32866,17 @@ var WeaveFitToScreenToolAction = class extends WeaveAction {
32783
32866
  trigger(cancelAction, params) {
32784
32867
  const stageZoomPlugin = this.getStageZoomPlugin();
32785
32868
  if (stageZoomPlugin) stageZoomPlugin.fitToScreen({ overrideZoom: params?.overrideZoom ?? true });
32786
- this.previousAction = params.previousAction;
32869
+ this.previousAction = params?.previousAction;
32787
32870
  this.cancelAction = cancelAction;
32788
32871
  this.cancelAction();
32789
32872
  }
32790
32873
  cleanup() {
32791
32874
  const stage = this.instance.getStage();
32792
- if (this.previousAction !== void 0) this.instance.triggerAction(this.previousAction);
32875
+ if (this.previousAction) this.instance.triggerAction(this.previousAction);
32793
32876
  stage.container().style.cursor = "default";
32794
32877
  }
32795
32878
  };
32796
32879
 
32797
- //#endregion
32798
- //#region src/actions/fit-to-selection-tool/constants.ts
32799
- const FIT_TO_SELECTION_TOOL_ACTION_NAME = "fitToSelectionTool";
32800
-
32801
32880
  //#endregion
32802
32881
  //#region src/actions/fit-to-selection-tool/fit-to-selection-tool.ts
32803
32882
  var WeaveFitToSelectionToolAction = class extends WeaveAction {
@@ -32829,13 +32908,13 @@ var WeaveFitToSelectionToolAction = class extends WeaveAction {
32829
32908
  smartZoom: params?.smartZoom ?? false,
32830
32909
  overrideZoom: params?.overrideZoom ?? true
32831
32910
  });
32832
- this.previousAction = params.previousAction;
32911
+ this.previousAction = params?.previousAction;
32833
32912
  this.cancelAction = cancelAction;
32834
32913
  this.cancelAction();
32835
32914
  }
32836
32915
  cleanup() {
32837
32916
  const stage = this.instance.getStage();
32838
- if (this.previousAction !== void 0) this.instance.triggerAction(this.previousAction);
32917
+ if (this.previousAction) this.instance.triggerAction(this.previousAction);
32839
32918
  stage.container().style.cursor = "default";
32840
32919
  }
32841
32920
  };
@@ -34119,7 +34198,7 @@ var WeaveBrushToolAction = class extends WeaveAction {
34119
34198
  if (this.state !== BRUSH_TOOL_STATE.IDLE) return;
34120
34199
  if (this.getZoomPlugin()?.isPinching()) return;
34121
34200
  if (this.isSpacePressed) return;
34122
- if (e.evt.button !== 0) return;
34201
+ if (e?.evt?.button !== 0) return;
34123
34202
  const pointPressure = this.getEventPressure(e);
34124
34203
  this.handleStartStroke(pointPressure);
34125
34204
  e.evt.stopPropagation();
@@ -37976,13 +38055,13 @@ var WeaveStageGridPlugin = class extends WeavePlugin {
37976
38055
  });
37977
38056
  stage.on("pointerdown", (e) => {
37978
38057
  const activeAction = this.instance.getActiveAction();
37979
- if (e && e.evt.button === 0 && activeAction === MOVE_TOOL_ACTION_NAME) this.moveToolActive = true;
37980
- if (e && (e.evt.button === 2 || e.evt.buttons === 4)) this.isMouseMiddleButtonPressed = true;
38058
+ if (e && e?.evt?.button === 0 && activeAction === MOVE_TOOL_ACTION_NAME) this.moveToolActive = true;
38059
+ if (e && (e?.evt?.button === 2 || e?.evt?.buttons === 4)) this.isMouseMiddleButtonPressed = true;
37981
38060
  });
37982
38061
  stage.on("pointerup", (e) => {
37983
38062
  const activeAction = this.instance.getActiveAction();
37984
- if (e && e.evt.button === 0 && activeAction === MOVE_TOOL_ACTION_NAME) this.moveToolActive = false;
37985
- if (e && (e.evt.button === 1 || e.evt.buttons === 0)) this.isMouseMiddleButtonPressed = false;
38063
+ if (e && e?.evt?.button === 0 && activeAction === MOVE_TOOL_ACTION_NAME) this.moveToolActive = false;
38064
+ if (e && (e?.evt?.button === 1 || e?.evt?.buttons === 0)) this.isMouseMiddleButtonPressed = false;
37986
38065
  });
37987
38066
  const handleMouseMove = () => {
37988
38067
  if (!this.enabled || !(this.isSpaceKeyPressed || this.isMouseMiddleButtonPressed || this.moveToolActive)) return;
@@ -38303,16 +38382,16 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
38303
38382
  let lastPos = null;
38304
38383
  stage.on("pointerdown", (e) => {
38305
38384
  this.pointers.set(e.evt.pointerId, {
38306
- x: e.evt.clientX,
38307
- y: e.evt.clientY
38385
+ x: e?.evt?.clientX ?? 0,
38386
+ y: e?.evt?.clientY ?? 0
38308
38387
  });
38309
38388
  if (this.pointers.size > 1) return;
38310
38389
  const activeAction = this.instance.getActiveAction();
38311
38390
  this.enableMove = false;
38312
38391
  if (activeAction === MOVE_TOOL_ACTION_NAME) this.moveToolActive = true;
38313
- if (e.evt.pointerType === "mouse" && e.evt.buttons === 1) this.isMouseLeftButtonPressed = true;
38314
- if (e.evt.pointerType === "mouse" && e.evt.buttons === 4) this.isMouseMiddleButtonPressed = true;
38315
- const isTouchOrPen = ["touch", "pen"].includes(e.evt.pointerType);
38392
+ if (e.evt.pointerType === "mouse" && e?.evt?.buttons === 1) this.isMouseLeftButtonPressed = true;
38393
+ if (e.evt.pointerType === "mouse" && e?.evt?.buttons === 4) this.isMouseMiddleButtonPressed = true;
38394
+ const isTouchOrPen = ["touch", "pen"].includes(e?.evt?.pointerType);
38316
38395
  if (this.enabled && (this.isSpaceKeyPressed || this.moveToolActive && (this.isMouseLeftButtonPressed || isTouchOrPen) || this.isMouseMiddleButtonPressed)) this.enableMove = true;
38317
38396
  if (this.enableMove) {
38318
38397
  this.isDragging = true;
@@ -38321,7 +38400,7 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
38321
38400
  }
38322
38401
  });
38323
38402
  stage.on("pointercancel", (e) => {
38324
- this.pointers.delete(e.evt.pointerId);
38403
+ if (e?.evt?.pointerId) this.pointers.delete(e.evt.pointerId);
38325
38404
  lastPos = null;
38326
38405
  });
38327
38406
  const handleMouseMove = (e) => {