@inditextech/weave-sdk 0.4.0 → 0.5.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
@@ -15627,18 +15627,25 @@ const WEAVE_NODES_SELECTION_LAYER_ID = "selectionLayer";
15627
15627
  //#endregion
15628
15628
  //#region src/plugins/context-menu/constants.ts
15629
15629
  const WEAVE_CONTEXT_MENU_KEY = "contextMenu";
15630
+ const WEAVE_CONTEXT_MENU_X_OFFSET_DEFAULT = 4;
15631
+ const WEAVE_CONTEXT_MENU_Y_OFFSET_DEFAULT = 4;
15630
15632
 
15631
15633
  //#endregion
15632
15634
  //#region src/plugins/context-menu/context-menu.ts
15633
15635
  var WeaveContextMenuPlugin = class extends WeavePlugin {
15634
15636
  getLayerName = void 0;
15635
15637
  initLayer = void 0;
15636
- constructor(options, callbacks) {
15638
+ constructor(params) {
15637
15639
  super();
15638
15640
  this.touchTimer = void 0;
15639
15641
  this.tapHold = false;
15640
- this.config = options;
15641
- this.callbacks = callbacks;
15642
+ const { callbacks, config } = params ?? {};
15643
+ this.config = {
15644
+ xOffset: WEAVE_CONTEXT_MENU_X_OFFSET_DEFAULT,
15645
+ yOffset: WEAVE_CONTEXT_MENU_Y_OFFSET_DEFAULT,
15646
+ ...config
15647
+ };
15648
+ this.callbacks = { ...callbacks };
15642
15649
  }
15643
15650
  getName() {
15644
15651
  return WEAVE_CONTEXT_MENU_KEY;
@@ -15648,7 +15655,7 @@ var WeaveContextMenuPlugin = class extends WeavePlugin {
15648
15655
  }
15649
15656
  triggerContextMenu(target) {
15650
15657
  const stage = this.instance.getStage();
15651
- const selectionPlugin = this.instance.getPlugin("nodesSelection");
15658
+ const selectionPlugin = this.instance.getPlugin(WEAVE_NODES_SELECTION_KEY);
15652
15659
  let clickOnTransformer = false;
15653
15660
  if (selectionPlugin) {
15654
15661
  const transformer = selectionPlugin.getTransformer();
@@ -15729,9 +15736,46 @@ var WeaveContextMenuPlugin = class extends WeavePlugin {
15729
15736
  //#endregion
15730
15737
  //#region src/plugins/nodes-selection/nodes-selection.ts
15731
15738
  var WeaveNodesSelectionPlugin = class extends WeavePlugin {
15732
- constructor(callbacks) {
15739
+ constructor(params) {
15733
15740
  super();
15734
- this.callbacks = callbacks;
15741
+ const { config, callbacks } = params ?? {};
15742
+ this.config = { transformer: {
15743
+ rotationSnaps: [
15744
+ 0,
15745
+ 45,
15746
+ 90,
15747
+ 135,
15748
+ 180,
15749
+ 225,
15750
+ 270,
15751
+ 315,
15752
+ 360
15753
+ ],
15754
+ rotationSnapTolerance: 3,
15755
+ ignoreStroke: true,
15756
+ flipEnabled: false,
15757
+ useSingleNodeRotation: true,
15758
+ shouldOverdrawWholeArea: true,
15759
+ anchorStyleFunc: (anchor) => {
15760
+ anchor.stroke("#27272aff");
15761
+ anchor.cornerRadius(12);
15762
+ if (anchor.hasName("top-center") || anchor.hasName("bottom-center")) {
15763
+ anchor.height(8);
15764
+ anchor.offsetY(4);
15765
+ anchor.width(32);
15766
+ anchor.offsetX(16);
15767
+ }
15768
+ if (anchor.hasName("middle-left") || anchor.hasName("middle-right")) {
15769
+ anchor.height(32);
15770
+ anchor.offsetY(16);
15771
+ anchor.width(8);
15772
+ anchor.offsetX(4);
15773
+ }
15774
+ },
15775
+ borderStroke: "#1e40afff",
15776
+ ...config?.transformer
15777
+ } };
15778
+ this.callbacks = callbacks ?? {};
15735
15779
  this.active = false;
15736
15780
  this.cameFromSelectingMultiple = false;
15737
15781
  this.selecting = false;
@@ -15765,39 +15809,7 @@ var WeaveNodesSelectionPlugin = class extends WeavePlugin {
15765
15809
  selectionLayer?.add(selectionRectangle);
15766
15810
  const tr = new Konva.Transformer({
15767
15811
  id: "selectionTransformer",
15768
- rotationSnaps: [
15769
- 0,
15770
- 45,
15771
- 90,
15772
- 135,
15773
- 180,
15774
- 225,
15775
- 270,
15776
- 315,
15777
- 360
15778
- ],
15779
- rotationSnapTolerance: 3,
15780
- ignoreStroke: true,
15781
- flipEnabled: false,
15782
- useSingleNodeRotation: true,
15783
- shouldOverdrawWholeArea: true,
15784
- anchorStyleFunc: (anchor) => {
15785
- anchor.stroke("#27272aff");
15786
- anchor.cornerRadius(12);
15787
- if (anchor.hasName("top-center") || anchor.hasName("bottom-center")) {
15788
- anchor.height(8);
15789
- anchor.offsetY(4);
15790
- anchor.width(32);
15791
- anchor.offsetX(16);
15792
- }
15793
- if (anchor.hasName("middle-left") || anchor.hasName("middle-right")) {
15794
- anchor.height(32);
15795
- anchor.offsetY(16);
15796
- anchor.width(8);
15797
- anchor.offsetX(4);
15798
- }
15799
- },
15800
- borderStroke: "#1e40afff"
15812
+ ...this.config.transformer
15801
15813
  });
15802
15814
  selectionLayer?.add(tr);
15803
15815
  tr.on("mouseenter", (e) => {
@@ -16065,8 +16077,9 @@ const COPY_PASTE_NODES_PLUGIN_STATE = {
16065
16077
  //#endregion
16066
16078
  //#region src/plugins/copy-paste-nodes/copy-paste-nodes.ts
16067
16079
  var WeaveCopyPasteNodesPlugin = class extends WeavePlugin {
16068
- constructor(callbacks) {
16080
+ constructor(params) {
16069
16081
  super();
16082
+ const { callbacks } = params ?? {};
16070
16083
  this.callbacks = callbacks;
16071
16084
  this.state = COPY_PASTE_NODES_PLUGIN_STATE.IDLE;
16072
16085
  }
@@ -17679,6 +17692,13 @@ var WeaveStateManager = class {
17679
17692
  }
17680
17693
  }, userName);
17681
17694
  }
17695
+ getElementsTree() {
17696
+ const state = this.instance.getStore().getState().weave;
17697
+ const jsonState = JSON.parse(JSON.stringify(state, null, 2));
17698
+ const mainLayer = jsonState.props.children.find((node) => node.key === "mainLayer");
17699
+ if (!mainLayer) return [];
17700
+ return mainLayer.props.children;
17701
+ }
17682
17702
  };
17683
17703
 
17684
17704
  //#endregion
@@ -17769,7 +17789,7 @@ var WeaveRegisterManager = class {
17769
17789
 
17770
17790
  //#endregion
17771
17791
  //#region package.json
17772
- var version = "0.4.0";
17792
+ var version = "0.5.0";
17773
17793
 
17774
17794
  //#endregion
17775
17795
  //#region src/managers/setup.ts
@@ -18349,6 +18369,9 @@ var Weave = class extends Emittery {
18349
18369
  moveNode(node, position, doRender = true) {
18350
18370
  this.stateManager.moveNode(node, position, doRender);
18351
18371
  }
18372
+ getElementsTree() {
18373
+ return this.stateManager.getElementsTree();
18374
+ }
18352
18375
  moveUp(node) {
18353
18376
  this.zIndexManager.moveUp(node);
18354
18377
  }
@@ -18376,6 +18399,17 @@ var Weave = class extends Emittery {
18376
18399
  getMousePointerRelativeToContainer(container) {
18377
18400
  return this.targetingManager.getMousePointerRelativeToContainer(container);
18378
18401
  }
18402
+ selectNodesByKey(nodesIds) {
18403
+ const selectionPlugin = this.getPlugin("nodesSelection");
18404
+ if (selectionPlugin) {
18405
+ const stage = this.getStage();
18406
+ const instanceNodes = nodesIds.map((nodeId) => {
18407
+ const nodeInstance = stage.findOne(`#${nodeId}`);
18408
+ return nodeInstance;
18409
+ });
18410
+ selectionPlugin.setSelectedNodes(instanceNodes);
18411
+ }
18412
+ }
18379
18413
  nodesToGroupSerialized(instancesToClone) {
18380
18414
  return this.cloningManager.nodesToGroupSerialized(instancesToClone);
18381
18415
  }
@@ -19398,44 +19432,129 @@ var WeaveImageNode = class extends WeaveNode {
19398
19432
  //#endregion
19399
19433
  //#region src/nodes/frame/constants.ts
19400
19434
  const WEAVE_FRAME_NODE_TYPE = "frame";
19435
+ const WEAVE_FRAME_NODE_SIZES_MULTIPLIER = 5;
19436
+ const WEAVE_FRAME_NODE_SIZES_ORIENTATION = {
19437
+ landscape: "landscape",
19438
+ portrait: "portrait"
19439
+ };
19440
+ const WEAVE_FRAME_NODE_SIZES_TYPES = {
19441
+ A1: "A1",
19442
+ A2: "A2",
19443
+ A3: "A3",
19444
+ A4: "A4",
19445
+ CUSTOM: "custom"
19446
+ };
19447
+ const WEAVE_FRAME_NODE_SIZES = {
19448
+ landscape: {
19449
+ A1: {
19450
+ width: 841,
19451
+ height: 594
19452
+ },
19453
+ A2: {
19454
+ width: 592,
19455
+ height: 420
19456
+ },
19457
+ A3: {
19458
+ width: 420,
19459
+ height: 297
19460
+ },
19461
+ A4: {
19462
+ width: 297,
19463
+ height: 210
19464
+ },
19465
+ custom: {
19466
+ width: 0,
19467
+ height: 0
19468
+ }
19469
+ },
19470
+ portrait: {
19471
+ A1: {
19472
+ width: 594,
19473
+ height: 841
19474
+ },
19475
+ A2: {
19476
+ width: 420,
19477
+ height: 594
19478
+ },
19479
+ A3: {
19480
+ width: 297,
19481
+ height: 420
19482
+ },
19483
+ A4: {
19484
+ width: 210,
19485
+ height: 297
19486
+ },
19487
+ custom: {
19488
+ width: 0,
19489
+ height: 0
19490
+ }
19491
+ }
19492
+ };
19493
+ const WEAVE_FRAME_NODE_DEFAULT_PROPS = {
19494
+ title: "Frame XXX",
19495
+ fontFamily: "Arial",
19496
+ titleHeight: 30,
19497
+ borderColor: "#000000ff",
19498
+ borderWidth: 2,
19499
+ frameWidth: WEAVE_FRAME_NODE_SIZES.landscape.A4.width * WEAVE_FRAME_NODE_SIZES_MULTIPLIER,
19500
+ frameHeight: WEAVE_FRAME_NODE_SIZES.landscape.A4.height * WEAVE_FRAME_NODE_SIZES_MULTIPLIER,
19501
+ frameType: WEAVE_FRAME_NODE_SIZES_TYPES.A4,
19502
+ frameOrientation: WEAVE_FRAME_NODE_SIZES_ORIENTATION.landscape
19503
+ };
19401
19504
 
19402
19505
  //#endregion
19403
19506
  //#region src/nodes/frame/frame.ts
19404
19507
  var WeaveFrameNode = class extends WeaveNode {
19405
19508
  nodeType = WEAVE_FRAME_NODE_TYPE;
19509
+ create(key, props) {
19510
+ return {
19511
+ key,
19512
+ type: this.nodeType,
19513
+ props: {
19514
+ ...props,
19515
+ id: key,
19516
+ nodeType: this.nodeType,
19517
+ ...WEAVE_FRAME_NODE_DEFAULT_PROPS,
19518
+ ...props.fontFamily && { title: props.fontFamily },
19519
+ ...props.title && { title: props.title },
19520
+ ...props.titleHeight && { titleHeight: props.titleHeight },
19521
+ ...props.borderColor && { borderColor: props.borderColor },
19522
+ ...props.borderWidth && { borderWidth: props.borderWidth },
19523
+ ...props.frameWidth && { frameWidth: props.frameWidth },
19524
+ ...props.frameHeight && { frameHeight: props.frameHeight },
19525
+ ...props.frameType && { frameType: props.frameType },
19526
+ ...props.frameOrientation && { frameOrientation: props.frameOrientation },
19527
+ children: []
19528
+ }
19529
+ };
19530
+ }
19406
19531
  onRender(props) {
19407
- const { id } = props;
19408
- const frameParams = { ...props };
19409
- delete frameParams.fontFamily;
19410
- delete frameParams.zIndex;
19411
- const frameWidth = 1403;
19412
- const frameHeight = 992;
19413
- const titleHeight = 30;
19414
- const strokeWidth = 2;
19532
+ const { id, zIndex,...restProps } = props;
19533
+ const frameParams = { ...restProps };
19415
19534
  const frame = new Konva.Group({
19416
19535
  ...frameParams,
19536
+ id,
19417
19537
  containerId: `${id}-group-internal`,
19418
19538
  containerOffsetX: 0,
19419
- containerOffsetY: titleHeight + strokeWidth,
19420
- isTarget: false,
19421
- width: frameWidth + strokeWidth * 2,
19422
- height: frameHeight + titleHeight + strokeWidth * 2,
19539
+ containerOffsetY: props.titleHeight + props.borderWidth,
19540
+ width: props.frameWidth + props.borderWidth * 2,
19541
+ height: props.frameHeight + props.titleHeight + props.borderWidth * 2,
19423
19542
  fill: "#ffffffff",
19424
19543
  clipX: 0,
19425
19544
  clipY: 0,
19426
- clipWidth: frameWidth + strokeWidth * 2,
19427
- clipHeight: frameHeight + titleHeight + strokeWidth * 2,
19545
+ clipWidth: props.frameWidth + props.borderWidth * 2,
19546
+ clipHeight: props.frameHeight + props.titleHeight + props.borderWidth * 2,
19428
19547
  name: "node"
19429
19548
  });
19430
19549
  const background = new Konva.Rect({
19431
19550
  id: `${id}-bg`,
19432
19551
  nodeId: id,
19433
- x: strokeWidth,
19434
- y: titleHeight + strokeWidth,
19435
- width: frameWidth,
19436
- stroke: "#000000ff",
19437
- strokeWidth: 2,
19438
- height: frameHeight,
19552
+ x: props.borderWidth,
19553
+ y: props.titleHeight + props.borderWidth,
19554
+ width: props.frameWidth,
19555
+ stroke: props.borderColor,
19556
+ strokeWidth: props.borderWidth,
19557
+ height: props.frameHeight,
19439
19558
  fill: "#ffffffff",
19440
19559
  draggable: false
19441
19560
  });
@@ -19444,12 +19563,12 @@ var WeaveFrameNode = class extends WeaveNode {
19444
19563
  id: `${id}-title`,
19445
19564
  x: 0,
19446
19565
  y: 0,
19447
- width: frameWidth,
19448
- height: titleHeight - 10,
19566
+ width: props.frameWidth,
19567
+ height: props.titleHeight - 10,
19449
19568
  fontSize: 20,
19450
19569
  fontFamily: props.fontFamily,
19451
19570
  align: "left",
19452
- text: frameParams.title,
19571
+ text: props.title,
19453
19572
  stroke: "#000000ff",
19454
19573
  strokeWidth: 1,
19455
19574
  listening: false,
@@ -19459,31 +19578,31 @@ var WeaveFrameNode = class extends WeaveNode {
19459
19578
  const frameInternal = new Konva.Group({
19460
19579
  id: `${id}-group-internal`,
19461
19580
  nodeId: id,
19462
- x: strokeWidth,
19463
- y: titleHeight + strokeWidth,
19464
- width: frameWidth,
19465
- height: frameHeight,
19581
+ x: props.borderWidth,
19582
+ y: props.titleHeight + props.borderWidth,
19583
+ width: props.frameWidth,
19584
+ height: props.frameHeight,
19466
19585
  draggable: false,
19467
19586
  stroke: "transparent",
19468
- strokeWidth,
19587
+ borderWidth: props.borderWidth,
19469
19588
  clipX: 0,
19470
19589
  clipY: 0,
19471
- clipWidth: frameWidth,
19472
- clipHeight: frameHeight
19590
+ clipWidth: props.frameWidth,
19591
+ clipHeight: props.frameHeight
19473
19592
  });
19474
19593
  frame.add(frameInternal);
19475
19594
  this.setupDefaultNodeEvents(frame);
19476
19595
  frame.on(WEAVE_NODE_CUSTOM_EVENTS.onTargetLeave, () => {
19477
19596
  background.setAttrs({
19478
19597
  stroke: "#000000ff",
19479
- strokeWidth: 2,
19598
+ strokeWidth: props.borderWidth,
19480
19599
  fill: "#ffffffff"
19481
19600
  });
19482
19601
  });
19483
19602
  frame.on(WEAVE_NODE_CUSTOM_EVENTS.onTargetEnter, () => {
19484
19603
  background.setAttrs({
19485
19604
  stroke: "#ff6863ff",
19486
- strokeWidth: 2,
19605
+ strokeWidth: props.borderWidth,
19487
19606
  fill: "#ecececff"
19488
19607
  });
19489
19608
  });
@@ -19534,29 +19653,35 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
19534
19653
  getLayerName = void 0;
19535
19654
  initLayer = void 0;
19536
19655
  padding = 100;
19656
+ defaultStep = 3;
19537
19657
  constructor(params) {
19538
19658
  super();
19539
- const { zoomSteps = [
19540
- .1,
19541
- .25,
19542
- .5,
19543
- 1,
19544
- 2,
19545
- 4,
19546
- 8
19547
- ], defaultZoom = 1, onZoomChange } = params;
19548
- this.zoomSteps = zoomSteps;
19549
- if (!this.zoomSteps.includes(defaultZoom)) throw new Error(`Default zoom ${defaultZoom} is not in zoom steps`);
19550
- this.actualStep = zoomSteps.findIndex((step) => step === defaultZoom);
19551
- this.actualScale = this.zoomSteps[this.actualStep];
19659
+ const { config, callbacks } = params;
19660
+ this.config = {
19661
+ zoomSteps: [
19662
+ .1,
19663
+ .25,
19664
+ .5,
19665
+ 1,
19666
+ 2,
19667
+ 4,
19668
+ 8
19669
+ ],
19670
+ defaultZoom: 1,
19671
+ ...config
19672
+ };
19673
+ this.callbacks = callbacks ?? {};
19674
+ if (!this.config.zoomSteps.includes(this.config.defaultZoom)) throw new Error(`Default zoom ${this.config.defaultZoom} is not in zoom steps`);
19675
+ this.actualStep = this.config.zoomSteps.findIndex((step) => step === this.config.defaultZoom);
19676
+ this.actualScale = this.config.zoomSteps[this.actualStep];
19552
19677
  this.defaultStep = this.actualStep;
19553
- this.onZoomChangeCb = onZoomChange;
19678
+ this.onZoomChangeCb = this.callbacks?.onZoomChange;
19554
19679
  }
19555
19680
  getName() {
19556
19681
  return WEAVE_STAGE_ZOOM_KEY;
19557
19682
  }
19558
19683
  onInit() {
19559
- this.setZoom(this.zoomSteps[this.actualStep]);
19684
+ this.setZoom(this.config.zoomSteps[this.actualStep]);
19560
19685
  }
19561
19686
  setZoom(scale, centered = true) {
19562
19687
  const stage = this.instance.getStage();
@@ -19590,7 +19715,7 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
19590
19715
  }
19591
19716
  const callbackParams = {
19592
19717
  scale,
19593
- zoomSteps: this.zoomSteps,
19718
+ zoomSteps: this.config.zoomSteps,
19594
19719
  actualStep: this.actualStep,
19595
19720
  onDefaultStep: this.actualStep === this.defaultStep,
19596
19721
  canZoomIn: this.canZoomIn(),
@@ -19602,52 +19727,52 @@ var WeaveStageZoomPlugin = class extends WeavePlugin {
19602
19727
  }
19603
19728
  canZoomOut() {
19604
19729
  if (!this.enabled) return false;
19605
- const actualZoomIsStep = this.zoomSteps.findIndex((scale) => scale === this.actualScale);
19730
+ const actualZoomIsStep = this.config.zoomSteps.findIndex((scale) => scale === this.actualScale);
19606
19731
  if (actualZoomIsStep === -1) this.actualStep = this.findClosestStepIndex();
19607
19732
  return this.actualStep - 1 > 0;
19608
19733
  }
19609
19734
  canZoomIn() {
19610
19735
  if (!this.enabled) return false;
19611
- const actualZoomIsStep = this.zoomSteps.findIndex((scale) => scale === this.actualScale);
19736
+ const actualZoomIsStep = this.config.zoomSteps.findIndex((scale) => scale === this.actualScale);
19612
19737
  if (actualZoomIsStep === -1) this.actualStep = this.findClosestStepIndex();
19613
- return this.actualStep + 1 < this.zoomSteps.length;
19738
+ return this.actualStep + 1 < this.config.zoomSteps.length;
19614
19739
  }
19615
19740
  zoomToStep(step) {
19616
19741
  if (!this.enabled) return;
19617
- if (step < 0 || step >= this.zoomSteps.length) throw new Error(`Defined step ${step} is out of bounds`);
19742
+ if (step < 0 || step >= this.config.zoomSteps.length) throw new Error(`Defined step ${step} is out of bounds`);
19618
19743
  this.actualStep = step;
19619
- this.setZoom(this.zoomSteps[step]);
19744
+ this.setZoom(this.config.zoomSteps[step]);
19620
19745
  }
19621
19746
  findClosestStepIndex() {
19622
19747
  let closestStepIndex = 0;
19623
19748
  let actualDiff = Infinity;
19624
- for (let i = 0; i < this.zoomSteps.length; i++) if (Math.abs(this.zoomSteps[i] - this.actualScale) < actualDiff) {
19749
+ for (let i = 0; i < this.config.zoomSteps.length; i++) if (Math.abs(this.config.zoomSteps[i] - this.actualScale) < actualDiff) {
19625
19750
  closestStepIndex = i;
19626
- actualDiff = Math.abs(this.zoomSteps[i] - this.actualScale);
19751
+ actualDiff = Math.abs(this.config.zoomSteps[i] - this.actualScale);
19627
19752
  }
19628
19753
  return closestStepIndex;
19629
19754
  }
19630
19755
  zoomIn() {
19631
19756
  if (!this.enabled) return;
19632
19757
  if (!this.canZoomIn()) return;
19633
- const actualZoomIsStep = this.zoomSteps.findIndex((scale) => scale === this.actualScale);
19758
+ const actualZoomIsStep = this.config.zoomSteps.findIndex((scale) => scale === this.actualScale);
19634
19759
  if (actualZoomIsStep === -1) this.actualStep = this.findClosestStepIndex();
19635
19760
  else this.actualStep += 1;
19636
- this.setZoom(this.zoomSteps[this.actualStep]);
19761
+ this.setZoom(this.config.zoomSteps[this.actualStep]);
19637
19762
  }
19638
19763
  zoomOut() {
19639
19764
  if (!this.enabled) return;
19640
19765
  if (!this.canZoomOut()) return;
19641
- const actualZoomIsStep = this.zoomSteps.findIndex((scale) => scale === this.actualScale);
19766
+ const actualZoomIsStep = this.config.zoomSteps.findIndex((scale) => scale === this.actualScale);
19642
19767
  if (actualZoomIsStep === -1) this.actualStep = this.findClosestStepIndex();
19643
19768
  else this.actualStep -= 1;
19644
- this.setZoom(this.zoomSteps[this.actualStep]);
19769
+ this.setZoom(this.config.zoomSteps[this.actualStep]);
19645
19770
  }
19646
19771
  fitToScreen() {
19647
19772
  if (!this.enabled) return;
19648
19773
  const mainLayer = this.instance.getMainLayer();
19649
19774
  if (mainLayer?.getChildren().length === 0) {
19650
- this.setZoom(this.zoomSteps[this.defaultStep]);
19775
+ this.setZoom(this.config.zoomSteps[this.defaultStep]);
19651
19776
  return;
19652
19777
  }
19653
19778
  const stage = this.instance.getStage();
@@ -20619,8 +20744,8 @@ var WeaveFrameToolAction = class extends WeaveAction {
20619
20744
  }
20620
20745
  initProps(params) {
20621
20746
  return {
20622
- title: "Frame XXX",
20623
- fontFamily: params?.fontFamily ?? "Arial",
20747
+ title: params?.title ?? WEAVE_FRAME_NODE_DEFAULT_PROPS.title,
20748
+ fontFamily: params?.fontFamily ?? WEAVE_FRAME_NODE_DEFAULT_PROPS.fontFamily,
20624
20749
  editing: false,
20625
20750
  opacity: 1
20626
20751
  };
@@ -20789,26 +20914,32 @@ var WeaveExportNodeToolAction = class extends WeaveAction {
20789
20914
  //#endregion
20790
20915
  //#region src/plugins/stage-grid/constants.ts
20791
20916
  const WEAVE_STAGE_GRID_KEY = "stageGrid";
20792
- const WEAVE_GRID_DEFAULT_SIZE = 50;
20793
- const WEAVE_GRID_LAYER_ID = "gridLayer";
20794
20917
  const WEAVE_GRID_TYPES = {
20795
20918
  ["LINES"]: "lines",
20796
20919
  ["DOTS"]: "dots"
20797
20920
  };
20921
+ const WEAVE_GRID_DEFAULT_SIZE = 50;
20922
+ const WEAVE_GRID_DEFAULT_TYPE = WEAVE_GRID_TYPES.LINES;
20923
+ const WEAVE_GRID_DEFAULT_COLOR = "rgba(0,0,0,0.2)";
20924
+ const WEAVE_GRID_DEFAULT_ORIGIN_COLOR = "rgba(255,0,0,0.2)";
20925
+ const WEAVE_GRID_LAYER_ID = "gridLayer";
20798
20926
 
20799
20927
  //#endregion
20800
20928
  //#region src/plugins/stage-grid/stage-grid.ts
20801
20929
  var WeaveStageGridPlugin = class extends WeavePlugin {
20802
- type = "lines";
20803
- gridColor = "rgba(0,0,0,0.2)";
20804
- originColor = "rgba(255,0,0,0.2)";
20805
20930
  constructor(params) {
20806
20931
  super();
20807
- const { gridSize = WEAVE_GRID_DEFAULT_SIZE } = params;
20932
+ const { config } = params ?? {};
20808
20933
  this.moveToolActive = false;
20809
20934
  this.isMouseMiddleButtonPressed = false;
20810
20935
  this.isSpaceKeyPressed = false;
20811
- this.gridSize = gridSize;
20936
+ this.config = {
20937
+ type: WEAVE_GRID_DEFAULT_TYPE,
20938
+ gridColor: WEAVE_GRID_DEFAULT_COLOR,
20939
+ gridOriginColor: WEAVE_GRID_DEFAULT_ORIGIN_COLOR,
20940
+ gridSize: WEAVE_GRID_DEFAULT_SIZE,
20941
+ ...config
20942
+ };
20812
20943
  }
20813
20944
  getName() {
20814
20945
  return WEAVE_STAGE_GRID_KEY;
@@ -20884,7 +21015,7 @@ var WeaveStageGridPlugin = class extends WeavePlugin {
20884
21015
  if (!layer) return;
20885
21016
  layer.destroyChildren();
20886
21017
  if (!this.enabled) return;
20887
- switch (this.type) {
21018
+ switch (this.config.type) {
20888
21019
  case WEAVE_GRID_TYPES.LINES:
20889
21020
  this.renderGridLines();
20890
21021
  break;
@@ -20903,41 +21034,41 @@ var WeaveStageGridPlugin = class extends WeavePlugin {
20903
21034
  const layer = this.getLayer();
20904
21035
  if (!layer) return;
20905
21036
  const stage = this.instance.getStage();
20906
- const stageXRound = this.round(stage.x(), this.gridSize) * -1;
21037
+ const stageXRound = this.round(stage.x(), this.config.gridSize) * -1;
20907
21038
  const pointsX = [];
20908
- for (let i = stageXRound; i < stageXRound + stage.width(); i += this.gridSize) pointsX.push(i / stage.scaleX());
20909
- const stageYRound = this.round(stage.y(), this.gridSize) * -1;
21039
+ for (let i = stageXRound; i < stageXRound + stage.width(); i += this.config.gridSize) pointsX.push(i / stage.scaleX());
21040
+ const stageYRound = this.round(stage.y(), this.config.gridSize) * -1;
20910
21041
  const pointsY = [];
20911
- for (let i = stageYRound; i < stageYRound + stage.height(); i += this.gridSize) pointsY.push(i / stage.scaleY());
21042
+ for (let i = stageYRound; i < stageYRound + stage.height(); i += this.config.gridSize) pointsY.push(i / stage.scaleY());
20912
21043
  for (let index = 0; index < pointsX.length; index++) {
20913
21044
  const point = pointsX[index];
20914
- let color = this.gridColor;
20915
- if (point === 0) color = this.originColor;
21045
+ let color = this.config.gridColor;
21046
+ if (point === 0) color = this.config.gridOriginColor;
20916
21047
  layer.add(new Line({
20917
21048
  points: [
20918
21049
  point,
20919
- (-stage.y() - 2 * this.gridSize) / stage.scaleY(),
21050
+ (-stage.y() - 2 * this.config.gridSize) / stage.scaleY(),
20920
21051
  point,
20921
- (stage.height() - stage.y() + 2 * this.gridSize) / stage.scaleY()
21052
+ (stage.height() - stage.y() + 2 * this.config.gridSize) / stage.scaleY()
20922
21053
  ],
20923
21054
  stroke: color,
20924
- strokeWidth: (point % (10 * (this.gridSize / stage.scaleX())) === 0 ? 2.5 : .5) / stage.scaleX(),
21055
+ strokeWidth: (point % (10 * (this.config.gridSize / stage.scaleX())) === 0 ? 2.5 : .5) / stage.scaleX(),
20925
21056
  listening: false
20926
21057
  }));
20927
21058
  }
20928
21059
  for (let index = 0; index < pointsY.length; index++) {
20929
21060
  const point = pointsY[index];
20930
- let color = this.gridColor;
20931
- if (point === 0) color = this.originColor;
21061
+ let color = this.config.gridColor;
21062
+ if (point === 0) color = this.config.gridOriginColor;
20932
21063
  layer.add(new Line({
20933
21064
  points: [
20934
- (-stage.x() - 2 * this.gridSize) / stage.scaleX(),
21065
+ (-stage.x() - 2 * this.config.gridSize) / stage.scaleX(),
20935
21066
  point,
20936
- (stage.width() - stage.x() + 2 * this.gridSize) / stage.scaleX(),
21067
+ (stage.width() - stage.x() + 2 * this.config.gridSize) / stage.scaleX(),
20937
21068
  point
20938
21069
  ],
20939
21070
  stroke: color,
20940
- strokeWidth: (point % (10 * (this.gridSize / stage.scaleY())) === 0 ? 2.5 : .5) / stage.scaleX(),
21071
+ strokeWidth: (point % (10 * (this.config.gridSize / stage.scaleY())) === 0 ? 2.5 : .5) / stage.scaleX(),
20941
21072
  listening: false
20942
21073
  }));
20943
21074
  }
@@ -20946,18 +21077,18 @@ var WeaveStageGridPlugin = class extends WeavePlugin {
20946
21077
  const layer = this.getLayer();
20947
21078
  if (!layer) return;
20948
21079
  const stage = this.instance.getStage();
20949
- const stageXRound = this.round(stage.x(), this.gridSize) * -1;
21080
+ const stageXRound = this.round(stage.x(), this.config.gridSize) * -1;
20950
21081
  const pointsX = [];
20951
- for (let i = stageXRound; i < stageXRound + stage.width(); i += this.gridSize) pointsX.push(i / stage.scaleX());
20952
- const stageYRound = this.round(stage.y(), this.gridSize) * -1;
21082
+ for (let i = stageXRound; i < stageXRound + stage.width(); i += this.config.gridSize) pointsX.push(i / stage.scaleX());
21083
+ const stageYRound = this.round(stage.y(), this.config.gridSize) * -1;
20953
21084
  const pointsY = [];
20954
- for (let i = stageYRound; i < stageYRound + stage.height(); i += this.gridSize) pointsY.push(i / stage.scaleY());
21085
+ for (let i = stageYRound; i < stageYRound + stage.height(); i += this.config.gridSize) pointsY.push(i / stage.scaleY());
20955
21086
  for (let indexX = 0; indexX < pointsX.length; indexX++) {
20956
21087
  const pointX = pointsX[indexX];
20957
21088
  for (let indexY = 0; indexY < pointsY.length; indexY++) {
20958
21089
  const pointY = pointsY[indexY];
20959
- let color = this.gridColor;
20960
- if (pointX === 0 || pointY === 0) color = this.originColor;
21090
+ let color = this.config.gridColor;
21091
+ if (pointX === 0 || pointY === 0) color = this.config.gridOriginColor;
20961
21092
  layer.add(new Circle({
20962
21093
  x: pointX,
20963
21094
  y: pointY,
@@ -20984,10 +21115,10 @@ var WeaveStageGridPlugin = class extends WeavePlugin {
20984
21115
  this.onRender();
20985
21116
  }
20986
21117
  getType() {
20987
- return this.type;
21118
+ return this.config.type;
20988
21119
  }
20989
21120
  setType(type) {
20990
- this.type = type;
21121
+ this.config.type = type;
20991
21122
  this.onRender();
20992
21123
  }
20993
21124
  };
@@ -21167,6 +21298,7 @@ var WeaveStageResizePlugin = class extends WeavePlugin {
21167
21298
 
21168
21299
  //#endregion
21169
21300
  //#region src/plugins/connected-users/constants.ts
21301
+ const WEAVE_CONNECTED_USERS_KEY = "connectedUsers";
21170
21302
  const WEAVE_CONNECTED_USER_INFO_KEY = "userInfo";
21171
21303
 
21172
21304
  //#endregion
@@ -21176,26 +21308,23 @@ var WeaveConnectedUsersPlugin = class extends WeavePlugin {
21176
21308
  getLayerName = void 0;
21177
21309
  constructor(params) {
21178
21310
  super();
21179
- const { getUser, onConnectedUsersChanged } = params;
21311
+ const { config, callbacks } = params ?? {};
21312
+ this.config = config;
21313
+ this.callbacks = callbacks ?? {};
21180
21314
  this.connectedUsers = {};
21181
- this.onConnectedUsersChanged = onConnectedUsersChanged;
21182
- this.getUser = getUser ?? (() => ({
21183
- name: "Unknown",
21184
- email: "unknown@domain.com"
21185
- }));
21186
21315
  }
21187
21316
  getName() {
21188
- return "connectedUsers";
21317
+ return WEAVE_CONNECTED_USERS_KEY;
21189
21318
  }
21190
21319
  onInit() {
21191
21320
  const store = this.instance.getStore();
21192
- const userInfo = this.getUser();
21321
+ const userInfo = this.config.getUser();
21193
21322
  store.setAwarenessInfo(WEAVE_CONNECTED_USER_INFO_KEY, userInfo);
21194
- this.onConnectedUsersChanged?.({ [userInfo.name]: userInfo });
21323
+ this.callbacks?.onConnectedUsersChanged?.({ [userInfo.name]: userInfo });
21195
21324
  store.onAwarenessChange((changes) => {
21196
21325
  if (!this.enabled) {
21197
21326
  this.connectedUsers = {};
21198
- this.onConnectedUsersChanged?.({});
21327
+ this.callbacks?.onConnectedUsersChanged?.({});
21199
21328
  return;
21200
21329
  }
21201
21330
  const newConnectedUsers = {};
@@ -21206,7 +21335,7 @@ var WeaveConnectedUsersPlugin = class extends WeavePlugin {
21206
21335
  newConnectedUsers[userInformation.name] = userInformation;
21207
21336
  }
21208
21337
  }
21209
- if (!(0, import_lodash.isEqual)(this.connectedUsers, newConnectedUsers)) this.onConnectedUsersChanged?.(newConnectedUsers);
21338
+ if (!(0, import_lodash.isEqual)(this.connectedUsers, newConnectedUsers)) this.callbacks?.onConnectedUsersChanged?.(newConnectedUsers);
21210
21339
  this.connectedUsers = newConnectedUsers;
21211
21340
  });
21212
21341
  }
@@ -21236,14 +21365,11 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
21236
21365
  userPointerBackgroundPaddingY = 8;
21237
21366
  constructor(params) {
21238
21367
  super();
21239
- const { getUser } = params;
21368
+ const { config } = params;
21240
21369
  this.renderCursors = true;
21241
21370
  this.usersPointers = {};
21242
21371
  this.usersPointersTimers = {};
21243
- this.getUser = getUser ?? (() => ({
21244
- name: "Unknown",
21245
- email: "unknown@domain.com"
21246
- }));
21372
+ this.config = config;
21247
21373
  }
21248
21374
  getName() {
21249
21375
  return WEAVE_USERS_POINTERS_KEY;
@@ -21264,7 +21390,7 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
21264
21390
  const store = this.instance.getStore();
21265
21391
  const stage = this.instance.getStage();
21266
21392
  store.onAwarenessChange((changes) => {
21267
- const selfUser = this.getUser();
21393
+ const selfUser = this.config.getUser();
21268
21394
  for (const change of changes) {
21269
21395
  if (!change[WEAVE_USER_POINTER_KEY]) continue;
21270
21396
  if (change[WEAVE_USER_POINTER_KEY] && selfUser.name !== change[WEAVE_USER_POINTER_KEY].user) {
@@ -21283,7 +21409,7 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
21283
21409
  });
21284
21410
  stage.on("dragmove", (e) => {
21285
21411
  e.evt.preventDefault();
21286
- const userInfo = this.getUser();
21412
+ const userInfo = this.config.getUser();
21287
21413
  const mousePos = stage.getRelativePointerPosition();
21288
21414
  if (mousePos) store.setAwarenessInfo(WEAVE_USER_POINTER_KEY, {
21289
21415
  user: userInfo.name,
@@ -21293,7 +21419,7 @@ var WeaveUsersPointersPlugin = class extends WeavePlugin {
21293
21419
  });
21294
21420
  stage.on("pointermove", (e) => {
21295
21421
  e.evt.preventDefault();
21296
- const userInfo = this.getUser();
21422
+ const userInfo = this.config.getUser();
21297
21423
  const mousePos = stage.getRelativePointerPosition();
21298
21424
  if (mousePos) store.setAwarenessInfo(WEAVE_USER_POINTER_KEY, {
21299
21425
  user: userInfo.name,
@@ -21453,8 +21579,9 @@ const WEAVE_STAGE_DROP_AREA_KEY = "stageDropArea";
21453
21579
  var WeaveStageDropAreaPlugin = class extends WeavePlugin {
21454
21580
  getLayerName = void 0;
21455
21581
  initLayer = void 0;
21456
- constructor(callbacks) {
21582
+ constructor(params) {
21457
21583
  super();
21584
+ const { callbacks } = params ?? {};
21458
21585
  this.callbacks = callbacks;
21459
21586
  this.enabled = true;
21460
21587
  }
@@ -21720,4 +21847,4 @@ var WeaveNodesSnappingPlugin = class extends WeavePlugin {
21720
21847
  };
21721
21848
 
21722
21849
  //#endregion
21723
- export { BRUSH_TOOL_STATE, COPY_PASTE_NODES_PLUGIN_STATE, FRAME_TOOL_ACTION_NAME, FRAME_TOOL_STATE, GUIDE_LINE_NAME, 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_TYPE, WEAVE_GRID_DEFAULT_SIZE, 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 };
21850
+ export { BRUSH_TOOL_STATE, COPY_PASTE_NODES_PLUGIN_STATE, FRAME_TOOL_ACTION_NAME, FRAME_TOOL_STATE, GUIDE_LINE_NAME, 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 };