@visactor/vrender 0.16.12-alpha.2 → 0.16.13

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/cjs/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export declare const version = "0.16.12-alpha.2";
1
+ export declare const version = "0.16.13";
2
2
  export * from '@visactor/vrender-core';
3
3
  export * from '@visactor/vrender-kits';
package/cjs/index.js CHANGED
@@ -21,5 +21,5 @@ Object.defineProperty(exports, "__esModule", {
21
21
 
22
22
  const vrender_core_1 = require("@visactor/vrender-core"), vrender_kits_1 = require("@visactor/vrender-kits");
23
23
 
24
- exports.version = "0.16.12-alpha.2", (0, vrender_kits_1.loadAllModule)(vrender_core_1.container),
24
+ exports.version = "0.16.13", (0, vrender_kits_1.loadAllModule)(vrender_core_1.container),
25
25
  __exportStar(require("@visactor/vrender-core"), exports), __exportStar(require("@visactor/vrender-kits"), exports);
package/cjs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,yDAAmD;AACnD,yDAAuD;AAG1C,QAAA,OAAO,GAAG,iBAAiB,CAAC;AAEzC,IAAA,4BAAa,EAAC,wBAAS,CAAC,CAAC;AAEzB,yDAAuC;AACvC,yDAAuC","file":"index.js","sourcesContent":["import { container } from '@visactor/vrender-core';\nimport { loadAllModule } from '@visactor/vrender-kits';\n\n// 导出版本号\nexport const version = \"0.16.12-alpha.2\";\n\nloadAllModule(container);\n\nexport * from '@visactor/vrender-core';\nexport * from '@visactor/vrender-kits';\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,yDAAmD;AACnD,yDAAuD;AAG1C,QAAA,OAAO,GAAG,SAAS,CAAC;AAEjC,IAAA,4BAAa,EAAC,wBAAS,CAAC,CAAC;AAEzB,yDAAuC;AACvC,yDAAuC","file":"index.js","sourcesContent":["import { container } from '@visactor/vrender-core';\nimport { loadAllModule } from '@visactor/vrender-kits';\n\n// 导出版本号\nexport const version = \"0.16.13\";\n\nloadAllModule(container);\n\nexport * from '@visactor/vrender-core';\nexport * from '@visactor/vrender-kits';\n"]}
package/dist/index.js CHANGED
@@ -3528,6 +3528,11 @@
3528
3528
  function fuzzyEqualVec(a, b) {
3529
3529
  return abs(a[0] - b[0]) + abs(a[1] - b[1]) < 1e-12;
3530
3530
  }
3531
+ function getDecimalPlaces(n) {
3532
+ var dStr = n.toString().split(/[eE]/),
3533
+ s = (dStr[0].split(".")[1] || "").length - (+dStr[1] || 0);
3534
+ return s > 0 ? s : 0;
3535
+ }
3531
3536
 
3532
3537
  var Point = /*#__PURE__*/function () {
3533
3538
  function Point() {
@@ -6280,7 +6285,10 @@
6280
6285
  direction: "horizontal",
6281
6286
  wordBreak: "break-all",
6282
6287
  ignoreBuf: !1,
6283
- verticalMode: 0
6288
+ verticalMode: 0,
6289
+ whiteSpace: "no-wrap",
6290
+ heightLimit: 1 / 0,
6291
+ lineClamp: 1 / 0
6284
6292
  };
6285
6293
  var DefaultStyle = Object.assign(Object.assign(Object.assign({
6286
6294
  opacity: 1,
@@ -9958,8 +9966,8 @@
9958
9966
  }, {
9959
9967
  key: "onBind",
9960
9968
  value: function onBind() {
9961
- var _a, _b, _c, _d, _e, _f;
9962
- this.fromNumber = isNumber$2(null === (_a = this.from) || void 0 === _a ? void 0 : _a.text) ? null === (_b = this.from) || void 0 === _b ? void 0 : _b.text : Number.parseFloat(null === (_c = this.from) || void 0 === _c ? void 0 : _c.text), this.toNumber = isNumber$2(null === (_d = this.to) || void 0 === _d ? void 0 : _d.text) ? null === (_e = this.to) || void 0 === _e ? void 0 : _e.text : Number.parseFloat(null === (_f = this.to) || void 0 === _f ? void 0 : _f.text), Number.isFinite(this.toNumber) || (this.fromNumber = 0), Number.isFinite(this.toNumber) || (this.valid = !1);
9969
+ var _a, _b, _c, _d, _e, _f, _g, _h;
9970
+ this.fromNumber = isNumber$2(null === (_a = this.from) || void 0 === _a ? void 0 : _a.text) ? null === (_b = this.from) || void 0 === _b ? void 0 : _b.text : Number.parseFloat(null === (_c = this.from) || void 0 === _c ? void 0 : _c.text), this.toNumber = isNumber$2(null === (_d = this.to) || void 0 === _d ? void 0 : _d.text) ? null === (_e = this.to) || void 0 === _e ? void 0 : _e.text : Number.parseFloat(null === (_f = this.to) || void 0 === _f ? void 0 : _f.text), Number.isFinite(this.toNumber) || (this.fromNumber = 0), Number.isFinite(this.toNumber) || (this.valid = !1), !1 !== this.valid && (this.decimalLength = null !== (_h = null === (_g = this.params) || void 0 === _g ? void 0 : _g.fixed) && void 0 !== _h ? _h : Math.max(getDecimalPlaces(this.fromNumber), getDecimalPlaces(this.toNumber)));
9963
9971
  }
9964
9972
  }, {
9965
9973
  key: "onEnd",
@@ -9967,11 +9975,7 @@
9967
9975
  }, {
9968
9976
  key: "onUpdate",
9969
9977
  value: function onUpdate(end, ratio, out) {
9970
- var _a;
9971
- if (!1 !== this.valid) if (end) out.text = this.toNumber;else {
9972
- var outText = this.fromNumber + (this.toNumber - this.fromNumber) * ratio;
9973
- (null === (_a = this.params) || void 0 === _a ? void 0 : _a.fixed) >= 0 && (outText = outText.toFixed(this.params.fixed)), out.text = outText;
9974
- }
9978
+ !1 !== this.valid && (out.text = end ? this.toNumber : (this.fromNumber + (this.toNumber - this.fromNumber) * ratio).toFixed(this.decimalLength));
9975
9979
  }
9976
9980
  }]);
9977
9981
  return IncreaseCount;
@@ -14481,7 +14485,7 @@
14481
14485
  return CanvasTextLayout;
14482
14486
  }();
14483
14487
 
14484
- var TEXT_UPDATE_TAG_KEY = ["text", "maxLineWidth", "fontSize", "fontFamily", "fontWeight", "ellipsis", "lineHeight", "direction", "wordBreak"].concat(_toConsumableArray(GRAPHIC_UPDATE_TAG_KEY));
14488
+ var TEXT_UPDATE_TAG_KEY = ["text", "maxLineWidth", "heightLimit", "lineClamp", "fontSize", "fontFamily", "fontWeight", "ellipsis", "lineHeight", "direction", "wordBreak"].concat(_toConsumableArray(GRAPHIC_UPDATE_TAG_KEY));
14485
14489
  var Text = /*#__PURE__*/function (_Graphic) {
14486
14490
  _inherits(Text, _Graphic);
14487
14491
  var _super = _createSuper(Text);
@@ -14555,6 +14559,118 @@
14555
14559
  paddingArray = parsePadding(boundsPadding);
14556
14560
  return paddingArray && bounds.expand(paddingArray), this.clearUpdateBoundTag(), bounds;
14557
14561
  }
14562
+ }, {
14563
+ key: "updateWrapAABBBounds",
14564
+ value: function updateWrapAABBBounds(text) {
14565
+ var _a, _b, _c;
14566
+ var textTheme = getTheme(this).text,
14567
+ _this$attribute = this.attribute,
14568
+ _this$attribute$fontF = _this$attribute.fontFamily,
14569
+ fontFamily = _this$attribute$fontF === void 0 ? textTheme.fontFamily : _this$attribute$fontF,
14570
+ _this$attribute$textA = _this$attribute.textAlign,
14571
+ textAlign = _this$attribute$textA === void 0 ? textTheme.textAlign : _this$attribute$textA,
14572
+ _this$attribute$textB = _this$attribute.textBaseline,
14573
+ textBaseline = _this$attribute$textB === void 0 ? textTheme.textBaseline : _this$attribute$textB,
14574
+ _this$attribute$fontS = _this$attribute.fontSize,
14575
+ fontSize = _this$attribute$fontS === void 0 ? textTheme.fontSize : _this$attribute$fontS,
14576
+ _this$attribute$lineH = _this$attribute.lineHeight,
14577
+ lineHeight = _this$attribute$lineH === void 0 ? this.attribute.lineHeight || this.attribute.fontSize || textTheme.fontSize : _this$attribute$lineH,
14578
+ _this$attribute$ellip = _this$attribute.ellipsis,
14579
+ ellipsis = _this$attribute$ellip === void 0 ? textTheme.ellipsis : _this$attribute$ellip,
14580
+ maxLineWidth = _this$attribute.maxLineWidth,
14581
+ _this$attribute$strok = _this$attribute.stroke,
14582
+ stroke = _this$attribute$strok === void 0 ? textTheme.stroke : _this$attribute$strok,
14583
+ _this$attribute$lineW = _this$attribute.lineWidth,
14584
+ lineWidth = _this$attribute$lineW === void 0 ? textTheme.lineWidth : _this$attribute$lineW,
14585
+ _this$attribute$wordB = _this$attribute.wordBreak,
14586
+ wordBreak = _this$attribute$wordB === void 0 ? textTheme.wordBreak : _this$attribute$wordB,
14587
+ _this$attribute$fontW = _this$attribute.fontWeight,
14588
+ fontWeight = _this$attribute$fontW === void 0 ? textTheme.fontWeight : _this$attribute$fontW,
14589
+ _this$attribute$ignor = _this$attribute.ignoreBuf,
14590
+ ignoreBuf = _this$attribute$ignor === void 0 ? textTheme.ignoreBuf : _this$attribute$ignor,
14591
+ _this$attribute$heigh = _this$attribute.heightLimit,
14592
+ heightLimit = _this$attribute$heigh === void 0 ? 0 : _this$attribute$heigh,
14593
+ lineClamp = _this$attribute.lineClamp,
14594
+ buf = ignoreBuf ? 0 : 2;
14595
+ if (!this.shouldUpdateShape() && (null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData)) {
14596
+ var _bbox = this.cache.layoutData.bbox;
14597
+ return this._AABBBounds.set(_bbox.xOffset, _bbox.yOffset, _bbox.xOffset + _bbox.width, _bbox.yOffset + _bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
14598
+ }
14599
+ var textMeasure = application.graphicUtil.textMeasure,
14600
+ layoutObj = new CanvasTextLayout(fontFamily, {
14601
+ fontSize: fontSize,
14602
+ fontWeight: fontWeight,
14603
+ fontFamily: fontFamily
14604
+ }, textMeasure),
14605
+ lines = isArray$1(text) ? text.map(function (l) {
14606
+ return l.toString();
14607
+ }) : [text.toString()],
14608
+ linesLayout = [],
14609
+ bboxWH = [0, 0];
14610
+ var lineCountLimit = 1 / 0;
14611
+ if (heightLimit > 0 && (lineCountLimit = Math.max(Math.floor(heightLimit / lineHeight), 1)), lineClamp && (lineCountLimit = Math.min(lineCountLimit, lineClamp)), "number" == typeof maxLineWidth && maxLineWidth !== 1 / 0) {
14612
+ if (maxLineWidth > 0) for (var i = 0; i < lines.length; i++) {
14613
+ var str = lines[i];
14614
+ var needCut = !0;
14615
+ if (i === lineCountLimit - 1) {
14616
+ var _clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1);
14617
+ linesLayout.push({
14618
+ str: _clip.str,
14619
+ width: _clip.width
14620
+ });
14621
+ break;
14622
+ }
14623
+ var clip = layoutObj.textMeasure.clipText(str, layoutObj.textOptions, maxLineWidth, "break-word" === wordBreak);
14624
+ if ("" !== str && "" === clip.str) {
14625
+ if (ellipsis) {
14626
+ var clipEllipsis = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1);
14627
+ clip.str = null !== (_b = clipEllipsis.str) && void 0 !== _b ? _b : "", clip.width = null !== (_c = clipEllipsis.width) && void 0 !== _c ? _c : 0;
14628
+ } else clip.str = "", clip.width = 0;
14629
+ needCut = !1;
14630
+ }
14631
+ if (linesLayout.push({
14632
+ str: clip.str,
14633
+ width: clip.width
14634
+ }), clip.str.length === str.length) ;else if (needCut) {
14635
+ var newStr = str.substring(clip.str.length);
14636
+ lines.splice(i + 1, 0, newStr);
14637
+ }
14638
+ }
14639
+ var maxWidth = 0;
14640
+ linesLayout.forEach(function (layout) {
14641
+ maxWidth = Math.max(maxWidth, layout.width);
14642
+ }), bboxWH[0] = maxWidth;
14643
+ } else {
14644
+ var width,
14645
+ _text,
14646
+ _lineWidth = 0;
14647
+ for (var _i = 0, len = lines.length; _i < len; _i++) {
14648
+ if (_i === lineCountLimit - 1) {
14649
+ var _clip2 = layoutObj.textMeasure.clipTextWithSuffix(lines[_i], layoutObj.textOptions, maxLineWidth, ellipsis, !1);
14650
+ linesLayout.push({
14651
+ str: _clip2.str,
14652
+ width: _clip2.width
14653
+ }), _lineWidth = Math.max(_lineWidth, _clip2.width);
14654
+ break;
14655
+ }
14656
+ _text = lines[_i], width = layoutObj.textMeasure.measureTextWidth(_text, layoutObj.textOptions, "break-word" === wordBreak), _lineWidth = Math.max(_lineWidth, width), linesLayout.push({
14657
+ str: _text,
14658
+ width: width
14659
+ });
14660
+ }
14661
+ bboxWH[0] = _lineWidth;
14662
+ }
14663
+ bboxWH[1] = linesLayout.length * (lineHeight + buf);
14664
+ var bbox = {
14665
+ xOffset: 0,
14666
+ yOffset: 0,
14667
+ width: bboxWH[0],
14668
+ height: bboxWH[1]
14669
+ };
14670
+ layoutObj.LayoutBBox(bbox, textAlign, textBaseline);
14671
+ var layoutData = layoutObj.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
14672
+ 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;
14673
+ }
14558
14674
  }, {
14559
14675
  key: "updateSingallineAABBBounds",
14560
14676
  value: function updateSingallineAABBBounds(text) {
@@ -14601,7 +14717,10 @@
14601
14717
  _attribute$wordBreak === void 0 ? textTheme.wordBreak : _attribute$wordBreak;
14602
14718
  var _attribute$ignoreBuf = attribute.ignoreBuf,
14603
14719
  ignoreBuf = _attribute$ignoreBuf === void 0 ? textTheme.ignoreBuf : _attribute$ignoreBuf,
14604
- buf = ignoreBuf ? 0 : Math.max(2, .075 * fontSize),
14720
+ _attribute$whiteSpace = attribute.whiteSpace,
14721
+ whiteSpace = _attribute$whiteSpace === void 0 ? textTheme.whiteSpace : _attribute$whiteSpace;
14722
+ if ("normal" === whiteSpace) return this.updateWrapAABBBounds(text);
14723
+ var buf = ignoreBuf ? 0 : Math.max(2, .075 * fontSize),
14605
14724
  _attribute$lineHeight = attribute.lineHeight,
14606
14725
  lineHeight = _attribute$lineHeight === void 0 ? null !== (_a = attribute.lineHeight) && void 0 !== _a ? _a : (attribute.fontSize || textTheme.fontSize) + buf : _attribute$lineHeight;
14607
14726
  if (!this.shouldUpdateShape() && this.cache) {
@@ -14750,11 +14869,12 @@
14750
14869
  stroke = _attribute$stroke3 === void 0 ? textTheme.stroke : _attribute$stroke3,
14751
14870
  _attribute$lineWidth3 = attribute.lineWidth,
14752
14871
  lineWidth = _attribute$lineWidth3 === void 0 ? textTheme.lineWidth : _attribute$lineWidth3,
14753
- _attribute$wordBreak2 = attribute.wordBreak;
14754
- _attribute$wordBreak2 === void 0 ? textTheme.wordBreak : _attribute$wordBreak2;
14872
+ _attribute$whiteSpace2 = attribute.whiteSpace,
14873
+ whiteSpace = _attribute$whiteSpace2 === void 0 ? textTheme.whiteSpace : _attribute$whiteSpace2;
14874
+ if ("normal" === whiteSpace) return this.updateWrapAABBBounds(text);
14755
14875
  if (!this.shouldUpdateShape() && (null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData)) {
14756
- var _bbox = this.cache.layoutData.bbox;
14757
- return this._AABBBounds.set(_bbox.xOffset, _bbox.yOffset, _bbox.xOffset + _bbox.width, _bbox.yOffset + _bbox.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
14876
+ var _bbox2 = this.cache.layoutData.bbox;
14877
+ return this._AABBBounds.set(_bbox2.xOffset, _bbox2.yOffset, _bbox2.xOffset + _bbox2.width, _bbox2.yOffset + _bbox2.height), stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
14758
14878
  }
14759
14879
  var textMeasure = application.graphicUtil.textMeasure,
14760
14880
  layoutData = new CanvasTextLayout(fontFamily, {
@@ -24841,6 +24961,11 @@
24841
24961
  get: function get() {
24842
24962
  return this.at(0);
24843
24963
  }
24964
+ }, {
24965
+ key: "preventRender",
24966
+ value: function preventRender(prevent) {
24967
+ prevent ? this._skipRender = -1 / 0 : this.params && this.params.optimize && !1 !== this.params.optimize.skipRenderWithOutRange ? this._skipRender = this.window.isVisible() ? 0 : 1 : this._skipRender = 0;
24968
+ }
24844
24969
  }, {
24845
24970
  key: "optmize",
24846
24971
  value: function optmize(params) {
@@ -24851,8 +24976,8 @@
24851
24976
  value: function optmizeRender() {
24852
24977
  var _this2 = this;
24853
24978
  var skipRenderWithOutRange = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !0;
24854
- skipRenderWithOutRange && (this._skipRender = this.window.isVisible() ? 0 : 1, this.window.onVisibleChange(function (visible) {
24855
- visible ? (_this2.dirtyBounds && _this2.dirtyBounds.setValue(0, 0, _this2._viewBox.width(), _this2._viewBox.height()), _this2._skipRender > 1 && _this2.renderNextFrame(), _this2._skipRender = 0) : _this2._skipRender = 1;
24979
+ skipRenderWithOutRange && (this._skipRender = this._skipRender < 0 ? this._skipRender : this.window.isVisible() ? 0 : 1, this.window.onVisibleChange(function (visible) {
24980
+ _this2._skipRender < 0 || (visible ? (_this2.dirtyBounds && _this2.dirtyBounds.setValue(0, 0, _this2._viewBox.width(), _this2._viewBox.height()), _this2._skipRender > 1 && _this2.renderNextFrame(), _this2._skipRender = 0) : _this2._skipRender = 1);
24856
24981
  }));
24857
24982
  }
24858
24983
  }, {
@@ -30240,7 +30365,7 @@
30240
30365
  }, {
30241
30366
  key: "getStaticCanvasCount",
30242
30367
  value: function getStaticCanvasCount() {
30243
- return 1;
30368
+ return 999;
30244
30369
  }
30245
30370
  }, {
30246
30371
  key: "loadJson",
@@ -33328,6 +33453,13 @@
33328
33453
  _context.globalAlpha = strokeOpacity * opacity, _context.lineWidth = getScaledStroke(this, lineWidth, this.dpr), _context.strokeStyle = createColor(this, stroke, params, offsetX, offsetY), _context.lineJoin = lineJoin, 0 === lineDash[0] && 0 === lineDash[1] || _context.setLineDash(lineDash), _context.lineCap = lineCap, _context.miterLimit = miterLimit;
33329
33454
  }
33330
33455
  }
33456
+ }, {
33457
+ key: "measureText",
33458
+ value: function measureText(text) {
33459
+ var method = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : application.global.measureTextMethod;
33460
+ this.setTransform(1, 0, 0, 1, 0, 0, !0, application.global.devicePixelRatio);
33461
+ return _get(_getPrototypeOf(LynxContext2d.prototype), "measureText", this).call(this, text, method);
33462
+ }
33331
33463
  }, {
33332
33464
  key: "createPattern",
33333
33465
  value: function createPattern(image, repetition) {
@@ -34494,7 +34626,7 @@
34494
34626
 
34495
34627
  var roughModule = _roughModule;
34496
34628
 
34497
- const version = "0.16.12-alpha.2";
34629
+ const version = "0.16.13";
34498
34630
  loadAllModule(container);
34499
34631
 
34500
34632
  exports.ACustomAnimate = ACustomAnimate;