@inditextech/weave-sdk 5.0.0-SNAPSHOT.403.1 → 5.0.0-SNAPSHOT.413.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
@@ -9115,6 +9115,32 @@ var WeaveFontsManager = class {
9115
9115
  this.logger = this.instance.getChildLogger("fonts-manager");
9116
9116
  this.logger.debug("Fonts manager created");
9117
9117
  }
9118
+ async loadFontFamily(fontFamily) {
9119
+ const fontsPromises = [];
9120
+ for (const fontFace of fontFamily.fontFaces) {
9121
+ const { source,...fontFaceDescriptors } = fontFace;
9122
+ const fontVariant = new FontFace(fontFamily.family, source, fontFaceDescriptors);
9123
+ fontsPromises.push(fontVariant.load().then(() => document.fonts.add(fontVariant)));
9124
+ }
9125
+ await Promise.all(fontsPromises);
9126
+ return {
9127
+ id: fontFamily.family,
9128
+ name: `${fontFamily.family}, sans-serif`,
9129
+ offsetY: fontFamily.offset.y,
9130
+ supportedStyles: fontFamily.supportedStyles
9131
+ };
9132
+ }
9133
+ async loadFontsFamilies(fontFamilies) {
9134
+ const familiesPromises = [];
9135
+ for (const fontFamily of fontFamilies) familiesPromises.push(this.loadFontFamily(fontFamily));
9136
+ try {
9137
+ const fonts = await Promise.all(familiesPromises);
9138
+ return fonts;
9139
+ } catch (ex) {
9140
+ console.error("Error loading fonts families", ex);
9141
+ return [];
9142
+ }
9143
+ }
9118
9144
  async loadFonts() {
9119
9145
  this.logger.info("Loading fonts");
9120
9146
  const fontsConfig = this.instance.getConfiguration().fonts;
@@ -9123,7 +9149,7 @@ var WeaveFontsManager = class {
9123
9149
  return;
9124
9150
  }
9125
9151
  let fontsToLoad = [];
9126
- if (fontsConfig && fontsConfig instanceof Function) fontsToLoad = await fontsConfig();
9152
+ if (fontsConfig && fontsConfig instanceof Function) fontsToLoad = await fontsConfig(this.loadFontsFamilies.bind(this));
9127
9153
  if (fontsConfig && fontsConfig instanceof Array) fontsToLoad = fontsConfig;
9128
9154
  for (const font of fontsToLoad) this.loadedFonts.push(font);
9129
9155
  this.logger.info("Fonts loaded");
@@ -9662,7 +9688,7 @@ var WeaveRegisterManager = class {
9662
9688
 
9663
9689
  //#endregion
9664
9690
  //#region package.json
9665
- var version = "5.0.0-SNAPSHOT.403.1";
9691
+ var version = "5.0.0-SNAPSHOT.413.1";
9666
9692
 
9667
9693
  //#endregion
9668
9694
  //#region src/managers/setup.ts
@@ -10977,6 +11003,12 @@ var Weave = class {
10977
11003
  this.stageManager.initStage();
10978
11004
  this.status = WEAVE_INSTANCE_STATUS.CONNECTING_TO_ROOM;
10979
11005
  this.emitEvent("onInstanceStatus", this.status);
11006
+ this.emitEvent("onUndoManagerStatusChange", {
11007
+ canUndo: false,
11008
+ canRedo: false,
11009
+ redoStackLength: 0,
11010
+ undoStackLength: 0
11011
+ });
10980
11012
  this.addEventListener("onStoreConnectionStatusChange", this.handleStoreConnectionStatusChange.bind(this));
10981
11013
  }
10982
11014
  async destroy() {
@@ -16041,6 +16073,18 @@ var WeaveImageNode = class extends WeaveNode {
16041
16073
  }
16042
16074
  if (node) this.loadImage(node.getAttrs(), node, false, false);
16043
16075
  }
16076
+ forceLoadFallbackImage(nodeInstance, dataURL) {
16077
+ const nodeId = nodeInstance.getAttrs().id ?? "";
16078
+ const node = this.instance.getStage().findOne(`#${nodeId}`);
16079
+ if (this.imageTryoutIds[nodeId]) {
16080
+ clearTimeout(this.imageTryoutIds[nodeId]);
16081
+ delete this.imageTryoutIds[nodeId];
16082
+ }
16083
+ if (node) {
16084
+ this.cacheImageFallbackURL(node.getAttrs(), dataURL);
16085
+ this.loadImage(node.getAttrs(), node, true);
16086
+ }
16087
+ }
16044
16088
  onDestroy(nodeInstance) {
16045
16089
  const nodeId = nodeInstance.getAttrs().id ?? "";
16046
16090
  const utilityLayer = this.instance.getUtilityLayer();
@@ -24783,6 +24827,7 @@ const WEAVE_IMAGE_TOOL_CONFIG_DEFAULT = { style: { cursor: {
24783
24827
  //#endregion
24784
24828
  //#region src/actions/image-tool/image-tool.ts
24785
24829
  var WeaveImageToolAction = class extends WeaveAction {
24830
+ initInitialized = false;
24786
24831
  initialized = false;
24787
24832
  initialCursor = null;
24788
24833
  imageAction = {};
@@ -24815,7 +24860,8 @@ var WeaveImageToolAction = class extends WeaveAction {
24815
24860
  };
24816
24861
  }
24817
24862
  onInit() {
24818
- this.instance.addEventListener("onStageDrop", (e) => {
24863
+ if (this.initInitialized) return;
24864
+ const handleImageOnStageDrop = (e) => {
24819
24865
  const dragId = this.instance.getDragStartedId();
24820
24866
  const dragProperties = this.instance.getDragProperties();
24821
24867
  if (dragProperties && dragId === WEAVE_IMAGE_TOOL_ACTION_NAME) {
@@ -24831,7 +24877,9 @@ var WeaveImageToolAction = class extends WeaveAction {
24831
24877
  position: mousePoint
24832
24878
  });
24833
24879
  }
24834
- });
24880
+ };
24881
+ this.instance.addEventListener("onStageDrop", handleImageOnStageDrop);
24882
+ this.initInitialized = true;
24835
24883
  }
24836
24884
  setupEvents() {
24837
24885
  const stage = this.instance.getStage();
@@ -25237,6 +25285,7 @@ const WEAVE_IMAGES_TOOL_DEFAULT_CONFIG = {
25237
25285
  //#endregion
25238
25286
  //#region src/actions/images-tool/images-tool.ts
25239
25287
  var WeaveImagesToolAction = class extends WeaveAction {
25288
+ initInitialized = false;
25240
25289
  initialized = false;
25241
25290
  initialCursor = null;
25242
25291
  nodesIds = [];
@@ -25279,7 +25328,8 @@ var WeaveImagesToolAction = class extends WeaveAction {
25279
25328
  };
25280
25329
  }
25281
25330
  onInit() {
25282
- this.instance.addEventListener("onStageDrop", (e) => {
25331
+ if (this.initInitialized) return;
25332
+ const handleImagesOnStageDrop = (e) => {
25283
25333
  const dragId = this.instance.getDragStartedId();
25284
25334
  const dragProperties = this.instance.getDragProperties();
25285
25335
  if (dragProperties && dragId === WEAVE_IMAGES_TOOL_ACTION_NAME) {
@@ -25294,7 +25344,9 @@ var WeaveImagesToolAction = class extends WeaveAction {
25294
25344
  ...dragProperties.forceMainContainer && { forceMainContainer: dragProperties.forceMainContainer }
25295
25345
  });
25296
25346
  }
25297
- });
25347
+ };
25348
+ this.instance.addEventListener("onStageDrop", handleImagesOnStageDrop);
25349
+ this.initInitialized = true;
25298
25350
  }
25299
25351
  setupEvents() {
25300
25352
  const stage = this.instance.getStage();
@@ -27484,6 +27536,7 @@ const VIDEO_TOOL_STATE = {
27484
27536
  //#endregion
27485
27537
  //#region src/actions/video-tool/video-tool.ts
27486
27538
  var WeaveVideoToolAction = class extends WeaveAction {
27539
+ initInitialized = false;
27487
27540
  initialized = false;
27488
27541
  initialCursor = null;
27489
27542
  cursorPadding = 5;
@@ -27520,7 +27573,8 @@ var WeaveVideoToolAction = class extends WeaveAction {
27520
27573
  };
27521
27574
  }
27522
27575
  onInit() {
27523
- this.instance.addEventListener("onStageDrop", (e) => {
27576
+ if (this.initInitialized) return;
27577
+ const handleVideoOnStageDrop = (e) => {
27524
27578
  const dragId = this.instance.getDragStartedId();
27525
27579
  const dragProperties = this.instance.getDragProperties();
27526
27580
  if (dragProperties && dragId === VIDEO_TOOL_ACTION_NAME) {
@@ -27534,7 +27588,9 @@ var WeaveVideoToolAction = class extends WeaveAction {
27534
27588
  position: mousePoint
27535
27589
  });
27536
27590
  }
27537
- });
27591
+ };
27592
+ this.instance.addEventListener("onStageDrop", handleVideoOnStageDrop);
27593
+ this.initInitialized = true;
27538
27594
  }
27539
27595
  setupEvents() {
27540
27596
  const stage = this.instance.getStage();
package/dist/sdk.node.js CHANGED
@@ -9114,6 +9114,32 @@ var WeaveFontsManager = class {
9114
9114
  this.logger = this.instance.getChildLogger("fonts-manager");
9115
9115
  this.logger.debug("Fonts manager created");
9116
9116
  }
9117
+ async loadFontFamily(fontFamily) {
9118
+ const fontsPromises = [];
9119
+ for (const fontFace of fontFamily.fontFaces) {
9120
+ const { source,...fontFaceDescriptors } = fontFace;
9121
+ const fontVariant = new FontFace(fontFamily.family, source, fontFaceDescriptors);
9122
+ fontsPromises.push(fontVariant.load().then(() => document.fonts.add(fontVariant)));
9123
+ }
9124
+ await Promise.all(fontsPromises);
9125
+ return {
9126
+ id: fontFamily.family,
9127
+ name: `${fontFamily.family}, sans-serif`,
9128
+ offsetY: fontFamily.offset.y,
9129
+ supportedStyles: fontFamily.supportedStyles
9130
+ };
9131
+ }
9132
+ async loadFontsFamilies(fontFamilies) {
9133
+ const familiesPromises = [];
9134
+ for (const fontFamily of fontFamilies) familiesPromises.push(this.loadFontFamily(fontFamily));
9135
+ try {
9136
+ const fonts = await Promise.all(familiesPromises);
9137
+ return fonts;
9138
+ } catch (ex) {
9139
+ console.error("Error loading fonts families", ex);
9140
+ return [];
9141
+ }
9142
+ }
9117
9143
  async loadFonts() {
9118
9144
  this.logger.info("Loading fonts");
9119
9145
  const fontsConfig = this.instance.getConfiguration().fonts;
@@ -9122,7 +9148,7 @@ var WeaveFontsManager = class {
9122
9148
  return;
9123
9149
  }
9124
9150
  let fontsToLoad = [];
9125
- if (fontsConfig && fontsConfig instanceof Function) fontsToLoad = await fontsConfig();
9151
+ if (fontsConfig && fontsConfig instanceof Function) fontsToLoad = await fontsConfig(this.loadFontsFamilies.bind(this));
9126
9152
  if (fontsConfig && fontsConfig instanceof Array) fontsToLoad = fontsConfig;
9127
9153
  for (const font of fontsToLoad) this.loadedFonts.push(font);
9128
9154
  this.logger.info("Fonts loaded");
@@ -9661,7 +9687,7 @@ var WeaveRegisterManager = class {
9661
9687
 
9662
9688
  //#endregion
9663
9689
  //#region package.json
9664
- var version = "5.0.0-SNAPSHOT.403.1";
9690
+ var version = "5.0.0-SNAPSHOT.413.1";
9665
9691
 
9666
9692
  //#endregion
9667
9693
  //#region src/managers/setup.ts
@@ -10976,6 +11002,12 @@ var Weave = class {
10976
11002
  this.stageManager.initStage();
10977
11003
  this.status = WEAVE_INSTANCE_STATUS.CONNECTING_TO_ROOM;
10978
11004
  this.emitEvent("onInstanceStatus", this.status);
11005
+ this.emitEvent("onUndoManagerStatusChange", {
11006
+ canUndo: false,
11007
+ canRedo: false,
11008
+ redoStackLength: 0,
11009
+ undoStackLength: 0
11010
+ });
10979
11011
  this.addEventListener("onStoreConnectionStatusChange", this.handleStoreConnectionStatusChange.bind(this));
10980
11012
  }
10981
11013
  async destroy() {
@@ -16040,6 +16072,18 @@ var WeaveImageNode = class extends WeaveNode {
16040
16072
  }
16041
16073
  if (node) this.loadImage(node.getAttrs(), node, false, false);
16042
16074
  }
16075
+ forceLoadFallbackImage(nodeInstance, dataURL) {
16076
+ const nodeId = nodeInstance.getAttrs().id ?? "";
16077
+ const node = this.instance.getStage().findOne(`#${nodeId}`);
16078
+ if (this.imageTryoutIds[nodeId]) {
16079
+ clearTimeout(this.imageTryoutIds[nodeId]);
16080
+ delete this.imageTryoutIds[nodeId];
16081
+ }
16082
+ if (node) {
16083
+ this.cacheImageFallbackURL(node.getAttrs(), dataURL);
16084
+ this.loadImage(node.getAttrs(), node, true);
16085
+ }
16086
+ }
16043
16087
  onDestroy(nodeInstance) {
16044
16088
  const nodeId = nodeInstance.getAttrs().id ?? "";
16045
16089
  const utilityLayer = this.instance.getUtilityLayer();
@@ -24782,6 +24826,7 @@ const WEAVE_IMAGE_TOOL_CONFIG_DEFAULT = { style: { cursor: {
24782
24826
  //#endregion
24783
24827
  //#region src/actions/image-tool/image-tool.ts
24784
24828
  var WeaveImageToolAction = class extends WeaveAction {
24829
+ initInitialized = false;
24785
24830
  initialized = false;
24786
24831
  initialCursor = null;
24787
24832
  imageAction = {};
@@ -24814,7 +24859,8 @@ var WeaveImageToolAction = class extends WeaveAction {
24814
24859
  };
24815
24860
  }
24816
24861
  onInit() {
24817
- this.instance.addEventListener("onStageDrop", (e) => {
24862
+ if (this.initInitialized) return;
24863
+ const handleImageOnStageDrop = (e) => {
24818
24864
  const dragId = this.instance.getDragStartedId();
24819
24865
  const dragProperties = this.instance.getDragProperties();
24820
24866
  if (dragProperties && dragId === WEAVE_IMAGE_TOOL_ACTION_NAME) {
@@ -24830,7 +24876,9 @@ var WeaveImageToolAction = class extends WeaveAction {
24830
24876
  position: mousePoint
24831
24877
  });
24832
24878
  }
24833
- });
24879
+ };
24880
+ this.instance.addEventListener("onStageDrop", handleImageOnStageDrop);
24881
+ this.initInitialized = true;
24834
24882
  }
24835
24883
  setupEvents() {
24836
24884
  const stage = this.instance.getStage();
@@ -25236,6 +25284,7 @@ const WEAVE_IMAGES_TOOL_DEFAULT_CONFIG = {
25236
25284
  //#endregion
25237
25285
  //#region src/actions/images-tool/images-tool.ts
25238
25286
  var WeaveImagesToolAction = class extends WeaveAction {
25287
+ initInitialized = false;
25239
25288
  initialized = false;
25240
25289
  initialCursor = null;
25241
25290
  nodesIds = [];
@@ -25278,7 +25327,8 @@ var WeaveImagesToolAction = class extends WeaveAction {
25278
25327
  };
25279
25328
  }
25280
25329
  onInit() {
25281
- this.instance.addEventListener("onStageDrop", (e) => {
25330
+ if (this.initInitialized) return;
25331
+ const handleImagesOnStageDrop = (e) => {
25282
25332
  const dragId = this.instance.getDragStartedId();
25283
25333
  const dragProperties = this.instance.getDragProperties();
25284
25334
  if (dragProperties && dragId === WEAVE_IMAGES_TOOL_ACTION_NAME) {
@@ -25293,7 +25343,9 @@ var WeaveImagesToolAction = class extends WeaveAction {
25293
25343
  ...dragProperties.forceMainContainer && { forceMainContainer: dragProperties.forceMainContainer }
25294
25344
  });
25295
25345
  }
25296
- });
25346
+ };
25347
+ this.instance.addEventListener("onStageDrop", handleImagesOnStageDrop);
25348
+ this.initInitialized = true;
25297
25349
  }
25298
25350
  setupEvents() {
25299
25351
  const stage = this.instance.getStage();
@@ -27483,6 +27535,7 @@ const VIDEO_TOOL_STATE = {
27483
27535
  //#endregion
27484
27536
  //#region src/actions/video-tool/video-tool.ts
27485
27537
  var WeaveVideoToolAction = class extends WeaveAction {
27538
+ initInitialized = false;
27486
27539
  initialized = false;
27487
27540
  initialCursor = null;
27488
27541
  cursorPadding = 5;
@@ -27519,7 +27572,8 @@ var WeaveVideoToolAction = class extends WeaveAction {
27519
27572
  };
27520
27573
  }
27521
27574
  onInit() {
27522
- this.instance.addEventListener("onStageDrop", (e) => {
27575
+ if (this.initInitialized) return;
27576
+ const handleVideoOnStageDrop = (e) => {
27523
27577
  const dragId = this.instance.getDragStartedId();
27524
27578
  const dragProperties = this.instance.getDragProperties();
27525
27579
  if (dragProperties && dragId === VIDEO_TOOL_ACTION_NAME) {
@@ -27533,7 +27587,9 @@ var WeaveVideoToolAction = class extends WeaveAction {
27533
27587
  position: mousePoint
27534
27588
  });
27535
27589
  }
27536
- });
27590
+ };
27591
+ this.instance.addEventListener("onStageDrop", handleVideoOnStageDrop);
27592
+ this.initInitialized = true;
27537
27593
  }
27538
27594
  setupEvents() {
27539
27595
  const stage = this.instance.getStage();