@inditextech/weave-sdk 5.0.0-SNAPSHOT.336.1 → 5.0.0-SNAPSHOT.342.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
@@ -9442,7 +9442,7 @@ var WeaveRegisterManager = class {
9442
9442
 
9443
9443
  //#endregion
9444
9444
  //#region package.json
9445
- var version = "5.0.0-SNAPSHOT.336.1";
9445
+ var version = "5.0.0-SNAPSHOT.342.1";
9446
9446
 
9447
9447
  //#endregion
9448
9448
  //#region src/managers/setup.ts
@@ -9802,60 +9802,80 @@ var WeaveExportManager = class {
9802
9802
  outH
9803
9803
  };
9804
9804
  }
9805
+ cloneStageForExport() {
9806
+ const originalStage = this.instance.getStage();
9807
+ const stage = originalStage.clone();
9808
+ const mainLayer = stage.findOne("#mainLayer");
9809
+ if (!mainLayer) throw new Error("Main layer not found");
9810
+ const selectionLayer = stage.findOne(`#${WEAVE_NODES_SELECTION_LAYER_ID}`);
9811
+ selectionLayer?.destroy();
9812
+ const gridLayer = stage.findOne(`#${WEAVE_GRID_LAYER_ID}`);
9813
+ gridLayer?.destroy();
9814
+ const scaleX = originalStage.scaleX();
9815
+ const scaleY = originalStage.scaleY();
9816
+ return {
9817
+ stage,
9818
+ mainLayer,
9819
+ originalScale: {
9820
+ scaleX,
9821
+ scaleY
9822
+ }
9823
+ };
9824
+ }
9825
+ setupForExport({ nodes, bounds, stage, mainLayer, scaleX, scaleY, options, exportArea }) {
9826
+ const { padding = 0, pixelRatio = 1, backgroundColor = WEAVE_EXPORT_BACKGROUND_COLOR } = options;
9827
+ const unscaledBounds = {
9828
+ x: bounds.x / scaleX,
9829
+ y: bounds.y / scaleY,
9830
+ width: bounds.width / scaleX,
9831
+ height: bounds.height / scaleY
9832
+ };
9833
+ const background = new Konva.Rect({
9834
+ x: unscaledBounds.x - padding,
9835
+ y: unscaledBounds.y - padding,
9836
+ width: unscaledBounds.width + 2 * padding,
9837
+ height: unscaledBounds.height + 2 * padding,
9838
+ strokeWidth: 0,
9839
+ fill: backgroundColor
9840
+ });
9841
+ const exportGroup = new Konva.Group();
9842
+ if (!exportArea) {
9843
+ exportGroup.add(background);
9844
+ for (const node of nodes) {
9845
+ const clonedNode = node.clone({ id: v4_default() });
9846
+ const absPos = node.getAbsolutePosition();
9847
+ clonedNode.absolutePosition({
9848
+ x: absPos.x / scaleX,
9849
+ y: absPos.y / scaleY
9850
+ });
9851
+ exportGroup.add(clonedNode);
9852
+ }
9853
+ mainLayer.add(exportGroup);
9854
+ } else mainLayer.add(background);
9855
+ const backgroundRect = background.getClientRect();
9856
+ stage.batchDraw();
9857
+ const { pixelRatio: finalPixelRatio } = this.fitKonvaPixelRatio(Math.round(backgroundRect.width), Math.round(backgroundRect.height), pixelRatio);
9858
+ return {
9859
+ exportGroup,
9860
+ pixelRatio: finalPixelRatio,
9861
+ backgroundRect
9862
+ };
9863
+ }
9805
9864
  exportNodesAsImage(nodes, boundingNodes, options) {
9806
9865
  return new Promise((resolve) => {
9807
- const { format = WEAVE_EXPORT_FORMATS.PNG, padding = 0, pixelRatio = 1, backgroundColor = WEAVE_EXPORT_BACKGROUND_COLOR } = options;
9808
- const nodesSelectionPluginPrev = this.getNodesSelectionPlugin()?.isEnabled();
9809
- const nodesStageGridPluginPrev = this.getStageGridPlugin()?.isEnabled();
9810
- this.getNodesSelectionPlugin()?.disable();
9811
- this.getStageGridPlugin()?.disable();
9812
- const stage = this.instance.getStage();
9813
- const mainLayer = this.instance.getMainLayer();
9814
- const originalPosition = {
9815
- x: stage.x(),
9816
- y: stage.y()
9817
- };
9818
- const originalScale = {
9819
- x: stage.scaleX(),
9820
- y: stage.scaleY()
9821
- };
9822
- stage.scale({
9823
- x: 1,
9824
- y: 1
9825
- });
9866
+ const { format = WEAVE_EXPORT_FORMATS.PNG } = options;
9867
+ const { stage, mainLayer, originalScale: { scaleX, scaleY } } = this.cloneStageForExport();
9826
9868
  if (mainLayer) {
9827
- const bounds = getExportBoundingBox(boundingNodes(nodes));
9828
- const scaleX = stage.scaleX();
9829
- const scaleY = stage.scaleY();
9830
- const unscaledBounds = {
9831
- x: bounds.x / scaleX,
9832
- y: bounds.y / scaleY,
9833
- width: bounds.width / scaleX,
9834
- height: bounds.height / scaleY
9835
- };
9836
- const exportGroup = new Konva.Group();
9837
- const background = new Konva.Rect({
9838
- x: unscaledBounds.x - padding,
9839
- y: unscaledBounds.y - padding,
9840
- width: unscaledBounds.width + 2 * padding,
9841
- height: unscaledBounds.height + 2 * padding,
9842
- strokeWidth: 0,
9843
- fill: backgroundColor
9869
+ const { pixelRatio: finalPixelRatio, backgroundRect, exportGroup } = this.setupForExport({
9870
+ nodes,
9871
+ bounds: getExportBoundingBox(boundingNodes(nodes)),
9872
+ stage,
9873
+ mainLayer,
9874
+ scaleX,
9875
+ scaleY,
9876
+ options,
9877
+ exportArea: false
9844
9878
  });
9845
- exportGroup.add(background);
9846
- for (const node of nodes) {
9847
- const clonedNode = node.clone({ id: v4_default() });
9848
- const absPos = node.getAbsolutePosition();
9849
- clonedNode.absolutePosition({
9850
- x: absPos.x / scaleX,
9851
- y: absPos.y / scaleY
9852
- });
9853
- exportGroup.add(clonedNode);
9854
- }
9855
- mainLayer.add(exportGroup);
9856
- const backgroundRect = background.getClientRect();
9857
- stage.batchDraw();
9858
- const { pixelRatio: finalPixelRatio } = this.fitKonvaPixelRatio(Math.round(backgroundRect.width), Math.round(backgroundRect.height), pixelRatio);
9859
9879
  exportGroup.toImage({
9860
9880
  x: Math.round(backgroundRect.x),
9861
9881
  y: Math.round(backgroundRect.y),
@@ -9866,11 +9886,7 @@ var WeaveExportManager = class {
9866
9886
  quality: options.quality ?? 1,
9867
9887
  callback: (img) => {
9868
9888
  exportGroup.destroy();
9869
- stage.position(originalPosition);
9870
- stage.scale(originalScale);
9871
- stage.batchDraw();
9872
- if (nodesSelectionPluginPrev) this.getNodesSelectionPlugin()?.enable();
9873
- if (nodesStageGridPluginPrev) this.getStageGridPlugin()?.enable();
9889
+ stage.destroy();
9874
9890
  resolve(img);
9875
9891
  }
9876
9892
  });
@@ -9879,58 +9895,19 @@ var WeaveExportManager = class {
9879
9895
  }
9880
9896
  exportNodesAsBlob(nodes, boundingNodes, options) {
9881
9897
  return new Promise((resolve) => {
9882
- const { format = WEAVE_EXPORT_FORMATS.PNG, padding = 0, pixelRatio = 1, backgroundColor = WEAVE_EXPORT_BACKGROUND_COLOR } = options;
9883
- const nodesSelectionPluginPrev = this.getNodesSelectionPlugin()?.isEnabled();
9884
- const nodesStageGridPluginPrev = this.getStageGridPlugin()?.isEnabled();
9885
- this.getNodesSelectionPlugin()?.disable();
9886
- this.getStageGridPlugin()?.disable();
9887
- const stage = this.instance.getStage();
9888
- const mainLayer = this.instance.getMainLayer();
9889
- const originalPosition = {
9890
- x: stage.x(),
9891
- y: stage.y()
9892
- };
9893
- const originalScale = {
9894
- x: stage.scaleX(),
9895
- y: stage.scaleY()
9896
- };
9897
- stage.scale({
9898
- x: 1,
9899
- y: 1
9900
- });
9898
+ const { format = WEAVE_EXPORT_FORMATS.PNG } = options;
9899
+ const { stage, mainLayer, originalScale: { scaleX, scaleY } } = this.cloneStageForExport();
9901
9900
  if (mainLayer) {
9902
- const bounds = getExportBoundingBox(boundingNodes(nodes));
9903
- const scaleX = stage.scaleX();
9904
- const scaleY = stage.scaleY();
9905
- const unscaledBounds = {
9906
- x: bounds.x / scaleX,
9907
- y: bounds.y / scaleY,
9908
- width: bounds.width / scaleX,
9909
- height: bounds.height / scaleY
9910
- };
9911
- const exportGroup = new Konva.Group();
9912
- const background = new Konva.Rect({
9913
- x: unscaledBounds.x - padding,
9914
- y: unscaledBounds.y - padding,
9915
- width: unscaledBounds.width + 2 * padding,
9916
- height: unscaledBounds.height + 2 * padding,
9917
- strokeWidth: 0,
9918
- fill: backgroundColor
9901
+ const { pixelRatio: finalPixelRatio, backgroundRect, exportGroup } = this.setupForExport({
9902
+ nodes,
9903
+ bounds: getExportBoundingBox(boundingNodes(nodes)),
9904
+ stage,
9905
+ mainLayer,
9906
+ scaleX,
9907
+ scaleY,
9908
+ options,
9909
+ exportArea: false
9919
9910
  });
9920
- exportGroup.add(background);
9921
- for (const node of nodes) {
9922
- const clonedNode = node.clone({ id: v4_default() });
9923
- const absPos = node.getAbsolutePosition();
9924
- clonedNode.absolutePosition({
9925
- x: absPos.x / scaleX,
9926
- y: absPos.y / scaleY
9927
- });
9928
- exportGroup.add(clonedNode);
9929
- }
9930
- mainLayer.add(exportGroup);
9931
- const backgroundRect = background.getClientRect();
9932
- stage.batchDraw();
9933
- const { pixelRatio: finalPixelRatio } = this.fitKonvaPixelRatio(Math.round(backgroundRect.width), Math.round(backgroundRect.height), pixelRatio);
9934
9911
  exportGroup.toBlob({
9935
9912
  x: Math.round(backgroundRect.x),
9936
9913
  y: Math.round(backgroundRect.y),
@@ -9941,11 +9918,7 @@ var WeaveExportManager = class {
9941
9918
  quality: options.quality ?? 1,
9942
9919
  callback: (blob) => {
9943
9920
  exportGroup.destroy();
9944
- stage.position(originalPosition);
9945
- stage.scale(originalScale);
9946
- stage.batchDraw();
9947
- if (nodesSelectionPluginPrev) this.getNodesSelectionPlugin()?.enable();
9948
- if (nodesStageGridPluginPrev) this.getStageGridPlugin()?.enable();
9921
+ stage.destroy();
9949
9922
  if (!blob) {
9950
9923
  (0, import_reject.default)(new Error("Failed to generate image blob"));
9951
9924
  return;
@@ -9958,58 +9931,19 @@ var WeaveExportManager = class {
9958
9931
  }
9959
9932
  exportNodesAsCanvas(nodes, boundingNodes, options) {
9960
9933
  return new Promise((resolve) => {
9961
- const { format = WEAVE_EXPORT_FORMATS.PNG, padding = 0, pixelRatio = 1, backgroundColor = WEAVE_EXPORT_BACKGROUND_COLOR } = options;
9962
- const nodesSelectionPluginPrev = this.getNodesSelectionPlugin()?.isEnabled();
9963
- const nodesStageGridPluginPrev = this.getStageGridPlugin()?.isEnabled();
9964
- this.getNodesSelectionPlugin()?.disable();
9965
- this.getStageGridPlugin()?.disable();
9966
- const stage = this.instance.getStage();
9967
- const mainLayer = this.instance.getMainLayer();
9968
- const originalPosition = {
9969
- x: stage.x(),
9970
- y: stage.y()
9971
- };
9972
- const originalScale = {
9973
- x: stage.scaleX(),
9974
- y: stage.scaleY()
9975
- };
9976
- stage.scale({
9977
- x: 1,
9978
- y: 1
9979
- });
9934
+ const { format = WEAVE_EXPORT_FORMATS.PNG } = options;
9935
+ const { stage, mainLayer, originalScale: { scaleX, scaleY } } = this.cloneStageForExport();
9980
9936
  if (mainLayer) {
9981
- const bounds = getExportBoundingBox(boundingNodes(nodes));
9982
- const scaleX = stage.scaleX();
9983
- const scaleY = stage.scaleY();
9984
- const unscaledBounds = {
9985
- x: bounds.x / scaleX,
9986
- y: bounds.y / scaleY,
9987
- width: bounds.width / scaleX,
9988
- height: bounds.height / scaleY
9989
- };
9990
- const exportGroup = new Konva.Group();
9991
- const background = new Konva.Rect({
9992
- x: unscaledBounds.x - padding,
9993
- y: unscaledBounds.y - padding,
9994
- width: unscaledBounds.width + 2 * padding,
9995
- height: unscaledBounds.height + 2 * padding,
9996
- strokeWidth: 0,
9997
- fill: backgroundColor
9937
+ const { pixelRatio: finalPixelRatio, backgroundRect, exportGroup } = this.setupForExport({
9938
+ nodes,
9939
+ bounds: getExportBoundingBox(boundingNodes(nodes)),
9940
+ stage,
9941
+ mainLayer,
9942
+ scaleX,
9943
+ scaleY,
9944
+ options,
9945
+ exportArea: false
9998
9946
  });
9999
- exportGroup.add(background);
10000
- for (const node of nodes) {
10001
- const clonedNode = node.clone({ id: v4_default() });
10002
- const absPos = node.getAbsolutePosition();
10003
- clonedNode.absolutePosition({
10004
- x: absPos.x / scaleX,
10005
- y: absPos.y / scaleY
10006
- });
10007
- exportGroup.add(clonedNode);
10008
- }
10009
- mainLayer.add(exportGroup);
10010
- const backgroundRect = background.getClientRect();
10011
- stage.batchDraw();
10012
- const { pixelRatio: finalPixelRatio } = this.fitKonvaPixelRatio(Math.round(backgroundRect.width), Math.round(backgroundRect.height), pixelRatio);
10013
9947
  exportGroup.toCanvas({
10014
9948
  x: Math.round(backgroundRect.x),
10015
9949
  y: Math.round(backgroundRect.y),
@@ -10020,11 +9954,7 @@ var WeaveExportManager = class {
10020
9954
  quality: options.quality ?? 1,
10021
9955
  callback: (canvas) => {
10022
9956
  exportGroup.destroy();
10023
- stage.position(originalPosition);
10024
- stage.scale(originalScale);
10025
- stage.batchDraw();
10026
- if (nodesSelectionPluginPrev) this.getNodesSelectionPlugin()?.enable();
10027
- if (nodesStageGridPluginPrev) this.getStageGridPlugin()?.enable();
9957
+ stage.destroy();
10028
9958
  resolve(canvas);
10029
9959
  }
10030
9960
  });
@@ -10033,180 +9963,99 @@ var WeaveExportManager = class {
10033
9963
  }
10034
9964
  exportAreaAsImage(area, options) {
10035
9965
  return new Promise((resolve) => {
10036
- const { format = WEAVE_EXPORT_FORMATS.PNG, padding = 0, pixelRatio = 1, backgroundColor = WEAVE_EXPORT_BACKGROUND_COLOR } = options;
10037
- const nodesSelectionPluginPrev = this.getNodesSelectionPlugin()?.isEnabled();
10038
- const nodesStageGridPluginPrev = this.getStageGridPlugin()?.isEnabled();
10039
- this.getNodesSelectionPlugin()?.disable();
10040
- this.getStageGridPlugin()?.disable();
10041
- const stage = this.instance.getStage();
10042
- const mainLayer = this.instance.getMainLayer();
10043
- if (!mainLayer) throw new Error("Main layer not found");
10044
- const originalPosition = {
10045
- x: stage.x(),
10046
- y: stage.y()
10047
- };
10048
- const originalScale = {
10049
- x: stage.scaleX(),
10050
- y: stage.scaleY()
10051
- };
10052
- stage.scale({
10053
- x: 1,
10054
- y: 1
10055
- });
10056
- stage.position({
10057
- x: 0,
10058
- y: 0
10059
- });
10060
- const bounds = area;
10061
- const background = new Konva.Rect({
10062
- x: bounds.x - padding,
10063
- y: bounds.y - padding,
10064
- width: bounds.width + 2 * padding,
10065
- height: bounds.height + 2 * padding,
10066
- strokeWidth: 0,
10067
- fill: backgroundColor
10068
- });
10069
- mainLayer.add(background);
10070
- background.moveToBottom();
10071
- stage.batchDraw();
10072
- stage.toImage({
10073
- x: area.x,
10074
- y: area.y,
10075
- width: area.width,
10076
- height: area.height,
10077
- mimeType: format,
10078
- pixelRatio,
10079
- quality: options.quality ?? 1,
10080
- callback: (img) => {
10081
- background.destroy();
10082
- stage.position(originalPosition);
10083
- stage.scale(originalScale);
10084
- stage.batchDraw();
10085
- if (nodesSelectionPluginPrev) this.getNodesSelectionPlugin()?.enable();
10086
- if (nodesStageGridPluginPrev) this.getStageGridPlugin()?.enable();
10087
- resolve(img);
10088
- }
10089
- });
9966
+ const { format = WEAVE_EXPORT_FORMATS.PNG } = options;
9967
+ const { stage, mainLayer, originalScale: { scaleX, scaleY } } = this.cloneStageForExport();
9968
+ if (mainLayer) {
9969
+ const { pixelRatio: finalPixelRatio } = this.setupForExport({
9970
+ nodes: [],
9971
+ bounds: area,
9972
+ stage,
9973
+ mainLayer,
9974
+ scaleX,
9975
+ scaleY,
9976
+ options,
9977
+ exportArea: true
9978
+ });
9979
+ stage.toImage({
9980
+ x: area.x,
9981
+ y: area.y,
9982
+ width: area.width,
9983
+ height: area.height,
9984
+ mimeType: format,
9985
+ pixelRatio: finalPixelRatio,
9986
+ quality: options.quality ?? 1,
9987
+ callback: (img) => {
9988
+ stage.destroy();
9989
+ resolve(img);
9990
+ }
9991
+ });
9992
+ }
10090
9993
  });
10091
9994
  }
10092
9995
  exportAreaAsBlob(area, options) {
10093
9996
  return new Promise((resolve) => {
10094
- const { format = WEAVE_EXPORT_FORMATS.PNG, padding = 0, pixelRatio = 1, backgroundColor = WEAVE_EXPORT_BACKGROUND_COLOR } = options;
10095
- const nodesSelectionPluginPrev = this.getNodesSelectionPlugin()?.isEnabled();
10096
- const nodesStageGridPluginPrev = this.getStageGridPlugin()?.isEnabled();
10097
- this.getNodesSelectionPlugin()?.disable();
10098
- this.getStageGridPlugin()?.disable();
10099
- const stage = this.instance.getStage();
10100
- const mainLayer = this.instance.getMainLayer();
10101
- if (!mainLayer) throw new Error("Main layer not found");
10102
- const originalPosition = {
10103
- x: stage.x(),
10104
- y: stage.y()
10105
- };
10106
- const originalScale = {
10107
- x: stage.scaleX(),
10108
- y: stage.scaleY()
10109
- };
10110
- stage.scale({
10111
- x: 1,
10112
- y: 1
10113
- });
10114
- stage.position({
10115
- x: 0,
10116
- y: 0
10117
- });
10118
- const bounds = area;
10119
- const background = new Konva.Rect({
10120
- x: bounds.x - padding,
10121
- y: bounds.y - padding,
10122
- width: bounds.width + 2 * padding,
10123
- height: bounds.height + 2 * padding,
10124
- strokeWidth: 0,
10125
- fill: backgroundColor
10126
- });
10127
- mainLayer.add(background);
10128
- background.moveToBottom();
10129
- stage.batchDraw();
10130
- stage.toBlob({
10131
- x: area.x,
10132
- y: area.y,
10133
- width: area.width,
10134
- height: area.height,
10135
- mimeType: format,
10136
- pixelRatio,
10137
- quality: options.quality ?? 1,
10138
- callback: (blob) => {
10139
- background.destroy();
10140
- stage.position(originalPosition);
10141
- stage.scale(originalScale);
10142
- stage.batchDraw();
10143
- if (nodesSelectionPluginPrev) this.getNodesSelectionPlugin()?.enable();
10144
- if (nodesStageGridPluginPrev) this.getStageGridPlugin()?.enable();
10145
- if (!blob) {
10146
- (0, import_reject.default)(new Error("Failed to generate image blob"));
10147
- return;
9997
+ const { format = WEAVE_EXPORT_FORMATS.PNG } = options;
9998
+ const { stage, mainLayer, originalScale: { scaleX, scaleY } } = this.cloneStageForExport();
9999
+ if (mainLayer) {
10000
+ const { pixelRatio: finalPixelRatio } = this.setupForExport({
10001
+ nodes: [],
10002
+ bounds: area,
10003
+ stage,
10004
+ mainLayer,
10005
+ scaleX,
10006
+ scaleY,
10007
+ options,
10008
+ exportArea: true
10009
+ });
10010
+ stage.toBlob({
10011
+ x: area.x,
10012
+ y: area.y,
10013
+ width: area.width,
10014
+ height: area.height,
10015
+ mimeType: format,
10016
+ pixelRatio: finalPixelRatio,
10017
+ quality: options.quality ?? 1,
10018
+ callback: (blob) => {
10019
+ stage.destroy();
10020
+ if (!blob) {
10021
+ (0, import_reject.default)(new Error("Failed to generate image blob"));
10022
+ return;
10023
+ }
10024
+ resolve(blob);
10148
10025
  }
10149
- resolve(blob);
10150
- }
10151
- });
10026
+ });
10027
+ }
10152
10028
  });
10153
10029
  }
10154
10030
  exportAreaAsCanvas(area, options) {
10155
10031
  return new Promise((resolve) => {
10156
- const { format = WEAVE_EXPORT_FORMATS.PNG, padding = 0, pixelRatio = 1, backgroundColor = WEAVE_EXPORT_BACKGROUND_COLOR } = options;
10157
- const nodesSelectionPluginPrev = this.getNodesSelectionPlugin()?.isEnabled();
10158
- const nodesStageGridPluginPrev = this.getStageGridPlugin()?.isEnabled();
10159
- this.getNodesSelectionPlugin()?.disable();
10160
- this.getStageGridPlugin()?.disable();
10161
- const stage = this.instance.getStage();
10162
- const mainLayer = this.instance.getMainLayer();
10163
- if (!mainLayer) throw new Error("Main layer not found");
10164
- const originalPosition = {
10165
- x: stage.x(),
10166
- y: stage.y()
10167
- };
10168
- const originalScale = {
10169
- x: stage.scaleX(),
10170
- y: stage.scaleY()
10171
- };
10172
- stage.scale({
10173
- x: 1,
10174
- y: 1
10175
- });
10176
- stage.position({
10177
- x: 0,
10178
- y: 0
10179
- });
10180
- const bounds = area;
10181
- const background = new Konva.Rect({
10182
- x: bounds.x - padding,
10183
- y: bounds.y - padding,
10184
- width: bounds.width + 2 * padding,
10185
- height: bounds.height + 2 * padding,
10186
- strokeWidth: 0,
10187
- fill: backgroundColor
10188
- });
10189
- mainLayer.add(background);
10190
- background.moveToBottom();
10191
- stage.batchDraw();
10192
- stage.toCanvas({
10193
- x: area.x,
10194
- y: area.y,
10195
- width: area.width,
10196
- height: area.height,
10197
- mimeType: format,
10198
- pixelRatio,
10199
- quality: options.quality ?? 1,
10200
- callback: (canvas) => {
10201
- background.destroy();
10202
- stage.position(originalPosition);
10203
- stage.scale(originalScale);
10204
- stage.batchDraw();
10205
- if (nodesSelectionPluginPrev) this.getNodesSelectionPlugin()?.enable();
10206
- if (nodesStageGridPluginPrev) this.getStageGridPlugin()?.enable();
10207
- resolve(canvas);
10208
- }
10209
- });
10032
+ const { format = WEAVE_EXPORT_FORMATS.PNG } = options;
10033
+ const { stage, mainLayer, originalScale: { scaleX, scaleY } } = this.cloneStageForExport();
10034
+ if (mainLayer) {
10035
+ const { pixelRatio: finalPixelRatio } = this.setupForExport({
10036
+ nodes: [],
10037
+ bounds: area,
10038
+ stage,
10039
+ mainLayer,
10040
+ scaleX,
10041
+ scaleY,
10042
+ options,
10043
+ exportArea: true
10044
+ });
10045
+ stage.toCanvas({
10046
+ x: area.x,
10047
+ y: area.y,
10048
+ width: area.width,
10049
+ height: area.height,
10050
+ mimeType: format,
10051
+ pixelRatio: finalPixelRatio,
10052
+ quality: options.quality ?? 1,
10053
+ callback: (canvas) => {
10054
+ stage.destroy();
10055
+ resolve(canvas);
10056
+ }
10057
+ });
10058
+ }
10210
10059
  });
10211
10060
  }
10212
10061
  async exportNodesServerSide(nodes, boundingNodes, options) {