@visactor/vrender-components 0.17.6 → 0.17.7-alpha.2

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/index.js CHANGED
@@ -3868,6 +3868,168 @@
3868
3868
  },
3869
3869
  __metadata$F = undefined && undefined.__metadata || function (k, v) {
3870
3870
  if ("object" == (typeof Reflect === "undefined" ? "undefined" : _typeof(Reflect)) && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
3871
+ };
3872
+ var VWindow = Symbol["for"]("VWindow");
3873
+ var WindowHandlerContribution = Symbol["for"]("WindowHandlerContribution");
3874
+ var DefaultWindow = /*#__PURE__*/function () {
3875
+ function DefaultWindow() {
3876
+ _classCallCheck(this, DefaultWindow);
3877
+ this.hooks = {
3878
+ onChange: new SyncHook(["x", "y", "width", "height"])
3879
+ }, this._uid = Generator.GenAutoIncrementId(), this.global = application.global, this.postInit();
3880
+ }
3881
+ _createClass(DefaultWindow, [{
3882
+ key: "width",
3883
+ get: function get() {
3884
+ if (this._handler) {
3885
+ var wh = this._handler.getWH();
3886
+ return this._width = wh.width;
3887
+ }
3888
+ return this._width;
3889
+ }
3890
+ }, {
3891
+ key: "height",
3892
+ get: function get() {
3893
+ if (this._handler) {
3894
+ var wh = this._handler.getWH();
3895
+ return this._height = wh.height;
3896
+ }
3897
+ return this._height;
3898
+ }
3899
+ }, {
3900
+ key: "dpr",
3901
+ get: function get() {
3902
+ return this._handler.getDpr();
3903
+ }
3904
+ }, {
3905
+ key: "postInit",
3906
+ value: function postInit() {
3907
+ var _this = this;
3908
+ this.global.hooks.onSetEnv.tap("window", function () {
3909
+ _this.active();
3910
+ }), this.active();
3911
+ }
3912
+ }, {
3913
+ key: "active",
3914
+ value: function active() {
3915
+ var global = this.global;
3916
+ if (!global.env || this.actived) return;
3917
+ container.getNamed(WindowHandlerContribution, global.env).configure(this, global), this.actived = !0;
3918
+ }
3919
+ }, {
3920
+ key: "style",
3921
+ get: function get() {
3922
+ return this._handler.getStyle();
3923
+ },
3924
+ set: function set(style) {
3925
+ this._handler.setStyle(style);
3926
+ }
3927
+ }, {
3928
+ key: "create",
3929
+ value: function create(params) {
3930
+ this._handler.createWindow(params);
3931
+ var windowWH = this._handler.getWH();
3932
+ this._width = windowWH.width, this._height = windowWH.height, this.title = this._handler.getTitle(), this.resizable = !0;
3933
+ }
3934
+ }, {
3935
+ key: "setWindowHandler",
3936
+ value: function setWindowHandler(handler) {
3937
+ this._handler = handler;
3938
+ }
3939
+ }, {
3940
+ key: "setDpr",
3941
+ value: function setDpr(dpr) {
3942
+ return this._handler.setDpr(dpr);
3943
+ }
3944
+ }, {
3945
+ key: "resize",
3946
+ value: function resize(w, h) {
3947
+ return this._handler.resizeWindow(w, h);
3948
+ }
3949
+ }, {
3950
+ key: "configure",
3951
+ value: function configure() {
3952
+ throw new Error("暂不支持");
3953
+ }
3954
+ }, {
3955
+ key: "release",
3956
+ value: function release() {
3957
+ return this._handler.releaseWindow();
3958
+ }
3959
+ }, {
3960
+ key: "getContext",
3961
+ value: function getContext() {
3962
+ return this._handler.getContext();
3963
+ }
3964
+ }, {
3965
+ key: "getNativeHandler",
3966
+ value: function getNativeHandler() {
3967
+ return this._handler.getNativeHandler();
3968
+ }
3969
+ }, {
3970
+ key: "getImageBuffer",
3971
+ value: function getImageBuffer(type) {
3972
+ return this._handler.getImageBuffer ? this._handler.getImageBuffer(type) : null;
3973
+ }
3974
+ }, {
3975
+ key: "addEventListener",
3976
+ value: function addEventListener(type, listener, options) {
3977
+ return this._handler.addEventListener(type, listener, options);
3978
+ }
3979
+ }, {
3980
+ key: "removeEventListener",
3981
+ value: function removeEventListener(type, listener, options) {
3982
+ return this._handler.removeEventListener(type, listener, options);
3983
+ }
3984
+ }, {
3985
+ key: "dispatchEvent",
3986
+ value: function dispatchEvent(event) {
3987
+ return this._handler.dispatchEvent(event);
3988
+ }
3989
+ }, {
3990
+ key: "getBoundingClientRect",
3991
+ value: function getBoundingClientRect() {
3992
+ return this._handler.getBoundingClientRect();
3993
+ }
3994
+ }, {
3995
+ key: "getContainer",
3996
+ value: function getContainer() {
3997
+ return this._handler.container;
3998
+ }
3999
+ }, {
4000
+ key: "clearViewBox",
4001
+ value: function clearViewBox(viewBox, color) {
4002
+ this._handler.clearViewBox(viewBox, color);
4003
+ }
4004
+ }, {
4005
+ key: "isVisible",
4006
+ value: function isVisible(bbox) {
4007
+ return this._handler.isVisible(bbox);
4008
+ }
4009
+ }, {
4010
+ key: "onVisibleChange",
4011
+ value: function onVisibleChange(cb) {
4012
+ return this._handler.onVisibleChange(cb);
4013
+ }
4014
+ }, {
4015
+ key: "getTopLeft",
4016
+ value: function getTopLeft(baseWindow) {
4017
+ return this._handler.getTopLeft(baseWindow);
4018
+ }
4019
+ }]);
4020
+ return DefaultWindow;
4021
+ }();
4022
+ DefaultWindow = __decorate$P([injectable(), __metadata$F("design:paramtypes", [])], DefaultWindow);
4023
+
4024
+ var __decorate$O = undefined && undefined.__decorate || function (decorators, target, key, desc) {
4025
+ var d,
4026
+ c = arguments.length,
4027
+ r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
4028
+ if ("object" == (typeof Reflect === "undefined" ? "undefined" : _typeof(Reflect)) && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
4029
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
4030
+ },
4031
+ __metadata$E = undefined && undefined.__metadata || function (k, v) {
4032
+ if ("object" == (typeof Reflect === "undefined" ? "undefined" : _typeof(Reflect)) && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
3871
4033
  },
3872
4034
  __param$y = undefined && undefined.__param || function (paramIndex, decorator) {
3873
4035
  return function (target, key) {
@@ -3948,10 +4110,45 @@
3948
4110
  specialCharSet: "-/: .,@%'\"~" + vutils.TextMeasure.ALPHABET_CHAR_SET + vutils.TextMeasure.ALPHABET_CHAR_SET.toUpperCase()
3949
4111
  }, null != option ? option : {}), textSpec);
3950
4112
  }
4113
+ }, {
4114
+ key: "drawGraphicToCanvas",
4115
+ value: function drawGraphicToCanvas(graphic, stage, canvas) {
4116
+ if (!stage.defaultLayer) return null;
4117
+ var window = container.get(VWindow),
4118
+ bounds = graphic.AABBBounds,
4119
+ width = bounds.width(),
4120
+ height = bounds.height();
4121
+ window.create({
4122
+ width: width,
4123
+ height: height,
4124
+ canvas: canvas,
4125
+ dpr: stage.window.dpr,
4126
+ canvasControled: !0,
4127
+ offscreen: !0,
4128
+ title: ""
4129
+ });
4130
+ var x = -bounds.x1,
4131
+ y = -bounds.y1,
4132
+ disableCheckGraphicWidthOutRange = stage.params.optimize.disableCheckGraphicWidthOutRange;
4133
+ stage.params.optimize.disableCheckGraphicWidthOutRange = !0, stage.defaultLayer.getNativeHandler().drawTo(window, [graphic], {
4134
+ x: x,
4135
+ y: y,
4136
+ width: width,
4137
+ height: height,
4138
+ stage: stage,
4139
+ layer: stage.defaultLayer,
4140
+ renderService: stage.renderService,
4141
+ background: "transparent",
4142
+ clear: !0,
4143
+ updateBounds: !1
4144
+ }), stage.params.optimize.disableCheckGraphicWidthOutRange = disableCheckGraphicWidthOutRange;
4145
+ var c = window.getNativeHandler();
4146
+ return c.nativeCanvas ? c.nativeCanvas : null;
4147
+ }
3951
4148
  }]);
3952
4149
  return DefaultGraphicUtil;
3953
4150
  }();
3954
- DefaultGraphicUtil = __decorate$P([injectable(), __param$y(0, inject(ContributionProvider)), __param$y(0, named(TextMeasureContribution)), __metadata$F("design:paramtypes", [Object])], DefaultGraphicUtil);
4151
+ DefaultGraphicUtil = __decorate$O([injectable(), __param$y(0, inject(ContributionProvider)), __param$y(0, named(TextMeasureContribution)), __metadata$E("design:paramtypes", [Object])], DefaultGraphicUtil);
3955
4152
  var TransformMode;
3956
4153
  !function (TransformMode) {
3957
4154
  TransformMode[TransformMode.transform = 0] = "transform", TransformMode[TransformMode.matrix = 1] = "matrix";
@@ -4028,7 +4225,7 @@
4028
4225
  }]);
4029
4226
  return DefaultTransformUtil;
4030
4227
  }();
4031
- DefaultTransformUtil = __decorate$P([injectable(), __metadata$F("design:paramtypes", [])], DefaultTransformUtil);
4228
+ DefaultTransformUtil = __decorate$O([injectable(), __metadata$E("design:paramtypes", [])], DefaultTransformUtil);
4032
4229
 
4033
4230
  var defaultThemeObj = {
4034
4231
  arc: DefaultArcAttribute,
@@ -7554,14 +7751,14 @@
7554
7751
  var VirtualLayerHandlerContribution = Symbol["for"]("VirtualLayerHandlerContribution");
7555
7752
 
7556
7753
  var _DefaultLayerService_,
7557
- __decorate$O = undefined && undefined.__decorate || function (decorators, target, key, desc) {
7754
+ __decorate$N = undefined && undefined.__decorate || function (decorators, target, key, desc) {
7558
7755
  var d,
7559
7756
  c = arguments.length,
7560
7757
  r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
7561
7758
  if ("object" == (typeof Reflect === "undefined" ? "undefined" : _typeof(Reflect)) && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
7562
7759
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7563
7760
  },
7564
- __metadata$E = undefined && undefined.__metadata || function (k, v) {
7761
+ __metadata$D = undefined && undefined.__metadata || function (k, v) {
7565
7762
  if ("object" == (typeof Reflect === "undefined" ? "undefined" : _typeof(Reflect)) && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
7566
7763
  };
7567
7764
  var DefaultLayerService = _DefaultLayerService_ = /*#__PURE__*/function () {
@@ -7599,7 +7796,7 @@
7599
7796
  var _a;
7600
7797
  this.tryInit();
7601
7798
  var layerMode = this.getRecommendedLayerType(options.layerMode);
7602
- layerMode = options.canvasId ? "static" : layerMode;
7799
+ layerMode = options.main || options.canvasId ? "static" : layerMode;
7603
7800
  var layerHandler = this.getLayerHandler(layerMode),
7604
7801
  layer = new Layer(stage, this.global, stage.window, Object.assign(Object.assign({
7605
7802
  main: !1
@@ -7647,169 +7844,7 @@
7647
7844
  }]);
7648
7845
  return DefaultLayerService_1;
7649
7846
  }();
7650
- DefaultLayerService.idprefix = "visactor_layer", DefaultLayerService.prefix_count = 0, DefaultLayerService = _DefaultLayerService_ = __decorate$O([injectable(), __metadata$E("design:paramtypes", [])], DefaultLayerService);
7651
-
7652
- var __decorate$N = undefined && undefined.__decorate || function (decorators, target, key, desc) {
7653
- var d,
7654
- c = arguments.length,
7655
- r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
7656
- if ("object" == (typeof Reflect === "undefined" ? "undefined" : _typeof(Reflect)) && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
7657
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7658
- },
7659
- __metadata$D = undefined && undefined.__metadata || function (k, v) {
7660
- if ("object" == (typeof Reflect === "undefined" ? "undefined" : _typeof(Reflect)) && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
7661
- };
7662
- var VWindow = Symbol["for"]("VWindow");
7663
- var WindowHandlerContribution = Symbol["for"]("WindowHandlerContribution");
7664
- var DefaultWindow = /*#__PURE__*/function () {
7665
- function DefaultWindow() {
7666
- _classCallCheck(this, DefaultWindow);
7667
- this.hooks = {
7668
- onChange: new SyncHook(["x", "y", "width", "height"])
7669
- }, this._uid = Generator.GenAutoIncrementId(), this.global = application.global, this.postInit();
7670
- }
7671
- _createClass(DefaultWindow, [{
7672
- key: "width",
7673
- get: function get() {
7674
- if (this._handler) {
7675
- var wh = this._handler.getWH();
7676
- return this._width = wh.width;
7677
- }
7678
- return this._width;
7679
- }
7680
- }, {
7681
- key: "height",
7682
- get: function get() {
7683
- if (this._handler) {
7684
- var wh = this._handler.getWH();
7685
- return this._height = wh.height;
7686
- }
7687
- return this._height;
7688
- }
7689
- }, {
7690
- key: "dpr",
7691
- get: function get() {
7692
- return this._handler.getDpr();
7693
- }
7694
- }, {
7695
- key: "postInit",
7696
- value: function postInit() {
7697
- var _this = this;
7698
- this.global.hooks.onSetEnv.tap("window", function () {
7699
- _this.active();
7700
- }), this.active();
7701
- }
7702
- }, {
7703
- key: "active",
7704
- value: function active() {
7705
- var global = this.global;
7706
- if (!global.env || this.actived) return;
7707
- container.getNamed(WindowHandlerContribution, global.env).configure(this, global), this.actived = !0;
7708
- }
7709
- }, {
7710
- key: "style",
7711
- get: function get() {
7712
- return this._handler.getStyle();
7713
- },
7714
- set: function set(style) {
7715
- this._handler.setStyle(style);
7716
- }
7717
- }, {
7718
- key: "create",
7719
- value: function create(params) {
7720
- this._handler.createWindow(params);
7721
- var windowWH = this._handler.getWH();
7722
- this._width = windowWH.width, this._height = windowWH.height, this.title = this._handler.getTitle(), this.resizable = !0;
7723
- }
7724
- }, {
7725
- key: "setWindowHandler",
7726
- value: function setWindowHandler(handler) {
7727
- this._handler = handler;
7728
- }
7729
- }, {
7730
- key: "setDpr",
7731
- value: function setDpr(dpr) {
7732
- return this._handler.setDpr(dpr);
7733
- }
7734
- }, {
7735
- key: "resize",
7736
- value: function resize(w, h) {
7737
- return this._handler.resizeWindow(w, h);
7738
- }
7739
- }, {
7740
- key: "configure",
7741
- value: function configure() {
7742
- throw new Error("暂不支持");
7743
- }
7744
- }, {
7745
- key: "release",
7746
- value: function release() {
7747
- return this._handler.releaseWindow();
7748
- }
7749
- }, {
7750
- key: "getContext",
7751
- value: function getContext() {
7752
- return this._handler.getContext();
7753
- }
7754
- }, {
7755
- key: "getNativeHandler",
7756
- value: function getNativeHandler() {
7757
- return this._handler.getNativeHandler();
7758
- }
7759
- }, {
7760
- key: "getImageBuffer",
7761
- value: function getImageBuffer(type) {
7762
- return this._handler.getImageBuffer ? this._handler.getImageBuffer(type) : null;
7763
- }
7764
- }, {
7765
- key: "addEventListener",
7766
- value: function addEventListener(type, listener, options) {
7767
- return this._handler.addEventListener(type, listener, options);
7768
- }
7769
- }, {
7770
- key: "removeEventListener",
7771
- value: function removeEventListener(type, listener, options) {
7772
- return this._handler.removeEventListener(type, listener, options);
7773
- }
7774
- }, {
7775
- key: "dispatchEvent",
7776
- value: function dispatchEvent(event) {
7777
- return this._handler.dispatchEvent(event);
7778
- }
7779
- }, {
7780
- key: "getBoundingClientRect",
7781
- value: function getBoundingClientRect() {
7782
- return this._handler.getBoundingClientRect();
7783
- }
7784
- }, {
7785
- key: "getContainer",
7786
- value: function getContainer() {
7787
- return this._handler.container;
7788
- }
7789
- }, {
7790
- key: "clearViewBox",
7791
- value: function clearViewBox(viewBox, color) {
7792
- this._handler.clearViewBox(viewBox, color);
7793
- }
7794
- }, {
7795
- key: "isVisible",
7796
- value: function isVisible(bbox) {
7797
- return this._handler.isVisible(bbox);
7798
- }
7799
- }, {
7800
- key: "onVisibleChange",
7801
- value: function onVisibleChange(cb) {
7802
- return this._handler.onVisibleChange(cb);
7803
- }
7804
- }, {
7805
- key: "getTopLeft",
7806
- value: function getTopLeft(baseWindow) {
7807
- return this._handler.getTopLeft(baseWindow);
7808
- }
7809
- }]);
7810
- return DefaultWindow;
7811
- }();
7812
- DefaultWindow = __decorate$N([injectable(), __metadata$D("design:paramtypes", [])], DefaultWindow);
7847
+ DefaultLayerService.idprefix = "visactor_layer", DefaultLayerService.prefix_count = 0, DefaultLayerService = _DefaultLayerService_ = __decorate$N([injectable(), __metadata$D("design:paramtypes", [])], DefaultLayerService);
7813
7848
 
7814
7849
  var coreModule = new ContainerModule(function (bind) {
7815
7850
  bind(VGlobal).to(DefaultGlobal).inSingletonScope(), bind(VWindow).to(DefaultWindow), bind(GraphicUtil).to(DefaultGraphicUtil).inSingletonScope(), bind(TransformUtil).to(DefaultTransformUtil).inSingletonScope(), bind(LayerService).to(DefaultLayerService).inSingletonScope();
@@ -15866,12 +15901,12 @@
15866
15901
  }
15867
15902
  var d = context.dpr % 1;
15868
15903
  (d || .5 !== d) && (dirtyBounds.x1 = Math.floor(dirtyBounds.x1 * context.dpr) / context.dpr, dirtyBounds.y1 = Math.floor(dirtyBounds.y1 * context.dpr) / context.dpr, dirtyBounds.x2 = Math.ceil(dirtyBounds.x2 * context.dpr) / context.dpr, dirtyBounds.y2 = Math.ceil(dirtyBounds.y2 * context.dpr) / context.dpr), this.backupDirtyBounds.copy(dirtyBounds), context.inuse = !0, context.clearMatrix(), context.setTransformForCurrent(!0);
15869
- var drawInArea = dirtyBounds.width() * context.dpr !== context.canvas.width || dirtyBounds.height() * context.dpr !== context.canvas.height;
15904
+ var drawInArea = dirtyBounds.width() * context.dpr < context.canvas.width || dirtyBounds.height() * context.dpr < context.canvas.height;
15870
15905
  context.save(), context.translate(x, y, !0), drawInArea && (context.beginPath(), context.rect(dirtyBounds.x1, dirtyBounds.y1, dirtyBounds.width(), dirtyBounds.height()), context.clip()), stage.camera && (this.dirtyBounds.setValue(-1 / 0, -1 / 0, 1 / 0, 1 / 0), this.backupDirtyBounds.setValue(-1 / 0, -1 / 0, 1 / 0, 1 / 0)), this.clearScreen(renderService, context, drawContext), context.save(), renderService.renderTreeRoots.sort(function (a, b) {
15871
15906
  var _a, _b;
15872
15907
  return (null !== (_a = a.attribute.zIndex) && void 0 !== _a ? _a : DefaultAttribute.zIndex) - (null !== (_b = b.attribute.zIndex) && void 0 !== _b ? _b : DefaultAttribute.zIndex);
15873
15908
  }).forEach(function (group) {
15874
- _this2.renderGroup(group, drawContext, matrixAllocate.allocate(1, 0, 0, 1, 0, 0));
15909
+ group.isContainer ? _this2.renderGroup(group, drawContext, matrixAllocate.allocate(1, 0, 0, 1, 0, 0)) : _this2.renderItem(group, drawContext);
15875
15910
  }), context.restore(), context.restore(), context.draw(), context.inuse = !1;
15876
15911
  }
15877
15912
  }, {
@@ -22899,7 +22934,7 @@
22899
22934
  labelLength += space;
22900
22935
  const layerCount = Object.keys(this.axisLabelLayerSize).length;
22901
22936
  if (axisVector[1] === 0) {
22902
- const labelBoundsHeight = this.axisLabelsContainer.AABBBounds.height();
22937
+ const labelBoundsHeight = this.axisLabelsContainer ? this.axisLabelsContainer.AABBBounds.height() : 0;
22903
22938
  if (isFinite(labelBoundsHeight)) {
22904
22939
  labelLength += labelBoundsHeight + (layerCount - 1) * space;
22905
22940
  }
@@ -22909,7 +22944,7 @@
22909
22944
  }
22910
22945
  else {
22911
22946
  if (axisVector[0] === 0) {
22912
- const boundsWidth = this.axisLabelsContainer.AABBBounds.width();
22947
+ const boundsWidth = this.axisLabelsContainer ? this.axisLabelsContainer.AABBBounds.width() : 0;
22913
22948
  if (isFinite(boundsWidth)) {
22914
22949
  labelLength += boundsWidth + (layerCount - 1) * space;
22915
22950
  }
@@ -29720,7 +29755,7 @@
29720
29755
  }
29721
29756
  };
29722
29757
 
29723
- const version = "0.17.6";
29758
+ const version = "0.17.7-alpha.2";
29724
29759
 
29725
29760
  exports.AbstractComponent = AbstractComponent;
29726
29761
  exports.ArcInfo = ArcInfo;