@inditextech/weave-sdk 3.9.0-SNAPSHOT.186.1 → 3.9.1

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";
@@ -20754,8 +20781,8 @@ var WeaveNode = class {
20754
20781
  return cancelBubble;
20755
20782
  }
20756
20783
  handleMouseout(e, node) {
20757
- const isCtrlOrMetaPressed = e.evt.ctrlKey || e.evt.metaKey;
20758
- if (isCtrlOrMetaPressed) return;
20784
+ const isCtrlOrMetaPressed = e.evt?.ctrlKey || e.evt?.metaKey;
20785
+ if (isCtrlOrMetaPressed) return false;
20759
20786
  const realNode = this.instance.getInstanceRecursive(node);
20760
20787
  if (realNode) this.hideHoverState();
20761
20788
  }
@@ -21409,10 +21436,16 @@ var WeaveTargetingManager = class {
21409
21436
  const utilityLayer = this.instance.getUtilityLayer();
21410
21437
  if (utilityLayer) utilityLayer.visible(false);
21411
21438
  let containerAlt = containerOverCursor(this.instance, [], relativeMousePointer);
21412
- if (!containerAlt) containerAlt = this.instance.getMainLayer();
21413
21439
  const nodesSelection = this.instance.getPlugin("nodesSelection");
21414
21440
  if (nodesSelection) nodesSelection.getTransformer().visible(false);
21415
- relativeMousePointer = containerAlt?.getRelativePointerPosition() ?? relativeMousePointer;
21441
+ if (containerAlt && point === void 0) relativeMousePointer = containerAlt.getRelativePointerPosition() ?? relativeMousePointer;
21442
+ if (!containerAlt && point === void 0) {
21443
+ containerAlt = this.instance.getMainLayer();
21444
+ relativeMousePointer = containerAlt?.getRelativePointerPosition() ?? {
21445
+ x: 0,
21446
+ y: 0
21447
+ };
21448
+ }
21416
21449
  if (utilityLayer) utilityLayer.visible(true);
21417
21450
  if (nodesSelection) nodesSelection.getTransformer().visible(true);
21418
21451
  return {
@@ -22007,7 +22040,7 @@ var WeaveRegisterManager = class {
22007
22040
 
22008
22041
  //#endregion
22009
22042
  //#region package.json
22010
- var version = "3.9.0-SNAPSHOT.186.1";
22043
+ var version = "3.9.1";
22011
22044
 
22012
22045
  //#endregion
22013
22046
  //#region src/managers/setup.ts
@@ -25708,7 +25741,7 @@ const WEAVE_IMAGE_DEFAULT_CONFIG = {
25708
25741
  cursor: { loading: "wait" }
25709
25742
  },
25710
25743
  imageLoading: {
25711
- maxRetryAttempts: 15,
25744
+ maxRetryAttempts: 3,
25712
25745
  retryDelayMs: 2e3
25713
25746
  },
25714
25747
  crossOrigin: "anonymous",
@@ -25758,19 +25791,7 @@ var WeaveImageCrop = class WeaveImageCrop {
25758
25791
  this.onClose = () => {};
25759
25792
  this.handleHide = this.hide.bind(this);
25760
25793
  }
25761
- show(onClose, options) {
25762
- this.onClose = onClose;
25763
- const nodeEdgeSnappingPlugin = this.getNodesEdgeSnappingPlugin();
25764
- if (nodeEdgeSnappingPlugin) nodeEdgeSnappingPlugin.disable();
25765
- const nodeDistanceSnappingPlugin = this.getNodesDistanceSnappingPlugin();
25766
- if (nodeDistanceSnappingPlugin) nodeDistanceSnappingPlugin.disable();
25767
- const nodesSelectionPlugin = this.getNodesSelectionPlugin();
25768
- if (nodesSelectionPlugin) nodesSelectionPlugin.disable();
25769
- this.node.clearCache(this.image);
25770
- this.image.setAttrs({ cropping: true });
25771
- this.image.listening(false);
25772
- const imageAttrs = this.image.getAttrs();
25773
- this.internalImage.hide();
25794
+ setupCropImage(imageAttrs, visible) {
25774
25795
  this.cropGroup.destroyChildren();
25775
25796
  const actualScale = imageAttrs.uncroppedImage.width / imageAttrs.imageInfo.width;
25776
25797
  const cropScale = imageAttrs.cropInfo ? imageAttrs.cropInfo.scaleX : actualScale;
@@ -25784,10 +25805,26 @@ var WeaveImageCrop = class WeaveImageCrop {
25784
25805
  scaleY: 1,
25785
25806
  image: this.internalImage.image(),
25786
25807
  crop: void 0,
25787
- visible: true,
25808
+ visible,
25788
25809
  listening: false,
25789
25810
  draggable: false
25790
25811
  });
25812
+ return { realScale };
25813
+ }
25814
+ show(onClose, options) {
25815
+ this.onClose = onClose;
25816
+ const nodeEdgeSnappingPlugin = this.getNodesEdgeSnappingPlugin();
25817
+ if (nodeEdgeSnappingPlugin) nodeEdgeSnappingPlugin.disable();
25818
+ const nodeDistanceSnappingPlugin = this.getNodesDistanceSnappingPlugin();
25819
+ if (nodeDistanceSnappingPlugin) nodeDistanceSnappingPlugin.disable();
25820
+ const nodesSelectionPlugin = this.getNodesSelectionPlugin();
25821
+ if (nodesSelectionPlugin) nodesSelectionPlugin.disable();
25822
+ this.node.clearCache(this.image);
25823
+ this.image.setAttrs({ cropping: true });
25824
+ this.image.listening(false);
25825
+ const imageAttrs = this.image.getAttrs();
25826
+ this.internalImage.hide();
25827
+ const { realScale } = this.setupCropImage(imageAttrs, true);
25791
25828
  this.imageOffsetX = imageAttrs.cropInfo ? imageAttrs.cropInfo.x * realScale : 0;
25792
25829
  this.imageOffsetY = imageAttrs.cropInfo ? imageAttrs.cropInfo.y * realScale : 0;
25793
25830
  const cropModeConfiguration = this.node.getConfiguration().cropMode;
@@ -26164,23 +26201,7 @@ var WeaveImageCrop = class WeaveImageCrop {
26164
26201
  }
26165
26202
  unCrop() {
26166
26203
  const imageAttrs = this.image.getAttrs();
26167
- this.cropGroup.destroyChildren();
26168
- const actualScale = imageAttrs.uncroppedImage.width / imageAttrs.imageInfo.width;
26169
- const cropScale = imageAttrs.cropInfo ? imageAttrs.cropInfo.scaleX : actualScale;
26170
- const realScale = actualScale / cropScale;
26171
- this.cropImage = new Konva.Image({
26172
- x: imageAttrs.cropInfo ? -imageAttrs.cropInfo.x * realScale : 0,
26173
- y: imageAttrs.cropInfo ? -imageAttrs.cropInfo.y * realScale : 0,
26174
- width: imageAttrs.uncroppedImage.width,
26175
- height: imageAttrs.uncroppedImage.height,
26176
- scaleX: 1,
26177
- scaleY: 1,
26178
- image: this.internalImage.image(),
26179
- crop: void 0,
26180
- visible: false,
26181
- listening: false,
26182
- draggable: false
26183
- });
26204
+ this.setupCropImage(imageAttrs, false);
26184
26205
  this.cropGroup.add(this.cropImage);
26185
26206
  const cropImageStage = this.cropImage.getAbsolutePosition();
26186
26207
  this.image.setAttrs({
@@ -26229,12 +26250,80 @@ var WeaveImageCrop = class WeaveImageCrop {
26229
26250
  this.instance.updateNode(this.node.serialize(this.image));
26230
26251
  }
26231
26252
  }
26253
+ handleClipExternal(image, reference) {
26254
+ const stage = this.instance.getStage();
26255
+ const originalRotation = image.getAbsoluteRotation();
26256
+ if (image.getAbsoluteRotation() !== reference.getAbsoluteRotation()) throw new Error("Image and reference must have the same rotation", { cause: "RotationNotAligned" });
26257
+ const originalContainer = image.getParent();
26258
+ const group = new Konva.Group();
26259
+ image.moveTo(group);
26260
+ reference.moveTo(group);
26261
+ originalContainer?.add(group);
26262
+ group.rotate(-originalRotation);
26263
+ const dImage = group.findOne("#" + image.getAttrs().id);
26264
+ const dReference = group.findOne("#" + reference.getAttrs().id);
26265
+ const intersectionRectAbs = this.getIntersectionRect(dImage, dReference);
26266
+ const intersectionRect = this.getIntersectionRect(dImage, dReference, stage);
26267
+ const imageRect = dImage.getClientRect({
26268
+ relativeTo: stage,
26269
+ skipStroke: true
26270
+ });
26271
+ if (!intersectionRect || !intersectionRectAbs) return;
26272
+ const imageAttrs = this.image.getAttrs();
26273
+ const actualScale = imageAttrs.uncroppedImage.width / imageAttrs.imageInfo.width;
26274
+ const cropScale = imageAttrs.cropInfo ? imageAttrs.cropInfo.scaleX : actualScale;
26275
+ const realScale = actualScale / cropScale;
26276
+ const imageOffsetX = imageAttrs.cropInfo ? imageAttrs.cropInfo.x * realScale : 0;
26277
+ const imageOffsetY = imageAttrs.cropInfo ? imageAttrs.cropInfo.y * realScale : 0;
26278
+ const diffX = intersectionRect.x - imageRect.x;
26279
+ const diffY = intersectionRect.y - imageRect.y;
26280
+ const realClipRect = {
26281
+ scaleX: actualScale,
26282
+ scaleY: actualScale,
26283
+ x: WeaveImageCrop.roundTo6Decimals(diffX + imageOffsetX),
26284
+ y: WeaveImageCrop.roundTo6Decimals(diffY + imageOffsetY),
26285
+ width: WeaveImageCrop.roundTo6Decimals(intersectionRect.width),
26286
+ height: WeaveImageCrop.roundTo6Decimals(intersectionRect.height)
26287
+ };
26288
+ if (dImage) {
26289
+ const cropSize = {
26290
+ x: diffX,
26291
+ y: diffY,
26292
+ width: intersectionRect.width,
26293
+ height: intersectionRect.height
26294
+ };
26295
+ dImage.setAttrs({
26296
+ width: intersectionRect.width,
26297
+ height: intersectionRect.height,
26298
+ cropInfo: realClipRect,
26299
+ cropSize,
26300
+ uncroppedImage: {
26301
+ width: imageAttrs.uncroppedImage.width,
26302
+ height: imageAttrs.uncroppedImage.height
26303
+ }
26304
+ });
26305
+ dImage.setAbsolutePosition(intersectionRectAbs);
26306
+ group.rotate(originalRotation);
26307
+ group.getChildren().forEach((child) => {
26308
+ child.moveTo(originalContainer);
26309
+ });
26310
+ group.destroy();
26311
+ const fImage = stage.findOne("#" + image.getAttrs().id);
26312
+ if (fImage) this.instance.updateNodeNT(this.node.serialize(fImage));
26313
+ }
26314
+ }
26232
26315
  static roundTo6Decimals(value) {
26233
26316
  return parseFloat(value.toFixed(6));
26234
26317
  }
26235
- getIntersectionRect(a, b) {
26236
- const rectA = a.getClientRect({ skipStroke: true });
26237
- const rectB = b.getClientRect({ skipStroke: true });
26318
+ getIntersectionRect(a, b, relativeTo) {
26319
+ const rectA = a.getClientRect({
26320
+ skipStroke: true,
26321
+ relativeTo
26322
+ });
26323
+ const rectB = b.getClientRect({
26324
+ skipStroke: true,
26325
+ relativeTo
26326
+ });
26238
26327
  const x1 = WeaveImageCrop.roundTo6Decimals(Math.max(rectA.x, rectB.x));
26239
26328
  const y1 = WeaveImageCrop.roundTo6Decimals(Math.max(rectA.y, rectB.y));
26240
26329
  const x2 = WeaveImageCrop.roundTo6Decimals(Math.min(rectA.x + rectA.width, rectB.x + rectB.width));
@@ -26726,8 +26815,8 @@ var WeaveImageNode = class extends WeaveNode {
26726
26815
  y: p.y - offsetY
26727
26816
  }));
26728
26817
  const rect = new Konva.Rect({
26729
- width: absoluteCorners[1].x - absoluteCorners[0].x,
26730
- height: absoluteCorners[2].y - absoluteCorners[0].y,
26818
+ width: Math.hypot(absoluteCorners[1].x - absoluteCorners[0].x, absoluteCorners[1].y - absoluteCorners[0].y),
26819
+ height: Math.hypot(absoluteCorners[3].x - absoluteCorners[0].x, absoluteCorners[3].y - absoluteCorners[0].y),
26731
26820
  fill: "transparent",
26732
26821
  strokeScaleEnabled: false,
26733
26822
  strokeWidth: 2,
@@ -26852,7 +26941,11 @@ var WeaveImageNode = class extends WeaveNode {
26852
26941
  onUpdate(nodeInstance, nextProps) {
26853
26942
  const id = nodeInstance.getAttrs().id;
26854
26943
  const node = nodeInstance;
26855
- nodeInstance.setAttrs({ ...nextProps });
26944
+ nodeInstance.setAttrs({
26945
+ ...nextProps,
26946
+ ...nextProps.cropInfo ? { cropInfo: nextProps.cropInfo } : { cropInfo: void 0 },
26947
+ ...nextProps.cropSize ? { cropSize: nextProps.cropSize } : { cropSize: void 0 }
26948
+ });
26856
26949
  const imagePlaceholder = node.findOne(`#${id}-placeholder`);
26857
26950
  const internalImage = node.findOne(`#${id}-image`);
26858
26951
  const nodeAttrs = node.getAttrs();
@@ -26896,29 +26989,12 @@ var WeaveImageNode = class extends WeaveNode {
26896
26989
  });
26897
26990
  }
26898
26991
  if (this.imageState[id ?? ""]?.loaded && this.imageState[id ?? ""]?.error) {
26899
- imagePlaceholder?.setAttrs({
26900
- ...internalImageProps,
26901
- ...nodeAttrs.imageProperties ?? {},
26902
- name: void 0,
26903
- id: `${id}-placeholder`,
26904
- nodeId: id,
26905
- x: 0,
26906
- y: 0,
26907
- scaleX: 1,
26908
- scaleY: 1,
26909
- rotation: 0,
26910
- visible: true,
26911
- fill: this.config.style.placeholder.fill,
26912
- strokeWidth: 0,
26913
- draggable: false,
26914
- zIndex: 0
26915
- });
26916
26992
  internalImage?.setAttrs({
26917
26993
  ...internalImageProps,
26918
26994
  ...nodeAttrs.imageProperties ?? {},
26919
26995
  name: void 0,
26920
26996
  id: `${id}-image`,
26921
- image: void 0,
26997
+ image: this.imageFallback[id ?? ""],
26922
26998
  nodeId: id,
26923
26999
  x: 0,
26924
27000
  y: 0,
@@ -26929,6 +27005,8 @@ var WeaveImageNode = class extends WeaveNode {
26929
27005
  draggable: false,
26930
27006
  zIndex: 1
26931
27007
  });
27008
+ internalImage?.visible(true);
27009
+ this.updateImageCrop(nodeInstance);
26932
27010
  }
26933
27011
  if (this.imageState[id ?? ""]?.loaded && !this.imageState[id ?? ""]?.error) {
26934
27012
  internalImage?.setAttrs({
@@ -26983,14 +27061,18 @@ var WeaveImageNode = class extends WeaveNode {
26983
27061
  }
26984
27062
  preloadImage(imageId, imageURL, { onLoad, onError }, loadingTryout = false) {
26985
27063
  const imageURLToLoad = imageURL ?? "http://localhost/false-image";
27064
+ if (imageURLToLoad === "") {
27065
+ this.setErrorState(imageId);
27066
+ return;
27067
+ }
26986
27068
  this.imageSource[imageId] = Konva.Util.createImageElement();
26987
27069
  this.imageSource[imageId].crossOrigin = this.config.crossOrigin;
26988
27070
  this.imageSource[imageId].onerror = (error) => {
26989
- if (!loadingTryout) this.imageState[imageId] = {
26990
- status: "error",
26991
- loaded: false,
26992
- error: true
26993
- };
27071
+ if (!loadingTryout) {
27072
+ const stage = this.instance.getStage();
27073
+ const image = stage.findOne(`#${imageId}`);
27074
+ if (image) this.setErrorState(imageId, image);
27075
+ }
26994
27076
  onError(error);
26995
27077
  };
26996
27078
  this.imageSource[imageId].onload = async () => {
@@ -27085,36 +27167,29 @@ var WeaveImageNode = class extends WeaveNode {
27085
27167
  }
27086
27168
  },
27087
27169
  onError: (error) => {
27088
- if (!this.config.useFallbackImage) this.imageTryoutIds[id] = setTimeout(() => {
27089
- const node = this.instance.getStage().findOne(`#${id}`);
27090
- if (node) {
27091
- this.imageTryoutAttempts[id] = (this.imageTryoutAttempts[id] ?? 0) + 1;
27092
- this.loadImage(node.getAttrs(), node, false, true);
27093
- }
27094
- }, this.config.imageLoading.retryDelayMs);
27170
+ if (!this.config.useFallbackImage) {
27171
+ const tryoutAttempts = this.imageTryoutAttempts[id] ?? 0;
27172
+ if (tryoutAttempts - 1 < this.config.imageLoading.maxRetryAttempts) {
27173
+ this.loadImageTryout(id);
27174
+ return;
27175
+ } else this.setErrorState(id, image);
27176
+ }
27095
27177
  if (loadTryout) {
27096
27178
  const tryoutAttempts = this.imageTryoutAttempts[id] ?? 0;
27097
- if (tryoutAttempts < this.config.imageLoading.maxRetryAttempts) this.imageTryoutIds[id] = setTimeout(() => {
27098
- const node = this.instance.getStage().findOne(`#${id}`);
27099
- if (node) {
27100
- this.imageTryoutAttempts[id] = tryoutAttempts + 1;
27101
- this.loadImage(node.getAttrs(), node, false, true);
27102
- }
27103
- }, this.config.imageLoading.retryDelayMs);
27179
+ if (tryoutAttempts - 1 < this.config.imageLoading.maxRetryAttempts) {
27180
+ this.loadImageTryout(id);
27181
+ return;
27182
+ } else this.setErrorState(id, image);
27104
27183
  return;
27105
27184
  }
27106
27185
  if (this.config.useFallbackImage && !useFallback && !loadTryout && imageProps.imageFallback) {
27107
27186
  this.loadImage({ ...params }, image, true);
27108
27187
  return;
27109
27188
  }
27110
- this.imageState[id] = {
27111
- status: "error",
27112
- loaded: false,
27113
- error: true
27114
- };
27189
+ this.setErrorState(id, image);
27115
27190
  image.setAttrs({ image: void 0 });
27191
+ console.error("Error loading image", error);
27116
27192
  this.resolveAsyncElement(id);
27117
- console.error("Error loading image", realImageURL, error);
27118
27193
  imagePlaceholder?.setAttrs({ visible: true });
27119
27194
  internalImage?.setAttrs({ visible: false });
27120
27195
  this.cacheNode(image);
@@ -27244,6 +27319,41 @@ var WeaveImageNode = class extends WeaveNode {
27244
27319
  }
27245
27320
  nodeInstance.destroy();
27246
27321
  }
27322
+ loadImageTryout(imageId) {
27323
+ this.imageTryoutIds[imageId] = setTimeout(() => {
27324
+ const node = this.instance.getStage().findOne(`#${imageId}`);
27325
+ if (node) {
27326
+ const tryoutAttempts = this.imageTryoutAttempts[imageId] ?? 0;
27327
+ this.imageTryoutAttempts[imageId] = tryoutAttempts + 1;
27328
+ this.loadImage(node.getAttrs(), node, false, true);
27329
+ }
27330
+ }, this.config.imageLoading.retryDelayMs);
27331
+ }
27332
+ setErrorState(imageId, image) {
27333
+ this.imageState[imageId] = {
27334
+ status: "loaded",
27335
+ loaded: true,
27336
+ error: true
27337
+ };
27338
+ this.resolveAsyncElement(imageId);
27339
+ if (image) this.cacheNode(image);
27340
+ }
27341
+ cropImageWithReference(image, reference) {
27342
+ const internalImage = image?.findOne(`#${image.getAttrs().id}-image`);
27343
+ const cropGroup = image?.findOne(`#${image.getAttrs().id}-cropGroup`);
27344
+ if (!internalImage || !cropGroup) throw new Error("Provided element is not a valid image node.", { cause: "InvalidImageNode" });
27345
+ this.imageCrop = new WeaveImageCrop(this.instance, this, image, internalImage, cropGroup);
27346
+ this.instance.stateTransactional(() => {
27347
+ this.imageCrop?.handleClipExternal(image, reference);
27348
+ const nodeHandler = this.instance.getNodeHandler(reference.getAttrs().nodeType);
27349
+ if (nodeHandler) {
27350
+ const rectangleState = nodeHandler.serialize(reference);
27351
+ this.instance.removeNodeNT(rectangleState);
27352
+ }
27353
+ });
27354
+ this.getNodesSelectionPlugin()?.setSelectedNodes([image]);
27355
+ this.getNodesSelectionPlugin()?.getHoverTransformer().forceUpdate();
27356
+ }
27247
27357
  };
27248
27358
 
27249
27359
  //#endregion
@@ -34416,14 +34526,15 @@ var WeaveImageToolAction = class extends WeaveAction {
34416
34526
  const dragProperties = this.instance.getDragProperties();
34417
34527
  if (dragProperties && dragId === WEAVE_IMAGE_TOOL_ACTION_NAME) {
34418
34528
  this.instance.getStage().setPointersPositions(e);
34419
- const position = this.instance.getStage().getRelativePointerPosition();
34420
- if (!position) return;
34529
+ const { mousePoint, container } = this.instance.getMousePointer();
34530
+ if (!mousePoint) return;
34421
34531
  this.instance.triggerAction(WEAVE_IMAGE_TOOL_ACTION_NAME, {
34422
34532
  type: WEAVE_IMAGE_TOOL_UPLOAD_TYPE.IMAGE_URL,
34423
34533
  image: dragProperties.imageURL,
34424
34534
  ...dragProperties.imageId ? { imageId: dragProperties.imageId } : {},
34425
34535
  ...dragProperties.forceMainContainer && { forceMainContainer: dragProperties.forceMainContainer },
34426
- position
34536
+ container,
34537
+ position: mousePoint
34427
34538
  });
34428
34539
  }
34429
34540
  });
@@ -34590,7 +34701,7 @@ var WeaveImageToolAction = class extends WeaveAction {
34590
34701
  }
34591
34702
  const { mousePoint, container } = this.instance.getMousePointer(position);
34592
34703
  this.imageAction[nodeId].clickPoint = mousePoint;
34593
- this.imageAction[nodeId].container = container;
34704
+ this.imageAction[nodeId].container = this.imageAction[nodeId].container ?? container;
34594
34705
  const nodeHandler = this.instance.getNodeHandler("image");
34595
34706
  const imageWidth = this.imageAction[nodeId].props.width ? this.imageAction[nodeId].props.width : imageSource?.width;
34596
34707
  const imageHeight = this.imageAction[nodeId].props.height ? this.imageAction[nodeId].props.height : imageSource?.height;
@@ -34657,9 +34768,9 @@ var WeaveImageToolAction = class extends WeaveAction {
34657
34768
  props: this.initProps(),
34658
34769
  imageId: nodeId,
34659
34770
  clickPoint: null,
34660
- container: void 0,
34661
34771
  imageFile: null,
34662
34772
  imageURL: null,
34773
+ container: params?.container,
34663
34774
  forceMainContainer: params?.forceMainContainer ?? false,
34664
34775
  uploadType: null,
34665
34776
  uploadImageFunction: null
@@ -34866,12 +34977,13 @@ var WeaveImagesToolAction = class extends WeaveAction {
34866
34977
  const dragProperties = this.instance.getDragProperties();
34867
34978
  if (dragProperties && dragId === WEAVE_IMAGES_TOOL_ACTION_NAME) {
34868
34979
  this.instance.getStage().setPointersPositions(e);
34869
- const position = this.instance.getStage().getRelativePointerPosition();
34870
- if (!position) return;
34980
+ const { mousePoint, container } = this.instance.getMousePointer();
34981
+ if (!mousePoint) return;
34871
34982
  this.instance.triggerAction(WEAVE_IMAGES_TOOL_ACTION_NAME, {
34872
34983
  type: WEAVE_IMAGES_TOOL_UPLOAD_TYPE.IMAGE_URL,
34873
34984
  images: dragProperties.imagesURL,
34874
- position,
34985
+ container,
34986
+ position: mousePoint,
34875
34987
  ...dragProperties.forceMainContainer && { forceMainContainer: dragProperties.forceMainContainer }
34876
34988
  });
34877
34989
  }
@@ -35032,7 +35144,7 @@ var WeaveImagesToolAction = class extends WeaveAction {
35032
35144
  stage.container().style.cursor = "default";
35033
35145
  const { mousePoint, container } = this.instance.getMousePointer(position);
35034
35146
  this.clickPoint = mousePoint;
35035
- this.container = container;
35147
+ this.container = this.container ?? container;
35036
35148
  const originPoint = {
35037
35149
  x: this.clickPoint?.x ?? 0,
35038
35150
  y: this.clickPoint?.y ?? 0
@@ -35087,10 +35199,8 @@ var WeaveImagesToolAction = class extends WeaveAction {
35087
35199
  },
35088
35200
  uploadImageFunction: uploadImageFunctionInternal,
35089
35201
  ...imageId && { imageId },
35090
- position: {
35091
- x: position$1.x,
35092
- y: position$1.y
35093
- },
35202
+ position: position$1,
35203
+ container: this.container,
35094
35204
  forceMainContainer: this.forceMainContainer,
35095
35205
  nodeId: nodeId$1
35096
35206
  }, true);
@@ -35124,10 +35234,8 @@ var WeaveImagesToolAction = class extends WeaveAction {
35124
35234
  },
35125
35235
  ...imageId && { imageId },
35126
35236
  ...options && { options },
35127
- position: {
35128
- x: position$1.x,
35129
- y: position$1.y
35130
- },
35237
+ position: position$1,
35238
+ container: this.container,
35131
35239
  forceMainContainer: this.forceMainContainer,
35132
35240
  nodeId: nodeId$1
35133
35241
  }, true);
@@ -35160,6 +35268,7 @@ var WeaveImagesToolAction = class extends WeaveAction {
35160
35268
  const selectionPlugin = this.instance.getPlugin("nodesSelection");
35161
35269
  if (selectionPlugin) selectionPlugin.setSelectedNodes([]);
35162
35270
  if (params?.position) this.setState(WEAVE_IMAGES_TOOL_STATE.SELECTED_POSITION);
35271
+ if (params?.container) this.container = params.container;
35163
35272
  this.nodesIds = [];
35164
35273
  this.forceMainContainer = params.forceMainContainer ?? false;
35165
35274
  if (params.type === WEAVE_IMAGES_TOOL_UPLOAD_TYPE.FILE) {
@@ -36977,11 +37086,13 @@ var WeaveVideoToolAction = class extends WeaveAction {
36977
37086
  const dragProperties = this.instance.getDragProperties();
36978
37087
  if (dragProperties && dragId === VIDEO_TOOL_ACTION_NAME) {
36979
37088
  this.instance.getStage().setPointersPositions(e);
36980
- const position = this.instance.getStage().getRelativePointerPosition();
37089
+ const { mousePoint, container } = this.instance.getMousePointer();
37090
+ if (!mousePoint) return;
36981
37091
  this.instance.triggerAction(VIDEO_TOOL_ACTION_NAME, {
36982
37092
  videoId: dragProperties.videoId,
36983
37093
  videoParams: dragProperties.videoParams,
36984
- position
37094
+ container,
37095
+ position: mousePoint
36985
37096
  });
36986
37097
  }
36987
37098
  });
@@ -37032,7 +37143,7 @@ var WeaveVideoToolAction = class extends WeaveAction {
37032
37143
  if (this.videoId && this.videoParams) {
37033
37144
  const { mousePoint, container } = this.instance.getMousePointer(position);
37034
37145
  this.clickPoint = mousePoint;
37035
- this.container = container;
37146
+ this.container = this.container ?? container;
37036
37147
  const nodeHandler = this.instance.getNodeHandler("video");
37037
37148
  if (nodeHandler) {
37038
37149
  const node = nodeHandler.create(this.videoId, {
@@ -37063,6 +37174,7 @@ var WeaveVideoToolAction = class extends WeaveAction {
37063
37174
  this.cancelAction = cancelAction;
37064
37175
  const selectionPlugin = this.instance.getPlugin("nodesSelection");
37065
37176
  if (selectionPlugin) selectionPlugin.setSelectedNodes([]);
37177
+ this.container = params?.container;
37066
37178
  this.forceMainContainer = params?.forceMainContainer ?? false;
37067
37179
  if (params?.videoId) this.updateProps({ videoId: params.videoId });
37068
37180
  if (params?.videoParams) {