@inditextech/weave-sdk 3.4.0 → 3.6.0-SNAPSHOT.112.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/sdk.node.js CHANGED
@@ -15083,6 +15083,11 @@ var WeaveStore = class {
15083
15083
  getDocument() {
15084
15084
  return this.document;
15085
15085
  }
15086
+ restartDocument() {
15087
+ this.latestState = { weave: {} };
15088
+ this.state = syncedStore({ weave: {} });
15089
+ this.document = getYjsDoc(this.state);
15090
+ }
15086
15091
  loadDocument(roomData) {
15087
15092
  yjs_default.applyUpdate(this.document, roomData);
15088
15093
  }
@@ -17958,6 +17963,15 @@ var WeaveContextMenuPlugin = class extends WeavePlugin {
17958
17963
  initLayer = void 0;
17959
17964
  constructor(params) {
17960
17965
  super();
17966
+ const { config } = params ?? {};
17967
+ this.config = {
17968
+ xOffset: WEAVE_CONTEXT_MENU_X_OFFSET_DEFAULT,
17969
+ yOffset: WEAVE_CONTEXT_MENU_Y_OFFSET_DEFAULT,
17970
+ ...config
17971
+ };
17972
+ this.initialize();
17973
+ }
17974
+ initialize() {
17961
17975
  this.timer = null;
17962
17976
  this.tapHold = false;
17963
17977
  this.contextMenuVisible = false;
@@ -17967,12 +17981,6 @@ var WeaveContextMenuPlugin = class extends WeavePlugin {
17967
17981
  time: 0
17968
17982
  };
17969
17983
  this.tapHoldTimeout = WEAVE_CONTEXT_MENU_TAP_HOLD_TIMEOUT;
17970
- const { config } = params ?? {};
17971
- this.config = {
17972
- xOffset: WEAVE_CONTEXT_MENU_X_OFFSET_DEFAULT,
17973
- yOffset: WEAVE_CONTEXT_MENU_Y_OFFSET_DEFAULT,
17974
- ...config
17975
- };
17976
17984
  this.pointers = {};
17977
17985
  }
17978
17986
  getName() {
@@ -18576,16 +18584,23 @@ const WEAVE_GRID_TYPES = {
18576
18584
  ["LINES"]: "lines",
18577
18585
  ["DOTS"]: "dots"
18578
18586
  };
18579
- const WEAVE_GRID_DEFAULT_SIZE = 50;
18580
- const WEAVE_GRID_DEFAULT_TYPE = WEAVE_GRID_TYPES.LINES;
18581
- const WEAVE_GRID_DEFAULT_COLOR = "rgba(0,0,0,0.1)";
18582
- const WEAVE_GRID_DEFAULT_ORIGIN_COLOR = "rgba(255,0,0,0.1)";
18583
- const WEAVE_GRID_DEFAULT_STROKE = .5;
18584
- const WEAVE_GRID_DEFAULT_MAJOR_LINE_RATIO = 4;
18585
- const WEAVE_GRID_DEFAULT_RADIUS = 1;
18586
- const WEAVE_GRID_DEFAULT_MAJOR_DOT_RATIO = 2;
18587
- const WEAVE_GRID_DEFAULT_MAJOR_EVERY = 10;
18588
- const WEAVE_GRID_DEFAULT_DOT_MAX_DOTS_PER_AXIS = 125;
18587
+ const WEAVE_GRID_DOT_TYPES = {
18588
+ ["SQUARE"]: "square",
18589
+ ["CIRCLE"]: "circle"
18590
+ };
18591
+ const WEAVE_GRID_DEFAULT_CONFIG = {
18592
+ type: WEAVE_GRID_TYPES.LINES,
18593
+ gridColor: "#b3b3b3",
18594
+ gridMajorColor: "#b3b3b3",
18595
+ gridOriginColor: "#ff746c",
18596
+ gridSize: 20,
18597
+ gridMajorEvery: 10,
18598
+ gridMajorRatio: 2,
18599
+ gridStroke: 1,
18600
+ gridDotType: WEAVE_GRID_DOT_TYPES.CIRCLE,
18601
+ gridDotRadius: 1,
18602
+ gridDotRectSize: 2
18603
+ };
18589
18604
  const WEAVE_GRID_LAYER_ID = "gridLayer";
18590
18605
 
18591
18606
  //#endregion
@@ -18616,7 +18631,10 @@ const DEFAULT_ADD_NODE_OPTIONS = { emitUserChangeEvent: false };
18616
18631
  const DEFAULT_UPDATE_NODE_OPTIONS = { emitUserChangeEvent: false };
18617
18632
  const DEFAULT_REMOVE_NODE_OPTIONS = { emitUserChangeEvent: false };
18618
18633
  const DEFAULT_MOVE_NODE_OPTIONS = { emitUserChangeEvent: false };
18619
- const WEAVE_DEFAULT_CONFIG = { behaviors: { axisLockThreshold: 5 } };
18634
+ const WEAVE_DEFAULT_CONFIG = {
18635
+ behaviors: { axisLockThreshold: 5 },
18636
+ performance: { upscale: { enabled: false } }
18637
+ };
18620
18638
 
18621
18639
  //#endregion
18622
18640
  //#region src/plugins/users-presence/constants.ts
@@ -18645,6 +18663,9 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
18645
18663
  constructor(params) {
18646
18664
  super();
18647
18665
  this.config = mergeExceptArrays(WEAVE_NODES_SELECTION_DEFAULT_CONFIG, params?.config ?? {});
18666
+ this.initialize();
18667
+ }
18668
+ initialize() {
18648
18669
  this.defaultEnabledAnchors = this.config.selection?.enabledAnchors ?? [
18649
18670
  "top-left",
18650
18671
  "top-center",
@@ -18808,7 +18829,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
18808
18829
  nodeHovered = void 0;
18809
18830
  }
18810
18831
  this.instance.getStage().handleMouseover?.();
18811
- });
18832
+ }, { signal: this.instance.getEventsController()?.signal });
18812
18833
  const handleTransform = (e) => {
18813
18834
  const moved = this.checkMoved(e);
18814
18835
  if (moved) this.getContextMenuPlugin()?.cancelLongPressTimer();
@@ -19223,11 +19244,11 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
19223
19244
  });
19224
19245
  return;
19225
19246
  }
19226
- });
19247
+ }, { signal: this.instance.getEventsController()?.signal });
19227
19248
  stage.container().addEventListener("keyup", (e) => {
19228
19249
  if (!(e.ctrlKey || e.metaKey)) this.isCtrlMetaPressed = false;
19229
19250
  if (e.code === "Space") this.isSpaceKeyPressed = false;
19230
- });
19251
+ }, { signal: this.instance.getEventsController()?.signal });
19231
19252
  stage.on("pointerdown", (e) => {
19232
19253
  this.setTapStart(e);
19233
19254
  this.handledClickOrTap = false;
@@ -19434,7 +19455,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
19434
19455
  if (existNode) newSelectedNodes.push(existNode);
19435
19456
  }
19436
19457
  this.tr.nodes([...newSelectedNodes]);
19437
- this.tr.forceUpdate();
19458
+ if (newSelectedNodes.length > 0) this.tr.forceUpdate();
19438
19459
  this.triggerSelectedNodesEvent();
19439
19460
  }
19440
19461
  getSelectionPlugin() {
@@ -19687,6 +19708,9 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
19687
19708
  super();
19688
19709
  this.getImageBase64 = params.getImageBase64;
19689
19710
  this.config = mergeExceptArrays(WEAVE_COPY_PASTE_CONFIG_DEFAULT, params?.config);
19711
+ this.initialize();
19712
+ }
19713
+ initialize() {
19690
19714
  this.actualInternalPaddingX = 0;
19691
19715
  this.actualInternalPaddingY = 0;
19692
19716
  this.lastInternalPasteSnapshot = "";
@@ -19792,7 +19816,7 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
19792
19816
  this.focusPasteCatcher();
19793
19817
  if (!this.enabled) return;
19794
19818
  }
19795
- });
19819
+ }, { signal: this.instance.getEventsController()?.signal });
19796
19820
  if (catcher) catcher.addEventListener("paste", async (e) => {
19797
19821
  e.preventDefault();
19798
19822
  let items = void 0;
@@ -19811,7 +19835,7 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
19811
19835
  return;
19812
19836
  }
19813
19837
  this.sendExternalPasteEvent(void 0, items);
19814
- });
19838
+ }, { signal: this.instance.getEventsController()?.signal });
19815
19839
  }
19816
19840
  sendExternalPasteEvent(dataList, items) {
19817
19841
  const stage = this.instance.getStage();
@@ -21966,11 +21990,34 @@ var WeaveRegisterManager = class {
21966
21990
  }
21967
21991
  }
21968
21992
  }
21993
+ resetNodesHandlers() {
21994
+ for (const nodeHandlerId of Object.keys(this.nodesHandlers)) {
21995
+ const nodeHandler = this.nodesHandlers[nodeHandlerId];
21996
+ nodeHandler.initialize?.();
21997
+ }
21998
+ }
21999
+ resetActionsHandlers() {
22000
+ for (const actionHandlerId of Object.keys(this.actionsHandlers)) {
22001
+ const actionHandler = this.actionsHandlers[actionHandlerId];
22002
+ actionHandler.initialize?.();
22003
+ }
22004
+ }
22005
+ resetPlugins() {
22006
+ for (const pluginId of Object.keys(this.plugins)) {
22007
+ const plugin = this.plugins[pluginId];
22008
+ plugin.initialize?.();
22009
+ }
22010
+ }
22011
+ reset() {
22012
+ this.resetNodesHandlers();
22013
+ this.resetActionsHandlers();
22014
+ this.resetPlugins();
22015
+ }
21969
22016
  };
21970
22017
 
21971
22018
  //#endregion
21972
22019
  //#region package.json
21973
- var version = "3.4.0";
22020
+ var version = "3.6.0-SNAPSHOT.112.1";
21974
22021
 
21975
22022
  //#endregion
21976
22023
  //#region src/managers/setup.ts
@@ -22087,6 +22134,11 @@ var WeaveStageManager = class {
22087
22134
  initialZIndex: void 0
22088
22135
  };
22089
22136
  const stage = new Konva.Stage({ ...props });
22137
+ if (!this.instance.isServerSide()) {
22138
+ const containerParent = stage.container().parentNode;
22139
+ stage.width(containerParent.clientWidth);
22140
+ stage.height(containerParent.clientHeight);
22141
+ }
22090
22142
  const realContainer = stage.container();
22091
22143
  if (realContainer !== void 0 && realContainer.style?.position !== "relative") realContainer.style.position = "relative";
22092
22144
  this.setStage(stage);
@@ -22219,6 +22271,10 @@ var WeaveExportManager = class {
22219
22271
  exportNodesAsImage(nodes, boundingNodes, options) {
22220
22272
  return new Promise((resolve) => {
22221
22273
  const { format = WEAVE_EXPORT_FORMATS.PNG, padding = 0, pixelRatio = 1, backgroundColor = WEAVE_EXPORT_BACKGROUND_COLOR } = options;
22274
+ const nodesSelectionPluginPrev = this.getNodesSelectionPlugin()?.isEnabled();
22275
+ const nodesDistanceSnappingPluginPrev = this.getNodesDistanceSnappingPlugin()?.isEnabled();
22276
+ const nodesEdgeSnappingPluginPrev = this.getNodesDistanceSnappingPlugin()?.isEnabled();
22277
+ const nodesStageGridPluginPrev = this.getStageGridPlugin()?.isEnabled();
22222
22278
  this.getNodesSelectionPlugin()?.disable();
22223
22279
  this.getNodesDistanceSnappingPlugin()?.disable();
22224
22280
  this.getNodesEdgeSnappingPlugin()?.disable();
@@ -22283,16 +22339,80 @@ var WeaveExportManager = class {
22283
22339
  stage.position(originalPosition);
22284
22340
  stage.scale(originalScale);
22285
22341
  stage.batchDraw();
22286
- this.getNodesSelectionPlugin()?.enable();
22287
- this.getNodesDistanceSnappingPlugin()?.enable();
22288
- this.getNodesEdgeSnappingPlugin()?.enable();
22289
- this.getStageGridPlugin()?.enable();
22342
+ if (nodesSelectionPluginPrev) this.getNodesSelectionPlugin()?.enable();
22343
+ if (nodesDistanceSnappingPluginPrev) this.getNodesDistanceSnappingPlugin()?.enable();
22344
+ if (nodesEdgeSnappingPluginPrev) this.getNodesEdgeSnappingPlugin()?.enable();
22345
+ if (nodesStageGridPluginPrev) this.getStageGridPlugin()?.enable();
22290
22346
  resolve(img);
22291
22347
  }
22292
22348
  });
22293
22349
  }
22294
22350
  });
22295
22351
  }
22352
+ exportAreaAsImage(area, options) {
22353
+ return new Promise((resolve) => {
22354
+ const { format = WEAVE_EXPORT_FORMATS.PNG, padding = 0, pixelRatio = 1, backgroundColor = WEAVE_EXPORT_BACKGROUND_COLOR } = options;
22355
+ const nodesSelectionPluginPrev = this.getNodesSelectionPlugin()?.isEnabled();
22356
+ const nodesDistanceSnappingPluginPrev = this.getNodesDistanceSnappingPlugin()?.isEnabled();
22357
+ const nodesEdgeSnappingPluginPrev = this.getNodesDistanceSnappingPlugin()?.isEnabled();
22358
+ const nodesStageGridPluginPrev = this.getStageGridPlugin()?.isEnabled();
22359
+ this.getNodesSelectionPlugin()?.disable();
22360
+ this.getNodesDistanceSnappingPlugin()?.disable();
22361
+ this.getNodesEdgeSnappingPlugin()?.disable();
22362
+ this.getStageGridPlugin()?.disable();
22363
+ const stage = this.instance.getStage();
22364
+ const mainLayer = this.instance.getMainLayer();
22365
+ if (!mainLayer) throw new Error("Main layer not found");
22366
+ const originalPosition = {
22367
+ x: stage.x(),
22368
+ y: stage.y()
22369
+ };
22370
+ const originalScale = {
22371
+ x: stage.scaleX(),
22372
+ y: stage.scaleY()
22373
+ };
22374
+ stage.scale({
22375
+ x: 1,
22376
+ y: 1
22377
+ });
22378
+ stage.position({
22379
+ x: 0,
22380
+ y: 0
22381
+ });
22382
+ const bounds = area;
22383
+ const background = new Konva.Rect({
22384
+ x: bounds.x - padding,
22385
+ y: bounds.y - padding,
22386
+ width: bounds.width + 2 * padding,
22387
+ height: bounds.height + 2 * padding,
22388
+ strokeWidth: 0,
22389
+ fill: backgroundColor
22390
+ });
22391
+ mainLayer.add(background);
22392
+ background.moveToBottom();
22393
+ stage.batchDraw();
22394
+ stage.toImage({
22395
+ x: area.x,
22396
+ y: area.y,
22397
+ width: area.width,
22398
+ height: area.height,
22399
+ mimeType: format,
22400
+ pixelRatio,
22401
+ quality: options.quality ?? 1,
22402
+ callback: (img) => {
22403
+ background.destroy();
22404
+ stage.position(originalPosition);
22405
+ stage.scale(originalScale);
22406
+ stage.batchDraw();
22407
+ if (nodesSelectionPluginPrev) this.getNodesSelectionPlugin()?.enable();
22408
+ if (nodesDistanceSnappingPluginPrev) this.getNodesDistanceSnappingPlugin()?.enable();
22409
+ if (nodesEdgeSnappingPluginPrev) this.getNodesEdgeSnappingPlugin()?.enable();
22410
+ if (nodesStageGridPluginPrev) this.getStageGridPlugin()?.enable();
22411
+ resolve(img);
22412
+ }
22413
+ });
22414
+ });
22415
+ }
22296
22416
  async exportNodesServerSide(nodes, boundingNodes, options) {
22297
22417
  const { format = WEAVE_EXPORT_FORMATS.PNG, padding = 0, pixelRatio = 1, backgroundColor = WEAVE_EXPORT_BACKGROUND_COLOR } = options;
22298
22418
  this.getNodesSelectionPlugin()?.disable();
@@ -22395,6 +22515,91 @@ var WeaveExportManager = class {
22395
22515
  height: imageHeight * pixelRatio
22396
22516
  };
22397
22517
  }
22518
+ async exportAreaServerSide(area, options) {
22519
+ const { format = WEAVE_EXPORT_FORMATS.PNG, padding = 0, pixelRatio = 1, backgroundColor = WEAVE_EXPORT_BACKGROUND_COLOR } = options;
22520
+ this.getNodesSelectionPlugin()?.disable();
22521
+ this.getNodesDistanceSnappingPlugin()?.disable();
22522
+ this.getNodesEdgeSnappingPlugin()?.disable();
22523
+ this.getStageGridPlugin()?.disable();
22524
+ const stage = this.instance.getStage();
22525
+ const mainLayer = this.instance.getMainLayer();
22526
+ if (!mainLayer) throw new Error("Main layer not found");
22527
+ const originalPosition = {
22528
+ x: stage.x(),
22529
+ y: stage.y()
22530
+ };
22531
+ const originalScale = {
22532
+ x: stage.scaleX(),
22533
+ y: stage.scaleY()
22534
+ };
22535
+ stage.scale({
22536
+ x: 1,
22537
+ y: 1
22538
+ });
22539
+ const bounds = area;
22540
+ const scaleX = stage.scaleX();
22541
+ const scaleY = stage.scaleY();
22542
+ const unscaledBounds = {
22543
+ x: bounds.x / scaleX,
22544
+ y: bounds.y / scaleY,
22545
+ width: bounds.width / scaleX,
22546
+ height: bounds.height / scaleY
22547
+ };
22548
+ const background = new Konva.Rect({
22549
+ x: unscaledBounds.x - padding,
22550
+ y: unscaledBounds.y - padding,
22551
+ width: unscaledBounds.width + 2 * padding,
22552
+ height: unscaledBounds.height + 2 * padding,
22553
+ strokeWidth: 0,
22554
+ fill: backgroundColor
22555
+ });
22556
+ mainLayer.add(background);
22557
+ background.moveToBottom();
22558
+ const backgroundRect = background.getClientRect({ relativeTo: stage });
22559
+ const composites = [];
22560
+ const imageWidth = Math.round(backgroundRect.width);
22561
+ const imageHeight = Math.round(backgroundRect.height);
22562
+ const maxRenderSize = 1920;
22563
+ const cols = Math.ceil(imageWidth / maxRenderSize);
22564
+ const rows = Math.ceil(imageHeight / maxRenderSize);
22565
+ const tileWidth = Math.floor(imageWidth / cols);
22566
+ const tileHeight = Math.floor(imageHeight / rows);
22567
+ for (let y = 0; y < imageHeight; y += tileHeight) for (let x = 0; x < imageWidth; x += tileWidth) {
22568
+ const width = Math.min(tileWidth, imageWidth - x);
22569
+ const height = Math.min(tileHeight, imageHeight - y);
22570
+ const canvas = await mainLayer.toCanvas({
22571
+ x: Math.round(backgroundRect.x) + x,
22572
+ y: Math.round(backgroundRect.y) + y,
22573
+ width,
22574
+ height,
22575
+ mimeType: format,
22576
+ pixelRatio,
22577
+ quality: options.quality ?? 1
22578
+ });
22579
+ let buffer = null;
22580
+ if (globalThis._weave_serverSideBackend === WEAVE_KONVA_BACKEND.CANVAS) buffer = canvas.toBuffer();
22581
+ if (globalThis._weave_serverSideBackend === WEAVE_KONVA_BACKEND.SKIA) buffer = await canvas.toBuffer();
22582
+ if (!buffer) throw new Error("Failed to generate image buffer");
22583
+ composites.push({
22584
+ top: y * pixelRatio,
22585
+ left: x * pixelRatio,
22586
+ input: buffer
22587
+ });
22588
+ }
22589
+ background.destroy();
22590
+ stage.position(originalPosition);
22591
+ stage.scale(originalScale);
22592
+ stage.batchDraw();
22593
+ this.getNodesSelectionPlugin()?.enable();
22594
+ this.getNodesDistanceSnappingPlugin()?.enable();
22595
+ this.getNodesEdgeSnappingPlugin()?.enable();
22596
+ this.getStageGridPlugin()?.enable();
22597
+ return {
22598
+ composites,
22599
+ width: imageWidth * pixelRatio,
22600
+ height: imageHeight * pixelRatio
22601
+ };
22602
+ }
22398
22603
  imageToBase64(img, mimeType) {
22399
22604
  if (img.naturalWidth === 0 && img.naturalHeight === 0) throw new Error("Image has no content");
22400
22605
  const canvas = document.createElement("canvas");
@@ -22674,7 +22879,12 @@ var WeaveAsyncManager = class {
22674
22879
  this.instance.emitEvent("onAsyncElementChange");
22675
22880
  }, new Map());
22676
22881
  }
22882
+ reset() {
22883
+ this.asyncElements.clear();
22884
+ this.asyncElementsLoadedEventEmitted = false;
22885
+ }
22677
22886
  checkForAsyncElements(elements) {
22887
+ this.instance.emitEvent("onAsyncElementsIdle");
22678
22888
  const amountAsyncResourcesExtracted = this.extractAsyncResources(elements);
22679
22889
  if (amountAsyncResourcesExtracted === 0 && !this.asyncElementsLoadedEventEmitted) {
22680
22890
  this.instance.emitEvent("onAsyncElementsLoaded");
@@ -22727,7 +22937,7 @@ var WeaveAsyncManager = class {
22727
22937
  status: WEAVE_ASYNC_STATUS.LOADING
22728
22938
  };
22729
22939
  this.asyncElements.set(nodeId, element);
22730
- this.instance.emitEvent("onAsyncElementsLoading", {
22940
+ if (!this.asyncElementsLoadedEventEmitted) this.instance.emitEvent("onAsyncElementsLoading", {
22731
22941
  loaded: this.getAmountAsyncElementsLoaded(),
22732
22942
  total: this.getAmountAsyncElements()
22733
22943
  });
@@ -22740,11 +22950,11 @@ var WeaveAsyncManager = class {
22740
22950
  status: WEAVE_ASYNC_STATUS.LOADED
22741
22951
  };
22742
22952
  this.asyncElements.set(nodeId, element);
22743
- this.instance.emitEvent("onAsyncElementsLoading", {
22744
- loaded: this.getAmountAsyncElementsLoaded(),
22745
- total: this.getAmountAsyncElements()
22746
- });
22747
22953
  if (!this.asyncElementsLoadedEventEmitted) {
22954
+ this.instance.emitEvent("onAsyncElementsLoading", {
22955
+ loaded: this.getAmountAsyncElementsLoaded(),
22956
+ total: this.getAmountAsyncElements()
22957
+ });
22748
22958
  const allLoaded = this.asyncElementsLoaded();
22749
22959
  if (allLoaded) {
22750
22960
  this.instance.emitEvent("onAsyncElementsLoaded");
@@ -22869,6 +23079,7 @@ var Weave = class {
22869
23079
  constructor(weaveConfig, stageConfig) {
22870
23080
  globalThis._weave_isServerSide = false;
22871
23081
  if (typeof window === "undefined") globalThis._weave_isServerSide = true;
23082
+ this.eventsController = void 0;
22872
23083
  this.emitter = new Emittery();
22873
23084
  Konva.showWarnings = false;
22874
23085
  this.id = v4_default();
@@ -22914,6 +23125,7 @@ var Weave = class {
22914
23125
  this.initialized = true;
22915
23126
  this.status = WEAVE_INSTANCE_STATUS.RUNNING;
22916
23127
  this.emitEvent("onInstanceStatus", this.status);
23128
+ this.emitEvent("onRender");
22917
23129
  });
22918
23130
  }
22919
23131
  setStatus(status) {
@@ -22938,6 +23150,7 @@ var Weave = class {
22938
23150
  async start() {
22939
23151
  this.moduleLogger.info("Start instance");
22940
23152
  if (!this.isServerSide()) {
23153
+ this.eventsController = new AbortController();
22941
23154
  if (!window.weave) window.weave = this;
22942
23155
  }
22943
23156
  this.emitEvent("onRoomLoaded", false);
@@ -22961,8 +23174,39 @@ var Weave = class {
22961
23174
  store.setup();
22962
23175
  store.connect();
22963
23176
  }
23177
+ async switchRoom() {
23178
+ this.moduleLogger.info(`Switching room`);
23179
+ const nodeHandlers = this.registerManager.getNodesHandlers();
23180
+ for (const nodeHandlerKey of Object.keys(nodeHandlers)) {
23181
+ const nodeHandler = nodeHandlers[nodeHandlerKey];
23182
+ nodeHandler?.onDestroyInstance();
23183
+ }
23184
+ const stage = this.getStage();
23185
+ if (stage) stage.destroy();
23186
+ if (this.eventsController) this.eventsController.abort();
23187
+ if (!this.isServerSide()) this.eventsController = new AbortController();
23188
+ this.registerManager.reset();
23189
+ this.asyncManager.reset();
23190
+ this.moduleLogger.info("Switching room instance");
23191
+ if (!this.isServerSide()) {
23192
+ if (!window.weave) window.weave = this;
23193
+ }
23194
+ this.emitEvent("onRoomLoaded", false);
23195
+ this.status = WEAVE_INSTANCE_STATUS.STARTING;
23196
+ this.emitEvent("onInstanceStatus", this.status);
23197
+ this.registerManager.reset();
23198
+ this.status = WEAVE_INSTANCE_STATUS.LOADING_FONTS;
23199
+ this.emitEvent("onInstanceStatus", this.status);
23200
+ await this.fontsManager.loadFonts();
23201
+ this.setupManager.setupLog();
23202
+ this.stageManager.initStage();
23203
+ this.status = WEAVE_INSTANCE_STATUS.CONNECTING_TO_ROOM;
23204
+ this.emitEvent("onInstanceStatus", this.status);
23205
+ this.addEventListener("onStoreConnectionStatusChange", this.handleStoreConnectionStatusChange.bind(this));
23206
+ }
22964
23207
  destroy() {
22965
23208
  this.moduleLogger.info(`Destroying the instance`);
23209
+ if (this.eventsController) this.eventsController.abort();
22966
23210
  this.emitter.clearListeners();
22967
23211
  this.status = WEAVE_INSTANCE_STATUS.IDLE;
22968
23212
  this.emitEvent("onInstanceStatus", this.status);
@@ -23432,9 +23676,15 @@ var Weave = class {
23432
23676
  async exportNodesServerSide(nodes, boundingNodes, options) {
23433
23677
  return await this.exportManager.exportNodesServerSide(nodes, boundingNodes, options);
23434
23678
  }
23679
+ async exportAreaServerSide(area, options) {
23680
+ return await this.exportManager.exportAreaServerSide(area, options);
23681
+ }
23435
23682
  async exportNodes(nodes, boundingNodes, options) {
23436
23683
  return await this.exportManager.exportNodesAsImage(nodes, boundingNodes, options);
23437
23684
  }
23685
+ async exportArea(area, options) {
23686
+ return await this.exportManager.exportAreaAsImage(area, options);
23687
+ }
23438
23688
  getExportBoundingBox(nodesIds) {
23439
23689
  const nodes = [];
23440
23690
  for (const nodeId of nodesIds) {
@@ -23597,6 +23847,9 @@ var Weave = class {
23597
23847
  getDragProperties() {
23598
23848
  return this.dragAndDropManager.getDragProperties();
23599
23849
  }
23850
+ getEventsController() {
23851
+ return this.eventsController;
23852
+ }
23600
23853
  };
23601
23854
 
23602
23855
  //#endregion
@@ -23688,6 +23941,7 @@ const downscaleImageFromURL = (url, options) => {
23688
23941
  //#endregion
23689
23942
  //#region src/internal-utils/upscale.ts
23690
23943
  const setupUpscaleStage = (instance, stage) => {
23944
+ if (instance.isServerSide()) return;
23691
23945
  const config = instance.getConfiguration();
23692
23946
  const doUpscale = config.performance?.upscale?.enabled ?? false;
23693
23947
  if (doUpscale) {
@@ -23719,7 +23973,14 @@ const setupUpscaleStage = (instance, stage) => {
23719
23973
  innerElement.style.transformOrigin = "0 0";
23720
23974
  innerElement.style.transform = `scale(${scaleToCover})`;
23721
23975
  }
23722
- } else stage.setAttrs({ upscaleScale: 1 });
23976
+ } else {
23977
+ const realContainer = stage.container();
23978
+ const containerWidth = realContainer.offsetWidth;
23979
+ const containerHeight = realContainer.offsetHeight;
23980
+ stage.width(containerWidth);
23981
+ stage.height(containerHeight);
23982
+ stage.setAttrs({ upscaleScale: 1 });
23983
+ }
23723
23984
  };
23724
23985
 
23725
23986
  //#endregion
@@ -23730,6 +23991,7 @@ var WeaveStageNode = class extends WeaveNode {
23730
23991
  wheelMousePressed = false;
23731
23992
  isCmdCtrlPressed = false;
23732
23993
  globalEventsInitialized = false;
23994
+ initialize = void 0;
23733
23995
  onRender(props) {
23734
23996
  const stage = new Konva.Stage({
23735
23997
  ...props,
@@ -23748,10 +24010,10 @@ var WeaveStageNode = class extends WeaveNode {
23748
24010
  container.setAttribute("tabindex", "0");
23749
24011
  stage.container().addEventListener("focus", () => {
23750
24012
  this.stageFocused = true;
23751
- });
24013
+ }, { signal: this.instance.getEventsController()?.signal });
23752
24014
  stage.container().addEventListener("blur", () => {
23753
24015
  this.stageFocused = false;
23754
- });
24016
+ }, { signal: this.instance.getEventsController()?.signal });
23755
24017
  }
23756
24018
  Konva.Stage.prototype.mode = function(mode) {
23757
24019
  if (typeof mode !== "undefined") this._mode = mode;
@@ -23821,7 +24083,7 @@ var WeaveStageNode = class extends WeaveNode {
23821
24083
  const selectedNode = transformer.nodes()[0];
23822
24084
  selectedNode.fire("onCmdCtrlPressed");
23823
24085
  }
23824
- });
24086
+ }, { signal: this.instance.getEventsController()?.signal });
23825
24087
  window.addEventListener("keyup", (e) => {
23826
24088
  if (!(e.ctrlKey || e.metaKey)) {
23827
24089
  this.isCmdCtrlPressed = false;
@@ -23832,7 +24094,7 @@ var WeaveStageNode = class extends WeaveNode {
23832
24094
  const selectedNode = transformer.nodes()[0];
23833
24095
  selectedNode.fire("onCmdCtrlReleased");
23834
24096
  }
23835
- });
24097
+ }, { signal: this.instance.getEventsController()?.signal });
23836
24098
  this.globalEventsInitialized = true;
23837
24099
  }
23838
24100
  isOnlyCtrlOrMeta(event) {
@@ -23852,6 +24114,7 @@ const WEAVE_LAYER_NODE_TYPE = "layer";
23852
24114
  //#region src/nodes/layer/layer.ts
23853
24115
  var WeaveLayerNode = class extends WeaveNode {
23854
24116
  nodeType = WEAVE_LAYER_NODE_TYPE;
24117
+ initialize = void 0;
23855
24118
  onRender(props) {
23856
24119
  const layer = new Konva.Layer({ ...props });
23857
24120
  layer.canMoveToContainer = function() {
@@ -23899,6 +24162,7 @@ const WEAVE_GROUP_NODE_TYPE = "group";
23899
24162
  //#region src/nodes/group/group.ts
23900
24163
  var WeaveGroupNode = class extends WeaveNode {
23901
24164
  nodeType = WEAVE_GROUP_NODE_TYPE;
24165
+ initialize = void 0;
23902
24166
  constructor(params) {
23903
24167
  super();
23904
24168
  const { config } = params ?? {};
@@ -23991,6 +24255,7 @@ const WEAVE_RECTANGLE_NODE_TYPE = "rectangle";
23991
24255
  //#region src/nodes/rectangle/rectangle.ts
23992
24256
  var WeaveRectangleNode = class extends WeaveNode {
23993
24257
  nodeType = WEAVE_RECTANGLE_NODE_TYPE;
24258
+ initialize = void 0;
23994
24259
  constructor(params) {
23995
24260
  super();
23996
24261
  const { config } = params ?? {};
@@ -24034,6 +24299,7 @@ const WEAVE_ELLIPSE_NODE_TYPE = "ellipse";
24034
24299
  //#region src/nodes/ellipse/ellipse.ts
24035
24300
  var WeaveEllipseNode = class extends WeaveNode {
24036
24301
  nodeType = WEAVE_ELLIPSE_NODE_TYPE;
24302
+ initialize = void 0;
24037
24303
  constructor(params) {
24038
24304
  super();
24039
24305
  const { config } = params ?? {};
@@ -24179,13 +24445,16 @@ var WeaveLineNode = class extends WeaveNode {
24179
24445
  constructor(params) {
24180
24446
  super();
24181
24447
  this.config = mergeExceptArrays(WEAVE_LINE_NODE_DEFAULT_CONFIG, params?.config ?? {});
24182
- this.handleNodeChanges = null;
24183
- this.handleZoomChanges = null;
24184
24448
  this.snapper = new GreedySnapper({
24185
24449
  snapAngles: this.config.snapAngles.angles,
24186
24450
  activateThreshold: this.config.snapAngles.activateThreshold,
24187
24451
  releaseThreshold: this.config.snapAngles.releaseThreshold
24188
24452
  });
24453
+ this.initialize();
24454
+ }
24455
+ initialize() {
24456
+ this.handleNodeChanges = null;
24457
+ this.handleZoomChanges = null;
24189
24458
  }
24190
24459
  onRender(props) {
24191
24460
  const line = new Konva.Line({
@@ -24490,17 +24759,19 @@ const TEXT_LAYOUT = {
24490
24759
  //#region src/nodes/text/text.ts
24491
24760
  var WeaveTextNode = class extends WeaveNode {
24492
24761
  nodeType = WEAVE_TEXT_NODE_TYPE;
24493
- editing = false;
24494
- textAreaSuperContainer = null;
24495
- textAreaContainer = null;
24496
- textArea = null;
24497
- eventsInitialized = false;
24498
- isCtrlMetaPressed = false;
24499
24762
  constructor(params) {
24500
24763
  super();
24501
24764
  const { config } = params ?? {};
24502
24765
  this.config = (0, import_lodash.merge)({}, WEAVE_TEXT_NODE_DEFAULT_CONFIG, config);
24766
+ this.initialize();
24767
+ }
24768
+ initialize() {
24503
24769
  this.keyPressHandler = void 0;
24770
+ this.eventsInitialized = false;
24771
+ this.isCtrlMetaPressed = false;
24772
+ this.textAreaSuperContainer = null;
24773
+ this.textAreaContainer = null;
24774
+ this.textArea = null;
24504
24775
  this.editing = false;
24505
24776
  this.textArea = null;
24506
24777
  }
@@ -24508,10 +24779,10 @@ var WeaveTextNode = class extends WeaveNode {
24508
24779
  if (!this.eventsInitialized && !globalThis._weave_isServerSide) {
24509
24780
  window.addEventListener("keydown", (e) => {
24510
24781
  if (e.ctrlKey || e.metaKey) this.isCtrlMetaPressed = true;
24511
- });
24782
+ }, { signal: this.instance.getEventsController()?.signal });
24512
24783
  window.addEventListener("keyup", (e) => {
24513
24784
  if (!(e.ctrlKey || e.metaKey)) this.isCtrlMetaPressed = false;
24514
- });
24785
+ }, { signal: this.instance.getEventsController()?.signal });
24515
24786
  this.eventsInitialized = true;
24516
24787
  }
24517
24788
  }
@@ -24539,7 +24810,7 @@ var WeaveTextNode = class extends WeaveNode {
24539
24810
  onAdd() {
24540
24811
  if (!this.instance.isServerSide() && !this.keyPressHandler) {
24541
24812
  this.keyPressHandler = this.handleKeyPress.bind(this);
24542
- window.addEventListener("keypress", this.keyPressHandler);
24813
+ window.addEventListener("keypress", this.keyPressHandler, { signal: this.instance.getEventsController()?.signal });
24543
24814
  }
24544
24815
  }
24545
24816
  onRender(props) {
@@ -24693,7 +24964,7 @@ var WeaveTextNode = class extends WeaveNode {
24693
24964
  });
24694
24965
  if (!this.instance.isServerSide() && !this.keyPressHandler) {
24695
24966
  this.keyPressHandler = this.handleKeyPress.bind(this);
24696
- window.addEventListener("keypress", this.keyPressHandler);
24967
+ window.addEventListener("keypress", this.keyPressHandler, { signal: this.instance.getEventsController()?.signal });
24697
24968
  }
24698
24969
  return text;
24699
24970
  }
@@ -24952,17 +25223,17 @@ var WeaveTextNode = class extends WeaveNode {
24952
25223
  this.textAreaSuperContainer.scrollTop = 0;
24953
25224
  this.textAreaSuperContainer.scrollLeft = 0;
24954
25225
  }
24955
- });
25226
+ }, { signal: this.instance.getEventsController()?.signal });
24956
25227
  this.textAreaContainer.addEventListener("scroll", () => {
24957
25228
  if (!this.textAreaContainer) return;
24958
25229
  this.textAreaContainer.scrollTop = 0;
24959
25230
  this.textAreaContainer.scrollLeft = 0;
24960
- });
25231
+ }, { signal: this.instance.getEventsController()?.signal });
24961
25232
  this.textArea.addEventListener("scroll", () => {
24962
25233
  if (!this.textArea) return;
24963
25234
  this.textArea.scrollTop = 0;
24964
25235
  this.textArea.scrollLeft = 0;
24965
- });
25236
+ }, { signal: this.instance.getEventsController()?.signal });
24966
25237
  const rotation = textNode.getAbsoluteRotation();
24967
25238
  if (rotation) {
24968
25239
  const transform = "rotate(" + rotation + "deg)";
@@ -25011,8 +25282,8 @@ var WeaveTextNode = class extends WeaveNode {
25011
25282
  this.textAreaDomResize(textNode);
25012
25283
  }
25013
25284
  };
25014
- this.textArea.addEventListener("keydown", handleKeyDown);
25015
- this.textArea.addEventListener("keyup", handleKeyUp);
25285
+ this.textArea.addEventListener("keydown", handleKeyDown, { signal: this.instance.getEventsController()?.signal });
25286
+ this.textArea.addEventListener("keyup", handleKeyUp, { signal: this.instance.getEventsController()?.signal });
25016
25287
  this.textArea.tabIndex = 1;
25017
25288
  this.textArea.focus();
25018
25289
  const handleOutsideClick = (e) => {
@@ -25038,7 +25309,7 @@ var WeaveTextNode = class extends WeaveNode {
25038
25309
  }
25039
25310
  };
25040
25311
  setTimeout(() => {
25041
- window.addEventListener("pointerup", handleOutsideClick);
25312
+ window.addEventListener("pointerup", handleOutsideClick, { signal: this.instance.getEventsController()?.signal });
25042
25313
  }, 0);
25043
25314
  this.instance.getStage().mode(WEAVE_STAGE_TEXT_EDITION_MODE);
25044
25315
  this.editing = true;
@@ -25374,7 +25645,7 @@ var WeaveImageCrop = class WeaveImageCrop {
25374
25645
  utilityLayer?.add(this.transformer);
25375
25646
  this.transformer?.forceUpdate();
25376
25647
  this.cropGroup.show();
25377
- window.addEventListener("keydown", this.handleHide);
25648
+ window.addEventListener("keydown", this.handleHide, { signal: this.instance.getEventsController()?.signal });
25378
25649
  if (options.cmdCtrl.triggered) {
25379
25650
  utilityLayer?.hide();
25380
25651
  const stage = this.instance.getStage();
@@ -25824,24 +26095,21 @@ const isAllowedUrl = (value) => {
25824
26095
  //#endregion
25825
26096
  //#region src/nodes/image/image.ts
25826
26097
  var WeaveImageNode = class extends WeaveNode {
25827
- imageBitmapCache = {};
25828
- imageSource = {};
25829
- imageFallback = {};
25830
- imageState = {};
25831
- imageTryoutAttempts = {};
25832
- imageTryoutIds = {};
25833
26098
  nodeType = WEAVE_IMAGE_NODE_TYPE;
25834
26099
  cursorsFallback = { loading: "wait" };
25835
26100
  cursors = {};
25836
26101
  constructor(params) {
25837
26102
  super();
25838
26103
  const { config } = params ?? {};
26104
+ this.config = mergeExceptArrays(WEAVE_IMAGE_DEFAULT_CONFIG, config);
26105
+ this.initialize();
26106
+ }
26107
+ initialize() {
25839
26108
  this.tapStart = {
25840
26109
  x: 0,
25841
26110
  y: 0,
25842
26111
  time: 0
25843
26112
  };
25844
- this.config = mergeExceptArrays(WEAVE_IMAGE_DEFAULT_CONFIG, config);
25845
26113
  this.imageCrop = null;
25846
26114
  this.imageBitmapCache = {};
25847
26115
  this.imageSource = {};
@@ -26065,7 +26333,7 @@ var WeaveImageNode = class extends WeaveNode {
26065
26333
  };
26066
26334
  this.updateImageCrop(image);
26067
26335
  } else {
26068
- this.updatePlaceholderSize(image, imagePlaceholder);
26336
+ this.updatePlaceholderSize(image);
26069
26337
  this.loadImage(imageProps, image, true);
26070
26338
  }
26071
26339
  if (this.config.performance.cache.enabled) image.on("transformend", () => {
@@ -26448,7 +26716,7 @@ var WeaveImageNode = class extends WeaveNode {
26448
26716
  }
26449
26717
  this.loadAsyncElement(id);
26450
26718
  preloadFunction(id, realImageURL ?? "", {
26451
- onLoad: () => {
26719
+ onLoad: async () => {
26452
26720
  if (useFallback) this.imageTryoutIds[id] = setTimeout(() => {
26453
26721
  const node = this.instance.getStage().findOne(`#${id}`);
26454
26722
  if (node) {
@@ -26499,7 +26767,7 @@ var WeaveImageNode = class extends WeaveNode {
26499
26767
  error: false
26500
26768
  };
26501
26769
  this.updateImageCrop(image);
26502
- this.resolveAsyncElement(id);
26770
+ if (!useFallback) this.resolveAsyncElement(id);
26503
26771
  this.cacheNode(image);
26504
26772
  }
26505
26773
  },
@@ -26540,13 +26808,9 @@ var WeaveImageNode = class extends WeaveNode {
26540
26808
  }
26541
26809
  }, loadTryout);
26542
26810
  }
26543
- updatePlaceholderSize(image, imagePlaceholder) {
26811
+ updatePlaceholderSize(image) {
26544
26812
  const imageAttrs = image.getAttrs();
26545
26813
  if (!this.imageState[imageAttrs.id ?? ""]?.loaded) return;
26546
- if (!imageAttrs.adding && !imageAttrs.cropInfo) {
26547
- imagePlaceholder.width(imageAttrs.uncroppedImage.width);
26548
- imagePlaceholder.height(imageAttrs.uncroppedImage.height);
26549
- }
26550
26814
  }
26551
26815
  updateImageCrop(image) {
26552
26816
  const imageAttrs = image.getAttrs();
@@ -26680,6 +26944,7 @@ const WEAVE_STAR_NODE_TYPE = "star";
26680
26944
  //#region src/nodes/star/star.ts
26681
26945
  var WeaveStarNode = class extends WeaveNode {
26682
26946
  nodeType = WEAVE_STAR_NODE_TYPE;
26947
+ initialize = void 0;
26683
26948
  constructor(params) {
26684
26949
  super();
26685
26950
  const { config } = params ?? {};
@@ -26765,6 +27030,7 @@ const WEAVE_ARROW_NODE_TYPE = "arrow";
26765
27030
  //#region src/nodes/arrow/arrow.ts
26766
27031
  var WeaveArrowNode = class extends WeaveNode {
26767
27032
  nodeType = WEAVE_ARROW_NODE_TYPE;
27033
+ initialize = void 0;
26768
27034
  constructor(params) {
26769
27035
  super();
26770
27036
  const { config } = params ?? {};
@@ -26821,6 +27087,7 @@ const WEAVE_REGULAR_POLYGON_NODE_TYPE = "regular-polygon";
26821
27087
  //#region src/nodes/regular-polygon/regular-polygon.ts
26822
27088
  var WeaveRegularPolygonNode = class extends WeaveNode {
26823
27089
  nodeType = WEAVE_REGULAR_POLYGON_NODE_TYPE;
27090
+ initialize = void 0;
26824
27091
  constructor(params) {
26825
27092
  super();
26826
27093
  const { config } = params ?? {};
@@ -26934,6 +27201,7 @@ var GroupFrame = class extends Konva.Group {
26934
27201
  //#region src/nodes/frame/frame.ts
26935
27202
  var WeaveFrameNode = class extends WeaveNode {
26936
27203
  nodeType = WEAVE_FRAME_NODE_TYPE;
27204
+ initialize = void 0;
26937
27205
  constructor(params) {
26938
27206
  super();
26939
27207
  const { config } = params ?? {};
@@ -27234,6 +27502,7 @@ const WEAVE_STROKE_NODE_DEFAULT_CONFIG = {
27234
27502
  //#region src/nodes/stroke/stroke.ts
27235
27503
  var WeaveStrokeNode = class extends WeaveNode {
27236
27504
  nodeType = WEAVE_STROKE_NODE_TYPE;
27505
+ initialize = void 0;
27237
27506
  constructor(params) {
27238
27507
  super();
27239
27508
  const { config } = params ?? {};
@@ -27810,8 +28079,6 @@ var WeaveSquareLineTipManager = class extends WeaveBaseLineTipManager {
27810
28079
  //#endregion
27811
28080
  //#region src/nodes/stroke-single/stroke-single.ts
27812
28081
  var WeaveStrokeSingleNode = class extends WeaveNode {
27813
- startHandle = null;
27814
- endHandle = null;
27815
28082
  nodeType = WEAVE_STROKE_SINGLE_NODE_TYPE;
27816
28083
  tipManagers = {
27817
28084
  [WEAVE_STROKE_SINGLE_NODE_TIP_TYPE.ARROW]: new WeaveArrowLineTipManager(),
@@ -27822,24 +28089,29 @@ var WeaveStrokeSingleNode = class extends WeaveNode {
27822
28089
  constructor(params) {
27823
28090
  super();
27824
28091
  this.config = mergeExceptArrays(WEAVE_STROKE_SINGLE_NODE_DEFAULT_CONFIG, params?.config ?? {});
27825
- this.handleNodeChanges = null;
27826
- this.handleZoomChanges = null;
27827
- this.shiftPressed = false;
27828
28092
  this.snapper = new GreedySnapper({
27829
28093
  snapAngles: this.config.snapAngles.angles,
27830
28094
  activateThreshold: this.config.snapAngles.activateThreshold,
27831
28095
  releaseThreshold: this.config.snapAngles.releaseThreshold
27832
28096
  });
28097
+ this.initialize();
28098
+ }
28099
+ initialize() {
27833
28100
  this.eventsInitialized = false;
28101
+ this.startHandle = null;
28102
+ this.endHandle = null;
28103
+ this.handleNodeChanges = null;
28104
+ this.handleZoomChanges = null;
28105
+ this.shiftPressed = false;
27834
28106
  }
27835
28107
  initEvents() {
27836
28108
  if (this.eventsInitialized) return;
27837
28109
  window.addEventListener("keydown", (e) => {
27838
28110
  if (e.key === "Shift") this.shiftPressed = true;
27839
- });
28111
+ }, { signal: this.instance.getEventsController()?.signal });
27840
28112
  window.addEventListener("keyup", (e) => {
27841
28113
  if (e.key === "Shift") this.shiftPressed = false;
27842
- });
28114
+ }, { signal: this.instance.getEventsController()?.signal });
27843
28115
  this.eventsInitialized = true;
27844
28116
  }
27845
28117
  onRender(props) {
@@ -28326,6 +28598,9 @@ var WeaveCommentNode = class extends WeaveNode {
28326
28598
  constructor(params) {
28327
28599
  super();
28328
28600
  this.config = mergeExceptArrays(WEAVE_COMMENT_NODE_DEFAULTS, params.config);
28601
+ this.initialize();
28602
+ }
28603
+ initialize() {
28329
28604
  this.commentDomVisibleId = null;
28330
28605
  this.commentDomVisible = false;
28331
28606
  this.commentDomAction = null;
@@ -28954,10 +29229,6 @@ const WEAVE_VIDEO_DEFAULT_CONFIG = {
28954
29229
  //#endregion
28955
29230
  //#region src/nodes/video/video.ts
28956
29231
  var WeaveVideoNode = class extends WeaveNode {
28957
- videoState = {};
28958
- videoSourceFrameId = {};
28959
- videoSource = {};
28960
- videoPlaceholder = {};
28961
29232
  nodeType = WEAVE_VIDEO_NODE_TYPE;
28962
29233
  constructor(params) {
28963
29234
  super();
@@ -28970,6 +29241,13 @@ var WeaveVideoNode = class extends WeaveNode {
28970
29241
  this.videoIconImage.src = this.config.style.icon.dataURL;
28971
29242
  }
28972
29243
  }
29244
+ initialize() {
29245
+ this.videoState = {};
29246
+ this.videoSource = {};
29247
+ this.videoSourceFrameId = {};
29248
+ this.videoPlaceholder = {};
29249
+ this.videoIconImage = void 0;
29250
+ }
28973
29251
  async loadPlaceholder(params, video) {
28974
29252
  const videoProps = params;
28975
29253
  const { id } = videoProps;
@@ -29464,6 +29742,7 @@ const WEAVE_MEASURE_NODE_DEFAULT_CONFIG = { style: {
29464
29742
  var WeaveMeasureNode = class extends WeaveNode {
29465
29743
  nodeType = WEAVE_MEASURE_NODE_TYPE;
29466
29744
  handlePointCircleRadius = 6;
29745
+ initialize = void 0;
29467
29746
  constructor(params) {
29468
29747
  super();
29469
29748
  this.config = mergeExceptArrays(WEAVE_MEASURE_NODE_DEFAULT_CONFIG, params?.config ?? {});
@@ -30754,6 +31033,7 @@ var WeaveConnectorNode = class extends WeaveNode {
30754
31033
  [WEAVE_CONNECTOR_NODE_DECORATOR_TYPE.DOT]: setupNodeDecoratorDot,
30755
31034
  [WEAVE_CONNECTOR_NODE_DECORATOR_TYPE.ARROW]: setupNodeDecoratorArrow
30756
31035
  };
31036
+ initialize = void 0;
30757
31037
  constructor(params) {
30758
31038
  super();
30759
31039
  this.config = mergeExceptArrays(WEAVE_CONNECTOR_NODE_DEFAULT_CONFIG, params?.config);
@@ -31504,10 +31784,6 @@ const WEAVE_STAGE_ZOOM_DEFAULT_CONFIG = {
31504
31784
  var WeaveStageZoomPlugin = class extends WeavePlugin {
31505
31785
  getLayerName = void 0;
31506
31786
  initLayer = void 0;
31507
- pinching = false;
31508
- zooming = false;
31509
- isTrackpad = false;
31510
- zoomVelocity = 0;
31511
31787
  zoomInertiaType = WEAVE_STAGE_ZOOM_TYPE.MOUSE_WHEEL;
31512
31788
  defaultStep = 3;
31513
31789
  constructor(params) {
@@ -31515,8 +31791,13 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
31515
31791
  const { config } = params ?? {};
31516
31792
  this.config = mergeExceptArrays(WEAVE_STAGE_ZOOM_DEFAULT_CONFIG, config);
31517
31793
  if (!this.config.zoomSteps.includes(this.config.defaultZoom)) throw new Error(`Default zoom ${this.config.defaultZoom} is not in zoom steps`);
31794
+ this.initialize();
31795
+ }
31796
+ initialize() {
31518
31797
  this.pinching = false;
31798
+ this.zooming = false;
31519
31799
  this.isTrackpad = false;
31800
+ this.zoomVelocity = 0;
31520
31801
  this.isCtrlOrMetaPressed = false;
31521
31802
  this.updatedMinimumZoom = false;
31522
31803
  this.actualStep = this.config.zoomSteps.findIndex((step) => step === this.config.defaultZoom);
@@ -31803,6 +32084,15 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
31803
32084
  if (box.width === 0 || box.height === 0) return;
31804
32085
  this.fitToElements(box, finalOptions);
31805
32086
  }
32087
+ fitToArea(area, options) {
32088
+ const finalOptions = mergeExceptArrays({
32089
+ smartZoom: false,
32090
+ overrideZoom: true
32091
+ }, options);
32092
+ if (!this.enabled) return;
32093
+ if (area.width === 0 || area.height === 0) return;
32094
+ this.fitToElements(area, finalOptions);
32095
+ }
31806
32096
  enable() {
31807
32097
  this.enabled = true;
31808
32098
  }
@@ -31821,10 +32111,10 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
31821
32111
  initEvents() {
31822
32112
  window.addEventListener("keydown", (e) => {
31823
32113
  if (e.ctrlKey || e.metaKey) this.isCtrlOrMetaPressed = true;
31824
- });
32114
+ }, { signal: this.instance.getEventsController()?.signal });
31825
32115
  window.addEventListener("keyup", (e) => {
31826
32116
  if (!(e.ctrlKey || e.metaKey)) this.isCtrlOrMetaPressed = false;
31827
- });
32117
+ }, { signal: this.instance.getEventsController()?.signal });
31828
32118
  const stage = this.instance.getStage();
31829
32119
  let lastCenter = null;
31830
32120
  let lastDist = 0;
@@ -31849,7 +32139,10 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
31849
32139
  return;
31850
32140
  }
31851
32141
  }
31852
- }, { passive: false });
32142
+ }, {
32143
+ passive: false,
32144
+ signal: this.instance.getEventsController()?.signal
32145
+ });
31853
32146
  stage.getContent().addEventListener("touchmove", (e) => {
31854
32147
  e.preventDefault();
31855
32148
  if (e.touches.length === 2) {
@@ -31889,12 +32182,18 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
31889
32182
  lastDist = dist;
31890
32183
  lastCenter = newCenter;
31891
32184
  }
31892
- }, { passive: false });
32185
+ }, {
32186
+ passive: false,
32187
+ signal: this.instance.getEventsController()?.signal
32188
+ });
31893
32189
  stage.getContent().addEventListener("touchend", () => {
31894
32190
  this.pinching = false;
31895
32191
  lastDist = 0;
31896
32192
  lastCenter = null;
31897
- }, { passive: false });
32193
+ }, {
32194
+ passive: false,
32195
+ signal: this.instance.getEventsController()?.signal
32196
+ });
31898
32197
  let doZoom = false;
31899
32198
  const handleWheelImmediate = (e) => {
31900
32199
  const performZoom = this.isCtrlOrMetaPressed || !this.isCtrlOrMetaPressed && e.ctrlKey && e.deltaMode === 0;
@@ -31912,7 +32211,10 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
31912
32211
  e.preventDefault();
31913
32212
  doZoom = true;
31914
32213
  };
31915
- window.addEventListener("wheel", handleWheelImmediate, { passive: false });
32214
+ window.addEventListener("wheel", handleWheelImmediate, {
32215
+ signal: this.instance.getEventsController()?.signal,
32216
+ passive: false
32217
+ });
31916
32218
  const handleWheel = (e) => {
31917
32219
  if (!doZoom) return;
31918
32220
  const delta = e.deltaY > 0 ? 1 : -1;
@@ -31925,7 +32227,10 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
31925
32227
  }
31926
32228
  };
31927
32229
  const throttledHandleWheel = (0, import_lodash.throttle)(handleWheel, DEFAULT_THROTTLE_MS);
31928
- window.addEventListener("wheel", throttledHandleWheel, { passive: true });
32230
+ window.addEventListener("wheel", throttledHandleWheel, {
32231
+ signal: this.instance.getEventsController()?.signal,
32232
+ passive: true
32233
+ });
31929
32234
  }
31930
32235
  getInertiaScale() {
31931
32236
  const stage = this.instance.getStage();
@@ -31983,6 +32288,7 @@ const ZOOM_OUT_TOOL_ACTION_NAME = "zoomOutTool";
31983
32288
  //#region src/actions/zoom-out-tool/zoom-out-tool.ts
31984
32289
  var WeaveZoomOutToolAction = class extends WeaveAction {
31985
32290
  onPropsChange = void 0;
32291
+ initialize = void 0;
31986
32292
  getName() {
31987
32293
  return ZOOM_OUT_TOOL_ACTION_NAME;
31988
32294
  }
@@ -32017,6 +32323,10 @@ const ZOOM_IN_TOOL_ACTION_NAME = "zoomInTool";
32017
32323
  //#region src/actions/zoom-in-tool/zoom-in-tool.ts
32018
32324
  var WeaveZoomInToolAction = class extends WeaveAction {
32019
32325
  onPropsChange = void 0;
32326
+ initialize = void 0;
32327
+ constructor() {
32328
+ super();
32329
+ }
32020
32330
  getName() {
32021
32331
  return ZOOM_IN_TOOL_ACTION_NAME;
32022
32332
  }
@@ -32051,6 +32361,10 @@ const FIT_TO_SCREEN_TOOL_ACTION_NAME = "fitToScreenTool";
32051
32361
  //#region src/actions/fit-to-screen-tool/fit-to-screen-tool.ts
32052
32362
  var WeaveFitToScreenToolAction = class extends WeaveAction {
32053
32363
  onPropsChange = void 0;
32364
+ initialize = void 0;
32365
+ constructor() {
32366
+ super();
32367
+ }
32054
32368
  getName() {
32055
32369
  return FIT_TO_SCREEN_TOOL_ACTION_NAME;
32056
32370
  }
@@ -32084,6 +32398,10 @@ const FIT_TO_SELECTION_TOOL_ACTION_NAME = "fitToSelectionTool";
32084
32398
  //#region src/actions/fit-to-selection-tool/fit-to-selection-tool.ts
32085
32399
  var WeaveFitToSelectionToolAction = class extends WeaveAction {
32086
32400
  onPropsChange = void 0;
32401
+ initialize = void 0;
32402
+ constructor() {
32403
+ super();
32404
+ }
32087
32405
  getName() {
32088
32406
  return FIT_TO_SELECTION_TOOL_ACTION_NAME;
32089
32407
  }
@@ -32126,6 +32444,9 @@ var WeaveMoveToolAction = class extends WeaveAction {
32126
32444
  onInit = void 0;
32127
32445
  constructor() {
32128
32446
  super();
32447
+ this.initialize();
32448
+ }
32449
+ initialize() {
32129
32450
  this.initialized = false;
32130
32451
  this.state = MOVE_TOOL_STATE.IDLE;
32131
32452
  }
@@ -32139,7 +32460,7 @@ var WeaveMoveToolAction = class extends WeaveAction {
32139
32460
  this.cancelAction();
32140
32461
  return;
32141
32462
  }
32142
- });
32463
+ }, { signal: this.instance.getEventsController()?.signal });
32143
32464
  stage.on("pointerdown", () => {
32144
32465
  if ([MOVE_TOOL_ACTION_NAME].includes(this.instance.getActiveAction() ?? "")) stage.container().style.cursor = "grabbing";
32145
32466
  });
@@ -32198,6 +32519,9 @@ var WeaveSelectionToolAction = class extends WeaveAction {
32198
32519
  onInit = void 0;
32199
32520
  constructor() {
32200
32521
  super();
32522
+ this.initialize();
32523
+ }
32524
+ initialize() {
32201
32525
  this.initialized = false;
32202
32526
  this.state = SELECTION_TOOL_STATE.IDLE;
32203
32527
  }
@@ -32261,6 +32585,9 @@ var WeaveEraserToolAction = class extends WeaveAction {
32261
32585
  onInit = void 0;
32262
32586
  constructor() {
32263
32587
  super();
32588
+ this.initialize();
32589
+ }
32590
+ initialize() {
32264
32591
  this.initialized = false;
32265
32592
  this.erasing = false;
32266
32593
  this.state = ERASER_TOOL_STATE.IDLE;
@@ -32294,7 +32621,7 @@ var WeaveEraserToolAction = class extends WeaveAction {
32294
32621
  this.cancelAction();
32295
32622
  return;
32296
32623
  }
32297
- });
32624
+ }, { signal: this.instance.getEventsController()?.signal });
32298
32625
  this.initialized = true;
32299
32626
  }
32300
32627
  setState(state) {
@@ -32361,6 +32688,9 @@ var WeaveRectangleToolAction = class extends WeaveAction {
32361
32688
  onInit = void 0;
32362
32689
  constructor() {
32363
32690
  super();
32691
+ this.initialize();
32692
+ }
32693
+ initialize() {
32364
32694
  this.pointers = new Map();
32365
32695
  this.initialized = false;
32366
32696
  this.state = RECTANGLE_TOOL_STATE.IDLE;
@@ -32396,7 +32726,7 @@ var WeaveRectangleToolAction = class extends WeaveAction {
32396
32726
  this.cancelAction();
32397
32727
  return;
32398
32728
  }
32399
- });
32729
+ }, { signal: this.instance.getEventsController()?.signal });
32400
32730
  stage.on("pointermove", () => {
32401
32731
  if (this.state === RECTANGLE_TOOL_STATE.IDLE) return;
32402
32732
  this.setCursor();
@@ -32570,6 +32900,9 @@ var WeaveEllipseToolAction = class extends WeaveAction {
32570
32900
  onInit = void 0;
32571
32901
  constructor() {
32572
32902
  super();
32903
+ this.initialize();
32904
+ }
32905
+ initialize() {
32573
32906
  this.pointers = new Map();
32574
32907
  this.initialized = false;
32575
32908
  this.state = ELLIPSE_TOOL_STATE.IDLE;
@@ -32605,7 +32938,7 @@ var WeaveEllipseToolAction = class extends WeaveAction {
32605
32938
  this.cancelAction();
32606
32939
  return;
32607
32940
  }
32608
- });
32941
+ }, { signal: this.instance.getEventsController()?.signal });
32609
32942
  stage.on("pointerdown", (e) => {
32610
32943
  this.setTapStart(e);
32611
32944
  this.pointers.set(e.evt.pointerId, {
@@ -32786,6 +33119,9 @@ var WeavePenToolAction = class extends WeaveAction {
32786
33119
  onInit = void 0;
32787
33120
  constructor() {
32788
33121
  super();
33122
+ this.initialize();
33123
+ }
33124
+ initialize() {
32789
33125
  this.pointers = new Map();
32790
33126
  this.initialized = false;
32791
33127
  this.state = PEN_TOOL_STATE.IDLE;
@@ -32821,7 +33157,7 @@ var WeavePenToolAction = class extends WeaveAction {
32821
33157
  this.cancelAction();
32822
33158
  return;
32823
33159
  }
32824
- });
33160
+ }, { signal: this.instance.getEventsController()?.signal });
32825
33161
  stage.on("pointerdown", (e) => {
32826
33162
  this.setTapStart(e);
32827
33163
  this.pointers.set(e.evt.pointerId, {
@@ -33058,6 +33394,9 @@ var WeaveLineToolAction = class extends WeaveAction {
33058
33394
  constructor(params) {
33059
33395
  super();
33060
33396
  this.config = mergeExceptArrays(LINE_TOOL_DEFAULT_CONFIG, params?.config ?? {});
33397
+ this.initialize();
33398
+ }
33399
+ initialize() {
33061
33400
  this.pointers = new Map();
33062
33401
  this.initialized = false;
33063
33402
  this.state = LINE_TOOL_STATE.IDLE;
@@ -33102,13 +33441,13 @@ var WeaveLineToolAction = class extends WeaveAction {
33102
33441
  this.snappedAngle = null;
33103
33442
  this.shiftPressed = true;
33104
33443
  }
33105
- });
33444
+ }, { signal: this.instance.getEventsController()?.signal });
33106
33445
  window.addEventListener("keyup", (e) => {
33107
33446
  if (e.key === "Shift" && this.instance.getActiveAction() === LINE_TOOL_ACTION_NAME) {
33108
33447
  this.snappedAngle = null;
33109
33448
  this.shiftPressed = false;
33110
33449
  }
33111
- });
33450
+ }, { signal: this.instance.getEventsController()?.signal });
33112
33451
  stage.on("pointerdown", (e) => {
33113
33452
  this.setTapStart(e);
33114
33453
  this.pointers.set(e.evt.pointerId, {
@@ -33323,6 +33662,9 @@ var WeaveBrushToolAction = class extends WeaveAction {
33323
33662
  constructor(params) {
33324
33663
  super();
33325
33664
  this.config = mergeExceptArrays(BRUSH_TOOL_DEFAULT_CONFIG, params?.config ?? {});
33665
+ this.initialize();
33666
+ }
33667
+ initialize() {
33326
33668
  this.initialized = false;
33327
33669
  this.state = BRUSH_TOOL_STATE.INACTIVE;
33328
33670
  this.strokeId = null;
@@ -33351,7 +33693,7 @@ var WeaveBrushToolAction = class extends WeaveAction {
33351
33693
  const stage = this.instance.getStage();
33352
33694
  window.addEventListener("keyup", (e) => {
33353
33695
  if (e.code === "Space" && this.instance.getActiveAction() === BRUSH_TOOL_ACTION_NAME) this.isSpacePressed = false;
33354
- });
33696
+ }, { signal: this.instance.getEventsController()?.signal });
33355
33697
  window.addEventListener("keydown", (e) => {
33356
33698
  if (e.code === "Enter" && this.instance.getActiveAction() === BRUSH_TOOL_ACTION_NAME) {
33357
33699
  e.stopPropagation();
@@ -33367,7 +33709,7 @@ var WeaveBrushToolAction = class extends WeaveAction {
33367
33709
  e.stopPropagation();
33368
33710
  this.cancelAction();
33369
33711
  }
33370
- });
33712
+ }, { signal: this.instance.getEventsController()?.signal });
33371
33713
  const handlePointerDown = (e) => {
33372
33714
  if (this.state === BRUSH_TOOL_STATE.INACTIVE) return;
33373
33715
  if (this.state !== BRUSH_TOOL_STATE.IDLE) return;
@@ -33576,6 +33918,9 @@ var WeaveTextToolAction = class extends WeaveAction {
33576
33918
  onInit = void 0;
33577
33919
  constructor() {
33578
33920
  super();
33921
+ this.initialize();
33922
+ }
33923
+ initialize() {
33579
33924
  this.initialized = false;
33580
33925
  this.state = TEXT_TOOL_STATE.IDLE;
33581
33926
  this.textId = null;
@@ -33605,7 +33950,7 @@ var WeaveTextToolAction = class extends WeaveAction {
33605
33950
  this.cancelAction();
33606
33951
  return;
33607
33952
  }
33608
- });
33953
+ }, { signal: this.instance.getEventsController()?.signal });
33609
33954
  stage.on("pointermove", () => {
33610
33955
  if (this.state === TEXT_TOOL_STATE.IDLE) return;
33611
33956
  this.setCursor();
@@ -33733,6 +34078,9 @@ var WeaveImageToolAction = class extends WeaveAction {
33733
34078
  constructor(params) {
33734
34079
  super();
33735
34080
  this.config = mergeExceptArrays(WEAVE_IMAGE_TOOL_CONFIG_DEFAULT, params?.config ?? {});
34081
+ this.initialize();
34082
+ }
34083
+ initialize() {
33736
34084
  this.pointers = new Map();
33737
34085
  this.initialized = false;
33738
34086
  this.imageId = null;
@@ -33776,7 +34124,7 @@ var WeaveImageToolAction = class extends WeaveAction {
33776
34124
  this.cancelAction();
33777
34125
  return;
33778
34126
  }
33779
- });
34127
+ }, { signal: this.instance.getEventsController()?.signal });
33780
34128
  stage.on("pointerdown", (e) => {
33781
34129
  this.setTapStart(e);
33782
34130
  if (this.ignorePointerEvents) return;
@@ -34173,6 +34521,9 @@ var WeaveImagesToolAction = class extends WeaveAction {
34173
34521
  constructor(params) {
34174
34522
  super();
34175
34523
  this.config = mergeExceptArrays(WEAVE_IMAGES_TOOL_DEFAULT_CONFIG, params ?? {});
34524
+ this.initialize();
34525
+ }
34526
+ initialize() {
34176
34527
  this.pointers = new Map();
34177
34528
  this.initialized = false;
34178
34529
  this.tempPointerFeedbackNode = null;
@@ -34219,7 +34570,7 @@ var WeaveImagesToolAction = class extends WeaveAction {
34219
34570
  const stage = this.instance.getStage();
34220
34571
  stage.container().addEventListener("keydown", (e) => {
34221
34572
  if (e.key === "Escape" && this.instance.getActiveAction() === WEAVE_IMAGES_TOOL_ACTION_NAME) this.cancelAction();
34222
- });
34573
+ }, { signal: this.instance.getEventsController()?.signal });
34223
34574
  stage.on("pointerdown", (e) => {
34224
34575
  this.setTapStart(e);
34225
34576
  this.pointers.set(e.evt.pointerId, {
@@ -34601,6 +34952,9 @@ var WeaveStarToolAction = class extends WeaveAction {
34601
34952
  onInit = void 0;
34602
34953
  constructor() {
34603
34954
  super();
34955
+ this.initialize();
34956
+ }
34957
+ initialize() {
34604
34958
  this.pointers = new Map();
34605
34959
  this.initialized = false;
34606
34960
  this.state = STAR_TOOL_STATE.IDLE;
@@ -34637,7 +34991,7 @@ var WeaveStarToolAction = class extends WeaveAction {
34637
34991
  this.cancelAction();
34638
34992
  return;
34639
34993
  }
34640
- });
34994
+ }, { signal: this.instance.getEventsController()?.signal });
34641
34995
  stage.on("pointerdown", (e) => {
34642
34996
  this.setTapStart(e);
34643
34997
  this.pointers.set(e.evt.pointerId, {
@@ -34802,8 +35156,8 @@ var WeaveStarToolAction = class extends WeaveAction {
34802
35156
 
34803
35157
  //#endregion
34804
35158
  //#region src/actions/arrow-tool/constants.ts
34805
- const ARROW_TOOL_ACTION_NAME = "arrowTool";
34806
- const ARROW_TOOL_STATE = {
35159
+ const WEAVE_ARROW_TOOL_ACTION_NAME = "arrowTool";
35160
+ const WEAVE_ARROW_TOOL_STATE = {
34807
35161
  ["IDLE"]: "idle",
34808
35162
  ["ADDING"]: "adding",
34809
35163
  ["DEFINING_SIZE"]: "definingSize",
@@ -34819,9 +35173,12 @@ var WeaveArrowToolAction = class extends WeaveAction {
34819
35173
  onInit = void 0;
34820
35174
  constructor() {
34821
35175
  super();
35176
+ this.initialize();
35177
+ }
35178
+ initialize() {
34822
35179
  this.pointers = new Map();
34823
35180
  this.initialized = false;
34824
- this.state = ARROW_TOOL_STATE.IDLE;
35181
+ this.state = WEAVE_ARROW_TOOL_STATE.IDLE;
34825
35182
  this.arrowId = null;
34826
35183
  this.tempArrowId = null;
34827
35184
  this.tempMainArrowNode = null;
@@ -34834,7 +35191,7 @@ var WeaveArrowToolAction = class extends WeaveAction {
34834
35191
  this.props = this.initProps();
34835
35192
  }
34836
35193
  getName() {
34837
- return ARROW_TOOL_ACTION_NAME;
35194
+ return WEAVE_ARROW_TOOL_ACTION_NAME;
34838
35195
  }
34839
35196
  initProps() {
34840
35197
  return {
@@ -34851,40 +35208,37 @@ var WeaveArrowToolAction = class extends WeaveAction {
34851
35208
  setupEvents() {
34852
35209
  const stage = this.instance.getStage();
34853
35210
  window.addEventListener("keydown", (e) => {
34854
- if (e.code === "Enter" && this.instance.getActiveAction() === ARROW_TOOL_ACTION_NAME) {
35211
+ if (e.code === "Enter" && this.instance.getActiveAction() === WEAVE_ARROW_TOOL_ACTION_NAME) {
34855
35212
  this.cancelAction();
34856
35213
  return;
34857
35214
  }
34858
- if (e.code === "Escape" && this.instance.getActiveAction() === ARROW_TOOL_ACTION_NAME) {
34859
- this.cancelAction();
34860
- return;
34861
- }
34862
- });
35215
+ if (e.code === "Escape" && this.instance.getActiveAction() === WEAVE_ARROW_TOOL_ACTION_NAME) this.cancelAction();
35216
+ }, { signal: this.instance.getEventsController()?.signal });
34863
35217
  stage.on("pointerdown", (e) => {
34864
35218
  this.setTapStart(e);
34865
35219
  this.pointers.set(e.evt.pointerId, {
34866
35220
  x: e.evt.clientX,
34867
35221
  y: e.evt.clientY
34868
35222
  });
34869
- if (this.pointers.size === 2 && this.instance.getActiveAction() === ARROW_TOOL_ACTION_NAME) {
34870
- this.state = ARROW_TOOL_STATE.ADDING;
35223
+ if (this.pointers.size === 2 && this.instance.getActiveAction() === WEAVE_ARROW_TOOL_ACTION_NAME) {
35224
+ this.state = WEAVE_ARROW_TOOL_STATE.ADDING;
34871
35225
  return;
34872
35226
  }
34873
- if (!this.tempMainArrowNode && this.state === ARROW_TOOL_STATE.ADDING) this.handleAdding();
34874
- if (this.tempMainArrowNode && this.state === ARROW_TOOL_STATE.ADDING) this.state = ARROW_TOOL_STATE.DEFINING_SIZE;
35227
+ if (!this.tempMainArrowNode && this.state === WEAVE_ARROW_TOOL_STATE.ADDING) this.handleAdding();
35228
+ if (this.tempMainArrowNode && this.state === WEAVE_ARROW_TOOL_STATE.ADDING) this.state = WEAVE_ARROW_TOOL_STATE.DEFINING_SIZE;
34875
35229
  });
34876
35230
  stage.on("pointermove", () => {
34877
- if (this.state === ARROW_TOOL_STATE.IDLE) return;
35231
+ if (this.state === WEAVE_ARROW_TOOL_STATE.IDLE) return;
34878
35232
  this.setCursor();
34879
- if (this.pointers.size === 2 && this.instance.getActiveAction() === ARROW_TOOL_ACTION_NAME) {
34880
- this.state = ARROW_TOOL_STATE.ADDING;
35233
+ if (this.pointers.size === 2 && this.instance.getActiveAction() === WEAVE_ARROW_TOOL_ACTION_NAME) {
35234
+ this.state = WEAVE_ARROW_TOOL_STATE.ADDING;
34881
35235
  return;
34882
35236
  }
34883
- if (this.state === ARROW_TOOL_STATE.DEFINING_SIZE) this.handleMovement();
35237
+ if (this.state === WEAVE_ARROW_TOOL_STATE.DEFINING_SIZE) this.handleMovement();
34884
35238
  });
34885
35239
  stage.on("pointerup", (e) => {
34886
35240
  this.pointers.delete(e.evt.pointerId);
34887
- if (this.state === ARROW_TOOL_STATE.DEFINING_SIZE) this.handleSettingSize();
35241
+ if (this.state === WEAVE_ARROW_TOOL_STATE.DEFINING_SIZE) this.handleSettingSize();
34888
35242
  });
34889
35243
  this.initialized = true;
34890
35244
  }
@@ -34898,7 +35252,7 @@ var WeaveArrowToolAction = class extends WeaveAction {
34898
35252
  this.tempPoint = void 0;
34899
35253
  this.tempNextPoint = void 0;
34900
35254
  this.clickPoint = null;
34901
- this.setState(ARROW_TOOL_STATE.ADDING);
35255
+ this.setState(WEAVE_ARROW_TOOL_STATE.ADDING);
34902
35256
  }
34903
35257
  handleAdding() {
34904
35258
  const stage = this.instance.getStage();
@@ -34949,7 +35303,7 @@ var WeaveArrowToolAction = class extends WeaveAction {
34949
35303
  this.measureContainer?.add(this.tempNextPoint);
34950
35304
  this.tempPoint.moveToTop();
34951
35305
  this.tempNextPoint.moveToTop();
34952
- this.setState(ARROW_TOOL_STATE.DEFINING_SIZE);
35306
+ this.setState(WEAVE_ARROW_TOOL_STATE.DEFINING_SIZE);
34953
35307
  }
34954
35308
  }
34955
35309
  handleSettingSize() {
@@ -34976,11 +35330,11 @@ var WeaveArrowToolAction = class extends WeaveAction {
34976
35330
  y: mousePoint.y,
34977
35331
  points: [0, 0]
34978
35332
  });
34979
- this.setState(ARROW_TOOL_STATE.DEFINING_SIZE);
35333
+ this.setState(WEAVE_ARROW_TOOL_STATE.DEFINING_SIZE);
34980
35334
  }
34981
35335
  }
34982
35336
  handleMovement() {
34983
- if (this.state !== ARROW_TOOL_STATE.DEFINING_SIZE) return;
35337
+ if (this.state !== WEAVE_ARROW_TOOL_STATE.DEFINING_SIZE) return;
34984
35338
  if (this.arrowId && this.tempArrowNode && this.measureContainer && this.tempNextPoint) {
34985
35339
  const { mousePoint } = this.instance.getMousePointerRelativeToContainer(this.measureContainer);
34986
35340
  this.tempArrowNode.setAttrs({
@@ -35047,7 +35401,7 @@ var WeaveArrowToolAction = class extends WeaveAction {
35047
35401
  this.container = void 0;
35048
35402
  this.measureContainer = void 0;
35049
35403
  this.clickPoint = null;
35050
- this.setState(ARROW_TOOL_STATE.IDLE);
35404
+ this.setState(WEAVE_ARROW_TOOL_STATE.IDLE);
35051
35405
  }
35052
35406
  setCursor() {
35053
35407
  const stage = this.instance.getStage();
@@ -35091,13 +35445,15 @@ const WEAVE_STROKE_TOOL_DEFAULT_CONFIG = { snapAngles: {
35091
35445
  var WeaveStrokeToolAction = class extends WeaveAction {
35092
35446
  initialized = false;
35093
35447
  initialCursor = null;
35094
- snappedAngle = null;
35095
35448
  shiftPressed = false;
35096
35449
  onPropsChange = void 0;
35097
35450
  onInit = void 0;
35098
35451
  constructor(params) {
35099
35452
  super();
35100
35453
  this.config = mergeExceptArrays(WEAVE_STROKE_TOOL_DEFAULT_CONFIG, params?.config ?? {});
35454
+ this.initialize();
35455
+ }
35456
+ initialize() {
35101
35457
  this.pointers = new Map();
35102
35458
  this.initialized = false;
35103
35459
  this.state = WEAVE_STROKE_TOOL_STATE.IDLE;
@@ -35106,7 +35462,6 @@ var WeaveStrokeToolAction = class extends WeaveAction {
35106
35462
  this.tempLineId = null;
35107
35463
  this.tempLineNode = null;
35108
35464
  this.container = void 0;
35109
- this.snappedAngle = null;
35110
35465
  this.measureContainer = void 0;
35111
35466
  this.clickPoint = null;
35112
35467
  this.snapper = new GreedySnapper({
@@ -35119,6 +35474,9 @@ var WeaveStrokeToolAction = class extends WeaveAction {
35119
35474
  getName() {
35120
35475
  return WEAVE_STROKE_TOOL_ACTION_NAME;
35121
35476
  }
35477
+ getNames() {
35478
+ return [WEAVE_STROKE_TOOL_ACTION_NAME, ...WEAVE_STROKE_TOOL_ACTION_NAME_ALIASES];
35479
+ }
35122
35480
  hasAliases() {
35123
35481
  return true;
35124
35482
  }
@@ -35137,32 +35495,26 @@ var WeaveStrokeToolAction = class extends WeaveAction {
35137
35495
  setupEvents() {
35138
35496
  const stage = this.instance.getStage();
35139
35497
  window.addEventListener("keydown", (e) => {
35140
- if (e.code === "Enter" && this.instance.getActiveAction() === WEAVE_STROKE_TOOL_ACTION_NAME) {
35498
+ if (e.code === "Enter" && this.getNames().includes(this.instance.getActiveAction() ?? "")) {
35141
35499
  this.cancelAction();
35142
35500
  return;
35143
35501
  }
35144
- if (e.code === "Escape" && this.instance.getActiveAction() === WEAVE_STROKE_TOOL_ACTION_NAME) {
35502
+ if (e.code === "Escape" && this.getNames().includes(this.instance.getActiveAction() ?? "")) {
35145
35503
  this.cancelAction();
35146
35504
  return;
35147
35505
  }
35148
- if (e.key === "Shift" && this.instance.getActiveAction() === WEAVE_STROKE_TOOL_ACTION_NAME) {
35149
- this.snappedAngle = null;
35150
- this.shiftPressed = true;
35151
- }
35152
- });
35506
+ if (e.key === "Shift" && this.getNames().includes(this.instance.getActiveAction() ?? "")) this.shiftPressed = true;
35507
+ }, { signal: this.instance.getEventsController()?.signal });
35153
35508
  window.addEventListener("keyup", (e) => {
35154
- if (e.key === "Shift" && this.instance.getActiveAction() === WEAVE_STROKE_TOOL_ACTION_NAME) {
35155
- this.snappedAngle = null;
35156
- this.shiftPressed = false;
35157
- }
35158
- });
35509
+ if (e.key === "Shift" && this.getNames().includes(this.instance.getActiveAction() ?? "")) this.shiftPressed = false;
35510
+ }, { signal: this.instance.getEventsController()?.signal });
35159
35511
  stage.on("pointerdown", (e) => {
35160
35512
  this.setTapStart(e);
35161
35513
  this.pointers.set(e.evt.pointerId, {
35162
35514
  x: e.evt.clientX,
35163
35515
  y: e.evt.clientY
35164
35516
  });
35165
- if (this.pointers.size === 2 && this.instance.getActiveAction() === WEAVE_STROKE_TOOL_ACTION_NAME) {
35517
+ if (this.pointers.size === 2 && this.getNames().includes(this.instance.getActiveAction() ?? "")) {
35166
35518
  this.state = WEAVE_STROKE_TOOL_STATE.ADDING;
35167
35519
  return;
35168
35520
  }
@@ -35172,7 +35524,7 @@ var WeaveStrokeToolAction = class extends WeaveAction {
35172
35524
  stage.on("pointermove", () => {
35173
35525
  if (this.state === WEAVE_STROKE_TOOL_STATE.IDLE) return;
35174
35526
  this.setCursor();
35175
- if (this.pointers.size === 2 && this.instance.getActiveAction() === WEAVE_STROKE_TOOL_ACTION_NAME) {
35527
+ if (this.pointers.size === 2 && this.getNames().includes(this.instance.getActiveAction() ?? "")) {
35176
35528
  this.state = WEAVE_STROKE_TOOL_STATE.ADDING;
35177
35529
  return;
35178
35530
  }
@@ -35190,7 +35542,7 @@ var WeaveStrokeToolAction = class extends WeaveAction {
35190
35542
  addLine() {
35191
35543
  this.setCursor();
35192
35544
  this.setFocusStage();
35193
- this.instance.emitEvent("onAddingStroke", { actionName: this.instance.getActiveAction() ?? WEAVE_STROKE_TOOL_ACTION_NAME });
35545
+ this.instance.emitEvent("onAddingStroke", { actionName: this.instance.getActiveAction() ?? "not-defined" });
35194
35546
  this.shiftPressed = false;
35195
35547
  this.clickPoint = null;
35196
35548
  this.setState(WEAVE_STROKE_TOOL_STATE.ADDING);
@@ -35298,7 +35650,7 @@ var WeaveStrokeToolAction = class extends WeaveAction {
35298
35650
  });
35299
35651
  delete finalLine.props.dragBoundFunc;
35300
35652
  this.instance.addNode(finalLine, this.container?.getAttrs().id);
35301
- this.instance.emitEvent("onAddedStroke", { actionName: this.instance.getActiveAction() ?? WEAVE_STROKE_TOOL_ACTION_NAME });
35653
+ this.instance.emitEvent("onAddedStroke", { actionName: this.instance.getActiveAction() ?? "not-defined" });
35302
35654
  nodeCreated = true;
35303
35655
  }
35304
35656
  }
@@ -35348,6 +35700,9 @@ var WeaveRegularPolygonToolAction = class extends WeaveAction {
35348
35700
  onInit = void 0;
35349
35701
  constructor() {
35350
35702
  super();
35703
+ this.initialize();
35704
+ }
35705
+ initialize() {
35351
35706
  this.pointers = new Map();
35352
35707
  this.initialized = false;
35353
35708
  this.state = REGULAR_POLYGON_TOOL_STATE.IDLE;
@@ -35382,7 +35737,7 @@ var WeaveRegularPolygonToolAction = class extends WeaveAction {
35382
35737
  this.cancelAction();
35383
35738
  return;
35384
35739
  }
35385
- });
35740
+ }, { signal: this.instance.getEventsController()?.signal });
35386
35741
  stage.on("pointerdown", (e) => {
35387
35742
  this.setTapStart(e);
35388
35743
  this.pointers.set(e.evt.pointerId, {
@@ -35556,6 +35911,9 @@ var WeaveFrameToolAction = class extends WeaveAction {
35556
35911
  onInit = void 0;
35557
35912
  constructor() {
35558
35913
  super();
35914
+ this.initialize();
35915
+ }
35916
+ initialize() {
35559
35917
  this.initialized = false;
35560
35918
  this.state = FRAME_TOOL_STATE.IDLE;
35561
35919
  this.frameId = null;
@@ -35583,7 +35941,7 @@ var WeaveFrameToolAction = class extends WeaveAction {
35583
35941
  this.cancelAction();
35584
35942
  return;
35585
35943
  }
35586
- });
35944
+ }, { signal: this.instance.getEventsController()?.signal });
35587
35945
  stage.on("pointermove", () => {
35588
35946
  if (this.state === FRAME_TOOL_STATE.IDLE) return;
35589
35947
  this.setCursor();
@@ -35685,6 +36043,10 @@ var WeaveExportStageToolAction = class extends WeaveAction {
35685
36043
  };
35686
36044
  onPropsChange = void 0;
35687
36045
  onInit = void 0;
36046
+ initialize = void 0;
36047
+ constructor() {
36048
+ super();
36049
+ }
35688
36050
  getName() {
35689
36051
  return EXPORT_STAGE_TOOL_ACTION_NAME;
35690
36052
  }
@@ -35732,6 +36094,10 @@ var WeaveExportNodesToolAction = class extends WeaveAction {
35732
36094
  };
35733
36095
  onPropsChange = void 0;
35734
36096
  onInit = void 0;
36097
+ initialize = void 0;
36098
+ constructor() {
36099
+ super();
36100
+ }
35735
36101
  getName() {
35736
36102
  return EXPORT_NODES_TOOL_ACTION_NAME;
35737
36103
  }
@@ -35784,6 +36150,9 @@ var WeaveAlignNodesToolAction = class extends WeaveAction {
35784
36150
  onInit = void 0;
35785
36151
  constructor() {
35786
36152
  super();
36153
+ this.initialize();
36154
+ }
36155
+ initialize() {
35787
36156
  this.initialized = false;
35788
36157
  this.state = ALIGN_NODES_TOOL_STATE.IDLE;
35789
36158
  }
@@ -36033,6 +36402,9 @@ var WeaveCommentToolAction = class extends WeaveAction {
36033
36402
  super();
36034
36403
  const { config } = params ?? {};
36035
36404
  this.config = mergeExceptArrays(WEAVE_COMMENT_TOOL_DEFAULT_CONFIG, config);
36405
+ this.initialize();
36406
+ }
36407
+ initialize() {
36036
36408
  this.pointers = new Map();
36037
36409
  this.initialized = false;
36038
36410
  this.state = WEAVE_COMMENT_TOOL_STATE.IDLE;
@@ -36110,7 +36482,7 @@ var WeaveCommentToolAction = class extends WeaveAction {
36110
36482
  return;
36111
36483
  }
36112
36484
  if (e.code === "Escape" && this.state === WEAVE_COMMENT_TOOL_STATE.CREATING_COMMENT) this.setState(WEAVE_COMMENT_TOOL_STATE.ADDING);
36113
- });
36485
+ }, { signal: this.instance.getEventsController()?.signal });
36114
36486
  stage.on("pointermove", (e) => {
36115
36487
  if (this.state === WEAVE_COMMENT_TOOL_STATE.IDLE) return;
36116
36488
  if (commentNodeHandler?.isCommentViewing()) {
@@ -36261,6 +36633,9 @@ var WeaveVideoToolAction = class extends WeaveAction {
36261
36633
  update = void 0;
36262
36634
  constructor() {
36263
36635
  super();
36636
+ this.initialize();
36637
+ }
36638
+ initialize() {
36264
36639
  this.pointers = new Map();
36265
36640
  this.initialized = false;
36266
36641
  this.state = VIDEO_TOOL_STATE.IDLE;
@@ -36307,7 +36682,7 @@ var WeaveVideoToolAction = class extends WeaveAction {
36307
36682
  this.cancelAction();
36308
36683
  return;
36309
36684
  }
36310
- });
36685
+ }, { signal: this.instance.getEventsController()?.signal });
36311
36686
  stage.on("pointerdown", (e) => {
36312
36687
  this.setTapStart(e);
36313
36688
  this.pointers.set(e.evt.pointerId, {
@@ -36440,6 +36815,9 @@ var WeaveMeasureToolAction = class extends WeaveAction {
36440
36815
  constructor(params) {
36441
36816
  super();
36442
36817
  this.config = mergeExceptArrays(WEAVE_MEASURE_TOOL_DEFAULT_CONFIG, params?.config ?? {});
36818
+ this.initialize();
36819
+ }
36820
+ initialize() {
36443
36821
  this.initialized = false;
36444
36822
  this.state = MEASURE_TOOL_STATE.IDLE;
36445
36823
  this.measureId = null;
@@ -36466,7 +36844,7 @@ var WeaveMeasureToolAction = class extends WeaveAction {
36466
36844
  const stage = this.instance.getStage();
36467
36845
  window.addEventListener("keydown", (e) => {
36468
36846
  if (e.code === "Escape" && this.instance.getActiveAction() === MEASURE_TOOL_ACTION_NAME) this.cancelAction();
36469
- });
36847
+ }, { signal: this.instance.getEventsController()?.signal });
36470
36848
  stage.on("pointermove", () => {
36471
36849
  if (this.state === MEASURE_TOOL_STATE.IDLE) return;
36472
36850
  if (this.state === MEASURE_TOOL_STATE.SET_TO) {
@@ -36736,6 +37114,9 @@ var WeaveConnectorToolAction = class extends WeaveAction {
36736
37114
  constructor(params) {
36737
37115
  super();
36738
37116
  this.config = mergeExceptArrays(CONNECTOR_TOOL_DEFAULT_CONFIG, params?.config);
37117
+ this.initialize();
37118
+ }
37119
+ initialize() {
36739
37120
  this.pointers = new Map();
36740
37121
  this.initialized = false;
36741
37122
  this.tempLineNode = null;
@@ -36774,7 +37155,7 @@ var WeaveConnectorToolAction = class extends WeaveAction {
36774
37155
  return;
36775
37156
  }
36776
37157
  if (e.code === "Escape" && this.instance.getActiveAction() === CONNECTOR_TOOL_ACTION_NAME) this.cancelAction();
36777
- });
37158
+ }, { signal: this.instance.getEventsController()?.signal });
36778
37159
  let nodeHovered = void 0;
36779
37160
  stage.on("pointermove", () => {
36780
37161
  if (!(this.state === CONNECTOR_TOOL_STATE.SELECTING_INITIAL || this.state === CONNECTOR_TOOL_STATE.SELECTING_FINAL)) return;
@@ -37089,25 +37470,25 @@ var WeaveConnectorToolAction = class extends WeaveAction {
37089
37470
  //#endregion
37090
37471
  //#region src/plugins/stage-grid/stage-grid.ts
37091
37472
  var WeaveStageGridPlugin = class extends WeavePlugin {
37092
- actStageZoomX = 1;
37093
- actStageZoomY = 1;
37094
- actStagePosX = 0;
37095
- actStagePosY = 0;
37096
37473
  constructor(params) {
37097
37474
  super();
37098
37475
  const { config } = params ?? {};
37099
37476
  this.moveToolActive = false;
37100
37477
  this.isMouseMiddleButtonPressed = false;
37101
37478
  this.isSpaceKeyPressed = false;
37102
- this.config = {
37103
- type: WEAVE_GRID_DEFAULT_TYPE,
37104
- gridColor: WEAVE_GRID_DEFAULT_COLOR,
37105
- gridOriginColor: WEAVE_GRID_DEFAULT_ORIGIN_COLOR,
37106
- gridSize: WEAVE_GRID_DEFAULT_SIZE,
37107
- gridDotMaxDotsPerAxis: WEAVE_GRID_DEFAULT_DOT_MAX_DOTS_PER_AXIS,
37108
- ...config
37109
- };
37110
37479
  this.forceStageChange = false;
37480
+ this.config = mergeExceptArrays(WEAVE_GRID_DEFAULT_CONFIG, config);
37481
+ this.initialize();
37482
+ }
37483
+ initialize() {
37484
+ this.moveToolActive = false;
37485
+ this.isMouseMiddleButtonPressed = false;
37486
+ this.isSpaceKeyPressed = false;
37487
+ this.forceStageChange = false;
37488
+ this.actStagePosX = 0;
37489
+ this.actStagePosY = 0;
37490
+ this.actStageZoomX = 1;
37491
+ this.actStageZoomY = 1;
37111
37492
  }
37112
37493
  getName() {
37113
37494
  return WEAVE_STAGE_GRID_PLUGIN_KEY;
@@ -37132,10 +37513,10 @@ var WeaveStageGridPlugin = class extends WeavePlugin {
37132
37513
  const stage = this.instance.getStage();
37133
37514
  window.addEventListener("keydown", (e) => {
37134
37515
  if (e.code === "Space") this.isSpaceKeyPressed = true;
37135
- });
37516
+ }, { signal: this.instance.getEventsController()?.signal });
37136
37517
  window.addEventListener("keyup", (e) => {
37137
37518
  if (e.code === "Space") this.isSpaceKeyPressed = false;
37138
- });
37519
+ }, { signal: this.instance.getEventsController()?.signal });
37139
37520
  this.instance.addEventListener("onStageMove", () => {
37140
37521
  this.onRender();
37141
37522
  });
@@ -37163,10 +37544,14 @@ var WeaveStageGridPlugin = class extends WeavePlugin {
37163
37544
  const layer = stage.findOne(`#${WEAVE_GRID_LAYER_ID}`);
37164
37545
  return layer;
37165
37546
  }
37547
+ getShapeAdaptiveSpacing(baseSpacing, scale) {
37548
+ const factor = Math.pow(2, Math.floor(Math.log2(1 / scale)));
37549
+ return baseSpacing * factor;
37550
+ }
37166
37551
  getAdaptiveSpacing(scale) {
37167
37552
  const baseGridSpacing = this.config.gridSize;
37168
- const minPixelSpacing = 8;
37169
- const maxPixelSpacing = 100;
37553
+ const minPixelSpacing = this.config.gridSize;
37554
+ const maxPixelSpacing = this.config.gridSize * 2;
37170
37555
  let spacing = baseGridSpacing;
37171
37556
  let pixelSpacing = spacing * scale;
37172
37557
  while (pixelSpacing < minPixelSpacing) {
@@ -37181,17 +37566,6 @@ var WeaveStageGridPlugin = class extends WeavePlugin {
37181
37566
  const snappedSpacing = baseGridSpacing * Math.pow(2, logFactor);
37182
37567
  return snappedSpacing;
37183
37568
  }
37184
- getAdjustedSpacing(startX, endX, startY, endY, baseSpacing = 50) {
37185
- let spacing = baseSpacing;
37186
- let dotCountX = Math.ceil((endX - startX) / spacing);
37187
- let dotCountY = Math.ceil((endY - startY) / spacing);
37188
- while ((dotCountX > this.config.gridDotMaxDotsPerAxis || dotCountY > this.config.gridDotMaxDotsPerAxis) && spacing < 1e6) {
37189
- spacing *= 2;
37190
- dotCountX = Math.ceil((endX - startX) / spacing);
37191
- dotCountY = Math.ceil((endY - startY) / spacing);
37192
- }
37193
- return spacing;
37194
- }
37195
37569
  renderGridLines() {
37196
37570
  const stage = this.instance.getStage();
37197
37571
  const gridLayer = this.getLayer();
@@ -37200,7 +37574,7 @@ var WeaveStageGridPlugin = class extends WeavePlugin {
37200
37574
  if (!this.enabled) return;
37201
37575
  const scale = stage.scaleX();
37202
37576
  const spacing = this.getAdaptiveSpacing(scale);
37203
- const invScale = (this.config.gridStroke ?? WEAVE_GRID_DEFAULT_STROKE) / scale;
37577
+ const invScale = this.config.gridStroke / scale;
37204
37578
  const offsetX = -stage.x() / stage.scaleX();
37205
37579
  const offsetY = -stage.y() / stage.scaleY();
37206
37580
  const margin = 2;
@@ -37210,11 +37584,19 @@ var WeaveStageGridPlugin = class extends WeavePlugin {
37210
37584
  const startY = Math.floor((offsetY - margin * worldHeight) / spacing) * spacing;
37211
37585
  const endX = offsetX + (1 + margin) * worldWidth;
37212
37586
  const endY = offsetY + (1 + margin) * worldHeight;
37213
- const highlightEvery = this.config.gridMajorEvery ?? WEAVE_GRID_DEFAULT_MAJOR_EVERY;
37587
+ const highlightEvery = this.config.gridMajorEvery;
37214
37588
  for (let x = startX; x <= endX; x += spacing) {
37215
37589
  const index = Math.round(x / spacing);
37216
37590
  const isHighlight = index % highlightEvery === 0;
37217
37591
  const isOrigin = Math.abs(x) < spacing / 2;
37592
+ let stroke = this.config.gridColor;
37593
+ if (isOrigin) stroke = this.config.gridOriginColor;
37594
+ else if (isHighlight) stroke = this.config.gridMajorColor;
37595
+ let strokeWidth = invScale;
37596
+ if (isHighlight || isOrigin) strokeWidth = invScale * this.config.gridMajorRatio;
37597
+ let zIndex = 1;
37598
+ if (isOrigin) zIndex = 3;
37599
+ else if (isHighlight) zIndex = 2;
37218
37600
  const line = new Konva.Line({
37219
37601
  points: [
37220
37602
  x,
@@ -37222,9 +37604,10 @@ var WeaveStageGridPlugin = class extends WeavePlugin {
37222
37604
  x,
37223
37605
  endY
37224
37606
  ],
37225
- stroke: isOrigin ? this.config.gridOriginColor : this.config.gridColor,
37226
- strokeWidth: !isHighlight && !isOrigin ? invScale : invScale * (this.config.gridMajorRatio ?? WEAVE_GRID_DEFAULT_MAJOR_LINE_RATIO),
37227
- listening: false
37607
+ stroke,
37608
+ strokeWidth,
37609
+ listening: false,
37610
+ zIndex
37228
37611
  });
37229
37612
  gridLayer.add(line);
37230
37613
  }
@@ -37232,6 +37615,14 @@ var WeaveStageGridPlugin = class extends WeavePlugin {
37232
37615
  const index = Math.round(y / spacing);
37233
37616
  const isHighlight = index % highlightEvery === 0;
37234
37617
  const isOrigin = Math.abs(y) < spacing / 2;
37618
+ let stroke = this.config.gridColor;
37619
+ if (isOrigin) stroke = this.config.gridOriginColor;
37620
+ else if (isHighlight) stroke = this.config.gridMajorColor;
37621
+ let strokeWidth = invScale;
37622
+ if (isHighlight || isOrigin) strokeWidth = invScale * this.config.gridMajorRatio;
37623
+ let zIndex = 1;
37624
+ if (isOrigin) zIndex = 3;
37625
+ else if (isHighlight) zIndex = 2;
37235
37626
  const line = new Konva.Line({
37236
37627
  points: [
37237
37628
  startX,
@@ -37239,9 +37630,10 @@ var WeaveStageGridPlugin = class extends WeavePlugin {
37239
37630
  endX,
37240
37631
  y
37241
37632
  ],
37242
- stroke: isOrigin ? this.config.gridOriginColor : this.config.gridColor,
37243
- strokeWidth: !isHighlight && !isOrigin ? invScale : invScale * 2,
37244
- listening: false
37633
+ stroke,
37634
+ strokeWidth,
37635
+ listening: false,
37636
+ zIndex
37245
37637
  });
37246
37638
  gridLayer.add(line);
37247
37639
  }
@@ -37252,67 +37644,78 @@ var WeaveStageGridPlugin = class extends WeavePlugin {
37252
37644
  if (!gridLayer) return;
37253
37645
  gridLayer.destroyChildren();
37254
37646
  if (!this.enabled) return;
37255
- const scale = stage.scaleX();
37256
- const spacing = this.getAdaptiveSpacing(scale);
37257
- const invScale = (this.config.gridDotRadius ?? WEAVE_GRID_DEFAULT_RADIUS) / scale;
37258
- const position = stage.position();
37259
- const offsetX = -position.x * invScale;
37260
- const offsetY = -position.y * invScale;
37261
- const margin = 2;
37262
- const worldWidth = stage.width() * invScale;
37263
- const worldHeight = stage.height() * invScale;
37264
- let startX = Math.floor((offsetX - margin * worldWidth) / spacing) * spacing;
37265
- const endX = offsetX + (1 + margin) * worldWidth;
37266
- let startY = Math.floor((offsetY - margin * worldHeight) / spacing) * spacing;
37267
- const endY = offsetY + (1 + margin) * worldHeight;
37268
- let adjustedSpacing = spacing;
37269
- let dotCountX = Math.ceil((endX - startX) / adjustedSpacing);
37270
- let dotCountY = Math.ceil((endY - startY) / adjustedSpacing);
37271
- while ((dotCountX > this.config.gridDotMaxDotsPerAxis || dotCountY > this.config.gridDotMaxDotsPerAxis) && adjustedSpacing < 1e6) {
37272
- adjustedSpacing *= 2;
37273
- dotCountX = Math.ceil((endX - startX) / adjustedSpacing);
37274
- dotCountY = Math.ceil((endY - startY) / adjustedSpacing);
37275
- }
37276
- this.getAdjustedSpacing(startX, endX, startY, endY, spacing);
37277
- startX = Math.floor((offsetX - margin * worldWidth) / adjustedSpacing) * adjustedSpacing;
37278
- startY = Math.floor((offsetY - margin * worldHeight) / adjustedSpacing) * adjustedSpacing;
37279
- const highlightEvery = this.config.gridMajorEvery ?? WEAVE_GRID_DEFAULT_MAJOR_EVERY;
37280
- const majorColor = this.config.gridColor;
37281
- const gridMajorRatio = this.config.gridMajorRatio ?? WEAVE_GRID_DEFAULT_MAJOR_DOT_RATIO;
37282
- const majorShape = new Konva.Shape({ sceneFunc: function(context) {
37283
- context.beginPath();
37284
- for (let x = startX; x <= endX; x += adjustedSpacing) for (let y = startY; y <= endY; y += adjustedSpacing) {
37285
- if (Math.abs(x) < spacing / 2 || Math.abs(y) < spacing / 2) continue;
37286
- const indexX = Math.round(x / spacing);
37287
- const indexY = Math.round(y / spacing);
37288
- const isHighlightX = indexX % highlightEvery === 0;
37289
- const isHighlightY = indexY % highlightEvery === 0;
37290
- const radius = !(isHighlightX || isHighlightY) ? invScale : invScale * gridMajorRatio;
37291
- context.moveTo(x + radius, y);
37292
- context.arc(x, y, radius, 0, Math.PI * 2, false);
37293
- }
37294
- context.fillStyle = majorColor;
37295
- context.fill();
37296
- } });
37297
- gridLayer.add(majorShape);
37298
- const originColor = this.config.gridOriginColor;
37299
- const originShape = new Konva.Shape({ sceneFunc: function(context) {
37300
- context.beginPath();
37301
- for (let x = startX; x <= endX; x += adjustedSpacing) {
37302
- const radius = invScale * gridMajorRatio;
37303
- context.moveTo(x + radius, 0);
37304
- context.arc(x, 0, radius, 0, Math.PI * 2);
37305
- }
37306
- for (let y = startY; y <= endY; y += adjustedSpacing) {
37307
- const radius = invScale * gridMajorRatio;
37308
- if (Math.abs(y) < spacing / 2) continue;
37309
- context.moveTo(0 + radius, y);
37310
- context.arc(0, y, radius, 0, Math.PI * 2);
37311
- }
37312
- context.fillStyle = originColor;
37313
- context.fill();
37314
- } });
37315
- gridLayer.add(originShape);
37647
+ const grid = new Konva.Shape({
37648
+ listening: false,
37649
+ sceneFunc: (ctx) => {
37650
+ const dotType = this.config.gridDotType;
37651
+ const scale = stage.scaleX();
37652
+ const pos = stage.position();
37653
+ const baseSpacing = this.config.gridSize;
37654
+ const spacing = this.getShapeAdaptiveSpacing(baseSpacing, scale);
37655
+ const highlightEvery = this.config.gridMajorEvery;
37656
+ const defaultColor = this.config.gridColor;
37657
+ const majorColor = this.config.gridMajorColor;
37658
+ const centerColor = this.config.gridOriginColor;
37659
+ if (dotType === WEAVE_GRID_DOT_TYPES.CIRCLE) {
37660
+ const scale$1 = stage.scaleX();
37661
+ const pos$1 = stage.position();
37662
+ const topLeftX = -pos$1.x / scale$1;
37663
+ const topLeftY = -pos$1.y / scale$1;
37664
+ const viewWidth = stage.width() / scale$1;
37665
+ const viewHeight = stage.height() / scale$1;
37666
+ const startX = Math.floor(topLeftX / spacing) * spacing;
37667
+ const startY = Math.floor(topLeftY / spacing) * spacing;
37668
+ const dotRadius = this.config.gridDotRadius;
37669
+ const dotMajorRadius = dotRadius * this.config.gridMajorRatio;
37670
+ for (let x = startX; x < topLeftX + viewWidth; x += spacing) for (let y = startY; y < topLeftY + viewHeight; y += spacing) {
37671
+ const indexX = Math.round(x / spacing);
37672
+ const indexY = Math.round(y / spacing);
37673
+ const isHighlightX = indexX % highlightEvery === 0;
37674
+ const isHighlightY = indexY % highlightEvery === 0;
37675
+ const isHighlight = isHighlightX || isHighlightY;
37676
+ const isOriginX = Math.abs(x) < spacing / 2;
37677
+ const isOriginY = Math.abs(y) < spacing / 2;
37678
+ const isOrigin = isOriginX || isOriginY;
37679
+ let fillStyle = defaultColor;
37680
+ if (isOrigin) fillStyle = centerColor;
37681
+ else if (isHighlight) fillStyle = majorColor;
37682
+ ctx.fillStyle = fillStyle;
37683
+ ctx.beginPath();
37684
+ ctx.arc(x, y, (isHighlight ? dotMajorRadius : dotRadius) / scale$1, 0, Math.PI * 2);
37685
+ ctx.fill();
37686
+ }
37687
+ }
37688
+ if (dotType === WEAVE_GRID_DOT_TYPES.SQUARE) {
37689
+ const topLeftX = -pos.x / scale;
37690
+ const topLeftY = -pos.y / scale;
37691
+ const viewWidth = stage.width() / scale;
37692
+ const viewHeight = stage.height() / scale;
37693
+ const startX = Math.floor(topLeftX / spacing) * spacing;
37694
+ const startY = Math.floor(topLeftY / spacing) * spacing;
37695
+ const defaultSize = this.config.gridDotRectSize;
37696
+ const majorSize = defaultSize * this.config.gridMajorRatio;
37697
+ for (let x = startX; x < topLeftX + viewWidth; x += spacing) for (let y = startY; y < topLeftY + viewHeight; y += spacing) {
37698
+ const sx = Math.round(x * scale) / scale;
37699
+ const sy = Math.round(y * scale) / scale;
37700
+ const indexX = Math.round(sx / spacing);
37701
+ const indexY = Math.round(sy / spacing);
37702
+ const isHighlightX = indexX % highlightEvery === 0;
37703
+ const isHighlightY = indexY % highlightEvery === 0;
37704
+ const isHighlight = isHighlightX || isHighlightY;
37705
+ const isOriginX = Math.abs(sx) < spacing / 2;
37706
+ const isOriginY = Math.abs(sy) < spacing / 2;
37707
+ const isOrigin = isOriginX || isOriginY;
37708
+ let fillStyle = defaultColor;
37709
+ if (isOrigin) fillStyle = centerColor;
37710
+ else if (isHighlight) fillStyle = majorColor;
37711
+ ctx.fillStyle = fillStyle;
37712
+ const size = (isHighlight ? majorSize : defaultSize) / scale;
37713
+ ctx.fillRect(sx - size / 2, sy - size / 2, size, size);
37714
+ }
37715
+ }
37716
+ }
37717
+ });
37718
+ gridLayer.add(grid);
37316
37719
  }
37317
37720
  hasStageChanged() {
37318
37721
  if (this.forceStageChange) {
@@ -37349,11 +37752,13 @@ var WeaveStageGridPlugin = class extends WeavePlugin {
37349
37752
  enable() {
37350
37753
  this.enabled = true;
37351
37754
  this.getLayer()?.show();
37755
+ this.forceStageChange = true;
37352
37756
  this.onRender();
37353
37757
  }
37354
37758
  disable() {
37355
37759
  this.enabled = false;
37356
37760
  this.getLayer()?.hide();
37761
+ this.forceStageChange = true;
37357
37762
  this.onRender();
37358
37763
  }
37359
37764
  getType() {
@@ -37364,20 +37769,27 @@ var WeaveStageGridPlugin = class extends WeavePlugin {
37364
37769
  this.forceStageChange = true;
37365
37770
  this.onRender();
37366
37771
  }
37772
+ getDotsType() {
37773
+ return this.config.gridDotType;
37774
+ }
37775
+ setDotsType(type) {
37776
+ this.config.gridDotType = type;
37777
+ this.forceStageChange = true;
37778
+ this.onRender();
37779
+ }
37367
37780
  };
37368
37781
 
37369
37782
  //#endregion
37370
37783
  //#region src/plugins/stage-panning/stage-panning.ts
37371
37784
  var WeaveStagePanningPlugin = class extends WeavePlugin {
37372
- panning = false;
37373
- currentPointer = null;
37374
- stageScrollInterval = void 0;
37375
- panEdgeTargets = {};
37376
37785
  getLayerName = void 0;
37377
37786
  initLayer = void 0;
37378
37787
  constructor(params) {
37379
37788
  super();
37380
37789
  this.config = mergeExceptArrays(WEAVE_STAGE_PANNING_DEFAULT_CONFIG, params?.config ?? {});
37790
+ this.initialize();
37791
+ }
37792
+ initialize() {
37381
37793
  this.pointers = new Map();
37382
37794
  this.panning = false;
37383
37795
  this.isDragging = false;
@@ -37389,6 +37801,9 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
37389
37801
  this.isCtrlOrMetaPressed = false;
37390
37802
  this.isSpaceKeyPressed = false;
37391
37803
  this.previousPointer = null;
37804
+ this.currentPointer = null;
37805
+ this.stageScrollInterval = void 0;
37806
+ this.panEdgeTargets = {};
37392
37807
  }
37393
37808
  getName() {
37394
37809
  return WEAVE_STAGE_PANNING_KEY;
@@ -37422,7 +37837,7 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
37422
37837
  this.isSpaceKeyPressed = true;
37423
37838
  this.setCursor();
37424
37839
  }
37425
- });
37840
+ }, { signal: this.instance.getEventsController()?.signal });
37426
37841
  window.addEventListener("keyup", (e) => {
37427
37842
  if (e.key === "Meta" || e.key === "Control") this.isCtrlOrMetaPressed = false;
37428
37843
  if (e.code === "Space") {
@@ -37433,7 +37848,7 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
37433
37848
  this.isSpaceKeyPressed = false;
37434
37849
  this.disableMove();
37435
37850
  }
37436
- });
37851
+ }, { signal: this.instance.getEventsController()?.signal });
37437
37852
  let lastPos = null;
37438
37853
  stage.on("pointerdown", (e) => {
37439
37854
  this.pointers.set(e.evt.pointerId, {
@@ -37506,7 +37921,10 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
37506
37921
  this.instance.emitEvent("onStageMove");
37507
37922
  };
37508
37923
  const handleWheelThrottled = (0, import_lodash.throttle)(handleWheel, WEAVE_STAGE_PANNING_THROTTLE_MS);
37509
- window.addEventListener("wheel", handleWheelThrottled, { passive: true });
37924
+ window.addEventListener("wheel", handleWheelThrottled, {
37925
+ passive: true,
37926
+ signal: this.instance.getEventsController()?.signal
37927
+ });
37510
37928
  stage.on("dragstart", (e) => {
37511
37929
  const duration = 1e3 / 60;
37512
37930
  if (this.panEdgeTargets[e.target.getAttrs().id ?? ""] !== void 0) return;
@@ -37564,7 +37982,10 @@ var WeaveStagePanningPlugin = class extends WeavePlugin {
37564
37982
  stage.container().style.setProperty("-webkit-user-drag", "none");
37565
37983
  stage.getContent().addEventListener("touchmove", function(e) {
37566
37984
  e.preventDefault();
37567
- }, { passive: false });
37985
+ }, {
37986
+ passive: false,
37987
+ signal: this.instance.getEventsController()?.signal
37988
+ });
37568
37989
  }
37569
37990
  isPanning() {
37570
37991
  return this.panning;
@@ -37642,6 +38063,9 @@ var WeaveStageMinimapPlugin = class extends WeavePlugin {
37642
38063
  constructor(params) {
37643
38064
  super();
37644
38065
  this.config = mergeExceptArrays(STAGE_MINIMAP_DEFAULT_CONFIG, params.config);
38066
+ this.initialize();
38067
+ }
38068
+ initialize() {
37645
38069
  this.initialized = false;
37646
38070
  }
37647
38071
  getName() {
@@ -37819,6 +38243,7 @@ const WEAVE_STAGE_RESIZE_KEY = "stageResize";
37819
38243
  var WeaveStageResizePlugin = class extends WeavePlugin {
37820
38244
  getLayerName = void 0;
37821
38245
  initLayer = void 0;
38246
+ initialize = void 0;
37822
38247
  getName() {
37823
38248
  return WEAVE_STAGE_RESIZE_KEY;
37824
38249
  }
@@ -37838,6 +38263,10 @@ var WeaveStageResizePlugin = class extends WeavePlugin {
37838
38263
  const pluginInstance = plugins[pluginId];
37839
38264
  pluginInstance.onRender?.();
37840
38265
  }
38266
+ this.instance.emitEvent("onStageResize", {
38267
+ width: stage.width(),
38268
+ height: stage.height()
38269
+ });
37841
38270
  }
37842
38271
  }
37843
38272
  onInit() {
@@ -37846,7 +38275,7 @@ var WeaveStageResizePlugin = class extends WeavePlugin {
37846
38275
  }, DEFAULT_THROTTLE_MS);
37847
38276
  window.addEventListener("resize", () => {
37848
38277
  throttledResize();
37849
- });
38278
+ }, { signal: this.instance.getEventsController()?.signal });
37850
38279
  const resizeObserver = new ResizeObserver(() => {
37851
38280
  throttledResize();
37852
38281
  });
@@ -37864,10 +38293,12 @@ var WeaveStageResizePlugin = class extends WeavePlugin {
37864
38293
  //#endregion
37865
38294
  //#region src/plugins/nodes-multi-selection-feedback/nodes-multi-selection-feedback.ts
37866
38295
  var WeaveNodesMultiSelectionFeedbackPlugin = class extends WeavePlugin {
37867
- selectedHalos = {};
37868
38296
  constructor(params) {
37869
38297
  super();
37870
38298
  this.config = mergeExceptArrays(WEAVE_NODES_MULTI_SELECTION_FEEDBACK_PLUGIN_DEFAULT_CONFIG, params?.config ?? {});
38299
+ this.initialize();
38300
+ }
38301
+ initialize() {
37871
38302
  this.selectedHalos = {};
37872
38303
  }
37873
38304
  getName() {
@@ -38033,12 +38464,14 @@ var WeaveNodesMultiSelectionFeedbackPlugin = class extends WeavePlugin {
38033
38464
  //#endregion
38034
38465
  //#region src/plugins/connected-users/connected-users.ts
38035
38466
  var WeaveConnectedUsersPlugin = class extends WeavePlugin {
38036
- connectedUsers = {};
38037
38467
  getLayerName = void 0;
38038
38468
  constructor(params) {
38039
38469
  super();
38040
38470
  const { config } = params ?? {};
38041
38471
  this.config = config;
38472
+ this.initialize();
38473
+ }
38474
+ initialize() {
38042
38475
  this.connectedUsers = {};
38043
38476
  }
38044
38477
  getName() {
@@ -38085,6 +38518,9 @@ var WeaveUsersSelectionPlugin = class extends WeavePlugin {
38085
38518
  this.config = config;
38086
38519
  this.config.getUser = memoize(this.config.getUser);
38087
38520
  this.config.getUserColor = memoize(this.config.getUserColor);
38521
+ this.initialize();
38522
+ }
38523
+ initialize() {
38088
38524
  this.usersSelection = {};
38089
38525
  }
38090
38526
  getName() {
@@ -38277,6 +38713,9 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
38277
38713
  this.config.getUser = memoize(this.config.getUser);
38278
38714
  this.config.getUserBackgroundColor = memoize(this.config.getUserBackgroundColor);
38279
38715
  this.config.getUserForegroundColor = memoize(this.config.getUserForegroundColor);
38716
+ this.initialize();
38717
+ }
38718
+ initialize() {
38280
38719
  this.usersPointers = {};
38281
38720
  this.usersOperations = {};
38282
38721
  }
@@ -38487,6 +38926,9 @@ var WeaveUsersPresencePlugin = class extends WeavePlugin {
38487
38926
  super();
38488
38927
  const { config } = params;
38489
38928
  this.config = mergeExceptArrays(WEAVE_USERS_PRESENCE_CONFIG_DEFAULT_PROPS, config);
38929
+ this.initialize();
38930
+ }
38931
+ initialize() {
38490
38932
  this.userPresence = {};
38491
38933
  }
38492
38934
  getName() {
@@ -38562,6 +39004,9 @@ var WeaveStageDropAreaPlugin = class extends WeavePlugin {
38562
39004
  initLayer = void 0;
38563
39005
  constructor() {
38564
39006
  super();
39007
+ this.initialize();
39008
+ }
39009
+ initialize() {
38565
39010
  this.enabled = true;
38566
39011
  }
38567
39012
  getName() {
@@ -38575,14 +39020,20 @@ var WeaveStageDropAreaPlugin = class extends WeavePlugin {
38575
39020
  stage.container().addEventListener("dragover", (e) => {
38576
39021
  e.preventDefault();
38577
39022
  e.stopPropagation();
38578
- });
39023
+ }, { signal: this.instance.getEventsController()?.signal });
38579
39024
  stage.container().addEventListener("drop", (e) => {
38580
39025
  e.preventDefault();
38581
39026
  e.stopPropagation();
38582
39027
  this.instance.emitEvent("onStageDrop", e);
39028
+ }, { signal: this.instance.getEventsController()?.signal });
39029
+ window.addEventListener("dragover", (e) => e.preventDefault(), {
39030
+ signal: this.instance.getEventsController()?.signal,
39031
+ passive: false
39032
+ });
39033
+ window.addEventListener("drop", (e) => e.preventDefault(), {
39034
+ signal: this.instance.getEventsController()?.signal,
39035
+ passive: false
38583
39036
  });
38584
- window.addEventListener("dragover", (e) => e.preventDefault(), { passive: false });
38585
- window.addEventListener("drop", (e) => e.preventDefault(), { passive: false });
38586
39037
  }
38587
39038
  enable() {
38588
39039
  this.enabled = true;
@@ -38601,6 +39052,9 @@ var WeaveNodesEdgeSnappingPlugin = class extends WeavePlugin {
38601
39052
  this.guideLineConfig = config?.guideLine ?? GUIDE_LINE_DEFAULT_CONFIG;
38602
39053
  this.dragSnappingThreshold = config?.dragSnappingThreshold ?? GUIDE_LINE_DRAG_SNAPPING_THRESHOLD;
38603
39054
  this.transformSnappingThreshold = config?.transformSnappingThreshold ?? GUIDE_LINE_TRANSFORM_SNAPPING_THRESHOLD;
39055
+ this.initialize();
39056
+ }
39057
+ initialize() {
38604
39058
  this.enabled = true;
38605
39059
  }
38606
39060
  getName() {
@@ -38977,6 +39431,9 @@ var WeaveNodesDistanceSnappingPlugin = class extends WeavePlugin {
38977
39431
  this.enterSnappingTolerance = config?.enterSnappingTolerance ?? GUIDE_ENTER_SNAPPING_TOLERANCE;
38978
39432
  this.exitSnappingTolerance = config?.exitSnappingTolerance ?? GUIDE_EXIT_SNAPPING_TOLERANCE;
38979
39433
  this.uiConfig = mergeExceptArrays(GUIDE_DISTANCE_LINE_DEFAULT_CONFIG, config?.ui);
39434
+ this.initialize();
39435
+ }
39436
+ initialize() {
38980
39437
  this.enabled = true;
38981
39438
  }
38982
39439
  getName() {
@@ -39623,12 +40080,14 @@ var WeaveNodesDistanceSnappingPlugin = class extends WeavePlugin {
39623
40080
  //#endregion
39624
40081
  //#region src/plugins/comments-renderer/comments-renderer.ts
39625
40082
  var WeaveCommentsRendererPlugin = class extends WeavePlugin {
39626
- comments = [];
39627
40083
  getLayerName = void 0;
39628
40084
  constructor(params) {
39629
40085
  super();
39630
40086
  const { config } = params ?? {};
39631
40087
  this.config = config;
40088
+ this.initialize();
40089
+ }
40090
+ initialize() {
39632
40091
  this.comments = [];
39633
40092
  }
39634
40093
  getName() {
@@ -39719,6 +40178,7 @@ const WEAVE_STAGE_KEYBOARD_MOVE_DEFAULT_CONFIG = { movementDelta: 5 };
39719
40178
  var WeaveStageKeyboardMovePlugin = class extends WeavePlugin {
39720
40179
  getLayerName = void 0;
39721
40180
  initLayer = void 0;
40181
+ initialize = void 0;
39722
40182
  constructor(params) {
39723
40183
  super();
39724
40184
  this.config = mergeExceptArrays(WEAVE_STAGE_KEYBOARD_MOVE_DEFAULT_CONFIG, params?.config ?? {});
@@ -39757,7 +40217,7 @@ var WeaveStageKeyboardMovePlugin = class extends WeavePlugin {
39757
40217
  if (e.code === "ArrowLeft" && e.shiftKey) this.handleNodesMovement("left");
39758
40218
  if (e.code === "ArrowRight" && e.shiftKey) this.handleNodesMovement("right");
39759
40219
  if (e.code === "ArrowDown" && e.shiftKey) this.handleNodesMovement("down");
39760
- });
40220
+ }, { signal: this.instance.getEventsController()?.signal });
39761
40221
  }
39762
40222
  enable() {
39763
40223
  this.enabled = true;
@@ -39779,4 +40239,4 @@ const setupCanvasBackend = async () => {
39779
40239
  };
39780
40240
 
39781
40241
  //#endregion
39782
- 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_COLOR, WEAVE_GRID_DEFAULT_DOT_MAX_DOTS_PER_AXIS, WEAVE_GRID_DEFAULT_MAJOR_DOT_RATIO, WEAVE_GRID_DEFAULT_MAJOR_EVERY, WEAVE_GRID_DEFAULT_MAJOR_LINE_RATIO, WEAVE_GRID_DEFAULT_ORIGIN_COLOR, WEAVE_GRID_DEFAULT_RADIUS, WEAVE_GRID_DEFAULT_SIZE, WEAVE_GRID_DEFAULT_STROKE, WEAVE_GRID_DEFAULT_TYPE, 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, getPositionRelativeToContainerOnPosition, getSelectedNodesMetadata, getStageClickPoint, getTargetAndSkipNodes, getTargetedNode, getTopmostShadowHost, getVisibleNodes, getVisibleNodesInViewport, hasFrames, hasImages, intersectArrays, isIOS, isInShadowDOM, isNodeInSelection, isServer, loadImageSource, memoize, mergeExceptArrays, moveNodeToContainer, moveNodeToContainerNT, resetScale, setupCanvasBackend, setupSkiaBackend };
40242
+ 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, getPositionRelativeToContainerOnPosition, getSelectedNodesMetadata, getStageClickPoint, getTargetAndSkipNodes, getTargetedNode, getTopmostShadowHost, getVisibleNodes, getVisibleNodesInViewport, hasFrames, hasImages, intersectArrays, isIOS, isInShadowDOM, isNodeInSelection, isServer, loadImageSource, memoize, mergeExceptArrays, moveNodeToContainer, moveNodeToContainerNT, resetScale, setupCanvasBackend, setupSkiaBackend };