@inditextech/weave-sdk 3.6.0 → 3.7.0-SNAPSHOT.134.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/types.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import Konva from "konva";
2
2
  import pino from "pino";
3
- import { WEAVE_ASYNC_STATUS, WEAVE_AWARENESS_LAYER_ID, WEAVE_EXPORT_BACKGROUND_COLOR, WEAVE_EXPORT_FORMATS, WEAVE_INSTANCE_STATUS, WEAVE_KONVA_BACKEND, WEAVE_LOG_LEVEL, WEAVE_NODE_CHANGE_TYPE, WEAVE_NODE_CUSTOM_EVENTS, WEAVE_NODE_LAYER_ID, WEAVE_NODE_POSITION, WEAVE_STORE_CONNECTION_STATUS, WEAVE_UTILITY_LAYER_ID } from "@inditextech/weave-types";
3
+ import { WEAVE_ASYNC_STATUS, WEAVE_AWARENESS_LAYER_ID, WEAVE_EXPORT_BACKGROUND_COLOR, WEAVE_EXPORT_FORMATS, WEAVE_EXPORT_RETURN_FORMAT, WEAVE_INSTANCE_STATUS, WEAVE_KONVA_BACKEND, WEAVE_LOG_LEVEL, WEAVE_NODE_CHANGE_TYPE, WEAVE_NODE_CUSTOM_EVENTS, WEAVE_NODE_LAYER_ID, WEAVE_NODE_POSITION, WEAVE_STORE_CONNECTION_STATUS, WEAVE_UTILITY_LAYER_ID } from "@inditextech/weave-types";
4
4
  import { getYjsDoc, getYjsValue, observeDeep, syncedStore } from "@syncedstore/core";
5
5
  import * as Y$1 from "yjs";
6
6
  import * as Y from "yjs";
@@ -15084,6 +15084,11 @@ var WeaveStore = class {
15084
15084
  getDocument() {
15085
15085
  return this.document;
15086
15086
  }
15087
+ restartDocument() {
15088
+ this.latestState = { weave: {} };
15089
+ this.state = syncedStore({ weave: {} });
15090
+ this.document = getYjsDoc(this.state);
15091
+ }
15087
15092
  loadDocument(roomData) {
15088
15093
  yjs_default.applyUpdate(this.document, roomData);
15089
15094
  }
@@ -17959,6 +17964,15 @@ var WeaveContextMenuPlugin = class extends WeavePlugin {
17959
17964
  initLayer = void 0;
17960
17965
  constructor(params) {
17961
17966
  super();
17967
+ const { config } = params ?? {};
17968
+ this.config = {
17969
+ xOffset: WEAVE_CONTEXT_MENU_X_OFFSET_DEFAULT,
17970
+ yOffset: WEAVE_CONTEXT_MENU_Y_OFFSET_DEFAULT,
17971
+ ...config
17972
+ };
17973
+ this.initialize();
17974
+ }
17975
+ initialize() {
17962
17976
  this.timer = null;
17963
17977
  this.tapHold = false;
17964
17978
  this.contextMenuVisible = false;
@@ -17968,12 +17982,6 @@ var WeaveContextMenuPlugin = class extends WeavePlugin {
17968
17982
  time: 0
17969
17983
  };
17970
17984
  this.tapHoldTimeout = WEAVE_CONTEXT_MENU_TAP_HOLD_TIMEOUT;
17971
- const { config } = params ?? {};
17972
- this.config = {
17973
- xOffset: WEAVE_CONTEXT_MENU_X_OFFSET_DEFAULT,
17974
- yOffset: WEAVE_CONTEXT_MENU_Y_OFFSET_DEFAULT,
17975
- ...config
17976
- };
17977
17985
  this.pointers = {};
17978
17986
  }
17979
17987
  getName() {
@@ -18624,7 +18632,10 @@ const DEFAULT_ADD_NODE_OPTIONS = { emitUserChangeEvent: false };
18624
18632
  const DEFAULT_UPDATE_NODE_OPTIONS = { emitUserChangeEvent: false };
18625
18633
  const DEFAULT_REMOVE_NODE_OPTIONS = { emitUserChangeEvent: false };
18626
18634
  const DEFAULT_MOVE_NODE_OPTIONS = { emitUserChangeEvent: false };
18627
- const WEAVE_DEFAULT_CONFIG = { behaviors: { axisLockThreshold: 5 } };
18635
+ const WEAVE_DEFAULT_CONFIG = {
18636
+ behaviors: { axisLockThreshold: 5 },
18637
+ performance: { upscale: { enabled: false } }
18638
+ };
18628
18639
 
18629
18640
  //#endregion
18630
18641
  //#region src/plugins/users-presence/constants.ts
@@ -18653,6 +18664,9 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
18653
18664
  constructor(params) {
18654
18665
  super();
18655
18666
  this.config = mergeExceptArrays(WEAVE_NODES_SELECTION_DEFAULT_CONFIG, params?.config ?? {});
18667
+ this.initialize();
18668
+ }
18669
+ initialize() {
18656
18670
  this.defaultEnabledAnchors = this.config.selection?.enabledAnchors ?? [
18657
18671
  "top-left",
18658
18672
  "top-center",
@@ -18816,7 +18830,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
18816
18830
  nodeHovered = void 0;
18817
18831
  }
18818
18832
  this.instance.getStage().handleMouseover?.();
18819
- });
18833
+ }, { signal: this.instance.getEventsController()?.signal });
18820
18834
  const handleTransform = (e) => {
18821
18835
  const moved = this.checkMoved(e);
18822
18836
  if (moved) this.getContextMenuPlugin()?.cancelLongPressTimer();
@@ -19222,6 +19236,10 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
19222
19236
  initEvents() {
19223
19237
  this.selecting = false;
19224
19238
  const stage = this.instance.getStage();
19239
+ window.addEventListener("blur", () => {
19240
+ this.isCtrlMetaPressed = false;
19241
+ this.isSpaceKeyPressed = false;
19242
+ }, { signal: this.instance.getEventsController()?.signal });
19225
19243
  stage.container().addEventListener("keydown", (e) => {
19226
19244
  if (e.ctrlKey || e.metaKey) this.isCtrlMetaPressed = true;
19227
19245
  if (e.code === "Space") this.isSpaceKeyPressed = true;
@@ -19231,11 +19249,11 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
19231
19249
  });
19232
19250
  return;
19233
19251
  }
19234
- });
19252
+ }, { signal: this.instance.getEventsController()?.signal });
19235
19253
  stage.container().addEventListener("keyup", (e) => {
19236
19254
  if (!(e.ctrlKey || e.metaKey)) this.isCtrlMetaPressed = false;
19237
19255
  if (e.code === "Space") this.isSpaceKeyPressed = false;
19238
- });
19256
+ }, { signal: this.instance.getEventsController()?.signal });
19239
19257
  stage.on("pointerdown", (e) => {
19240
19258
  this.setTapStart(e);
19241
19259
  this.handledClickOrTap = false;
@@ -19442,7 +19460,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
19442
19460
  if (existNode) newSelectedNodes.push(existNode);
19443
19461
  }
19444
19462
  this.tr.nodes([...newSelectedNodes]);
19445
- this.tr.forceUpdate();
19463
+ if (newSelectedNodes.length > 0) this.tr.forceUpdate();
19446
19464
  this.triggerSelectedNodesEvent();
19447
19465
  }
19448
19466
  getSelectionPlugin() {
@@ -19695,6 +19713,9 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
19695
19713
  super();
19696
19714
  this.getImageBase64 = params.getImageBase64;
19697
19715
  this.config = mergeExceptArrays(WEAVE_COPY_PASTE_CONFIG_DEFAULT, params?.config);
19716
+ this.initialize();
19717
+ }
19718
+ initialize() {
19698
19719
  this.actualInternalPaddingX = 0;
19699
19720
  this.actualInternalPaddingY = 0;
19700
19721
  this.lastInternalPasteSnapshot = "";
@@ -19800,7 +19821,7 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
19800
19821
  this.focusPasteCatcher();
19801
19822
  if (!this.enabled) return;
19802
19823
  }
19803
- });
19824
+ }, { signal: this.instance.getEventsController()?.signal });
19804
19825
  if (catcher) catcher.addEventListener("paste", async (e) => {
19805
19826
  e.preventDefault();
19806
19827
  let items = void 0;
@@ -19819,7 +19840,7 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
19819
19840
  return;
19820
19841
  }
19821
19842
  this.sendExternalPasteEvent(void 0, items);
19822
- });
19843
+ }, { signal: this.instance.getEventsController()?.signal });
19823
19844
  }
19824
19845
  sendExternalPasteEvent(dataList, items) {
19825
19846
  const stage = this.instance.getStage();
@@ -21985,11 +22006,34 @@ var WeaveRegisterManager = class {
21985
22006
  }
21986
22007
  }
21987
22008
  }
22009
+ resetNodesHandlers() {
22010
+ for (const nodeHandlerId of Object.keys(this.nodesHandlers)) {
22011
+ const nodeHandler = this.nodesHandlers[nodeHandlerId];
22012
+ nodeHandler.initialize?.();
22013
+ }
22014
+ }
22015
+ resetActionsHandlers() {
22016
+ for (const actionHandlerId of Object.keys(this.actionsHandlers)) {
22017
+ const actionHandler = this.actionsHandlers[actionHandlerId];
22018
+ actionHandler.initialize?.();
22019
+ }
22020
+ }
22021
+ resetPlugins() {
22022
+ for (const pluginId of Object.keys(this.plugins)) {
22023
+ const plugin = this.plugins[pluginId];
22024
+ plugin.initialize?.();
22025
+ }
22026
+ }
22027
+ reset() {
22028
+ this.resetNodesHandlers();
22029
+ this.resetActionsHandlers();
22030
+ this.resetPlugins();
22031
+ }
21988
22032
  };
21989
22033
 
21990
22034
  //#endregion
21991
22035
  //#region package.json
21992
- var version = "3.6.0";
22036
+ var version = "3.7.0-SNAPSHOT.134.1";
21993
22037
 
21994
22038
  //#endregion
21995
22039
  //#region src/managers/setup.ts
@@ -22106,6 +22150,11 @@ var WeaveStageManager = class {
22106
22150
  initialZIndex: void 0
22107
22151
  };
22108
22152
  const stage = new Konva.Stage({ ...props });
22153
+ if (!this.instance.isServerSide()) {
22154
+ const containerParent = stage.container().parentNode;
22155
+ stage.width(containerParent.clientWidth);
22156
+ stage.height(containerParent.clientHeight);
22157
+ }
22109
22158
  const realContainer = stage.container();
22110
22159
  if (realContainer !== void 0 && realContainer.style?.position !== "relative") realContainer.style.position = "relative";
22111
22160
  this.setStage(stage);
@@ -22316,6 +22365,172 @@ var WeaveExportManager = class {
22316
22365
  }
22317
22366
  });
22318
22367
  }
22368
+ exportNodesAsBlob(nodes, boundingNodes, options) {
22369
+ return new Promise((resolve) => {
22370
+ const { format = WEAVE_EXPORT_FORMATS.PNG, padding = 0, pixelRatio = 1, backgroundColor = WEAVE_EXPORT_BACKGROUND_COLOR } = options;
22371
+ const nodesSelectionPluginPrev = this.getNodesSelectionPlugin()?.isEnabled();
22372
+ const nodesDistanceSnappingPluginPrev = this.getNodesDistanceSnappingPlugin()?.isEnabled();
22373
+ const nodesEdgeSnappingPluginPrev = this.getNodesDistanceSnappingPlugin()?.isEnabled();
22374
+ const nodesStageGridPluginPrev = this.getStageGridPlugin()?.isEnabled();
22375
+ this.getNodesSelectionPlugin()?.disable();
22376
+ this.getNodesDistanceSnappingPlugin()?.disable();
22377
+ this.getNodesEdgeSnappingPlugin()?.disable();
22378
+ this.getStageGridPlugin()?.disable();
22379
+ const stage = this.instance.getStage();
22380
+ const mainLayer = this.instance.getMainLayer();
22381
+ const originalPosition = {
22382
+ x: stage.x(),
22383
+ y: stage.y()
22384
+ };
22385
+ const originalScale = {
22386
+ x: stage.scaleX(),
22387
+ y: stage.scaleY()
22388
+ };
22389
+ stage.scale({
22390
+ x: 1,
22391
+ y: 1
22392
+ });
22393
+ if (mainLayer) {
22394
+ const bounds = getExportBoundingBox(boundingNodes(nodes));
22395
+ const scaleX = stage.scaleX();
22396
+ const scaleY = stage.scaleY();
22397
+ const unscaledBounds = {
22398
+ x: bounds.x / scaleX,
22399
+ y: bounds.y / scaleY,
22400
+ width: bounds.width / scaleX,
22401
+ height: bounds.height / scaleY
22402
+ };
22403
+ const exportGroup = new Konva.Group();
22404
+ const background = new Konva.Rect({
22405
+ x: unscaledBounds.x - padding,
22406
+ y: unscaledBounds.y - padding,
22407
+ width: unscaledBounds.width + 2 * padding,
22408
+ height: unscaledBounds.height + 2 * padding,
22409
+ strokeWidth: 0,
22410
+ fill: backgroundColor
22411
+ });
22412
+ exportGroup.add(background);
22413
+ for (const node of nodes) {
22414
+ const clonedNode = node.clone({ id: v4_default() });
22415
+ const absPos = node.getAbsolutePosition();
22416
+ clonedNode.absolutePosition({
22417
+ x: absPos.x / scaleX,
22418
+ y: absPos.y / scaleY
22419
+ });
22420
+ exportGroup.add(clonedNode);
22421
+ }
22422
+ mainLayer.add(exportGroup);
22423
+ const backgroundRect = background.getClientRect();
22424
+ stage.batchDraw();
22425
+ const { pixelRatio: finalPixelRatio } = this.fitKonvaPixelRatio(Math.round(backgroundRect.width), Math.round(backgroundRect.height), pixelRatio);
22426
+ exportGroup.toBlob({
22427
+ x: Math.round(backgroundRect.x),
22428
+ y: Math.round(backgroundRect.y),
22429
+ width: Math.round(backgroundRect.width),
22430
+ height: Math.round(backgroundRect.height),
22431
+ mimeType: format,
22432
+ pixelRatio: finalPixelRatio,
22433
+ quality: options.quality ?? 1,
22434
+ callback: (blob) => {
22435
+ exportGroup.destroy();
22436
+ stage.position(originalPosition);
22437
+ stage.scale(originalScale);
22438
+ stage.batchDraw();
22439
+ if (nodesSelectionPluginPrev) this.getNodesSelectionPlugin()?.enable();
22440
+ if (nodesDistanceSnappingPluginPrev) this.getNodesDistanceSnappingPlugin()?.enable();
22441
+ if (nodesEdgeSnappingPluginPrev) this.getNodesEdgeSnappingPlugin()?.enable();
22442
+ if (nodesStageGridPluginPrev) this.getStageGridPlugin()?.enable();
22443
+ if (!blob) {
22444
+ (0, import_lodash.reject)(new Error("Failed to generate image blob"));
22445
+ return;
22446
+ }
22447
+ resolve(blob);
22448
+ }
22449
+ });
22450
+ }
22451
+ });
22452
+ }
22453
+ exportNodesAsCanvas(nodes, boundingNodes, options) {
22454
+ return new Promise((resolve) => {
22455
+ const { format = WEAVE_EXPORT_FORMATS.PNG, padding = 0, pixelRatio = 1, backgroundColor = WEAVE_EXPORT_BACKGROUND_COLOR } = options;
22456
+ const nodesSelectionPluginPrev = this.getNodesSelectionPlugin()?.isEnabled();
22457
+ const nodesDistanceSnappingPluginPrev = this.getNodesDistanceSnappingPlugin()?.isEnabled();
22458
+ const nodesEdgeSnappingPluginPrev = this.getNodesDistanceSnappingPlugin()?.isEnabled();
22459
+ const nodesStageGridPluginPrev = this.getStageGridPlugin()?.isEnabled();
22460
+ this.getNodesSelectionPlugin()?.disable();
22461
+ this.getNodesDistanceSnappingPlugin()?.disable();
22462
+ this.getNodesEdgeSnappingPlugin()?.disable();
22463
+ this.getStageGridPlugin()?.disable();
22464
+ const stage = this.instance.getStage();
22465
+ const mainLayer = this.instance.getMainLayer();
22466
+ const originalPosition = {
22467
+ x: stage.x(),
22468
+ y: stage.y()
22469
+ };
22470
+ const originalScale = {
22471
+ x: stage.scaleX(),
22472
+ y: stage.scaleY()
22473
+ };
22474
+ stage.scale({
22475
+ x: 1,
22476
+ y: 1
22477
+ });
22478
+ if (mainLayer) {
22479
+ const bounds = getExportBoundingBox(boundingNodes(nodes));
22480
+ const scaleX = stage.scaleX();
22481
+ const scaleY = stage.scaleY();
22482
+ const unscaledBounds = {
22483
+ x: bounds.x / scaleX,
22484
+ y: bounds.y / scaleY,
22485
+ width: bounds.width / scaleX,
22486
+ height: bounds.height / scaleY
22487
+ };
22488
+ const exportGroup = new Konva.Group();
22489
+ const background = new Konva.Rect({
22490
+ x: unscaledBounds.x - padding,
22491
+ y: unscaledBounds.y - padding,
22492
+ width: unscaledBounds.width + 2 * padding,
22493
+ height: unscaledBounds.height + 2 * padding,
22494
+ strokeWidth: 0,
22495
+ fill: backgroundColor
22496
+ });
22497
+ exportGroup.add(background);
22498
+ for (const node of nodes) {
22499
+ const clonedNode = node.clone({ id: v4_default() });
22500
+ const absPos = node.getAbsolutePosition();
22501
+ clonedNode.absolutePosition({
22502
+ x: absPos.x / scaleX,
22503
+ y: absPos.y / scaleY
22504
+ });
22505
+ exportGroup.add(clonedNode);
22506
+ }
22507
+ mainLayer.add(exportGroup);
22508
+ const backgroundRect = background.getClientRect();
22509
+ stage.batchDraw();
22510
+ const { pixelRatio: finalPixelRatio } = this.fitKonvaPixelRatio(Math.round(backgroundRect.width), Math.round(backgroundRect.height), pixelRatio);
22511
+ exportGroup.toCanvas({
22512
+ x: Math.round(backgroundRect.x),
22513
+ y: Math.round(backgroundRect.y),
22514
+ width: Math.round(backgroundRect.width),
22515
+ height: Math.round(backgroundRect.height),
22516
+ mimeType: format,
22517
+ pixelRatio: finalPixelRatio,
22518
+ quality: options.quality ?? 1,
22519
+ callback: (canvas) => {
22520
+ exportGroup.destroy();
22521
+ stage.position(originalPosition);
22522
+ stage.scale(originalScale);
22523
+ stage.batchDraw();
22524
+ if (nodesSelectionPluginPrev) this.getNodesSelectionPlugin()?.enable();
22525
+ if (nodesDistanceSnappingPluginPrev) this.getNodesDistanceSnappingPlugin()?.enable();
22526
+ if (nodesEdgeSnappingPluginPrev) this.getNodesEdgeSnappingPlugin()?.enable();
22527
+ if (nodesStageGridPluginPrev) this.getStageGridPlugin()?.enable();
22528
+ resolve(canvas);
22529
+ }
22530
+ });
22531
+ }
22532
+ });
22533
+ }
22319
22534
  exportAreaAsImage(area, options) {
22320
22535
  return new Promise((resolve) => {
22321
22536
  const { format = WEAVE_EXPORT_FORMATS.PNG, padding = 0, pixelRatio = 1, backgroundColor = WEAVE_EXPORT_BACKGROUND_COLOR } = options;
@@ -22380,6 +22595,138 @@ var WeaveExportManager = class {
22380
22595
  });
22381
22596
  });
22382
22597
  }
22598
+ exportAreaAsBlob(area, options) {
22599
+ return new Promise((resolve) => {
22600
+ const { format = WEAVE_EXPORT_FORMATS.PNG, padding = 0, pixelRatio = 1, backgroundColor = WEAVE_EXPORT_BACKGROUND_COLOR } = options;
22601
+ const nodesSelectionPluginPrev = this.getNodesSelectionPlugin()?.isEnabled();
22602
+ const nodesDistanceSnappingPluginPrev = this.getNodesDistanceSnappingPlugin()?.isEnabled();
22603
+ const nodesEdgeSnappingPluginPrev = this.getNodesDistanceSnappingPlugin()?.isEnabled();
22604
+ const nodesStageGridPluginPrev = this.getStageGridPlugin()?.isEnabled();
22605
+ this.getNodesSelectionPlugin()?.disable();
22606
+ this.getNodesDistanceSnappingPlugin()?.disable();
22607
+ this.getNodesEdgeSnappingPlugin()?.disable();
22608
+ this.getStageGridPlugin()?.disable();
22609
+ const stage = this.instance.getStage();
22610
+ const mainLayer = this.instance.getMainLayer();
22611
+ if (!mainLayer) throw new Error("Main layer not found");
22612
+ const originalPosition = {
22613
+ x: stage.x(),
22614
+ y: stage.y()
22615
+ };
22616
+ const originalScale = {
22617
+ x: stage.scaleX(),
22618
+ y: stage.scaleY()
22619
+ };
22620
+ stage.scale({
22621
+ x: 1,
22622
+ y: 1
22623
+ });
22624
+ stage.position({
22625
+ x: 0,
22626
+ y: 0
22627
+ });
22628
+ const bounds = area;
22629
+ const background = new Konva.Rect({
22630
+ x: bounds.x - padding,
22631
+ y: bounds.y - padding,
22632
+ width: bounds.width + 2 * padding,
22633
+ height: bounds.height + 2 * padding,
22634
+ strokeWidth: 0,
22635
+ fill: backgroundColor
22636
+ });
22637
+ mainLayer.add(background);
22638
+ background.moveToBottom();
22639
+ stage.batchDraw();
22640
+ stage.toBlob({
22641
+ x: area.x,
22642
+ y: area.y,
22643
+ width: area.width,
22644
+ height: area.height,
22645
+ mimeType: format,
22646
+ pixelRatio,
22647
+ quality: options.quality ?? 1,
22648
+ callback: (blob) => {
22649
+ background.destroy();
22650
+ stage.position(originalPosition);
22651
+ stage.scale(originalScale);
22652
+ stage.batchDraw();
22653
+ if (nodesSelectionPluginPrev) this.getNodesSelectionPlugin()?.enable();
22654
+ if (nodesDistanceSnappingPluginPrev) this.getNodesDistanceSnappingPlugin()?.enable();
22655
+ if (nodesEdgeSnappingPluginPrev) this.getNodesEdgeSnappingPlugin()?.enable();
22656
+ if (nodesStageGridPluginPrev) this.getStageGridPlugin()?.enable();
22657
+ if (!blob) {
22658
+ (0, import_lodash.reject)(new Error("Failed to generate image blob"));
22659
+ return;
22660
+ }
22661
+ resolve(blob);
22662
+ }
22663
+ });
22664
+ });
22665
+ }
22666
+ exportAreaAsCanvas(area, options) {
22667
+ return new Promise((resolve) => {
22668
+ const { format = WEAVE_EXPORT_FORMATS.PNG, padding = 0, pixelRatio = 1, backgroundColor = WEAVE_EXPORT_BACKGROUND_COLOR } = options;
22669
+ const nodesSelectionPluginPrev = this.getNodesSelectionPlugin()?.isEnabled();
22670
+ const nodesDistanceSnappingPluginPrev = this.getNodesDistanceSnappingPlugin()?.isEnabled();
22671
+ const nodesEdgeSnappingPluginPrev = this.getNodesDistanceSnappingPlugin()?.isEnabled();
22672
+ const nodesStageGridPluginPrev = this.getStageGridPlugin()?.isEnabled();
22673
+ this.getNodesSelectionPlugin()?.disable();
22674
+ this.getNodesDistanceSnappingPlugin()?.disable();
22675
+ this.getNodesEdgeSnappingPlugin()?.disable();
22676
+ this.getStageGridPlugin()?.disable();
22677
+ const stage = this.instance.getStage();
22678
+ const mainLayer = this.instance.getMainLayer();
22679
+ if (!mainLayer) throw new Error("Main layer not found");
22680
+ const originalPosition = {
22681
+ x: stage.x(),
22682
+ y: stage.y()
22683
+ };
22684
+ const originalScale = {
22685
+ x: stage.scaleX(),
22686
+ y: stage.scaleY()
22687
+ };
22688
+ stage.scale({
22689
+ x: 1,
22690
+ y: 1
22691
+ });
22692
+ stage.position({
22693
+ x: 0,
22694
+ y: 0
22695
+ });
22696
+ const bounds = area;
22697
+ const background = new Konva.Rect({
22698
+ x: bounds.x - padding,
22699
+ y: bounds.y - padding,
22700
+ width: bounds.width + 2 * padding,
22701
+ height: bounds.height + 2 * padding,
22702
+ strokeWidth: 0,
22703
+ fill: backgroundColor
22704
+ });
22705
+ mainLayer.add(background);
22706
+ background.moveToBottom();
22707
+ stage.batchDraw();
22708
+ stage.toCanvas({
22709
+ x: area.x,
22710
+ y: area.y,
22711
+ width: area.width,
22712
+ height: area.height,
22713
+ mimeType: format,
22714
+ pixelRatio,
22715
+ quality: options.quality ?? 1,
22716
+ callback: (canvas) => {
22717
+ background.destroy();
22718
+ stage.position(originalPosition);
22719
+ stage.scale(originalScale);
22720
+ stage.batchDraw();
22721
+ if (nodesSelectionPluginPrev) this.getNodesSelectionPlugin()?.enable();
22722
+ if (nodesDistanceSnappingPluginPrev) this.getNodesDistanceSnappingPlugin()?.enable();
22723
+ if (nodesEdgeSnappingPluginPrev) this.getNodesEdgeSnappingPlugin()?.enable();
22724
+ if (nodesStageGridPluginPrev) this.getStageGridPlugin()?.enable();
22725
+ resolve(canvas);
22726
+ }
22727
+ });
22728
+ });
22729
+ }
22383
22730
  async exportNodesServerSide(nodes, boundingNodes, options) {
22384
22731
  const { format = WEAVE_EXPORT_FORMATS.PNG, padding = 0, pixelRatio = 1, backgroundColor = WEAVE_EXPORT_BACKGROUND_COLOR } = options;
22385
22732
  this.getNodesSelectionPlugin()?.disable();
@@ -22595,6 +22942,14 @@ var WeaveExportManager = class {
22595
22942
  const snappingPlugin = this.instance.getPlugin(WEAVE_NODES_DISTANCE_SNAPPING_PLUGIN_KEY);
22596
22943
  return snappingPlugin;
22597
22944
  }
22945
+ blobToDataURL(blob) {
22946
+ return new Promise((resolve, reject) => {
22947
+ const reader = new FileReader();
22948
+ reader.onloadend = () => resolve(reader.result);
22949
+ reader.onerror = () => reject(new Error("Failed to convert blob to data URL"));
22950
+ reader.readAsDataURL(blob);
22951
+ });
22952
+ }
22598
22953
  };
22599
22954
 
22600
22955
  //#endregion
@@ -22846,7 +23201,12 @@ var WeaveAsyncManager = class {
22846
23201
  this.instance.emitEvent("onAsyncElementChange");
22847
23202
  }, new Map());
22848
23203
  }
23204
+ reset() {
23205
+ this.asyncElements.clear();
23206
+ this.asyncElementsLoadedEventEmitted = false;
23207
+ }
22849
23208
  checkForAsyncElements(elements) {
23209
+ this.instance.emitEvent("onAsyncElementsIdle");
22850
23210
  const amountAsyncResourcesExtracted = this.extractAsyncResources(elements);
22851
23211
  if (amountAsyncResourcesExtracted === 0 && !this.asyncElementsLoadedEventEmitted) {
22852
23212
  this.instance.emitEvent("onAsyncElementsLoaded");
@@ -22899,7 +23259,7 @@ var WeaveAsyncManager = class {
22899
23259
  status: WEAVE_ASYNC_STATUS.LOADING
22900
23260
  };
22901
23261
  this.asyncElements.set(nodeId, element);
22902
- this.instance.emitEvent("onAsyncElementsLoading", {
23262
+ if (!this.asyncElementsLoadedEventEmitted) this.instance.emitEvent("onAsyncElementsLoading", {
22903
23263
  loaded: this.getAmountAsyncElementsLoaded(),
22904
23264
  total: this.getAmountAsyncElements()
22905
23265
  });
@@ -22912,11 +23272,11 @@ var WeaveAsyncManager = class {
22912
23272
  status: WEAVE_ASYNC_STATUS.LOADED
22913
23273
  };
22914
23274
  this.asyncElements.set(nodeId, element);
22915
- this.instance.emitEvent("onAsyncElementsLoading", {
22916
- loaded: this.getAmountAsyncElementsLoaded(),
22917
- total: this.getAmountAsyncElements()
22918
- });
22919
23275
  if (!this.asyncElementsLoadedEventEmitted) {
23276
+ this.instance.emitEvent("onAsyncElementsLoading", {
23277
+ loaded: this.getAmountAsyncElementsLoaded(),
23278
+ total: this.getAmountAsyncElements()
23279
+ });
22920
23280
  const allLoaded = this.asyncElementsLoaded();
22921
23281
  if (allLoaded) {
22922
23282
  this.instance.emitEvent("onAsyncElementsLoaded");
@@ -23041,6 +23401,7 @@ var Weave = class {
23041
23401
  constructor(weaveConfig, stageConfig) {
23042
23402
  globalThis._weave_isServerSide = false;
23043
23403
  if (typeof window === "undefined") globalThis._weave_isServerSide = true;
23404
+ this.eventsController = void 0;
23044
23405
  this.emitter = new Emittery();
23045
23406
  Konva.showWarnings = false;
23046
23407
  this.id = v4_default();
@@ -23086,6 +23447,7 @@ var Weave = class {
23086
23447
  this.initialized = true;
23087
23448
  this.status = WEAVE_INSTANCE_STATUS.RUNNING;
23088
23449
  this.emitEvent("onInstanceStatus", this.status);
23450
+ this.emitEvent("onRender");
23089
23451
  });
23090
23452
  }
23091
23453
  setStatus(status) {
@@ -23110,6 +23472,7 @@ var Weave = class {
23110
23472
  async start() {
23111
23473
  this.moduleLogger.info("Start instance");
23112
23474
  if (!this.isServerSide()) {
23475
+ this.eventsController = new AbortController();
23113
23476
  if (!window.weave) window.weave = this;
23114
23477
  }
23115
23478
  this.emitEvent("onRoomLoaded", false);
@@ -23133,8 +23496,39 @@ var Weave = class {
23133
23496
  store.setup();
23134
23497
  store.connect();
23135
23498
  }
23499
+ async switchRoom() {
23500
+ this.moduleLogger.info(`Switching room`);
23501
+ const nodeHandlers = this.registerManager.getNodesHandlers();
23502
+ for (const nodeHandlerKey of Object.keys(nodeHandlers)) {
23503
+ const nodeHandler = nodeHandlers[nodeHandlerKey];
23504
+ nodeHandler?.onDestroyInstance();
23505
+ }
23506
+ const stage = this.getStage();
23507
+ if (stage) stage.destroy();
23508
+ if (this.eventsController) this.eventsController.abort();
23509
+ if (!this.isServerSide()) this.eventsController = new AbortController();
23510
+ this.registerManager.reset();
23511
+ this.asyncManager.reset();
23512
+ this.moduleLogger.info("Switching room instance");
23513
+ if (!this.isServerSide()) {
23514
+ if (!window.weave) window.weave = this;
23515
+ }
23516
+ this.emitEvent("onRoomLoaded", false);
23517
+ this.status = WEAVE_INSTANCE_STATUS.STARTING;
23518
+ this.emitEvent("onInstanceStatus", this.status);
23519
+ this.registerManager.reset();
23520
+ this.status = WEAVE_INSTANCE_STATUS.LOADING_FONTS;
23521
+ this.emitEvent("onInstanceStatus", this.status);
23522
+ await this.fontsManager.loadFonts();
23523
+ this.setupManager.setupLog();
23524
+ this.stageManager.initStage();
23525
+ this.status = WEAVE_INSTANCE_STATUS.CONNECTING_TO_ROOM;
23526
+ this.emitEvent("onInstanceStatus", this.status);
23527
+ this.addEventListener("onStoreConnectionStatusChange", this.handleStoreConnectionStatusChange.bind(this));
23528
+ }
23136
23529
  destroy() {
23137
23530
  this.moduleLogger.info(`Destroying the instance`);
23531
+ if (this.eventsController) this.eventsController.abort();
23138
23532
  this.emitter.clearListeners();
23139
23533
  this.status = WEAVE_INSTANCE_STATUS.IDLE;
23140
23534
  this.emitEvent("onInstanceStatus", this.status);
@@ -23607,11 +24001,27 @@ var Weave = class {
23607
24001
  async exportAreaServerSide(area, options) {
23608
24002
  return await this.exportManager.exportAreaServerSide(area, options);
23609
24003
  }
23610
- async exportNodes(nodes, boundingNodes, options) {
23611
- return await this.exportManager.exportNodesAsImage(nodes, boundingNodes, options);
24004
+ async exportNodes(nodes, boundingNodes, options, returnFormat = WEAVE_EXPORT_RETURN_FORMAT.IMAGE) {
24005
+ switch (returnFormat) {
24006
+ case WEAVE_EXPORT_RETURN_FORMAT.BLOB: return await this.exportManager.exportNodesAsBlob(nodes, boundingNodes, options);
24007
+ case WEAVE_EXPORT_RETURN_FORMAT.CANVAS: return await this.exportManager.exportNodesAsCanvas(nodes, boundingNodes, options);
24008
+ case WEAVE_EXPORT_RETURN_FORMAT.DATA_URL: {
24009
+ const blob = await this.exportManager.exportNodesAsBlob(nodes, boundingNodes, options);
24010
+ return await this.exportManager.blobToDataURL(blob);
24011
+ }
24012
+ case WEAVE_EXPORT_RETURN_FORMAT.IMAGE: return await this.exportManager.exportNodesAsImage(nodes, boundingNodes, options);
24013
+ }
23612
24014
  }
23613
- async exportArea(area, options) {
23614
- return await this.exportManager.exportAreaAsImage(area, options);
24015
+ async exportArea(area, options, returnFormat = WEAVE_EXPORT_RETURN_FORMAT.IMAGE) {
24016
+ switch (returnFormat) {
24017
+ case WEAVE_EXPORT_RETURN_FORMAT.BLOB: return await this.exportManager.exportAreaAsBlob(area, options);
24018
+ case WEAVE_EXPORT_RETURN_FORMAT.CANVAS: return await this.exportManager.exportAreaAsCanvas(area, options);
24019
+ case WEAVE_EXPORT_RETURN_FORMAT.DATA_URL: {
24020
+ const blob = await this.exportManager.exportAreaAsBlob(area, options);
24021
+ return await this.exportManager.blobToDataURL(blob);
24022
+ }
24023
+ case WEAVE_EXPORT_RETURN_FORMAT.IMAGE: return await this.exportManager.exportAreaAsImage(area, options);
24024
+ }
23615
24025
  }
23616
24026
  getExportBoundingBox(nodesIds) {
23617
24027
  const nodes = [];
@@ -23775,6 +24185,9 @@ var Weave = class {
23775
24185
  getDragProperties() {
23776
24186
  return this.dragAndDropManager.getDragProperties();
23777
24187
  }
24188
+ getEventsController() {
24189
+ return this.eventsController;
24190
+ }
23778
24191
  };
23779
24192
 
23780
24193
  //#endregion
@@ -23866,6 +24279,7 @@ const downscaleImageFromURL = (url, options) => {
23866
24279
  //#endregion
23867
24280
  //#region src/internal-utils/upscale.ts
23868
24281
  const setupUpscaleStage = (instance, stage) => {
24282
+ if (instance.isServerSide()) return;
23869
24283
  const config = instance.getConfiguration();
23870
24284
  const doUpscale = config.performance?.upscale?.enabled ?? false;
23871
24285
  if (doUpscale) {
@@ -23897,7 +24311,14 @@ const setupUpscaleStage = (instance, stage) => {
23897
24311
  innerElement.style.transformOrigin = "0 0";
23898
24312
  innerElement.style.transform = `scale(${scaleToCover})`;
23899
24313
  }
23900
- } else stage.setAttrs({ upscaleScale: 1 });
24314
+ } else {
24315
+ const realContainer = stage.container();
24316
+ const containerWidth = realContainer.offsetWidth;
24317
+ const containerHeight = realContainer.offsetHeight;
24318
+ stage.width(containerWidth);
24319
+ stage.height(containerHeight);
24320
+ stage.setAttrs({ upscaleScale: 1 });
24321
+ }
23901
24322
  };
23902
24323
 
23903
24324
  //#endregion
@@ -23908,6 +24329,7 @@ var WeaveStageNode = class extends WeaveNode {
23908
24329
  wheelMousePressed = false;
23909
24330
  isCmdCtrlPressed = false;
23910
24331
  globalEventsInitialized = false;
24332
+ initialize = void 0;
23911
24333
  onRender(props) {
23912
24334
  const stage = new Konva.Stage({
23913
24335
  ...props,
@@ -23926,10 +24348,10 @@ var WeaveStageNode = class extends WeaveNode {
23926
24348
  container.setAttribute("tabindex", "0");
23927
24349
  stage.container().addEventListener("focus", () => {
23928
24350
  this.stageFocused = true;
23929
- });
24351
+ }, { signal: this.instance.getEventsController()?.signal });
23930
24352
  stage.container().addEventListener("blur", () => {
23931
24353
  this.stageFocused = false;
23932
- });
24354
+ }, { signal: this.instance.getEventsController()?.signal });
23933
24355
  }
23934
24356
  Konva.Stage.prototype.mode = function(mode) {
23935
24357
  if (typeof mode !== "undefined") this._mode = mode;
@@ -23989,6 +24411,9 @@ var WeaveStageNode = class extends WeaveNode {
23989
24411
  setupEvents() {
23990
24412
  if (this.globalEventsInitialized) return;
23991
24413
  if (this.instance.isServerSide()) return;
24414
+ window.addEventListener("blur", () => {
24415
+ this.isCmdCtrlPressed = false;
24416
+ }, { signal: this.instance.getEventsController()?.signal });
23992
24417
  window.addEventListener("keydown", (e) => {
23993
24418
  if (this.isOnlyCtrlOrMeta(e)) {
23994
24419
  this.isCmdCtrlPressed = true;
@@ -23999,7 +24424,7 @@ var WeaveStageNode = class extends WeaveNode {
23999
24424
  const selectedNode = transformer.nodes()[0];
24000
24425
  selectedNode.fire("onCmdCtrlPressed");
24001
24426
  }
24002
- });
24427
+ }, { signal: this.instance.getEventsController()?.signal });
24003
24428
  window.addEventListener("keyup", (e) => {
24004
24429
  if (!(e.ctrlKey || e.metaKey)) {
24005
24430
  this.isCmdCtrlPressed = false;
@@ -24010,7 +24435,7 @@ var WeaveStageNode = class extends WeaveNode {
24010
24435
  const selectedNode = transformer.nodes()[0];
24011
24436
  selectedNode.fire("onCmdCtrlReleased");
24012
24437
  }
24013
- });
24438
+ }, { signal: this.instance.getEventsController()?.signal });
24014
24439
  this.globalEventsInitialized = true;
24015
24440
  }
24016
24441
  isOnlyCtrlOrMeta(event) {
@@ -24030,6 +24455,7 @@ const WEAVE_LAYER_NODE_TYPE = "layer";
24030
24455
  //#region src/nodes/layer/layer.ts
24031
24456
  var WeaveLayerNode = class extends WeaveNode {
24032
24457
  nodeType = WEAVE_LAYER_NODE_TYPE;
24458
+ initialize = void 0;
24033
24459
  onRender(props) {
24034
24460
  const layer = new Konva.Layer({ ...props });
24035
24461
  layer.canMoveToContainer = function() {
@@ -24077,6 +24503,7 @@ const WEAVE_GROUP_NODE_TYPE = "group";
24077
24503
  //#region src/nodes/group/group.ts
24078
24504
  var WeaveGroupNode = class extends WeaveNode {
24079
24505
  nodeType = WEAVE_GROUP_NODE_TYPE;
24506
+ initialize = void 0;
24080
24507
  constructor(params) {
24081
24508
  super();
24082
24509
  const { config } = params ?? {};
@@ -24169,6 +24596,7 @@ const WEAVE_RECTANGLE_NODE_TYPE = "rectangle";
24169
24596
  //#region src/nodes/rectangle/rectangle.ts
24170
24597
  var WeaveRectangleNode = class extends WeaveNode {
24171
24598
  nodeType = WEAVE_RECTANGLE_NODE_TYPE;
24599
+ initialize = void 0;
24172
24600
  constructor(params) {
24173
24601
  super();
24174
24602
  const { config } = params ?? {};
@@ -24212,6 +24640,7 @@ const WEAVE_ELLIPSE_NODE_TYPE = "ellipse";
24212
24640
  //#region src/nodes/ellipse/ellipse.ts
24213
24641
  var WeaveEllipseNode = class extends WeaveNode {
24214
24642
  nodeType = WEAVE_ELLIPSE_NODE_TYPE;
24643
+ initialize = void 0;
24215
24644
  constructor(params) {
24216
24645
  super();
24217
24646
  const { config } = params ?? {};
@@ -24357,13 +24786,16 @@ var WeaveLineNode = class extends WeaveNode {
24357
24786
  constructor(params) {
24358
24787
  super();
24359
24788
  this.config = mergeExceptArrays(WEAVE_LINE_NODE_DEFAULT_CONFIG, params?.config ?? {});
24360
- this.handleNodeChanges = null;
24361
- this.handleZoomChanges = null;
24362
24789
  this.snapper = new GreedySnapper({
24363
24790
  snapAngles: this.config.snapAngles.angles,
24364
24791
  activateThreshold: this.config.snapAngles.activateThreshold,
24365
24792
  releaseThreshold: this.config.snapAngles.releaseThreshold
24366
24793
  });
24794
+ this.initialize();
24795
+ }
24796
+ initialize() {
24797
+ this.handleNodeChanges = null;
24798
+ this.handleZoomChanges = null;
24367
24799
  }
24368
24800
  onRender(props) {
24369
24801
  const line = new Konva.Line({
@@ -24668,28 +25100,33 @@ const TEXT_LAYOUT = {
24668
25100
  //#region src/nodes/text/text.ts
24669
25101
  var WeaveTextNode = class extends WeaveNode {
24670
25102
  nodeType = WEAVE_TEXT_NODE_TYPE;
24671
- editing = false;
24672
- textAreaSuperContainer = null;
24673
- textAreaContainer = null;
24674
- textArea = null;
24675
- eventsInitialized = false;
24676
- isCtrlMetaPressed = false;
24677
25103
  constructor(params) {
24678
25104
  super();
24679
25105
  const { config } = params ?? {};
24680
25106
  this.config = (0, import_lodash.merge)({}, WEAVE_TEXT_NODE_DEFAULT_CONFIG, config);
25107
+ this.initialize();
25108
+ }
25109
+ initialize() {
24681
25110
  this.keyPressHandler = void 0;
25111
+ this.eventsInitialized = false;
25112
+ this.isCtrlMetaPressed = false;
25113
+ this.textAreaSuperContainer = null;
25114
+ this.textAreaContainer = null;
25115
+ this.textArea = null;
24682
25116
  this.editing = false;
24683
25117
  this.textArea = null;
24684
25118
  }
24685
25119
  initEvents() {
24686
25120
  if (!this.eventsInitialized && !globalThis._weave_isServerSide) {
25121
+ window.addEventListener("blur", () => {
25122
+ this.isCtrlMetaPressed = false;
25123
+ }, { signal: this.instance.getEventsController()?.signal });
24687
25124
  window.addEventListener("keydown", (e) => {
24688
25125
  if (e.ctrlKey || e.metaKey) this.isCtrlMetaPressed = true;
24689
- });
25126
+ }, { signal: this.instance.getEventsController()?.signal });
24690
25127
  window.addEventListener("keyup", (e) => {
24691
25128
  if (!(e.ctrlKey || e.metaKey)) this.isCtrlMetaPressed = false;
24692
- });
25129
+ }, { signal: this.instance.getEventsController()?.signal });
24693
25130
  this.eventsInitialized = true;
24694
25131
  }
24695
25132
  }
@@ -24717,7 +25154,7 @@ var WeaveTextNode = class extends WeaveNode {
24717
25154
  onAdd() {
24718
25155
  if (!this.instance.isServerSide() && !this.keyPressHandler) {
24719
25156
  this.keyPressHandler = this.handleKeyPress.bind(this);
24720
- window.addEventListener("keypress", this.keyPressHandler);
25157
+ window.addEventListener("keypress", this.keyPressHandler, { signal: this.instance.getEventsController()?.signal });
24721
25158
  }
24722
25159
  }
24723
25160
  onRender(props) {
@@ -24871,7 +25308,7 @@ var WeaveTextNode = class extends WeaveNode {
24871
25308
  });
24872
25309
  if (!this.instance.isServerSide() && !this.keyPressHandler) {
24873
25310
  this.keyPressHandler = this.handleKeyPress.bind(this);
24874
- window.addEventListener("keypress", this.keyPressHandler);
25311
+ window.addEventListener("keypress", this.keyPressHandler, { signal: this.instance.getEventsController()?.signal });
24875
25312
  }
24876
25313
  return text;
24877
25314
  }
@@ -25130,17 +25567,17 @@ var WeaveTextNode = class extends WeaveNode {
25130
25567
  this.textAreaSuperContainer.scrollTop = 0;
25131
25568
  this.textAreaSuperContainer.scrollLeft = 0;
25132
25569
  }
25133
- });
25570
+ }, { signal: this.instance.getEventsController()?.signal });
25134
25571
  this.textAreaContainer.addEventListener("scroll", () => {
25135
25572
  if (!this.textAreaContainer) return;
25136
25573
  this.textAreaContainer.scrollTop = 0;
25137
25574
  this.textAreaContainer.scrollLeft = 0;
25138
- });
25575
+ }, { signal: this.instance.getEventsController()?.signal });
25139
25576
  this.textArea.addEventListener("scroll", () => {
25140
25577
  if (!this.textArea) return;
25141
25578
  this.textArea.scrollTop = 0;
25142
25579
  this.textArea.scrollLeft = 0;
25143
- });
25580
+ }, { signal: this.instance.getEventsController()?.signal });
25144
25581
  const rotation = textNode.getAbsoluteRotation();
25145
25582
  if (rotation) {
25146
25583
  const transform = "rotate(" + rotation + "deg)";
@@ -25189,8 +25626,8 @@ var WeaveTextNode = class extends WeaveNode {
25189
25626
  this.textAreaDomResize(textNode);
25190
25627
  }
25191
25628
  };
25192
- this.textArea.addEventListener("keydown", handleKeyDown);
25193
- this.textArea.addEventListener("keyup", handleKeyUp);
25629
+ this.textArea.addEventListener("keydown", handleKeyDown, { signal: this.instance.getEventsController()?.signal });
25630
+ this.textArea.addEventListener("keyup", handleKeyUp, { signal: this.instance.getEventsController()?.signal });
25194
25631
  this.textArea.tabIndex = 1;
25195
25632
  this.textArea.focus();
25196
25633
  const handleOutsideClick = (e) => {
@@ -25216,7 +25653,7 @@ var WeaveTextNode = class extends WeaveNode {
25216
25653
  }
25217
25654
  };
25218
25655
  setTimeout(() => {
25219
- window.addEventListener("pointerup", handleOutsideClick);
25656
+ window.addEventListener("pointerup", handleOutsideClick, { signal: this.instance.getEventsController()?.signal });
25220
25657
  }, 0);
25221
25658
  this.instance.getStage().mode(WEAVE_STAGE_TEXT_EDITION_MODE);
25222
25659
  this.editing = true;
@@ -25552,7 +25989,7 @@ var WeaveImageCrop = class WeaveImageCrop {
25552
25989
  utilityLayer?.add(this.transformer);
25553
25990
  this.transformer?.forceUpdate();
25554
25991
  this.cropGroup.show();
25555
- window.addEventListener("keydown", this.handleHide);
25992
+ window.addEventListener("keydown", this.handleHide, { signal: this.instance.getEventsController()?.signal });
25556
25993
  if (options.cmdCtrl.triggered) {
25557
25994
  utilityLayer?.hide();
25558
25995
  const stage = this.instance.getStage();
@@ -26002,24 +26439,21 @@ const isAllowedUrl = (value) => {
26002
26439
  //#endregion
26003
26440
  //#region src/nodes/image/image.ts
26004
26441
  var WeaveImageNode = class extends WeaveNode {
26005
- imageBitmapCache = {};
26006
- imageSource = {};
26007
- imageFallback = {};
26008
- imageState = {};
26009
- imageTryoutAttempts = {};
26010
- imageTryoutIds = {};
26011
26442
  nodeType = WEAVE_IMAGE_NODE_TYPE;
26012
26443
  cursorsFallback = { loading: "wait" };
26013
26444
  cursors = {};
26014
26445
  constructor(params) {
26015
26446
  super();
26016
26447
  const { config } = params ?? {};
26448
+ this.config = mergeExceptArrays(WEAVE_IMAGE_DEFAULT_CONFIG, config);
26449
+ this.initialize();
26450
+ }
26451
+ initialize() {
26017
26452
  this.tapStart = {
26018
26453
  x: 0,
26019
26454
  y: 0,
26020
26455
  time: 0
26021
26456
  };
26022
- this.config = mergeExceptArrays(WEAVE_IMAGE_DEFAULT_CONFIG, config);
26023
26457
  this.imageCrop = null;
26024
26458
  this.imageBitmapCache = {};
26025
26459
  this.imageSource = {};
@@ -26243,7 +26677,7 @@ var WeaveImageNode = class extends WeaveNode {
26243
26677
  };
26244
26678
  this.updateImageCrop(image);
26245
26679
  } else {
26246
- this.updatePlaceholderSize(image, imagePlaceholder);
26680
+ this.updatePlaceholderSize(image);
26247
26681
  this.loadImage(imageProps, image, true);
26248
26682
  }
26249
26683
  if (this.config.performance.cache.enabled) image.on("transformend", () => {
@@ -26626,7 +27060,7 @@ var WeaveImageNode = class extends WeaveNode {
26626
27060
  }
26627
27061
  this.loadAsyncElement(id);
26628
27062
  preloadFunction(id, realImageURL ?? "", {
26629
- onLoad: () => {
27063
+ onLoad: async () => {
26630
27064
  if (useFallback) this.imageTryoutIds[id] = setTimeout(() => {
26631
27065
  const node = this.instance.getStage().findOne(`#${id}`);
26632
27066
  if (node) {
@@ -26677,7 +27111,7 @@ var WeaveImageNode = class extends WeaveNode {
26677
27111
  error: false
26678
27112
  };
26679
27113
  this.updateImageCrop(image);
26680
- this.resolveAsyncElement(id);
27114
+ if (!useFallback) this.resolveAsyncElement(id);
26681
27115
  this.cacheNode(image);
26682
27116
  }
26683
27117
  },
@@ -26718,13 +27152,9 @@ var WeaveImageNode = class extends WeaveNode {
26718
27152
  }
26719
27153
  }, loadTryout);
26720
27154
  }
26721
- updatePlaceholderSize(image, imagePlaceholder) {
27155
+ updatePlaceholderSize(image) {
26722
27156
  const imageAttrs = image.getAttrs();
26723
27157
  if (!this.imageState[imageAttrs.id ?? ""]?.loaded) return;
26724
- if (!imageAttrs.adding && !imageAttrs.cropInfo) {
26725
- imagePlaceholder.width(imageAttrs.uncroppedImage.width);
26726
- imagePlaceholder.height(imageAttrs.uncroppedImage.height);
26727
- }
26728
27158
  }
26729
27159
  updateImageCrop(image) {
26730
27160
  const imageAttrs = image.getAttrs();
@@ -26858,6 +27288,7 @@ const WEAVE_STAR_NODE_TYPE = "star";
26858
27288
  //#region src/nodes/star/star.ts
26859
27289
  var WeaveStarNode = class extends WeaveNode {
26860
27290
  nodeType = WEAVE_STAR_NODE_TYPE;
27291
+ initialize = void 0;
26861
27292
  constructor(params) {
26862
27293
  super();
26863
27294
  const { config } = params ?? {};
@@ -26943,6 +27374,7 @@ const WEAVE_ARROW_NODE_TYPE = "arrow";
26943
27374
  //#region src/nodes/arrow/arrow.ts
26944
27375
  var WeaveArrowNode = class extends WeaveNode {
26945
27376
  nodeType = WEAVE_ARROW_NODE_TYPE;
27377
+ initialize = void 0;
26946
27378
  constructor(params) {
26947
27379
  super();
26948
27380
  const { config } = params ?? {};
@@ -26999,6 +27431,7 @@ const WEAVE_REGULAR_POLYGON_NODE_TYPE = "regular-polygon";
26999
27431
  //#region src/nodes/regular-polygon/regular-polygon.ts
27000
27432
  var WeaveRegularPolygonNode = class extends WeaveNode {
27001
27433
  nodeType = WEAVE_REGULAR_POLYGON_NODE_TYPE;
27434
+ initialize = void 0;
27002
27435
  constructor(params) {
27003
27436
  super();
27004
27437
  const { config } = params ?? {};
@@ -27112,6 +27545,7 @@ var GroupFrame = class extends Konva.Group {
27112
27545
  //#region src/nodes/frame/frame.ts
27113
27546
  var WeaveFrameNode = class extends WeaveNode {
27114
27547
  nodeType = WEAVE_FRAME_NODE_TYPE;
27548
+ initialize = void 0;
27115
27549
  constructor(params) {
27116
27550
  super();
27117
27551
  const { config } = params ?? {};
@@ -27220,15 +27654,16 @@ var WeaveFrameNode = class extends WeaveNode {
27220
27654
  width: props.frameWidth - borderWidth * 2,
27221
27655
  height: props.frameHeight - borderWidth * 2,
27222
27656
  strokeScaleEnabled: true,
27223
- clipFunc: (ctx) => {
27224
- const width = (frameInternal.width() + borderWidth) * frameInternal.scaleX();
27225
- const height = (frameInternal.height() + borderWidth) * frameInternal.scaleY();
27226
- ctx.rect(-(borderWidth / 2) * frameInternal.scaleX(), -(borderWidth / 2) * frameInternal.scaleY(), width, height);
27227
- },
27228
27657
  listening: true,
27229
27658
  draggable: false,
27230
27659
  isTargetable: false
27231
27660
  });
27661
+ frameInternal.clip({
27662
+ x: -(borderWidth / 2) * frameInternal.scaleX(),
27663
+ y: -(borderWidth / 2) * frameInternal.scaleX(),
27664
+ width: (frameInternal.width() + borderWidth) * frameInternal.scaleX(),
27665
+ height: (frameInternal.height() + borderWidth) * frameInternal.scaleY()
27666
+ });
27232
27667
  frame.add(frameInternal);
27233
27668
  const selectionArea = new Konva.Rect({
27234
27669
  ...frameParams,
@@ -27328,6 +27763,12 @@ var WeaveFrameNode = class extends WeaveNode {
27328
27763
  frame.getNodeAnchors = function() {
27329
27764
  return [];
27330
27765
  };
27766
+ frame.clip({
27767
+ x: 0,
27768
+ y: text.y(),
27769
+ width: frame.width(),
27770
+ height: frame.height() + text.height()
27771
+ });
27331
27772
  return frame;
27332
27773
  }
27333
27774
  onUpdate(nodeInstance, nextProps) {
@@ -27412,6 +27853,7 @@ const WEAVE_STROKE_NODE_DEFAULT_CONFIG = {
27412
27853
  //#region src/nodes/stroke/stroke.ts
27413
27854
  var WeaveStrokeNode = class extends WeaveNode {
27414
27855
  nodeType = WEAVE_STROKE_NODE_TYPE;
27856
+ initialize = void 0;
27415
27857
  constructor(params) {
27416
27858
  super();
27417
27859
  const { config } = params ?? {};
@@ -27988,8 +28430,6 @@ var WeaveSquareLineTipManager = class extends WeaveBaseLineTipManager {
27988
28430
  //#endregion
27989
28431
  //#region src/nodes/stroke-single/stroke-single.ts
27990
28432
  var WeaveStrokeSingleNode = class extends WeaveNode {
27991
- startHandle = null;
27992
- endHandle = null;
27993
28433
  nodeType = WEAVE_STROKE_SINGLE_NODE_TYPE;
27994
28434
  tipManagers = {
27995
28435
  [WEAVE_STROKE_SINGLE_NODE_TIP_TYPE.ARROW]: new WeaveArrowLineTipManager(),
@@ -28000,24 +28440,29 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
28000
28440
  constructor(params) {
28001
28441
  super();
28002
28442
  this.config = mergeExceptArrays(WEAVE_STROKE_SINGLE_NODE_DEFAULT_CONFIG, params?.config ?? {});
28003
- this.handleNodeChanges = null;
28004
- this.handleZoomChanges = null;
28005
- this.shiftPressed = false;
28006
28443
  this.snapper = new GreedySnapper({
28007
28444
  snapAngles: this.config.snapAngles.angles,
28008
28445
  activateThreshold: this.config.snapAngles.activateThreshold,
28009
28446
  releaseThreshold: this.config.snapAngles.releaseThreshold
28010
28447
  });
28448
+ this.initialize();
28449
+ }
28450
+ initialize() {
28011
28451
  this.eventsInitialized = false;
28452
+ this.startHandle = null;
28453
+ this.endHandle = null;
28454
+ this.handleNodeChanges = null;
28455
+ this.handleZoomChanges = null;
28456
+ this.shiftPressed = false;
28012
28457
  }
28013
28458
  initEvents() {
28014
28459
  if (this.eventsInitialized) return;
28015
28460
  window.addEventListener("keydown", (e) => {
28016
28461
  if (e.key === "Shift") this.shiftPressed = true;
28017
- });
28462
+ }, { signal: this.instance.getEventsController()?.signal });
28018
28463
  window.addEventListener("keyup", (e) => {
28019
28464
  if (e.key === "Shift") this.shiftPressed = false;
28020
- });
28465
+ }, { signal: this.instance.getEventsController()?.signal });
28021
28466
  this.eventsInitialized = true;
28022
28467
  }
28023
28468
  onRender(props) {
@@ -28504,6 +28949,9 @@ var WeaveCommentNode = class extends WeaveNode {
28504
28949
  constructor(params) {
28505
28950
  super();
28506
28951
  this.config = mergeExceptArrays(WEAVE_COMMENT_NODE_DEFAULTS, params.config);
28952
+ this.initialize();
28953
+ }
28954
+ initialize() {
28507
28955
  this.commentDomVisibleId = null;
28508
28956
  this.commentDomVisible = false;
28509
28957
  this.commentDomAction = null;
@@ -29132,10 +29580,6 @@ const WEAVE_VIDEO_DEFAULT_CONFIG = {
29132
29580
  //#endregion
29133
29581
  //#region src/nodes/video/video.ts
29134
29582
  var WeaveVideoNode = class extends WeaveNode {
29135
- videoState = {};
29136
- videoSourceFrameId = {};
29137
- videoSource = {};
29138
- videoPlaceholder = {};
29139
29583
  nodeType = WEAVE_VIDEO_NODE_TYPE;
29140
29584
  constructor(params) {
29141
29585
  super();
@@ -29148,6 +29592,13 @@ var WeaveVideoNode = class extends WeaveNode {
29148
29592
  this.videoIconImage.src = this.config.style.icon.dataURL;
29149
29593
  }
29150
29594
  }
29595
+ initialize() {
29596
+ this.videoState = {};
29597
+ this.videoSource = {};
29598
+ this.videoSourceFrameId = {};
29599
+ this.videoPlaceholder = {};
29600
+ this.videoIconImage = void 0;
29601
+ }
29151
29602
  async loadPlaceholder(params, video) {
29152
29603
  const videoProps = params;
29153
29604
  const { id } = videoProps;
@@ -29642,6 +30093,7 @@ const WEAVE_MEASURE_NODE_DEFAULT_CONFIG = { style: {
29642
30093
  var WeaveMeasureNode = class extends WeaveNode {
29643
30094
  nodeType = WEAVE_MEASURE_NODE_TYPE;
29644
30095
  handlePointCircleRadius = 6;
30096
+ initialize = void 0;
29645
30097
  constructor(params) {
29646
30098
  super();
29647
30099
  this.config = mergeExceptArrays(WEAVE_MEASURE_NODE_DEFAULT_CONFIG, params?.config ?? {});
@@ -30932,6 +31384,7 @@ var WeaveConnectorNode = class extends WeaveNode {
30932
31384
  [WEAVE_CONNECTOR_NODE_DECORATOR_TYPE.DOT]: setupNodeDecoratorDot,
30933
31385
  [WEAVE_CONNECTOR_NODE_DECORATOR_TYPE.ARROW]: setupNodeDecoratorArrow
30934
31386
  };
31387
+ initialize = void 0;
30935
31388
  constructor(params) {
30936
31389
  super();
30937
31390
  this.config = mergeExceptArrays(WEAVE_CONNECTOR_NODE_DEFAULT_CONFIG, params?.config);
@@ -31682,10 +32135,6 @@ const WEAVE_STAGE_ZOOM_DEFAULT_CONFIG = {
31682
32135
  var WeaveStageZoomPlugin = class extends WeavePlugin {
31683
32136
  getLayerName = void 0;
31684
32137
  initLayer = void 0;
31685
- pinching = false;
31686
- zooming = false;
31687
- isTrackpad = false;
31688
- zoomVelocity = 0;
31689
32138
  zoomInertiaType = WEAVE_STAGE_ZOOM_TYPE.MOUSE_WHEEL;
31690
32139
  defaultStep = 3;
31691
32140
  constructor(params) {
@@ -31693,8 +32142,13 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
31693
32142
  const { config } = params ?? {};
31694
32143
  this.config = mergeExceptArrays(WEAVE_STAGE_ZOOM_DEFAULT_CONFIG, config);
31695
32144
  if (!this.config.zoomSteps.includes(this.config.defaultZoom)) throw new Error(`Default zoom ${this.config.defaultZoom} is not in zoom steps`);
32145
+ this.initialize();
32146
+ }
32147
+ initialize() {
31696
32148
  this.pinching = false;
32149
+ this.zooming = false;
31697
32150
  this.isTrackpad = false;
32151
+ this.zoomVelocity = 0;
31698
32152
  this.isCtrlOrMetaPressed = false;
31699
32153
  this.updatedMinimumZoom = false;
31700
32154
  this.actualStep = this.config.zoomSteps.findIndex((step) => step === this.config.defaultZoom);
@@ -31981,6 +32435,15 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
31981
32435
  if (box.width === 0 || box.height === 0) return;
31982
32436
  this.fitToElements(box, finalOptions);
31983
32437
  }
32438
+ fitToArea(area, options) {
32439
+ const finalOptions = mergeExceptArrays({
32440
+ smartZoom: false,
32441
+ overrideZoom: true
32442
+ }, options);
32443
+ if (!this.enabled) return;
32444
+ if (area.width === 0 || area.height === 0) return;
32445
+ this.fitToElements(area, finalOptions);
32446
+ }
31984
32447
  enable() {
31985
32448
  this.enabled = true;
31986
32449
  }
@@ -31997,12 +32460,15 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
31997
32460
  };
31998
32461
  }
31999
32462
  initEvents() {
32463
+ window.addEventListener("blur", () => {
32464
+ this.isCtrlOrMetaPressed = false;
32465
+ }, { signal: this.instance.getEventsController()?.signal });
32000
32466
  window.addEventListener("keydown", (e) => {
32001
32467
  if (e.ctrlKey || e.metaKey) this.isCtrlOrMetaPressed = true;
32002
- });
32468
+ }, { signal: this.instance.getEventsController()?.signal });
32003
32469
  window.addEventListener("keyup", (e) => {
32004
32470
  if (!(e.ctrlKey || e.metaKey)) this.isCtrlOrMetaPressed = false;
32005
- });
32471
+ }, { signal: this.instance.getEventsController()?.signal });
32006
32472
  const stage = this.instance.getStage();
32007
32473
  let lastCenter = null;
32008
32474
  let lastDist = 0;
@@ -32027,7 +32493,10 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
32027
32493
  return;
32028
32494
  }
32029
32495
  }
32030
- }, { passive: false });
32496
+ }, {
32497
+ passive: false,
32498
+ signal: this.instance.getEventsController()?.signal
32499
+ });
32031
32500
  stage.getContent().addEventListener("touchmove", (e) => {
32032
32501
  e.preventDefault();
32033
32502
  if (e.touches.length === 2) {
@@ -32067,12 +32536,18 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
32067
32536
  lastDist = dist;
32068
32537
  lastCenter = newCenter;
32069
32538
  }
32070
- }, { passive: false });
32539
+ }, {
32540
+ passive: false,
32541
+ signal: this.instance.getEventsController()?.signal
32542
+ });
32071
32543
  stage.getContent().addEventListener("touchend", () => {
32072
32544
  this.pinching = false;
32073
32545
  lastDist = 0;
32074
32546
  lastCenter = null;
32075
- }, { passive: false });
32547
+ }, {
32548
+ passive: false,
32549
+ signal: this.instance.getEventsController()?.signal
32550
+ });
32076
32551
  let doZoom = false;
32077
32552
  const handleWheelImmediate = (e) => {
32078
32553
  const performZoom = this.isCtrlOrMetaPressed || !this.isCtrlOrMetaPressed && e.ctrlKey && e.deltaMode === 0;
@@ -32090,7 +32565,10 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
32090
32565
  e.preventDefault();
32091
32566
  doZoom = true;
32092
32567
  };
32093
- window.addEventListener("wheel", handleWheelImmediate, { passive: false });
32568
+ window.addEventListener("wheel", handleWheelImmediate, {
32569
+ signal: this.instance.getEventsController()?.signal,
32570
+ passive: false
32571
+ });
32094
32572
  const handleWheel = (e) => {
32095
32573
  if (!doZoom) return;
32096
32574
  const delta = e.deltaY > 0 ? 1 : -1;
@@ -32103,7 +32581,10 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
32103
32581
  }
32104
32582
  };
32105
32583
  const throttledHandleWheel = (0, import_lodash.throttle)(handleWheel, DEFAULT_THROTTLE_MS);
32106
- window.addEventListener("wheel", throttledHandleWheel, { passive: true });
32584
+ window.addEventListener("wheel", throttledHandleWheel, {
32585
+ signal: this.instance.getEventsController()?.signal,
32586
+ passive: true
32587
+ });
32107
32588
  }
32108
32589
  getInertiaScale() {
32109
32590
  const stage = this.instance.getStage();
@@ -32161,6 +32642,7 @@ const ZOOM_OUT_TOOL_ACTION_NAME = "zoomOutTool";
32161
32642
  //#region src/actions/zoom-out-tool/zoom-out-tool.ts
32162
32643
  var WeaveZoomOutToolAction = class extends WeaveAction {
32163
32644
  onPropsChange = void 0;
32645
+ initialize = void 0;
32164
32646
  getName() {
32165
32647
  return ZOOM_OUT_TOOL_ACTION_NAME;
32166
32648
  }
@@ -32195,6 +32677,10 @@ const ZOOM_IN_TOOL_ACTION_NAME = "zoomInTool";
32195
32677
  //#region src/actions/zoom-in-tool/zoom-in-tool.ts
32196
32678
  var WeaveZoomInToolAction = class extends WeaveAction {
32197
32679
  onPropsChange = void 0;
32680
+ initialize = void 0;
32681
+ constructor() {
32682
+ super();
32683
+ }
32198
32684
  getName() {
32199
32685
  return ZOOM_IN_TOOL_ACTION_NAME;
32200
32686
  }
@@ -32229,6 +32715,10 @@ const FIT_TO_SCREEN_TOOL_ACTION_NAME = "fitToScreenTool";
32229
32715
  //#region src/actions/fit-to-screen-tool/fit-to-screen-tool.ts
32230
32716
  var WeaveFitToScreenToolAction = class extends WeaveAction {
32231
32717
  onPropsChange = void 0;
32718
+ initialize = void 0;
32719
+ constructor() {
32720
+ super();
32721
+ }
32232
32722
  getName() {
32233
32723
  return FIT_TO_SCREEN_TOOL_ACTION_NAME;
32234
32724
  }
@@ -32262,6 +32752,10 @@ const FIT_TO_SELECTION_TOOL_ACTION_NAME = "fitToSelectionTool";
32262
32752
  //#region src/actions/fit-to-selection-tool/fit-to-selection-tool.ts
32263
32753
  var WeaveFitToSelectionToolAction = class extends WeaveAction {
32264
32754
  onPropsChange = void 0;
32755
+ initialize = void 0;
32756
+ constructor() {
32757
+ super();
32758
+ }
32265
32759
  getName() {
32266
32760
  return FIT_TO_SELECTION_TOOL_ACTION_NAME;
32267
32761
  }
@@ -32304,6 +32798,9 @@ var WeaveMoveToolAction = class extends WeaveAction {
32304
32798
  onInit = void 0;
32305
32799
  constructor() {
32306
32800
  super();
32801
+ this.initialize();
32802
+ }
32803
+ initialize() {
32307
32804
  this.initialized = false;
32308
32805
  this.state = MOVE_TOOL_STATE.IDLE;
32309
32806
  }
@@ -32317,7 +32814,7 @@ var WeaveMoveToolAction = class extends WeaveAction {
32317
32814
  this.cancelAction();
32318
32815
  return;
32319
32816
  }
32320
- });
32817
+ }, { signal: this.instance.getEventsController()?.signal });
32321
32818
  stage.on("pointerdown", () => {
32322
32819
  if ([MOVE_TOOL_ACTION_NAME].includes(this.instance.getActiveAction() ?? "")) stage.container().style.cursor = "grabbing";
32323
32820
  });
@@ -32376,6 +32873,9 @@ var WeaveSelectionToolAction = class extends WeaveAction {
32376
32873
  onInit = void 0;
32377
32874
  constructor() {
32378
32875
  super();
32876
+ this.initialize();
32877
+ }
32878
+ initialize() {
32379
32879
  this.initialized = false;
32380
32880
  this.state = SELECTION_TOOL_STATE.IDLE;
32381
32881
  }
@@ -32439,6 +32939,9 @@ var WeaveEraserToolAction = class extends WeaveAction {
32439
32939
  onInit = void 0;
32440
32940
  constructor() {
32441
32941
  super();
32942
+ this.initialize();
32943
+ }
32944
+ initialize() {
32442
32945
  this.initialized = false;
32443
32946
  this.erasing = false;
32444
32947
  this.state = ERASER_TOOL_STATE.IDLE;
@@ -32472,7 +32975,7 @@ var WeaveEraserToolAction = class extends WeaveAction {
32472
32975
  this.cancelAction();
32473
32976
  return;
32474
32977
  }
32475
- });
32978
+ }, { signal: this.instance.getEventsController()?.signal });
32476
32979
  this.initialized = true;
32477
32980
  }
32478
32981
  setState(state) {
@@ -32539,6 +33042,9 @@ var WeaveRectangleToolAction = class extends WeaveAction {
32539
33042
  onInit = void 0;
32540
33043
  constructor() {
32541
33044
  super();
33045
+ this.initialize();
33046
+ }
33047
+ initialize() {
32542
33048
  this.pointers = new Map();
32543
33049
  this.initialized = false;
32544
33050
  this.state = RECTANGLE_TOOL_STATE.IDLE;
@@ -32574,7 +33080,7 @@ var WeaveRectangleToolAction = class extends WeaveAction {
32574
33080
  this.cancelAction();
32575
33081
  return;
32576
33082
  }
32577
- });
33083
+ }, { signal: this.instance.getEventsController()?.signal });
32578
33084
  stage.on("pointermove", () => {
32579
33085
  if (this.state === RECTANGLE_TOOL_STATE.IDLE) return;
32580
33086
  this.setCursor();
@@ -32748,6 +33254,9 @@ var WeaveEllipseToolAction = class extends WeaveAction {
32748
33254
  onInit = void 0;
32749
33255
  constructor() {
32750
33256
  super();
33257
+ this.initialize();
33258
+ }
33259
+ initialize() {
32751
33260
  this.pointers = new Map();
32752
33261
  this.initialized = false;
32753
33262
  this.state = ELLIPSE_TOOL_STATE.IDLE;
@@ -32783,7 +33292,7 @@ var WeaveEllipseToolAction = class extends WeaveAction {
32783
33292
  this.cancelAction();
32784
33293
  return;
32785
33294
  }
32786
- });
33295
+ }, { signal: this.instance.getEventsController()?.signal });
32787
33296
  stage.on("pointerdown", (e) => {
32788
33297
  this.setTapStart(e);
32789
33298
  this.pointers.set(e.evt.pointerId, {
@@ -32964,6 +33473,9 @@ var WeavePenToolAction = class extends WeaveAction {
32964
33473
  onInit = void 0;
32965
33474
  constructor() {
32966
33475
  super();
33476
+ this.initialize();
33477
+ }
33478
+ initialize() {
32967
33479
  this.pointers = new Map();
32968
33480
  this.initialized = false;
32969
33481
  this.state = PEN_TOOL_STATE.IDLE;
@@ -32999,7 +33511,7 @@ var WeavePenToolAction = class extends WeaveAction {
32999
33511
  this.cancelAction();
33000
33512
  return;
33001
33513
  }
33002
- });
33514
+ }, { signal: this.instance.getEventsController()?.signal });
33003
33515
  stage.on("pointerdown", (e) => {
33004
33516
  this.setTapStart(e);
33005
33517
  this.pointers.set(e.evt.pointerId, {
@@ -33236,6 +33748,9 @@ var WeaveLineToolAction = class extends WeaveAction {
33236
33748
  constructor(params) {
33237
33749
  super();
33238
33750
  this.config = mergeExceptArrays(LINE_TOOL_DEFAULT_CONFIG, params?.config ?? {});
33751
+ this.initialize();
33752
+ }
33753
+ initialize() {
33239
33754
  this.pointers = new Map();
33240
33755
  this.initialized = false;
33241
33756
  this.state = LINE_TOOL_STATE.IDLE;
@@ -33280,13 +33795,13 @@ var WeaveLineToolAction = class extends WeaveAction {
33280
33795
  this.snappedAngle = null;
33281
33796
  this.shiftPressed = true;
33282
33797
  }
33283
- });
33798
+ }, { signal: this.instance.getEventsController()?.signal });
33284
33799
  window.addEventListener("keyup", (e) => {
33285
33800
  if (e.key === "Shift" && this.instance.getActiveAction() === LINE_TOOL_ACTION_NAME) {
33286
33801
  this.snappedAngle = null;
33287
33802
  this.shiftPressed = false;
33288
33803
  }
33289
- });
33804
+ }, { signal: this.instance.getEventsController()?.signal });
33290
33805
  stage.on("pointerdown", (e) => {
33291
33806
  this.setTapStart(e);
33292
33807
  this.pointers.set(e.evt.pointerId, {
@@ -33501,6 +34016,9 @@ var WeaveBrushToolAction = class extends WeaveAction {
33501
34016
  constructor(params) {
33502
34017
  super();
33503
34018
  this.config = mergeExceptArrays(BRUSH_TOOL_DEFAULT_CONFIG, params?.config ?? {});
34019
+ this.initialize();
34020
+ }
34021
+ initialize() {
33504
34022
  this.initialized = false;
33505
34023
  this.state = BRUSH_TOOL_STATE.INACTIVE;
33506
34024
  this.strokeId = null;
@@ -33529,7 +34047,7 @@ var WeaveBrushToolAction = class extends WeaveAction {
33529
34047
  const stage = this.instance.getStage();
33530
34048
  window.addEventListener("keyup", (e) => {
33531
34049
  if (e.code === "Space" && this.instance.getActiveAction() === BRUSH_TOOL_ACTION_NAME) this.isSpacePressed = false;
33532
- });
34050
+ }, { signal: this.instance.getEventsController()?.signal });
33533
34051
  window.addEventListener("keydown", (e) => {
33534
34052
  if (e.code === "Enter" && this.instance.getActiveAction() === BRUSH_TOOL_ACTION_NAME) {
33535
34053
  e.stopPropagation();
@@ -33545,7 +34063,7 @@ var WeaveBrushToolAction = class extends WeaveAction {
33545
34063
  e.stopPropagation();
33546
34064
  this.cancelAction();
33547
34065
  }
33548
- });
34066
+ }, { signal: this.instance.getEventsController()?.signal });
33549
34067
  const handlePointerDown = (e) => {
33550
34068
  if (this.state === BRUSH_TOOL_STATE.INACTIVE) return;
33551
34069
  if (this.state !== BRUSH_TOOL_STATE.IDLE) return;
@@ -33754,6 +34272,9 @@ var WeaveTextToolAction = class extends WeaveAction {
33754
34272
  onInit = void 0;
33755
34273
  constructor() {
33756
34274
  super();
34275
+ this.initialize();
34276
+ }
34277
+ initialize() {
33757
34278
  this.initialized = false;
33758
34279
  this.state = TEXT_TOOL_STATE.IDLE;
33759
34280
  this.textId = null;
@@ -33783,7 +34304,7 @@ var WeaveTextToolAction = class extends WeaveAction {
33783
34304
  this.cancelAction();
33784
34305
  return;
33785
34306
  }
33786
- });
34307
+ }, { signal: this.instance.getEventsController()?.signal });
33787
34308
  stage.on("pointermove", () => {
33788
34309
  if (this.state === TEXT_TOOL_STATE.IDLE) return;
33789
34310
  this.setCursor();
@@ -33911,6 +34432,9 @@ var WeaveImageToolAction = class extends WeaveAction {
33911
34432
  constructor(params) {
33912
34433
  super();
33913
34434
  this.config = mergeExceptArrays(WEAVE_IMAGE_TOOL_CONFIG_DEFAULT, params?.config ?? {});
34435
+ this.initialize();
34436
+ }
34437
+ initialize() {
33914
34438
  this.pointers = new Map();
33915
34439
  this.initialized = false;
33916
34440
  this.imageId = null;
@@ -33954,7 +34478,7 @@ var WeaveImageToolAction = class extends WeaveAction {
33954
34478
  this.cancelAction();
33955
34479
  return;
33956
34480
  }
33957
- });
34481
+ }, { signal: this.instance.getEventsController()?.signal });
33958
34482
  stage.on("pointerdown", (e) => {
33959
34483
  this.setTapStart(e);
33960
34484
  if (this.ignorePointerEvents) return;
@@ -34351,6 +34875,9 @@ var WeaveImagesToolAction = class extends WeaveAction {
34351
34875
  constructor(params) {
34352
34876
  super();
34353
34877
  this.config = mergeExceptArrays(WEAVE_IMAGES_TOOL_DEFAULT_CONFIG, params ?? {});
34878
+ this.initialize();
34879
+ }
34880
+ initialize() {
34354
34881
  this.pointers = new Map();
34355
34882
  this.initialized = false;
34356
34883
  this.tempPointerFeedbackNode = null;
@@ -34397,7 +34924,7 @@ var WeaveImagesToolAction = class extends WeaveAction {
34397
34924
  const stage = this.instance.getStage();
34398
34925
  stage.container().addEventListener("keydown", (e) => {
34399
34926
  if (e.key === "Escape" && this.instance.getActiveAction() === WEAVE_IMAGES_TOOL_ACTION_NAME) this.cancelAction();
34400
- });
34927
+ }, { signal: this.instance.getEventsController()?.signal });
34401
34928
  stage.on("pointerdown", (e) => {
34402
34929
  this.setTapStart(e);
34403
34930
  this.pointers.set(e.evt.pointerId, {
@@ -34779,6 +35306,9 @@ var WeaveStarToolAction = class extends WeaveAction {
34779
35306
  onInit = void 0;
34780
35307
  constructor() {
34781
35308
  super();
35309
+ this.initialize();
35310
+ }
35311
+ initialize() {
34782
35312
  this.pointers = new Map();
34783
35313
  this.initialized = false;
34784
35314
  this.state = STAR_TOOL_STATE.IDLE;
@@ -34815,7 +35345,7 @@ var WeaveStarToolAction = class extends WeaveAction {
34815
35345
  this.cancelAction();
34816
35346
  return;
34817
35347
  }
34818
- });
35348
+ }, { signal: this.instance.getEventsController()?.signal });
34819
35349
  stage.on("pointerdown", (e) => {
34820
35350
  this.setTapStart(e);
34821
35351
  this.pointers.set(e.evt.pointerId, {
@@ -34980,8 +35510,8 @@ var WeaveStarToolAction = class extends WeaveAction {
34980
35510
 
34981
35511
  //#endregion
34982
35512
  //#region src/actions/arrow-tool/constants.ts
34983
- const ARROW_TOOL_ACTION_NAME = "arrowTool";
34984
- const ARROW_TOOL_STATE = {
35513
+ const WEAVE_ARROW_TOOL_ACTION_NAME = "arrowTool";
35514
+ const WEAVE_ARROW_TOOL_STATE = {
34985
35515
  ["IDLE"]: "idle",
34986
35516
  ["ADDING"]: "adding",
34987
35517
  ["DEFINING_SIZE"]: "definingSize",
@@ -34997,9 +35527,12 @@ var WeaveArrowToolAction = class extends WeaveAction {
34997
35527
  onInit = void 0;
34998
35528
  constructor() {
34999
35529
  super();
35530
+ this.initialize();
35531
+ }
35532
+ initialize() {
35000
35533
  this.pointers = new Map();
35001
35534
  this.initialized = false;
35002
- this.state = ARROW_TOOL_STATE.IDLE;
35535
+ this.state = WEAVE_ARROW_TOOL_STATE.IDLE;
35003
35536
  this.arrowId = null;
35004
35537
  this.tempArrowId = null;
35005
35538
  this.tempMainArrowNode = null;
@@ -35012,7 +35545,7 @@ var WeaveArrowToolAction = class extends WeaveAction {
35012
35545
  this.props = this.initProps();
35013
35546
  }
35014
35547
  getName() {
35015
- return ARROW_TOOL_ACTION_NAME;
35548
+ return WEAVE_ARROW_TOOL_ACTION_NAME;
35016
35549
  }
35017
35550
  initProps() {
35018
35551
  return {
@@ -35029,40 +35562,37 @@ var WeaveArrowToolAction = class extends WeaveAction {
35029
35562
  setupEvents() {
35030
35563
  const stage = this.instance.getStage();
35031
35564
  window.addEventListener("keydown", (e) => {
35032
- if (e.code === "Enter" && this.instance.getActiveAction() === ARROW_TOOL_ACTION_NAME) {
35565
+ if (e.code === "Enter" && this.instance.getActiveAction() === WEAVE_ARROW_TOOL_ACTION_NAME) {
35033
35566
  this.cancelAction();
35034
35567
  return;
35035
35568
  }
35036
- if (e.code === "Escape" && this.instance.getActiveAction() === ARROW_TOOL_ACTION_NAME) {
35037
- this.cancelAction();
35038
- return;
35039
- }
35040
- });
35569
+ if (e.code === "Escape" && this.instance.getActiveAction() === WEAVE_ARROW_TOOL_ACTION_NAME) this.cancelAction();
35570
+ }, { signal: this.instance.getEventsController()?.signal });
35041
35571
  stage.on("pointerdown", (e) => {
35042
35572
  this.setTapStart(e);
35043
35573
  this.pointers.set(e.evt.pointerId, {
35044
35574
  x: e.evt.clientX,
35045
35575
  y: e.evt.clientY
35046
35576
  });
35047
- if (this.pointers.size === 2 && this.instance.getActiveAction() === ARROW_TOOL_ACTION_NAME) {
35048
- this.state = ARROW_TOOL_STATE.ADDING;
35577
+ if (this.pointers.size === 2 && this.instance.getActiveAction() === WEAVE_ARROW_TOOL_ACTION_NAME) {
35578
+ this.state = WEAVE_ARROW_TOOL_STATE.ADDING;
35049
35579
  return;
35050
35580
  }
35051
- if (!this.tempMainArrowNode && this.state === ARROW_TOOL_STATE.ADDING) this.handleAdding();
35052
- if (this.tempMainArrowNode && this.state === ARROW_TOOL_STATE.ADDING) this.state = ARROW_TOOL_STATE.DEFINING_SIZE;
35581
+ if (!this.tempMainArrowNode && this.state === WEAVE_ARROW_TOOL_STATE.ADDING) this.handleAdding();
35582
+ if (this.tempMainArrowNode && this.state === WEAVE_ARROW_TOOL_STATE.ADDING) this.state = WEAVE_ARROW_TOOL_STATE.DEFINING_SIZE;
35053
35583
  });
35054
35584
  stage.on("pointermove", () => {
35055
- if (this.state === ARROW_TOOL_STATE.IDLE) return;
35585
+ if (this.state === WEAVE_ARROW_TOOL_STATE.IDLE) return;
35056
35586
  this.setCursor();
35057
- if (this.pointers.size === 2 && this.instance.getActiveAction() === ARROW_TOOL_ACTION_NAME) {
35058
- this.state = ARROW_TOOL_STATE.ADDING;
35587
+ if (this.pointers.size === 2 && this.instance.getActiveAction() === WEAVE_ARROW_TOOL_ACTION_NAME) {
35588
+ this.state = WEAVE_ARROW_TOOL_STATE.ADDING;
35059
35589
  return;
35060
35590
  }
35061
- if (this.state === ARROW_TOOL_STATE.DEFINING_SIZE) this.handleMovement();
35591
+ if (this.state === WEAVE_ARROW_TOOL_STATE.DEFINING_SIZE) this.handleMovement();
35062
35592
  });
35063
35593
  stage.on("pointerup", (e) => {
35064
35594
  this.pointers.delete(e.evt.pointerId);
35065
- if (this.state === ARROW_TOOL_STATE.DEFINING_SIZE) this.handleSettingSize();
35595
+ if (this.state === WEAVE_ARROW_TOOL_STATE.DEFINING_SIZE) this.handleSettingSize();
35066
35596
  });
35067
35597
  this.initialized = true;
35068
35598
  }
@@ -35076,7 +35606,7 @@ var WeaveArrowToolAction = class extends WeaveAction {
35076
35606
  this.tempPoint = void 0;
35077
35607
  this.tempNextPoint = void 0;
35078
35608
  this.clickPoint = null;
35079
- this.setState(ARROW_TOOL_STATE.ADDING);
35609
+ this.setState(WEAVE_ARROW_TOOL_STATE.ADDING);
35080
35610
  }
35081
35611
  handleAdding() {
35082
35612
  const stage = this.instance.getStage();
@@ -35127,7 +35657,7 @@ var WeaveArrowToolAction = class extends WeaveAction {
35127
35657
  this.measureContainer?.add(this.tempNextPoint);
35128
35658
  this.tempPoint.moveToTop();
35129
35659
  this.tempNextPoint.moveToTop();
35130
- this.setState(ARROW_TOOL_STATE.DEFINING_SIZE);
35660
+ this.setState(WEAVE_ARROW_TOOL_STATE.DEFINING_SIZE);
35131
35661
  }
35132
35662
  }
35133
35663
  handleSettingSize() {
@@ -35154,11 +35684,11 @@ var WeaveArrowToolAction = class extends WeaveAction {
35154
35684
  y: mousePoint.y,
35155
35685
  points: [0, 0]
35156
35686
  });
35157
- this.setState(ARROW_TOOL_STATE.DEFINING_SIZE);
35687
+ this.setState(WEAVE_ARROW_TOOL_STATE.DEFINING_SIZE);
35158
35688
  }
35159
35689
  }
35160
35690
  handleMovement() {
35161
- if (this.state !== ARROW_TOOL_STATE.DEFINING_SIZE) return;
35691
+ if (this.state !== WEAVE_ARROW_TOOL_STATE.DEFINING_SIZE) return;
35162
35692
  if (this.arrowId && this.tempArrowNode && this.measureContainer && this.tempNextPoint) {
35163
35693
  const { mousePoint } = this.instance.getMousePointerRelativeToContainer(this.measureContainer);
35164
35694
  this.tempArrowNode.setAttrs({
@@ -35225,7 +35755,7 @@ var WeaveArrowToolAction = class extends WeaveAction {
35225
35755
  this.container = void 0;
35226
35756
  this.measureContainer = void 0;
35227
35757
  this.clickPoint = null;
35228
- this.setState(ARROW_TOOL_STATE.IDLE);
35758
+ this.setState(WEAVE_ARROW_TOOL_STATE.IDLE);
35229
35759
  }
35230
35760
  setCursor() {
35231
35761
  const stage = this.instance.getStage();
@@ -35269,13 +35799,15 @@ const WEAVE_STROKE_TOOL_DEFAULT_CONFIG = { snapAngles: {
35269
35799
  var WeaveStrokeToolAction = class extends WeaveAction {
35270
35800
  initialized = false;
35271
35801
  initialCursor = null;
35272
- snappedAngle = null;
35273
35802
  shiftPressed = false;
35274
35803
  onPropsChange = void 0;
35275
35804
  onInit = void 0;
35276
35805
  constructor(params) {
35277
35806
  super();
35278
35807
  this.config = mergeExceptArrays(WEAVE_STROKE_TOOL_DEFAULT_CONFIG, params?.config ?? {});
35808
+ this.initialize();
35809
+ }
35810
+ initialize() {
35279
35811
  this.pointers = new Map();
35280
35812
  this.initialized = false;
35281
35813
  this.state = WEAVE_STROKE_TOOL_STATE.IDLE;
@@ -35284,7 +35816,6 @@ var WeaveStrokeToolAction = class extends WeaveAction {
35284
35816
  this.tempLineId = null;
35285
35817
  this.tempLineNode = null;
35286
35818
  this.container = void 0;
35287
- this.snappedAngle = null;
35288
35819
  this.measureContainer = void 0;
35289
35820
  this.clickPoint = null;
35290
35821
  this.snapper = new GreedySnapper({
@@ -35297,6 +35828,9 @@ var WeaveStrokeToolAction = class extends WeaveAction {
35297
35828
  getName() {
35298
35829
  return WEAVE_STROKE_TOOL_ACTION_NAME;
35299
35830
  }
35831
+ getNames() {
35832
+ return [WEAVE_STROKE_TOOL_ACTION_NAME, ...WEAVE_STROKE_TOOL_ACTION_NAME_ALIASES];
35833
+ }
35300
35834
  hasAliases() {
35301
35835
  return true;
35302
35836
  }
@@ -35315,32 +35849,26 @@ var WeaveStrokeToolAction = class extends WeaveAction {
35315
35849
  setupEvents() {
35316
35850
  const stage = this.instance.getStage();
35317
35851
  window.addEventListener("keydown", (e) => {
35318
- if (e.code === "Enter" && this.instance.getActiveAction() === WEAVE_STROKE_TOOL_ACTION_NAME) {
35852
+ if (e.code === "Enter" && this.getNames().includes(this.instance.getActiveAction() ?? "")) {
35319
35853
  this.cancelAction();
35320
35854
  return;
35321
35855
  }
35322
- if (e.code === "Escape" && this.instance.getActiveAction() === WEAVE_STROKE_TOOL_ACTION_NAME) {
35856
+ if (e.code === "Escape" && this.getNames().includes(this.instance.getActiveAction() ?? "")) {
35323
35857
  this.cancelAction();
35324
35858
  return;
35325
35859
  }
35326
- if (e.key === "Shift" && this.instance.getActiveAction() === WEAVE_STROKE_TOOL_ACTION_NAME) {
35327
- this.snappedAngle = null;
35328
- this.shiftPressed = true;
35329
- }
35330
- });
35860
+ if (e.key === "Shift" && this.getNames().includes(this.instance.getActiveAction() ?? "")) this.shiftPressed = true;
35861
+ }, { signal: this.instance.getEventsController()?.signal });
35331
35862
  window.addEventListener("keyup", (e) => {
35332
- if (e.key === "Shift" && this.instance.getActiveAction() === WEAVE_STROKE_TOOL_ACTION_NAME) {
35333
- this.snappedAngle = null;
35334
- this.shiftPressed = false;
35335
- }
35336
- });
35863
+ if (e.key === "Shift" && this.getNames().includes(this.instance.getActiveAction() ?? "")) this.shiftPressed = false;
35864
+ }, { signal: this.instance.getEventsController()?.signal });
35337
35865
  stage.on("pointerdown", (e) => {
35338
35866
  this.setTapStart(e);
35339
35867
  this.pointers.set(e.evt.pointerId, {
35340
35868
  x: e.evt.clientX,
35341
35869
  y: e.evt.clientY
35342
35870
  });
35343
- if (this.pointers.size === 2 && this.instance.getActiveAction() === WEAVE_STROKE_TOOL_ACTION_NAME) {
35871
+ if (this.pointers.size === 2 && this.getNames().includes(this.instance.getActiveAction() ?? "")) {
35344
35872
  this.state = WEAVE_STROKE_TOOL_STATE.ADDING;
35345
35873
  return;
35346
35874
  }
@@ -35350,7 +35878,7 @@ var WeaveStrokeToolAction = class extends WeaveAction {
35350
35878
  stage.on("pointermove", () => {
35351
35879
  if (this.state === WEAVE_STROKE_TOOL_STATE.IDLE) return;
35352
35880
  this.setCursor();
35353
- if (this.pointers.size === 2 && this.instance.getActiveAction() === WEAVE_STROKE_TOOL_ACTION_NAME) {
35881
+ if (this.pointers.size === 2 && this.getNames().includes(this.instance.getActiveAction() ?? "")) {
35354
35882
  this.state = WEAVE_STROKE_TOOL_STATE.ADDING;
35355
35883
  return;
35356
35884
  }
@@ -35368,7 +35896,7 @@ var WeaveStrokeToolAction = class extends WeaveAction {
35368
35896
  addLine() {
35369
35897
  this.setCursor();
35370
35898
  this.setFocusStage();
35371
- this.instance.emitEvent("onAddingStroke", { actionName: this.instance.getActiveAction() ?? WEAVE_STROKE_TOOL_ACTION_NAME });
35899
+ this.instance.emitEvent("onAddingStroke", { actionName: this.instance.getActiveAction() ?? "not-defined" });
35372
35900
  this.shiftPressed = false;
35373
35901
  this.clickPoint = null;
35374
35902
  this.setState(WEAVE_STROKE_TOOL_STATE.ADDING);
@@ -35476,7 +36004,7 @@ var WeaveStrokeToolAction = class extends WeaveAction {
35476
36004
  });
35477
36005
  delete finalLine.props.dragBoundFunc;
35478
36006
  this.instance.addNode(finalLine, this.container?.getAttrs().id);
35479
- this.instance.emitEvent("onAddedStroke", { actionName: this.instance.getActiveAction() ?? WEAVE_STROKE_TOOL_ACTION_NAME });
36007
+ this.instance.emitEvent("onAddedStroke", { actionName: this.instance.getActiveAction() ?? "not-defined" });
35480
36008
  nodeCreated = true;
35481
36009
  }
35482
36010
  }
@@ -35526,6 +36054,9 @@ var WeaveRegularPolygonToolAction = class extends WeaveAction {
35526
36054
  onInit = void 0;
35527
36055
  constructor() {
35528
36056
  super();
36057
+ this.initialize();
36058
+ }
36059
+ initialize() {
35529
36060
  this.pointers = new Map();
35530
36061
  this.initialized = false;
35531
36062
  this.state = REGULAR_POLYGON_TOOL_STATE.IDLE;
@@ -35560,7 +36091,7 @@ var WeaveRegularPolygonToolAction = class extends WeaveAction {
35560
36091
  this.cancelAction();
35561
36092
  return;
35562
36093
  }
35563
- });
36094
+ }, { signal: this.instance.getEventsController()?.signal });
35564
36095
  stage.on("pointerdown", (e) => {
35565
36096
  this.setTapStart(e);
35566
36097
  this.pointers.set(e.evt.pointerId, {
@@ -35734,6 +36265,9 @@ var WeaveFrameToolAction = class extends WeaveAction {
35734
36265
  onInit = void 0;
35735
36266
  constructor() {
35736
36267
  super();
36268
+ this.initialize();
36269
+ }
36270
+ initialize() {
35737
36271
  this.initialized = false;
35738
36272
  this.state = FRAME_TOOL_STATE.IDLE;
35739
36273
  this.frameId = null;
@@ -35761,7 +36295,7 @@ var WeaveFrameToolAction = class extends WeaveAction {
35761
36295
  this.cancelAction();
35762
36296
  return;
35763
36297
  }
35764
- });
36298
+ }, { signal: this.instance.getEventsController()?.signal });
35765
36299
  stage.on("pointermove", () => {
35766
36300
  if (this.state === FRAME_TOOL_STATE.IDLE) return;
35767
36301
  this.setCursor();
@@ -35863,12 +36397,16 @@ var WeaveExportStageToolAction = class extends WeaveAction {
35863
36397
  };
35864
36398
  onPropsChange = void 0;
35865
36399
  onInit = void 0;
36400
+ initialize = void 0;
36401
+ constructor() {
36402
+ super();
36403
+ }
35866
36404
  getName() {
35867
36405
  return EXPORT_STAGE_TOOL_ACTION_NAME;
35868
36406
  }
35869
36407
  async exportStage(boundingNodes) {
35870
36408
  const mainLayer = this.instance.getMainLayer();
35871
- const img = await this.instance.exportNodes(mainLayer?.getChildren() ?? [], boundingNodes, this.options);
36409
+ const img = await this.instance.exportNodes(mainLayer?.getChildren() ?? [], boundingNodes, this.options, WEAVE_EXPORT_RETURN_FORMAT.IMAGE);
35872
36410
  return img;
35873
36411
  }
35874
36412
  async trigger(cancelAction, { boundingNodes, options }) {
@@ -35910,11 +36448,15 @@ var WeaveExportNodesToolAction = class extends WeaveAction {
35910
36448
  };
35911
36449
  onPropsChange = void 0;
35912
36450
  onInit = void 0;
36451
+ initialize = void 0;
36452
+ constructor() {
36453
+ super();
36454
+ }
35913
36455
  getName() {
35914
36456
  return EXPORT_NODES_TOOL_ACTION_NAME;
35915
36457
  }
35916
36458
  async exportNodes(nodes, boundingNodes) {
35917
- const img = await this.instance.exportNodes(nodes, boundingNodes ?? ((nodes$1) => nodes$1), this.options);
36459
+ const img = await this.instance.exportNodes(nodes, boundingNodes ?? ((nodes$1) => nodes$1), this.options, WEAVE_EXPORT_RETURN_FORMAT.IMAGE);
35918
36460
  return img;
35919
36461
  }
35920
36462
  async trigger(cancelAction, { nodes, boundingNodes, options, triggerSelectionTool = true }) {
@@ -35962,6 +36504,9 @@ var WeaveAlignNodesToolAction = class extends WeaveAction {
35962
36504
  onInit = void 0;
35963
36505
  constructor() {
35964
36506
  super();
36507
+ this.initialize();
36508
+ }
36509
+ initialize() {
35965
36510
  this.initialized = false;
35966
36511
  this.state = ALIGN_NODES_TOOL_STATE.IDLE;
35967
36512
  }
@@ -36211,6 +36756,9 @@ var WeaveCommentToolAction = class extends WeaveAction {
36211
36756
  super();
36212
36757
  const { config } = params ?? {};
36213
36758
  this.config = mergeExceptArrays(WEAVE_COMMENT_TOOL_DEFAULT_CONFIG, config);
36759
+ this.initialize();
36760
+ }
36761
+ initialize() {
36214
36762
  this.pointers = new Map();
36215
36763
  this.initialized = false;
36216
36764
  this.state = WEAVE_COMMENT_TOOL_STATE.IDLE;
@@ -36288,7 +36836,7 @@ var WeaveCommentToolAction = class extends WeaveAction {
36288
36836
  return;
36289
36837
  }
36290
36838
  if (e.code === "Escape" && this.state === WEAVE_COMMENT_TOOL_STATE.CREATING_COMMENT) this.setState(WEAVE_COMMENT_TOOL_STATE.ADDING);
36291
- });
36839
+ }, { signal: this.instance.getEventsController()?.signal });
36292
36840
  stage.on("pointermove", (e) => {
36293
36841
  if (this.state === WEAVE_COMMENT_TOOL_STATE.IDLE) return;
36294
36842
  if (commentNodeHandler?.isCommentViewing()) {
@@ -36439,6 +36987,9 @@ var WeaveVideoToolAction = class extends WeaveAction {
36439
36987
  update = void 0;
36440
36988
  constructor() {
36441
36989
  super();
36990
+ this.initialize();
36991
+ }
36992
+ initialize() {
36442
36993
  this.pointers = new Map();
36443
36994
  this.initialized = false;
36444
36995
  this.state = VIDEO_TOOL_STATE.IDLE;
@@ -36485,7 +37036,7 @@ var WeaveVideoToolAction = class extends WeaveAction {
36485
37036
  this.cancelAction();
36486
37037
  return;
36487
37038
  }
36488
- });
37039
+ }, { signal: this.instance.getEventsController()?.signal });
36489
37040
  stage.on("pointerdown", (e) => {
36490
37041
  this.setTapStart(e);
36491
37042
  this.pointers.set(e.evt.pointerId, {
@@ -36664,6 +37215,9 @@ var WeaveMeasureToolAction = class extends WeaveAction {
36664
37215
  constructor(params) {
36665
37216
  super();
36666
37217
  this.config = mergeExceptArrays(WEAVE_MEASURE_TOOL_DEFAULT_CONFIG, params?.config ?? {});
37218
+ this.initialize();
37219
+ }
37220
+ initialize() {
36667
37221
  this.initialized = false;
36668
37222
  this.state = MEASURE_TOOL_STATE.IDLE;
36669
37223
  this.measureId = null;
@@ -36690,7 +37244,7 @@ var WeaveMeasureToolAction = class extends WeaveAction {
36690
37244
  const stage = this.instance.getStage();
36691
37245
  window.addEventListener("keydown", (e) => {
36692
37246
  if (e.code === "Escape" && this.instance.getActiveAction() === MEASURE_TOOL_ACTION_NAME) this.cancelAction();
36693
- });
37247
+ }, { signal: this.instance.getEventsController()?.signal });
36694
37248
  stage.on("pointermove", () => {
36695
37249
  if (this.state === MEASURE_TOOL_STATE.IDLE) return;
36696
37250
  if (this.state === MEASURE_TOOL_STATE.SET_TO) {
@@ -36960,6 +37514,9 @@ var WeaveConnectorToolAction = class extends WeaveAction {
36960
37514
  constructor(params) {
36961
37515
  super();
36962
37516
  this.config = mergeExceptArrays(CONNECTOR_TOOL_DEFAULT_CONFIG, params?.config);
37517
+ this.initialize();
37518
+ }
37519
+ initialize() {
36963
37520
  this.pointers = new Map();
36964
37521
  this.initialized = false;
36965
37522
  this.tempLineNode = null;
@@ -36998,7 +37555,7 @@ var WeaveConnectorToolAction = class extends WeaveAction {
36998
37555
  return;
36999
37556
  }
37000
37557
  if (e.code === "Escape" && this.instance.getActiveAction() === CONNECTOR_TOOL_ACTION_NAME) this.cancelAction();
37001
- });
37558
+ }, { signal: this.instance.getEventsController()?.signal });
37002
37559
  let nodeHovered = void 0;
37003
37560
  stage.on("pointermove", () => {
37004
37561
  if (!(this.state === CONNECTOR_TOOL_STATE.SELECTING_INITIAL || this.state === CONNECTOR_TOOL_STATE.SELECTING_FINAL)) return;
@@ -37313,10 +37870,6 @@ var WeaveConnectorToolAction = class extends WeaveAction {
37313
37870
  //#endregion
37314
37871
  //#region src/plugins/stage-grid/stage-grid.ts
37315
37872
  var WeaveStageGridPlugin = class extends WeavePlugin {
37316
- actStageZoomX = 1;
37317
- actStageZoomY = 1;
37318
- actStagePosX = 0;
37319
- actStagePosY = 0;
37320
37873
  constructor(params) {
37321
37874
  super();
37322
37875
  const { config } = params ?? {};
@@ -37332,6 +37885,10 @@ var WeaveStageGridPlugin = class extends WeavePlugin {
37332
37885
  this.isMouseMiddleButtonPressed = false;
37333
37886
  this.isSpaceKeyPressed = false;
37334
37887
  this.forceStageChange = false;
37888
+ this.actStagePosX = 0;
37889
+ this.actStagePosY = 0;
37890
+ this.actStageZoomX = 1;
37891
+ this.actStageZoomY = 1;
37335
37892
  }
37336
37893
  getName() {
37337
37894
  return WEAVE_STAGE_GRID_PLUGIN_KEY;
@@ -37356,10 +37913,10 @@ var WeaveStageGridPlugin = class extends WeavePlugin {
37356
37913
  const stage = this.instance.getStage();
37357
37914
  window.addEventListener("keydown", (e) => {
37358
37915
  if (e.code === "Space") this.isSpaceKeyPressed = true;
37359
- });
37916
+ }, { signal: this.instance.getEventsController()?.signal });
37360
37917
  window.addEventListener("keyup", (e) => {
37361
37918
  if (e.code === "Space") this.isSpaceKeyPressed = false;
37362
- });
37919
+ }, { signal: this.instance.getEventsController()?.signal });
37363
37920
  this.instance.addEventListener("onStageMove", () => {
37364
37921
  this.onRender();
37365
37922
  });
@@ -37625,15 +38182,14 @@ var WeaveStageGridPlugin = class extends WeavePlugin {
37625
38182
  //#endregion
37626
38183
  //#region src/plugins/stage-panning/stage-panning.ts
37627
38184
  var WeaveStagePanningPlugin = class extends WeavePlugin {
37628
- panning = false;
37629
- currentPointer = null;
37630
- stageScrollInterval = void 0;
37631
- panEdgeTargets = {};
37632
38185
  getLayerName = void 0;
37633
38186
  initLayer = void 0;
37634
38187
  constructor(params) {
37635
38188
  super();
37636
38189
  this.config = mergeExceptArrays(WEAVE_STAGE_PANNING_DEFAULT_CONFIG, params?.config ?? {});
38190
+ this.initialize();
38191
+ }
38192
+ initialize() {
37637
38193
  this.pointers = new Map();
37638
38194
  this.panning = false;
37639
38195
  this.isDragging = false;
@@ -37645,6 +38201,9 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
37645
38201
  this.isCtrlOrMetaPressed = false;
37646
38202
  this.isSpaceKeyPressed = false;
37647
38203
  this.previousPointer = null;
38204
+ this.currentPointer = null;
38205
+ this.stageScrollInterval = void 0;
38206
+ this.panEdgeTargets = {};
37648
38207
  }
37649
38208
  getName() {
37650
38209
  return WEAVE_STAGE_PANNING_KEY;
@@ -37668,6 +38227,9 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
37668
38227
  }
37669
38228
  initEvents() {
37670
38229
  const stage = this.instance.getStage();
38230
+ window.addEventListener("blur", () => {
38231
+ this.isCtrlOrMetaPressed = false;
38232
+ }, { signal: this.instance.getEventsController()?.signal });
37671
38233
  window.addEventListener("keydown", (e) => {
37672
38234
  if (e.ctrlKey || e.metaKey) this.isCtrlOrMetaPressed = true;
37673
38235
  if (e.code === "Space") {
@@ -37678,7 +38240,7 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
37678
38240
  this.isSpaceKeyPressed = true;
37679
38241
  this.setCursor();
37680
38242
  }
37681
- });
38243
+ }, { signal: this.instance.getEventsController()?.signal });
37682
38244
  window.addEventListener("keyup", (e) => {
37683
38245
  if (e.key === "Meta" || e.key === "Control") this.isCtrlOrMetaPressed = false;
37684
38246
  if (e.code === "Space") {
@@ -37689,7 +38251,7 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
37689
38251
  this.isSpaceKeyPressed = false;
37690
38252
  this.disableMove();
37691
38253
  }
37692
- });
38254
+ }, { signal: this.instance.getEventsController()?.signal });
37693
38255
  let lastPos = null;
37694
38256
  stage.on("pointerdown", (e) => {
37695
38257
  this.pointers.set(e.evt.pointerId, {
@@ -37762,7 +38324,10 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
37762
38324
  this.instance.emitEvent("onStageMove");
37763
38325
  };
37764
38326
  const handleWheelThrottled = (0, import_lodash.throttle)(handleWheel, WEAVE_STAGE_PANNING_THROTTLE_MS);
37765
- window.addEventListener("wheel", handleWheelThrottled, { passive: true });
38327
+ window.addEventListener("wheel", handleWheelThrottled, {
38328
+ passive: true,
38329
+ signal: this.instance.getEventsController()?.signal
38330
+ });
37766
38331
  stage.on("dragstart", (e) => {
37767
38332
  const duration = 1e3 / 60;
37768
38333
  if (this.panEdgeTargets[e.target.getAttrs().id ?? ""] !== void 0) return;
@@ -37820,7 +38385,10 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
37820
38385
  stage.container().style.setProperty("-webkit-user-drag", "none");
37821
38386
  stage.getContent().addEventListener("touchmove", function(e) {
37822
38387
  e.preventDefault();
37823
- }, { passive: false });
38388
+ }, {
38389
+ passive: false,
38390
+ signal: this.instance.getEventsController()?.signal
38391
+ });
37824
38392
  }
37825
38393
  isPanning() {
37826
38394
  return this.panning;
@@ -37898,6 +38466,9 @@ var WeaveStageMinimapPlugin = class extends WeavePlugin {
37898
38466
  constructor(params) {
37899
38467
  super();
37900
38468
  this.config = mergeExceptArrays(STAGE_MINIMAP_DEFAULT_CONFIG, params.config);
38469
+ this.initialize();
38470
+ }
38471
+ initialize() {
37901
38472
  this.initialized = false;
37902
38473
  }
37903
38474
  getName() {
@@ -38075,6 +38646,7 @@ const WEAVE_STAGE_RESIZE_KEY = "stageResize";
38075
38646
  var WeaveStageResizePlugin = class extends WeavePlugin {
38076
38647
  getLayerName = void 0;
38077
38648
  initLayer = void 0;
38649
+ initialize = void 0;
38078
38650
  getName() {
38079
38651
  return WEAVE_STAGE_RESIZE_KEY;
38080
38652
  }
@@ -38094,6 +38666,10 @@ var WeaveStageResizePlugin = class extends WeavePlugin {
38094
38666
  const pluginInstance = plugins[pluginId];
38095
38667
  pluginInstance.onRender?.();
38096
38668
  }
38669
+ this.instance.emitEvent("onStageResize", {
38670
+ width: stage.width(),
38671
+ height: stage.height()
38672
+ });
38097
38673
  }
38098
38674
  }
38099
38675
  onInit() {
@@ -38102,7 +38678,7 @@ var WeaveStageResizePlugin = class extends WeavePlugin {
38102
38678
  }, DEFAULT_THROTTLE_MS);
38103
38679
  window.addEventListener("resize", () => {
38104
38680
  throttledResize();
38105
- });
38681
+ }, { signal: this.instance.getEventsController()?.signal });
38106
38682
  const resizeObserver = new ResizeObserver(() => {
38107
38683
  throttledResize();
38108
38684
  });
@@ -38120,10 +38696,12 @@ var WeaveStageResizePlugin = class extends WeavePlugin {
38120
38696
  //#endregion
38121
38697
  //#region src/plugins/nodes-multi-selection-feedback/nodes-multi-selection-feedback.ts
38122
38698
  var WeaveNodesMultiSelectionFeedbackPlugin = class extends WeavePlugin {
38123
- selectedHalos = {};
38124
38699
  constructor(params) {
38125
38700
  super();
38126
38701
  this.config = mergeExceptArrays(WEAVE_NODES_MULTI_SELECTION_FEEDBACK_PLUGIN_DEFAULT_CONFIG, params?.config ?? {});
38702
+ this.initialize();
38703
+ }
38704
+ initialize() {
38127
38705
  this.selectedHalos = {};
38128
38706
  }
38129
38707
  getName() {
@@ -38289,12 +38867,14 @@ var WeaveNodesMultiSelectionFeedbackPlugin = class extends WeavePlugin {
38289
38867
  //#endregion
38290
38868
  //#region src/plugins/connected-users/connected-users.ts
38291
38869
  var WeaveConnectedUsersPlugin = class extends WeavePlugin {
38292
- connectedUsers = {};
38293
38870
  getLayerName = void 0;
38294
38871
  constructor(params) {
38295
38872
  super();
38296
38873
  const { config } = params ?? {};
38297
38874
  this.config = config;
38875
+ this.initialize();
38876
+ }
38877
+ initialize() {
38298
38878
  this.connectedUsers = {};
38299
38879
  }
38300
38880
  getName() {
@@ -38341,6 +38921,9 @@ var WeaveUsersSelectionPlugin = class extends WeavePlugin {
38341
38921
  this.config = config;
38342
38922
  this.config.getUser = memoize(this.config.getUser);
38343
38923
  this.config.getUserColor = memoize(this.config.getUserColor);
38924
+ this.initialize();
38925
+ }
38926
+ initialize() {
38344
38927
  this.usersSelection = {};
38345
38928
  }
38346
38929
  getName() {
@@ -38533,6 +39116,9 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
38533
39116
  this.config.getUser = memoize(this.config.getUser);
38534
39117
  this.config.getUserBackgroundColor = memoize(this.config.getUserBackgroundColor);
38535
39118
  this.config.getUserForegroundColor = memoize(this.config.getUserForegroundColor);
39119
+ this.initialize();
39120
+ }
39121
+ initialize() {
38536
39122
  this.usersPointers = {};
38537
39123
  this.usersOperations = {};
38538
39124
  }
@@ -38743,6 +39329,9 @@ var WeaveUsersPresencePlugin = class extends WeavePlugin {
38743
39329
  super();
38744
39330
  const { config } = params;
38745
39331
  this.config = mergeExceptArrays(WEAVE_USERS_PRESENCE_CONFIG_DEFAULT_PROPS, config);
39332
+ this.initialize();
39333
+ }
39334
+ initialize() {
38746
39335
  this.userPresence = {};
38747
39336
  }
38748
39337
  getName() {
@@ -38818,6 +39407,9 @@ var WeaveStageDropAreaPlugin = class extends WeavePlugin {
38818
39407
  initLayer = void 0;
38819
39408
  constructor() {
38820
39409
  super();
39410
+ this.initialize();
39411
+ }
39412
+ initialize() {
38821
39413
  this.enabled = true;
38822
39414
  }
38823
39415
  getName() {
@@ -38831,14 +39423,20 @@ var WeaveStageDropAreaPlugin = class extends WeavePlugin {
38831
39423
  stage.container().addEventListener("dragover", (e) => {
38832
39424
  e.preventDefault();
38833
39425
  e.stopPropagation();
38834
- });
39426
+ }, { signal: this.instance.getEventsController()?.signal });
38835
39427
  stage.container().addEventListener("drop", (e) => {
38836
39428
  e.preventDefault();
38837
39429
  e.stopPropagation();
38838
39430
  this.instance.emitEvent("onStageDrop", e);
39431
+ }, { signal: this.instance.getEventsController()?.signal });
39432
+ window.addEventListener("dragover", (e) => e.preventDefault(), {
39433
+ signal: this.instance.getEventsController()?.signal,
39434
+ passive: false
39435
+ });
39436
+ window.addEventListener("drop", (e) => e.preventDefault(), {
39437
+ signal: this.instance.getEventsController()?.signal,
39438
+ passive: false
38839
39439
  });
38840
- window.addEventListener("dragover", (e) => e.preventDefault(), { passive: false });
38841
- window.addEventListener("drop", (e) => e.preventDefault(), { passive: false });
38842
39440
  }
38843
39441
  enable() {
38844
39442
  this.enabled = true;
@@ -38857,6 +39455,9 @@ var WeaveNodesEdgeSnappingPlugin = class extends WeavePlugin {
38857
39455
  this.guideLineConfig = config?.guideLine ?? GUIDE_LINE_DEFAULT_CONFIG;
38858
39456
  this.dragSnappingThreshold = config?.dragSnappingThreshold ?? GUIDE_LINE_DRAG_SNAPPING_THRESHOLD;
38859
39457
  this.transformSnappingThreshold = config?.transformSnappingThreshold ?? GUIDE_LINE_TRANSFORM_SNAPPING_THRESHOLD;
39458
+ this.initialize();
39459
+ }
39460
+ initialize() {
38860
39461
  this.enabled = true;
38861
39462
  }
38862
39463
  getName() {
@@ -39233,6 +39834,9 @@ var WeaveNodesDistanceSnappingPlugin = class extends WeavePlugin {
39233
39834
  this.enterSnappingTolerance = config?.enterSnappingTolerance ?? GUIDE_ENTER_SNAPPING_TOLERANCE;
39234
39835
  this.exitSnappingTolerance = config?.exitSnappingTolerance ?? GUIDE_EXIT_SNAPPING_TOLERANCE;
39235
39836
  this.uiConfig = mergeExceptArrays(GUIDE_DISTANCE_LINE_DEFAULT_CONFIG, config?.ui);
39837
+ this.initialize();
39838
+ }
39839
+ initialize() {
39236
39840
  this.enabled = true;
39237
39841
  }
39238
39842
  getName() {
@@ -39879,12 +40483,14 @@ var WeaveNodesDistanceSnappingPlugin = class extends WeavePlugin {
39879
40483
  //#endregion
39880
40484
  //#region src/plugins/comments-renderer/comments-renderer.ts
39881
40485
  var WeaveCommentsRendererPlugin = class extends WeavePlugin {
39882
- comments = [];
39883
40486
  getLayerName = void 0;
39884
40487
  constructor(params) {
39885
40488
  super();
39886
40489
  const { config } = params ?? {};
39887
40490
  this.config = config;
40491
+ this.initialize();
40492
+ }
40493
+ initialize() {
39888
40494
  this.comments = [];
39889
40495
  }
39890
40496
  getName() {
@@ -39975,6 +40581,7 @@ const WEAVE_STAGE_KEYBOARD_MOVE_DEFAULT_CONFIG = { movementDelta: 5 };
39975
40581
  var WeaveStageKeyboardMovePlugin = class extends WeavePlugin {
39976
40582
  getLayerName = void 0;
39977
40583
  initLayer = void 0;
40584
+ initialize = void 0;
39978
40585
  constructor(params) {
39979
40586
  super();
39980
40587
  this.config = mergeExceptArrays(WEAVE_STAGE_KEYBOARD_MOVE_DEFAULT_CONFIG, params?.config ?? {});
@@ -40013,7 +40620,7 @@ var WeaveStageKeyboardMovePlugin = class extends WeavePlugin {
40013
40620
  if (e.code === "ArrowLeft" && e.shiftKey) this.handleNodesMovement("left");
40014
40621
  if (e.code === "ArrowRight" && e.shiftKey) this.handleNodesMovement("right");
40015
40622
  if (e.code === "ArrowDown" && e.shiftKey) this.handleNodesMovement("down");
40016
- });
40623
+ }, { signal: this.instance.getEventsController()?.signal });
40017
40624
  }
40018
40625
  enable() {
40019
40626
  this.enabled = true;
@@ -40024,5 +40631,5 @@ var WeaveStageKeyboardMovePlugin = class extends WeavePlugin {
40024
40631
  };
40025
40632
 
40026
40633
  //#endregion
40027
- export { ALIGN_NODES_ALIGN_TO, ALIGN_NODES_TOOL_ACTION_NAME, ALIGN_NODES_TOOL_STATE, ARROW_TOOL_ACTION_NAME, ARROW_TOOL_STATE, BRUSH_TOOL_ACTION_NAME, BRUSH_TOOL_DEFAULT_CONFIG, BRUSH_TOOL_STATE, CONNECTOR_TOOL_ACTION_NAME, CONNECTOR_TOOL_DEFAULT_CONFIG, CONNECTOR_TOOL_STATE, COPY_PASTE_NODES_PLUGIN_STATE, ELLIPSE_TOOL_ACTION_NAME, ELLIPSE_TOOL_STATE, ERASER_TOOL_ACTION_NAME, ERASER_TOOL_STATE, FRAME_TOOL_ACTION_NAME, FRAME_TOOL_STATE, GUIDE_DISTANCE_LINE_DEFAULT_CONFIG, GUIDE_ENTER_SNAPPING_TOLERANCE, GUIDE_EXIT_SNAPPING_TOLERANCE, GUIDE_HORIZONTAL_LINE_NAME, GUIDE_LINE_DEFAULT_CONFIG, GUIDE_LINE_DRAG_SNAPPING_THRESHOLD, GUIDE_LINE_NAME, GUIDE_LINE_TRANSFORM_SNAPPING_THRESHOLD, GUIDE_ORIENTATION, GUIDE_VERTICAL_LINE_NAME, LINE_TOOL_ACTION_NAME, LINE_TOOL_DEFAULT_CONFIG, LINE_TOOL_STATE, MEASURE_TOOL_ACTION_NAME, MEASURE_TOOL_STATE, MOVE_TOOL_ACTION_NAME, MOVE_TOOL_STATE, NODE_SNAP, NODE_SNAP_HORIZONTAL, NODE_SNAP_VERTICAL, PEN_TOOL_ACTION_NAME, PEN_TOOL_STATE, RECTANGLE_TOOL_ACTION_NAME, RECTANGLE_TOOL_STATE, REGULAR_POLYGON_TOOL_ACTION_NAME, REGULAR_POLYGON_TOOL_STATE, SELECTION_TOOL_ACTION_NAME, SELECTION_TOOL_STATE, STAGE_MINIMAP_DEFAULT_CONFIG, STAR_TOOL_ACTION_NAME, STAR_TOOL_STATE, TEXT_LAYOUT, TEXT_TOOL_ACTION_NAME, TEXT_TOOL_STATE, VIDEO_TOOL_ACTION_NAME, VIDEO_TOOL_STATE, WEAVE_ARROW_NODE_TYPE, WEAVE_COMMENTS_RENDERER_KEY, WEAVE_COMMENTS_TOOL_LAYER_ID, WEAVE_COMMENT_CREATE_ACTION, WEAVE_COMMENT_NODE_ACTION, WEAVE_COMMENT_NODE_DEFAULTS, WEAVE_COMMENT_NODE_TYPE, WEAVE_COMMENT_STATUS, WEAVE_COMMENT_TOOL_ACTION_NAME, WEAVE_COMMENT_TOOL_DEFAULT_CONFIG, WEAVE_COMMENT_TOOL_STATE, WEAVE_COMMENT_VIEW_ACTION, WEAVE_CONNECTOR_NODE_ANCHOR_ORIGIN, WEAVE_CONNECTOR_NODE_DECORATOR_TYPE, WEAVE_CONNECTOR_NODE_DEFAULT_CONFIG, WEAVE_CONNECTOR_NODE_LINE_ORIGIN, WEAVE_CONNECTOR_NODE_LINE_TYPE, WEAVE_CONNECTOR_NODE_TYPE, WEAVE_COPY_PASTE_CONFIG_DEFAULT, WEAVE_COPY_PASTE_NODES_KEY, WEAVE_COPY_PASTE_PASTE_CATCHER_ID, WEAVE_COPY_PASTE_PASTE_MODES, WEAVE_DEFAULT_USER_INFO_FUNCTION, WEAVE_ELLIPSE_NODE_TYPE, WEAVE_FRAME_DEFAULT_BACKGROUND_COLOR, WEAVE_FRAME_NODE_DEFAULT_CONFIG, WEAVE_FRAME_NODE_DEFAULT_PROPS, WEAVE_FRAME_NODE_TYPE, WEAVE_GRID_DEFAULT_CONFIG, WEAVE_GRID_DOT_TYPES, WEAVE_GRID_LAYER_ID, WEAVE_GRID_TYPES, WEAVE_GROUP_NODE_TYPE, WEAVE_IMAGES_TOOL_ACTION_NAME, WEAVE_IMAGES_TOOL_DEFAULT_CONFIG, WEAVE_IMAGES_TOOL_STATE, WEAVE_IMAGES_TOOL_UPLOAD_TYPE, WEAVE_IMAGE_CROP_ANCHOR_POSITION, WEAVE_IMAGE_CROP_END_TYPE, WEAVE_IMAGE_DEFAULT_CONFIG, WEAVE_IMAGE_NODE_TYPE, WEAVE_IMAGE_TOOL_ACTION_NAME, WEAVE_IMAGE_TOOL_CONFIG_DEFAULT, WEAVE_IMAGE_TOOL_STATE, WEAVE_IMAGE_TOOL_UPLOAD_TYPE, WEAVE_LAYER_NODE_TYPE, WEAVE_LINE_NODE_DEFAULT_CONFIG, WEAVE_LINE_NODE_TYPE, WEAVE_MEASURE_NODE_DEFAULT_CONFIG, WEAVE_MEASURE_NODE_TYPE, WEAVE_MEASURE_TOOL_DEFAULT_CONFIG, WEAVE_NODES_DISTANCE_SNAPPING_PLUGIN_KEY, WEAVE_NODES_EDGE_SNAPPING_PLUGIN_KEY, WEAVE_NODES_MULTI_SELECTION_FEEDBACK_PLUGIN_DEFAULT_CONFIG, WEAVE_NODES_MULTI_SELECTION_FEEDBACK_PLUGIN_KEY, WEAVE_NODES_MULTI_SELECTION_FEEDBACK_PLUGIN_LAYER_ID, WEAVE_NODES_SELECTION_DEFAULT_CONFIG, WEAVE_NODES_SELECTION_KEY, WEAVE_NODES_SELECTION_LAYER_ID, WEAVE_RECTANGLE_NODE_TYPE, WEAVE_REGULAR_POLYGON_NODE_TYPE, WEAVE_STAGE_DEFAULT_MODE, WEAVE_STAGE_DROP_AREA_KEY, WEAVE_STAGE_GRID_PLUGIN_KEY, WEAVE_STAGE_IMAGE_CROPPING_MODE, WEAVE_STAGE_KEYBOARD_MOVE_DEFAULT_CONFIG, WEAVE_STAGE_KEYBOARD_MOVE_KEY, WEAVE_STAGE_MINIMAP_KEY, WEAVE_STAGE_NODE_TYPE, WEAVE_STAGE_PANNING_DEFAULT_CONFIG, WEAVE_STAGE_PANNING_KEY, WEAVE_STAGE_PANNING_THROTTLE_MS, WEAVE_STAGE_TEXT_EDITION_MODE, WEAVE_STAGE_ZOOM_DEFAULT_CONFIG, WEAVE_STAGE_ZOOM_KEY, WEAVE_STAGE_ZOOM_TYPE, WEAVE_STAR_NODE_TYPE, WEAVE_STROKE_NODE_DEFAULT_CONFIG, WEAVE_STROKE_NODE_TYPE, WEAVE_STROKE_SINGLE_NODE_DEFAULT_CONFIG, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE, WEAVE_STROKE_SINGLE_NODE_TIP_TYPE, WEAVE_STROKE_SINGLE_NODE_TYPE, WEAVE_STROKE_TOOL_ACTION_NAME, WEAVE_STROKE_TOOL_ACTION_NAME_ALIASES, WEAVE_STROKE_TOOL_DEFAULT_CONFIG, WEAVE_STROKE_TOOL_STATE, WEAVE_TEXT_NODE_DEFAULT_CONFIG, WEAVE_TEXT_NODE_TYPE, WEAVE_USERS_POINTERS_CONFIG_DEFAULT_PROPS, WEAVE_USERS_POINTERS_KEY, WEAVE_USERS_PRESENCE_CONFIG_DEFAULT_PROPS, WEAVE_USERS_PRESENCE_PLUGIN_KEY, WEAVE_USERS_SELECTION_KEY, WEAVE_USER_POINTER_KEY, WEAVE_USER_PRESENCE_KEY, WEAVE_USER_SELECTION_KEY, WEAVE_VIDEO_DEFAULT_CONFIG, WEAVE_VIDEO_NODE_TYPE, Weave, WeaveAction, WeaveAlignNodesToolAction, WeaveArrowNode, WeaveArrowToolAction, WeaveBrushToolAction, WeaveCommentNode, WeaveCommentToolAction, WeaveCommentsRendererPlugin, WeaveConnectedUsersPlugin, WeaveConnectorNode, WeaveConnectorToolAction, WeaveContextMenuPlugin, WeaveCopyPasteNodesPlugin, WeaveEllipseNode, WeaveEllipseToolAction, WeaveEraserToolAction, WeaveExportNodesToolAction, WeaveExportStageToolAction, WeaveFitToScreenToolAction, WeaveFitToSelectionToolAction, WeaveFrameNode, WeaveFrameToolAction, WeaveGroupNode, WeaveImageNode, WeaveImageToolAction, WeaveImagesToolAction, WeaveLayerNode, WeaveLineNode, WeaveLineToolAction, WeaveMeasureNode, WeaveMeasureToolAction, WeaveMoveToolAction, WeaveNode, WeaveNodesDistanceSnappingPlugin, WeaveNodesEdgeSnappingPlugin, WeaveNodesMultiSelectionFeedbackPlugin, WeaveNodesSelectionPlugin, WeavePenToolAction, WeavePlugin, WeaveRectangleNode, WeaveRectangleToolAction, WeaveRegularPolygonNode, WeaveRegularPolygonToolAction, WeaveRenderer, WeaveSelectionToolAction, WeaveStageDropAreaPlugin, WeaveStageGridPlugin, WeaveStageKeyboardMovePlugin, WeaveStageMinimapPlugin, WeaveStageNode, WeaveStagePanningPlugin, WeaveStageResizePlugin, WeaveStageZoomPlugin, WeaveStarNode, WeaveStarToolAction, WeaveStore, WeaveStrokeNode, WeaveStrokeSingleNode, WeaveStrokeToolAction, WeaveTextNode, WeaveTextToolAction, WeaveUsersPointersPlugin, WeaveUsersPresencePlugin, WeaveUsersSelectionPlugin, WeaveVideoNode, WeaveVideoToolAction, WeaveZoomInToolAction, WeaveZoomOutToolAction, canComposite, clearContainerTargets, containerOverCursor, containsNodeDeep, defaultInitialState, downscaleImageFile, downscaleImageFromURL, getBoundingBox, getDownscaleRatio, getExportBoundingBox, getImageSizeFromFile, getJSONFromYjsBinary, getPositionRelativeToContainerOnPosition, getSelectedNodesMetadata, getStageClickPoint, getTargetAndSkipNodes, getTargetedNode, getTopmostShadowHost, getVisibleNodes, getVisibleNodesInViewport, hasFrames, hasImages, intersectArrays, isArray, isIOS, isInShadowDOM, isNodeInSelection, isObject, isServer, loadImageSource, mapJsonToYjsArray, mapJsonToYjsElements, mapJsonToYjsMap, memoize, mergeExceptArrays, moveNodeToContainer, moveNodeToContainerNT, resetScale, setupCanvasBackend, setupSkiaBackend, weavejsToYjsBinary };
40634
+ export { ALIGN_NODES_ALIGN_TO, ALIGN_NODES_TOOL_ACTION_NAME, ALIGN_NODES_TOOL_STATE, BRUSH_TOOL_ACTION_NAME, BRUSH_TOOL_DEFAULT_CONFIG, BRUSH_TOOL_STATE, CONNECTOR_TOOL_ACTION_NAME, CONNECTOR_TOOL_DEFAULT_CONFIG, CONNECTOR_TOOL_STATE, COPY_PASTE_NODES_PLUGIN_STATE, ELLIPSE_TOOL_ACTION_NAME, ELLIPSE_TOOL_STATE, ERASER_TOOL_ACTION_NAME, ERASER_TOOL_STATE, FRAME_TOOL_ACTION_NAME, FRAME_TOOL_STATE, GUIDE_DISTANCE_LINE_DEFAULT_CONFIG, GUIDE_ENTER_SNAPPING_TOLERANCE, GUIDE_EXIT_SNAPPING_TOLERANCE, GUIDE_HORIZONTAL_LINE_NAME, GUIDE_LINE_DEFAULT_CONFIG, GUIDE_LINE_DRAG_SNAPPING_THRESHOLD, GUIDE_LINE_NAME, GUIDE_LINE_TRANSFORM_SNAPPING_THRESHOLD, GUIDE_ORIENTATION, GUIDE_VERTICAL_LINE_NAME, LINE_TOOL_ACTION_NAME, LINE_TOOL_DEFAULT_CONFIG, LINE_TOOL_STATE, MEASURE_TOOL_ACTION_NAME, MEASURE_TOOL_STATE, MOVE_TOOL_ACTION_NAME, MOVE_TOOL_STATE, NODE_SNAP, NODE_SNAP_HORIZONTAL, NODE_SNAP_VERTICAL, PEN_TOOL_ACTION_NAME, PEN_TOOL_STATE, RECTANGLE_TOOL_ACTION_NAME, RECTANGLE_TOOL_STATE, REGULAR_POLYGON_TOOL_ACTION_NAME, REGULAR_POLYGON_TOOL_STATE, SELECTION_TOOL_ACTION_NAME, SELECTION_TOOL_STATE, STAGE_MINIMAP_DEFAULT_CONFIG, STAR_TOOL_ACTION_NAME, STAR_TOOL_STATE, TEXT_LAYOUT, TEXT_TOOL_ACTION_NAME, TEXT_TOOL_STATE, VIDEO_TOOL_ACTION_NAME, VIDEO_TOOL_STATE, WEAVE_ARROW_NODE_TYPE, WEAVE_ARROW_TOOL_ACTION_NAME, WEAVE_ARROW_TOOL_STATE, WEAVE_COMMENTS_RENDERER_KEY, WEAVE_COMMENTS_TOOL_LAYER_ID, WEAVE_COMMENT_CREATE_ACTION, WEAVE_COMMENT_NODE_ACTION, WEAVE_COMMENT_NODE_DEFAULTS, WEAVE_COMMENT_NODE_TYPE, WEAVE_COMMENT_STATUS, WEAVE_COMMENT_TOOL_ACTION_NAME, WEAVE_COMMENT_TOOL_DEFAULT_CONFIG, WEAVE_COMMENT_TOOL_STATE, WEAVE_COMMENT_VIEW_ACTION, WEAVE_CONNECTOR_NODE_ANCHOR_ORIGIN, WEAVE_CONNECTOR_NODE_DECORATOR_TYPE, WEAVE_CONNECTOR_NODE_DEFAULT_CONFIG, WEAVE_CONNECTOR_NODE_LINE_ORIGIN, WEAVE_CONNECTOR_NODE_LINE_TYPE, WEAVE_CONNECTOR_NODE_TYPE, WEAVE_COPY_PASTE_CONFIG_DEFAULT, WEAVE_COPY_PASTE_NODES_KEY, WEAVE_COPY_PASTE_PASTE_CATCHER_ID, WEAVE_COPY_PASTE_PASTE_MODES, WEAVE_DEFAULT_USER_INFO_FUNCTION, WEAVE_ELLIPSE_NODE_TYPE, WEAVE_FRAME_DEFAULT_BACKGROUND_COLOR, WEAVE_FRAME_NODE_DEFAULT_CONFIG, WEAVE_FRAME_NODE_DEFAULT_PROPS, WEAVE_FRAME_NODE_TYPE, WEAVE_GRID_DEFAULT_CONFIG, WEAVE_GRID_DOT_TYPES, WEAVE_GRID_LAYER_ID, WEAVE_GRID_TYPES, WEAVE_GROUP_NODE_TYPE, WEAVE_IMAGES_TOOL_ACTION_NAME, WEAVE_IMAGES_TOOL_DEFAULT_CONFIG, WEAVE_IMAGES_TOOL_STATE, WEAVE_IMAGES_TOOL_UPLOAD_TYPE, WEAVE_IMAGE_CROP_ANCHOR_POSITION, WEAVE_IMAGE_CROP_END_TYPE, WEAVE_IMAGE_DEFAULT_CONFIG, WEAVE_IMAGE_NODE_TYPE, WEAVE_IMAGE_TOOL_ACTION_NAME, WEAVE_IMAGE_TOOL_CONFIG_DEFAULT, WEAVE_IMAGE_TOOL_STATE, WEAVE_IMAGE_TOOL_UPLOAD_TYPE, WEAVE_LAYER_NODE_TYPE, WEAVE_LINE_NODE_DEFAULT_CONFIG, WEAVE_LINE_NODE_TYPE, WEAVE_MEASURE_NODE_DEFAULT_CONFIG, WEAVE_MEASURE_NODE_TYPE, WEAVE_MEASURE_TOOL_DEFAULT_CONFIG, WEAVE_NODES_DISTANCE_SNAPPING_PLUGIN_KEY, WEAVE_NODES_EDGE_SNAPPING_PLUGIN_KEY, WEAVE_NODES_MULTI_SELECTION_FEEDBACK_PLUGIN_DEFAULT_CONFIG, WEAVE_NODES_MULTI_SELECTION_FEEDBACK_PLUGIN_KEY, WEAVE_NODES_MULTI_SELECTION_FEEDBACK_PLUGIN_LAYER_ID, WEAVE_NODES_SELECTION_DEFAULT_CONFIG, WEAVE_NODES_SELECTION_KEY, WEAVE_NODES_SELECTION_LAYER_ID, WEAVE_RECTANGLE_NODE_TYPE, WEAVE_REGULAR_POLYGON_NODE_TYPE, WEAVE_STAGE_DEFAULT_MODE, WEAVE_STAGE_DROP_AREA_KEY, WEAVE_STAGE_GRID_PLUGIN_KEY, WEAVE_STAGE_IMAGE_CROPPING_MODE, WEAVE_STAGE_KEYBOARD_MOVE_DEFAULT_CONFIG, WEAVE_STAGE_KEYBOARD_MOVE_KEY, WEAVE_STAGE_MINIMAP_KEY, WEAVE_STAGE_NODE_TYPE, WEAVE_STAGE_PANNING_DEFAULT_CONFIG, WEAVE_STAGE_PANNING_KEY, WEAVE_STAGE_PANNING_THROTTLE_MS, WEAVE_STAGE_TEXT_EDITION_MODE, WEAVE_STAGE_ZOOM_DEFAULT_CONFIG, WEAVE_STAGE_ZOOM_KEY, WEAVE_STAGE_ZOOM_TYPE, WEAVE_STAR_NODE_TYPE, WEAVE_STROKE_NODE_DEFAULT_CONFIG, WEAVE_STROKE_NODE_TYPE, WEAVE_STROKE_SINGLE_NODE_DEFAULT_CONFIG, WEAVE_STROKE_SINGLE_NODE_TIP_SIDE, WEAVE_STROKE_SINGLE_NODE_TIP_TYPE, WEAVE_STROKE_SINGLE_NODE_TYPE, WEAVE_STROKE_TOOL_ACTION_NAME, WEAVE_STROKE_TOOL_ACTION_NAME_ALIASES, WEAVE_STROKE_TOOL_DEFAULT_CONFIG, WEAVE_STROKE_TOOL_STATE, WEAVE_TEXT_NODE_DEFAULT_CONFIG, WEAVE_TEXT_NODE_TYPE, WEAVE_USERS_POINTERS_CONFIG_DEFAULT_PROPS, WEAVE_USERS_POINTERS_KEY, WEAVE_USERS_PRESENCE_CONFIG_DEFAULT_PROPS, WEAVE_USERS_PRESENCE_PLUGIN_KEY, WEAVE_USERS_SELECTION_KEY, WEAVE_USER_POINTER_KEY, WEAVE_USER_PRESENCE_KEY, WEAVE_USER_SELECTION_KEY, WEAVE_VIDEO_DEFAULT_CONFIG, WEAVE_VIDEO_NODE_TYPE, Weave, WeaveAction, WeaveAlignNodesToolAction, WeaveArrowNode, WeaveArrowToolAction, WeaveBrushToolAction, WeaveCommentNode, WeaveCommentToolAction, WeaveCommentsRendererPlugin, WeaveConnectedUsersPlugin, WeaveConnectorNode, WeaveConnectorToolAction, WeaveContextMenuPlugin, WeaveCopyPasteNodesPlugin, WeaveEllipseNode, WeaveEllipseToolAction, WeaveEraserToolAction, WeaveExportNodesToolAction, WeaveExportStageToolAction, WeaveFitToScreenToolAction, WeaveFitToSelectionToolAction, WeaveFrameNode, WeaveFrameToolAction, WeaveGroupNode, WeaveImageNode, WeaveImageToolAction, WeaveImagesToolAction, WeaveLayerNode, WeaveLineNode, WeaveLineToolAction, WeaveMeasureNode, WeaveMeasureToolAction, WeaveMoveToolAction, WeaveNode, WeaveNodesDistanceSnappingPlugin, WeaveNodesEdgeSnappingPlugin, WeaveNodesMultiSelectionFeedbackPlugin, WeaveNodesSelectionPlugin, WeavePenToolAction, WeavePlugin, WeaveRectangleNode, WeaveRectangleToolAction, WeaveRegularPolygonNode, WeaveRegularPolygonToolAction, WeaveRenderer, WeaveSelectionToolAction, WeaveStageDropAreaPlugin, WeaveStageGridPlugin, WeaveStageKeyboardMovePlugin, WeaveStageMinimapPlugin, WeaveStageNode, WeaveStagePanningPlugin, WeaveStageResizePlugin, WeaveStageZoomPlugin, WeaveStarNode, WeaveStarToolAction, WeaveStore, WeaveStrokeNode, WeaveStrokeSingleNode, WeaveStrokeToolAction, WeaveTextNode, WeaveTextToolAction, WeaveUsersPointersPlugin, WeaveUsersPresencePlugin, WeaveUsersSelectionPlugin, WeaveVideoNode, WeaveVideoToolAction, WeaveZoomInToolAction, WeaveZoomOutToolAction, canComposite, clearContainerTargets, containerOverCursor, containsNodeDeep, defaultInitialState, downscaleImageFile, downscaleImageFromURL, getBoundingBox, getDownscaleRatio, getExportBoundingBox, getImageSizeFromFile, getJSONFromYjsBinary, getPositionRelativeToContainerOnPosition, getSelectedNodesMetadata, getStageClickPoint, getTargetAndSkipNodes, getTargetedNode, getTopmostShadowHost, getVisibleNodes, getVisibleNodesInViewport, hasFrames, hasImages, intersectArrays, isArray, isIOS, isInShadowDOM, isNodeInSelection, isObject, isServer, loadImageSource, mapJsonToYjsArray, mapJsonToYjsElements, mapJsonToYjsMap, memoize, mergeExceptArrays, moveNodeToContainer, moveNodeToContainerNT, resetScale, setupCanvasBackend, setupSkiaBackend, weavejsToYjsBinary };
40028
40635
  //# sourceMappingURL=types.js.map