@tmagic/stage 1.0.0-beta.11 → 1.0.0-beta.14

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.
@@ -13,6 +13,7 @@
13
13
 
14
14
  const GHOST_EL_ID_PREFIX = "ghost_el_";
15
15
  const DRAG_EL_ID_PREFIX = "drag_el_";
16
+ const HIGHLIGHT_EL_ID_PREFIX = "highlight_el_";
16
17
  const DEFAULT_ZOOM = 1;
17
18
  var GuidesType = /* @__PURE__ */ ((GuidesType2) => {
18
19
  GuidesType2["HORIZONTAL"] = "horizontal";
@@ -170,21 +171,14 @@
170
171
  };
171
172
 
172
173
  class StageDragResize extends EventEmitter.EventEmitter {
173
- core;
174
- container;
175
- target;
176
- dragEl;
177
- moveable;
178
- horizontalGuidelines = [];
179
- verticalGuidelines = [];
180
- elementGuidelines = [];
181
- moveableOptions = {};
182
- dragStatus = "end" /* END */;
183
- ghostEl;
184
- mode = Mode.ABSOLUTE;
185
- moveableHelper;
186
174
  constructor(config) {
187
175
  super();
176
+ this.horizontalGuidelines = [];
177
+ this.verticalGuidelines = [];
178
+ this.elementGuidelines = [];
179
+ this.mode = Mode.ABSOLUTE;
180
+ this.moveableOptions = {};
181
+ this.dragStatus = "end" /* END */;
188
182
  this.core = config.core;
189
183
  this.container = config.container;
190
184
  this.dragEl = globalThis.document.createElement("div");
@@ -406,6 +400,7 @@
406
400
  top: ${offset.top}px;
407
401
  width: ${width}px;
408
402
  height: ${height}px;
403
+ z-index: 9;
409
404
  `;
410
405
  this.dragEl.id = `${DRAG_EL_ID_PREFIX}${el.id}`;
411
406
  }
@@ -416,6 +411,7 @@
416
411
  if (!this.target)
417
412
  return {};
418
413
  const isAbsolute = this.mode === Mode.ABSOLUTE;
414
+ const isFixed = this.mode === Mode.FIXED;
419
415
  let { moveableOptions = {} } = this.core.config;
420
416
  if (typeof moveableOptions === "function") {
421
417
  moveableOptions = moveableOptions(this.core);
@@ -427,8 +423,8 @@
427
423
  dragArea: false,
428
424
  draggable: true,
429
425
  resizable: true,
430
- snappable: isAbsolute,
431
- snapGap: isAbsolute,
426
+ snappable: isAbsolute || isFixed,
427
+ snapGap: isAbsolute || isFixed,
432
428
  snapThreshold: 5,
433
429
  snapDigit: 0,
434
430
  throttleDrag: 0,
@@ -519,15 +515,97 @@
519
515
  };
520
516
  };
521
517
 
518
+ class TargetCalibrate extends EventEmitter.EventEmitter {
519
+ constructor(config) {
520
+ super();
521
+ this.parent = config.parent;
522
+ this.mask = config.mask;
523
+ this.dr = config.dr;
524
+ this.operationEl = globalThis.document.createElement("div");
525
+ this.parent.append(this.operationEl);
526
+ }
527
+ update(el, prefix) {
528
+ const { width, height } = el.getBoundingClientRect();
529
+ const { left, top } = this.getOffset(el);
530
+ this.operationEl.style.cssText = `
531
+ position: absolute;
532
+ left: ${left}px;
533
+ top: ${top}px;
534
+ width: ${width}px;
535
+ height: ${height}px;
536
+ `;
537
+ this.operationEl.id = `${prefix}${el.id}`;
538
+ return this.operationEl;
539
+ }
540
+ destroy() {
541
+ this.operationEl?.remove();
542
+ }
543
+ getOffset(el) {
544
+ const { transform } = getComputedStyle(el);
545
+ const { offsetParent } = el;
546
+ let left = el.offsetLeft;
547
+ let top = el.offsetTop;
548
+ if (transform.indexOf("matrix") > -1) {
549
+ let a = 1;
550
+ let b = 1;
551
+ let c = 1;
552
+ let d = 1;
553
+ let e = 0;
554
+ let f = 0;
555
+ transform.replace(/matrix\((.+), (.+), (.+), (.+), (.+), (.+)\)/, ($0, $1, $2, $3, $4, $5, $6) => {
556
+ a = +$1;
557
+ b = +$2;
558
+ c = +$3;
559
+ d = +$4;
560
+ e = +$5;
561
+ f = +$6;
562
+ return transform;
563
+ });
564
+ left = a * left + c * top + e;
565
+ top = b * left + d * top + f;
566
+ }
567
+ if (offsetParent) {
568
+ const parentOffset = this.getOffset(offsetParent);
569
+ return {
570
+ left: left + parentOffset.left,
571
+ top: top + parentOffset.top
572
+ };
573
+ }
574
+ if (this.dr.mode === Mode.FIXED) {
575
+ if (getMode(el) === Mode.FIXED) {
576
+ return {
577
+ left,
578
+ top
579
+ };
580
+ }
581
+ return {
582
+ left: left - this.mask.scrollLeft,
583
+ top: top - this.mask.scrollTop
584
+ };
585
+ }
586
+ if (getMode(el) === Mode.FIXED) {
587
+ return {
588
+ left: left + this.mask.scrollLeft,
589
+ top: top + this.mask.scrollTop
590
+ };
591
+ }
592
+ return {
593
+ left,
594
+ top
595
+ };
596
+ }
597
+ }
598
+
522
599
  class StageHighlight extends EventEmitter.EventEmitter {
523
- core;
524
- container;
525
- target;
526
- moveable;
527
600
  constructor(config) {
528
601
  super();
529
602
  this.core = config.core;
530
603
  this.container = config.container;
604
+ this.calibrationTarget = new TargetCalibrate({
605
+ parent: this.core.mask.content,
606
+ mask: this.core.mask,
607
+ dr: this.core.dr
608
+ });
531
609
  }
532
610
  highlight(el) {
533
611
  if (!el || el === this.target)
@@ -535,31 +613,61 @@
535
613
  this.target = el;
536
614
  this.moveable?.destroy();
537
615
  this.moveable = new Moveable__default["default"](this.container, {
538
- target: this.target,
539
- scrollable: true,
540
- origin: false
616
+ target: this.calibrationTarget.update(el, HIGHLIGHT_EL_ID_PREFIX),
617
+ origin: false,
618
+ rootContainer: this.core.container,
619
+ zoom: 1
541
620
  });
542
621
  }
543
622
  clearHighlight() {
544
623
  if (!this.moveable)
545
624
  return;
625
+ this.target = void 0;
546
626
  this.moveable.target = null;
547
627
  this.moveable.updateTarget();
548
628
  }
549
629
  destroy() {
550
630
  this.moveable?.destroy();
631
+ this.calibrationTarget.destroy();
551
632
  }
552
633
  }
553
634
 
554
635
  class Rule extends EventEmitter__default["default"] {
555
- hGuides;
556
- vGuides;
557
- horizontalGuidelines = [];
558
- verticalGuidelines = [];
559
- container;
560
- containerResizeObserver;
561
636
  constructor(container) {
562
637
  super();
638
+ this.horizontalGuidelines = [];
639
+ this.verticalGuidelines = [];
640
+ this.getGuidesStyle = (type) => ({
641
+ position: "fixed",
642
+ zIndex: 1,
643
+ left: type === GuidesType.HORIZONTAL ? 0 : "-30px",
644
+ top: type === GuidesType.HORIZONTAL ? "-30px" : 0,
645
+ width: type === GuidesType.HORIZONTAL ? "100%" : "30px",
646
+ height: type === GuidesType.HORIZONTAL ? "30px" : "100%"
647
+ });
648
+ this.createGuides = (type, defaultGuides = []) => new Guides__default["default"](this.container, {
649
+ type,
650
+ defaultGuides,
651
+ displayDragPos: true,
652
+ backgroundColor: "#fff",
653
+ lineColor: "#000",
654
+ textColor: "#000",
655
+ style: this.getGuidesStyle(type)
656
+ });
657
+ this.hGuidesChangeGuidesHandler = (e) => {
658
+ this.horizontalGuidelines = e.guides;
659
+ this.emit("changeGuides", {
660
+ type: GuidesType.HORIZONTAL,
661
+ guides: this.horizontalGuidelines
662
+ });
663
+ };
664
+ this.vGuidesChangeGuidesHandler = (e) => {
665
+ this.verticalGuidelines = e.guides;
666
+ this.emit("changeGuides", {
667
+ type: GuidesType.VERTICAL,
668
+ guides: this.verticalGuidelines
669
+ });
670
+ };
563
671
  this.container = container;
564
672
  this.hGuides = this.createGuides(GuidesType.HORIZONTAL);
565
673
  this.vGuides = this.createGuides(GuidesType.VERTICAL);
@@ -628,41 +736,10 @@
628
736
  this.containerResizeObserver.disconnect();
629
737
  this.removeAllListeners();
630
738
  }
631
- getGuidesStyle = (type) => ({
632
- position: "fixed",
633
- zIndex: 1,
634
- left: type === GuidesType.HORIZONTAL ? 0 : "-30px",
635
- top: type === GuidesType.HORIZONTAL ? "-30px" : 0,
636
- width: type === GuidesType.HORIZONTAL ? "100%" : "30px",
637
- height: type === GuidesType.HORIZONTAL ? "30px" : "100%"
638
- });
639
- createGuides = (type, defaultGuides = []) => new Guides__default["default"](this.container, {
640
- type,
641
- defaultGuides,
642
- displayDragPos: true,
643
- backgroundColor: "#fff",
644
- lineColor: "#000",
645
- textColor: "#000",
646
- style: this.getGuidesStyle(type)
647
- });
648
- hGuidesChangeGuidesHandler = (e) => {
649
- this.horizontalGuidelines = e.guides;
650
- this.emit("changeGuides", {
651
- type: GuidesType.HORIZONTAL,
652
- guides: this.horizontalGuidelines
653
- });
654
- };
655
- vGuidesChangeGuidesHandler = (e) => {
656
- this.verticalGuidelines = e.guides;
657
- this.emit("changeGuides", {
658
- type: GuidesType.VERTICAL,
659
- guides: this.verticalGuidelines
660
- });
661
- };
662
739
  }
663
740
 
664
741
  const wrapperClassName = "editor-mask-wrapper";
665
- const throttleTime = 300;
742
+ const throttleTime = 100;
666
743
  const hideScrollbar = () => {
667
744
  const style = globalThis.document.createElement("style");
668
745
  style.innerHTML = `
@@ -696,32 +773,73 @@
696
773
  return el;
697
774
  };
698
775
  class StageMask extends Rule {
699
- content = createContent();
700
- wrapper;
701
- core;
702
- page = null;
703
- pageScrollParent = null;
704
- scrollTop = 0;
705
- scrollLeft = 0;
706
- width = 0;
707
- height = 0;
708
- wrapperHeight = 0;
709
- wrapperWidth = 0;
710
- mode = Mode.ABSOLUTE;
711
- pageResizeObserver = null;
712
- wrapperResizeObserver = null;
713
- highlightHandler = lodashEs.throttle((event) => {
714
- this.emit("highlight", event);
715
- }, throttleTime);
716
776
  constructor(config) {
717
777
  const wrapper = createWrapper();
718
778
  super(wrapper);
779
+ this.content = createContent();
780
+ this.page = null;
781
+ this.pageScrollParent = null;
782
+ this.scrollTop = 0;
783
+ this.scrollLeft = 0;
784
+ this.width = 0;
785
+ this.height = 0;
786
+ this.wrapperHeight = 0;
787
+ this.wrapperWidth = 0;
788
+ this.maxScrollTop = 0;
789
+ this.maxScrollLeft = 0;
790
+ this.mode = Mode.ABSOLUTE;
791
+ this.pageResizeObserver = null;
792
+ this.wrapperResizeObserver = null;
793
+ this.highlightHandler = lodashEs.throttle((event) => {
794
+ this.emit("highlight", event);
795
+ }, throttleTime);
796
+ this.mouseDownHandler = (event) => {
797
+ this.emit("clearHighlight");
798
+ event.stopImmediatePropagation();
799
+ event.stopPropagation();
800
+ if (event.button !== MouseButton.LEFT && event.button !== MouseButton.RIGHT)
801
+ return;
802
+ if (event.target.className.indexOf("moveable-control") !== -1) {
803
+ return;
804
+ }
805
+ this.content.removeEventListener("mousemove", this.highlightHandler);
806
+ this.emit("beforeSelect", event);
807
+ globalThis.document.addEventListener("mouseup", this.mouseUpHandler);
808
+ };
809
+ this.mouseUpHandler = () => {
810
+ globalThis.document.removeEventListener("mouseup", this.mouseUpHandler);
811
+ this.content.addEventListener("mousemove", this.highlightHandler);
812
+ this.emit("select");
813
+ };
814
+ this.mouseWheelHandler = (event) => {
815
+ this.emit("clearHighlight");
816
+ if (!this.page)
817
+ throw new Error("page \u672A\u521D\u59CB\u5316");
818
+ const { deltaY, deltaX } = event;
819
+ if (this.page.clientHeight < this.wrapperHeight && deltaY)
820
+ return;
821
+ if (this.page.clientWidth < this.wrapperWidth && deltaX)
822
+ return;
823
+ if (this.maxScrollTop > 0) {
824
+ this.scrollTop = this.scrollTop + deltaY;
825
+ }
826
+ if (this.maxScrollLeft > 0) {
827
+ this.scrollLeft = this.scrollLeft + deltaX;
828
+ }
829
+ this.fixScrollValue();
830
+ this.scroll();
831
+ this.emit("scroll", event);
832
+ };
833
+ this.mouseLeaveHandler = () => {
834
+ setTimeout(() => this.emit("clearHighlight"), throttleTime);
835
+ };
719
836
  this.wrapper = wrapper;
720
837
  this.core = config.core;
721
838
  this.content.addEventListener("mousedown", this.mouseDownHandler);
722
839
  this.wrapper.appendChild(this.content);
723
840
  this.content.addEventListener("wheel", this.mouseWheelHandler);
724
841
  this.content.addEventListener("mousemove", this.highlightHandler);
842
+ this.content.addEventListener("mouseleave", this.mouseLeaveHandler);
725
843
  }
726
844
  setMode(mode) {
727
845
  this.mode = mode;
@@ -746,6 +864,9 @@
746
864
  const { clientHeight, clientWidth } = entry.target;
747
865
  this.setHeight(clientHeight);
748
866
  this.setWidth(clientWidth);
867
+ this.fixScrollValue();
868
+ this.scroll();
869
+ this.core.dr.updateMoveable();
749
870
  });
750
871
  this.pageResizeObserver.observe(page);
751
872
  this.wrapperResizeObserver = new ResizeObserver((entries) => {
@@ -753,6 +874,8 @@
753
874
  const { clientHeight, clientWidth } = entry.target;
754
875
  this.wrapperHeight = clientHeight;
755
876
  this.wrapperWidth = clientWidth;
877
+ this.setMaxScrollLeft();
878
+ this.setMaxScrollTop();
756
879
  });
757
880
  this.wrapperResizeObserver.observe(this.wrapper);
758
881
  }
@@ -771,10 +894,17 @@
771
894
  this.pageScrollParent = null;
772
895
  this.pageResizeObserver?.disconnect();
773
896
  this.wrapperResizeObserver?.disconnect();
897
+ this.content.removeEventListener("mouseleave", this.mouseLeaveHandler);
774
898
  super.destroy();
775
899
  }
776
900
  scroll() {
777
901
  let { scrollLeft, scrollTop } = this;
902
+ if (this.pageScrollParent) {
903
+ this.pageScrollParent.scrollTo({
904
+ top: scrollTop,
905
+ left: scrollLeft
906
+ });
907
+ }
778
908
  if (this.mode === Mode.FIXED) {
779
909
  scrollLeft = 0;
780
910
  scrollTop = 0;
@@ -787,75 +917,75 @@
787
917
  }
788
918
  setHeight(height) {
789
919
  this.height = height;
920
+ this.setMaxScrollTop();
790
921
  this.content.style.height = `${height}px`;
791
922
  }
792
923
  setWidth(width) {
793
924
  this.width = width;
925
+ this.setMaxScrollLeft();
794
926
  this.content.style.width = `${width}px`;
795
927
  }
796
- mouseDownHandler = (event) => {
797
- this.emit("clearHighlight");
798
- event.stopImmediatePropagation();
799
- event.stopPropagation();
800
- if (event.button !== MouseButton.LEFT && event.button !== MouseButton.RIGHT)
801
- return;
802
- if (event.target.className.indexOf("moveable-control") !== -1) {
803
- return;
804
- }
805
- this.content.removeEventListener("mousemove", this.highlightHandler);
806
- this.emit("beforeSelect", event);
807
- globalThis.document.addEventListener("mouseup", this.mouseUpHandler);
808
- };
809
- mouseUpHandler = () => {
810
- globalThis.document.removeEventListener("mouseup", this.mouseUpHandler);
811
- this.content.addEventListener("mousemove", this.highlightHandler);
812
- this.emit("select");
813
- };
814
- mouseWheelHandler = (event) => {
815
- this.emit("clearHighlight");
816
- if (!this.page)
817
- throw new Error("page \u672A\u521D\u59CB\u5316");
818
- const { deltaY, deltaX } = event;
819
- const { height, wrapperHeight, width, wrapperWidth } = this;
820
- const maxScrollTop = height - wrapperHeight;
821
- const maxScrollLeft = width - wrapperWidth;
822
- if (maxScrollTop > 0) {
823
- if (deltaY > 0) {
824
- this.scrollTop = this.scrollTop + Math.min(maxScrollTop - this.scrollTop, deltaY);
825
- } else {
826
- this.scrollTop = Math.max(this.scrollTop + deltaY, 0);
827
- }
828
- }
829
- if (width > wrapperWidth) {
830
- if (deltaX > 0) {
831
- this.scrollLeft = this.scrollLeft + Math.min(maxScrollLeft - this.scrollLeft, deltaX);
832
- } else {
833
- this.scrollLeft = Math.max(this.scrollLeft + deltaX, 0);
834
- }
835
- }
836
- if (this.mode !== Mode.FIXED) {
837
- this.scrollTo(this.scrollLeft, this.scrollTop);
838
- }
839
- if (this.pageScrollParent) {
840
- this.pageScrollParent.scrollTo({
841
- top: this.scrollTop,
842
- left: this.scrollLeft
843
- });
844
- }
845
- this.scroll();
846
- this.emit("scroll", event);
847
- };
928
+ setMaxScrollLeft() {
929
+ this.maxScrollLeft = this.width - this.wrapperWidth;
930
+ }
931
+ setMaxScrollTop() {
932
+ this.maxScrollTop = this.height - this.wrapperHeight;
933
+ }
934
+ fixScrollValue() {
935
+ if (this.scrollTop < 0)
936
+ this.scrollTop = 0;
937
+ if (this.scrollLeft < 0)
938
+ this.scrollLeft = 0;
939
+ if (this.maxScrollTop < this.scrollTop)
940
+ this.scrollTop = this.maxScrollTop;
941
+ if (this.maxScrollLeft < this.scrollLeft)
942
+ this.scrollLeft = this.maxScrollLeft;
943
+ }
848
944
  }
849
945
 
850
946
  class StageRender extends EventEmitter.EventEmitter {
851
- contentWindow = null;
852
- runtime = null;
853
- iframe;
854
- runtimeUrl;
855
- core;
856
- render;
857
947
  constructor({ core }) {
858
948
  super();
949
+ this.contentWindow = null;
950
+ this.runtime = null;
951
+ this.getMagicApi = () => ({
952
+ onPageElUpdate: (el) => this.emit("page-el-update", el),
953
+ onRuntimeReady: (runtime) => {
954
+ this.runtime = runtime;
955
+ globalThis.runtime = runtime;
956
+ this.emit("runtime-ready", runtime);
957
+ }
958
+ });
959
+ this.getRuntime = () => {
960
+ if (this.runtime)
961
+ return Promise.resolve(this.runtime);
962
+ return new Promise((resolve) => {
963
+ const listener = (runtime) => {
964
+ this.off("runtime-ready", listener);
965
+ resolve(runtime);
966
+ };
967
+ this.on("runtime-ready", listener);
968
+ });
969
+ };
970
+ this.loadHandler = async () => {
971
+ this.emit("onload");
972
+ if (this.render) {
973
+ const el = await this.render(this.core);
974
+ if (el) {
975
+ this.iframe?.contentDocument?.body?.appendChild(el);
976
+ }
977
+ }
978
+ if (this.contentWindow) {
979
+ const style = this.contentWindow.document.createElement("style");
980
+ style.id = "tmagic-stage-render";
981
+ style.innerHTML = `
982
+ .${SELECTED_CLASS}, .${SELECTED_CLASS}-parent {
983
+ z-index: ${ZIndex.SELECTED_EL};
984
+ }
985
+ `;
986
+ this.contentWindow.document.head.appendChild(style);
987
+ }
988
+ };
859
989
  this.core = core;
860
990
  this.runtimeUrl = core.config.runtimeUrl || "";
861
991
  this.render = core.config.render;
@@ -868,14 +998,6 @@
868
998
  `;
869
999
  this.iframe.addEventListener("load", this.loadHandler);
870
1000
  }
871
- getMagicApi = () => ({
872
- onPageElUpdate: (el) => this.emit("page-el-update", el),
873
- onRuntimeReady: (runtime) => {
874
- this.runtime = runtime;
875
- globalThis.runtime = runtime;
876
- this.emit("runtime-ready", runtime);
877
- }
878
- });
879
1001
  async mount(el) {
880
1002
  if (this.iframe) {
881
1003
  if (!isSameDomain(this.runtimeUrl) && this.runtimeUrl) {
@@ -892,17 +1014,6 @@
892
1014
  throw Error("mount \u5931\u8D25");
893
1015
  }
894
1016
  }
895
- getRuntime = () => {
896
- if (this.runtime)
897
- return Promise.resolve(this.runtime);
898
- return new Promise((resolve) => {
899
- const listener = (runtime) => {
900
- this.off("runtime-ready", listener);
901
- resolve(runtime);
902
- };
903
- this.on("runtime-ready", listener);
904
- });
905
- };
906
1017
  destroy() {
907
1018
  this.iframe?.removeEventListener("load", this.loadHandler);
908
1019
  this.contentWindow = null;
@@ -910,40 +1021,12 @@
910
1021
  this.iframe = void 0;
911
1022
  this.removeAllListeners();
912
1023
  }
913
- loadHandler = async () => {
914
- this.emit("onload");
915
- if (this.render) {
916
- const el = await this.render(this.core);
917
- if (el) {
918
- this.iframe?.contentDocument?.body?.appendChild(el);
919
- }
920
- }
921
- if (this.contentWindow) {
922
- const style = this.contentWindow.document.createElement("style");
923
- style.id = "tmagic-stage-render";
924
- style.innerHTML = `
925
- .${SELECTED_CLASS}, .${SELECTED_CLASS}-parent {
926
- z-index: ${ZIndex.SELECTED_EL};
927
- }
928
- `;
929
- this.contentWindow.document.head.appendChild(style);
930
- }
931
- };
932
1024
  }
933
1025
 
934
1026
  class StageCore extends EventEmitter.EventEmitter {
935
- selectedDom;
936
- highlightedDom;
937
- renderer;
938
- mask;
939
- dr;
940
- highlightLayer;
941
- config;
942
- zoom = DEFAULT_ZOOM;
943
- container;
944
- canSelect;
945
1027
  constructor(config) {
946
1028
  super();
1029
+ this.zoom = DEFAULT_ZOOM;
947
1030
  this.config = config;
948
1031
  this.setZoom(config.zoom);
949
1032
  this.canSelect = config.canSelect || ((el) => !!el.id);
@@ -1030,7 +1113,7 @@
1030
1113
  }
1031
1114
  update(data) {
1032
1115
  const { config } = data;
1033
- this.renderer?.getRuntime().then((runtime) => {
1116
+ return this.renderer?.getRuntime().then((runtime) => {
1034
1117
  runtime?.update?.(data);
1035
1118
  setTimeout(() => {
1036
1119
  const el = this.renderer.contentWindow?.document.getElementById(`${config.id}`);
@@ -1056,13 +1139,13 @@
1056
1139
  this.highlightedDom = el;
1057
1140
  }
1058
1141
  sortNode(data) {
1059
- this.renderer?.getRuntime().then((runtime) => runtime?.sortNode?.(data));
1142
+ return this.renderer?.getRuntime().then((runtime) => runtime?.sortNode?.(data));
1060
1143
  }
1061
1144
  add(data) {
1062
- this.renderer?.getRuntime().then((runtime) => runtime?.add?.(data));
1145
+ return this.renderer?.getRuntime().then((runtime) => runtime?.add?.(data));
1063
1146
  }
1064
1147
  remove(data) {
1065
- this.renderer?.getRuntime().then((runtime) => runtime?.remove?.(data));
1148
+ return this.renderer?.getRuntime().then((runtime) => runtime?.remove?.(data));
1066
1149
  }
1067
1150
  setZoom(zoom = DEFAULT_ZOOM) {
1068
1151
  this.zoom = zoom;
@@ -1103,8 +1186,7 @@
1103
1186
  exports.StageRender = StageRender;
1104
1187
  exports["default"] = StageCore;
1105
1188
 
1106
- Object.defineProperty(exports, '__esModule', { value: true });
1107
- exports[Symbol.toStringTag] = 'Module';
1189
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
1108
1190
 
1109
1191
  }));
1110
1192
  //# sourceMappingURL=tmagic-stage.umd.js.map