Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare to release 5.2.1 #827

Merged
merged 18 commits into from
Sep 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/nightly-next.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Publish Nightly Next

on:
schedule:
- cron: '0 8 * * *'
workflow_dispatch: {}
repository_dispatch:
types: publish-nightly-next

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x]

steps:
- uses: actions/checkout@v2
with:
ref: next

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
registry-url: https://registry.npmjs.org/
- name: Setup and publish nightly
run: |
npm ci
npm run release
npm run prepare:nightly-next
npm publish --tag next
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
44 changes: 27 additions & 17 deletions build/prepareNightly.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,36 @@ const fs = require('fs');
const packageJsonPath = __dirname + '/../package.json';
const nightlyPackageName = 'zrender-nightly';

const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
const version = packageJson.version;
const parts = /(\d+)\.(\d+)\.(\d+)($|\-)/.exec(version);
if (!parts) {
throw new Error(`Invalid version number ${version}`);
}
// Add date to version.
const major = +parts[1];
const minor = +parts[2];
let patch = +parts[3];
const isStable = !parts[4];
if (isStable) {
// It's previous stable version. Dev version should be higher.
patch++;
function updateVersion(version) {
const isNext = process.argv.includes('--next');
const parts = /(\d+)\.(\d+)\.(\d+)($|\-)/.exec(version);
if (!parts) {
throw new Error(`Invalid version number ${version}`);
}
// Add date to version.
const major = +parts[1];
let minor = +parts[2];
let patch = +parts[3];
const isStable = !parts[4];
if (isStable) {
// It's previous stable version. Dev version should be higher.
if (isNext) {
// Increase minor version for next branch.
minor++;
}
else {
// Increase main version for master branch.
patch++;
}
}

const date = new Date().toISOString().replace(/:|T|\.|-/g, '').slice(0, 8);
return `${major}.${minor}.${patch}-dev.${date}`;
}

const date = new Date().toISOString().replace(/:|T|\.|-/g, '').slice(0, 8);
const nightlyVersion = `${major}.${minor}.${patch}-dev.${date}`;

const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
packageJson.name = nightlyPackageName;
packageJson.version = nightlyVersion;
packageJson.version = updateVersion(packageJson.version);

fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf-8');
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"build": "npm run build:bundle && npm run build:lib",
"release": "node build/build.js --minify && npm run build:lib",
"prepare:nightly": "node build/prepareNightly.js",
"prepare:nightly-next": "node build/prepareNightly.js --next",
"build:bundle": "node build/build.js",
"build:lib": "npx tsc -m ES2015 --outDir lib",
"watch:bundle": "node build/build.js --watch",
Expand Down Expand Up @@ -51,4 +52,4 @@
"typescript": "4.3.5",
"uglify-js": "^3.10.0"
}
}
}
12 changes: 6 additions & 6 deletions src/Element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import Point from './core/Point';
import { LIGHT_LABEL_COLOR, DARK_LABEL_COLOR } from './config';
import { parse, stringify } from './tool/color';
import env from './core/env';
import { REDARAW_BIT } from './graphic/constants';
import { REDRAW_BIT } from './graphic/constants';

export interface ElementAnimateConfig {
duration?: number
Expand Down Expand Up @@ -655,7 +655,7 @@ class Element<Props extends ElementProps = ElementProps> {

// Mark textEl to update transform.
// DON'T use markRedraw. It will cause Element itself to dirty again.
textEl.__dirty |= REDARAW_BIT;
textEl.__dirty |= REDRAW_BIT;

if (textStyleChanged) {
// Only mark style dirty if necessary. Update ZRText is costly.
Expand Down Expand Up @@ -937,7 +937,7 @@ class Element<Props extends ElementProps = ElementProps> {
this._toggleHoverLayerFlag(false);
// NOTE: avoid unexpected refresh when moving out from hover layer!!
// Only clear from hover layer.
this.__dirty &= ~REDARAW_BIT;
this.__dirty &= ~REDRAW_BIT;
}

// Return used state.
Expand Down Expand Up @@ -1024,7 +1024,7 @@ class Element<Props extends ElementProps = ElementProps> {
this._toggleHoverLayerFlag(false);
// NOTE: avoid unexpected refresh when moving out from hover layer!!
// Only clear from hover layer.
this.__dirty &= ~REDARAW_BIT;
this.__dirty &= ~REDRAW_BIT;
}
}
}
Expand Down Expand Up @@ -1354,7 +1354,7 @@ class Element<Props extends ElementProps = ElementProps> {
* Mark element needs to be repainted
*/
markRedraw() {
this.__dirty |= REDARAW_BIT;
this.__dirty |= REDRAW_BIT;
const zr = this.__zr;
if (zr) {
if (this.__inHover) {
Expand Down Expand Up @@ -1623,7 +1623,7 @@ class Element<Props extends ElementProps = ElementProps> {
elProto.dragging = false;
elProto.ignoreClip = false;
elProto.__inHover = false;
elProto.__dirty = REDARAW_BIT;
elProto.__dirty = REDRAW_BIT;


const logs: Dictionary<boolean> = {};
Expand Down
4 changes: 2 additions & 2 deletions src/Storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Element from './Element';
import timsort from './core/timsort';
import Displayable from './graphic/Displayable';
import Path from './graphic/Path';
import { REDARAW_BIT } from './graphic/constants';
import { REDRAW_BIT } from './graphic/constants';

let invalidZErrorLogged = false;
function logInvalidZError() {
Expand Down Expand Up @@ -141,7 +141,7 @@ export default class Storage {

// Force to mark as dirty if group is dirty
if (el.__dirty) {
child.__dirty |= REDARAW_BIT;
child.__dirty |= REDRAW_BIT;
}

this._updateAndAddDisplayable(child, clipPaths, includeIgnore);
Expand Down
6 changes: 3 additions & 3 deletions src/canvas/Layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { getCanvasGradient } from './helper';
import { createCanvasPattern } from './graphic';
import Displayable from '../graphic/Displayable';
import BoundingRect from '../core/BoundingRect';
import { REDARAW_BIT } from '../graphic/constants';
import { REDRAW_BIT } from '../graphic/constants';

function returnFalse() {
return false;
Expand Down Expand Up @@ -281,7 +281,7 @@ export default class Layer extends Eventful {
* or not painted this frame.
*/
const shouldPaint = el.shouldBePainted(viewWidth, viewHeight, true, true);
const prevRect = el.__isRendered && ((el.__dirty & REDARAW_BIT) || !shouldPaint)
const prevRect = el.__isRendered && ((el.__dirty & REDRAW_BIT) || !shouldPaint)
? el.getPrevPaintRect()
: null;
if (prevRect) {
Expand All @@ -293,7 +293,7 @@ export default class Layer extends Eventful {
* if the element should be brushed this frame and either being
* dirty or not rendered before.
*/
const curRect = shouldPaint && ((el.__dirty & REDARAW_BIT) || !el.__isRendered)
const curRect = shouldPaint && ((el.__dirty & REDRAW_BIT) || !el.__isRendered)
? el.getPaintRect()
: null;
if (curRect) {
Expand Down
4 changes: 2 additions & 2 deletions src/canvas/Painter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { PainterBase } from '../PainterBase';
import BoundingRect from '../core/BoundingRect';
import IncrementalDisplayable from '../graphic/IncrementalDisplayable';
import Path from '../graphic/Path';
import { REDARAW_BIT } from '../graphic/constants';
import { REDRAW_BIT } from '../graphic/constants';

const HOVER_LAYER_ZLEVEL = 1e5;
const CANVAS_ZLEVEL = 314159;
Expand Down Expand Up @@ -751,7 +751,7 @@ export default class CanvasPainter implements PainterBase {
updatePrevLayer(i);
prevLayer = layer;
}
if ((el.__dirty & REDARAW_BIT) && !el.__inHover) { // Ignore dirty elements in hover layer.
if ((el.__dirty & REDRAW_BIT) && !el.__inHover) { // Ignore dirty elements in hover layer.
layer.__dirty = true;
if (layer.incremental && layer.__drawIndex < 0) {
// Start draw from the first dirty element.
Expand Down
4 changes: 2 additions & 2 deletions src/canvas/graphic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { MatrixArray } from '../core/matrix';
import { map } from '../core/util';
import { normalizeLineDash } from '../graphic/helper/dashStyle';
import IncrementalDisplayable from '../graphic/IncrementalDisplayable';
import { REDARAW_BIT, SHAPE_CHANGED_BIT } from '../graphic/constants';
import { REDRAW_BIT, SHAPE_CHANGED_BIT } from '../graphic/constants';

const pathProxyForDraw = new PathProxy(true);

Expand Down Expand Up @@ -648,7 +648,7 @@ export function brush(
// Or this element will always been rendered in progressive rendering.
// But other dirty bit should not be cleared, otherwise it cause the shape
// can not be updated in this case.
el.__dirty &= ~REDARAW_BIT;
el.__dirty &= ~REDRAW_BIT;
el.__isRendered = false;
return;
}
Expand Down
5 changes: 4 additions & 1 deletion src/core/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,16 @@ export function clientToLocal(
// <https://bugs.jquery.com/ticket/8523#comment:14>
// BTW3, In ff, offsetX/offsetY is always 0.
else if (env.browser.firefox
// use offsetX/offsetY for Firefox >= 39
// PENDING: consider Firefox for Android and Firefox OS? >= 43
&& env.browser.version < '39'
&& (e as FirefoxMouseEvent).layerX != null
&& (e as FirefoxMouseEvent).layerX !== (e as MouseEvent).offsetX
) {
out.zrX = (e as FirefoxMouseEvent).layerX;
out.zrY = (e as FirefoxMouseEvent).layerY;
}
// For IE6+, chrome, safari, opera. (When will ff support offsetX?)
// For IE6+, chrome, safari, opera, firefox >= 39
else if ((e as MouseEvent).offsetX != null) {
out.zrX = (e as MouseEvent).offsetX;
out.zrY = (e as MouseEvent).offsetY;
Expand Down
12 changes: 9 additions & 3 deletions src/core/util.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* global: defineProperty */
import { Dictionary, ArrayLike, KeyOfDistributive } from './types';
import { GradientObject } from '../graphic/Gradient';
import { ImagePatternObject } from '../graphic/Pattern';
Expand Down Expand Up @@ -38,6 +39,7 @@ const nativeMap = arrayProto.map;
// In case some env may redefine the global variable `Function`.
const ctorFunction = function () {}.constructor;
const protoFunction = ctorFunction ? ctorFunction.prototype : null;
const protoKey = '__proto__';

// Avoid assign to an exported constiable, for transforming to cjs.
const methods: {[key: string]: Function} = {};
Expand All @@ -47,6 +49,7 @@ export function $override(name: string, fn: Function) {
}

let idStart = 0x0907;

/**
* Generate unique id
*/
Expand Down Expand Up @@ -106,7 +109,8 @@ export function clone<T extends any>(source: T): T {
else if (!BUILTIN_OBJECT[typeStr] && !isPrimitive(source) && !isDom(source)) {
result = {} as any;
for (let key in source) {
if (source.hasOwnProperty(key)) {
// Check if key is __proto__ to avoid prototype pollution
if (source.hasOwnProperty(key) && key !== protoKey) {
result[key] = clone(source[key]);
}
}
Expand All @@ -131,7 +135,8 @@ export function merge(target: any, source: any, overwrite?: boolean): any {
}

for (let key in source) {
if (source.hasOwnProperty(key)) {
// Check if key is __proto__ to avoid prototype pollution
if (source.hasOwnProperty(key) && key !== protoKey) {
const targetProp = target[key];
const sourceProp = source[key];

Expand Down Expand Up @@ -184,7 +189,8 @@ export function extend<
}
else {
for (let key in source) {
if (source.hasOwnProperty(key)) {
// Check if key is __proto__ to avoid prototype pollution
if (source.hasOwnProperty(key) && key !== protoKey) {
(target as S & T)[key] = (source as T & S)[key];
}
}
Expand Down
1 change: 1 addition & 0 deletions src/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export {
ElementProps
} from './Element';

export {default as Displayable, DisplayableProps} from './graphic/Displayable';
export {default as Group, GroupProps} from './graphic/Group';
export {default as Path, PathStyleProps, PathProps, PathStatePropNames, PathState} from './graphic/Path';
export {default as Image, ImageStyleProps, ImageProps, ImageState} from './graphic/Image';
Expand Down
4 changes: 2 additions & 2 deletions src/graphic/Displayable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { PropType, Dictionary, MapToType } from '../core/types';
import Path from './Path';
import { keys, extend, createObject } from '../core/util';
import Animator from '../animation/Animator';
import { REDARAW_BIT, STYLE_CHANGED_BIT } from './constants';
import { REDRAW_BIT, STYLE_CHANGED_BIT } from './constants';

// type CalculateTextPositionResult = ReturnType<typeof calculateTextPosition>

Expand Down Expand Up @@ -598,7 +598,7 @@ class Displayable<Props extends DisplayableProps = DisplayableProps> extends Ele
dispProto._rect = null;
dispProto.dirtyRectTolerance = 0;

dispProto.__dirty = REDARAW_BIT | STYLE_CHANGED_BIT;
dispProto.__dirty = REDRAW_BIT | STYLE_CHANGED_BIT;
})()
}

Expand Down
2 changes: 1 addition & 1 deletion src/graphic/Gradient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface GradientObject {

colorStops: GradientColorStop[]

global: boolean
global?: boolean
}

export interface InnerGradientObject extends GradientObject {
Expand Down
6 changes: 3 additions & 3 deletions src/graphic/Path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { defaults, keys, extend, clone, isString, createObject } from '../core/u
import Animator from '../animation/Animator';
import { lum } from '../tool/color';
import { DARK_LABEL_COLOR, LIGHT_LABEL_COLOR, DARK_MODE_THRESHOLD, LIGHTER_LABEL_COLOR } from '../config';
import { REDARAW_BIT, SHAPE_CHANGED_BIT, STYLE_CHANGED_BIT } from './constants';
import { REDRAW_BIT, SHAPE_CHANGED_BIT, STYLE_CHANGED_BIT } from './constants';


export interface PathStyleProps extends CommonStyleProps {
Expand Down Expand Up @@ -193,7 +193,7 @@ class Path<Props extends PathProps = PathProps> extends Displayable<Props> {
(decalEl as any)[pathCopyParams[i]] = this[pathCopyParams[i]];
}

decalEl.__dirty |= REDARAW_BIT;
decalEl.__dirty |= REDRAW_BIT;
}
else if (this._decalEl) {
this._decalEl = null;
Expand Down Expand Up @@ -670,7 +670,7 @@ class Path<Props extends PathProps = PathProps> extends Displayable<Props> {
pathProto.segmentIgnoreThreshold = 0;
pathProto.subPixelOptimize = false;
pathProto.autoBatch = false;
pathProto.__dirty = REDARAW_BIT | STYLE_CHANGED_BIT | SHAPE_CHANGED_BIT;
pathProto.__dirty = REDRAW_BIT | STYLE_CHANGED_BIT | SHAPE_CHANGED_BIT;
})()
}

Expand Down
2 changes: 1 addition & 1 deletion src/graphic/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Bit masks to check which parts of element needs to be updated.
export const REDARAW_BIT = 1;
export const REDRAW_BIT = 1;
export const STYLE_CHANGED_BIT = 2;
export const SHAPE_CHANGED_BIT = 4;
4 changes: 2 additions & 2 deletions src/svg/graphic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function bindStyle(svgEl: SVGElement, style: AllStyleOption, el?: Path | TSpan |

// only set opacity. stroke and fill cannot be applied to svg image
if (el instanceof ZRImage) {
svgEl.style.opacity = opacity + '';
attr(svgEl, 'opacity', opacity + '');
return;
}

Expand Down Expand Up @@ -137,7 +137,7 @@ function bindStyle(svgEl: SVGElement, style: AllStyleOption, el?: Path | TSpan |
attr(svgEl, 'stroke-dashoffset', (lineDashOffset || 0) + '');
}
else {
attr(svgEl, 'stroke-dasharray', '');
attr(svgEl, 'stroke-dasharray', NONE);
}

// PENDING
Expand Down
Loading