zrender-nightly 5.5.0-dev.20240131 → 5.5.1-dev.20240131

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 (61) hide show
  1. package/README.md +1 -1
  2. package/build/package.json +3 -0
  3. package/dist/package.json +3 -0
  4. package/dist/zrender.js +218 -27
  5. package/dist/zrender.js.map +1 -1
  6. package/dist/zrender.min.js +1 -1
  7. package/lib/Element.d.ts +1 -0
  8. package/lib/Element.js +12 -0
  9. package/lib/Handler.js +3 -3
  10. package/lib/canvas/Layer.d.ts +0 -1
  11. package/lib/canvas/Layer.js +2 -2
  12. package/lib/canvas/Painter.js +1 -1
  13. package/lib/core/PathProxy.js +0 -1
  14. package/lib/core/Transformable.js +5 -1
  15. package/lib/core/env.js +2 -1
  16. package/lib/core/matrix.d.ts +1 -1
  17. package/lib/core/matrix.js +4 -3
  18. package/lib/core/timsort.js +0 -9
  19. package/lib/graphic/helper/parseText.d.ts +1 -1
  20. package/lib/svg/Painter.d.ts +2 -0
  21. package/lib/svg/Painter.js +3 -2
  22. package/lib/svg/core.d.ts +3 -1
  23. package/lib/svg/core.js +2 -1
  24. package/lib/svg/cssAnimation.js +2 -1
  25. package/lib/svg/cssClassId.d.ts +1 -0
  26. package/lib/svg/cssClassId.js +4 -0
  27. package/lib/svg/cssEmphasis.d.ts +3 -0
  28. package/lib/svg/cssEmphasis.js +60 -0
  29. package/lib/svg/graphic.js +21 -1
  30. package/lib/svg/patch.js +4 -1
  31. package/lib/tool/color.d.ts +3 -0
  32. package/lib/tool/color.js +21 -0
  33. package/lib/tool/parseSVG.js +4 -1
  34. package/lib/zrender.d.ts +10 -4
  35. package/lib/zrender.js +69 -6
  36. package/package.README.md +9 -0
  37. package/package.json +29 -2
  38. package/src/.eslintrc.yaml +1 -1
  39. package/src/Element.ts +16 -0
  40. package/src/Handler.ts +3 -3
  41. package/src/canvas/Layer.ts +2 -5
  42. package/src/canvas/Painter.ts +2 -2
  43. package/src/core/PathProxy.ts +0 -2
  44. package/src/core/Transformable.ts +6 -1
  45. package/src/core/env.ts +4 -1
  46. package/src/core/matrix.ts +8 -3
  47. package/src/core/timsort.ts +0 -13
  48. package/src/core/util.ts +4 -4
  49. package/src/dom/HandlerProxy.ts +7 -7
  50. package/src/graphic/helper/parseText.ts +4 -4
  51. package/src/svg/Painter.ts +13 -6
  52. package/src/svg/core.ts +10 -2
  53. package/src/svg/cssAnimation.ts +2 -1
  54. package/src/svg/cssClassId.ts +5 -0
  55. package/src/svg/cssEmphasis.ts +73 -0
  56. package/src/svg/graphic.ts +23 -1
  57. package/src/svg/patch.ts +5 -2
  58. package/src/tool/color.ts +27 -1
  59. package/src/tool/parseSVG.ts +4 -1
  60. package/src/zrender.ts +82 -11
  61. package/.travis.yml +0 -12
package/lib/Element.d.ts CHANGED
@@ -166,6 +166,7 @@ declare class Element<Props extends ElementProps = ElementProps> {
166
166
  clearStates(noAnimation?: boolean): void;
167
167
  useState(stateName: string, keepCurrentStates?: boolean, noAnimation?: boolean, forceUseHoverLayer?: boolean): ElementState;
168
168
  useStates(states: string[], noAnimation?: boolean, forceUseHoverLayer?: boolean): void;
169
+ isSilent(): boolean;
169
170
  private _updateAnimationTargets;
170
171
  removeState(state: string): void;
171
172
  replaceState(oldState: string, newState: string, forceAdd: boolean): void;
package/lib/Element.js CHANGED
@@ -400,6 +400,18 @@ var Element = (function () {
400
400
  }
401
401
  }
402
402
  };
403
+ Element.prototype.isSilent = function () {
404
+ var isSilent = this.silent;
405
+ var ancestor = this.parent;
406
+ while (!isSilent && ancestor) {
407
+ if (ancestor.silent) {
408
+ isSilent = true;
409
+ break;
410
+ }
411
+ ancestor = ancestor.parent;
412
+ }
413
+ return isSilent;
414
+ };
403
415
  Element.prototype._updateAnimationTargets = function () {
404
416
  for (var i = 0; i < this.animators.length; i++) {
405
417
  var animator = this.animators[i];
package/lib/Handler.js CHANGED
@@ -262,9 +262,9 @@ function isHover(displayable, x, y) {
262
262
  if (clipPath && !clipPath.contain(x, y)) {
263
263
  return false;
264
264
  }
265
- if (el.silent) {
266
- isSilent = true;
267
- }
265
+ }
266
+ if (el.silent) {
267
+ isSilent = true;
268
268
  }
269
269
  var hostEl = el.__hostTarget;
270
270
  el = hostEl ? hostEl : el.parent;
@@ -27,7 +27,6 @@ export default class Layer extends Eventful {
27
27
  zlevel: number;
28
28
  maxRepaintRectCount: number;
29
29
  private _paintRects;
30
- __painter: CanvasPainter;
31
30
  __dirty: boolean;
32
31
  __firstTimePaint: boolean;
33
32
  __used: boolean;
@@ -169,7 +169,7 @@ var Layer = (function (_super) {
169
169
  }
170
170
  for (var i = this.__prevStartIndex; i < this.__prevEndIndex; ++i) {
171
171
  var el = prevList[i];
172
- var shouldPaint = el.shouldBePainted(viewWidth, viewHeight, true, true);
172
+ var shouldPaint = el && el.shouldBePainted(viewWidth, viewHeight, true, true);
173
173
  if (el && (!shouldPaint || !el.__zr) && el.__isRendered) {
174
174
  var prevRect = el.getPrevPaintRect();
175
175
  if (prevRect) {
@@ -266,7 +266,7 @@ var Layer = (function (_super) {
266
266
  clearColorGradientOrPattern = createCanvasPattern(ctx, clearColor, {
267
267
  dirty: function () {
268
268
  self.setUnpainted();
269
- self.__painter.refresh();
269
+ self.painter.refresh();
270
270
  }
271
271
  });
272
272
  }
@@ -393,7 +393,7 @@ var CanvasPainter = (function () {
393
393
  }
394
394
  }
395
395
  }
396
- layer.__painter = this;
396
+ layer.painter || (layer.painter = this);
397
397
  };
398
398
  CanvasPainter.prototype.eachLayer = function (cb, context) {
399
399
  var zlevelList = this._zlevelList;
@@ -434,7 +434,6 @@ var PathProxy = (function () {
434
434
  var delta = data[i++];
435
435
  var endAngle = delta + startAngle;
436
436
  i += 1;
437
- var anticlockwise = !data[i++];
438
437
  if (isFirst) {
439
438
  x0 = mathCos(startAngle) * rx + cx;
440
439
  y0 = mathSin(startAngle) * ry + cy;
@@ -45,7 +45,10 @@ var Transformable = (function () {
45
45
  var needLocalTransform = this.needLocalTransform();
46
46
  var m = this.transform;
47
47
  if (!(needLocalTransform || parentTransform)) {
48
- m && mIdentity(m);
48
+ if (m) {
49
+ mIdentity(m);
50
+ this.invTransform = null;
51
+ }
49
52
  return;
50
53
  }
51
54
  m = m || matrix.create();
@@ -121,6 +124,7 @@ var Transformable = (function () {
121
124
  var parent = this.parent;
122
125
  var m = this.transform;
123
126
  if (parent && parent.transform) {
127
+ parent.invTransform = parent.invTransform || matrix.create();
124
128
  matrix.mul(tmpTransform, parent.invTransform, m);
125
129
  m = tmpTransform;
126
130
  }
package/lib/core/env.js CHANGED
@@ -32,7 +32,8 @@ if (typeof wx === 'object' && typeof wx.getSystemInfoSync === 'function') {
32
32
  else if (typeof document === 'undefined' && typeof self !== 'undefined') {
33
33
  env.worker = true;
34
34
  }
35
- else if (typeof navigator === 'undefined') {
35
+ else if (typeof navigator === 'undefined'
36
+ || navigator.userAgent.indexOf('Node.js') === 0) {
36
37
  env.node = true;
37
38
  env.svgSupported = true;
38
39
  }
@@ -5,7 +5,7 @@ export declare function identity(out: MatrixArray): MatrixArray;
5
5
  export declare function copy(out: MatrixArray, m: MatrixArray): MatrixArray;
6
6
  export declare function mul(out: MatrixArray, m1: MatrixArray, m2: MatrixArray): MatrixArray;
7
7
  export declare function translate(out: MatrixArray, a: MatrixArray, v: VectorArray): MatrixArray;
8
- export declare function rotate(out: MatrixArray, a: MatrixArray, rad: number): MatrixArray;
8
+ export declare function rotate(out: MatrixArray, a: MatrixArray, rad: number, pivot?: VectorArray): MatrixArray;
9
9
  export declare function scale(out: MatrixArray, a: MatrixArray, v: VectorArray): MatrixArray;
10
10
  export declare function invert(out: MatrixArray, a: MatrixArray): MatrixArray | null;
11
11
  export declare function clone(a: MatrixArray): MatrixArray;
@@ -43,7 +43,8 @@ export function translate(out, a, v) {
43
43
  out[5] = a[5] + v[1];
44
44
  return out;
45
45
  }
46
- export function rotate(out, a, rad) {
46
+ export function rotate(out, a, rad, pivot) {
47
+ if (pivot === void 0) { pivot = [0, 0]; }
47
48
  var aa = a[0];
48
49
  var ac = a[2];
49
50
  var atx = a[4];
@@ -56,8 +57,8 @@ export function rotate(out, a, rad) {
56
57
  out[1] = -aa * st + ab * ct;
57
58
  out[2] = ac * ct + ad * st;
58
59
  out[3] = -ac * st + ct * ad;
59
- out[4] = ct * atx + st * aty;
60
- out[5] = ct * aty - st * atx;
60
+ out[4] = ct * (atx - pivot[0]) + st * (aty - pivot[1]) + pivot[0];
61
+ out[5] = ct * (aty - pivot[1]) - st * (atx - pivot[0]) + pivot[1];
61
62
  return out;
62
63
  }
63
64
  export function scale(out, a, v) {
@@ -1,6 +1,5 @@
1
1
  var DEFAULT_MIN_MERGE = 32;
2
2
  var DEFAULT_MIN_GALLOPING = 7;
3
- var DEFAULT_TMP_STORAGE_LENGTH = 256;
4
3
  function minRunLength(n) {
5
4
  var r = 0;
6
5
  while (n >= DEFAULT_MIN_MERGE) {
@@ -167,18 +166,10 @@ function gallopRight(value, array, start, length, hint, compare) {
167
166
  }
168
167
  function TimSort(array, compare) {
169
168
  var minGallop = DEFAULT_MIN_GALLOPING;
170
- var length = 0;
171
- var tmpStorageLength = DEFAULT_TMP_STORAGE_LENGTH;
172
- var stackLength = 0;
173
169
  var runStart;
174
170
  var runLength;
175
171
  var stackSize = 0;
176
- length = array.length;
177
- if (length < 2 * DEFAULT_TMP_STORAGE_LENGTH) {
178
- tmpStorageLength = length >>> 1;
179
- }
180
172
  var tmp = [];
181
- stackLength = length < 120 ? 5 : length < 1542 ? 10 : length < 119151 ? 19 : 40;
182
173
  runStart = [];
183
174
  runLength = [];
184
175
  function pushRun(_runStart, _runLength) {
@@ -6,7 +6,7 @@ interface InnerTruncateOption {
6
6
  placeholder?: string;
7
7
  maxIterations?: number;
8
8
  }
9
- export declare function truncateText(text: string, containerWidth: number, font: string, ellipsis: string, options: InnerTruncateOption): string;
9
+ export declare function truncateText(text: string, containerWidth: number, font: string, ellipsis?: string, options?: InnerTruncateOption): string;
10
10
  export interface PlainTextContentBlock {
11
11
  lineHeight: number;
12
12
  calculatedLineHeight: number;
@@ -39,9 +39,11 @@ declare class SVGPainter implements PainterBase {
39
39
  willUpdate?: boolean;
40
40
  compress?: boolean;
41
41
  useViewBox?: boolean;
42
+ emphasis?: boolean;
42
43
  }): SVGVNode;
43
44
  renderToString(opts?: {
44
45
  cssAnimation?: boolean;
46
+ cssEmphasis?: boolean;
45
47
  useViewBox?: boolean;
46
48
  }): string;
47
49
  setBackgroundColor(backgroundColor: SVGPainterBackgroundColor): void;
@@ -65,6 +65,7 @@ var SVGPainter = (function () {
65
65
  scope.animation = opts.animation;
66
66
  scope.willUpdate = opts.willUpdate;
67
67
  scope.compress = opts.compress;
68
+ scope.emphasis = opts.emphasis;
68
69
  var children = [];
69
70
  var bgVNode = this._bgVNode = createBackgroundVNode(width, height, this._backgroundColor, scope);
70
71
  bgVNode && children.push(bgVNode);
@@ -89,6 +90,7 @@ var SVGPainter = (function () {
89
90
  opts = opts || {};
90
91
  return vNodeToString(this.renderToVNode({
91
92
  animation: retrieve2(opts.cssAnimation, true),
93
+ emphasis: retrieve2(opts.cssEmphasis, true),
92
94
  willUpdate: false,
93
95
  compress: true,
94
96
  useViewBox: retrieve2(opts.useViewBox, true)
@@ -225,8 +227,7 @@ function createBackgroundVNode(width, height, backgroundColor, scope) {
225
227
  width: width,
226
228
  height: height,
227
229
  x: '0',
228
- y: '0',
229
- id: '0'
230
+ y: '0'
230
231
  });
231
232
  if (isGradient(backgroundColor)) {
232
233
  setGradient({ fill: backgroundColor }, bgVNode.attrs, 'fill', scope);
package/lib/svg/core.d.ts CHANGED
@@ -4,6 +4,7 @@ export declare const SVGNS = "http://www.w3.org/2000/svg";
4
4
  export declare const XLINKNS = "http://www.w3.org/1999/xlink";
5
5
  export declare const XMLNS = "http://www.w3.org/2000/xmlns/";
6
6
  export declare const XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace";
7
+ export declare const META_DATA_PREFIX = "ecmeta_";
7
8
  export declare function createElement(name: string): SVGElement;
8
9
  export declare type SVGVNodeAttrs = Record<string, string | number | undefined | boolean>;
9
10
  export interface SVGVNode {
@@ -30,13 +31,14 @@ export interface BrushScope {
30
31
  defs: Record<string, SVGVNode>;
31
32
  cssNodes: Record<string, CSSSelectorVNode>;
32
33
  cssAnims: Record<string, Record<string, Record<string, string>>>;
33
- cssClassIdx: number;
34
+ cssStyleCache: Record<string, string>;
34
35
  cssAnimIdx: number;
35
36
  shadowIdx: number;
36
37
  gradientIdx: number;
37
38
  patternIdx: number;
38
39
  clipPathIdx: number;
39
40
  animation?: boolean;
41
+ emphasis?: boolean;
40
42
  willUpdate?: boolean;
41
43
  compress?: boolean;
42
44
  }
package/lib/svg/core.js CHANGED
@@ -4,6 +4,7 @@ export var SVGNS = 'http://www.w3.org/2000/svg';
4
4
  export var XLINKNS = 'http://www.w3.org/1999/xlink';
5
5
  export var XMLNS = 'http://www.w3.org/2000/xmlns/';
6
6
  export var XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
7
+ export var META_DATA_PREFIX = 'ecmeta_';
7
8
  export function createElement(name) {
8
9
  return document.createElementNS(SVGNS, name);
9
10
  }
@@ -85,7 +86,7 @@ export function createBrushScope(zrId) {
85
86
  defs: {},
86
87
  cssNodes: {},
87
88
  cssAnims: {},
88
- cssClassIdx: 0,
89
+ cssStyleCache: {},
89
90
  cssAnimIdx: 0,
90
91
  shadowIdx: 0,
91
92
  gradientIdx: 0,
@@ -6,6 +6,7 @@ import { getPathPrecision, getSRTTransformString } from './helper.js';
6
6
  import { each, extend, filter, isNumber, isString, keys } from '../core/util.js';
7
7
  import CompoundPath from '../graphic/CompoundPath.js';
8
8
  import { createCubicEasingFunc } from '../animation/cubicEasing.js';
9
+ import { getClassId } from './cssClassId.js';
9
10
  export var EASING_MAP = {
10
11
  cubicIn: '0.32,0,0.67,0',
11
12
  cubicOut: '0.33,1,0.68,1',
@@ -266,7 +267,7 @@ export function createCSSAnimation(el, attrs, scope, onlyShape) {
266
267
  }
267
268
  }
268
269
  if (cssAnimations.length) {
269
- var className = scope.zrId + '-cls-' + scope.cssClassIdx++;
270
+ var className = scope.zrId + '-cls-' + getClassId();
270
271
  scope.cssNodes['.' + className] = {
271
272
  animation: cssAnimations.join(',')
272
273
  };
@@ -0,0 +1 @@
1
+ export declare function getClassId(): number;
@@ -0,0 +1,4 @@
1
+ var cssClassIdx = 0;
2
+ export function getClassId() {
3
+ return cssClassIdx++;
4
+ }
@@ -0,0 +1,3 @@
1
+ import Displayable from '../graphic/Displayable';
2
+ import { BrushScope, SVGVNodeAttrs } from './core';
3
+ export declare function createCSSEmphasis(el: Displayable, attrs: SVGVNodeAttrs, scope: BrushScope): void;
@@ -0,0 +1,60 @@
1
+ import { liftColor } from '../tool/color.js';
2
+ import { getClassId } from './cssClassId.js';
3
+ export function createCSSEmphasis(el, attrs, scope) {
4
+ if (!el.ignore) {
5
+ if (el.isSilent()) {
6
+ var style = {
7
+ 'pointer-events': 'none'
8
+ };
9
+ setClassAttribute(style, attrs, scope, true);
10
+ }
11
+ else {
12
+ var emphasisStyle = el.states.emphasis && el.states.emphasis.style
13
+ ? el.states.emphasis.style
14
+ : {};
15
+ var fill = emphasisStyle.fill;
16
+ if (!fill) {
17
+ var normalFill = el.style && el.style.fill;
18
+ var selectFill = el.states.select
19
+ && el.states.select.style
20
+ && el.states.select.style.fill;
21
+ var fromFill = el.currentStates.indexOf('select') >= 0
22
+ ? (selectFill || normalFill)
23
+ : normalFill;
24
+ if (fromFill) {
25
+ fill = liftColor(fromFill);
26
+ }
27
+ }
28
+ var lineWidth = emphasisStyle.lineWidth;
29
+ if (lineWidth) {
30
+ var scaleX = (!emphasisStyle.strokeNoScale && el.transform)
31
+ ? el.transform[0]
32
+ : 1;
33
+ lineWidth = lineWidth / scaleX;
34
+ }
35
+ var style = {
36
+ cursor: 'pointer'
37
+ };
38
+ if (fill) {
39
+ style.fill = fill;
40
+ }
41
+ if (emphasisStyle.stroke) {
42
+ style.stroke = emphasisStyle.stroke;
43
+ }
44
+ if (lineWidth) {
45
+ style['stroke-width'] = lineWidth;
46
+ }
47
+ setClassAttribute(style, attrs, scope, true);
48
+ }
49
+ }
50
+ }
51
+ function setClassAttribute(style, attrs, scope, withHover) {
52
+ var styleKey = JSON.stringify(style);
53
+ var className = scope.cssStyleCache[styleKey];
54
+ if (!className) {
55
+ className = scope.zrId + '-cls-' + getClassId();
56
+ scope.cssStyleCache[styleKey] = className;
57
+ scope.cssNodes['.' + className + (withHover ? ':hover' : '')] = style;
58
+ }
59
+ attrs["class"] = attrs["class"] ? (attrs["class"] + ' ' + className) : className;
60
+ }
@@ -5,12 +5,14 @@ import { getLineHeight } from '../contain/text.js';
5
5
  import TSpan from '../graphic/TSpan.js';
6
6
  import SVGPathRebuilder from './SVGPathRebuilder.js';
7
7
  import mapStyleToAttrs from './mapStyleToAttrs.js';
8
- import { createVNode, vNodeToString } from './core.js';
8
+ import { createVNode, vNodeToString, META_DATA_PREFIX } from './core.js';
9
9
  import { assert, clone, isFunction, isString, logError, map, retrieve2 } from '../core/util.js';
10
10
  import { createOrUpdateImage } from '../graphic/helper/image.js';
11
11
  import { createCSSAnimation } from './cssAnimation.js';
12
12
  import { hasSeparateFont, parseFontSize } from '../graphic/Text.js';
13
13
  import { DEFAULT_FONT, DEFAULT_FONT_FAMILY } from '../core/platform.js';
14
+ import { createCSSEmphasis } from './cssEmphasis.js';
15
+ import { getElementSSRData } from '../zrender.js';
14
16
  var round = Math.round;
15
17
  function isImageLike(val) {
16
18
  return val && isString(val.src);
@@ -27,12 +29,26 @@ function setStyleAttrs(attrs, style, el, scope) {
27
29
  else if (isFillStroke && isPattern(val)) {
28
30
  setPattern(el, attrs, key, scope);
29
31
  }
32
+ else if (isFillStroke && val === 'none') {
33
+ attrs[key] = 'transparent';
34
+ }
30
35
  else {
31
36
  attrs[key] = val;
32
37
  }
33
38
  }, style, el, false);
34
39
  setShadow(el, attrs, scope);
35
40
  }
41
+ function setMetaData(attrs, el) {
42
+ var metaData = getElementSSRData(el);
43
+ if (metaData) {
44
+ metaData.each(function (val, key) {
45
+ val != null && (attrs[(META_DATA_PREFIX + key).toLowerCase()] = val + '');
46
+ });
47
+ if (el.isSilent()) {
48
+ attrs[META_DATA_PREFIX + 'silent'] = 'true';
49
+ }
50
+ }
51
+ }
36
52
  function noRotateScale(m) {
37
53
  return isAroundZero(m[0] - 1)
38
54
  && isAroundZero(m[1])
@@ -137,7 +153,9 @@ export function brushSVGPath(el, scope) {
137
153
  }
138
154
  setTransform(attrs, el.transform);
139
155
  setStyleAttrs(attrs, style, el, scope);
156
+ setMetaData(attrs, el);
140
157
  scope.animation && createCSSAnimation(el, attrs, scope);
158
+ scope.emphasis && createCSSEmphasis(el, attrs, scope);
141
159
  return createVNode(svgElType, el.id + '', attrs);
142
160
  }
143
161
  export function brushSVGImage(el, scope) {
@@ -171,6 +189,7 @@ export function brushSVGImage(el, scope) {
171
189
  }
172
190
  setTransform(attrs, el.transform);
173
191
  setStyleAttrs(attrs, style, el, scope);
192
+ setMetaData(attrs, el);
174
193
  scope.animation && createCSSAnimation(el, attrs, scope);
175
194
  return createVNode('image', el.id + '', attrs);
176
195
  }
@@ -223,6 +242,7 @@ export function brushSVGTSpan(el, scope) {
223
242
  }
224
243
  setTransform(attrs, el.transform);
225
244
  setStyleAttrs(attrs, style, el, scope);
245
+ setMetaData(attrs, el);
226
246
  scope.animation && createCSSAnimation(el, attrs, scope);
227
247
  return createVNode('text', el.id + '', attrs, undefined, text);
228
248
  }
package/lib/svg/patch.js CHANGED
@@ -95,7 +95,10 @@ export function updateAttrs(oldVnode, vnode) {
95
95
  elm.removeAttribute(key);
96
96
  }
97
97
  else {
98
- if (key.charCodeAt(0) !== xChar) {
98
+ if (key === 'style') {
99
+ elm.style.cssText = cur;
100
+ }
101
+ else if (key.charCodeAt(0) !== xChar) {
99
102
  elm.setAttribute(key, cur);
100
103
  }
101
104
  else if (key === 'xmlns:xlink' || key === 'xmlns') {
@@ -1,3 +1,4 @@
1
+ import { GradientObject } from '../graphic/Gradient';
1
2
  export declare function parse(colorStr: string, rgbaArr?: number[]): number[];
2
3
  export declare function lift(color: string, level: number): string;
3
4
  export declare function toHex(color: string): string;
@@ -17,4 +18,6 @@ export declare function modifyAlpha(color: string, alpha?: number): string;
17
18
  export declare function stringify(arrColor: number[], type: string): string;
18
19
  export declare function lum(color: string, backgroundLum: number): number;
19
20
  export declare function random(): string;
21
+ export declare function liftColor(color: GradientObject): GradientObject;
22
+ export declare function liftColor(color: string): string;
20
23
  export {};
package/lib/tool/color.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import LRU from '../core/LRU.js';
2
+ import { extend, isGradientObject, isString, map } from '../core/util.js';
2
3
  var kCSSColorTable = {
3
4
  'transparent': [0, 0, 0, 0], 'aliceblue': [240, 248, 255, 1],
4
5
  'antiquewhite': [250, 235, 215, 1], 'aqua': [0, 255, 255, 1],
@@ -406,3 +407,23 @@ export function random() {
406
407
  Math.round(Math.random() * 255)
407
408
  ], 'rgb');
408
409
  }
410
+ var liftedColorCache = new LRU(100);
411
+ export function liftColor(color) {
412
+ if (isString(color)) {
413
+ var liftedColor = liftedColorCache.get(color);
414
+ if (!liftedColor) {
415
+ liftedColor = lift(color, -0.1);
416
+ liftedColorCache.put(color, liftedColor);
417
+ }
418
+ return liftedColor;
419
+ }
420
+ else if (isGradientObject(color)) {
421
+ var ret = extend({}, color);
422
+ ret.colorStops = map(color.colorStops, function (stop) { return ({
423
+ offset: stop.offset,
424
+ color: lift(stop.color, -0.1)
425
+ }); });
426
+ return ret;
427
+ }
428
+ return color;
429
+ }
@@ -554,7 +554,10 @@ function parseTransformAttribute(xmlNode, node) {
554
554
  matrix.scale(mt, mt, [parseFloat(valueArr[0]), parseFloat(valueArr[1] || valueArr[0])]);
555
555
  break;
556
556
  case 'rotate':
557
- matrix.rotate(mt, mt, -parseFloat(valueArr[0]) * DEGREE_TO_ANGLE);
557
+ matrix.rotate(mt, mt, -parseFloat(valueArr[0]) * DEGREE_TO_ANGLE, [
558
+ parseFloat(valueArr[1] || '0'),
559
+ parseFloat(valueArr[2] || '0')
560
+ ]);
558
561
  break;
559
562
  case 'skewX':
560
563
  var sx = Math.tan(parseFloat(valueArr[0]) * DEGREE_TO_ANGLE);
package/lib/zrender.d.ts CHANGED
@@ -7,6 +7,7 @@
7
7
  * LICENSE
8
8
  * https://github.com/ecomfe/zrender/blob/master/LICENSE.txt
9
9
  */
10
+ import * as zrUtil from './core/util';
10
11
  import Handler from './Handler';
11
12
  import Storage from './Storage';
12
13
  import { PainterBase } from './PainterBase';
@@ -32,6 +33,7 @@ declare class ZRender {
32
33
  private _stillFrameAccum;
33
34
  private _needsRefresh;
34
35
  private _needsRefreshHover;
36
+ private _disposed;
35
37
  private _darkMode;
36
38
  private _backgroundColor;
37
39
  constructor(id: number, dom?: HTMLElement, opts?: ZRenderInitOpt);
@@ -55,13 +57,13 @@ declare class ZRender {
55
57
  height?: number | string;
56
58
  }): void;
57
59
  clearAnimation(): void;
58
- getWidth(): number;
59
- getHeight(): number;
60
+ getWidth(): number | undefined;
61
+ getHeight(): number | undefined;
60
62
  setCursorStyle(cursorStyle: string): void;
61
63
  findHover(x: number, y: number): {
62
64
  target: Displayable;
63
65
  topTarget: Displayable;
64
- };
66
+ } | undefined;
65
67
  on<Ctx>(eventName: ElementEventName, eventHandler: ElementEventCallback<Ctx, ZRenderType>, context?: Ctx): this;
66
68
  on<Ctx>(eventName: string, eventHandler: WithThisType<EventCallback<any[]>, unknown extends Ctx ? ZRenderType : Ctx>, context?: Ctx): this;
67
69
  off(eventName?: string, eventHandler?: EventCallback): void;
@@ -84,7 +86,11 @@ export declare function dispose(zr: ZRender): void;
84
86
  export declare function disposeAll(): void;
85
87
  export declare function getInstance(id: number): ZRender;
86
88
  export declare function registerPainter(name: string, Ctor: PainterBaseCtor): void;
87
- export declare const version = "5.5.0-dev.20240131";
89
+ export declare type ElementSSRData = zrUtil.HashMap<unknown>;
90
+ export declare type ElementSSRDataGetter<T> = (el: Element) => zrUtil.HashMap<T>;
91
+ export declare function getElementSSRData(el: Element): ElementSSRData;
92
+ export declare function registerSSRDataGetter<T>(getter: ElementSSRDataGetter<T>): void;
93
+ export declare const version = "5.5.1-dev.20240131";
88
94
  export interface ZRenderType extends ZRender {
89
95
  }
90
96
  export {};