@inditextech/weave-sdk 3.5.0 → 3.6.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.js +164 -5
- package/dist/sdk.node.js +164 -5
- package/dist/types.d.ts +46 -26
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +164 -5
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
package/dist/sdk.js
CHANGED
|
@@ -21978,7 +21978,7 @@ var WeaveRegisterManager = class {
|
|
|
21978
21978
|
|
|
21979
21979
|
//#endregion
|
|
21980
21980
|
//#region package.json
|
|
21981
|
-
var version = "3.
|
|
21981
|
+
var version = "3.6.0";
|
|
21982
21982
|
|
|
21983
21983
|
//#endregion
|
|
21984
21984
|
//#region src/managers/setup.ts
|
|
@@ -22227,6 +22227,10 @@ var WeaveExportManager = class {
|
|
|
22227
22227
|
exportNodesAsImage(nodes, boundingNodes, options) {
|
|
22228
22228
|
return new Promise((resolve) => {
|
|
22229
22229
|
const { format = WEAVE_EXPORT_FORMATS.PNG, padding = 0, pixelRatio = 1, backgroundColor = WEAVE_EXPORT_BACKGROUND_COLOR } = options;
|
|
22230
|
+
const nodesSelectionPluginPrev = this.getNodesSelectionPlugin()?.isEnabled();
|
|
22231
|
+
const nodesDistanceSnappingPluginPrev = this.getNodesDistanceSnappingPlugin()?.isEnabled();
|
|
22232
|
+
const nodesEdgeSnappingPluginPrev = this.getNodesDistanceSnappingPlugin()?.isEnabled();
|
|
22233
|
+
const nodesStageGridPluginPrev = this.getStageGridPlugin()?.isEnabled();
|
|
22230
22234
|
this.getNodesSelectionPlugin()?.disable();
|
|
22231
22235
|
this.getNodesDistanceSnappingPlugin()?.disable();
|
|
22232
22236
|
this.getNodesEdgeSnappingPlugin()?.disable();
|
|
@@ -22291,16 +22295,80 @@ var WeaveExportManager = class {
|
|
|
22291
22295
|
stage.position(originalPosition);
|
|
22292
22296
|
stage.scale(originalScale);
|
|
22293
22297
|
stage.batchDraw();
|
|
22294
|
-
this.getNodesSelectionPlugin()?.enable();
|
|
22295
|
-
this.getNodesDistanceSnappingPlugin()?.enable();
|
|
22296
|
-
this.getNodesEdgeSnappingPlugin()?.enable();
|
|
22297
|
-
this.getStageGridPlugin()?.enable();
|
|
22298
|
+
if (nodesSelectionPluginPrev) this.getNodesSelectionPlugin()?.enable();
|
|
22299
|
+
if (nodesDistanceSnappingPluginPrev) this.getNodesDistanceSnappingPlugin()?.enable();
|
|
22300
|
+
if (nodesEdgeSnappingPluginPrev) this.getNodesEdgeSnappingPlugin()?.enable();
|
|
22301
|
+
if (nodesStageGridPluginPrev) this.getStageGridPlugin()?.enable();
|
|
22298
22302
|
resolve(img);
|
|
22299
22303
|
}
|
|
22300
22304
|
});
|
|
22301
22305
|
}
|
|
22302
22306
|
});
|
|
22303
22307
|
}
|
|
22308
|
+
exportAreaAsImage(area, options) {
|
|
22309
|
+
return new Promise((resolve) => {
|
|
22310
|
+
const { format = WEAVE_EXPORT_FORMATS.PNG, padding = 0, pixelRatio = 1, backgroundColor = WEAVE_EXPORT_BACKGROUND_COLOR } = options;
|
|
22311
|
+
const nodesSelectionPluginPrev = this.getNodesSelectionPlugin()?.isEnabled();
|
|
22312
|
+
const nodesDistanceSnappingPluginPrev = this.getNodesDistanceSnappingPlugin()?.isEnabled();
|
|
22313
|
+
const nodesEdgeSnappingPluginPrev = this.getNodesDistanceSnappingPlugin()?.isEnabled();
|
|
22314
|
+
const nodesStageGridPluginPrev = this.getStageGridPlugin()?.isEnabled();
|
|
22315
|
+
this.getNodesSelectionPlugin()?.disable();
|
|
22316
|
+
this.getNodesDistanceSnappingPlugin()?.disable();
|
|
22317
|
+
this.getNodesEdgeSnappingPlugin()?.disable();
|
|
22318
|
+
this.getStageGridPlugin()?.disable();
|
|
22319
|
+
const stage = this.instance.getStage();
|
|
22320
|
+
const mainLayer = this.instance.getMainLayer();
|
|
22321
|
+
if (!mainLayer) throw new Error("Main layer not found");
|
|
22322
|
+
const originalPosition = {
|
|
22323
|
+
x: stage.x(),
|
|
22324
|
+
y: stage.y()
|
|
22325
|
+
};
|
|
22326
|
+
const originalScale = {
|
|
22327
|
+
x: stage.scaleX(),
|
|
22328
|
+
y: stage.scaleY()
|
|
22329
|
+
};
|
|
22330
|
+
stage.scale({
|
|
22331
|
+
x: 1,
|
|
22332
|
+
y: 1
|
|
22333
|
+
});
|
|
22334
|
+
stage.position({
|
|
22335
|
+
x: 0,
|
|
22336
|
+
y: 0
|
|
22337
|
+
});
|
|
22338
|
+
const bounds = area;
|
|
22339
|
+
const background = new Konva.Rect({
|
|
22340
|
+
x: bounds.x - padding,
|
|
22341
|
+
y: bounds.y - padding,
|
|
22342
|
+
width: bounds.width + 2 * padding,
|
|
22343
|
+
height: bounds.height + 2 * padding,
|
|
22344
|
+
strokeWidth: 0,
|
|
22345
|
+
fill: backgroundColor
|
|
22346
|
+
});
|
|
22347
|
+
mainLayer.add(background);
|
|
22348
|
+
background.moveToBottom();
|
|
22349
|
+
stage.batchDraw();
|
|
22350
|
+
stage.toImage({
|
|
22351
|
+
x: area.x,
|
|
22352
|
+
y: area.y,
|
|
22353
|
+
width: area.width,
|
|
22354
|
+
height: area.height,
|
|
22355
|
+
mimeType: format,
|
|
22356
|
+
pixelRatio,
|
|
22357
|
+
quality: options.quality ?? 1,
|
|
22358
|
+
callback: (img) => {
|
|
22359
|
+
background.destroy();
|
|
22360
|
+
stage.position(originalPosition);
|
|
22361
|
+
stage.scale(originalScale);
|
|
22362
|
+
stage.batchDraw();
|
|
22363
|
+
if (nodesSelectionPluginPrev) this.getNodesSelectionPlugin()?.enable();
|
|
22364
|
+
if (nodesDistanceSnappingPluginPrev) this.getNodesDistanceSnappingPlugin()?.enable();
|
|
22365
|
+
if (nodesEdgeSnappingPluginPrev) this.getNodesEdgeSnappingPlugin()?.enable();
|
|
22366
|
+
if (nodesStageGridPluginPrev) this.getStageGridPlugin()?.enable();
|
|
22367
|
+
resolve(img);
|
|
22368
|
+
}
|
|
22369
|
+
});
|
|
22370
|
+
});
|
|
22371
|
+
}
|
|
22304
22372
|
async exportNodesServerSide(nodes, boundingNodes, options) {
|
|
22305
22373
|
const { format = WEAVE_EXPORT_FORMATS.PNG, padding = 0, pixelRatio = 1, backgroundColor = WEAVE_EXPORT_BACKGROUND_COLOR } = options;
|
|
22306
22374
|
this.getNodesSelectionPlugin()?.disable();
|
|
@@ -22403,6 +22471,91 @@ var WeaveExportManager = class {
|
|
|
22403
22471
|
height: imageHeight * pixelRatio
|
|
22404
22472
|
};
|
|
22405
22473
|
}
|
|
22474
|
+
async exportAreaServerSide(area, options) {
|
|
22475
|
+
const { format = WEAVE_EXPORT_FORMATS.PNG, padding = 0, pixelRatio = 1, backgroundColor = WEAVE_EXPORT_BACKGROUND_COLOR } = options;
|
|
22476
|
+
this.getNodesSelectionPlugin()?.disable();
|
|
22477
|
+
this.getNodesDistanceSnappingPlugin()?.disable();
|
|
22478
|
+
this.getNodesEdgeSnappingPlugin()?.disable();
|
|
22479
|
+
this.getStageGridPlugin()?.disable();
|
|
22480
|
+
const stage = this.instance.getStage();
|
|
22481
|
+
const mainLayer = this.instance.getMainLayer();
|
|
22482
|
+
if (!mainLayer) throw new Error("Main layer not found");
|
|
22483
|
+
const originalPosition = {
|
|
22484
|
+
x: stage.x(),
|
|
22485
|
+
y: stage.y()
|
|
22486
|
+
};
|
|
22487
|
+
const originalScale = {
|
|
22488
|
+
x: stage.scaleX(),
|
|
22489
|
+
y: stage.scaleY()
|
|
22490
|
+
};
|
|
22491
|
+
stage.scale({
|
|
22492
|
+
x: 1,
|
|
22493
|
+
y: 1
|
|
22494
|
+
});
|
|
22495
|
+
const bounds = area;
|
|
22496
|
+
const scaleX = stage.scaleX();
|
|
22497
|
+
const scaleY = stage.scaleY();
|
|
22498
|
+
const unscaledBounds = {
|
|
22499
|
+
x: bounds.x / scaleX,
|
|
22500
|
+
y: bounds.y / scaleY,
|
|
22501
|
+
width: bounds.width / scaleX,
|
|
22502
|
+
height: bounds.height / scaleY
|
|
22503
|
+
};
|
|
22504
|
+
const background = new Konva.Rect({
|
|
22505
|
+
x: unscaledBounds.x - padding,
|
|
22506
|
+
y: unscaledBounds.y - padding,
|
|
22507
|
+
width: unscaledBounds.width + 2 * padding,
|
|
22508
|
+
height: unscaledBounds.height + 2 * padding,
|
|
22509
|
+
strokeWidth: 0,
|
|
22510
|
+
fill: backgroundColor
|
|
22511
|
+
});
|
|
22512
|
+
mainLayer.add(background);
|
|
22513
|
+
background.moveToBottom();
|
|
22514
|
+
const backgroundRect = background.getClientRect({ relativeTo: stage });
|
|
22515
|
+
const composites = [];
|
|
22516
|
+
const imageWidth = Math.round(backgroundRect.width);
|
|
22517
|
+
const imageHeight = Math.round(backgroundRect.height);
|
|
22518
|
+
const maxRenderSize = 1920;
|
|
22519
|
+
const cols = Math.ceil(imageWidth / maxRenderSize);
|
|
22520
|
+
const rows = Math.ceil(imageHeight / maxRenderSize);
|
|
22521
|
+
const tileWidth = Math.floor(imageWidth / cols);
|
|
22522
|
+
const tileHeight = Math.floor(imageHeight / rows);
|
|
22523
|
+
for (let y = 0; y < imageHeight; y += tileHeight) for (let x = 0; x < imageWidth; x += tileWidth) {
|
|
22524
|
+
const width = Math.min(tileWidth, imageWidth - x);
|
|
22525
|
+
const height = Math.min(tileHeight, imageHeight - y);
|
|
22526
|
+
const canvas = await mainLayer.toCanvas({
|
|
22527
|
+
x: Math.round(backgroundRect.x) + x,
|
|
22528
|
+
y: Math.round(backgroundRect.y) + y,
|
|
22529
|
+
width,
|
|
22530
|
+
height,
|
|
22531
|
+
mimeType: format,
|
|
22532
|
+
pixelRatio,
|
|
22533
|
+
quality: options.quality ?? 1
|
|
22534
|
+
});
|
|
22535
|
+
let buffer = null;
|
|
22536
|
+
if (globalThis._weave_serverSideBackend === WEAVE_KONVA_BACKEND.CANVAS) buffer = canvas.toBuffer();
|
|
22537
|
+
if (globalThis._weave_serverSideBackend === WEAVE_KONVA_BACKEND.SKIA) buffer = await canvas.toBuffer();
|
|
22538
|
+
if (!buffer) throw new Error("Failed to generate image buffer");
|
|
22539
|
+
composites.push({
|
|
22540
|
+
top: y * pixelRatio,
|
|
22541
|
+
left: x * pixelRatio,
|
|
22542
|
+
input: buffer
|
|
22543
|
+
});
|
|
22544
|
+
}
|
|
22545
|
+
background.destroy();
|
|
22546
|
+
stage.position(originalPosition);
|
|
22547
|
+
stage.scale(originalScale);
|
|
22548
|
+
stage.batchDraw();
|
|
22549
|
+
this.getNodesSelectionPlugin()?.enable();
|
|
22550
|
+
this.getNodesDistanceSnappingPlugin()?.enable();
|
|
22551
|
+
this.getNodesEdgeSnappingPlugin()?.enable();
|
|
22552
|
+
this.getStageGridPlugin()?.enable();
|
|
22553
|
+
return {
|
|
22554
|
+
composites,
|
|
22555
|
+
width: imageWidth * pixelRatio,
|
|
22556
|
+
height: imageHeight * pixelRatio
|
|
22557
|
+
};
|
|
22558
|
+
}
|
|
22406
22559
|
imageToBase64(img, mimeType) {
|
|
22407
22560
|
if (img.naturalWidth === 0 && img.naturalHeight === 0) throw new Error("Image has no content");
|
|
22408
22561
|
const canvas = document.createElement("canvas");
|
|
@@ -23440,9 +23593,15 @@ var Weave = class {
|
|
|
23440
23593
|
async exportNodesServerSide(nodes, boundingNodes, options) {
|
|
23441
23594
|
return await this.exportManager.exportNodesServerSide(nodes, boundingNodes, options);
|
|
23442
23595
|
}
|
|
23596
|
+
async exportAreaServerSide(area, options) {
|
|
23597
|
+
return await this.exportManager.exportAreaServerSide(area, options);
|
|
23598
|
+
}
|
|
23443
23599
|
async exportNodes(nodes, boundingNodes, options) {
|
|
23444
23600
|
return await this.exportManager.exportNodesAsImage(nodes, boundingNodes, options);
|
|
23445
23601
|
}
|
|
23602
|
+
async exportArea(area, options) {
|
|
23603
|
+
return await this.exportManager.exportAreaAsImage(area, options);
|
|
23604
|
+
}
|
|
23446
23605
|
getExportBoundingBox(nodesIds) {
|
|
23447
23606
|
const nodes = [];
|
|
23448
23607
|
for (const nodeId of nodesIds) {
|
package/dist/sdk.node.js
CHANGED
|
@@ -21977,7 +21977,7 @@ var WeaveRegisterManager = class {
|
|
|
21977
21977
|
|
|
21978
21978
|
//#endregion
|
|
21979
21979
|
//#region package.json
|
|
21980
|
-
var version = "3.
|
|
21980
|
+
var version = "3.6.0";
|
|
21981
21981
|
|
|
21982
21982
|
//#endregion
|
|
21983
21983
|
//#region src/managers/setup.ts
|
|
@@ -22226,6 +22226,10 @@ var WeaveExportManager = class {
|
|
|
22226
22226
|
exportNodesAsImage(nodes, boundingNodes, options) {
|
|
22227
22227
|
return new Promise((resolve) => {
|
|
22228
22228
|
const { format = WEAVE_EXPORT_FORMATS.PNG, padding = 0, pixelRatio = 1, backgroundColor = WEAVE_EXPORT_BACKGROUND_COLOR } = options;
|
|
22229
|
+
const nodesSelectionPluginPrev = this.getNodesSelectionPlugin()?.isEnabled();
|
|
22230
|
+
const nodesDistanceSnappingPluginPrev = this.getNodesDistanceSnappingPlugin()?.isEnabled();
|
|
22231
|
+
const nodesEdgeSnappingPluginPrev = this.getNodesDistanceSnappingPlugin()?.isEnabled();
|
|
22232
|
+
const nodesStageGridPluginPrev = this.getStageGridPlugin()?.isEnabled();
|
|
22229
22233
|
this.getNodesSelectionPlugin()?.disable();
|
|
22230
22234
|
this.getNodesDistanceSnappingPlugin()?.disable();
|
|
22231
22235
|
this.getNodesEdgeSnappingPlugin()?.disable();
|
|
@@ -22290,16 +22294,80 @@ var WeaveExportManager = class {
|
|
|
22290
22294
|
stage.position(originalPosition);
|
|
22291
22295
|
stage.scale(originalScale);
|
|
22292
22296
|
stage.batchDraw();
|
|
22293
|
-
this.getNodesSelectionPlugin()?.enable();
|
|
22294
|
-
this.getNodesDistanceSnappingPlugin()?.enable();
|
|
22295
|
-
this.getNodesEdgeSnappingPlugin()?.enable();
|
|
22296
|
-
this.getStageGridPlugin()?.enable();
|
|
22297
|
+
if (nodesSelectionPluginPrev) this.getNodesSelectionPlugin()?.enable();
|
|
22298
|
+
if (nodesDistanceSnappingPluginPrev) this.getNodesDistanceSnappingPlugin()?.enable();
|
|
22299
|
+
if (nodesEdgeSnappingPluginPrev) this.getNodesEdgeSnappingPlugin()?.enable();
|
|
22300
|
+
if (nodesStageGridPluginPrev) this.getStageGridPlugin()?.enable();
|
|
22297
22301
|
resolve(img);
|
|
22298
22302
|
}
|
|
22299
22303
|
});
|
|
22300
22304
|
}
|
|
22301
22305
|
});
|
|
22302
22306
|
}
|
|
22307
|
+
exportAreaAsImage(area, options) {
|
|
22308
|
+
return new Promise((resolve) => {
|
|
22309
|
+
const { format = WEAVE_EXPORT_FORMATS.PNG, padding = 0, pixelRatio = 1, backgroundColor = WEAVE_EXPORT_BACKGROUND_COLOR } = options;
|
|
22310
|
+
const nodesSelectionPluginPrev = this.getNodesSelectionPlugin()?.isEnabled();
|
|
22311
|
+
const nodesDistanceSnappingPluginPrev = this.getNodesDistanceSnappingPlugin()?.isEnabled();
|
|
22312
|
+
const nodesEdgeSnappingPluginPrev = this.getNodesDistanceSnappingPlugin()?.isEnabled();
|
|
22313
|
+
const nodesStageGridPluginPrev = this.getStageGridPlugin()?.isEnabled();
|
|
22314
|
+
this.getNodesSelectionPlugin()?.disable();
|
|
22315
|
+
this.getNodesDistanceSnappingPlugin()?.disable();
|
|
22316
|
+
this.getNodesEdgeSnappingPlugin()?.disable();
|
|
22317
|
+
this.getStageGridPlugin()?.disable();
|
|
22318
|
+
const stage = this.instance.getStage();
|
|
22319
|
+
const mainLayer = this.instance.getMainLayer();
|
|
22320
|
+
if (!mainLayer) throw new Error("Main layer not found");
|
|
22321
|
+
const originalPosition = {
|
|
22322
|
+
x: stage.x(),
|
|
22323
|
+
y: stage.y()
|
|
22324
|
+
};
|
|
22325
|
+
const originalScale = {
|
|
22326
|
+
x: stage.scaleX(),
|
|
22327
|
+
y: stage.scaleY()
|
|
22328
|
+
};
|
|
22329
|
+
stage.scale({
|
|
22330
|
+
x: 1,
|
|
22331
|
+
y: 1
|
|
22332
|
+
});
|
|
22333
|
+
stage.position({
|
|
22334
|
+
x: 0,
|
|
22335
|
+
y: 0
|
|
22336
|
+
});
|
|
22337
|
+
const bounds = area;
|
|
22338
|
+
const background = new Konva.Rect({
|
|
22339
|
+
x: bounds.x - padding,
|
|
22340
|
+
y: bounds.y - padding,
|
|
22341
|
+
width: bounds.width + 2 * padding,
|
|
22342
|
+
height: bounds.height + 2 * padding,
|
|
22343
|
+
strokeWidth: 0,
|
|
22344
|
+
fill: backgroundColor
|
|
22345
|
+
});
|
|
22346
|
+
mainLayer.add(background);
|
|
22347
|
+
background.moveToBottom();
|
|
22348
|
+
stage.batchDraw();
|
|
22349
|
+
stage.toImage({
|
|
22350
|
+
x: area.x,
|
|
22351
|
+
y: area.y,
|
|
22352
|
+
width: area.width,
|
|
22353
|
+
height: area.height,
|
|
22354
|
+
mimeType: format,
|
|
22355
|
+
pixelRatio,
|
|
22356
|
+
quality: options.quality ?? 1,
|
|
22357
|
+
callback: (img) => {
|
|
22358
|
+
background.destroy();
|
|
22359
|
+
stage.position(originalPosition);
|
|
22360
|
+
stage.scale(originalScale);
|
|
22361
|
+
stage.batchDraw();
|
|
22362
|
+
if (nodesSelectionPluginPrev) this.getNodesSelectionPlugin()?.enable();
|
|
22363
|
+
if (nodesDistanceSnappingPluginPrev) this.getNodesDistanceSnappingPlugin()?.enable();
|
|
22364
|
+
if (nodesEdgeSnappingPluginPrev) this.getNodesEdgeSnappingPlugin()?.enable();
|
|
22365
|
+
if (nodesStageGridPluginPrev) this.getStageGridPlugin()?.enable();
|
|
22366
|
+
resolve(img);
|
|
22367
|
+
}
|
|
22368
|
+
});
|
|
22369
|
+
});
|
|
22370
|
+
}
|
|
22303
22371
|
async exportNodesServerSide(nodes, boundingNodes, options) {
|
|
22304
22372
|
const { format = WEAVE_EXPORT_FORMATS.PNG, padding = 0, pixelRatio = 1, backgroundColor = WEAVE_EXPORT_BACKGROUND_COLOR } = options;
|
|
22305
22373
|
this.getNodesSelectionPlugin()?.disable();
|
|
@@ -22402,6 +22470,91 @@ var WeaveExportManager = class {
|
|
|
22402
22470
|
height: imageHeight * pixelRatio
|
|
22403
22471
|
};
|
|
22404
22472
|
}
|
|
22473
|
+
async exportAreaServerSide(area, options) {
|
|
22474
|
+
const { format = WEAVE_EXPORT_FORMATS.PNG, padding = 0, pixelRatio = 1, backgroundColor = WEAVE_EXPORT_BACKGROUND_COLOR } = options;
|
|
22475
|
+
this.getNodesSelectionPlugin()?.disable();
|
|
22476
|
+
this.getNodesDistanceSnappingPlugin()?.disable();
|
|
22477
|
+
this.getNodesEdgeSnappingPlugin()?.disable();
|
|
22478
|
+
this.getStageGridPlugin()?.disable();
|
|
22479
|
+
const stage = this.instance.getStage();
|
|
22480
|
+
const mainLayer = this.instance.getMainLayer();
|
|
22481
|
+
if (!mainLayer) throw new Error("Main layer not found");
|
|
22482
|
+
const originalPosition = {
|
|
22483
|
+
x: stage.x(),
|
|
22484
|
+
y: stage.y()
|
|
22485
|
+
};
|
|
22486
|
+
const originalScale = {
|
|
22487
|
+
x: stage.scaleX(),
|
|
22488
|
+
y: stage.scaleY()
|
|
22489
|
+
};
|
|
22490
|
+
stage.scale({
|
|
22491
|
+
x: 1,
|
|
22492
|
+
y: 1
|
|
22493
|
+
});
|
|
22494
|
+
const bounds = area;
|
|
22495
|
+
const scaleX = stage.scaleX();
|
|
22496
|
+
const scaleY = stage.scaleY();
|
|
22497
|
+
const unscaledBounds = {
|
|
22498
|
+
x: bounds.x / scaleX,
|
|
22499
|
+
y: bounds.y / scaleY,
|
|
22500
|
+
width: bounds.width / scaleX,
|
|
22501
|
+
height: bounds.height / scaleY
|
|
22502
|
+
};
|
|
22503
|
+
const background = new Konva.Rect({
|
|
22504
|
+
x: unscaledBounds.x - padding,
|
|
22505
|
+
y: unscaledBounds.y - padding,
|
|
22506
|
+
width: unscaledBounds.width + 2 * padding,
|
|
22507
|
+
height: unscaledBounds.height + 2 * padding,
|
|
22508
|
+
strokeWidth: 0,
|
|
22509
|
+
fill: backgroundColor
|
|
22510
|
+
});
|
|
22511
|
+
mainLayer.add(background);
|
|
22512
|
+
background.moveToBottom();
|
|
22513
|
+
const backgroundRect = background.getClientRect({ relativeTo: stage });
|
|
22514
|
+
const composites = [];
|
|
22515
|
+
const imageWidth = Math.round(backgroundRect.width);
|
|
22516
|
+
const imageHeight = Math.round(backgroundRect.height);
|
|
22517
|
+
const maxRenderSize = 1920;
|
|
22518
|
+
const cols = Math.ceil(imageWidth / maxRenderSize);
|
|
22519
|
+
const rows = Math.ceil(imageHeight / maxRenderSize);
|
|
22520
|
+
const tileWidth = Math.floor(imageWidth / cols);
|
|
22521
|
+
const tileHeight = Math.floor(imageHeight / rows);
|
|
22522
|
+
for (let y = 0; y < imageHeight; y += tileHeight) for (let x = 0; x < imageWidth; x += tileWidth) {
|
|
22523
|
+
const width = Math.min(tileWidth, imageWidth - x);
|
|
22524
|
+
const height = Math.min(tileHeight, imageHeight - y);
|
|
22525
|
+
const canvas = await mainLayer.toCanvas({
|
|
22526
|
+
x: Math.round(backgroundRect.x) + x,
|
|
22527
|
+
y: Math.round(backgroundRect.y) + y,
|
|
22528
|
+
width,
|
|
22529
|
+
height,
|
|
22530
|
+
mimeType: format,
|
|
22531
|
+
pixelRatio,
|
|
22532
|
+
quality: options.quality ?? 1
|
|
22533
|
+
});
|
|
22534
|
+
let buffer = null;
|
|
22535
|
+
if (globalThis._weave_serverSideBackend === WEAVE_KONVA_BACKEND.CANVAS) buffer = canvas.toBuffer();
|
|
22536
|
+
if (globalThis._weave_serverSideBackend === WEAVE_KONVA_BACKEND.SKIA) buffer = await canvas.toBuffer();
|
|
22537
|
+
if (!buffer) throw new Error("Failed to generate image buffer");
|
|
22538
|
+
composites.push({
|
|
22539
|
+
top: y * pixelRatio,
|
|
22540
|
+
left: x * pixelRatio,
|
|
22541
|
+
input: buffer
|
|
22542
|
+
});
|
|
22543
|
+
}
|
|
22544
|
+
background.destroy();
|
|
22545
|
+
stage.position(originalPosition);
|
|
22546
|
+
stage.scale(originalScale);
|
|
22547
|
+
stage.batchDraw();
|
|
22548
|
+
this.getNodesSelectionPlugin()?.enable();
|
|
22549
|
+
this.getNodesDistanceSnappingPlugin()?.enable();
|
|
22550
|
+
this.getNodesEdgeSnappingPlugin()?.enable();
|
|
22551
|
+
this.getStageGridPlugin()?.enable();
|
|
22552
|
+
return {
|
|
22553
|
+
composites,
|
|
22554
|
+
width: imageWidth * pixelRatio,
|
|
22555
|
+
height: imageHeight * pixelRatio
|
|
22556
|
+
};
|
|
22557
|
+
}
|
|
22405
22558
|
imageToBase64(img, mimeType) {
|
|
22406
22559
|
if (img.naturalWidth === 0 && img.naturalHeight === 0) throw new Error("Image has no content");
|
|
22407
22560
|
const canvas = document.createElement("canvas");
|
|
@@ -23439,9 +23592,15 @@ var Weave = class {
|
|
|
23439
23592
|
async exportNodesServerSide(nodes, boundingNodes, options) {
|
|
23440
23593
|
return await this.exportManager.exportNodesServerSide(nodes, boundingNodes, options);
|
|
23441
23594
|
}
|
|
23595
|
+
async exportAreaServerSide(area, options) {
|
|
23596
|
+
return await this.exportManager.exportAreaServerSide(area, options);
|
|
23597
|
+
}
|
|
23442
23598
|
async exportNodes(nodes, boundingNodes, options) {
|
|
23443
23599
|
return await this.exportManager.exportNodesAsImage(nodes, boundingNodes, options);
|
|
23444
23600
|
}
|
|
23601
|
+
async exportArea(area, options) {
|
|
23602
|
+
return await this.exportManager.exportAreaAsImage(area, options);
|
|
23603
|
+
}
|
|
23445
23604
|
getExportBoundingBox(nodesIds) {
|
|
23446
23605
|
const nodes = [];
|
|
23447
23606
|
for (const nodeId of nodesIds) {
|
package/dist/types.d.ts
CHANGED
|
@@ -4,16 +4,16 @@ import { DeepPartial, ImageCrossOrigin, MappedTypeDescription, NodeSerializable,
|
|
|
4
4
|
import * as Y$1 from "yjs";
|
|
5
5
|
import * as Y from "yjs";
|
|
6
6
|
import { Doc } from "yjs";
|
|
7
|
-
import * as
|
|
8
|
-
import * as
|
|
9
|
-
import * as
|
|
7
|
+
import * as konva_lib_types10 from "konva/lib/types";
|
|
8
|
+
import * as konva_lib_types16 from "konva/lib/types";
|
|
9
|
+
import * as konva_lib_types17 from "konva/lib/types";
|
|
10
10
|
import { Vector2d } from "konva/lib/types";
|
|
11
|
-
import * as konva_lib_Node14 from "konva/lib/Node";
|
|
12
|
-
import * as konva_lib_Node15 from "konva/lib/Node";
|
|
13
|
-
import * as konva_lib_Node16 from "konva/lib/Node";
|
|
14
|
-
import * as konva_lib_Node17 from "konva/lib/Node";
|
|
15
11
|
import * as konva_lib_Node18 from "konva/lib/Node";
|
|
16
12
|
import * as konva_lib_Node19 from "konva/lib/Node";
|
|
13
|
+
import * as konva_lib_Node20 from "konva/lib/Node";
|
|
14
|
+
import * as konva_lib_Node21 from "konva/lib/Node";
|
|
15
|
+
import * as konva_lib_Node22 from "konva/lib/Node";
|
|
16
|
+
import * as konva_lib_Node23 from "konva/lib/Node";
|
|
17
17
|
import * as konva_lib_Node0 from "konva/lib/Node";
|
|
18
18
|
import * as konva_lib_Node1 from "konva/lib/Node";
|
|
19
19
|
import * as konva_lib_Node2 from "konva/lib/Node";
|
|
@@ -21,17 +21,17 @@ import * as konva_lib_Node3 from "konva/lib/Node";
|
|
|
21
21
|
import * as konva_lib_Node5 from "konva/lib/Node";
|
|
22
22
|
import * as konva_lib_Node6 from "konva/lib/Node";
|
|
23
23
|
import { KonvaEventObject } from "konva/lib/Node";
|
|
24
|
-
import * as
|
|
25
|
-
import * as
|
|
26
|
-
import * as
|
|
27
|
-
import * as
|
|
24
|
+
import * as konva_lib_Shape11 from "konva/lib/Shape";
|
|
25
|
+
import * as konva_lib_Shape12 from "konva/lib/Shape";
|
|
26
|
+
import * as konva_lib_Group13 from "konva/lib/Group";
|
|
27
|
+
import * as konva_lib_Group8 from "konva/lib/Group";
|
|
28
28
|
import { Stage, StageConfig } from "konva/lib/Stage";
|
|
29
29
|
import * as konva_lib_shapes_Transformer4 from "konva/lib/shapes/Transformer";
|
|
30
30
|
import { TransformerConfig } from "konva/lib/shapes/Transformer";
|
|
31
|
-
import * as
|
|
32
|
-
import * as
|
|
33
|
-
import * as
|
|
34
|
-
import * as
|
|
31
|
+
import * as konva_lib_shapes_Rect7 from "konva/lib/shapes/Rect";
|
|
32
|
+
import * as konva_lib_shapes_Line14 from "konva/lib/shapes/Line";
|
|
33
|
+
import * as konva_lib_shapes_Line15 from "konva/lib/shapes/Line";
|
|
34
|
+
import * as konva_lib_Layer9 from "konva/lib/Layer";
|
|
35
35
|
|
|
36
36
|
//#region src/stores/store.d.ts
|
|
37
37
|
declare abstract class WeaveStore implements WeaveStoreBase {
|
|
@@ -613,7 +613,7 @@ declare class WeaveStagePanningPlugin extends WeavePlugin {
|
|
|
613
613
|
getNodesEdgeSnappingPlugin(): WeaveNodesEdgeSnappingPlugin | undefined;
|
|
614
614
|
getNodesDistanceSnappingPlugin(): WeaveNodesDistanceSnappingPlugin | undefined;
|
|
615
615
|
getStageGridPlugin(): WeaveStageGridPlugin | undefined;
|
|
616
|
-
getCurrentPointer():
|
|
616
|
+
getCurrentPointer(): konva_lib_types10.Vector2d | null;
|
|
617
617
|
cleanupEdgeMoveIntervals(): void;
|
|
618
618
|
enable(): void;
|
|
619
619
|
disable(): void;
|
|
@@ -647,7 +647,7 @@ declare class WeaveNodesMultiSelectionFeedbackPlugin extends WeavePlugin {
|
|
|
647
647
|
getName(): string;
|
|
648
648
|
getLayerName(): string;
|
|
649
649
|
initLayer(): void;
|
|
650
|
-
getSelectedHalos(): Record<string,
|
|
650
|
+
getSelectedHalos(): Record<string, konva_lib_shapes_Rect7.Rect>;
|
|
651
651
|
cleanupSelectedHalos(): void;
|
|
652
652
|
private getNodeRectInfo;
|
|
653
653
|
private getNodeInfo;
|
|
@@ -781,7 +781,7 @@ declare class WeaveNodesSelectionPlugin extends WeavePlugin {
|
|
|
781
781
|
getHoverTransformer(): Konva.Transformer;
|
|
782
782
|
handleBehaviors(): void;
|
|
783
783
|
setSelectedNodes(nodes: Konva.Node[]): void;
|
|
784
|
-
getSelectedNodes(): (
|
|
784
|
+
getSelectedNodes(): (konva_lib_Shape12.Shape<konva_lib_Shape11.ShapeConfig> | konva_lib_Group13.Group)[];
|
|
785
785
|
getSelectedNodesExtended(): WeaveSelection[];
|
|
786
786
|
selectAll(): void;
|
|
787
787
|
selectNone(): void;
|
|
@@ -930,7 +930,7 @@ declare class WeaveTargetingManager {
|
|
|
930
930
|
nodeIntersectsContainerElement(node: Konva.Node | Konva.Transformer, actualLayer?: Konva.Layer | Konva.Group): Konva.Node | undefined;
|
|
931
931
|
getMousePointer(point?: Konva.Vector2d): WeaveMousePointInfo;
|
|
932
932
|
getMousePointerRelativeToContainer(container: Konva.Node | Konva.Layer): WeaveMousePointInfoSimple;
|
|
933
|
-
getRealSelectedNode: (nodeTarget: Konva.Node) =>
|
|
933
|
+
getRealSelectedNode: (nodeTarget: Konva.Node) => konva_lib_Node19.Node<konva_lib_Node18.NodeConfig>;
|
|
934
934
|
}
|
|
935
935
|
|
|
936
936
|
//#endregion
|
|
@@ -949,8 +949,8 @@ declare class WeaveCloningManager {
|
|
|
949
949
|
cloneNode(targetNode: Konva.Node): Konva.Node | undefined;
|
|
950
950
|
addClone(node: Konva.Node): void;
|
|
951
951
|
removeClone(node: Konva.Node): void;
|
|
952
|
-
getClones():
|
|
953
|
-
isClone(node: Konva.Node):
|
|
952
|
+
getClones(): konva_lib_Node21.Node<konva_lib_Node20.NodeConfig>[];
|
|
953
|
+
isClone(node: Konva.Node): konva_lib_Node23.Node<konva_lib_Node22.NodeConfig> | undefined;
|
|
954
954
|
cleanupClones(): void;
|
|
955
955
|
}
|
|
956
956
|
|
|
@@ -1216,7 +1216,27 @@ declare class Weave {
|
|
|
1216
1216
|
width: number;
|
|
1217
1217
|
height: number;
|
|
1218
1218
|
}>;
|
|
1219
|
+
exportAreaServerSide(area: {
|
|
1220
|
+
x: number;
|
|
1221
|
+
y: number;
|
|
1222
|
+
width: number;
|
|
1223
|
+
height: number;
|
|
1224
|
+
}, options: WeaveExportNodesOptions): Promise<{
|
|
1225
|
+
composites: {
|
|
1226
|
+
input: Buffer;
|
|
1227
|
+
left: number;
|
|
1228
|
+
top: number;
|
|
1229
|
+
}[];
|
|
1230
|
+
width: number;
|
|
1231
|
+
height: number;
|
|
1232
|
+
}>;
|
|
1219
1233
|
exportNodes(nodes: WeaveElementInstance[], boundingNodes: (nodes: Konva.Node[]) => Konva.Node[], options: WeaveExportNodesOptions): Promise<HTMLImageElement>;
|
|
1234
|
+
exportArea(area: {
|
|
1235
|
+
x: number;
|
|
1236
|
+
y: number;
|
|
1237
|
+
width: number;
|
|
1238
|
+
height: number;
|
|
1239
|
+
}, options: WeaveExportNodesOptions): Promise<HTMLImageElement>;
|
|
1220
1240
|
getExportBoundingBox(nodesIds: string[]): {
|
|
1221
1241
|
x: number;
|
|
1222
1242
|
y: number;
|
|
@@ -2117,10 +2137,10 @@ declare class WeaveBaseLineTipManager {
|
|
|
2117
2137
|
render(instance: Konva.Group, point: WeaveStrokeSingleNodeTipSide): void;
|
|
2118
2138
|
update(instance: Konva.Group, point: WeaveStrokeSingleNodeTipSide): void;
|
|
2119
2139
|
protected getTip(instance: Konva.Group, point: WeaveStrokeSingleNodeTipSide): Konva.Node | undefined;
|
|
2120
|
-
protected getInternalLine(instance: Konva.Group):
|
|
2140
|
+
protected getInternalLine(instance: Konva.Group): konva_lib_shapes_Line15.Line<konva_lib_shapes_Line14.LineConfig> | undefined;
|
|
2121
2141
|
protected getLinePoints(instance: Konva.Group): {
|
|
2122
|
-
lineStartPoint:
|
|
2123
|
-
lineEndPoint:
|
|
2142
|
+
lineStartPoint: konva_lib_types16.Vector2d;
|
|
2143
|
+
lineEndPoint: konva_lib_types17.Vector2d;
|
|
2124
2144
|
};
|
|
2125
2145
|
}
|
|
2126
2146
|
|
|
@@ -2378,7 +2398,7 @@ declare class WeaveCommentNode<T> extends WeaveNode {
|
|
|
2378
2398
|
protected commentDomVisible: boolean;
|
|
2379
2399
|
protected showResolved: boolean;
|
|
2380
2400
|
constructor(params: WeaveCommentNodeParams<T>);
|
|
2381
|
-
onRender(props: WeaveElementAttributes):
|
|
2401
|
+
onRender(props: WeaveElementAttributes): konva_lib_Group8.Group;
|
|
2382
2402
|
onUpdate(nodeInstance: WeaveElementInstance, nextProps: WeaveElementAttributes): void;
|
|
2383
2403
|
onDestroy(nodeInstance: WeaveElementInstance): void;
|
|
2384
2404
|
private expandNode;
|
|
@@ -4831,7 +4851,7 @@ declare class WeaveCommentsRendererPlugin<T> extends WeavePlugin {
|
|
|
4831
4851
|
private initCommentsLayer;
|
|
4832
4852
|
deleteComments(): void;
|
|
4833
4853
|
render(): void;
|
|
4834
|
-
getCommentsLayer():
|
|
4854
|
+
getCommentsLayer(): konva_lib_Layer9.Layer;
|
|
4835
4855
|
enable(): void;
|
|
4836
4856
|
disable(): void;
|
|
4837
4857
|
}
|