Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
175 commits
Select commit Hold shift + click to select a range
97fe137
Merge pull request #814 from ecomfe/master
pissang Sep 3, 2021
7bb451c
WIP: try svg-ssr
pissang Sep 23, 2021
cd93186
wip(svg-ssr): compress generated strings
pissang Sep 24, 2021
7381160
wip(svg-ssr): use builtin shape to optimize the size
pissang Sep 24, 2021
3d37a30
Merge branch 'master' into svg-ssr
pissang Sep 24, 2021
f06e85e
wip(svg-ssr): merge from master
pissang Sep 24, 2021
5704662
wip(svg-ssr): support shadow and gradient
pissang Sep 25, 2021
911a205
wip(svg-ssr): add pattern. upgrade ts
pissang Sep 26, 2021
3c60942
wip(svg-ssr): add clipPaths. fix skew transform
pissang Sep 26, 2021
8eb1bc0
wip(svg-ssr): refact to add inner structure storage for dom
pissang Sep 27, 2021
01b2213
wip(svg-ssr): name inner store structure to vnode
pissang Sep 27, 2021
b22cdbe
wip(svg-ssr): add preact patch test
pissang Sep 27, 2021
a12574a
wip(ssr): use snabbdom patch algorithm.
pissang Sep 28, 2021
3588983
wip(svg-ssr): optimize vnode attribute create
pissang Sep 28, 2021
75e5c98
wip(svg-ssr): clean code, cache svg path rebuilder
pissang Sep 29, 2021
b1c2e84
wip(svg-ssr): add animates
pissang Sep 29, 2021
10a6cd2
wip(svg): animation easing
pissang Sep 29, 2021
7bab051
wip(svg-ssr): add animation delay. fix easing on path
pissang Sep 29, 2021
b9d1139
wip(svg-ssr): fix some error in node env
pissang Sep 29, 2021
79ad104
refact(svg): replaced original svg renderer with new
pissang Sep 30, 2021
4cda9a2
wip(svg): fix some issues in echarts
pissang Sep 30, 2021
2b93671
wip(svg): fix id geenrate not in scope.
pissang Sep 30, 2021
c081732
wip(svg): add willUpdate hint
pissang Sep 30, 2021
c810d9e
wip(svg): compress output svg string
pissang Oct 1, 2021
ccca72a
wip(svg): fix setBackgroundColor and getSvgRoot
pissang Oct 1, 2021
508844f
wip(svg): optimize ssr output
pissang Oct 1, 2021
36763db
wip(svg): fix image pattern
pissang Oct 2, 2021
8978c36
wip(svg): use css animation instead of SMIL
pissang Oct 3, 2021
3f6d32e
wip(svg): add transform origin and skew in animation
pissang Oct 3, 2021
b9cc86f
wip(svg): animation only applied on ssr
pissang Oct 3, 2021
7e02159
wip(svg): fix css animation
pissang Oct 3, 2021
0f60ea5
wip(svg): add multiple kf support in css transform
pissang Oct 3, 2021
a855add
wip(svg): fix typos. default to use linear easing
pissang Oct 3, 2021
a48d334
wip(svg): add path animation for compound path
pissang Oct 4, 2021
165dcdc
wip(ssr): add basic text width map for node environment
pissang Oct 5, 2021
e2b0685
wip(ssr): fix some escape chars
pissang Oct 5, 2021
4f7803a
style: naming tweak
pissang Oct 6, 2021
2074583
wip(ssr): disable animation when path data don't match.
pissang Oct 6, 2021
93a5fac
wip(ssr): not add css class if there is no property can animate.
pissang Oct 6, 2021
b055250
chore: add node env
pissang Oct 6, 2021
5cb9a67
refact: remove code for ancient browsers.
pissang Oct 6, 2021
f9be13c
wip(svg): optimize transform origin output in animation
pissang Oct 6, 2021
5a511ac
wip(svg): fix transform origin in animation
pissang Oct 6, 2021
1fe5a47
wip(svg): fix class and id conflicts in multiple instances.
pissang Oct 7, 2021
3ee98e1
wip(svg): fix typo
pissang Oct 7, 2021
294de34
wip(svg): keep text empty space logic
pissang Oct 7, 2021
7140c05
wip(svg): fix animation name.
pissang Oct 7, 2021
95215f5
wip(svg): fix some issues after review
pissang Oct 8, 2021
38d9436
wip(svg): add explain comment
pissang Oct 8, 2021
b0ede2c
fix entry js
pissang Oct 8, 2021
b88a611
wip(svg): fix shadow error log when scale is 0
pissang Oct 8, 2021
b95c3f8
wip(svg): add cssAnimation option in renderToString
pissang Oct 8, 2021
dd57edf
wip(svg): set font attributes instead of style. apache/echarts#15064
pissang Oct 8, 2021
af0d89d
wip(text): always set font in style to avoid other css overwrite it
pissang Oct 8, 2021
8182684
wip(svg): use separated font css in style
pissang Oct 8, 2021
b1d9cde
wip(svg): fix font size with px postfix
pissang Oct 8, 2021
7b734b7
wip(svg): use null check in fontSize
pissang Oct 9, 2021
4d0fed6
Merge pull request #838 from ecomfe/master
pissang Oct 11, 2021
0302bf6
Merge branch 'next' into svg-ssr
pissang Oct 11, 2021
2181392
Merge pull request #836 from ecomfe/svg-ssr
pissang Oct 12, 2021
1e269b9
fix(event): fix firefox version comparison flaw.
plainheart Oct 12, 2021
424b906
Merge pull request #839 from ecomfe/fix-firefox-version-comparison
pissang Oct 12, 2021
aa67650
fix(svg): put style on the svg dom instead of container
pissang Oct 14, 2021
ca72646
style: simpler prop name
pissang Oct 14, 2021
ac84ffe
refact: remove IncrementalDisplayable from dependencies
pissang Oct 14, 2021
2d4e1d1
feat: add setPlatformAPI
pissang Oct 14, 2021
beab675
Expose createCanvas in util for compatibility
pissang Oct 15, 2021
7a58527
test: update unit test
pissang Oct 15, 2021
38102ff
feat(platform): add loadImage in platform api
pissang Oct 15, 2021
9468300
fix(platform): wider loadImage callback type
pissang Oct 15, 2021
3868e26
Merge pull request #840 from ecomfe/svg-ssr
pissang Oct 15, 2021
a49e7e4
fix type error
pissang Oct 15, 2021
a2e90a6
Merge pull request #841 from ecomfe/svg-ssr
pissang Oct 17, 2021
cd756a9
refact: remove spline implentation to reduce code size a bit
pissang Nov 21, 2021
c1de881
feat(animation): support different easing in each keyframe
pissang Nov 21, 2021
731cd9d
feat: support per kf easing in css animation
pissang Nov 22, 2021
7d3fe39
test: optimize ssr case
pissang Nov 22, 2021
c3ba264
tweak
pissang Nov 23, 2021
9fb1577
fix(svg): update `_svgDom` when vnode changed.
plainheart Nov 26, 2021
de32829
refact: simplify codes, remove unused animation.onframe
pissang Nov 29, 2021
9997ff9
fix: not remove original attributes when css animation is used.
pissang Nov 29, 2021
369b25a
fix(svg): pre-create svg vnode when initializing.
plainheart Nov 30, 2021
511f9ef
chore(svg): remove some magic strings.
plainheart Nov 30, 2021
33a9cfb
fix(svg): remove unused `emptyNodeAt` & `isVnode` and unnecessary typ…
plainheart Nov 30, 2021
d063e33
fix(svg): remove unused `insertedVnodeQueue`.
plainheart Nov 30, 2021
429e332
Merge pull request #853 from ecomfe/fix-svg-dom
pissang Dec 1, 2021
d4ae235
Merge remote-tracking branch 'origin' into animation-keyframe-easing
pissang Dec 1, 2021
f7fb65d
Merge branch 'next' into animation-keyframe-easing
pissang Dec 1, 2021
1a64a4e
refact: optimize code of line dash
pissang Dec 1, 2021
c85a5de
fix(animation): use max time of animator in each keyframe
pissang Dec 1, 2021
975663b
fix(text): fix fill 'none' not work
pissang Dec 1, 2021
07483bf
feat(animation): support cubic bezier easing expression
pissang Dec 1, 2021
e8283b0
fix(svg): set attributes for svg dom when initializing.
plainheart Dec 3, 2021
e72518d
Merge pull request #855 from ecomfe/fix-svg-root-attrs
pissang Dec 3, 2021
b8ed9ff
feat(anim): ability to set min duration in animator.
pissang Dec 5, 2021
c004d17
fix(animation): optimize keyframe animation
pissang Dec 7, 2021
220ab41
animation: remove unused Clip#gap. fix max time issue
pissang Dec 9, 2021
c0c6318
feat: support discrete animation
pissang Dec 10, 2021
8e8af77
feat(svg): support exporting base64-encoded dataURL.
plainheart Dec 10, 2021
893b154
fix: use `window.btoa` in browser, otherwise fallback to Node Buffer.
plainheart Dec 10, 2021
960fa6e
fix: throw an error if base64 isn't natively supported.
plainheart Dec 10, 2021
e4bb5e2
fix: use const instead of let.
plainheart Dec 10, 2021
f66fb07
fix: use `console.error` instead of `throw new Error`.
plainheart Dec 10, 2021
e3d7e84
fix: fix unexpected dev code.
plainheart Dec 10, 2021
9b8ec04
refactor: add `hasGlobalWindow` to the `env` detector & simplify the …
plainheart Dec 11, 2021
9812aff
Merge pull request #856 from ecomfe/svg-export-base64
pissang Dec 11, 2021
f00ace2
feat: support gradient animation
pissang Dec 13, 2021
552fcc7
fix gradient animation in state transition
pissang Dec 13, 2021
b6306a6
fix importing from global export
pissang Dec 14, 2021
4d55109
fix discrete animation
pissang Dec 14, 2021
63affe8
feat: add Animator#duration
pissang Dec 14, 2021
b3c9512
feat(animation): support negative keyframe time.
pissang Dec 14, 2021
c6cc31e
fix(animation): use raw value in discrete animation.
pissang Dec 15, 2021
7117eb8
fix(svg): fix css animation
pissang Dec 15, 2021
000c53d
revert an unsure change.
pissang Dec 15, 2021
3e57c58
fix linting issues from deepscan
pissang Dec 15, 2021
953a2ea
Merge branch 'next' into animation-keyframe-easing
pissang Dec 15, 2021
582bf5d
clean code
pissang Dec 15, 2021
826ce2f
fix previous tracks may not stopped when animation values are same
pissang Dec 15, 2021
571de74
fix(animation): fix animateTo twice will cause animation lost
pissang Dec 15, 2021
a168ab4
remove `pathToImage`
pissang Dec 17, 2021
d0bd5df
feat: support anchor transform
pissang Dec 17, 2021
5dcb5ff
fix(animation): fix boolean value type not using discrete animation
pissang Dec 17, 2021
b9482d4
fix linting issues
pissang Dec 17, 2021
7732252
remove symlink
pissang Dec 17, 2021
7f84215
optimize code based on review
pissang Dec 20, 2021
f64bdb9
Merge pull request #857 from ecomfe/animation-keyframe-easing
pissang Dec 20, 2021
03f4a1e
fix(animation): ignore loop animation when switching state.
pissang Dec 22, 2021
f2594ec
fix: optimize image type check in svg renderer.
pissang Dec 22, 2021
7a2a420
update test case
pissang Dec 22, 2021
cd718dc
Merge pull request #859 from ecomfe/fix-animation
pissang Dec 22, 2021
27b5070
Merge pull request #860 from ecomfe/fix-ssr-image
pissang Dec 22, 2021
13ba53c
feat(ssr): add useViewBox opt
pissang Dec 22, 2021
d239b31
feat(ssr): change useViewBox to be true by default
pissang Dec 22, 2021
b002256
style: remove unused code
pissang Dec 22, 2021
ef40d70
Merge pull request #861 from ecomfe/svg-ssr-viewbox
pissang Dec 22, 2021
2ab3c96
chore: add .js in the import statement of es modules.
pissang Dec 23, 2021
1d7ff7b
fix index.ts
pissang Dec 23, 2021
e6483e7
chore: fix globby in windows
pissang Dec 23, 2021
5b75ddb
Merge pull request #862 from ecomfe/add-js-extension
pissang Dec 23, 2021
301879e
fix import parsing case
pissang Dec 24, 2021
4460f54
fix broken code
pissang Dec 24, 2021
ae7a625
fix issue from deepscan
pissang Dec 24, 2021
595c4c0
Merge pull request #863 from ecomfe/add-js-extension
pissang Dec 24, 2021
e0d636e
fix package-lock.json
pissang Dec 24, 2021
f740dca
Merge pull request #864 from ecomfe/add-js-extension
pissang Dec 24, 2021
94db9e1
feat(sector): the sector supports arbitrary corner radius.
plainheart Dec 28, 2021
53819e9
chore(build): process lib extension after compilation in watch mode.
plainheart Dec 28, 2021
d928320
feat(sector): rename `cr` to `cornerRadius`.
plainheart Dec 28, 2021
022217b
fix(sector): use normalized `innerRadius` & `radius` instead of raw `…
plainheart Dec 29, 2021
b3864e0
test: support changing the renderer.
plainheart Dec 29, 2021
cecdab1
fix(sector): 1) use `r - r0` as the relative value of percentage if t…
plainheart Dec 29, 2021
f4ed2d7
fix(sector): remove unnecessary condition.
plainheart Dec 29, 2021
3bb9b1b
fix(sector): avoid unnecessary invocation.
plainheart Dec 30, 2021
dcd5bf5
fix(sector): use `const` instead of `let`.
plainheart Dec 30, 2021
8aa2f5c
fix(sector): a small tweak.
plainheart Dec 31, 2021
55b5d4e
fix(sector): fix types and tweak comment.
plainheart Dec 31, 2021
f3a06ed
fix(sector): recover some previous code.
plainheart Jan 4, 2022
c6a5dfa
chore: remove unused function.
plainheart Jan 4, 2022
0ee1b32
fix(svg): fix animation on strokePercent will cause partially drawing.
mrwd2009 Jan 4, 2022
6547a9b
Use variable 'strokePercent' directly.
mrwd2009 Jan 4, 2022
ef28006
fix(sector): fix some broken cases when sector arc is small.
plainheart Jan 4, 2022
0a4d6f0
Merge pull request #867 from mrwd2009/fix-svg-strokepercent
pissang Jan 5, 2022
f11e39e
refactor(sector): remove support for percentage value of corner radius.
plainheart Jan 6, 2022
4f5c6d6
fix: remove unused import.
plainheart Jan 6, 2022
db0029f
Merge pull request #865 from ecomfe/enhance-sector-corner-radius
pissang Jan 7, 2022
8eb919d
chore: update the description and keywords in package.json
plainheart Jan 7, 2022
9cde42c
Merge pull request #869 from ecomfe/update-package-json
pissang Jan 7, 2022
c42b082
fix(animator): `NaN` shouldn't be considered as the number type.
plainheart Jan 8, 2022
cc3d274
Merge pull request #870 from ecomfe/fix-animator
pissang Jan 9, 2022
a40f31a
fix(srctor): 1) don't use `normalizeArcAngles` anymore. 2) optimize t…
plainheart Jan 13, 2022
25033ef
fix(sector): remove unused import.
plainheart Jan 13, 2022
5822f04
Merge pull request #871 from ecomfe/fix-sector
pissang Jan 13, 2022
e417624
fix(animation): fix gradient animation
pissang Jan 14, 2022
c2e14d5
Merge pull request #872 from ecomfe/fix-gradient-animation
pissang Jan 14, 2022
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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,7 @@ pip-log.txt

/lib
/esm
node_modules
node_modules

# rollup visualizer
/stats.html
75 changes: 48 additions & 27 deletions build/build.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// const typescript = require('@rollup/plugin-typescript');
const typescript = require('rollup-plugin-typescript2');
const replace = require('@rollup/plugin-replace');
const rollup = require('rollup');
const path = require('path');
const processs = require('process');
Expand All @@ -12,24 +13,34 @@ function current() {
return (new Date()).toLocaleString();
}

const inputOption = {
input: path.resolve(__dirname, '../index.ts'),
plugins: [typescript({
tsconfigOverride: {
compilerOptions: {
// Rollup don't use CommonJS by default.
module: 'ES2015',
sourceMap: true,
// Use the esm d.ts
declaration: false
}
}
}), progress({
scope: {
total: 0
}
})]
};
function createInputOption(env, isWatch) {
return {
input: path.resolve(__dirname, '../index.ts'),
plugins: [
typescript({
clean: !isWatch,
tsconfigOverride: {
compilerOptions: {
// Rollup don't use CommonJS by default.
module: 'ES2015',
sourceMap: true,
// Use the esm d.ts
declaration: false
}
}
}),
replace({
preventAssignment: true,
'process.env.NODE_ENV': JSON.stringify(env)
}),
progress({
scope: {
total: 0
}
})
]
};
}

const outputOption = {
format: 'umd',
Expand All @@ -39,18 +50,17 @@ const outputOption = {
};

function minify(outPath) {
const fileMinPath = outPath.replace(/.js$/, '.min.js');
const code = fs.readFileSync(outPath, 'utf-8');
const uglifyResult = UglifyJS.minify(code);
if (uglifyResult.error) {
throw new Error(uglifyResult.error);
}
fs.writeFileSync(fileMinPath, uglifyResult.code, 'utf-8');
fs.writeFileSync(outPath, uglifyResult.code, 'utf-8');
}

if (processs.argv.includes('--watch')) {
const watcher = rollup.watch({
...inputOption,
...createInputOption('development', true),
output: [outputOption],
watch: {
clearScreen: true
Expand Down Expand Up @@ -83,13 +93,24 @@ if (processs.argv.includes('--watch')) {
});
}
else {
// Unminified
rollup.rollup({
...inputOption
...createInputOption('development', false)
}).then(bundle => {
bundle.write(outputOption).then(function () {
if (process.argv.indexOf('--minify') >= 0) {
minify(outputOption.file);
}
});
bundle.write(outputOption);
});
// Minified
if (process.argv.indexOf('--minify') >= 0) {
rollup.rollup({
...createInputOption('production', false)
}).then(bundle => {
const file = outputOption.file.replace(/.js$/, '.min.js');
bundle.write(Object.assign(outputOption, {
file,
sourcemap: false
})).then(function () {
minify(file);
});
});
}
}
67 changes: 67 additions & 0 deletions build/processLib.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Porcess generated lib files.
// Like adding js extension in the import statement.

const { transformImport } = require('./transformImport');
const globby = require('globby');
const path = require('path');
const fs = require('fs');
const chalk = require('chalk');
const rollup = require('rollup');
const nodeResolve = require('@rollup/plugin-node-resolve').default;

function addJsExtension(moduleName) {
// Ignore 'tslib'
if (!(moduleName.startsWith('.'))) {
return moduleName;
}
if (moduleName.endsWith('.ts')) {
// Replace ts with js
return moduleName.replace(/\.ts$/, '.js');
}
else if (moduleName.endsWith('.js')) {
return moduleName;
}
else {
return moduleName + '.js'
}
}

async function transform() {
const libFiles = await globby([
'**/*.js'
], {
cwd: path.join(__dirname, '../lib'),
absolute: true
});

if (libFiles.length === 0) {
throw new Error('No lib files found.')
}

for (let file of libFiles) {
const code = fs.readFileSync(file, 'utf-8');
fs.writeFileSync(file, transformImport(code, addJsExtension), 'utf-8');
}

// Transform index;
const indexFile = path.join(__dirname, '../index.js');
fs.writeFileSync(
indexFile,
transformImport(
fs.readFileSync(indexFile, 'utf-8'),
(mduleName) => addJsExtension(mduleName).replace('./src', './lib')
)
)
}

transform().then(() => {
console.log(chalk.green('Added .js extensions.'));
console.log(chalk.gray('Start testing generated libs...'));
}).then(() => {
return rollup.rollup({
input: path.resolve(__dirname, '../index.js'),
plugins: [nodeResolve()]
});
}).then(() => {
console.log(chalk.green('Libs can be bundled!'));
});
115 changes: 115 additions & 0 deletions build/transformImport.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
// adding js extension in the import statement.

// Reference:
// https://regexr.com/47jlq
// https://gist.github.com/manekinekko/7e58a17bc62a9be47172
const regexp = /((?:(?:import)|(?:export))\s+?(?:(?:(?:[\w*\s{},\/]*)\s+from\s+?)|))(?:(?:"(.*?)")|(?:'(.*?)'))([\s]*?(?:;|$|))/g;

module.exports.transformImport = function (code, processModuleName) {
return code.replace(regexp, (str, prefix, moduleNameA, moduleNameB, postfix) => {
let moduleName = (moduleNameA === undefined ? moduleNameB : moduleNameA).trim();
const quote = moduleNameA === undefined ? "'" : '"';
return prefix + quote + processModuleName(moduleName) + quote + postfix;
// Not support other extensions.
});
}


const testCases = `import videos from './videos/index.js'

export default (socket, context) => {
// dynamically importing all the socket.io handler (it's dynamic import that happen at run time)
import {
something
} from "./test/okbb"

const f = 2;

import test from 'obb'


import {
Component
} from '@angular2/core';

import defaultMember from "module-0";

import * as name from "module-1 ";

import { member } from " module-2";

import { member as alias } from "module-3";

import { member1 , member2 } from "module-4";

import { member1 , member2 as alias2 , member3 as alias3 } from "module-5";

import defaultMember, { member, member } from "module-6";

import defaultMember, * as name from "module-7";

import "module-8";

import "module-9" // comment no problem

import {
AAAA,
// BBB
} from 'module-10';

import "module-b' // doesn't match -> the opening and closing quation mark are different

importing hya from 'ttt'

import fbsfrom ''


// Export expressions.
export { aaa };

export * from "module-11";

export { aaa } from "module-12";

// Should not be parsed
export default aaa;

export function bbb () {
};
`

module.exports.runTest = function () {
const expected = [
'./videos/index.js',
'./test/okbb',
'obb',
'@angular2/core',
'module-0',
'module-1',
'module-2',
'module-3',
'module-4',
'module-5',
'module-6',
'module-7',
'module-8',
'module-9',
'module-10',
'module-11',
'module-12'
]
let cursor = 0;
module.exports.transformImport(testCases, (moduleName) => {
if (expected[cursor] !== moduleName) {
throw new Error(`Expected ${expected[cursor]}. Actual ${moduleName}`);
}
cursor++;
return moduleName;
})
if (cursor !== expected.length) {
throw new Error('Test failed');
}
console.log('All test passed!')
}

// module.exports.runTest();
4 changes: 2 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './lib/zrender';
export * from './lib/export';
export * from './src/zrender';
export * from './src/export';
9 changes: 1 addition & 8 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
export * from './lib/zrender';
export * from './lib/export';

import {registerPainter} from './lib/zrender';
import CanvasPainter from './lib/canvas/Painter';
import SVGPainter from './lib/svg/Painter';
registerPainter('canvas', CanvasPainter);
registerPainter('svg', SVGPainter);
export * from './lib/all.js'
10 changes: 1 addition & 9 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
export * from './src/zrender';
export * from './src/export';

import {registerPainter} from './src/zrender';
import CanvasPainter from './src/canvas/Painter';
import SVGPainter from './src/svg/Painter';
registerPainter('canvas', CanvasPainter);
registerPainter('svg', SVGPainter);
// import './src/vml/vml';
export * from './lib/all';
Loading