@inditextech/weave-sdk 0.7.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/sdk.js CHANGED
@@ -15484,6 +15484,7 @@ var require_lodash = __commonJS({ "../../node_modules/lodash/lodash.js"(exports,
15484
15484
  } else root._ = _;
15485
15485
  }).call(exports);
15486
15486
  } });
15487
+ var import_lodash$1 = __toESM(require_lodash());
15487
15488
  var import_lodash = __toESM(require_lodash(), 1);
15488
15489
 
15489
15490
  //#endregion
@@ -15571,13 +15572,13 @@ var WeaveStore = class {
15571
15572
  const newState = JSON.parse(JSON.stringify(this.getState()));
15572
15573
  config.callbacks?.onStateChange?.(newState);
15573
15574
  this.instance.emitEvent("onStateChange", newState);
15574
- if (!this.isRoomLoaded && !(0, import_lodash.isEmpty)(this.state.weave)) {
15575
+ if (!this.isRoomLoaded && !(0, import_lodash$1.isEmpty)(this.state.weave)) {
15575
15576
  this.instance.setupRenderer();
15576
15577
  this.isRoomLoaded = true;
15577
15578
  config.callbacks?.onRoomLoaded?.(this.isRoomLoaded);
15578
15579
  this.instance.emitEvent("onRoomLoaded", this.isRoomLoaded);
15579
15580
  }
15580
- if (this.isRoomLoaded && !(0, import_lodash.isEmpty)(this.state.weave)) this.instance.render();
15581
+ if (this.isRoomLoaded && !(0, import_lodash$1.isEmpty)(this.state.weave)) this.instance.render();
15581
15582
  });
15582
15583
  }
15583
15584
  canUndoStateStep() {
@@ -15639,13 +15640,12 @@ var WeaveContextMenuPlugin = class extends WeavePlugin {
15639
15640
  super();
15640
15641
  this.touchTimer = void 0;
15641
15642
  this.tapHold = false;
15642
- const { callbacks, config } = params ?? {};
15643
+ const { config } = params ?? {};
15643
15644
  this.config = {
15644
15645
  xOffset: WEAVE_CONTEXT_MENU_X_OFFSET_DEFAULT,
15645
15646
  yOffset: WEAVE_CONTEXT_MENU_Y_OFFSET_DEFAULT,
15646
15647
  ...config
15647
15648
  };
15648
- this.callbacks = { ...callbacks };
15649
15649
  }
15650
15650
  getName() {
15651
15651
  return WEAVE_CONTEXT_MENU_KEY;
@@ -15682,7 +15682,11 @@ var WeaveContextMenuPlugin = class extends WeavePlugin {
15682
15682
  x: containerRect.left + pointerPos.x + (this.config.xOffset ?? 4),
15683
15683
  y: containerRect.top + pointerPos.y + (this.config.yOffset ?? 4)
15684
15684
  };
15685
- this.callbacks.onNodeMenu?.(this.instance, nodes, point, true);
15685
+ this.instance.emitEvent("onNodeContextMenu", {
15686
+ selection: nodes,
15687
+ point,
15688
+ visible: true
15689
+ });
15686
15690
  }
15687
15691
  }
15688
15692
  initEvents() {
@@ -15718,7 +15722,11 @@ var WeaveContextMenuPlugin = class extends WeavePlugin {
15718
15722
  x: containerRect.left + pointerPos.x + (this.config.xOffset ?? 4),
15719
15723
  y: containerRect.top + pointerPos.y + (this.config.yOffset ?? 4)
15720
15724
  };
15721
- this.callbacks.onNodeMenu?.(this.instance, [], point, false);
15725
+ this.instance.emitEvent("onNodeContextMenu", {
15726
+ selection: [],
15727
+ point,
15728
+ visible: false
15729
+ });
15722
15730
  }
15723
15731
  });
15724
15732
  }
@@ -15738,7 +15746,7 @@ var WeaveContextMenuPlugin = class extends WeavePlugin {
15738
15746
  var WeaveNodesSelectionPlugin = class extends WeavePlugin {
15739
15747
  constructor(params) {
15740
15748
  super();
15741
- const { config, callbacks } = params ?? {};
15749
+ const { config } = params ?? {};
15742
15750
  this.config = { transformer: {
15743
15751
  rotationSnaps: [
15744
15752
  0,
@@ -15776,7 +15784,6 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
15776
15784
  borderStroke: "#1e40afff",
15777
15785
  ...config?.transformer
15778
15786
  } };
15779
- this.callbacks = callbacks ?? {};
15780
15787
  this.active = false;
15781
15788
  this.cameFromSelectingMultiple = false;
15782
15789
  this.selecting = false;
@@ -15794,6 +15801,10 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
15794
15801
  const layer = new Konva.Layer({ id: this.getLayerName() });
15795
15802
  stage.add(layer);
15796
15803
  }
15804
+ isPasting() {
15805
+ const copyPastePlugin = this.instance.getPlugin("copyPasteNodes");
15806
+ return copyPastePlugin.isPasting();
15807
+ }
15797
15808
  isSelecting() {
15798
15809
  return this.instance.getActiveAction() === "selectionTool";
15799
15810
  }
@@ -15837,14 +15848,18 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
15837
15848
  if (nodesSnappingPlugin && this.isSelecting() && this.isNodeSelected(node)) nodesSnappingPlugin.cleanupEvaluateGuidelines();
15838
15849
  });
15839
15850
  tr.on("mouseenter", (e) => {
15840
- const stage$1 = this.instance.getStage();
15841
- stage$1.container().style.cursor = "grab";
15842
- e.cancelBubble = true;
15851
+ if (!this.isPasting()) {
15852
+ const stage$1 = this.instance.getStage();
15853
+ stage$1.container().style.cursor = "grab";
15854
+ e.cancelBubble = true;
15855
+ }
15843
15856
  });
15844
15857
  tr.on("mouseleave", (e) => {
15845
- const stage$1 = this.instance.getStage();
15846
- stage$1.container().style.cursor = "default";
15847
- e.cancelBubble = true;
15858
+ if (!this.isPasting()) {
15859
+ const stage$1 = this.instance.getStage();
15860
+ stage$1.container().style.cursor = "default";
15861
+ e.cancelBubble = true;
15862
+ }
15848
15863
  });
15849
15864
  this.tr = tr;
15850
15865
  this.selectionRectangle = selectionRectangle;
@@ -15892,7 +15907,6 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
15892
15907
  node: nodeHandler.serialize(node)
15893
15908
  };
15894
15909
  });
15895
- this.callbacks?.onNodesChange?.(selectedNodes);
15896
15910
  this.instance.emitEvent("onNodesChange", selectedNodes);
15897
15911
  }
15898
15912
  initEvents() {
@@ -16012,10 +16026,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
16012
16026
  if (e.target instanceof Konva.Stage && !selectedGroup) {
16013
16027
  this.tr.nodes([]);
16014
16028
  this.triggerSelectedNodesEvent();
16015
- if (contextMenuPlugin && !contextMenuPlugin.isTapHold()) {
16016
- this.callbacks?.onStageSelection?.();
16017
- this.instance.emitEvent("onStageSelection", void 0);
16018
- }
16029
+ if (contextMenuPlugin && !contextMenuPlugin.isTapHold()) this.instance.emitEvent("onStageSelection");
16019
16030
  return;
16020
16031
  }
16021
16032
  const metaPressed = e.evt.shiftKey || e.evt.ctrlKey || e.evt.metaKey;
@@ -16066,6 +16077,17 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
16066
16077
  getSelectedNodes() {
16067
16078
  return this.tr.nodes();
16068
16079
  }
16080
+ getSelectedNodesExtended() {
16081
+ const selectedNodes = this.tr.getNodes().map((node) => {
16082
+ const nodeType = node.getAttr("nodeType");
16083
+ const nodeHandler = this.instance.getNodeHandler(nodeType);
16084
+ return {
16085
+ instance: node,
16086
+ node: nodeHandler.serialize(node)
16087
+ };
16088
+ });
16089
+ return selectedNodes;
16090
+ }
16069
16091
  removeSelectedNodes() {
16070
16092
  const selectedNodes = this.tr.getNodes();
16071
16093
  for (const node of selectedNodes) node.destroy();
@@ -16101,10 +16123,8 @@ const COPY_PASTE_NODES_PLUGIN_STATE = {
16101
16123
  //#endregion
16102
16124
  //#region src/plugins/copy-paste-nodes/copy-paste-nodes.ts
16103
16125
  var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
16104
- constructor(params) {
16126
+ constructor() {
16105
16127
  super();
16106
- const { callbacks } = params ?? {};
16107
- this.callbacks = callbacks;
16108
16128
  this.state = COPY_PASTE_NODES_PLUGIN_STATE.IDLE;
16109
16129
  }
16110
16130
  getName() {
@@ -16161,18 +16181,15 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
16161
16181
  await this.readClipboardData();
16162
16182
  this.performPaste();
16163
16183
  } catch (ex) {
16164
- this.callbacks?.onPaste?.(ex);
16165
16184
  this.instance.emitEvent("onPaste", ex);
16166
16185
  }
16167
16186
  try {
16168
16187
  const items$1 = await navigator.clipboard.read();
16169
16188
  if (items$1 && items$1.length === 1) {
16170
16189
  const item = items$1[0];
16171
- this.callbacks?.onPasteExternal?.(item);
16172
16190
  this.instance.emitEvent("onPasteExternal", item);
16173
16191
  }
16174
16192
  } catch (ex) {
16175
- this.callbacks?.onPaste?.(ex);
16176
16193
  this.instance.emitEvent("onPaste", ex);
16177
16194
  }
16178
16195
  };
@@ -16213,7 +16230,7 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
16213
16230
  node.props.x = mousePoint.x + (node.props.x - this.toPaste.weaveMinPoint.x);
16214
16231
  node.props.y = mousePoint.y + (node.props.y - this.toPaste.weaveMinPoint.y);
16215
16232
  this.instance.addNode(node, container?.getAttr("id"));
16216
- this.callbacks?.onPaste?.();
16233
+ this.instance.emitEvent("onPaste");
16217
16234
  this.instance.emitEvent("onPaste", void 0);
16218
16235
  }
16219
16236
  this.toPaste = void 0;
@@ -16243,10 +16260,8 @@ var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
16243
16260
  for (const serializedNode of result.serializedNodes) copyClipboard.weave[serializedNode.key ?? ""] = serializedNode;
16244
16261
  try {
16245
16262
  await this.writeClipboardData(JSON.stringify(copyClipboard));
16246
- this.callbacks?.onCopy?.();
16247
- this.instance.emitEvent("onCopy", void 0);
16263
+ this.instance.emitEvent("onCopy");
16248
16264
  } catch (ex) {
16249
- this.callbacks?.onCopy?.(ex);
16250
16265
  this.instance.emitEvent("onCopy", ex);
16251
16266
  }
16252
16267
  }
@@ -16390,6 +16405,14 @@ var WeaveNode = class {
16390
16405
  this.previousPointer = stage.container().style.cursor;
16391
16406
  stage.container().style.cursor = "pointer";
16392
16407
  e.cancelBubble = true;
16408
+ return;
16409
+ }
16410
+ if (this.isPasting()) {
16411
+ const stage = this.instance.getStage();
16412
+ this.previousPointer = stage.container().style.cursor;
16413
+ stage.container().style.cursor = "crosshair";
16414
+ e.cancelBubble = true;
16415
+ return;
16393
16416
  }
16394
16417
  });
16395
16418
  node.on("mouseleave", (e) => {
@@ -16399,6 +16422,14 @@ var WeaveNode = class {
16399
16422
  stage.container().style.cursor = this.previousPointer ?? "default";
16400
16423
  this.previousPointer = null;
16401
16424
  e.cancelBubble = true;
16425
+ return;
16426
+ }
16427
+ if (this.isPasting()) {
16428
+ const stage = this.instance.getStage();
16429
+ this.previousPointer = stage.container().style.cursor;
16430
+ stage.container().style.cursor = "crosshair";
16431
+ e.cancelBubble = true;
16432
+ return;
16402
16433
  }
16403
16434
  });
16404
16435
  }
@@ -16437,12 +16468,14 @@ var WeaveNode = class {
16437
16468
  //#endregion
16438
16469
  //#region src/actions/action.ts
16439
16470
  var WeaveAction = class {
16440
- constructor(callbacks) {
16441
- this.callbacks = callbacks;
16471
+ constructor() {
16442
16472
  return new Proxy(this, { set: (target, key, value) => {
16443
16473
  Reflect.set(target, key, value);
16444
- this.internalUpdate?.();
16445
- this.callbacks?.onPropsChange?.(this.props);
16474
+ this.onPropsChange?.();
16475
+ this.instance?.emitEvent("onPropsChange", {
16476
+ instance: this,
16477
+ props: this.props
16478
+ });
16446
16479
  return true;
16447
16480
  } });
16448
16481
  }
@@ -17807,7 +17840,7 @@ var WeaveRegisterManager = class {
17807
17840
 
17808
17841
  //#endregion
17809
17842
  //#region package.json
17810
- var version = "0.7.1";
17843
+ var version = "0.9.0";
17811
17844
 
17812
17845
  //#endregion
17813
17846
  //#region src/managers/setup.ts
@@ -18818,10 +18851,8 @@ var WeaveImageToolAction = class extends WeaveAction {
18818
18851
  initialized = false;
18819
18852
  initialCursor = null;
18820
18853
  update = void 0;
18821
- constructor(imageCallbacks) {
18822
- const { onPropsChange,...restCallbacks } = imageCallbacks;
18823
- super({ onPropsChange });
18824
- this.imageCallbacks = restCallbacks;
18854
+ constructor() {
18855
+ super();
18825
18856
  this.initialized = false;
18826
18857
  this.state = IMAGE_TOOL_STATE.IDLE;
18827
18858
  this.imageId = null;
@@ -18902,7 +18933,7 @@ var WeaveImageToolAction = class extends WeaveAction {
18902
18933
  console.error(error);
18903
18934
  };
18904
18935
  this.preloadImgs[this.imageId].onload = () => {
18905
- this.imageCallbacks?.onImageLoadEnd?.();
18936
+ this.instance.emitEvent("onImageLoadEnd", void 0);
18906
18937
  if (this.imageId) this.props = {
18907
18938
  ...this.props,
18908
18939
  width: this.preloadImgs[this.imageId].width,
@@ -18911,11 +18942,11 @@ var WeaveImageToolAction = class extends WeaveAction {
18911
18942
  this.addImageNode();
18912
18943
  };
18913
18944
  this.preloadImgs[this.imageId].onerror = () => {
18914
- this.imageCallbacks?.onImageLoadEnd?.(new Error("Error loading image"));
18945
+ this.instance.emitEvent("onImageLoadEnd", new Error("Error loading image"));
18915
18946
  this.cancelAction();
18916
18947
  };
18917
18948
  this.preloadImgs[this.imageId].src = imageURL;
18918
- this.imageCallbacks?.onImageLoadStart?.();
18949
+ this.instance.emitEvent("onImageLoadStart");
18919
18950
  }
18920
18951
  addImageNode() {
18921
18952
  const stage = this.instance.getStage();
@@ -18941,7 +18972,6 @@ var WeaveImageToolAction = class extends WeaveAction {
18941
18972
  this.setState(IMAGE_TOOL_STATE.ADDING);
18942
18973
  }
18943
18974
  addImage() {
18944
- this.imageCallbacks?.onUploadImage(this.loadImage.bind(this));
18945
18975
  this.setState(IMAGE_TOOL_STATE.UPLOADING);
18946
18976
  }
18947
18977
  handleAdding() {
@@ -18984,7 +19014,7 @@ var WeaveImageToolAction = class extends WeaveAction {
18984
19014
  this.addImage();
18985
19015
  return { finishUploadCallback: this.loadImage.bind(this) };
18986
19016
  }
18987
- internalUpdate() {
19017
+ onPropsChange() {
18988
19018
  const stage = this.instance?.getStage();
18989
19019
  if (stage) {
18990
19020
  const tempImage = this.instance.getStage().findOne(`#${this.tempImageId}`);
@@ -19509,12 +19539,23 @@ const WEAVE_FRAME_NODE_SIZES = {
19509
19539
  }
19510
19540
  }
19511
19541
  };
19512
- const WEAVE_FRAME_NODE_DEFAULT_PROPS = {
19513
- title: "Frame XXX",
19542
+ const WEAVE_FRAME_NODE_DEFAULT_CONFIG = {
19514
19543
  fontFamily: "Arial",
19544
+ fontStyle: "normal",
19515
19545
  titleHeight: 30,
19516
19546
  borderColor: "#000000ff",
19517
19547
  borderWidth: 2,
19548
+ onTargetLeave: {
19549
+ borderColor: "#000000ff",
19550
+ fill: "#ffffffff"
19551
+ },
19552
+ onTargetEnter: {
19553
+ borderColor: "#ff6863ff",
19554
+ fill: "#ecececff"
19555
+ }
19556
+ };
19557
+ const WEAVE_FRAME_NODE_DEFAULT_PROPS = {
19558
+ title: "Frame XXX",
19518
19559
  frameWidth: WEAVE_FRAME_NODE_SIZES.landscape.A4.width * WEAVE_FRAME_NODE_SIZES_MULTIPLIER,
19519
19560
  frameHeight: WEAVE_FRAME_NODE_SIZES.landscape.A4.height * WEAVE_FRAME_NODE_SIZES_MULTIPLIER,
19520
19561
  frameType: WEAVE_FRAME_NODE_SIZES_TYPES.A4,
@@ -19525,6 +19566,14 @@ const WEAVE_FRAME_NODE_DEFAULT_PROPS = {
19525
19566
  //#region src/nodes/frame/frame.ts
19526
19567
  var WeaveFrameNode = class extends WeaveNode {
19527
19568
  nodeType = WEAVE_FRAME_NODE_TYPE;
19569
+ constructor(params) {
19570
+ super();
19571
+ const { config } = params ?? {};
19572
+ this.config = {
19573
+ ...WEAVE_FRAME_NODE_DEFAULT_CONFIG,
19574
+ ...config
19575
+ };
19576
+ }
19528
19577
  create(key, props) {
19529
19578
  return {
19530
19579
  key,
@@ -19533,12 +19582,9 @@ var WeaveFrameNode = class extends WeaveNode {
19533
19582
  ...props,
19534
19583
  id: key,
19535
19584
  nodeType: this.nodeType,
19585
+ ...this.config,
19536
19586
  ...WEAVE_FRAME_NODE_DEFAULT_PROPS,
19537
- ...props.fontFamily && { title: props.fontFamily },
19538
19587
  ...props.title && { title: props.title },
19539
- ...props.titleHeight && { titleHeight: props.titleHeight },
19540
- ...props.borderColor && { borderColor: props.borderColor },
19541
- ...props.borderWidth && { borderWidth: props.borderWidth },
19542
19588
  ...props.frameWidth && { frameWidth: props.frameWidth },
19543
19589
  ...props.frameHeight && { frameHeight: props.frameHeight },
19544
19590
  ...props.frameType && { frameType: props.frameType },
@@ -19549,30 +19595,31 @@ var WeaveFrameNode = class extends WeaveNode {
19549
19595
  }
19550
19596
  onRender(props) {
19551
19597
  const { id, zIndex,...restProps } = props;
19598
+ const { fontFamily, fontStyle, titleHeight, borderColor, borderWidth, onTargetEnter: { borderColor: onTargetEnterBorderColor, fill: onTargetEnterFill }, onTargetLeave: { borderColor: onTargetLeaveBorderColor, fill: onTargetLeaveFill } } = this.config;
19552
19599
  const frameParams = { ...restProps };
19553
19600
  const frame = new Konva.Group({
19554
19601
  ...frameParams,
19555
19602
  id,
19556
19603
  containerId: `${id}-group-internal`,
19557
19604
  containerOffsetX: 0,
19558
- containerOffsetY: props.titleHeight + props.borderWidth,
19559
- width: props.frameWidth + props.borderWidth * 2,
19560
- height: props.frameHeight + props.titleHeight + props.borderWidth * 2,
19605
+ containerOffsetY: titleHeight + borderWidth,
19606
+ width: props.frameWidth + borderWidth * 2,
19607
+ height: props.frameHeight + titleHeight + borderWidth * 2,
19561
19608
  fill: "#ffffffff",
19562
19609
  clipX: 0,
19563
19610
  clipY: 0,
19564
- clipWidth: props.frameWidth + props.borderWidth * 2,
19565
- clipHeight: props.frameHeight + props.titleHeight + props.borderWidth * 2,
19611
+ clipWidth: props.frameWidth + borderWidth * 2,
19612
+ clipHeight: props.frameHeight + titleHeight + borderWidth * 2,
19566
19613
  name: "node"
19567
19614
  });
19568
19615
  const background = new Konva.Rect({
19569
19616
  id: `${id}-bg`,
19570
19617
  nodeId: id,
19571
- x: props.borderWidth,
19572
- y: props.titleHeight + props.borderWidth,
19618
+ x: borderWidth,
19619
+ y: titleHeight + borderWidth,
19573
19620
  width: props.frameWidth,
19574
- stroke: props.borderColor,
19575
- strokeWidth: props.borderWidth,
19621
+ stroke: borderColor,
19622
+ strokeWidth: borderWidth,
19576
19623
  strokeScaleEnabled: false,
19577
19624
  height: props.frameHeight,
19578
19625
  fill: "#ffffffff",
@@ -19584,9 +19631,10 @@ var WeaveFrameNode = class extends WeaveNode {
19584
19631
  x: 0,
19585
19632
  y: 0,
19586
19633
  width: props.frameWidth,
19587
- height: props.titleHeight - 10,
19634
+ height: titleHeight - 10,
19588
19635
  fontSize: 20,
19589
- fontFamily: props.fontFamily,
19636
+ fontFamily,
19637
+ fontStyle,
19590
19638
  align: "left",
19591
19639
  text: props.title,
19592
19640
  stroke: "#000000ff",
@@ -19599,14 +19647,14 @@ var WeaveFrameNode = class extends WeaveNode {
19599
19647
  const frameInternal = new Konva.Group({
19600
19648
  id: `${id}-group-internal`,
19601
19649
  nodeId: id,
19602
- x: props.borderWidth,
19603
- y: props.titleHeight + props.borderWidth,
19650
+ x: borderWidth,
19651
+ y: titleHeight + borderWidth,
19604
19652
  width: props.frameWidth,
19605
19653
  height: props.frameHeight,
19606
19654
  draggable: false,
19607
19655
  stroke: "transparent",
19608
19656
  strokeScaleEnabled: false,
19609
- borderWidth: props.borderWidth,
19657
+ borderWidth,
19610
19658
  clipX: 0,
19611
19659
  clipY: 0,
19612
19660
  clipWidth: props.frameWidth,
@@ -19616,16 +19664,16 @@ var WeaveFrameNode = class extends WeaveNode {
19616
19664
  this.setupDefaultNodeEvents(frame);
19617
19665
  frame.on(WEAVE_NODE_CUSTOM_EVENTS.onTargetLeave, () => {
19618
19666
  background.setAttrs({
19619
- stroke: "#000000ff",
19620
- strokeWidth: props.borderWidth,
19621
- fill: "#ffffffff"
19667
+ stroke: onTargetLeaveBorderColor,
19668
+ strokeWidth: borderWidth,
19669
+ fill: onTargetLeaveFill
19622
19670
  });
19623
19671
  });
19624
19672
  frame.on(WEAVE_NODE_CUSTOM_EVENTS.onTargetEnter, () => {
19625
19673
  background.setAttrs({
19626
- stroke: "#ff6863ff",
19627
- strokeWidth: props.borderWidth,
19628
- fill: "#ecececff"
19674
+ stroke: onTargetEnterBorderColor,
19675
+ strokeWidth: borderWidth,
19676
+ fill: onTargetEnterFill
19629
19677
  });
19630
19678
  });
19631
19679
  return frame;
@@ -19634,7 +19682,6 @@ var WeaveFrameNode = class extends WeaveNode {
19634
19682
  const { id } = nextProps;
19635
19683
  const frameNode = nodeInstance;
19636
19684
  const newProps = { ...nextProps };
19637
- delete newProps.title;
19638
19685
  nodeInstance.setAttrs({ ...newProps });
19639
19686
  const frameTitle = frameNode.findOne(`#${id}-title`);
19640
19687
  if (frameTitle) frameTitle.setAttrs({ text: nextProps.title });
@@ -19678,7 +19725,7 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
19678
19725
  defaultStep = 3;
19679
19726
  constructor(params) {
19680
19727
  super();
19681
- const { config, callbacks } = params;
19728
+ const { config } = params ?? {};
19682
19729
  this.config = {
19683
19730
  zoomSteps: [
19684
19731
  .1,
@@ -19692,12 +19739,10 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
19692
19739
  defaultZoom: 1,
19693
19740
  ...config
19694
19741
  };
19695
- this.callbacks = callbacks ?? {};
19696
19742
  if (!this.config.zoomSteps.includes(this.config.defaultZoom)) throw new Error(`Default zoom ${this.config.defaultZoom} is not in zoom steps`);
19697
19743
  this.actualStep = this.config.zoomSteps.findIndex((step) => step === this.config.defaultZoom);
19698
19744
  this.actualScale = this.config.zoomSteps[this.actualStep];
19699
19745
  this.defaultStep = this.actualStep;
19700
- this.onZoomChangeCb = this.callbacks?.onZoomChange;
19701
19746
  }
19702
19747
  getName() {
19703
19748
  return WEAVE_STAGE_ZOOM_KEY;
@@ -19743,7 +19788,6 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
19743
19788
  canZoomIn: this.canZoomIn(),
19744
19789
  canZoomOut: this.canZoomOut()
19745
19790
  };
19746
- this.onZoomChangeCb?.(callbackParams);
19747
19791
  this.instance.emitEvent("onZoomChange", callbackParams);
19748
19792
  }
19749
19793
  }
@@ -19857,7 +19901,7 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
19857
19901
  //#endregion
19858
19902
  //#region src/actions/zoom-out-tool/zoom-out-tool.ts
19859
19903
  var WeaveZoomOutToolAction = class extends WeaveAction {
19860
- internalUpdate = void 0;
19904
+ onPropsChange = void 0;
19861
19905
  getName() {
19862
19906
  return "zoomOutTool";
19863
19907
  }
@@ -19886,7 +19930,7 @@ var WeaveZoomOutToolAction = class extends WeaveAction {
19886
19930
  //#endregion
19887
19931
  //#region src/actions/zoom-in-tool/zoom-in-tool.ts
19888
19932
  var WeaveZoomInToolAction = class extends WeaveAction {
19889
- internalUpdate = void 0;
19933
+ onPropsChange = void 0;
19890
19934
  getName() {
19891
19935
  return "zoomInTool";
19892
19936
  }
@@ -19915,7 +19959,7 @@ var WeaveZoomInToolAction = class extends WeaveAction {
19915
19959
  //#endregion
19916
19960
  //#region src/actions/fit-to-screen-tool/fit-to-screen-tool.ts
19917
19961
  var WeaveFitToScreenToolAction = class extends WeaveAction {
19918
- internalUpdate = void 0;
19962
+ onPropsChange = void 0;
19919
19963
  getName() {
19920
19964
  return "fitToScreenTool";
19921
19965
  }
@@ -19943,7 +19987,7 @@ var WeaveFitToScreenToolAction = class extends WeaveAction {
19943
19987
  //#endregion
19944
19988
  //#region src/actions/fit-to-selection-tool/fit-to-selection-tool.ts
19945
19989
  var WeaveFitToSelectionToolAction = class extends WeaveAction {
19946
- internalUpdate = void 0;
19990
+ onPropsChange = void 0;
19947
19991
  getName() {
19948
19992
  return "fitToSelectionTool";
19949
19993
  }
@@ -19985,7 +20029,7 @@ const MOVE_TOOL_STATE = {
19985
20029
  //#region src/actions/move-tool/move-tool.ts
19986
20030
  var WeaveMoveToolAction = class extends WeaveAction {
19987
20031
  initialized = false;
19988
- internalUpdate = void 0;
20032
+ onPropsChange = void 0;
19989
20033
  onInit = void 0;
19990
20034
  constructor() {
19991
20035
  super();
@@ -20041,7 +20085,7 @@ const SELECTION_TOOL_STATE = {
20041
20085
  //#region src/actions/selection-tool/selection-tool.ts
20042
20086
  var WeaveSelectionToolAction = class extends WeaveAction {
20043
20087
  initialized = false;
20044
- internalUpdate = void 0;
20088
+ onPropsChange = void 0;
20045
20089
  onInit = void 0;
20046
20090
  constructor() {
20047
20091
  super();
@@ -20105,10 +20149,10 @@ const RECTANGLE_TOOL_STATE = {
20105
20149
  //#region src/actions/rectangle-tool/rectangle-tool.ts
20106
20150
  var WeaveRectangleToolAction = class extends WeaveAction {
20107
20151
  initialized = false;
20108
- internalUpdate = void 0;
20152
+ onPropsChange = void 0;
20109
20153
  onInit = void 0;
20110
- constructor(callbacks) {
20111
- super(callbacks);
20154
+ constructor() {
20155
+ super();
20112
20156
  this.initialized = false;
20113
20157
  this.state = RECTANGLE_TOOL_STATE.IDLE;
20114
20158
  this.rectId = null;
@@ -20268,10 +20312,10 @@ const PEN_TOOL_STATE = {
20268
20312
  var WeavePenToolAction = class extends WeaveAction {
20269
20313
  initialized = false;
20270
20314
  initialCursor = null;
20271
- internalUpdate = void 0;
20315
+ onPropsChange = void 0;
20272
20316
  onInit = void 0;
20273
- constructor(callbacks) {
20274
- super(callbacks);
20317
+ constructor() {
20318
+ super();
20275
20319
  this.initialized = false;
20276
20320
  this.state = PEN_TOOL_STATE.IDLE;
20277
20321
  this.lineId = null;
@@ -20501,10 +20545,10 @@ const BRUSH_TOOL_STATE = {
20501
20545
  //#region src/actions/brush-tool/brush-tool.ts
20502
20546
  var WeaveBrushToolAction = class extends WeaveAction {
20503
20547
  initialized = false;
20504
- internalUpdate = void 0;
20548
+ onPropsChange = void 0;
20505
20549
  onInit = void 0;
20506
- constructor(callbacks) {
20507
- super(callbacks);
20550
+ constructor() {
20551
+ super();
20508
20552
  this.initialized = false;
20509
20553
  this.state = BRUSH_TOOL_STATE.INACTIVE;
20510
20554
  this.strokeId = null;
@@ -20650,7 +20694,7 @@ const TEXT_TOOL_STATE = {
20650
20694
  var WeaveTextToolAction = class extends WeaveAction {
20651
20695
  initialized = false;
20652
20696
  initialCursor = null;
20653
- internalUpdate = void 0;
20697
+ onPropsChange = void 0;
20654
20698
  onInit = void 0;
20655
20699
  constructor() {
20656
20700
  super();
@@ -20757,10 +20801,10 @@ const FRAME_TOOL_STATE = {
20757
20801
  //#region src/actions/frame-tool/frame-tool.ts
20758
20802
  var WeaveFrameToolAction = class extends WeaveAction {
20759
20803
  initialized = false;
20760
- internalUpdate = void 0;
20804
+ onPropsChange = void 0;
20761
20805
  onInit = void 0;
20762
- constructor(callbacks) {
20763
- super(callbacks);
20806
+ constructor() {
20807
+ super();
20764
20808
  this.initialized = false;
20765
20809
  this.state = FRAME_TOOL_STATE.IDLE;
20766
20810
  this.frameId = null;
@@ -20773,7 +20817,6 @@ var WeaveFrameToolAction = class extends WeaveAction {
20773
20817
  initProps(params) {
20774
20818
  return {
20775
20819
  title: params?.title ?? WEAVE_FRAME_NODE_DEFAULT_PROPS.title,
20776
- fontFamily: params?.fontFamily ?? WEAVE_FRAME_NODE_DEFAULT_PROPS.fontFamily,
20777
20820
  editing: false,
20778
20821
  opacity: 1
20779
20822
  };
@@ -20861,7 +20904,7 @@ var WeaveExportStageToolAction = class extends WeaveAction {
20861
20904
  backgroundColor: WEAVE_EXPORT_BACKGROUND_COLOR,
20862
20905
  quality: 1
20863
20906
  };
20864
- internalUpdate = void 0;
20907
+ onPropsChange = void 0;
20865
20908
  onInit = void 0;
20866
20909
  getName() {
20867
20910
  return "exportStageTool";
@@ -20905,7 +20948,7 @@ var WeaveExportNodeToolAction = class extends WeaveAction {
20905
20948
  backgroundColor: WEAVE_EXPORT_BACKGROUND_COLOR,
20906
20949
  quality: 1
20907
20950
  };
20908
- internalUpdate = void 0;
20951
+ onPropsChange = void 0;
20909
20952
  onInit = void 0;
20910
20953
  getName() {
20911
20954
  return "exportNodeTool";
@@ -21297,24 +21340,32 @@ var WeaveStageResizePlugin = class extends WeavePlugin {
21297
21340
  getName() {
21298
21341
  return WEAVE_STAGE_RESIZE_KEY;
21299
21342
  }
21300
- onInit() {
21343
+ resizeStage() {
21301
21344
  const stage = this.instance.getStage();
21302
- window.addEventListener("resize", () => {
21303
- const containerParent = stage.container().parentNode;
21304
- if (!this.enabled) return;
21305
- if (containerParent) {
21306
- const containerBoundBox = stage.container().getBoundingClientRect();
21307
- const containerWidth = containerBoundBox.width;
21308
- const containerHeight = containerBoundBox.height;
21309
- stage.width(containerWidth);
21310
- stage.height(containerHeight);
21311
- const plugins = this.instance.getPlugins();
21312
- for (const pluginId of Object.keys(plugins)) {
21313
- const pluginInstance = plugins[pluginId];
21314
- pluginInstance.onRender?.();
21315
- }
21345
+ const containerParent = stage.container().parentNode;
21346
+ if (!this.enabled) return;
21347
+ if (containerParent) {
21348
+ const containerBoundBox = stage.container().getBoundingClientRect();
21349
+ const containerWidth = containerBoundBox.width;
21350
+ const containerHeight = containerBoundBox.height;
21351
+ stage.width(containerWidth);
21352
+ stage.height(containerHeight);
21353
+ const plugins = this.instance.getPlugins();
21354
+ for (const pluginId of Object.keys(plugins)) {
21355
+ const pluginInstance = plugins[pluginId];
21356
+ pluginInstance.onRender?.();
21316
21357
  }
21358
+ }
21359
+ }
21360
+ onInit() {
21361
+ window.addEventListener("resize", () => {
21362
+ this.resizeStage();
21317
21363
  });
21364
+ const resizeObserver = new ResizeObserver(() => {
21365
+ this.resizeStage();
21366
+ });
21367
+ const stage = this.instance.getStage();
21368
+ resizeObserver.observe(stage.container());
21318
21369
  }
21319
21370
  enable() {
21320
21371
  this.enabled = true;
@@ -21336,9 +21387,8 @@ var WeaveConnectedUsersPlugin = class extends WeavePlugin {
21336
21387
  getLayerName = void 0;
21337
21388
  constructor(params) {
21338
21389
  super();
21339
- const { config, callbacks } = params ?? {};
21390
+ const { config } = params ?? {};
21340
21391
  this.config = config;
21341
- this.callbacks = callbacks ?? {};
21342
21392
  this.connectedUsers = {};
21343
21393
  }
21344
21394
  getName() {
@@ -21348,11 +21398,11 @@ var WeaveConnectedUsersPlugin = class extends WeavePlugin {
21348
21398
  const store = this.instance.getStore();
21349
21399
  const userInfo = this.config.getUser();
21350
21400
  store.setAwarenessInfo(WEAVE_CONNECTED_USER_INFO_KEY, userInfo);
21351
- this.callbacks?.onConnectedUsersChanged?.({ [userInfo.name]: userInfo });
21352
- store.onAwarenessChange((changes) => {
21401
+ this.instance.emitEvent("onConnectedUsersChange", { [userInfo.name]: userInfo });
21402
+ this.instance.addEventListener("onAwarenessChange", (changes) => {
21353
21403
  if (!this.enabled) {
21354
21404
  this.connectedUsers = {};
21355
- this.callbacks?.onConnectedUsersChanged?.({});
21405
+ this.instance.emitEvent("onConnectedUsersChange", {});
21356
21406
  return;
21357
21407
  }
21358
21408
  const newConnectedUsers = {};
@@ -21363,7 +21413,7 @@ var WeaveConnectedUsersPlugin = class extends WeavePlugin {
21363
21413
  newConnectedUsers[userInformation.name] = userInformation;
21364
21414
  }
21365
21415
  }
21366
- if (!(0, import_lodash.isEqual)(this.connectedUsers, newConnectedUsers)) this.callbacks?.onConnectedUsersChanged?.(newConnectedUsers);
21416
+ if (!(0, import_lodash$1.isEqual)(this.connectedUsers, newConnectedUsers)) this.instance.emitEvent("onConnectedUsersChange", newConnectedUsers);
21367
21417
  this.connectedUsers = newConnectedUsers;
21368
21418
  });
21369
21419
  }
@@ -21417,7 +21467,7 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
21417
21467
  onInit() {
21418
21468
  const store = this.instance.getStore();
21419
21469
  const stage = this.instance.getStage();
21420
- store.onAwarenessChange((changes) => {
21470
+ this.instance.addEventListener("onAwarenessChange", (changes) => {
21421
21471
  const selfUser = this.config.getUser();
21422
21472
  for (const change of changes) {
21423
21473
  if (!change[WEAVE_USER_POINTER_KEY]) continue;
@@ -21550,7 +21600,7 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
21550
21600
  x: userPointer.actualPos.x,
21551
21601
  y: userPointer.actualPos.y
21552
21602
  };
21553
- const hasChanged = !import_lodash.default.isEqual(actualPos, oldPos);
21603
+ const hasChanged = !import_lodash$1.default.isEqual(actualPos, oldPos);
21554
21604
  const userPointNode = userPointerNode.getChildren((node) => node.getAttrs().id === "userPoint");
21555
21605
  userPointNode[0]?.setAttrs({
21556
21606
  radius: this.userPointerCircleRadius / stage.scaleX(),
@@ -21607,10 +21657,8 @@ const WEAVE_STAGE_DROP_AREA_KEY = "stageDropArea";
21607
21657
  var WeaveStageDropAreaPlugin = class extends WeavePlugin {
21608
21658
  getLayerName = void 0;
21609
21659
  initLayer = void 0;
21610
- constructor(params) {
21660
+ constructor() {
21611
21661
  super();
21612
- const { callbacks } = params ?? {};
21613
- this.callbacks = callbacks;
21614
21662
  this.enabled = true;
21615
21663
  }
21616
21664
  getName() {
@@ -21628,7 +21676,6 @@ var WeaveStageDropAreaPlugin = class extends WeavePlugin {
21628
21676
  stage.container().addEventListener("drop", (e) => {
21629
21677
  e.preventDefault();
21630
21678
  e.stopPropagation();
21631
- this.callbacks?.onStageDrop?.(e);
21632
21679
  this.instance.emitEvent("onStageDrop", e);
21633
21680
  });
21634
21681
  }
@@ -21941,4 +21988,4 @@ var WeaveNodesSnappingPlugin = class extends WeavePlugin {
21941
21988
  };
21942
21989
 
21943
21990
  //#endregion
21944
- export { BRUSH_TOOL_STATE, COPY_PASTE_NODES_PLUGIN_STATE, FRAME_TOOL_ACTION_NAME, FRAME_TOOL_STATE, GUIDE_LINE_DEFAULT_CONFIG, GUIDE_LINE_DRAG_SNAPPING_THRESHOLD, GUIDE_LINE_NAME, GUIDE_LINE_TRANSFORM_SNAPPING_THRESHOLD, GUIDE_ORIENTATION, IMAGE_TOOL_STATE, MOVE_TOOL_ACTION_NAME, MOVE_TOOL_STATE, NODE_SNAP, PEN_TOOL_STATE, RECTANGLE_TOOL_ACTION_NAME, RECTANGLE_TOOL_STATE, SELECTION_TOOL_ACTION_NAME, SELECTION_TOOL_STATE, TEXT_TOOL_STATE, WEAVE_COPY_PASTE_NODES_KEY, WEAVE_FRAME_NODE_DEFAULT_PROPS, WEAVE_FRAME_NODE_SIZES, WEAVE_FRAME_NODE_SIZES_MULTIPLIER, WEAVE_FRAME_NODE_SIZES_ORIENTATION, WEAVE_FRAME_NODE_SIZES_TYPES, WEAVE_FRAME_NODE_TYPE, WEAVE_GRID_DEFAULT_COLOR, WEAVE_GRID_DEFAULT_ORIGIN_COLOR, WEAVE_GRID_DEFAULT_SIZE, WEAVE_GRID_DEFAULT_TYPE, WEAVE_GRID_LAYER_ID, WEAVE_GRID_TYPES, WEAVE_NODES_SELECTION_KEY, WEAVE_NODES_SELECTION_LAYER_ID, WEAVE_NODES_SNAPPING_KEY, WEAVE_STAGE_GRID_KEY, Weave, WeaveAction, WeaveBrushToolAction, WeaveConnectedUsersPlugin, WeaveContextMenuPlugin, WeaveCopyPasteNodesPlugin, WeaveExportNodeToolAction, WeaveExportStageToolAction, WeaveFitToScreenToolAction, WeaveFitToSelectionToolAction, WeaveFrameNode, WeaveFrameToolAction, WeaveGroupNode, WeaveImageNode, WeaveImageToolAction, WeaveLayerNode, WeaveLineNode, WeaveMoveToolAction, WeaveNode, WeaveNodesSelectionPlugin, WeaveNodesSnappingPlugin, WeavePenToolAction, WeavePlugin, WeaveRectangleNode, WeaveRectangleToolAction, WeaveSelectionToolAction, WeaveStageDropAreaPlugin, WeaveStageGridPlugin, WeaveStageNode, WeaveStagePanningPlugin, WeaveStageResizePlugin, WeaveStageZoomPlugin, WeaveStore, WeaveTextNode, WeaveTextToolAction, WeaveUsersPointersPlugin, WeaveZoomInToolAction, WeaveZoomOutToolAction, resetScale };
21991
+ export { BRUSH_TOOL_STATE, COPY_PASTE_NODES_PLUGIN_STATE, FRAME_TOOL_ACTION_NAME, FRAME_TOOL_STATE, GUIDE_LINE_DEFAULT_CONFIG, GUIDE_LINE_DRAG_SNAPPING_THRESHOLD, GUIDE_LINE_NAME, GUIDE_LINE_TRANSFORM_SNAPPING_THRESHOLD, GUIDE_ORIENTATION, IMAGE_TOOL_STATE, MOVE_TOOL_ACTION_NAME, MOVE_TOOL_STATE, NODE_SNAP, PEN_TOOL_STATE, RECTANGLE_TOOL_ACTION_NAME, RECTANGLE_TOOL_STATE, SELECTION_TOOL_ACTION_NAME, SELECTION_TOOL_STATE, TEXT_TOOL_STATE, WEAVE_COPY_PASTE_NODES_KEY, WEAVE_FRAME_NODE_DEFAULT_CONFIG, WEAVE_FRAME_NODE_DEFAULT_PROPS, WEAVE_FRAME_NODE_SIZES, WEAVE_FRAME_NODE_SIZES_MULTIPLIER, WEAVE_FRAME_NODE_SIZES_ORIENTATION, WEAVE_FRAME_NODE_SIZES_TYPES, WEAVE_FRAME_NODE_TYPE, WEAVE_GRID_DEFAULT_COLOR, WEAVE_GRID_DEFAULT_ORIGIN_COLOR, WEAVE_GRID_DEFAULT_SIZE, WEAVE_GRID_DEFAULT_TYPE, WEAVE_GRID_LAYER_ID, WEAVE_GRID_TYPES, WEAVE_NODES_SELECTION_KEY, WEAVE_NODES_SELECTION_LAYER_ID, WEAVE_NODES_SNAPPING_KEY, WEAVE_STAGE_GRID_KEY, Weave, WeaveAction, WeaveBrushToolAction, WeaveConnectedUsersPlugin, WeaveContextMenuPlugin, WeaveCopyPasteNodesPlugin, WeaveExportNodeToolAction, WeaveExportStageToolAction, WeaveFitToScreenToolAction, WeaveFitToSelectionToolAction, WeaveFrameNode, WeaveFrameToolAction, WeaveGroupNode, WeaveImageNode, WeaveImageToolAction, WeaveLayerNode, WeaveLineNode, WeaveMoveToolAction, WeaveNode, WeaveNodesSelectionPlugin, WeaveNodesSnappingPlugin, WeavePenToolAction, WeavePlugin, WeaveRectangleNode, WeaveRectangleToolAction, WeaveSelectionToolAction, WeaveStageDropAreaPlugin, WeaveStageGridPlugin, WeaveStageNode, WeaveStagePanningPlugin, WeaveStageResizePlugin, WeaveStageZoomPlugin, WeaveStore, WeaveTextNode, WeaveTextToolAction, WeaveUsersPointersPlugin, WeaveZoomInToolAction, WeaveZoomOutToolAction, resetScale };