@inditextech/weave-sdk 2.19.0 → 2.20.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 CHANGED
@@ -20366,22 +20366,27 @@ var WeaveNode = class {
20366
20366
  }
20367
20367
  const realNodeTarget = this.getRealSelectedNode(nodeTarget);
20368
20368
  if (realNodeTarget.getAttrs().isCloned) return;
20369
- originalNode = realNodeTarget.clone();
20370
- originalContainer = realNodeTarget.getParent();
20371
- if (originalContainer?.getAttrs().nodeId) originalContainer = stage.findOne(`#${originalContainer.getAttrs().nodeId}`);
20372
20369
  if (this.getNodesSelectionPlugin()?.getSelectedNodes().length === 1 && realNodeTarget.getAttr("dragStartOpacity") === void 0) {
20373
20370
  realNodeTarget.setAttr("dragStartOpacity", realNodeTarget.opacity());
20374
20371
  realNodeTarget.opacity(this.getNodesSelectionPlugin()?.getDragOpacity());
20375
20372
  }
20373
+ originalNode = realNodeTarget.clone();
20374
+ originalContainer = realNodeTarget.getParent();
20375
+ if (originalContainer?.getAttrs().nodeId) originalContainer = stage.findOne(`#${originalContainer.getAttrs().nodeId}`);
20376
20376
  if (e.evt?.altKey) {
20377
20377
  nodeTarget.setAttrs({ isCloneOrigin: true });
20378
20378
  nodeTarget.setAttrs({ isCloned: false });
20379
20379
  nodeTarget.stopDrag(e.evt);
20380
20380
  e.cancelBubble = true;
20381
20381
  const clone = this.instance.getCloningManager().cloneNode(realNodeTarget);
20382
+ const originalNodeOpacity = realNodeTarget.getAttr("dragStartOpacity") ?? 1;
20383
+ realNodeTarget.setAttrs({ opacity: originalNodeOpacity });
20384
+ realNodeTarget.setAttr("dragStartOpacity", void 0);
20382
20385
  if (clone && !this.instance.getCloningManager().isClone(clone)) {
20383
- clone.setAttrs({ isCloneOrigin: false });
20384
- clone.setAttrs({ isCloned: true });
20386
+ clone.setAttrs({
20387
+ isCloneOrigin: false,
20388
+ isCloned: true
20389
+ });
20385
20390
  this.instance.getCloningManager().addClone(clone);
20386
20391
  }
20387
20392
  stage.setPointersPositions(e.evt);
@@ -20704,6 +20709,9 @@ var WeaveNode = class {
20704
20709
  const usersPresencePlugin = this.instance.getPlugin(WEAVE_USERS_PRESENCE_PLUGIN_KEY);
20705
20710
  return usersPresencePlugin;
20706
20711
  }
20712
+ getIsAsync() {
20713
+ return false;
20714
+ }
20707
20715
  };
20708
20716
 
20709
20717
  //#endregion
@@ -22078,7 +22086,7 @@ var WeaveRegisterManager = class {
22078
22086
 
22079
22087
  //#endregion
22080
22088
  //#region package.json
22081
- var version = "2.19.0";
22089
+ var version = "2.20.1";
22082
22090
 
22083
22091
  //#endregion
22084
22092
  //#region src/managers/setup.ts
@@ -22779,6 +22787,34 @@ var WeaveAsyncManager = class {
22779
22787
  this.asyncElements = watchMap(() => {
22780
22788
  this.instance.emitEvent("onAsyncElementChange");
22781
22789
  }, new Map());
22790
+ this.instance.addEventListener("onRoomLoaded", (isRoomLoaded) => {
22791
+ if (!isRoomLoaded) return;
22792
+ const roomHasResourcesToLoad = this.roomHasResourcesToLoad();
22793
+ if (!roomHasResourcesToLoad && !this.asyncElementsLoadedEventEmitted) {
22794
+ this.instance.emitEvent("onAsyncElementsLoaded");
22795
+ this.asyncElementsLoadedEventEmitted = true;
22796
+ }
22797
+ });
22798
+ }
22799
+ extractAsyncElements(state) {
22800
+ const asyncElements = [];
22801
+ const traverse = (element) => {
22802
+ const nodeHandler = this.instance.getNodeHandler(element.type);
22803
+ if (nodeHandler?.getIsAsync()) asyncElements.push(element);
22804
+ const children = element.props?.children;
22805
+ if (Array.isArray(children)) for (const child of children) traverse(child);
22806
+ };
22807
+ if ("key" in state.weave && state.weave.key === "stage") {
22808
+ const children = state.weave.props.children ?? [];
22809
+ for (const child of children) traverse(child);
22810
+ } else for (const element of Object.values(state.weave)) traverse(element);
22811
+ return asyncElements;
22812
+ }
22813
+ roomHasResourcesToLoad() {
22814
+ const roomData = this.instance.getStore().getState();
22815
+ const jsonRoomData = JSON.parse(JSON.stringify(roomData));
22816
+ const asyncElements = this.extractAsyncElements(jsonRoomData);
22817
+ return asyncElements.length > 0;
22782
22818
  }
22783
22819
  asyncElementsLoaded() {
22784
22820
  return [...this.asyncElements.values()].every((el) => el.status === WEAVE_ASYNC_STATUS.LOADED);
@@ -25247,7 +25283,7 @@ const WEAVE_IMAGE_CROP_END_TYPE = {
25247
25283
  ["CANCEL"]: "cancel"
25248
25284
  };
25249
25285
  const WEAVE_IMAGE_DEFAULT_CONFIG = {
25250
- performance: { caching: false },
25286
+ performance: { cache: { enabled: false } },
25251
25287
  crossOrigin: "anonymous"
25252
25288
  };
25253
25289
 
@@ -25271,7 +25307,7 @@ var WeaveImageNode = class extends WeaveNode {
25271
25307
  this.imageCrop = null;
25272
25308
  }
25273
25309
  onRegister() {
25274
- this.logger.info(`image caching enabled: ${this.config.performance.caching}`);
25310
+ this.logger.info(`image caching enabled: ${this.config.performance.cache.enabled}`);
25275
25311
  }
25276
25312
  triggerCrop(imageNode) {
25277
25313
  const stage = this.instance.getStage();
@@ -25448,7 +25484,7 @@ var WeaveImageNode = class extends WeaveNode {
25448
25484
  this.updatePlaceholderSize(image, imagePlaceholder);
25449
25485
  this.loadImage(imageProps, image);
25450
25486
  }
25451
- if (this.config.performance.caching) image.on("transformend", () => {
25487
+ if (this.config.performance.cache.enabled) image.on("transformend", () => {
25452
25488
  this.cacheNode(image);
25453
25489
  });
25454
25490
  image.setAttr("imageURL", imageProps.imageURL);
@@ -25461,12 +25497,12 @@ var WeaveImageNode = class extends WeaveNode {
25461
25497
  return image;
25462
25498
  }
25463
25499
  clearCache(nodeInstance) {
25464
- if (this.config.performance.caching) nodeInstance.clearCache();
25500
+ if (this.config.performance.cache.enabled) nodeInstance.clearCache();
25465
25501
  }
25466
25502
  cacheNode(nodeInstance) {
25467
- if (this.config.performance.caching) {
25503
+ if (this.config.performance.cache.enabled) {
25468
25504
  nodeInstance.clearCache();
25469
- nodeInstance.cache();
25505
+ nodeInstance.cache({ pixelRatio: this.config.performance.cache.pixelRatio });
25470
25506
  }
25471
25507
  }
25472
25508
  onUpdate(nodeInstance, nextProps) {
@@ -25765,6 +25801,9 @@ var WeaveImageNode = class extends WeaveNode {
25765
25801
  y: 1
25766
25802
  });
25767
25803
  }
25804
+ getIsAsync() {
25805
+ return true;
25806
+ }
25768
25807
  };
25769
25808
 
25770
25809
  //#endregion
@@ -27774,6 +27813,9 @@ var WeaveVideoNode = class extends WeaveNode {
27774
27813
  y: 1
27775
27814
  });
27776
27815
  }
27816
+ getIsAsync() {
27817
+ return true;
27818
+ }
27777
27819
  };
27778
27820
 
27779
27821
  //#endregion
@@ -29793,6 +29835,9 @@ var WeaveConnectorNode = class extends WeaveNode {
29793
29835
  }
29794
29836
  return result;
29795
29837
  };
29838
+ getIsAsync() {
29839
+ return true;
29840
+ }
29796
29841
  };
29797
29842
 
29798
29843
  //#endregion
@@ -31665,13 +31710,14 @@ var WeaveBrushToolAction = class extends WeaveAction {
31665
31710
  this.cancelAction();
31666
31711
  return;
31667
31712
  }
31668
- if (e.code === "Space" && this.instance.getActiveAction() === BRUSH_TOOL_ACTION_NAME) this.isSpacePressed = true;
31669
- if (e.code === "Escape" && this.instance.getActiveAction() === BRUSH_TOOL_ACTION_NAME) {
31670
- this.cancelAction();
31713
+ if (e.code === "Space" && this.instance.getActiveAction() === BRUSH_TOOL_ACTION_NAME) {
31714
+ this.isSpacePressed = true;
31671
31715
  return;
31672
31716
  }
31717
+ if (e.code === "Escape" && this.instance.getActiveAction() === BRUSH_TOOL_ACTION_NAME) this.cancelAction();
31673
31718
  });
31674
31719
  const handlePointerDown = (e) => {
31720
+ if (this.state === BRUSH_TOOL_STATE.INACTIVE) return;
31675
31721
  if (this.state !== BRUSH_TOOL_STATE.IDLE) return;
31676
31722
  if (this.getZoomPlugin()?.isPinching()) return;
31677
31723
  if (this.isSpacePressed) return;