@visactor/vrender-core 0.16.17-alpha.3 → 0.16.17-alpha.8

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.
Files changed (55) hide show
  1. package/cjs/core/stage.js +3 -3
  2. package/cjs/core/stage.js.map +1 -1
  3. package/cjs/event/event-manager.d.ts +5 -1
  4. package/cjs/event/event-manager.js +11 -7
  5. package/cjs/event/event-manager.js.map +1 -1
  6. package/cjs/event/event-system.js +8 -7
  7. package/cjs/event/event-system.js.map +1 -1
  8. package/cjs/graphic/graphic-service/graphic-service.d.ts +3 -2
  9. package/cjs/graphic/graphic-service/graphic-service.js +19 -2
  10. package/cjs/graphic/graphic-service/graphic-service.js.map +1 -1
  11. package/cjs/graphic/graphic.js +1 -1
  12. package/cjs/graphic/graphic.js.map +1 -1
  13. package/cjs/graphic/richtext.js +1 -1
  14. package/cjs/graphic/richtext.js.map +1 -1
  15. package/cjs/graphic/symbol.js +1 -3
  16. package/cjs/graphic/symbol.js.map +1 -1
  17. package/cjs/interface/event.d.ts +1 -34
  18. package/cjs/interface/event.js.map +1 -1
  19. package/cjs/interface/stage.d.ts +6 -0
  20. package/cjs/interface/stage.js.map +1 -1
  21. package/cjs/picker/pick-interceptor.js +2 -1
  22. package/cjs/picker/pick-interceptor.js.map +1 -1
  23. package/cjs/render/contributions/render/image-render.js +2 -1
  24. package/cjs/render/contributions/render/image-render.js.map +1 -1
  25. package/cjs/render/contributions/render/symbol-render.js +20 -4
  26. package/cjs/render/contributions/render/symbol-render.js.map +1 -1
  27. package/dist/index.js +94 -26
  28. package/dist/index.min.js +1 -1
  29. package/es/core/stage.js +3 -3
  30. package/es/core/stage.js.map +1 -1
  31. package/es/event/event-manager.d.ts +5 -1
  32. package/es/event/event-manager.js +11 -7
  33. package/es/event/event-manager.js.map +1 -1
  34. package/es/event/event-system.js +4 -2
  35. package/es/event/event-system.js.map +1 -1
  36. package/es/graphic/graphic-service/graphic-service.d.ts +3 -2
  37. package/es/graphic/graphic-service/graphic-service.js +19 -2
  38. package/es/graphic/graphic-service/graphic-service.js.map +1 -1
  39. package/es/graphic/graphic.js +1 -1
  40. package/es/graphic/graphic.js.map +1 -1
  41. package/es/graphic/richtext.js +1 -1
  42. package/es/graphic/richtext.js.map +1 -1
  43. package/es/graphic/symbol.js +1 -3
  44. package/es/graphic/symbol.js.map +1 -1
  45. package/es/interface/event.d.ts +1 -34
  46. package/es/interface/event.js.map +1 -1
  47. package/es/interface/stage.d.ts +6 -0
  48. package/es/interface/stage.js.map +1 -1
  49. package/es/picker/pick-interceptor.js +2 -1
  50. package/es/picker/pick-interceptor.js.map +1 -1
  51. package/es/render/contributions/render/image-render.js +2 -1
  52. package/es/render/contributions/render/image-render.js.map +1 -1
  53. package/es/render/contributions/render/symbol-render.js +20 -4
  54. package/es/render/contributions/render/symbol-render.js.map +1 -1
  55. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -6581,8 +6581,9 @@
6581
6581
  function isMouseLike(pointerType) {
6582
6582
  return pointerType === 'mouse' || pointerType === 'pen';
6583
6583
  }
6584
+ const DEFAULT_CLICK_INTERVAL = 200;
6584
6585
  class EventManager {
6585
- constructor(root) {
6586
+ constructor(root, config) {
6586
6587
  this.dispatch = new vutils.EventEmitter();
6587
6588
  this.mappingState = {
6588
6589
  trackingData: {}
@@ -6741,6 +6742,7 @@
6741
6742
  this.cursor = '';
6742
6743
  };
6743
6744
  this.onPointerUp = (from, target) => {
6745
+ var _a;
6744
6746
  if (!(from instanceof FederatedPointerEvent)) {
6745
6747
  console.warn('EventManager cannot map a non-pointer event as a pointer event');
6746
6748
  return;
@@ -6787,7 +6789,8 @@
6787
6789
  };
6788
6790
  }
6789
6791
  const clickHistory = trackingData.clicksByButton[from.button];
6790
- if (clickHistory.target === clickEvent.target && now - clickHistory.timeStamp < 200) {
6792
+ if (clickHistory.target === clickEvent.target &&
6793
+ now - clickHistory.timeStamp < ((_a = this._config.clickInterval) !== null && _a !== void 0 ? _a : DEFAULT_CLICK_INTERVAL)) {
6791
6794
  ++clickHistory.clickCount;
6792
6795
  }
6793
6796
  else {
@@ -6846,6 +6849,7 @@
6846
6849
  };
6847
6850
  this.rootTarget = root;
6848
6851
  this.mappingTable = {};
6852
+ this._config = Object.assign({ clickInterval: DEFAULT_CLICK_INTERVAL }, config);
6849
6853
  this.addEventMapping('pointerdown', this.onPointerDown);
6850
6854
  this.addEventMapping('pointermove', this.onPointerMove);
6851
6855
  this.addEventMapping('pointerout', this.onPointerOut);
@@ -7237,8 +7241,10 @@
7237
7241
  const wheelEvent = this.normalizeWheelEvent(nativeEvent);
7238
7242
  this.manager.mapEvent(wheelEvent);
7239
7243
  };
7240
- const { targetElement, resolution, rootNode, global, viewport, autoPreventDefault = false } = params;
7241
- this.manager = new EventManager(rootNode);
7244
+ const { targetElement, resolution, rootNode, global, viewport, autoPreventDefault = false, clickInterval } = params;
7245
+ this.manager = new EventManager(rootNode, {
7246
+ clickInterval
7247
+ });
7242
7248
  this.globalObj = global;
7243
7249
  this.supportsPointerEvents = global.supportsPointerEvents;
7244
7250
  this.supportsTouchEvents = global.supportsTouchEvents;
@@ -11366,13 +11372,11 @@
11366
11372
  ];
11367
11373
  const GRAPHIC_UPDATE_TAG_KEY = [
11368
11374
  'lineWidth',
11369
- 'lineCap',
11370
- 'lineJoin',
11371
- 'miterLimit',
11372
11375
  'scaleX',
11373
11376
  'scaleY',
11374
11377
  'angle',
11375
- 'anchor'
11378
+ 'anchor',
11379
+ 'visible'
11376
11380
  ];
11377
11381
  const tempConstantXYKey = ['x', 'y'];
11378
11382
  const tempConstantScaleXYKey = ['scaleX', 'scaleY'];
@@ -15752,9 +15756,7 @@
15752
15756
  const cacheList = [];
15753
15757
  path.forEach((item) => {
15754
15758
  const cache = new CustomPath2D().fromString(item.d);
15755
- const attribute = {
15756
- fill: 'black'
15757
- };
15759
+ const attribute = {};
15758
15760
  SVG_PARSE_ATTRIBUTE_MAP_KEYS.forEach(k => {
15759
15761
  if (item[k]) {
15760
15762
  attribute[SVG_PARSE_ATTRIBUTE_MAP[k]] = item[k];
@@ -17256,7 +17258,7 @@
17256
17258
  }
17257
17259
  doUpdateFrameCache() {
17258
17260
  var _a;
17259
- const { textConfig, maxWidth, maxHeight, width, height, ellipsis, wordBreak, verticalDirection, textAlign, textBaseline, layoutDirection, singleLine } = this.attribute;
17261
+ const { textConfig = [], maxWidth, maxHeight, width, height, ellipsis, wordBreak, verticalDirection, textAlign, textBaseline, layoutDirection, singleLine } = this.attribute;
17260
17262
  const paragraphs = [];
17261
17263
  for (let i = 0; i < textConfig.length; i++) {
17262
17264
  if ('image' in textConfig[i]) {
@@ -18611,6 +18613,9 @@
18611
18613
  return true;
18612
18614
  }
18613
18615
  updateRectAABBBounds(attribute, rectTheme, aabbBounds, graphic) {
18616
+ if (!this._validCheck(attribute, rectTheme, aabbBounds, graphic)) {
18617
+ return aabbBounds;
18618
+ }
18614
18619
  if (!this.updatePathProxyAABBBounds(aabbBounds, graphic)) {
18615
18620
  const { width = rectTheme.width, height = rectTheme.height } = attribute;
18616
18621
  aabbBounds.set(0, 0, width, height);
@@ -18654,12 +18659,18 @@
18654
18659
  return aabbBounds;
18655
18660
  }
18656
18661
  updateGlyphAABBBounds(attribute, theme, aabbBounds, graphic) {
18662
+ if (!this._validCheck(attribute, theme, aabbBounds, graphic)) {
18663
+ return aabbBounds;
18664
+ }
18657
18665
  graphic.getSubGraphic().forEach((node) => {
18658
18666
  aabbBounds.union(node.AABBBounds);
18659
18667
  });
18660
18668
  return aabbBounds;
18661
18669
  }
18662
18670
  updateRichTextAABBBounds(attribute, richtextTheme, aabbBounds, graphic) {
18671
+ if (!this._validCheck(attribute, richtextTheme, aabbBounds, graphic)) {
18672
+ return aabbBounds;
18673
+ }
18663
18674
  if (!graphic) {
18664
18675
  return aabbBounds;
18665
18676
  }
@@ -18709,6 +18720,9 @@
18709
18720
  return aabbBounds;
18710
18721
  }
18711
18722
  updateTextAABBBounds(attribute, textTheme, aabbBounds, graphic) {
18723
+ if (!this._validCheck(attribute, textTheme, aabbBounds, graphic)) {
18724
+ return aabbBounds;
18725
+ }
18712
18726
  if (!graphic) {
18713
18727
  return aabbBounds;
18714
18728
  }
@@ -18734,6 +18748,9 @@
18734
18748
  return aabbBounds;
18735
18749
  }
18736
18750
  updatePathAABBBounds(attribute, pathTheme, aabbBounds, graphic) {
18751
+ if (!this._validCheck(attribute, pathTheme, aabbBounds, graphic)) {
18752
+ return aabbBounds;
18753
+ }
18737
18754
  if (!this.updatePathProxyAABBBounds(aabbBounds, graphic)) {
18738
18755
  this.updatePathAABBBoundsImprecise(attribute, pathTheme, aabbBounds, graphic);
18739
18756
  }
@@ -18802,6 +18819,9 @@
18802
18819
  return aabbBounds;
18803
18820
  }
18804
18821
  updatePolygonAABBBounds(attribute, polygonTheme, aabbBounds, graphic) {
18822
+ if (!this._validCheck(attribute, polygonTheme, aabbBounds, graphic)) {
18823
+ return aabbBounds;
18824
+ }
18805
18825
  if (!this.updatePathProxyAABBBounds(aabbBounds, graphic)) {
18806
18826
  this.updatePolygonAABBBoundsImprecise(attribute, polygonTheme, aabbBounds, graphic);
18807
18827
  }
@@ -18821,6 +18841,9 @@
18821
18841
  return aabbBounds;
18822
18842
  }
18823
18843
  updateLineAABBBounds(attribute, lineTheme, aabbBounds, graphic) {
18844
+ if (!this._validCheck(attribute, lineTheme, aabbBounds, graphic)) {
18845
+ return aabbBounds;
18846
+ }
18824
18847
  if (!this.updatePathProxyAABBBounds(aabbBounds, graphic)) {
18825
18848
  attribute.segments
18826
18849
  ? this.updateLineAABBBoundsBySegments(attribute, lineTheme, aabbBounds, graphic)
@@ -18853,6 +18876,9 @@
18853
18876
  return b;
18854
18877
  }
18855
18878
  updateAreaAABBBounds(attribute, areaTheme, aabbBounds, graphic) {
18879
+ if (!this._validCheck(attribute, areaTheme, aabbBounds, graphic)) {
18880
+ return aabbBounds;
18881
+ }
18856
18882
  if (!this.updatePathProxyAABBBounds(aabbBounds, graphic)) {
18857
18883
  attribute.segments
18858
18884
  ? this.updateAreaAABBBoundsBySegments(attribute, areaTheme, aabbBounds, graphic)
@@ -18889,6 +18915,9 @@
18889
18915
  return b;
18890
18916
  }
18891
18917
  updateCircleAABBBounds(attribute, circleTheme, aabbBounds, full, graphic) {
18918
+ if (!this._validCheck(attribute, circleTheme, aabbBounds, graphic)) {
18919
+ return aabbBounds;
18920
+ }
18892
18921
  if (!this.updatePathProxyAABBBounds(aabbBounds, graphic)) {
18893
18922
  full
18894
18923
  ? this.updateCircleAABBBoundsImprecise(attribute, circleTheme, aabbBounds, graphic)
@@ -18926,6 +18955,9 @@
18926
18955
  return aabbBounds;
18927
18956
  }
18928
18957
  updateArcAABBBounds(attribute, arcTheme, aabbBounds, full, graphic) {
18958
+ if (!this._validCheck(attribute, arcTheme, aabbBounds, graphic)) {
18959
+ return aabbBounds;
18960
+ }
18929
18961
  if (!this.updatePathProxyAABBBounds(aabbBounds, graphic)) {
18930
18962
  full
18931
18963
  ? this.updateArcAABBBoundsImprecise(attribute, arcTheme, aabbBounds, graphic)
@@ -18979,6 +19011,9 @@
18979
19011
  return aabbBounds;
18980
19012
  }
18981
19013
  updateSymbolAABBBounds(attribute, symbolTheme, aabbBounds, full, graphic) {
19014
+ if (!this._validCheck(attribute, symbolTheme, aabbBounds, graphic)) {
19015
+ return aabbBounds;
19016
+ }
18982
19017
  if (!this.updatePathProxyAABBBounds(aabbBounds, graphic)) {
18983
19018
  full
18984
19019
  ? this.updateSymbolAABBBoundsImprecise(attribute, symbolTheme, aabbBounds, graphic)
@@ -19022,6 +19057,9 @@
19022
19057
  return aabbBounds;
19023
19058
  }
19024
19059
  updateImageAABBBounds(attribute, imageTheme, aabbBounds, graphic) {
19060
+ if (!this._validCheck(attribute, imageTheme, aabbBounds, graphic)) {
19061
+ return aabbBounds;
19062
+ }
19025
19063
  if (!this.updatePathProxyAABBBounds(aabbBounds, graphic)) {
19026
19064
  const { width = imageTheme.width, height = imageTheme.height } = attribute;
19027
19065
  aabbBounds.set(0, 0, width, height);
@@ -19057,6 +19095,21 @@
19057
19095
  this.combindShadowAABBBounds(aabbBounds, graphic);
19058
19096
  vutils.transformBoundsWithMatrix(aabbBounds, aabbBounds, graphic.transMatrix);
19059
19097
  }
19098
+ _validCheck(attribute, theme, aabbBounds, graphic) {
19099
+ if (!graphic) {
19100
+ return true;
19101
+ }
19102
+ if (!graphic.valid) {
19103
+ aabbBounds.clear();
19104
+ return false;
19105
+ }
19106
+ const { visible = theme.visible } = attribute;
19107
+ if (!visible) {
19108
+ aabbBounds.clear();
19109
+ return false;
19110
+ }
19111
+ return true;
19112
+ }
19060
19113
  };
19061
19114
  exports.DefaultGraphicService = __decorate([
19062
19115
  injectable(),
@@ -20910,12 +20963,21 @@
20910
20963
  const camera = context.camera;
20911
20964
  context.camera = null;
20912
20965
  if (parsedPath.draw(context, size, p.x, p.y, undefined, (p, a) => {
20966
+ var _a, _b, _c;
20967
+ if (symbol._parsedPath.svgCache) {
20968
+ const obj = Object.assign({}, a);
20969
+ obj.fill = (_a = a.fill) !== null && _a !== void 0 ? _a : symbol.attribute.fill;
20970
+ obj.opacity = (_b = a.fill) !== null && _b !== void 0 ? _b : symbol.attribute.opacity;
20971
+ obj.fillOpacity = symbol.attribute.fillOpacity;
20972
+ obj.stroke = (_c = a.stroke) !== null && _c !== void 0 ? _c : symbol.attribute.stroke;
20973
+ a = obj;
20974
+ }
20913
20975
  if (a.fill) {
20914
20976
  if (fillCb) {
20915
20977
  fillCb(context, symbol.attribute, symbolAttribute);
20916
20978
  }
20917
20979
  else {
20918
- context.setCommonStyle(symbol, a, originX - x, originY - y);
20980
+ context.setCommonStyle(symbol, a, originX - x, originY - y, symbolAttribute);
20919
20981
  context.fill();
20920
20982
  }
20921
20983
  }
@@ -20924,7 +20986,7 @@
20924
20986
  strokeCb(context, symbol.attribute, symbolAttribute);
20925
20987
  }
20926
20988
  else {
20927
- context.setStrokeStyle(symbol, a, (originX - x) / scaleX, (originY - y) / scaleY);
20989
+ context.setStrokeStyle(symbol, a, (originX - x) / scaleX, (originY - y) / scaleY, symbolAttribute);
20928
20990
  context.stroke();
20929
20991
  }
20930
20992
  }
@@ -20935,12 +20997,21 @@
20935
20997
  }
20936
20998
  else {
20937
20999
  if (parsedPath.draw(context, size, x, y, z, (p, a) => {
21000
+ var _a, _b, _c;
21001
+ if (symbol._parsedPath.svgCache) {
21002
+ const obj = Object.assign({}, a);
21003
+ obj.fill = (_a = a.fill) !== null && _a !== void 0 ? _a : symbol.attribute.fill;
21004
+ obj.opacity = (_b = a.opacity) !== null && _b !== void 0 ? _b : symbol.attribute.opacity;
21005
+ obj.fillOpacity = symbol.attribute.fillOpacity;
21006
+ obj.stroke = (_c = a.stroke) !== null && _c !== void 0 ? _c : symbol.attribute.stroke;
21007
+ a = obj;
21008
+ }
20938
21009
  if (a.fill) {
20939
21010
  if (fillCb) {
20940
21011
  fillCb(context, symbol.attribute, symbolAttribute);
20941
21012
  }
20942
21013
  else {
20943
- context.setCommonStyle(symbol, a, originX - x, originY - y);
21014
+ context.setCommonStyle(symbol, a, originX - x, originY - y, symbolAttribute);
20944
21015
  context.fill();
20945
21016
  }
20946
21017
  }
@@ -20949,7 +21020,7 @@
20949
21020
  strokeCb(context, symbol.attribute, symbolAttribute);
20950
21021
  }
20951
21022
  else {
20952
- context.setStrokeStyle(symbol, a, (originX - x) / scaleX, (originY - y) / scaleY);
21023
+ context.setStrokeStyle(symbol, a, (originX - x) / scaleX, (originY - y) / scaleY, symbolAttribute);
20953
21024
  context.stroke();
20954
21025
  }
20955
21026
  }
@@ -21444,7 +21515,9 @@
21444
21515
  if (repeat) {
21445
21516
  const pattern = context.createPattern(res.data, repeatStr[repeat]);
21446
21517
  context.fillStyle = pattern;
21447
- context.fillRect(x, y, width, height);
21518
+ context.translate(x, y, true);
21519
+ context.fillRect(0, 0, width, height);
21520
+ context.translate(-x, -y, true);
21448
21521
  }
21449
21522
  else {
21450
21523
  context.drawImage(res.data, x, y, width, height);
@@ -22761,6 +22834,7 @@
22761
22834
  }
22762
22835
  context.camera = null;
22763
22836
  pickParams.in3dInterceptor = false;
22837
+ context.restore();
22764
22838
  return result;
22765
22839
  }
22766
22840
  context.restore();
@@ -26225,12 +26299,7 @@
26225
26299
  this.stage = this;
26226
26300
  this.renderStyle = params.renderStyle;
26227
26301
  if (this.global.supportEvent) {
26228
- this.eventSystem = new EventSystem({
26229
- targetElement: this.window,
26230
- resolution: this.window.dpr || this.global.devicePixelRatio,
26231
- rootNode: this,
26232
- global: this.global,
26233
- viewport: {
26302
+ this.eventSystem = new EventSystem(Object.assign({ targetElement: this.window, resolution: this.window.dpr || this.global.devicePixelRatio, rootNode: this, global: this.global, viewport: {
26234
26303
  viewBox: this._viewBox,
26235
26304
  get x() {
26236
26305
  return this.viewBox.x1;
@@ -26244,8 +26313,7 @@
26244
26313
  get height() {
26245
26314
  return this.viewBox.height();
26246
26315
  }
26247
- }
26248
- });
26316
+ } }, params.event));
26249
26317
  }
26250
26318
  if (params.autoRender) {
26251
26319
  this.enableAutoRender();
@@ -26267,7 +26335,7 @@
26267
26335
  this.ticker.addTimeline(this.timeline);
26268
26336
  this.timeline.pause();
26269
26337
  this.optmize(params.optimize);
26270
- if (this._background && vutils.isString(this._background)) {
26338
+ if (params.background && vutils.isString(this._background) && this._background.includes('/')) {
26271
26339
  this.setAttributes({ background: this._background });
26272
26340
  }
26273
26341
  }