@inditextech/weave-sdk 2.18.1 → 2.20.0
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.d.ts +38 -26
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +66 -9
- package/dist/sdk.js.map +1 -1
- package/dist/sdk.node.d.ts +38 -26
- package/dist/sdk.node.d.ts.map +1 -1
- package/dist/sdk.node.js +66 -9
- package/dist/sdk.node.js.map +1 -1
- package/package.json +2 -2
package/dist/sdk.node.js
CHANGED
|
@@ -20079,7 +20079,8 @@ var WeaveNode = class {
|
|
|
20079
20079
|
register(instance) {
|
|
20080
20080
|
this.instance = instance;
|
|
20081
20081
|
this.logger = this.instance.getChildLogger(this.getNodeType());
|
|
20082
|
-
this.
|
|
20082
|
+
this.onRegister();
|
|
20083
|
+
this.instance.getChildLogger(`node-${this.getNodeType()}`).debug(`Node with type [${this.getNodeType()}] registered`);
|
|
20083
20084
|
return this;
|
|
20084
20085
|
}
|
|
20085
20086
|
getNodeType() {
|
|
@@ -20567,6 +20568,7 @@ var WeaveNode = class {
|
|
|
20567
20568
|
}
|
|
20568
20569
|
};
|
|
20569
20570
|
}
|
|
20571
|
+
onRegister() {}
|
|
20570
20572
|
onAdd(nodeInstance) {}
|
|
20571
20573
|
onDestroy(nodeInstance) {
|
|
20572
20574
|
nodeInstance.destroy();
|
|
@@ -22075,7 +22077,7 @@ var WeaveRegisterManager = class {
|
|
|
22075
22077
|
|
|
22076
22078
|
//#endregion
|
|
22077
22079
|
//#region package.json
|
|
22078
|
-
var version = "2.
|
|
22080
|
+
var version = "2.20.0";
|
|
22079
22081
|
|
|
22080
22082
|
//#endregion
|
|
22081
22083
|
//#region src/managers/setup.ts
|
|
@@ -22768,6 +22770,7 @@ function watchMap(onChange, map = new Map()) {
|
|
|
22768
22770
|
//#endregion
|
|
22769
22771
|
//#region src/managers/async/async.ts
|
|
22770
22772
|
var WeaveAsyncManager = class {
|
|
22773
|
+
asyncElementsLoadedEventEmitted = false;
|
|
22771
22774
|
constructor(instance) {
|
|
22772
22775
|
this.instance = instance;
|
|
22773
22776
|
this.logger = this.instance.getChildLogger("async-manager");
|
|
@@ -22779,6 +22782,12 @@ var WeaveAsyncManager = class {
|
|
|
22779
22782
|
asyncElementsLoaded() {
|
|
22780
22783
|
return [...this.asyncElements.values()].every((el) => el.status === WEAVE_ASYNC_STATUS.LOADED);
|
|
22781
22784
|
}
|
|
22785
|
+
getAmountAsyncElements() {
|
|
22786
|
+
return [...this.asyncElements.values()].length;
|
|
22787
|
+
}
|
|
22788
|
+
getAmountAsyncElementsLoaded() {
|
|
22789
|
+
return [...this.asyncElements.values()].filter((el) => el.status === WEAVE_ASYNC_STATUS.LOADED).length;
|
|
22790
|
+
}
|
|
22782
22791
|
loadAsyncElement(nodeId, type) {
|
|
22783
22792
|
let element = this.asyncElements.get(nodeId);
|
|
22784
22793
|
if (element) element.status = WEAVE_ASYNC_STATUS.LOADING;
|
|
@@ -22787,6 +22796,10 @@ var WeaveAsyncManager = class {
|
|
|
22787
22796
|
status: WEAVE_ASYNC_STATUS.LOADING
|
|
22788
22797
|
};
|
|
22789
22798
|
this.asyncElements.set(nodeId, element);
|
|
22799
|
+
this.instance.emitEvent("onAsyncElementsLoading", {
|
|
22800
|
+
loaded: this.getAmountAsyncElementsLoaded(),
|
|
22801
|
+
total: this.getAmountAsyncElements()
|
|
22802
|
+
});
|
|
22790
22803
|
}
|
|
22791
22804
|
resolveAsyncElement(nodeId, type) {
|
|
22792
22805
|
let element = this.asyncElements.get(nodeId);
|
|
@@ -22796,6 +22809,17 @@ var WeaveAsyncManager = class {
|
|
|
22796
22809
|
status: WEAVE_ASYNC_STATUS.LOADED
|
|
22797
22810
|
};
|
|
22798
22811
|
this.asyncElements.set(nodeId, element);
|
|
22812
|
+
this.instance.emitEvent("onAsyncElementsLoading", {
|
|
22813
|
+
loaded: this.getAmountAsyncElementsLoaded(),
|
|
22814
|
+
total: this.getAmountAsyncElements()
|
|
22815
|
+
});
|
|
22816
|
+
if (!this.asyncElementsLoadedEventEmitted) {
|
|
22817
|
+
const allLoaded = this.asyncElementsLoaded();
|
|
22818
|
+
if (allLoaded) {
|
|
22819
|
+
this.instance.emitEvent("onAsyncElementsLoaded");
|
|
22820
|
+
this.asyncElementsLoadedEventEmitted = true;
|
|
22821
|
+
}
|
|
22822
|
+
}
|
|
22799
22823
|
}
|
|
22800
22824
|
};
|
|
22801
22825
|
|
|
@@ -24454,6 +24478,10 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
24454
24478
|
this.instance.addEventListener("onNodeRenderedAdded", (node) => {
|
|
24455
24479
|
if (node.id() === text.id() && node.getParent() !== text.getParent()) text.getAttr("cancelEditMode")?.();
|
|
24456
24480
|
});
|
|
24481
|
+
if (!this.instance.isServerSide() && !this.keyPressHandler) {
|
|
24482
|
+
this.keyPressHandler = this.handleKeyPress.bind(this);
|
|
24483
|
+
window.addEventListener("keypress", this.keyPressHandler);
|
|
24484
|
+
}
|
|
24457
24485
|
return text;
|
|
24458
24486
|
}
|
|
24459
24487
|
onUpdate(nodeInstance, nextProps) {
|
|
@@ -24879,6 +24907,7 @@ var WeaveImageCrop = class WeaveImageCrop {
|
|
|
24879
24907
|
if (nodeDistanceSnappingPlugin) nodeDistanceSnappingPlugin.disable();
|
|
24880
24908
|
const nodesSelectionPlugin = this.getNodesSelectionPlugin();
|
|
24881
24909
|
if (nodesSelectionPlugin) nodesSelectionPlugin.disable();
|
|
24910
|
+
this.node.clearCache(this.image);
|
|
24882
24911
|
this.image.setAttrs({ cropping: true });
|
|
24883
24912
|
const imageAttrs = this.image.getAttrs();
|
|
24884
24913
|
this.internalImage.hide();
|
|
@@ -25057,6 +25086,7 @@ var WeaveImageCrop = class WeaveImageCrop {
|
|
|
25057
25086
|
if (nodesSelectionPlugin) nodesSelectionPlugin.enable();
|
|
25058
25087
|
stage.mode(WEAVE_STAGE_DEFAULT_MODE);
|
|
25059
25088
|
this.instance.releaseMutexLock();
|
|
25089
|
+
this.node.cacheNode(this.image);
|
|
25060
25090
|
this.instance.emitEvent("onImageCropEnd", { instance: this.image });
|
|
25061
25091
|
}
|
|
25062
25092
|
drawGridLines(x, y, width, height) {
|
|
@@ -25118,6 +25148,7 @@ var WeaveImageCrop = class WeaveImageCrop {
|
|
|
25118
25148
|
this.image.setAbsolutePosition(cropImageStage);
|
|
25119
25149
|
this.image.attrs.cropInfo = void 0;
|
|
25120
25150
|
this.instance.updateNode(this.node.serialize(this.image));
|
|
25151
|
+
this.node.cacheNode(this.image);
|
|
25121
25152
|
}
|
|
25122
25153
|
handleClipEnd() {
|
|
25123
25154
|
const clipRect = this.cropRect.getClientRect({ relativeTo: this.cropGroup });
|
|
@@ -25214,11 +25245,15 @@ const WEAVE_IMAGE_CROP_END_TYPE = {
|
|
|
25214
25245
|
["ACCEPT"]: "accept",
|
|
25215
25246
|
["CANCEL"]: "cancel"
|
|
25216
25247
|
};
|
|
25217
|
-
const WEAVE_IMAGE_DEFAULT_CONFIG = {
|
|
25248
|
+
const WEAVE_IMAGE_DEFAULT_CONFIG = {
|
|
25249
|
+
performance: { cache: { enabled: false } },
|
|
25250
|
+
crossOrigin: "anonymous"
|
|
25251
|
+
};
|
|
25218
25252
|
|
|
25219
25253
|
//#endregion
|
|
25220
25254
|
//#region src/nodes/image/image.ts
|
|
25221
25255
|
var WeaveImageNode = class extends WeaveNode {
|
|
25256
|
+
imageBitmapCache = {};
|
|
25222
25257
|
imageSource = {};
|
|
25223
25258
|
imageState = {};
|
|
25224
25259
|
nodeType = WEAVE_IMAGE_NODE_TYPE;
|
|
@@ -25234,6 +25269,9 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
25234
25269
|
this.config = mergeExceptArrays(WEAVE_IMAGE_DEFAULT_CONFIG, config);
|
|
25235
25270
|
this.imageCrop = null;
|
|
25236
25271
|
}
|
|
25272
|
+
onRegister() {
|
|
25273
|
+
this.logger.info(`image caching enabled: ${this.config.performance.cache.enabled}`);
|
|
25274
|
+
}
|
|
25237
25275
|
triggerCrop(imageNode) {
|
|
25238
25276
|
const stage = this.instance.getStage();
|
|
25239
25277
|
if (imageNode.getAttrs().cropping ?? false) return;
|
|
@@ -25383,8 +25421,9 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
25383
25421
|
};
|
|
25384
25422
|
if (this.imageSource[id]) {
|
|
25385
25423
|
imagePlaceholder.destroy();
|
|
25424
|
+
const imageSource = this.imageSource[id];
|
|
25386
25425
|
internalImage.setAttrs({
|
|
25387
|
-
image:
|
|
25426
|
+
image: imageSource,
|
|
25388
25427
|
visible: true
|
|
25389
25428
|
});
|
|
25390
25429
|
image.setAttr("imageInfo", {
|
|
@@ -25408,14 +25447,27 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
25408
25447
|
this.updatePlaceholderSize(image, imagePlaceholder);
|
|
25409
25448
|
this.loadImage(imageProps, image);
|
|
25410
25449
|
}
|
|
25450
|
+
if (this.config.performance.cache.enabled) image.on("transformend", () => {
|
|
25451
|
+
this.cacheNode(image);
|
|
25452
|
+
});
|
|
25411
25453
|
image.setAttr("imageURL", imageProps.imageURL);
|
|
25412
25454
|
this.instance.addEventListener("onNodeRenderedAdded", (node) => {
|
|
25413
25455
|
if (node.id() === image.id() && node.getParent() !== image.getParent()) {
|
|
25414
25456
|
if (this.imageCrop) this.closeCrop(image, WEAVE_IMAGE_CROP_END_TYPE.CANCEL);
|
|
25415
25457
|
}
|
|
25416
25458
|
});
|
|
25459
|
+
this.cacheNode(image);
|
|
25417
25460
|
return image;
|
|
25418
25461
|
}
|
|
25462
|
+
clearCache(nodeInstance) {
|
|
25463
|
+
if (this.config.performance.cache.enabled) nodeInstance.clearCache();
|
|
25464
|
+
}
|
|
25465
|
+
cacheNode(nodeInstance) {
|
|
25466
|
+
if (this.config.performance.cache.enabled) {
|
|
25467
|
+
nodeInstance.clearCache();
|
|
25468
|
+
nodeInstance.cache({ pixelRatio: this.config.performance.cache.pixelRatio });
|
|
25469
|
+
}
|
|
25470
|
+
}
|
|
25419
25471
|
onUpdate(nodeInstance, nextProps) {
|
|
25420
25472
|
const id = nodeInstance.getAttrs().id;
|
|
25421
25473
|
const node = nodeInstance;
|
|
@@ -25515,6 +25567,7 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
25515
25567
|
});
|
|
25516
25568
|
this.updateImageCrop(nodeInstance);
|
|
25517
25569
|
}
|
|
25570
|
+
this.cacheNode(nodeInstance);
|
|
25518
25571
|
}
|
|
25519
25572
|
preloadImage(imageId, imageURL, { onLoad, onError }) {
|
|
25520
25573
|
const realImageURL = this.config.urlTransformer?.(imageURL ?? "") ?? imageURL;
|
|
@@ -25529,7 +25582,7 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
25529
25582
|
delete this.imageState[imageId];
|
|
25530
25583
|
onError(error);
|
|
25531
25584
|
};
|
|
25532
|
-
this.imageSource[imageId].onload = () => {
|
|
25585
|
+
this.imageSource[imageId].onload = async () => {
|
|
25533
25586
|
this.imageState[imageId] = {
|
|
25534
25587
|
loaded: true,
|
|
25535
25588
|
error: false
|
|
@@ -25561,10 +25614,11 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
25561
25614
|
height: imageProps.height ? imageProps.height : this.imageSource[id].height
|
|
25562
25615
|
});
|
|
25563
25616
|
imagePlaceholder.destroy();
|
|
25617
|
+
const imageSource = this.imageSource[id];
|
|
25564
25618
|
internalImage.setAttrs({
|
|
25565
25619
|
width: imageProps.width ? imageProps.width : this.imageSource[id].width,
|
|
25566
25620
|
height: imageProps.height ? imageProps.height : this.imageSource[id].height,
|
|
25567
|
-
image:
|
|
25621
|
+
image: imageSource,
|
|
25568
25622
|
visible: true
|
|
25569
25623
|
});
|
|
25570
25624
|
internalImage.setAttr("imageInfo", {
|
|
@@ -25587,6 +25641,7 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
25587
25641
|
};
|
|
25588
25642
|
this.updateImageCrop(image);
|
|
25589
25643
|
this.resolveAsyncElement(id);
|
|
25644
|
+
this.cacheNode(image);
|
|
25590
25645
|
}
|
|
25591
25646
|
},
|
|
25592
25647
|
onError: (error) => {
|
|
@@ -25611,6 +25666,7 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
25611
25666
|
console.error("Error loading image", realImageURL, error);
|
|
25612
25667
|
imagePlaceholder?.setAttrs({ visible: true });
|
|
25613
25668
|
internalImage?.setAttrs({ visible: false });
|
|
25669
|
+
this.cacheNode(image);
|
|
25614
25670
|
}
|
|
25615
25671
|
});
|
|
25616
25672
|
}
|
|
@@ -31608,13 +31664,14 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
31608
31664
|
this.cancelAction();
|
|
31609
31665
|
return;
|
|
31610
31666
|
}
|
|
31611
|
-
if (e.code === "Space" && this.instance.getActiveAction() === BRUSH_TOOL_ACTION_NAME)
|
|
31612
|
-
|
|
31613
|
-
this.cancelAction();
|
|
31667
|
+
if (e.code === "Space" && this.instance.getActiveAction() === BRUSH_TOOL_ACTION_NAME) {
|
|
31668
|
+
this.isSpacePressed = true;
|
|
31614
31669
|
return;
|
|
31615
31670
|
}
|
|
31671
|
+
if (e.code === "Escape" && this.instance.getActiveAction() === BRUSH_TOOL_ACTION_NAME) this.cancelAction();
|
|
31616
31672
|
});
|
|
31617
31673
|
const handlePointerDown = (e) => {
|
|
31674
|
+
if (this.state === BRUSH_TOOL_STATE.INACTIVE) return;
|
|
31618
31675
|
if (this.state !== BRUSH_TOOL_STATE.IDLE) return;
|
|
31619
31676
|
if (this.getZoomPlugin()?.isPinching()) return;
|
|
31620
31677
|
if (this.isSpacePressed) return;
|