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