@visactor/vtable-plugins 1.19.10-alpha.0 → 1.19.10-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.
@@ -742,15 +742,7 @@
742
742
  const EnvContribution = Symbol.for("EnvContribution");
743
743
  const VGlobal = Symbol.for("VGlobal");
744
744
 
745
- const container = new Container();
746
-
747
- const RenderService = Symbol.for("RenderService");
748
-
749
- class Application {
750
- get renderService() {
751
- return this._renderService || (this._renderService = container.get(RenderService)), this._renderService;
752
- }
753
- }
745
+ class Application {}
754
746
  const application = new Application();
755
747
 
756
748
  let idx = 0;
@@ -4092,8 +4084,7 @@
4092
4084
  y1: 0,
4093
4085
  strokeBoundsBuffer: 0,
4094
4086
  cornerRadius: 0,
4095
- cornerType: "round",
4096
- drawStrokeWhenZeroWH: !1
4087
+ cornerType: "round"
4097
4088
  });
4098
4089
  Object.assign(Object.assign({}, DefaultAttribute), {
4099
4090
  width: 0,
@@ -4102,8 +4093,7 @@
4102
4093
  y1: 0,
4103
4094
  cornerRadius: 0,
4104
4095
  length: 0,
4105
- cornerType: "round",
4106
- drawStrokeWhenZeroWH: !1
4096
+ cornerType: "round"
4107
4097
  });
4108
4098
  const DefaultSymbolAttribute = Object.assign(Object.assign({}, DefaultAttribute), {
4109
4099
  symbolType: "circle",
@@ -4330,34 +4320,6 @@
4330
4320
  }
4331
4321
  return c;
4332
4322
  }
4333
- static processColorStops(colorStops) {
4334
- if (!colorStops || 0 === colorStops.length) return [];
4335
- if (colorStops.some(item => item.length)) {
4336
- const stops = colorStops.map(item => ({
4337
- color: item.value,
4338
- offset: item.length ? parseFloat(item.length.value) / 100 : -1
4339
- }));
4340
- stops[0].offset < 0 && (stops[0].offset = 0), stops[stops.length - 1].offset < 0 && (stops[stops.length - 1].offset = 1);
4341
- for (let i = 1; i < stops.length - 1; i++) if (stops[i].offset < 0) {
4342
- const prevWithOffsetIdx = i - 1;
4343
- let nextWithOffsetIdx = i + 1;
4344
- for (; nextWithOffsetIdx < stops.length && stops[nextWithOffsetIdx].offset < 0;) nextWithOffsetIdx++;
4345
- const startOffset = stops[prevWithOffsetIdx].offset,
4346
- endOffset = stops[nextWithOffsetIdx].offset,
4347
- unspecCount = nextWithOffsetIdx - prevWithOffsetIdx;
4348
- for (let j = 1; j < unspecCount; j++) stops[prevWithOffsetIdx + j].offset = startOffset + (endOffset - startOffset) * j / unspecCount;
4349
- i = nextWithOffsetIdx - 1;
4350
- }
4351
- return stops;
4352
- }
4353
- return colorStops.map((item, index) => {
4354
- const offset = colorStops.length > 1 ? index / (colorStops.length - 1) : 0;
4355
- return {
4356
- color: item.value,
4357
- offset: offset
4358
- };
4359
- });
4360
- }
4361
4323
  static ParseConic(datum) {
4362
4324
  const {
4363
4325
  orientation: orientation,
@@ -4371,7 +4333,10 @@
4371
4333
  y: .5,
4372
4334
  startAngle: sa,
4373
4335
  endAngle: sa + pi2,
4374
- stops: GradientParser.processColorStops(colorStops)
4336
+ stops: colorStops.map(item => ({
4337
+ color: item.value,
4338
+ offset: parseFloat(item.length.value) / 100
4339
+ }))
4375
4340
  };
4376
4341
  }
4377
4342
  static ParseRadial(datum) {
@@ -4386,7 +4351,10 @@
4386
4351
  y1: .5,
4387
4352
  r0: 0,
4388
4353
  r1: 1,
4389
- stops: GradientParser.processColorStops(colorStops)
4354
+ stops: colorStops.map(item => ({
4355
+ color: item.value,
4356
+ offset: parseFloat(item.length.value) / 100
4357
+ }))
4390
4358
  };
4391
4359
  }
4392
4360
  static ParseLinear(datum) {
@@ -4408,7 +4376,10 @@
4408
4376
  y0: y0,
4409
4377
  x1: x1,
4410
4378
  y1: y1,
4411
- stops: GradientParser.processColorStops(colorStops)
4379
+ stops: colorStops.map(item => ({
4380
+ color: item.value,
4381
+ offset: parseFloat(item.length.value) / 100
4382
+ }))
4412
4383
  };
4413
4384
  }
4414
4385
  }
@@ -4492,9 +4463,6 @@
4492
4463
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4493
4464
  };
4494
4465
  let ATextMeasure = class {
4495
- constructor() {
4496
- this.id = "ATextMeasure";
4497
- }
4498
4466
  configure(service, env) {
4499
4467
  this.canvas = service.canvas, this.context = service.context, service.bindTextMeasure(this);
4500
4468
  }
@@ -4887,13 +4855,11 @@
4887
4855
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4888
4856
  };
4889
4857
  const TextMeasureContribution = Symbol.for("TextMeasureContribution");
4890
- let DefaultTextMeasureContribution = class extends ATextMeasure {
4891
- constructor() {
4892
- super(...arguments), this.id = "DefaultTextMeasureContribution";
4893
- }
4894
- };
4858
+ let DefaultTextMeasureContribution = class extends ATextMeasure {};
4895
4859
  DefaultTextMeasureContribution = __decorate$t([injectable()], DefaultTextMeasureContribution);
4896
4860
 
4861
+ const container = new Container();
4862
+
4897
4863
  const CanvasFactory = Symbol.for("CanvasFactory");
4898
4864
 
4899
4865
  function wrapCanvas(params) {
@@ -5472,17 +5438,13 @@
5472
5438
  return this.tryInitCanvas(), this._context;
5473
5439
  }
5474
5440
  constructor(contributions) {
5475
- this.contributions = contributions, this.configured = !1, this.global = application.global, this._textMeasureMap = new Map(), this.global.hooks.onSetEnv.tap("graphic-util", (lastEnv, env, global) => {
5441
+ this.contributions = contributions, this.configured = !1, this.global = application.global, this.global.hooks.onSetEnv.tap("graphic-util", (lastEnv, env, global) => {
5476
5442
  this.configured = !1, this.configure(global, env);
5477
5443
  });
5478
5444
  }
5479
5445
  get textMeasure() {
5480
5446
  return this._textMeasure || this.configure(this.global, this.global.env), this._textMeasure;
5481
5447
  }
5482
- getTextMeasureInstance(textMeasureId) {
5483
- if (!textMeasureId) return this.textMeasure;
5484
- return this._textMeasureMap.get(textMeasureId) || this.textMeasure;
5485
- }
5486
5448
  configure(global, env) {
5487
5449
  this.configured || (this.contributions.getContributions().forEach(contribution => {
5488
5450
  contribution.configure(this, env);
@@ -5495,7 +5457,7 @@
5495
5457
  }
5496
5458
  }
5497
5459
  bindTextMeasure(tm) {
5498
- this._textMeasure && "DefaultTextMeasureContribution" !== tm.id || (this._textMeasure = tm), this._textMeasureMap.has(tm.id) || this._textMeasureMap.set(tm.id, tm);
5460
+ this._textMeasure = tm;
5499
5461
  }
5500
5462
  measureText(text, tc, method = "native") {
5501
5463
  var _a;
@@ -8279,7 +8241,7 @@
8279
8241
  });
8280
8242
  }
8281
8243
  setAttributes(params, forceUpdateTag = !1, context) {
8282
- params && ((params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params).background ? this.loadImage(params.background, !0) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._setAttributes(params, forceUpdateTag, context));
8244
+ (params = this.onBeforeAttributeUpdate && this.onBeforeAttributeUpdate(params, this.attribute, null, context) || params).background ? this.loadImage(params.background, !0) : params.shadowGraphic && this.setShadowGraphic(params.shadowGraphic), this._setAttributes(params, forceUpdateTag, context);
8283
8245
  }
8284
8246
  _setAttributes(params, forceUpdateTag = !1, context) {
8285
8247
  const keys = Object.keys(params);
@@ -9104,8 +9066,8 @@
9104
9066
  function strokeVisible(opacity, strokeOpacity) {
9105
9067
  return opacity * strokeOpacity > 0;
9106
9068
  }
9107
- function rectStrokeVisible(opacity, strokeOpacity, width, height, drawStrokeWhenZeroWH) {
9108
- return drawStrokeWhenZeroWH ? opacity * strokeOpacity > 0 : opacity * strokeOpacity > 0 && 0 !== width && 0 !== height;
9069
+ function rectStrokeVisible(opacity, strokeOpacity, width, height) {
9070
+ return opacity * strokeOpacity > 0 && 0 !== width && 0 !== height;
9109
9071
  }
9110
9072
 
9111
9073
  const AreaRenderContribution = Symbol.for("AreaRenderContribution");
@@ -9526,7 +9488,7 @@
9526
9488
  this.cache.layoutData.lines.forEach(item => {
9527
9489
  mergedText += item.str;
9528
9490
  });
9529
- return (Array.isArray(text) ? text.join("") : text).toString() !== mergedText;
9491
+ return (Array.isArray(text) ? text.join("") : text) !== mergedText;
9530
9492
  }
9531
9493
  return "vertical" === attribute.direction && this.cache.verticalList && this.cache.verticalList[0] ? this.cache.verticalList[0].map(item => item.text).join("") !== attribute.text.toString() : null != this.clipedText && this.clipedText !== attribute.text.toString();
9532
9494
  }
@@ -9625,7 +9587,7 @@
9625
9587
  return fontSize ? .1 * fontSize : 0;
9626
9588
  }
9627
9589
  updateHorizontalMultilineAABBBounds(text) {
9628
- var _a, _b;
9590
+ var _a;
9629
9591
  const textTheme = this.getGraphicTheme(),
9630
9592
  attribute = this.attribute,
9631
9593
  {
@@ -9652,7 +9614,7 @@
9652
9614
  const bbox = this.cache.layoutData.bbox;
9653
9615
  return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
9654
9616
  }
9655
- const textMeasure = application.graphicUtil.getTextMeasureInstance(this.textMeasureId || (null === (_b = this.stage) || void 0 === _b ? void 0 : _b.textMeasureId)),
9617
+ const textMeasure = application.graphicUtil.textMeasure,
9656
9618
  layoutData = new CanvasTextLayout(fontFamily, {
9657
9619
  fontSize: fontSize,
9658
9620
  fontWeight: fontWeight,
@@ -9670,7 +9632,7 @@
9670
9632
  return this.cache.layoutData = layoutData, this.clearUpdateShapeTag(), this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
9671
9633
  }
9672
9634
  updateWrapAABBBounds(text) {
9673
- var _a, _b, _c, _d;
9635
+ var _a, _b, _c;
9674
9636
  const textTheme = this.getGraphicTheme(),
9675
9637
  {
9676
9638
  fontFamily = textTheme.fontFamily,
@@ -9696,7 +9658,7 @@
9696
9658
  const bbox = this.cache.layoutData.bbox;
9697
9659
  return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
9698
9660
  }
9699
- const textMeasure = application.graphicUtil.getTextMeasureInstance(this.textMeasureId || (null === (_b = this.stage) || void 0 === _b ? void 0 : _b.textMeasureId)),
9661
+ const textMeasure = application.graphicUtil.textMeasure,
9700
9662
  textOptions = {
9701
9663
  fontSize: fontSize,
9702
9664
  fontWeight: fontWeight,
@@ -9728,7 +9690,7 @@
9728
9690
  if ("" !== str && "" === clip.str || clip.wordBreaked) {
9729
9691
  if (ellipsis) {
9730
9692
  const clipEllipsis = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
9731
- clip.str = null !== (_c = clipEllipsis.str) && void 0 !== _c ? _c : "", clip.width = null !== (_d = clipEllipsis.width) && void 0 !== _d ? _d : 0;
9693
+ clip.str = null !== (_b = clipEllipsis.str) && void 0 !== _b ? _b : "", clip.width = null !== (_c = clipEllipsis.width) && void 0 !== _c ? _c : 0;
9732
9694
  } else clip.str = "", clip.width = 0;
9733
9695
  needCut = !1;
9734
9696
  }
@@ -9791,9 +9753,9 @@
9791
9753
  return this.cache.layoutData = layoutData, this.clearUpdateShapeTag(), this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
9792
9754
  }
9793
9755
  updateVerticalMultilineAABBBounds(text) {
9794
- var _a, _b, _c;
9756
+ var _a, _b;
9795
9757
  const textTheme = this.getGraphicTheme(),
9796
- textMeasure = application.graphicUtil.getTextMeasureInstance(this.textMeasureId || (null === (_a = this.stage) || void 0 === _a ? void 0 : _a.textMeasureId));
9758
+ textMeasure = application.graphicUtil.textMeasure;
9797
9759
  let width;
9798
9760
  const attribute = this.attribute,
9799
9761
  {
@@ -9814,7 +9776,7 @@
9814
9776
  } = attribute;
9815
9777
  if (!verticalMode) {
9816
9778
  const t = textAlign;
9817
- textAlign = null !== (_b = Text.baselineMapAlign[textBaseline]) && void 0 !== _b ? _b : "left", textBaseline = null !== (_c = Text.alignMapBaseline[t]) && void 0 !== _c ? _c : "top";
9779
+ textAlign = null !== (_a = Text.baselineMapAlign[textBaseline]) && void 0 !== _a ? _a : "left", textBaseline = null !== (_b = Text.alignMapBaseline[t]) && void 0 !== _b ? _b : "top";
9818
9780
  }
9819
9781
  if (width = 0, !this.shouldUpdateShape() && this.cache) {
9820
9782
  this.cache.verticalList.forEach(item => {
@@ -11799,8 +11761,7 @@
11799
11761
  y1: y1,
11800
11762
  x: originX = rectAttribute.x,
11801
11763
  y: originY = rectAttribute.y,
11802
- fillStrokeOrder = rectAttribute.fillStrokeOrder,
11803
- drawStrokeWhenZeroWH = rectAttribute.drawStrokeWhenZeroWH
11764
+ fillStrokeOrder = rectAttribute.fillStrokeOrder
11804
11765
  } = rect.attribute;
11805
11766
  let {
11806
11767
  width: width,
@@ -11808,7 +11769,7 @@
11808
11769
  } = rect.attribute;
11809
11770
  width = (null != width ? width : x1 - originX) || 0, height = (null != height ? height : y1 - originY) || 0;
11810
11771
  const fVisible = rectFillVisible(opacity, fillOpacity, width, height, fill),
11811
- sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height, drawStrokeWhenZeroWH),
11772
+ sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height),
11812
11773
  doFill = runFill(fill, background),
11813
11774
  doStroke = runStroke(stroke, lineWidth);
11814
11775
  if (!rect.valid || !visible) return;
@@ -12530,6 +12491,7 @@
12530
12491
  decorator(target, key, paramIndex);
12531
12492
  };
12532
12493
  };
12494
+ const RenderService = Symbol.for("RenderService");
12533
12495
  let DefaultRenderService = class {
12534
12496
  constructor(drawContribution) {
12535
12497
  this.drawContribution = drawContribution;
@@ -13418,6 +13380,8 @@
13418
13380
  application.transformUtil = transformUtil;
13419
13381
  const graphicService = container.get(GraphicService);
13420
13382
  application.graphicService = graphicService;
13383
+ const renderService = container.get(RenderService);
13384
+ application.renderService = renderService;
13421
13385
  const layerService = container.get(LayerService);
13422
13386
  application.layerService = layerService;
13423
13387
 
@@ -13665,13 +13629,13 @@
13665
13629
  this._skipRender > 1 && this.renderNextFrame(), this._skipRender = 0;
13666
13630
  } else this._skipRender = 1;
13667
13631
  }, this.beforeRender = stage => {
13668
- this._beforeRenderList.forEach(cb => cb(stage));
13632
+ this._beforeRender && this._beforeRender(stage);
13669
13633
  }, this.afterClearScreen = drawParams => {
13670
13634
  this._afterClearScreen && this._afterClearScreen(drawParams);
13671
13635
  }, this.afterClearRect = drawParams => {
13672
13636
  this._afterClearRect && this._afterClearRect(drawParams);
13673
13637
  }, this.afterRender = stage => {
13674
- this.renderCount++, this._afterRenderList.forEach(cb => cb(stage)), this._afterNextRenderCbs && this._afterNextRenderCbs.forEach(cb => cb(stage)), this._afterNextRenderCbs = null, this.tickedBeforeRender = !1;
13638
+ this.renderCount++, this._afterRender && this._afterRender(stage), this._afterNextRenderCbs && this._afterNextRenderCbs.forEach(cb => cb(stage)), this._afterNextRenderCbs = null, this.tickedBeforeRender = !1;
13675
13639
  }, this.afterTickCb = () => {
13676
13640
  this.tickedBeforeRender = !0, "rendering" !== this.state && this.renderNextFrame();
13677
13641
  }, this.params = params, this.theme = new Theme(), this.hooks = {
@@ -13679,7 +13643,7 @@
13679
13643
  afterRender: new SyncHook(["stage"]),
13680
13644
  afterClearScreen: new SyncHook(["stage"]),
13681
13645
  afterClearRect: new SyncHook(["stage"])
13682
- }, this.global = application.global, !this.global.env && isBrowserEnv() && this.global.setEnv("browser"), this.window = container.get(VWindow), this.renderService = container.get(RenderService), this.pluginService = container.get(PluginService), this.layerService = container.get(LayerService), this.graphicService = container.get(GraphicService), this.pluginService.active(this, params), this._beforeRenderList = [], this._afterRenderList = [], this.window.create({
13646
+ }, this.global = application.global, !this.global.env && isBrowserEnv() && this.global.setEnv("browser"), this.window = container.get(VWindow), this.renderService = container.get(RenderService), this.pluginService = container.get(PluginService), this.layerService = container.get(LayerService), this.graphicService = container.get(GraphicService), this.pluginService.active(this, params), this.window.create({
13683
13647
  width: params.width,
13684
13648
  height: params.height,
13685
13649
  viewBox: params.viewBox,
@@ -13690,7 +13654,7 @@
13690
13654
  canvas: params.canvas
13691
13655
  }), this.state = "normal", this.renderCount = 0, this.tryInitEventSystem(), this._background = null !== (_a = params.background) && void 0 !== _a ? _a : DefaultConfig.BACKGROUND, this.appendChild(this.layerService.createLayer(this, {
13692
13656
  main: !0
13693
- })), this.nextFrameRenderLayerSet = new Set(), this.willNextFrameRender = !1, this.stage = this, this.renderStyle = params.renderStyle, params.autoRender && this.enableAutoRender(), params.autoRefresh && this.enableAutoRefresh(), !1 === params.disableDirtyBounds && this.enableDirtyBounds(), params.enableHtmlAttribute && this.enableHtmlAttribute(params.enableHtmlAttribute), params.ReactDOM && this.enableReactAttribute(params.ReactDOM), params.enableLayout && this.enableLayout(), this.hooks.beforeRender.tap("constructor", this.beforeRender), this.hooks.afterRender.tap("constructor", this.afterRender), params.beforeRender && this._beforeRenderList.push(params.beforeRender), params.afterRender && this._afterRenderList.push(params.afterRender), this.hooks.afterClearScreen.tap("constructor", this.afterClearScreen), this.hooks.afterClearRect.tap("constructor", this.afterClearRect), this._afterClearScreen = params.afterClearScreen, this._afterClearRect = params.afterClearRect, this.supportInteractiveLayer = !1 !== params.interactiveLayer, params.optimize || (params.optimize = {
13657
+ })), this.nextFrameRenderLayerSet = new Set(), this.willNextFrameRender = !1, this.stage = this, this.renderStyle = params.renderStyle, params.autoRender && this.enableAutoRender(), params.autoRefresh && this.enableAutoRefresh(), !1 === params.disableDirtyBounds && this.enableDirtyBounds(), params.enableHtmlAttribute && this.enableHtmlAttribute(params.enableHtmlAttribute), params.ReactDOM && this.enableReactAttribute(params.ReactDOM), params.enableLayout && this.enableLayout(), this.hooks.beforeRender.tap("constructor", this.beforeRender), this.hooks.afterRender.tap("constructor", this.afterRender), this.hooks.afterClearScreen.tap("constructor", this.afterClearScreen), this.hooks.afterClearRect.tap("constructor", this.afterClearRect), this._beforeRender = params.beforeRender, this._afterRender = params.afterRender, this._afterClearScreen = params.afterClearScreen, this._afterClearRect = params.afterClearRect, this.supportInteractiveLayer = !1 !== params.interactiveLayer, params.optimize || (params.optimize = {
13694
13658
  tickRenderMode: "effect"
13695
13659
  }), this.optmize(params.optimize), params.background && isString$3(this._background) && this._background.includes("/") && this.setAttributes({
13696
13660
  background: this._background
@@ -13805,16 +13769,10 @@
13805
13769
  options.enableView3dTransform && this.enableView3dTransform();
13806
13770
  }
13807
13771
  setBeforeRender(cb) {
13808
- this._beforeRenderList.push(cb);
13809
- }
13810
- removeBeforeRender(cb) {
13811
- this._beforeRenderList = this._beforeRenderList.filter(c => c !== cb);
13772
+ this._beforeRender = cb;
13812
13773
  }
13813
13774
  setAfterRender(cb) {
13814
- this._afterRenderList.push(cb);
13815
- }
13816
- removeAfterRender(cb) {
13817
- this._afterRenderList = this._afterRenderList.filter(c => c !== cb);
13775
+ this._afterRender = cb;
13818
13776
  }
13819
13777
  afterNextRender(cb) {
13820
13778
  this._afterNextRenderCbs || (this._afterNextRenderCbs = []), this._afterNextRenderCbs.push(cb);