zrender-nightly 5.5.0-dev.20221018 → 5.5.0-dev.20221019
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/build/prepareNightly.js +12 -2
- package/dist/zrender.js +103 -43
- package/dist/zrender.js.map +1 -1
- package/dist/zrender.min.js +1 -1
- package/lib/canvas/Layer.js +6 -1
- package/lib/graphic/Gradient.d.ts +2 -0
- package/lib/svg/Painter.d.ts +4 -1
- package/lib/svg/Painter.js +51 -34
- package/lib/svg/graphic.d.ts +3 -1
- package/lib/svg/graphic.js +49 -11
- package/lib/svg/helper.js +1 -1
- package/lib/zrender.d.ts +1 -1
- package/lib/zrender.js +1 -1
- package/package.json +2 -2
- package/src/canvas/Layer.ts +9 -1
- package/src/graphic/Gradient.ts +2 -0
- package/src/svg/Painter.ts +72 -41
- package/src/svg/graphic.ts +53 -13
- package/src/svg/helper.ts +1 -1
- package/src/zrender.ts +1 -1
package/build/prepareNightly.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
|
+
const { execSync } = require('child_process');
|
|
3
|
+
|
|
2
4
|
const packageJsonPath = __dirname + '/../package.json';
|
|
3
5
|
const nightlyPackageName = 'zrender-nightly';
|
|
4
6
|
|
|
@@ -33,6 +35,14 @@ function updateVersion(version) {
|
|
|
33
35
|
|
|
34
36
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
35
37
|
packageJson.name = nightlyPackageName;
|
|
36
|
-
|
|
38
|
+
const version = updateVersion(packageJson.version);
|
|
39
|
+
|
|
40
|
+
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf-8');
|
|
41
|
+
|
|
42
|
+
// Update version in package.json and package-lock.json
|
|
43
|
+
execSync(`npm version ${version} --git-tag-version=false`);
|
|
37
44
|
|
|
38
|
-
|
|
45
|
+
const entryPath = __dirname + '/../src/zrender.ts';
|
|
46
|
+
const entryFile = fs.readFileSync(entryPath, 'utf-8')
|
|
47
|
+
.replace(/export const version = '\S+'/, `export const version = '${version}'`);
|
|
48
|
+
fs.writeFileSync(entryPath, entryFile, 'utf-8');
|
package/dist/zrender.js
CHANGED
|
@@ -4149,7 +4149,7 @@
|
|
|
4149
4149
|
var encodeBase64 = (function () {
|
|
4150
4150
|
if (env.hasGlobalWindow && isFunction(window.btoa)) {
|
|
4151
4151
|
return function (str) {
|
|
4152
|
-
return window.btoa(unescape(str));
|
|
4152
|
+
return window.btoa(unescape(encodeURIComponent(str)));
|
|
4153
4153
|
};
|
|
4154
4154
|
}
|
|
4155
4155
|
if (typeof Buffer !== 'undefined') {
|
|
@@ -7196,7 +7196,7 @@
|
|
|
7196
7196
|
function registerPainter(name, Ctor) {
|
|
7197
7197
|
painterCtors[name] = Ctor;
|
|
7198
7198
|
}
|
|
7199
|
-
var version = '5.
|
|
7199
|
+
var version = '5.5.0-dev.20221019';
|
|
7200
7200
|
|
|
7201
7201
|
var STYLE_MAGIC_KEY = '__zr_style_' + Math.round((Math.random() * 10));
|
|
7202
7202
|
var DEFAULT_COMMON_STYLE = {
|
|
@@ -14959,7 +14959,10 @@
|
|
|
14959
14959
|
if (clearColor && clearColor !== 'transparent') {
|
|
14960
14960
|
var clearColorGradientOrPattern = void 0;
|
|
14961
14961
|
if (isGradientObject(clearColor)) {
|
|
14962
|
-
|
|
14962
|
+
var shouldCache = clearColor.global || (clearColor.__width === width
|
|
14963
|
+
&& clearColor.__height === height);
|
|
14964
|
+
clearColorGradientOrPattern = shouldCache
|
|
14965
|
+
&& clearColor.__canvasGradient
|
|
14963
14966
|
|| getCanvasGradient(ctx, clearColor, {
|
|
14964
14967
|
x: 0,
|
|
14965
14968
|
y: 0,
|
|
@@ -14967,6 +14970,8 @@
|
|
|
14967
14970
|
height: height
|
|
14968
14971
|
});
|
|
14969
14972
|
clearColor.__canvasGradient = clearColorGradientOrPattern;
|
|
14973
|
+
clearColor.__width = width;
|
|
14974
|
+
clearColor.__height = height;
|
|
14970
14975
|
}
|
|
14971
14976
|
else if (isImagePatternObject(clearColor)) {
|
|
14972
14977
|
clearColor.scaleX = clearColor.scaleX || dpr;
|
|
@@ -16247,7 +16252,7 @@
|
|
|
16247
16252
|
}
|
|
16248
16253
|
};
|
|
16249
16254
|
}
|
|
16250
|
-
var
|
|
16255
|
+
var builtinShapesDef = {
|
|
16251
16256
|
circle: [createAttrsConvert(['cx', 'cy', 'r'])],
|
|
16252
16257
|
polyline: [convertPolyShape, validatePolyShape],
|
|
16253
16258
|
polygon: [convertPolyShape, validatePolyShape]
|
|
@@ -16264,7 +16269,7 @@
|
|
|
16264
16269
|
function brushSVGPath(el, scope) {
|
|
16265
16270
|
var style = el.style;
|
|
16266
16271
|
var shape = el.shape;
|
|
16267
|
-
var builtinShpDef =
|
|
16272
|
+
var builtinShpDef = builtinShapesDef[el.type];
|
|
16268
16273
|
var attrs = {};
|
|
16269
16274
|
var needsAnimate = scope.animation;
|
|
16270
16275
|
var svgElType = 'path';
|
|
@@ -16504,9 +16509,12 @@
|
|
|
16504
16509
|
}
|
|
16505
16510
|
function setPattern(el, attrs, target, scope) {
|
|
16506
16511
|
var val = el.style[target];
|
|
16507
|
-
var
|
|
16508
|
-
|
|
16509
|
-
|
|
16512
|
+
var boundingRect = el.getBoundingRect();
|
|
16513
|
+
var patternAttrs = {};
|
|
16514
|
+
var repeat = val.repeat;
|
|
16515
|
+
var noRepeat = repeat === 'no-repeat';
|
|
16516
|
+
var repeatX = repeat === 'repeat-x';
|
|
16517
|
+
var repeatY = repeat === 'repeat-y';
|
|
16510
16518
|
var child;
|
|
16511
16519
|
if (isImagePattern(val)) {
|
|
16512
16520
|
var imageWidth_1 = val.imageWidth;
|
|
@@ -16531,8 +16539,20 @@
|
|
|
16531
16539
|
var setSizeToVNode_1 = function (vNode, img) {
|
|
16532
16540
|
if (vNode) {
|
|
16533
16541
|
var svgEl = vNode.elm;
|
|
16534
|
-
var width =
|
|
16535
|
-
var height =
|
|
16542
|
+
var width = imageWidth_1 || img.width;
|
|
16543
|
+
var height = imageHeight_1 || img.height;
|
|
16544
|
+
if (vNode.tag === 'pattern') {
|
|
16545
|
+
if (repeatX) {
|
|
16546
|
+
height = 1;
|
|
16547
|
+
width /= boundingRect.width;
|
|
16548
|
+
}
|
|
16549
|
+
else if (repeatY) {
|
|
16550
|
+
width = 1;
|
|
16551
|
+
height /= boundingRect.height;
|
|
16552
|
+
}
|
|
16553
|
+
}
|
|
16554
|
+
vNode.attrs.width = width;
|
|
16555
|
+
vNode.attrs.height = height;
|
|
16536
16556
|
if (svgEl) {
|
|
16537
16557
|
svgEl.setAttribute('width', width);
|
|
16538
16558
|
svgEl.setAttribute('height', height);
|
|
@@ -16540,7 +16560,7 @@
|
|
|
16540
16560
|
}
|
|
16541
16561
|
};
|
|
16542
16562
|
var createdImage = createOrUpdateImage(imageSrc, null, el, function (img) {
|
|
16543
|
-
setSizeToVNode_1(patternVNode, img);
|
|
16563
|
+
noRepeat || setSizeToVNode_1(patternVNode, img);
|
|
16544
16564
|
setSizeToVNode_1(child, img);
|
|
16545
16565
|
});
|
|
16546
16566
|
if (createdImage && createdImage.width && createdImage.height) {
|
|
@@ -16564,7 +16584,30 @@
|
|
|
16564
16584
|
if (!child) {
|
|
16565
16585
|
return;
|
|
16566
16586
|
}
|
|
16567
|
-
|
|
16587
|
+
var patternWidth;
|
|
16588
|
+
var patternHeight;
|
|
16589
|
+
if (noRepeat) {
|
|
16590
|
+
patternWidth = patternHeight = 1;
|
|
16591
|
+
}
|
|
16592
|
+
else if (repeatX) {
|
|
16593
|
+
patternHeight = 1;
|
|
16594
|
+
patternWidth = patternAttrs.width / boundingRect.width;
|
|
16595
|
+
}
|
|
16596
|
+
else if (repeatY) {
|
|
16597
|
+
patternWidth = 1;
|
|
16598
|
+
patternHeight = patternAttrs.height / boundingRect.height;
|
|
16599
|
+
}
|
|
16600
|
+
else {
|
|
16601
|
+
patternAttrs.patternUnits = 'userSpaceOnUse';
|
|
16602
|
+
}
|
|
16603
|
+
if (patternWidth != null && !isNaN(patternWidth)) {
|
|
16604
|
+
patternAttrs.width = patternWidth;
|
|
16605
|
+
}
|
|
16606
|
+
if (patternHeight != null && !isNaN(patternHeight)) {
|
|
16607
|
+
patternAttrs.height = patternHeight;
|
|
16608
|
+
}
|
|
16609
|
+
var patternTransform = getSRTTransformString(val);
|
|
16610
|
+
patternTransform && (patternAttrs.patternTransform = patternTransform);
|
|
16568
16611
|
var patternVNode = createVNode('pattern', '', patternAttrs, [child]);
|
|
16569
16612
|
var patternKey = vNodeToString(patternVNode);
|
|
16570
16613
|
var patternCache = scope.patternCache;
|
|
@@ -16916,7 +16959,6 @@
|
|
|
16916
16959
|
SVGPainter.prototype.renderToVNode = function (opts) {
|
|
16917
16960
|
opts = opts || {};
|
|
16918
16961
|
var list = this.storage.getDisplayList(true);
|
|
16919
|
-
var bgColor = this._backgroundColor;
|
|
16920
16962
|
var width = this._width;
|
|
16921
16963
|
var height = this._height;
|
|
16922
16964
|
var scope = createBrushScope(this._id);
|
|
@@ -16924,22 +16966,8 @@
|
|
|
16924
16966
|
scope.willUpdate = opts.willUpdate;
|
|
16925
16967
|
scope.compress = opts.compress;
|
|
16926
16968
|
var children = [];
|
|
16927
|
-
|
|
16928
|
-
|
|
16929
|
-
this._bgVNode = createVNode('rect', 'bg', {
|
|
16930
|
-
width: width,
|
|
16931
|
-
height: height,
|
|
16932
|
-
x: '0',
|
|
16933
|
-
y: '0',
|
|
16934
|
-
id: '0',
|
|
16935
|
-
fill: color,
|
|
16936
|
-
'fill-opacity': opacity
|
|
16937
|
-
});
|
|
16938
|
-
children.push(this._bgVNode);
|
|
16939
|
-
}
|
|
16940
|
-
else {
|
|
16941
|
-
this._bgVNode = null;
|
|
16942
|
-
}
|
|
16969
|
+
var bgVNode = this._bgVNode = createBackgroundVNode(width, height, this._backgroundColor, scope);
|
|
16970
|
+
bgVNode && children.push(bgVNode);
|
|
16943
16971
|
var mainVNode = !opts.compress
|
|
16944
16972
|
? (this._mainVNode = createVNode('g', 'main', {}, [])) : null;
|
|
16945
16973
|
this._paintList(list, scope, mainVNode ? mainVNode.children : children);
|
|
@@ -16968,14 +16996,6 @@
|
|
|
16968
16996
|
};
|
|
16969
16997
|
SVGPainter.prototype.setBackgroundColor = function (backgroundColor) {
|
|
16970
16998
|
this._backgroundColor = backgroundColor;
|
|
16971
|
-
var bgVNode = this._bgVNode;
|
|
16972
|
-
if (bgVNode && bgVNode.elm) {
|
|
16973
|
-
var _a = normalizeColor(backgroundColor), color = _a.color, opacity = _a.opacity;
|
|
16974
|
-
bgVNode.elm.setAttribute('fill', color);
|
|
16975
|
-
if (opacity < 1) {
|
|
16976
|
-
bgVNode.elm.setAttribute('fill-opacity', opacity);
|
|
16977
|
-
}
|
|
16978
|
-
}
|
|
16979
16999
|
};
|
|
16980
17000
|
SVGPainter.prototype.getSvgRoot = function () {
|
|
16981
17001
|
return this._mainVNode && this._mainVNode.elm;
|
|
@@ -17040,10 +17060,20 @@
|
|
|
17040
17060
|
viewportStyle.width = width + 'px';
|
|
17041
17061
|
viewportStyle.height = height + 'px';
|
|
17042
17062
|
}
|
|
17043
|
-
|
|
17044
|
-
|
|
17045
|
-
svgDom
|
|
17046
|
-
|
|
17063
|
+
if (!isPattern(this._backgroundColor)) {
|
|
17064
|
+
var svgDom = this._svgDom;
|
|
17065
|
+
if (svgDom) {
|
|
17066
|
+
svgDom.setAttribute('width', width);
|
|
17067
|
+
svgDom.setAttribute('height', height);
|
|
17068
|
+
}
|
|
17069
|
+
var bgEl = this._bgVNode && this._bgVNode.elm;
|
|
17070
|
+
if (bgEl) {
|
|
17071
|
+
bgEl.setAttribute('width', width);
|
|
17072
|
+
bgEl.setAttribute('height', height);
|
|
17073
|
+
}
|
|
17074
|
+
}
|
|
17075
|
+
else {
|
|
17076
|
+
this.refresh();
|
|
17047
17077
|
}
|
|
17048
17078
|
}
|
|
17049
17079
|
};
|
|
@@ -17071,13 +17101,13 @@
|
|
|
17071
17101
|
this._oldVNode = null;
|
|
17072
17102
|
};
|
|
17073
17103
|
SVGPainter.prototype.toDataURL = function (base64) {
|
|
17074
|
-
var str =
|
|
17104
|
+
var str = this.renderToString();
|
|
17075
17105
|
var prefix = 'data:image/svg+xml;';
|
|
17076
17106
|
if (base64) {
|
|
17077
17107
|
str = encodeBase64(str);
|
|
17078
17108
|
return str && prefix + 'base64,' + str;
|
|
17079
17109
|
}
|
|
17080
|
-
return prefix + 'charset=UTF-8,' + str;
|
|
17110
|
+
return prefix + 'charset=UTF-8,' + encodeURIComponent(str);
|
|
17081
17111
|
};
|
|
17082
17112
|
return SVGPainter;
|
|
17083
17113
|
}());
|
|
@@ -17087,6 +17117,36 @@
|
|
|
17087
17117
|
logError('In SVG mode painter not support method "' + method + '"');
|
|
17088
17118
|
}
|
|
17089
17119
|
};
|
|
17120
|
+
}
|
|
17121
|
+
function createBackgroundVNode(width, height, backgroundColor, scope) {
|
|
17122
|
+
var bgVNode;
|
|
17123
|
+
if (backgroundColor && backgroundColor !== 'none') {
|
|
17124
|
+
bgVNode = createVNode('rect', 'bg', {
|
|
17125
|
+
width: width,
|
|
17126
|
+
height: height,
|
|
17127
|
+
x: '0',
|
|
17128
|
+
y: '0',
|
|
17129
|
+
id: '0'
|
|
17130
|
+
});
|
|
17131
|
+
if (isGradient(backgroundColor)) {
|
|
17132
|
+
setGradient({ fill: backgroundColor }, bgVNode.attrs, 'fill', scope);
|
|
17133
|
+
}
|
|
17134
|
+
else if (isPattern(backgroundColor)) {
|
|
17135
|
+
setPattern({
|
|
17136
|
+
style: {
|
|
17137
|
+
fill: backgroundColor
|
|
17138
|
+
},
|
|
17139
|
+
dirty: noop,
|
|
17140
|
+
getBoundingRect: function () { return ({ width: width, height: height }); }
|
|
17141
|
+
}, bgVNode.attrs, 'fill', scope);
|
|
17142
|
+
}
|
|
17143
|
+
else {
|
|
17144
|
+
var _a = normalizeColor(backgroundColor), color = _a.color, opacity = _a.opacity;
|
|
17145
|
+
bgVNode.attrs.fill = color;
|
|
17146
|
+
opacity < 1 && (bgVNode.attrs.fillOpacity = opacity);
|
|
17147
|
+
}
|
|
17148
|
+
}
|
|
17149
|
+
return bgVNode;
|
|
17090
17150
|
}
|
|
17091
17151
|
|
|
17092
17152
|
registerPainter('canvas', CanvasPainter);
|