@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.js +145 -66
- package/dist/sdk.node.js +145 -66
- 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 +7 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +145 -66
- 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";
|
|
@@ -18807,7 +18834,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
18807
18834
|
const nodesSelected = tr.nodes();
|
|
18808
18835
|
if (nodesSelected.length === 1) {
|
|
18809
18836
|
const node = nodesSelected[0];
|
|
18810
|
-
stage.container().style.cursor = node.defineMousePointer() ?? "grab";
|
|
18837
|
+
stage.container().style.cursor = (typeof node?.defineMousePointer === "function" ? node.defineMousePointer() : null) ?? "grab";
|
|
18811
18838
|
} else stage.container().style.cursor = "grab";
|
|
18812
18839
|
});
|
|
18813
18840
|
tr.on("mouseout", (e) => {
|
|
@@ -18864,8 +18891,9 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
18864
18891
|
let selectedNodes = [];
|
|
18865
18892
|
tr.on("dragstart", (e) => {
|
|
18866
18893
|
this.dragInProcess = true;
|
|
18894
|
+
if (!e?.evt) return;
|
|
18867
18895
|
let isWheelMousePressed = false;
|
|
18868
|
-
if (e.evt
|
|
18896
|
+
if (e.evt?.button === 1) isWheelMousePressed = true;
|
|
18869
18897
|
const mainLayer = this.instance.getMainLayer();
|
|
18870
18898
|
if (!mainLayer) return;
|
|
18871
18899
|
initialPos = {
|
|
@@ -18902,7 +18930,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
18902
18930
|
y: e.target.y()
|
|
18903
18931
|
};
|
|
18904
18932
|
let isWheelMousePressed = false;
|
|
18905
|
-
if (e.evt
|
|
18933
|
+
if (e.evt?.button === 1) isWheelMousePressed = true;
|
|
18906
18934
|
e.cancelBubble = true;
|
|
18907
18935
|
if (initialPos) {
|
|
18908
18936
|
const moved = this.checkMovedDrag(initialPos, actualPos);
|
|
@@ -19245,8 +19273,8 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19245
19273
|
this.handledClickOrTap = false;
|
|
19246
19274
|
this.pointers[e.evt.pointerId] = e.evt;
|
|
19247
19275
|
if (e.evt.pointerType === "touch" && Object.keys(this.pointers).length > 1) return;
|
|
19248
|
-
if (e.evt.pointerType === "mouse" && e.evt
|
|
19249
|
-
if (e.evt.pointerType === "pen" && e.evt
|
|
19276
|
+
if (e.evt.pointerType === "mouse" && e.evt?.button !== 0) return;
|
|
19277
|
+
if (e.evt.pointerType === "pen" && e.evt?.pressure <= .05) return;
|
|
19250
19278
|
if (!this.initialized) return;
|
|
19251
19279
|
if (!this.active) return;
|
|
19252
19280
|
if (stage.mode() !== WEAVE_STAGE_DEFAULT_MODE) return;
|
|
@@ -19299,8 +19327,9 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19299
19327
|
this.panLoopId = requestAnimationFrame(() => this.panLoop());
|
|
19300
19328
|
});
|
|
19301
19329
|
const handleMouseMove = (e) => {
|
|
19330
|
+
if (!e?.evt) return;
|
|
19302
19331
|
const moved = this.checkMoved(e);
|
|
19303
|
-
if (e.evt
|
|
19332
|
+
if (e.evt?.buttons === 0) return;
|
|
19304
19333
|
if (e.evt.pointerType === "touch" && Object.keys(this.pointers).length > 1) return;
|
|
19305
19334
|
if (!this.initialized) return;
|
|
19306
19335
|
if (!this.active) return;
|
|
@@ -19470,7 +19499,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19470
19499
|
this.hideHoverState();
|
|
19471
19500
|
const selectedGroup = getTargetedNode(this.instance);
|
|
19472
19501
|
if (!this.initialized) return;
|
|
19473
|
-
if (e.evt.pointerType === "mouse" && e.evt
|
|
19502
|
+
if (e.evt.pointerType === "mouse" && e.evt?.button && e.evt?.button !== 0) return;
|
|
19474
19503
|
let areNodesSelected = false;
|
|
19475
19504
|
let nodeTargeted = selectedGroup && !(selectedGroup.getAttrs().active ?? false) ? selectedGroup : e.target;
|
|
19476
19505
|
if (e.target === this.instance.getStage()) {
|
|
@@ -19533,7 +19562,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
|
|
|
19533
19562
|
if (areNodesSelected) {
|
|
19534
19563
|
stage.container().tabIndex = 1;
|
|
19535
19564
|
stage.container().focus();
|
|
19536
|
-
stage.container().style.cursor = nodeTargeted.defineMousePointer() ?? "grab";
|
|
19565
|
+
stage.container().style.cursor = (typeof nodeTargeted?.defineMousePointer === "function" ? nodeTargeted.defineMousePointer() : null) ?? "grab";
|
|
19537
19566
|
}
|
|
19538
19567
|
this.triggerSelectedNodesEvent();
|
|
19539
19568
|
}
|
|
@@ -19701,6 +19730,10 @@ const WEAVE_COPY_PASTE_CONFIG_DEFAULT = {
|
|
|
19701
19730
|
}
|
|
19702
19731
|
};
|
|
19703
19732
|
|
|
19733
|
+
//#endregion
|
|
19734
|
+
//#region src/actions/fit-to-selection-tool/constants.ts
|
|
19735
|
+
const FIT_TO_SELECTION_TOOL_ACTION_NAME = "fitToSelectionTool";
|
|
19736
|
+
|
|
19704
19737
|
//#endregion
|
|
19705
19738
|
//#region src/plugins/copy-paste-nodes/copy-paste-nodes.ts
|
|
19706
19739
|
var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
|
|
@@ -19912,8 +19945,8 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
|
|
|
19912
19945
|
}
|
|
19913
19946
|
const nodesSelectionPlugin = this.getNodesSelectionPlugin();
|
|
19914
19947
|
nodesSelectionPlugin?.setSelectedNodes(realNodes);
|
|
19915
|
-
this.instance?.triggerAction(
|
|
19916
|
-
previousAction:
|
|
19948
|
+
this.instance?.triggerAction(FIT_TO_SELECTION_TOOL_ACTION_NAME, {
|
|
19949
|
+
previousAction: SELECTION_TOOL_ACTION_NAME,
|
|
19917
19950
|
smartZoom: true
|
|
19918
19951
|
});
|
|
19919
19952
|
this.instance.emitEvent("onPaste", {
|
|
@@ -20188,6 +20221,33 @@ const augmentKonvaNodeClass = (config) => {
|
|
|
20188
20221
|
Konva.Node.prototype.closeCrop = function() {};
|
|
20189
20222
|
Konva.Node.prototype.resetCrop = function() {};
|
|
20190
20223
|
Konva.Node.prototype.dblClick = function() {};
|
|
20224
|
+
Konva.Node.prototype.allowedAnchors = function() {
|
|
20225
|
+
return [];
|
|
20226
|
+
};
|
|
20227
|
+
Konva.Node.prototype.isSelectable = function() {
|
|
20228
|
+
return true;
|
|
20229
|
+
};
|
|
20230
|
+
Konva.Node.prototype.handleMouseover = function() {};
|
|
20231
|
+
Konva.Node.prototype.handleMouseout = function() {};
|
|
20232
|
+
Konva.Node.prototype.handleSelectNode = function() {};
|
|
20233
|
+
Konva.Node.prototype.handleDeselectNode = function() {};
|
|
20234
|
+
Konva.Node.prototype.defineMousePointer = function() {
|
|
20235
|
+
return "default";
|
|
20236
|
+
};
|
|
20237
|
+
Konva.Node.prototype.canBeHovered = function() {
|
|
20238
|
+
return false;
|
|
20239
|
+
};
|
|
20240
|
+
Konva.Node.prototype.canDrag = function() {
|
|
20241
|
+
return false;
|
|
20242
|
+
};
|
|
20243
|
+
Konva.Node.prototype.canMoveToContainer = function() {
|
|
20244
|
+
return false;
|
|
20245
|
+
};
|
|
20246
|
+
Konva.Node.prototype.getNodeAnchors = function() {
|
|
20247
|
+
return [];
|
|
20248
|
+
};
|
|
20249
|
+
Konva.Node.prototype.lockMutex = function() {};
|
|
20250
|
+
Konva.Node.prototype.releaseMutex = function() {};
|
|
20191
20251
|
};
|
|
20192
20252
|
var WeaveNode = class {
|
|
20193
20253
|
async register(instance) {
|
|
@@ -20479,10 +20539,11 @@ var WeaveNode = class {
|
|
|
20479
20539
|
node.off("dragstart");
|
|
20480
20540
|
node.on("dragstart", (e) => {
|
|
20481
20541
|
const nodeTarget = e.target;
|
|
20542
|
+
if (!e.evt) return;
|
|
20482
20543
|
let isWheelMousePressed = false;
|
|
20483
|
-
if (e.evt
|
|
20544
|
+
if (e.evt?.button === 1) isWheelMousePressed = true;
|
|
20484
20545
|
this.getNodesSelectionFeedbackPlugin()?.hideSelectionHalo(nodeTarget);
|
|
20485
|
-
const canMove = nodeTarget?.canDrag()
|
|
20546
|
+
const canMove = typeof nodeTarget?.canDrag === "function" ? nodeTarget.canDrag() : false;
|
|
20486
20547
|
if (!canMove) {
|
|
20487
20548
|
nodeTarget.stopDrag();
|
|
20488
20549
|
return;
|
|
@@ -20534,7 +20595,7 @@ var WeaveNode = class {
|
|
|
20534
20595
|
nodesSelectionPlugin?.setSelectedNodes([]);
|
|
20535
20596
|
requestAnimationFrame(() => {
|
|
20536
20597
|
nodesSelectionPlugin?.setSelectedNodes(this.instance.getCloningManager().getClones());
|
|
20537
|
-
clone?.startDrag(e.evt);
|
|
20598
|
+
if (clone?.getStage()) clone.startDrag(e.evt);
|
|
20538
20599
|
});
|
|
20539
20600
|
}
|
|
20540
20601
|
if (this.getNodesSelectionPlugin()?.getSelectedNodes().length === 1) this.instance.setMutexLock({
|
|
@@ -20545,7 +20606,7 @@ var WeaveNode = class {
|
|
|
20545
20606
|
const handleDragMove = (e) => {
|
|
20546
20607
|
const nodeTarget = e.target;
|
|
20547
20608
|
let isWheelMousePressed = false;
|
|
20548
|
-
if (e.evt
|
|
20609
|
+
if (e.evt?.button === 1) isWheelMousePressed = true;
|
|
20549
20610
|
e.cancelBubble = true;
|
|
20550
20611
|
if (e.evt?.buttons === 0) {
|
|
20551
20612
|
nodeTarget.stopDrag();
|
|
@@ -20737,12 +20798,12 @@ var WeaveNode = class {
|
|
|
20737
20798
|
}
|
|
20738
20799
|
if (isNodeSelectionEnabled && this.isSelecting() && !this.isNodeSelected(realNode) && !this.isPasting() && isTargetable && !(isLocked || isMutexLocked) && stage.mode() === WEAVE_STAGE_DEFAULT_MODE) {
|
|
20739
20800
|
showHover = true;
|
|
20740
|
-
stage.container().style.cursor =
|
|
20801
|
+
stage.container().style.cursor = (typeof node?.defineMousePointer === "function" ? node.defineMousePointer() : null) ?? "pointer";
|
|
20741
20802
|
cancelBubble = true;
|
|
20742
20803
|
}
|
|
20743
20804
|
if (isNodeSelectionEnabled && this.isSelecting() && this.isNodeSelected(realNode) && !this.isPasting() && isTargetable && !(isLocked || isMutexLocked) && stage.mode() === WEAVE_STAGE_DEFAULT_MODE) {
|
|
20744
20805
|
showHover = true;
|
|
20745
|
-
stage.container().style.cursor =
|
|
20806
|
+
stage.container().style.cursor = (typeof node?.defineMousePointer === "function" ? node.defineMousePointer() : null) ?? "grab";
|
|
20746
20807
|
cancelBubble = true;
|
|
20747
20808
|
}
|
|
20748
20809
|
if (!isTargetable) cancelBubble = true;
|
|
@@ -22014,7 +22075,7 @@ var WeaveRegisterManager = class {
|
|
|
22014
22075
|
|
|
22015
22076
|
//#endregion
|
|
22016
22077
|
//#region package.json
|
|
22017
|
-
var version = "3.9.
|
|
22078
|
+
var version = "3.9.2";
|
|
22018
22079
|
|
|
22019
22080
|
//#endregion
|
|
22020
22081
|
//#region src/managers/setup.ts
|
|
@@ -24192,6 +24253,7 @@ function loadImageSource(image, options) {
|
|
|
24192
24253
|
}
|
|
24193
24254
|
async function downscaleImageFile(file, ratio) {
|
|
24194
24255
|
const bitmap = await createImageBitmap(file);
|
|
24256
|
+
if (bitmap.width === 0) throw new Error("Invalid image", { cause: "InvalidImage" });
|
|
24195
24257
|
const width = Math.round(bitmap.width * ratio);
|
|
24196
24258
|
const height = Math.round(bitmap.height * ratio);
|
|
24197
24259
|
const canvas = document.createElement("canvas");
|
|
@@ -24208,13 +24270,19 @@ function getImageSizeFromFile(file) {
|
|
|
24208
24270
|
const img = new Image();
|
|
24209
24271
|
const url = URL.createObjectURL(file);
|
|
24210
24272
|
img.onload = () => {
|
|
24273
|
+
if (img.naturalWidth === 0) {
|
|
24274
|
+
reject(new Error("Invalid image", { cause: "InvalidImage" }));
|
|
24275
|
+
return;
|
|
24276
|
+
}
|
|
24211
24277
|
resolve({
|
|
24212
24278
|
width: img.naturalWidth,
|
|
24213
24279
|
height: img.naturalHeight
|
|
24214
24280
|
});
|
|
24215
24281
|
URL.revokeObjectURL(url);
|
|
24216
24282
|
};
|
|
24217
|
-
img.onerror =
|
|
24283
|
+
img.onerror = () => {
|
|
24284
|
+
reject(new Error("Invalid image", { cause: "InvalidImage" }));
|
|
24285
|
+
};
|
|
24218
24286
|
img.src = url;
|
|
24219
24287
|
});
|
|
24220
24288
|
}
|
|
@@ -24238,6 +24306,10 @@ const downscaleImageFromURL = (url, options) => {
|
|
|
24238
24306
|
const img = new Image();
|
|
24239
24307
|
img.crossOrigin = crossOrigin;
|
|
24240
24308
|
img.onload = () => {
|
|
24309
|
+
if (img.naturalWidth === 0) {
|
|
24310
|
+
reject(new Error("Invalid image", { cause: "InvalidImage" }));
|
|
24311
|
+
return;
|
|
24312
|
+
}
|
|
24241
24313
|
const ratio = Math.min(maxWidth / img.width, maxHeight / img.height, 1);
|
|
24242
24314
|
const width = Math.round(img.width * ratio);
|
|
24243
24315
|
const height = Math.round(img.height * ratio);
|
|
@@ -24248,7 +24320,9 @@ const downscaleImageFromURL = (url, options) => {
|
|
|
24248
24320
|
ctx.drawImage(img, 0, 0, width, height);
|
|
24249
24321
|
resolve(canvas.toDataURL(type));
|
|
24250
24322
|
};
|
|
24251
|
-
img.onerror =
|
|
24323
|
+
img.onerror = () => {
|
|
24324
|
+
reject(new Error("Invalid image", { cause: "InvalidImage" }));
|
|
24325
|
+
};
|
|
24252
24326
|
img.src = url;
|
|
24253
24327
|
});
|
|
24254
24328
|
};
|
|
@@ -27006,15 +27080,24 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
27006
27080
|
const imageURLToLoad = imageURL ?? "http://localhost/false-image";
|
|
27007
27081
|
this.imageFallback[imageId] = Konva.Util.createImageElement();
|
|
27008
27082
|
this.imageFallback[imageId].crossOrigin = this.config.crossOrigin;
|
|
27009
|
-
this.imageFallback[imageId].onerror = (
|
|
27083
|
+
this.imageFallback[imageId].onerror = () => {
|
|
27010
27084
|
this.imageState[imageId] = {
|
|
27011
27085
|
status: "error-fallback",
|
|
27012
27086
|
loaded: false,
|
|
27013
27087
|
error: true
|
|
27014
27088
|
};
|
|
27015
|
-
onError(
|
|
27089
|
+
onError(new Error(`Failed to load fallback image from provided URL`, { cause: "ErrorLoadingFallbackImage" }));
|
|
27016
27090
|
};
|
|
27017
27091
|
this.imageFallback[imageId].onload = async () => {
|
|
27092
|
+
if (this.imageFallback[imageId].width === 0) {
|
|
27093
|
+
this.imageState[imageId] = {
|
|
27094
|
+
status: "error-fallback",
|
|
27095
|
+
loaded: false,
|
|
27096
|
+
error: true
|
|
27097
|
+
};
|
|
27098
|
+
onError(new Error(`Invalid fallback image provided`, { cause: "InvalidFallbackImage" }));
|
|
27099
|
+
return;
|
|
27100
|
+
}
|
|
27018
27101
|
this.imageState[imageId] = {
|
|
27019
27102
|
status: "loading",
|
|
27020
27103
|
loaded: true,
|
|
@@ -27041,15 +27124,19 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
27041
27124
|
}
|
|
27042
27125
|
this.imageSource[imageId] = Konva.Util.createImageElement();
|
|
27043
27126
|
this.imageSource[imageId].crossOrigin = this.config.crossOrigin;
|
|
27044
|
-
this.imageSource[imageId].onerror = (
|
|
27127
|
+
this.imageSource[imageId].onerror = () => {
|
|
27045
27128
|
if (!loadingTryout) {
|
|
27046
27129
|
const stage = this.instance.getStage();
|
|
27047
27130
|
const image = stage.findOne(`#${imageId}`);
|
|
27048
27131
|
if (image) this.setErrorState(imageId, image);
|
|
27049
27132
|
}
|
|
27050
|
-
onError(
|
|
27133
|
+
onError(new Error(`Failed to load image from provided URL`, { cause: "ErrorLoadingImage" }));
|
|
27051
27134
|
};
|
|
27052
27135
|
this.imageSource[imageId].onload = async () => {
|
|
27136
|
+
if (this.imageSource[imageId].width === 0) {
|
|
27137
|
+
onError(new Error(`Invalid image provided`, { cause: "InvalidImage" }));
|
|
27138
|
+
return;
|
|
27139
|
+
}
|
|
27053
27140
|
const stage = this.instance.getStage();
|
|
27054
27141
|
if (!this.instance.isServerSide()) stage.container().style.cursor = "pointer";
|
|
27055
27142
|
this.imageState[imageId] = {
|
|
@@ -27141,14 +27228,16 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
27141
27228
|
}
|
|
27142
27229
|
},
|
|
27143
27230
|
onError: (error) => {
|
|
27144
|
-
|
|
27231
|
+
let isInvalidImage = false;
|
|
27232
|
+
if (error.cause === "InvalidImage") isInvalidImage = true;
|
|
27233
|
+
if (!this.config.useFallbackImage && !isInvalidImage) {
|
|
27145
27234
|
const tryoutAttempts = this.imageTryoutAttempts[id] ?? 0;
|
|
27146
27235
|
if (tryoutAttempts - 1 < this.config.imageLoading.maxRetryAttempts) {
|
|
27147
27236
|
this.loadImageTryout(id);
|
|
27148
27237
|
return;
|
|
27149
27238
|
} else this.setErrorState(id, image);
|
|
27150
27239
|
}
|
|
27151
|
-
if (loadTryout) {
|
|
27240
|
+
if (loadTryout && !isInvalidImage) {
|
|
27152
27241
|
const tryoutAttempts = this.imageTryoutAttempts[id] ?? 0;
|
|
27153
27242
|
if (tryoutAttempts - 1 < this.config.imageLoading.maxRetryAttempts) {
|
|
27154
27243
|
this.loadImageTryout(id);
|
|
@@ -27161,12 +27250,7 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
27161
27250
|
return;
|
|
27162
27251
|
}
|
|
27163
27252
|
this.setErrorState(id, image);
|
|
27164
|
-
image.setAttrs({ image: void 0 });
|
|
27165
|
-
console.error("Error loading image", error);
|
|
27166
27253
|
this.resolveAsyncElement(id);
|
|
27167
|
-
imagePlaceholder?.setAttrs({ visible: true });
|
|
27168
|
-
internalImage?.setAttrs({ visible: false });
|
|
27169
|
-
this.cacheNode(image);
|
|
27170
27254
|
}
|
|
27171
27255
|
}, loadTryout);
|
|
27172
27256
|
}
|
|
@@ -29658,8 +29742,7 @@ var WeaveVideoNode = class extends WeaveNode {
|
|
|
29658
29742
|
this.videoPlaceholder[id] = Konva.Util.createImageElement();
|
|
29659
29743
|
this.videoPlaceholder[id].crossOrigin = this.config.crossOrigin;
|
|
29660
29744
|
this.videoPlaceholder[id].src = realVideoPlaceholderURL;
|
|
29661
|
-
this.videoPlaceholder[id].onerror = (
|
|
29662
|
-
console.error("Error loading video placeholder", realVideoPlaceholderURL, error);
|
|
29745
|
+
this.videoPlaceholder[id].onerror = () => {
|
|
29663
29746
|
this.resolveAsyncElement(id);
|
|
29664
29747
|
};
|
|
29665
29748
|
this.videoPlaceholder[id].onload = () => {
|
|
@@ -32697,13 +32780,13 @@ var WeaveZoomOutToolAction = class extends WeaveAction {
|
|
|
32697
32780
|
const stageZoomPlugin = this.getStageZoomPlugin();
|
|
32698
32781
|
if (!stageZoomPlugin.canZoomOut()) return;
|
|
32699
32782
|
stageZoomPlugin.zoomOut();
|
|
32700
|
-
this.previousAction = params
|
|
32783
|
+
this.previousAction = params?.previousAction;
|
|
32701
32784
|
this.cancelAction = cancelAction;
|
|
32702
32785
|
this.cancelAction();
|
|
32703
32786
|
}
|
|
32704
32787
|
cleanup() {
|
|
32705
32788
|
const stage = this.instance.getStage();
|
|
32706
|
-
if (this.previousAction
|
|
32789
|
+
if (this.previousAction) this.instance.triggerAction(this.previousAction);
|
|
32707
32790
|
stage.container().style.cursor = "default";
|
|
32708
32791
|
}
|
|
32709
32792
|
};
|
|
@@ -32735,13 +32818,13 @@ var WeaveZoomInToolAction = class extends WeaveAction {
|
|
|
32735
32818
|
const stageZoomPlugin = this.getStageZoomPlugin();
|
|
32736
32819
|
if (!stageZoomPlugin.canZoomIn()) return;
|
|
32737
32820
|
stageZoomPlugin.zoomIn();
|
|
32738
|
-
this.previousAction = params
|
|
32821
|
+
this.previousAction = params?.previousAction;
|
|
32739
32822
|
this.cancelAction = cancelAction;
|
|
32740
32823
|
this.cancelAction();
|
|
32741
32824
|
}
|
|
32742
32825
|
cleanup() {
|
|
32743
32826
|
const stage = this.instance.getStage();
|
|
32744
|
-
if (this.previousAction
|
|
32827
|
+
if (this.previousAction) this.instance.triggerAction(this.previousAction);
|
|
32745
32828
|
stage.container().style.cursor = "default";
|
|
32746
32829
|
}
|
|
32747
32830
|
};
|
|
@@ -32772,21 +32855,17 @@ var WeaveFitToScreenToolAction = class extends WeaveAction {
|
|
|
32772
32855
|
trigger(cancelAction, params) {
|
|
32773
32856
|
const stageZoomPlugin = this.getStageZoomPlugin();
|
|
32774
32857
|
if (stageZoomPlugin) stageZoomPlugin.fitToScreen({ overrideZoom: params?.overrideZoom ?? true });
|
|
32775
|
-
this.previousAction = params
|
|
32858
|
+
this.previousAction = params?.previousAction;
|
|
32776
32859
|
this.cancelAction = cancelAction;
|
|
32777
32860
|
this.cancelAction();
|
|
32778
32861
|
}
|
|
32779
32862
|
cleanup() {
|
|
32780
32863
|
const stage = this.instance.getStage();
|
|
32781
|
-
if (this.previousAction
|
|
32864
|
+
if (this.previousAction) this.instance.triggerAction(this.previousAction);
|
|
32782
32865
|
stage.container().style.cursor = "default";
|
|
32783
32866
|
}
|
|
32784
32867
|
};
|
|
32785
32868
|
|
|
32786
|
-
//#endregion
|
|
32787
|
-
//#region src/actions/fit-to-selection-tool/constants.ts
|
|
32788
|
-
const FIT_TO_SELECTION_TOOL_ACTION_NAME = "fitToSelectionTool";
|
|
32789
|
-
|
|
32790
32869
|
//#endregion
|
|
32791
32870
|
//#region src/actions/fit-to-selection-tool/fit-to-selection-tool.ts
|
|
32792
32871
|
var WeaveFitToSelectionToolAction = class extends WeaveAction {
|
|
@@ -32818,13 +32897,13 @@ var WeaveFitToSelectionToolAction = class extends WeaveAction {
|
|
|
32818
32897
|
smartZoom: params?.smartZoom ?? false,
|
|
32819
32898
|
overrideZoom: params?.overrideZoom ?? true
|
|
32820
32899
|
});
|
|
32821
|
-
this.previousAction = params
|
|
32900
|
+
this.previousAction = params?.previousAction;
|
|
32822
32901
|
this.cancelAction = cancelAction;
|
|
32823
32902
|
this.cancelAction();
|
|
32824
32903
|
}
|
|
32825
32904
|
cleanup() {
|
|
32826
32905
|
const stage = this.instance.getStage();
|
|
32827
|
-
if (this.previousAction
|
|
32906
|
+
if (this.previousAction) this.instance.triggerAction(this.previousAction);
|
|
32828
32907
|
stage.container().style.cursor = "default";
|
|
32829
32908
|
}
|
|
32830
32909
|
};
|
|
@@ -34108,7 +34187,7 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
34108
34187
|
if (this.state !== BRUSH_TOOL_STATE.IDLE) return;
|
|
34109
34188
|
if (this.getZoomPlugin()?.isPinching()) return;
|
|
34110
34189
|
if (this.isSpacePressed) return;
|
|
34111
|
-
if (e
|
|
34190
|
+
if (e?.evt?.button !== 0) return;
|
|
34112
34191
|
const pointPressure = this.getEventPressure(e);
|
|
34113
34192
|
this.handleStartStroke(pointPressure);
|
|
34114
34193
|
e.evt.stopPropagation();
|
|
@@ -37919,13 +37998,13 @@ var WeaveStageGridPlugin = class extends WeavePlugin {
|
|
|
37919
37998
|
});
|
|
37920
37999
|
stage.on("pointerdown", (e) => {
|
|
37921
38000
|
const activeAction = this.instance.getActiveAction();
|
|
37922
|
-
if (e && e
|
|
37923
|
-
if (e && (e
|
|
38001
|
+
if (e && e?.evt?.button === 0 && activeAction === MOVE_TOOL_ACTION_NAME) this.moveToolActive = true;
|
|
38002
|
+
if (e && (e?.evt?.button === 2 || e?.evt?.buttons === 4)) this.isMouseMiddleButtonPressed = true;
|
|
37924
38003
|
});
|
|
37925
38004
|
stage.on("pointerup", (e) => {
|
|
37926
38005
|
const activeAction = this.instance.getActiveAction();
|
|
37927
|
-
if (e && e
|
|
37928
|
-
if (e && (e
|
|
38006
|
+
if (e && e?.evt?.button === 0 && activeAction === MOVE_TOOL_ACTION_NAME) this.moveToolActive = false;
|
|
38007
|
+
if (e && (e?.evt?.button === 1 || e?.evt?.buttons === 0)) this.isMouseMiddleButtonPressed = false;
|
|
37929
38008
|
});
|
|
37930
38009
|
const handleMouseMove = () => {
|
|
37931
38010
|
if (!this.enabled || !(this.isSpaceKeyPressed || this.isMouseMiddleButtonPressed || this.moveToolActive)) return;
|
|
@@ -38246,16 +38325,16 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
|
|
|
38246
38325
|
let lastPos = null;
|
|
38247
38326
|
stage.on("pointerdown", (e) => {
|
|
38248
38327
|
this.pointers.set(e.evt.pointerId, {
|
|
38249
|
-
x: e
|
|
38250
|
-
y: e
|
|
38328
|
+
x: e?.evt?.clientX ?? 0,
|
|
38329
|
+
y: e?.evt?.clientY ?? 0
|
|
38251
38330
|
});
|
|
38252
38331
|
if (this.pointers.size > 1) return;
|
|
38253
38332
|
const activeAction = this.instance.getActiveAction();
|
|
38254
38333
|
this.enableMove = false;
|
|
38255
38334
|
if (activeAction === MOVE_TOOL_ACTION_NAME) this.moveToolActive = true;
|
|
38256
|
-
if (e.evt.pointerType === "mouse" && e
|
|
38257
|
-
if (e.evt.pointerType === "mouse" && e
|
|
38258
|
-
const isTouchOrPen = ["touch", "pen"].includes(e
|
|
38335
|
+
if (e.evt.pointerType === "mouse" && e?.evt?.buttons === 1) this.isMouseLeftButtonPressed = true;
|
|
38336
|
+
if (e.evt.pointerType === "mouse" && e?.evt?.buttons === 4) this.isMouseMiddleButtonPressed = true;
|
|
38337
|
+
const isTouchOrPen = ["touch", "pen"].includes(e?.evt?.pointerType);
|
|
38259
38338
|
if (this.enabled && (this.isSpaceKeyPressed || this.moveToolActive && (this.isMouseLeftButtonPressed || isTouchOrPen) || this.isMouseMiddleButtonPressed)) this.enableMove = true;
|
|
38260
38339
|
if (this.enableMove) {
|
|
38261
38340
|
this.isDragging = true;
|
|
@@ -38264,7 +38343,7 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
|
|
|
38264
38343
|
}
|
|
38265
38344
|
});
|
|
38266
38345
|
stage.on("pointercancel", (e) => {
|
|
38267
|
-
this.pointers.delete(e.evt.pointerId);
|
|
38346
|
+
if (e?.evt?.pointerId) this.pointers.delete(e.evt.pointerId);
|
|
38268
38347
|
lastPos = null;
|
|
38269
38348
|
});
|
|
38270
38349
|
const handleMouseMove = (e) => {
|