@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/sdk.node.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");
@@ -441,11 +441,11 @@ var require_lodash = __commonJS({ "../../node_modules/lodash/lodash.js"(exports,
441
441
  /** Used as a safe reference for `undefined` in pre-ES5 environments. */
442
442
  var undefined$1;
443
443
  /** Used as the semantic version number. */
444
- var VERSION = "4.17.21";
444
+ var VERSION = "4.18.1";
445
445
  /** Used as the size to enable large array optimizations. */
446
446
  var LARGE_ARRAY_SIZE$1 = 200;
447
447
  /** Error message constants. */
448
- 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`";
448
+ 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`";
449
449
  /** Used to stand-in for `undefined` hash values. */
450
450
  var HASH_UNDEFINED$2 = "__lodash_hash_undefined__";
451
451
  /** Used as the maximum memoize cache size. */
@@ -1885,6 +1885,10 @@ var require_lodash = __commonJS({ "../../node_modules/lodash/lodash.js"(exports,
1885
1885
  * embedded Ruby (ERB) as well as ES2015 template strings. Change the
1886
1886
  * following template settings to use alternative delimiters.
1887
1887
  *
1888
+ * **Security:** See
1889
+ * [threat model](https://github.com/lodash/lodash/blob/main/threat-model.md)
1890
+ * — `_.template` is insecure and will be removed in v5.
1891
+ *
1888
1892
  * @static
1889
1893
  * @memberOf _
1890
1894
  * @type {Object}
@@ -2287,7 +2291,7 @@ var require_lodash = __commonJS({ "../../node_modules/lodash/lodash.js"(exports,
2287
2291
  * @name has
2288
2292
  * @memberOf SetCache
2289
2293
  * @param {*} value The value to search for.
2290
- * @returns {number} Returns `true` if `value` is found, else `false`.
2294
+ * @returns {boolean} Returns `true` if `value` is found, else `false`.
2291
2295
  */
2292
2296
  function setCacheHas(value) {
2293
2297
  return this.__data__.has(value);
@@ -3825,8 +3829,15 @@ var require_lodash = __commonJS({ "../../node_modules/lodash/lodash.js"(exports,
3825
3829
  */
3826
3830
  function baseUnset(object, path) {
3827
3831
  path = castPath(path, object);
3828
- object = parent(object, path);
3829
- return object == null || delete object[toKey(last(path))];
3832
+ var index = -1, length = path.length;
3833
+ if (!length) return true;
3834
+ while (++index < length) {
3835
+ var key = toKey(path[index]);
3836
+ if (key === "__proto__" && !hasOwnProperty$9.call(object, "__proto__")) return false;
3837
+ if ((key === "constructor" || key === "prototype") && index < length - 1) return false;
3838
+ }
3839
+ var obj = parent(object, path);
3840
+ return obj == null || delete obj[toKey(last(path))];
3830
3841
  }
3831
3842
  /**
3832
3843
  * The base implementation of `_.update`.
@@ -5730,7 +5741,7 @@ var require_lodash = __commonJS({ "../../node_modules/lodash/lodash.js"(exports,
5730
5741
  }
5731
5742
  /**
5732
5743
  * Creates an array with all falsey values removed. The values `false`, `null`,
5733
- * `0`, `""`, `undefined`, and `NaN` are falsey.
5744
+ * `0`, `-0`, `0n`, `""`, `undefined`, and `NaN` are falsy.
5734
5745
  *
5735
5746
  * @static
5736
5747
  * @memberOf _
@@ -6208,7 +6219,7 @@ var require_lodash = __commonJS({ "../../node_modules/lodash/lodash.js"(exports,
6208
6219
  var index = -1, length = pairs == null ? 0 : pairs.length, result$1 = {};
6209
6220
  while (++index < length) {
6210
6221
  var pair = pairs[index];
6211
- result$1[pair[0]] = pair[1];
6222
+ baseAssignValue$4(result$1, pair[0], pair[1]);
6212
6223
  }
6213
6224
  return result$1;
6214
6225
  }
@@ -12311,6 +12322,8 @@ var require_lodash = __commonJS({ "../../node_modules/lodash/lodash.js"(exports,
12311
12322
  * **Note:** JavaScript follows the IEEE-754 standard for resolving
12312
12323
  * floating-point values which can produce unexpected results.
12313
12324
  *
12325
+ * **Note:** If `lower` is greater than `upper`, the values are swapped.
12326
+ *
12314
12327
  * @static
12315
12328
  * @memberOf _
12316
12329
  * @since 0.7.0
@@ -12324,9 +12337,16 @@ var require_lodash = __commonJS({ "../../node_modules/lodash/lodash.js"(exports,
12324
12337
  * _.random(0, 5);
12325
12338
  * // => an integer between 0 and 5
12326
12339
  *
12340
+ * // when lower is greater than upper the values are swapped
12341
+ * _.random(5, 0);
12342
+ * // => an integer between 0 and 5
12343
+ *
12327
12344
  * _.random(5);
12328
12345
  * // => also an integer between 0 and 5
12329
12346
  *
12347
+ * _.random(-5);
12348
+ * // => an integer between -5 and 0
12349
+ *
12330
12350
  * _.random(5, true);
12331
12351
  * // => a floating-point number between 0 and 5
12332
12352
  *
@@ -12859,6 +12879,10 @@ var require_lodash = __commonJS({ "../../node_modules/lodash/lodash.js"(exports,
12859
12879
  * properties may be accessed as free variables in the template. If a setting
12860
12880
  * object is given, it takes precedence over `_.templateSettings` values.
12861
12881
  *
12882
+ * **Security:** `_.template` is insecure and should not be used. It will be
12883
+ * removed in Lodash v5. Avoid untrusted input. See
12884
+ * [threat model](https://github.com/lodash/lodash/blob/main/threat-model.md).
12885
+ *
12862
12886
  * **Note:** In the development build `_.template` utilizes
12863
12887
  * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl)
12864
12888
  * for easier debugging.
@@ -12960,8 +12984,11 @@ var require_lodash = __commonJS({ "../../node_modules/lodash/lodash.js"(exports,
12960
12984
  var settings = lodash.templateSettings;
12961
12985
  if (guard && isIterateeCall$2(string, options, guard)) options = undefined$1;
12962
12986
  string = toString(string);
12963
- options = assignInWith({}, options, settings, customDefaultsAssignIn);
12964
- var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn), importsKeys = keys(imports), importsValues = baseValues(imports, importsKeys);
12987
+ options = assignWith({}, options, settings, customDefaultsAssignIn);
12988
+ var imports = assignWith({}, options.imports, settings.imports, customDefaultsAssignIn), importsKeys = keys(imports), importsValues = baseValues(imports, importsKeys);
12989
+ arrayEach(importsKeys, function(key) {
12990
+ if (reForbiddenIdentifierChars.test(key)) throw new Error$1(INVALID_TEMPL_IMPORTS_ERROR_TEXT);
12991
+ });
12965
12992
  var isEscaping, isEvaluating, index = 0, interpolate = options.interpolate || reNoMatch, source = "__p += '";
12966
12993
  var reDelimiters = RegExp$1((options.escape || reNoMatch).source + "|" + interpolate.source + "|" + (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + "|" + (options.evaluate || reNoMatch).source + "|$", "g");
12967
12994
  var sourceURL = "//# sourceURL=" + (hasOwnProperty$9.call(options, "sourceURL") ? (options.sourceURL + "").replace(/\s/g, " ") : "lodash.templateSources[" + ++templateCounter + "]") + "\n";
@@ -18806,7 +18833,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
18806
18833
  const nodesSelected = tr.nodes();
18807
18834
  if (nodesSelected.length === 1) {
18808
18835
  const node = nodesSelected[0];
18809
- stage.container().style.cursor = node.defineMousePointer() ?? "grab";
18836
+ stage.container().style.cursor = (typeof node?.defineMousePointer === "function" ? node.defineMousePointer() : null) ?? "grab";
18810
18837
  } else stage.container().style.cursor = "grab";
18811
18838
  });
18812
18839
  tr.on("mouseout", (e) => {
@@ -18863,8 +18890,9 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
18863
18890
  let selectedNodes = [];
18864
18891
  tr.on("dragstart", (e) => {
18865
18892
  this.dragInProcess = true;
18893
+ if (!e?.evt) return;
18866
18894
  let isWheelMousePressed = false;
18867
- if (e.evt.button === 1) isWheelMousePressed = true;
18895
+ if (e.evt?.button === 1) isWheelMousePressed = true;
18868
18896
  const mainLayer = this.instance.getMainLayer();
18869
18897
  if (!mainLayer) return;
18870
18898
  initialPos = {
@@ -18901,7 +18929,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
18901
18929
  y: e.target.y()
18902
18930
  };
18903
18931
  let isWheelMousePressed = false;
18904
- if (e.evt.button === 1) isWheelMousePressed = true;
18932
+ if (e.evt?.button === 1) isWheelMousePressed = true;
18905
18933
  e.cancelBubble = true;
18906
18934
  if (initialPos) {
18907
18935
  const moved = this.checkMovedDrag(initialPos, actualPos);
@@ -19244,8 +19272,8 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
19244
19272
  this.handledClickOrTap = false;
19245
19273
  this.pointers[e.evt.pointerId] = e.evt;
19246
19274
  if (e.evt.pointerType === "touch" && Object.keys(this.pointers).length > 1) return;
19247
- if (e.evt.pointerType === "mouse" && e.evt.button !== 0) return;
19248
- if (e.evt.pointerType === "pen" && e.evt.pressure <= .05) return;
19275
+ if (e.evt.pointerType === "mouse" && e.evt?.button !== 0) return;
19276
+ if (e.evt.pointerType === "pen" && e.evt?.pressure <= .05) return;
19249
19277
  if (!this.initialized) return;
19250
19278
  if (!this.active) return;
19251
19279
  if (stage.mode() !== WEAVE_STAGE_DEFAULT_MODE) return;
@@ -19298,8 +19326,9 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
19298
19326
  this.panLoopId = requestAnimationFrame(() => this.panLoop());
19299
19327
  });
19300
19328
  const handleMouseMove = (e) => {
19329
+ if (!e?.evt) return;
19301
19330
  const moved = this.checkMoved(e);
19302
- if (e.evt.buttons === 0) return;
19331
+ if (e.evt?.buttons === 0) return;
19303
19332
  if (e.evt.pointerType === "touch" && Object.keys(this.pointers).length > 1) return;
19304
19333
  if (!this.initialized) return;
19305
19334
  if (!this.active) return;
@@ -19469,7 +19498,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
19469
19498
  this.hideHoverState();
19470
19499
  const selectedGroup = getTargetedNode(this.instance);
19471
19500
  if (!this.initialized) return;
19472
- if (e.evt.pointerType === "mouse" && e.evt.button && e.evt.button !== 0) return;
19501
+ if (e.evt.pointerType === "mouse" && e.evt?.button && e.evt?.button !== 0) return;
19473
19502
  let areNodesSelected = false;
19474
19503
  let nodeTargeted = selectedGroup && !(selectedGroup.getAttrs().active ?? false) ? selectedGroup : e.target;
19475
19504
  if (e.target === this.instance.getStage()) {
@@ -19532,7 +19561,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
19532
19561
  if (areNodesSelected) {
19533
19562
  stage.container().tabIndex = 1;
19534
19563
  stage.container().focus();
19535
- stage.container().style.cursor = nodeTargeted.defineMousePointer() ?? "grab";
19564
+ stage.container().style.cursor = (typeof nodeTargeted?.defineMousePointer === "function" ? nodeTargeted.defineMousePointer() : null) ?? "grab";
19536
19565
  }
19537
19566
  this.triggerSelectedNodesEvent();
19538
19567
  }
@@ -19700,6 +19729,10 @@ const WEAVE_COPY_PASTE_CONFIG_DEFAULT = {
19700
19729
  }
19701
19730
  };
19702
19731
 
19732
+ //#endregion
19733
+ //#region src/actions/fit-to-selection-tool/constants.ts
19734
+ const FIT_TO_SELECTION_TOOL_ACTION_NAME = "fitToSelectionTool";
19735
+
19703
19736
  //#endregion
19704
19737
  //#region src/plugins/copy-paste-nodes/copy-paste-nodes.ts
19705
19738
  var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
@@ -19911,8 +19944,8 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
19911
19944
  }
19912
19945
  const nodesSelectionPlugin = this.getNodesSelectionPlugin();
19913
19946
  nodesSelectionPlugin?.setSelectedNodes(realNodes);
19914
- this.instance?.triggerAction("fitToSelectionTool", {
19915
- previousAction: "selectionTool",
19947
+ this.instance?.triggerAction(FIT_TO_SELECTION_TOOL_ACTION_NAME, {
19948
+ previousAction: SELECTION_TOOL_ACTION_NAME,
19916
19949
  smartZoom: true
19917
19950
  });
19918
19951
  this.instance.emitEvent("onPaste", {
@@ -20187,6 +20220,33 @@ const augmentKonvaNodeClass = (config) => {
20187
20220
  Konva.Node.prototype.closeCrop = function() {};
20188
20221
  Konva.Node.prototype.resetCrop = function() {};
20189
20222
  Konva.Node.prototype.dblClick = function() {};
20223
+ Konva.Node.prototype.allowedAnchors = function() {
20224
+ return [];
20225
+ };
20226
+ Konva.Node.prototype.isSelectable = function() {
20227
+ return true;
20228
+ };
20229
+ Konva.Node.prototype.handleMouseover = function() {};
20230
+ Konva.Node.prototype.handleMouseout = function() {};
20231
+ Konva.Node.prototype.handleSelectNode = function() {};
20232
+ Konva.Node.prototype.handleDeselectNode = function() {};
20233
+ Konva.Node.prototype.defineMousePointer = function() {
20234
+ return "default";
20235
+ };
20236
+ Konva.Node.prototype.canBeHovered = function() {
20237
+ return false;
20238
+ };
20239
+ Konva.Node.prototype.canDrag = function() {
20240
+ return false;
20241
+ };
20242
+ Konva.Node.prototype.canMoveToContainer = function() {
20243
+ return false;
20244
+ };
20245
+ Konva.Node.prototype.getNodeAnchors = function() {
20246
+ return [];
20247
+ };
20248
+ Konva.Node.prototype.lockMutex = function() {};
20249
+ Konva.Node.prototype.releaseMutex = function() {};
20190
20250
  };
20191
20251
  var WeaveNode = class {
20192
20252
  async register(instance) {
@@ -20478,10 +20538,11 @@ var WeaveNode = class {
20478
20538
  node.off("dragstart");
20479
20539
  node.on("dragstart", (e) => {
20480
20540
  const nodeTarget = e.target;
20541
+ if (!e.evt) return;
20481
20542
  let isWheelMousePressed = false;
20482
- if (e.evt.button === 1) isWheelMousePressed = true;
20543
+ if (e.evt?.button === 1) isWheelMousePressed = true;
20483
20544
  this.getNodesSelectionFeedbackPlugin()?.hideSelectionHalo(nodeTarget);
20484
- const canMove = nodeTarget?.canDrag() ?? false;
20545
+ const canMove = typeof nodeTarget?.canDrag === "function" ? nodeTarget.canDrag() : false;
20485
20546
  if (!canMove) {
20486
20547
  nodeTarget.stopDrag();
20487
20548
  return;
@@ -20533,7 +20594,7 @@ var WeaveNode = class {
20533
20594
  nodesSelectionPlugin?.setSelectedNodes([]);
20534
20595
  requestAnimationFrame(() => {
20535
20596
  nodesSelectionPlugin?.setSelectedNodes(this.instance.getCloningManager().getClones());
20536
- clone?.startDrag(e.evt);
20597
+ if (clone?.getStage()) clone.startDrag(e.evt);
20537
20598
  });
20538
20599
  }
20539
20600
  if (this.getNodesSelectionPlugin()?.getSelectedNodes().length === 1) this.instance.setMutexLock({
@@ -20544,7 +20605,7 @@ var WeaveNode = class {
20544
20605
  const handleDragMove = (e) => {
20545
20606
  const nodeTarget = e.target;
20546
20607
  let isWheelMousePressed = false;
20547
- if (e.evt.button === 1) isWheelMousePressed = true;
20608
+ if (e.evt?.button === 1) isWheelMousePressed = true;
20548
20609
  e.cancelBubble = true;
20549
20610
  if (e.evt?.buttons === 0) {
20550
20611
  nodeTarget.stopDrag();
@@ -20736,12 +20797,12 @@ var WeaveNode = class {
20736
20797
  }
20737
20798
  if (isNodeSelectionEnabled && this.isSelecting() && !this.isNodeSelected(realNode) && !this.isPasting() && isTargetable && !(isLocked || isMutexLocked) && stage.mode() === WEAVE_STAGE_DEFAULT_MODE) {
20738
20799
  showHover = true;
20739
- stage.container().style.cursor = realNode?.defineMousePointer() ?? "pointer";
20800
+ stage.container().style.cursor = (typeof node?.defineMousePointer === "function" ? node.defineMousePointer() : null) ?? "pointer";
20740
20801
  cancelBubble = true;
20741
20802
  }
20742
20803
  if (isNodeSelectionEnabled && this.isSelecting() && this.isNodeSelected(realNode) && !this.isPasting() && isTargetable && !(isLocked || isMutexLocked) && stage.mode() === WEAVE_STAGE_DEFAULT_MODE) {
20743
20804
  showHover = true;
20744
- stage.container().style.cursor = realNode?.defineMousePointer() ?? "grab";
20805
+ stage.container().style.cursor = (typeof node?.defineMousePointer === "function" ? node.defineMousePointer() : null) ?? "grab";
20745
20806
  cancelBubble = true;
20746
20807
  }
20747
20808
  if (!isTargetable) cancelBubble = true;
@@ -22013,7 +22074,7 @@ var WeaveRegisterManager = class {
22013
22074
 
22014
22075
  //#endregion
22015
22076
  //#region package.json
22016
- var version = "3.9.0";
22077
+ var version = "3.9.2";
22017
22078
 
22018
22079
  //#endregion
22019
22080
  //#region src/managers/setup.ts
@@ -24191,6 +24252,7 @@ function loadImageSource(image, options) {
24191
24252
  }
24192
24253
  async function downscaleImageFile(file, ratio) {
24193
24254
  const bitmap = await createImageBitmap(file);
24255
+ if (bitmap.width === 0) throw new Error("Invalid image", { cause: "InvalidImage" });
24194
24256
  const width = Math.round(bitmap.width * ratio);
24195
24257
  const height = Math.round(bitmap.height * ratio);
24196
24258
  const canvas = document.createElement("canvas");
@@ -24207,13 +24269,19 @@ function getImageSizeFromFile(file) {
24207
24269
  const img = new Image();
24208
24270
  const url = URL.createObjectURL(file);
24209
24271
  img.onload = () => {
24272
+ if (img.naturalWidth === 0) {
24273
+ reject(new Error("Invalid image", { cause: "InvalidImage" }));
24274
+ return;
24275
+ }
24210
24276
  resolve({
24211
24277
  width: img.naturalWidth,
24212
24278
  height: img.naturalHeight
24213
24279
  });
24214
24280
  URL.revokeObjectURL(url);
24215
24281
  };
24216
- img.onerror = reject;
24282
+ img.onerror = () => {
24283
+ reject(new Error("Invalid image", { cause: "InvalidImage" }));
24284
+ };
24217
24285
  img.src = url;
24218
24286
  });
24219
24287
  }
@@ -24237,6 +24305,10 @@ const downscaleImageFromURL = (url, options) => {
24237
24305
  const img = new Image();
24238
24306
  img.crossOrigin = crossOrigin;
24239
24307
  img.onload = () => {
24308
+ if (img.naturalWidth === 0) {
24309
+ reject(new Error("Invalid image", { cause: "InvalidImage" }));
24310
+ return;
24311
+ }
24240
24312
  const ratio = Math.min(maxWidth / img.width, maxHeight / img.height, 1);
24241
24313
  const width = Math.round(img.width * ratio);
24242
24314
  const height = Math.round(img.height * ratio);
@@ -24247,7 +24319,9 @@ const downscaleImageFromURL = (url, options) => {
24247
24319
  ctx.drawImage(img, 0, 0, width, height);
24248
24320
  resolve(canvas.toDataURL(type));
24249
24321
  };
24250
- img.onerror = reject;
24322
+ img.onerror = () => {
24323
+ reject(new Error("Invalid image", { cause: "InvalidImage" }));
24324
+ };
24251
24325
  img.src = url;
24252
24326
  });
24253
24327
  };
@@ -27005,15 +27079,24 @@ var WeaveImageNode = class extends WeaveNode {
27005
27079
  const imageURLToLoad = imageURL ?? "http://localhost/false-image";
27006
27080
  this.imageFallback[imageId] = Konva.Util.createImageElement();
27007
27081
  this.imageFallback[imageId].crossOrigin = this.config.crossOrigin;
27008
- this.imageFallback[imageId].onerror = (error) => {
27082
+ this.imageFallback[imageId].onerror = () => {
27009
27083
  this.imageState[imageId] = {
27010
27084
  status: "error-fallback",
27011
27085
  loaded: false,
27012
27086
  error: true
27013
27087
  };
27014
- onError(error);
27088
+ onError(new Error(`Failed to load fallback image from provided URL`, { cause: "ErrorLoadingFallbackImage" }));
27015
27089
  };
27016
27090
  this.imageFallback[imageId].onload = async () => {
27091
+ if (this.imageFallback[imageId].width === 0) {
27092
+ this.imageState[imageId] = {
27093
+ status: "error-fallback",
27094
+ loaded: false,
27095
+ error: true
27096
+ };
27097
+ onError(new Error(`Invalid fallback image provided`, { cause: "InvalidFallbackImage" }));
27098
+ return;
27099
+ }
27017
27100
  this.imageState[imageId] = {
27018
27101
  status: "loading",
27019
27102
  loaded: true,
@@ -27040,15 +27123,19 @@ var WeaveImageNode = class extends WeaveNode {
27040
27123
  }
27041
27124
  this.imageSource[imageId] = Konva.Util.createImageElement();
27042
27125
  this.imageSource[imageId].crossOrigin = this.config.crossOrigin;
27043
- this.imageSource[imageId].onerror = (error) => {
27126
+ this.imageSource[imageId].onerror = () => {
27044
27127
  if (!loadingTryout) {
27045
27128
  const stage = this.instance.getStage();
27046
27129
  const image = stage.findOne(`#${imageId}`);
27047
27130
  if (image) this.setErrorState(imageId, image);
27048
27131
  }
27049
- onError(error);
27132
+ onError(new Error(`Failed to load image from provided URL`, { cause: "ErrorLoadingImage" }));
27050
27133
  };
27051
27134
  this.imageSource[imageId].onload = async () => {
27135
+ if (this.imageSource[imageId].width === 0) {
27136
+ onError(new Error(`Invalid image provided`, { cause: "InvalidImage" }));
27137
+ return;
27138
+ }
27052
27139
  const stage = this.instance.getStage();
27053
27140
  if (!this.instance.isServerSide()) stage.container().style.cursor = "pointer";
27054
27141
  this.imageState[imageId] = {
@@ -27140,14 +27227,16 @@ var WeaveImageNode = class extends WeaveNode {
27140
27227
  }
27141
27228
  },
27142
27229
  onError: (error) => {
27143
- if (!this.config.useFallbackImage) {
27230
+ let isInvalidImage = false;
27231
+ if (error.cause === "InvalidImage") isInvalidImage = true;
27232
+ if (!this.config.useFallbackImage && !isInvalidImage) {
27144
27233
  const tryoutAttempts = this.imageTryoutAttempts[id] ?? 0;
27145
27234
  if (tryoutAttempts - 1 < this.config.imageLoading.maxRetryAttempts) {
27146
27235
  this.loadImageTryout(id);
27147
27236
  return;
27148
27237
  } else this.setErrorState(id, image);
27149
27238
  }
27150
- if (loadTryout) {
27239
+ if (loadTryout && !isInvalidImage) {
27151
27240
  const tryoutAttempts = this.imageTryoutAttempts[id] ?? 0;
27152
27241
  if (tryoutAttempts - 1 < this.config.imageLoading.maxRetryAttempts) {
27153
27242
  this.loadImageTryout(id);
@@ -27160,12 +27249,7 @@ var WeaveImageNode = class extends WeaveNode {
27160
27249
  return;
27161
27250
  }
27162
27251
  this.setErrorState(id, image);
27163
- image.setAttrs({ image: void 0 });
27164
- console.error("Error loading image", error);
27165
27252
  this.resolveAsyncElement(id);
27166
- imagePlaceholder?.setAttrs({ visible: true });
27167
- internalImage?.setAttrs({ visible: false });
27168
- this.cacheNode(image);
27169
27253
  }
27170
27254
  }, loadTryout);
27171
27255
  }
@@ -29657,8 +29741,7 @@ var WeaveVideoNode = class extends WeaveNode {
29657
29741
  this.videoPlaceholder[id] = Konva.Util.createImageElement();
29658
29742
  this.videoPlaceholder[id].crossOrigin = this.config.crossOrigin;
29659
29743
  this.videoPlaceholder[id].src = realVideoPlaceholderURL;
29660
- this.videoPlaceholder[id].onerror = (error) => {
29661
- console.error("Error loading video placeholder", realVideoPlaceholderURL, error);
29744
+ this.videoPlaceholder[id].onerror = () => {
29662
29745
  this.resolveAsyncElement(id);
29663
29746
  };
29664
29747
  this.videoPlaceholder[id].onload = () => {
@@ -32696,13 +32779,13 @@ var WeaveZoomOutToolAction = class extends WeaveAction {
32696
32779
  const stageZoomPlugin = this.getStageZoomPlugin();
32697
32780
  if (!stageZoomPlugin.canZoomOut()) return;
32698
32781
  stageZoomPlugin.zoomOut();
32699
- this.previousAction = params.previousAction;
32782
+ this.previousAction = params?.previousAction;
32700
32783
  this.cancelAction = cancelAction;
32701
32784
  this.cancelAction();
32702
32785
  }
32703
32786
  cleanup() {
32704
32787
  const stage = this.instance.getStage();
32705
- if (this.previousAction !== void 0) this.instance.triggerAction(this.previousAction);
32788
+ if (this.previousAction) this.instance.triggerAction(this.previousAction);
32706
32789
  stage.container().style.cursor = "default";
32707
32790
  }
32708
32791
  };
@@ -32734,13 +32817,13 @@ var WeaveZoomInToolAction = class extends WeaveAction {
32734
32817
  const stageZoomPlugin = this.getStageZoomPlugin();
32735
32818
  if (!stageZoomPlugin.canZoomIn()) return;
32736
32819
  stageZoomPlugin.zoomIn();
32737
- this.previousAction = params.previousAction;
32820
+ this.previousAction = params?.previousAction;
32738
32821
  this.cancelAction = cancelAction;
32739
32822
  this.cancelAction();
32740
32823
  }
32741
32824
  cleanup() {
32742
32825
  const stage = this.instance.getStage();
32743
- if (this.previousAction !== void 0) this.instance.triggerAction(this.previousAction);
32826
+ if (this.previousAction) this.instance.triggerAction(this.previousAction);
32744
32827
  stage.container().style.cursor = "default";
32745
32828
  }
32746
32829
  };
@@ -32771,21 +32854,17 @@ var WeaveFitToScreenToolAction = class extends WeaveAction {
32771
32854
  trigger(cancelAction, params) {
32772
32855
  const stageZoomPlugin = this.getStageZoomPlugin();
32773
32856
  if (stageZoomPlugin) stageZoomPlugin.fitToScreen({ overrideZoom: params?.overrideZoom ?? true });
32774
- this.previousAction = params.previousAction;
32857
+ this.previousAction = params?.previousAction;
32775
32858
  this.cancelAction = cancelAction;
32776
32859
  this.cancelAction();
32777
32860
  }
32778
32861
  cleanup() {
32779
32862
  const stage = this.instance.getStage();
32780
- if (this.previousAction !== void 0) this.instance.triggerAction(this.previousAction);
32863
+ if (this.previousAction) this.instance.triggerAction(this.previousAction);
32781
32864
  stage.container().style.cursor = "default";
32782
32865
  }
32783
32866
  };
32784
32867
 
32785
- //#endregion
32786
- //#region src/actions/fit-to-selection-tool/constants.ts
32787
- const FIT_TO_SELECTION_TOOL_ACTION_NAME = "fitToSelectionTool";
32788
-
32789
32868
  //#endregion
32790
32869
  //#region src/actions/fit-to-selection-tool/fit-to-selection-tool.ts
32791
32870
  var WeaveFitToSelectionToolAction = class extends WeaveAction {
@@ -32817,13 +32896,13 @@ var WeaveFitToSelectionToolAction = class extends WeaveAction {
32817
32896
  smartZoom: params?.smartZoom ?? false,
32818
32897
  overrideZoom: params?.overrideZoom ?? true
32819
32898
  });
32820
- this.previousAction = params.previousAction;
32899
+ this.previousAction = params?.previousAction;
32821
32900
  this.cancelAction = cancelAction;
32822
32901
  this.cancelAction();
32823
32902
  }
32824
32903
  cleanup() {
32825
32904
  const stage = this.instance.getStage();
32826
- if (this.previousAction !== void 0) this.instance.triggerAction(this.previousAction);
32905
+ if (this.previousAction) this.instance.triggerAction(this.previousAction);
32827
32906
  stage.container().style.cursor = "default";
32828
32907
  }
32829
32908
  };
@@ -34107,7 +34186,7 @@ var WeaveBrushToolAction = class extends WeaveAction {
34107
34186
  if (this.state !== BRUSH_TOOL_STATE.IDLE) return;
34108
34187
  if (this.getZoomPlugin()?.isPinching()) return;
34109
34188
  if (this.isSpacePressed) return;
34110
- if (e.evt.button !== 0) return;
34189
+ if (e?.evt?.button !== 0) return;
34111
34190
  const pointPressure = this.getEventPressure(e);
34112
34191
  this.handleStartStroke(pointPressure);
34113
34192
  e.evt.stopPropagation();
@@ -37918,13 +37997,13 @@ var WeaveStageGridPlugin = class extends WeavePlugin {
37918
37997
  });
37919
37998
  stage.on("pointerdown", (e) => {
37920
37999
  const activeAction = this.instance.getActiveAction();
37921
- if (e && e.evt.button === 0 && activeAction === MOVE_TOOL_ACTION_NAME) this.moveToolActive = true;
37922
- if (e && (e.evt.button === 2 || e.evt.buttons === 4)) this.isMouseMiddleButtonPressed = true;
38000
+ if (e && e?.evt?.button === 0 && activeAction === MOVE_TOOL_ACTION_NAME) this.moveToolActive = true;
38001
+ if (e && (e?.evt?.button === 2 || e?.evt?.buttons === 4)) this.isMouseMiddleButtonPressed = true;
37923
38002
  });
37924
38003
  stage.on("pointerup", (e) => {
37925
38004
  const activeAction = this.instance.getActiveAction();
37926
- if (e && e.evt.button === 0 && activeAction === MOVE_TOOL_ACTION_NAME) this.moveToolActive = false;
37927
- if (e && (e.evt.button === 1 || e.evt.buttons === 0)) this.isMouseMiddleButtonPressed = false;
38005
+ if (e && e?.evt?.button === 0 && activeAction === MOVE_TOOL_ACTION_NAME) this.moveToolActive = false;
38006
+ if (e && (e?.evt?.button === 1 || e?.evt?.buttons === 0)) this.isMouseMiddleButtonPressed = false;
37928
38007
  });
37929
38008
  const handleMouseMove = () => {
37930
38009
  if (!this.enabled || !(this.isSpaceKeyPressed || this.isMouseMiddleButtonPressed || this.moveToolActive)) return;
@@ -38245,16 +38324,16 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
38245
38324
  let lastPos = null;
38246
38325
  stage.on("pointerdown", (e) => {
38247
38326
  this.pointers.set(e.evt.pointerId, {
38248
- x: e.evt.clientX,
38249
- y: e.evt.clientY
38327
+ x: e?.evt?.clientX ?? 0,
38328
+ y: e?.evt?.clientY ?? 0
38250
38329
  });
38251
38330
  if (this.pointers.size > 1) return;
38252
38331
  const activeAction = this.instance.getActiveAction();
38253
38332
  this.enableMove = false;
38254
38333
  if (activeAction === MOVE_TOOL_ACTION_NAME) this.moveToolActive = true;
38255
- if (e.evt.pointerType === "mouse" && e.evt.buttons === 1) this.isMouseLeftButtonPressed = true;
38256
- if (e.evt.pointerType === "mouse" && e.evt.buttons === 4) this.isMouseMiddleButtonPressed = true;
38257
- const isTouchOrPen = ["touch", "pen"].includes(e.evt.pointerType);
38334
+ if (e.evt.pointerType === "mouse" && e?.evt?.buttons === 1) this.isMouseLeftButtonPressed = true;
38335
+ if (e.evt.pointerType === "mouse" && e?.evt?.buttons === 4) this.isMouseMiddleButtonPressed = true;
38336
+ const isTouchOrPen = ["touch", "pen"].includes(e?.evt?.pointerType);
38258
38337
  if (this.enabled && (this.isSpaceKeyPressed || this.moveToolActive && (this.isMouseLeftButtonPressed || isTouchOrPen) || this.isMouseMiddleButtonPressed)) this.enableMove = true;
38259
38338
  if (this.enableMove) {
38260
38339
  this.isDragging = true;
@@ -38263,7 +38342,7 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
38263
38342
  }
38264
38343
  });
38265
38344
  stage.on("pointercancel", (e) => {
38266
- this.pointers.delete(e.evt.pointerId);
38345
+ if (e?.evt?.pointerId) this.pointers.delete(e.evt.pointerId);
38267
38346
  lastPos = null;
38268
38347
  });
38269
38348
  const handleMouseMove = (e) => {