@inditextech/weave-sdk 2.18.0 → 2.19.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 +20 -13
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +71 -6
- package/dist/sdk.js.map +1 -1
- package/dist/sdk.node.d.ts +13 -6
- package/dist/sdk.node.d.ts.map +1 -1
- package/dist/sdk.node.js +71 -6
- package/dist/sdk.node.js.map +1 -1
- package/package.json +2 -2
package/dist/sdk.js
CHANGED
|
@@ -20080,7 +20080,8 @@ var WeaveNode = class {
|
|
|
20080
20080
|
register(instance) {
|
|
20081
20081
|
this.instance = instance;
|
|
20082
20082
|
this.logger = this.instance.getChildLogger(this.getNodeType());
|
|
20083
|
-
this.
|
|
20083
|
+
this.onRegister();
|
|
20084
|
+
this.instance.getChildLogger(`node-${this.getNodeType()}`).debug(`Node with type [${this.getNodeType()}] registered`);
|
|
20084
20085
|
return this;
|
|
20085
20086
|
}
|
|
20086
20087
|
getNodeType() {
|
|
@@ -20568,6 +20569,7 @@ var WeaveNode = class {
|
|
|
20568
20569
|
}
|
|
20569
20570
|
};
|
|
20570
20571
|
}
|
|
20572
|
+
onRegister() {}
|
|
20571
20573
|
onAdd(nodeInstance) {}
|
|
20572
20574
|
onDestroy(nodeInstance) {
|
|
20573
20575
|
nodeInstance.destroy();
|
|
@@ -22076,7 +22078,7 @@ var WeaveRegisterManager = class {
|
|
|
22076
22078
|
|
|
22077
22079
|
//#endregion
|
|
22078
22080
|
//#region package.json
|
|
22079
|
-
var version = "2.
|
|
22081
|
+
var version = "2.19.0";
|
|
22080
22082
|
|
|
22081
22083
|
//#endregion
|
|
22082
22084
|
//#region src/managers/setup.ts
|
|
@@ -22769,6 +22771,7 @@ function watchMap(onChange, map = new Map()) {
|
|
|
22769
22771
|
//#endregion
|
|
22770
22772
|
//#region src/managers/async/async.ts
|
|
22771
22773
|
var WeaveAsyncManager = class {
|
|
22774
|
+
asyncElementsLoadedEventEmitted = false;
|
|
22772
22775
|
constructor(instance) {
|
|
22773
22776
|
this.instance = instance;
|
|
22774
22777
|
this.logger = this.instance.getChildLogger("async-manager");
|
|
@@ -22780,6 +22783,12 @@ var WeaveAsyncManager = class {
|
|
|
22780
22783
|
asyncElementsLoaded() {
|
|
22781
22784
|
return [...this.asyncElements.values()].every((el) => el.status === WEAVE_ASYNC_STATUS.LOADED);
|
|
22782
22785
|
}
|
|
22786
|
+
getAmountAsyncElements() {
|
|
22787
|
+
return [...this.asyncElements.values()].length;
|
|
22788
|
+
}
|
|
22789
|
+
getAmountAsyncElementsLoaded() {
|
|
22790
|
+
return [...this.asyncElements.values()].filter((el) => el.status === WEAVE_ASYNC_STATUS.LOADED).length;
|
|
22791
|
+
}
|
|
22783
22792
|
loadAsyncElement(nodeId, type) {
|
|
22784
22793
|
let element = this.asyncElements.get(nodeId);
|
|
22785
22794
|
if (element) element.status = WEAVE_ASYNC_STATUS.LOADING;
|
|
@@ -22788,6 +22797,10 @@ var WeaveAsyncManager = class {
|
|
|
22788
22797
|
status: WEAVE_ASYNC_STATUS.LOADING
|
|
22789
22798
|
};
|
|
22790
22799
|
this.asyncElements.set(nodeId, element);
|
|
22800
|
+
this.instance.emitEvent("onAsyncElementsLoading", {
|
|
22801
|
+
loaded: this.getAmountAsyncElementsLoaded(),
|
|
22802
|
+
total: this.getAmountAsyncElements()
|
|
22803
|
+
});
|
|
22791
22804
|
}
|
|
22792
22805
|
resolveAsyncElement(nodeId, type) {
|
|
22793
22806
|
let element = this.asyncElements.get(nodeId);
|
|
@@ -22797,6 +22810,17 @@ var WeaveAsyncManager = class {
|
|
|
22797
22810
|
status: WEAVE_ASYNC_STATUS.LOADED
|
|
22798
22811
|
};
|
|
22799
22812
|
this.asyncElements.set(nodeId, element);
|
|
22813
|
+
this.instance.emitEvent("onAsyncElementsLoading", {
|
|
22814
|
+
loaded: this.getAmountAsyncElementsLoaded(),
|
|
22815
|
+
total: this.getAmountAsyncElements()
|
|
22816
|
+
});
|
|
22817
|
+
if (!this.asyncElementsLoadedEventEmitted) {
|
|
22818
|
+
const allLoaded = this.asyncElementsLoaded();
|
|
22819
|
+
if (allLoaded) {
|
|
22820
|
+
this.instance.emitEvent("onAsyncElementsLoaded");
|
|
22821
|
+
this.asyncElementsLoadedEventEmitted = true;
|
|
22822
|
+
}
|
|
22823
|
+
}
|
|
22800
22824
|
}
|
|
22801
22825
|
};
|
|
22802
22826
|
|
|
@@ -24455,6 +24479,10 @@ var WeaveTextNode = class extends WeaveNode {
|
|
|
24455
24479
|
this.instance.addEventListener("onNodeRenderedAdded", (node) => {
|
|
24456
24480
|
if (node.id() === text.id() && node.getParent() !== text.getParent()) text.getAttr("cancelEditMode")?.();
|
|
24457
24481
|
});
|
|
24482
|
+
if (!this.instance.isServerSide() && !this.keyPressHandler) {
|
|
24483
|
+
this.keyPressHandler = this.handleKeyPress.bind(this);
|
|
24484
|
+
window.addEventListener("keypress", this.keyPressHandler);
|
|
24485
|
+
}
|
|
24458
24486
|
return text;
|
|
24459
24487
|
}
|
|
24460
24488
|
onUpdate(nodeInstance, nextProps) {
|
|
@@ -24880,6 +24908,7 @@ var WeaveImageCrop = class WeaveImageCrop {
|
|
|
24880
24908
|
if (nodeDistanceSnappingPlugin) nodeDistanceSnappingPlugin.disable();
|
|
24881
24909
|
const nodesSelectionPlugin = this.getNodesSelectionPlugin();
|
|
24882
24910
|
if (nodesSelectionPlugin) nodesSelectionPlugin.disable();
|
|
24911
|
+
this.node.clearCache(this.image);
|
|
24883
24912
|
this.image.setAttrs({ cropping: true });
|
|
24884
24913
|
const imageAttrs = this.image.getAttrs();
|
|
24885
24914
|
this.internalImage.hide();
|
|
@@ -25058,6 +25087,7 @@ var WeaveImageCrop = class WeaveImageCrop {
|
|
|
25058
25087
|
if (nodesSelectionPlugin) nodesSelectionPlugin.enable();
|
|
25059
25088
|
stage.mode(WEAVE_STAGE_DEFAULT_MODE);
|
|
25060
25089
|
this.instance.releaseMutexLock();
|
|
25090
|
+
this.node.cacheNode(this.image);
|
|
25061
25091
|
this.instance.emitEvent("onImageCropEnd", { instance: this.image });
|
|
25062
25092
|
}
|
|
25063
25093
|
drawGridLines(x, y, width, height) {
|
|
@@ -25119,6 +25149,7 @@ var WeaveImageCrop = class WeaveImageCrop {
|
|
|
25119
25149
|
this.image.setAbsolutePosition(cropImageStage);
|
|
25120
25150
|
this.image.attrs.cropInfo = void 0;
|
|
25121
25151
|
this.instance.updateNode(this.node.serialize(this.image));
|
|
25152
|
+
this.node.cacheNode(this.image);
|
|
25122
25153
|
}
|
|
25123
25154
|
handleClipEnd() {
|
|
25124
25155
|
const clipRect = this.cropRect.getClientRect({ relativeTo: this.cropGroup });
|
|
@@ -25215,11 +25246,15 @@ const WEAVE_IMAGE_CROP_END_TYPE = {
|
|
|
25215
25246
|
["ACCEPT"]: "accept",
|
|
25216
25247
|
["CANCEL"]: "cancel"
|
|
25217
25248
|
};
|
|
25218
|
-
const WEAVE_IMAGE_DEFAULT_CONFIG = {
|
|
25249
|
+
const WEAVE_IMAGE_DEFAULT_CONFIG = {
|
|
25250
|
+
performance: { caching: false },
|
|
25251
|
+
crossOrigin: "anonymous"
|
|
25252
|
+
};
|
|
25219
25253
|
|
|
25220
25254
|
//#endregion
|
|
25221
25255
|
//#region src/nodes/image/image.ts
|
|
25222
25256
|
var WeaveImageNode = class extends WeaveNode {
|
|
25257
|
+
imageBitmapCache = {};
|
|
25223
25258
|
imageSource = {};
|
|
25224
25259
|
imageState = {};
|
|
25225
25260
|
nodeType = WEAVE_IMAGE_NODE_TYPE;
|
|
@@ -25235,6 +25270,9 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
25235
25270
|
this.config = mergeExceptArrays(WEAVE_IMAGE_DEFAULT_CONFIG, config);
|
|
25236
25271
|
this.imageCrop = null;
|
|
25237
25272
|
}
|
|
25273
|
+
onRegister() {
|
|
25274
|
+
this.logger.info(`image caching enabled: ${this.config.performance.caching}`);
|
|
25275
|
+
}
|
|
25238
25276
|
triggerCrop(imageNode) {
|
|
25239
25277
|
const stage = this.instance.getStage();
|
|
25240
25278
|
if (imageNode.getAttrs().cropping ?? false) return;
|
|
@@ -25384,8 +25422,9 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
25384
25422
|
};
|
|
25385
25423
|
if (this.imageSource[id]) {
|
|
25386
25424
|
imagePlaceholder.destroy();
|
|
25425
|
+
const imageSource = this.imageSource[id];
|
|
25387
25426
|
internalImage.setAttrs({
|
|
25388
|
-
image:
|
|
25427
|
+
image: imageSource,
|
|
25389
25428
|
visible: true
|
|
25390
25429
|
});
|
|
25391
25430
|
image.setAttr("imageInfo", {
|
|
@@ -25409,14 +25448,27 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
25409
25448
|
this.updatePlaceholderSize(image, imagePlaceholder);
|
|
25410
25449
|
this.loadImage(imageProps, image);
|
|
25411
25450
|
}
|
|
25451
|
+
if (this.config.performance.caching) image.on("transformend", () => {
|
|
25452
|
+
this.cacheNode(image);
|
|
25453
|
+
});
|
|
25412
25454
|
image.setAttr("imageURL", imageProps.imageURL);
|
|
25413
25455
|
this.instance.addEventListener("onNodeRenderedAdded", (node) => {
|
|
25414
25456
|
if (node.id() === image.id() && node.getParent() !== image.getParent()) {
|
|
25415
25457
|
if (this.imageCrop) this.closeCrop(image, WEAVE_IMAGE_CROP_END_TYPE.CANCEL);
|
|
25416
25458
|
}
|
|
25417
25459
|
});
|
|
25460
|
+
this.cacheNode(image);
|
|
25418
25461
|
return image;
|
|
25419
25462
|
}
|
|
25463
|
+
clearCache(nodeInstance) {
|
|
25464
|
+
if (this.config.performance.caching) nodeInstance.clearCache();
|
|
25465
|
+
}
|
|
25466
|
+
cacheNode(nodeInstance) {
|
|
25467
|
+
if (this.config.performance.caching) {
|
|
25468
|
+
nodeInstance.clearCache();
|
|
25469
|
+
nodeInstance.cache();
|
|
25470
|
+
}
|
|
25471
|
+
}
|
|
25420
25472
|
onUpdate(nodeInstance, nextProps) {
|
|
25421
25473
|
const id = nodeInstance.getAttrs().id;
|
|
25422
25474
|
const node = nodeInstance;
|
|
@@ -25516,6 +25568,7 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
25516
25568
|
});
|
|
25517
25569
|
this.updateImageCrop(nodeInstance);
|
|
25518
25570
|
}
|
|
25571
|
+
this.cacheNode(nodeInstance);
|
|
25519
25572
|
}
|
|
25520
25573
|
preloadImage(imageId, imageURL, { onLoad, onError }) {
|
|
25521
25574
|
const realImageURL = this.config.urlTransformer?.(imageURL ?? "") ?? imageURL;
|
|
@@ -25530,7 +25583,7 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
25530
25583
|
delete this.imageState[imageId];
|
|
25531
25584
|
onError(error);
|
|
25532
25585
|
};
|
|
25533
|
-
this.imageSource[imageId].onload = () => {
|
|
25586
|
+
this.imageSource[imageId].onload = async () => {
|
|
25534
25587
|
this.imageState[imageId] = {
|
|
25535
25588
|
loaded: true,
|
|
25536
25589
|
error: false
|
|
@@ -25562,10 +25615,11 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
25562
25615
|
height: imageProps.height ? imageProps.height : this.imageSource[id].height
|
|
25563
25616
|
});
|
|
25564
25617
|
imagePlaceholder.destroy();
|
|
25618
|
+
const imageSource = this.imageSource[id];
|
|
25565
25619
|
internalImage.setAttrs({
|
|
25566
25620
|
width: imageProps.width ? imageProps.width : this.imageSource[id].width,
|
|
25567
25621
|
height: imageProps.height ? imageProps.height : this.imageSource[id].height,
|
|
25568
|
-
image:
|
|
25622
|
+
image: imageSource,
|
|
25569
25623
|
visible: true
|
|
25570
25624
|
});
|
|
25571
25625
|
internalImage.setAttr("imageInfo", {
|
|
@@ -25588,6 +25642,7 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
25588
25642
|
};
|
|
25589
25643
|
this.updateImageCrop(image);
|
|
25590
25644
|
this.resolveAsyncElement(id);
|
|
25645
|
+
this.cacheNode(image);
|
|
25591
25646
|
}
|
|
25592
25647
|
},
|
|
25593
25648
|
onError: (error) => {
|
|
@@ -25612,6 +25667,7 @@ var WeaveImageNode = class extends WeaveNode {
|
|
|
25612
25667
|
console.error("Error loading image", realImageURL, error);
|
|
25613
25668
|
imagePlaceholder?.setAttrs({ visible: true });
|
|
25614
25669
|
internalImage?.setAttrs({ visible: false });
|
|
25670
|
+
this.cacheNode(image);
|
|
25615
25671
|
}
|
|
25616
25672
|
});
|
|
25617
25673
|
}
|
|
@@ -31569,6 +31625,7 @@ const BRUSH_TOOL_DEFAULT_CONFIG = { interpolationSteps: 10 };
|
|
|
31569
31625
|
//#region src/actions/brush-tool/brush-tool.ts
|
|
31570
31626
|
var WeaveBrushToolAction = class extends WeaveAction {
|
|
31571
31627
|
initialized = false;
|
|
31628
|
+
isSpacePressed = false;
|
|
31572
31629
|
onPropsChange = void 0;
|
|
31573
31630
|
onInit = void 0;
|
|
31574
31631
|
constructor(params) {
|
|
@@ -31582,6 +31639,7 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
31582
31639
|
this.isEraser = false;
|
|
31583
31640
|
this.measureContainer = void 0;
|
|
31584
31641
|
this.props = this.initProps();
|
|
31642
|
+
this.isSpacePressed = false;
|
|
31585
31643
|
}
|
|
31586
31644
|
getName() {
|
|
31587
31645
|
return BRUSH_TOOL_ACTION_NAME;
|
|
@@ -31599,11 +31657,15 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
31599
31657
|
}
|
|
31600
31658
|
setupEvents() {
|
|
31601
31659
|
const stage = this.instance.getStage();
|
|
31660
|
+
window.addEventListener("keyup", (e) => {
|
|
31661
|
+
if (e.code === "Space" && this.instance.getActiveAction() === BRUSH_TOOL_ACTION_NAME) this.isSpacePressed = false;
|
|
31662
|
+
});
|
|
31602
31663
|
window.addEventListener("keydown", (e) => {
|
|
31603
31664
|
if (e.code === "Enter" && this.instance.getActiveAction() === BRUSH_TOOL_ACTION_NAME) {
|
|
31604
31665
|
this.cancelAction();
|
|
31605
31666
|
return;
|
|
31606
31667
|
}
|
|
31668
|
+
if (e.code === "Space" && this.instance.getActiveAction() === BRUSH_TOOL_ACTION_NAME) this.isSpacePressed = true;
|
|
31607
31669
|
if (e.code === "Escape" && this.instance.getActiveAction() === BRUSH_TOOL_ACTION_NAME) {
|
|
31608
31670
|
this.cancelAction();
|
|
31609
31671
|
return;
|
|
@@ -31612,6 +31674,8 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
31612
31674
|
const handlePointerDown = (e) => {
|
|
31613
31675
|
if (this.state !== BRUSH_TOOL_STATE.IDLE) return;
|
|
31614
31676
|
if (this.getZoomPlugin()?.isPinching()) return;
|
|
31677
|
+
if (this.isSpacePressed) return;
|
|
31678
|
+
if (e.evt.button !== 0) return;
|
|
31615
31679
|
const pointPressure = this.getEventPressure(e);
|
|
31616
31680
|
this.handleStartStroke(pointPressure);
|
|
31617
31681
|
e.evt.stopPropagation();
|
|
@@ -31785,6 +31849,7 @@ var WeaveBrushToolAction = class extends WeaveAction {
|
|
|
31785
31849
|
}
|
|
31786
31850
|
setCursor() {
|
|
31787
31851
|
const stage = this.instance.getStage();
|
|
31852
|
+
if (this.isSpacePressed) return;
|
|
31788
31853
|
stage.container().style.cursor = "crosshair";
|
|
31789
31854
|
}
|
|
31790
31855
|
setFocusStage() {
|