From ed308815bad9095295a649d85bb18b0a6f9fc370 Mon Sep 17 00:00:00 2001 From: Zhongxiang Wang Date: Fri, 7 Nov 2025 23:23:22 +0800 Subject: [PATCH 1/2] fix(workflow): fix match pattern for changed files collection in the lint action --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b71d1386d..ea1ce3e8b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,7 @@ jobs: - name: Collect changed files run: | mkdir ~/tmp/ - git diff ${{ github.event.pull_request.base.sha }} ${{ github.sha }} --diff-filter=ACM --name-only --relative '*src/**/*.ts' > ~/tmp/changed_files + git diff ${{ github.event.pull_request.base.sha }} ${{ github.sha }} --diff-filter=ACM --name-only --relative '*src/*.ts' '*src/**/*.ts' > ~/tmp/changed_files echo -e "Changed files: \n$(cat ~/tmp/changed_files)" - name: Lint From 4df3af4caa6f138d318caa01c39a2e8b5c01a383 Mon Sep 17 00:00:00 2001 From: plainheart Date: Sat, 23 Nov 2024 18:01:44 +0800 Subject: [PATCH 2/2] fix(svg): enhance svg encodeBase64 compatibility --- src/svg/helper.ts | 11 +++++------ test/svg-ssr.html | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/src/svg/helper.ts b/src/svg/helper.ts index c8eaa2b84..f435c498c 100644 --- a/src/svg/helper.ts +++ b/src/svg/helper.ts @@ -2,7 +2,7 @@ import { MatrixArray } from '../core/matrix'; import Transformable, { TransformProp } from '../core/Transformable'; -import { RADIAN_TO_DEGREE, retrieve2, logError, isFunction } from '../core/util'; +import { RADIAN_TO_DEGREE, retrieve2, logError } from '../core/util'; import Displayable from '../graphic/Displayable'; import { GradientObject } from '../graphic/Gradient'; import { LinearGradientObject } from '../graphic/LinearGradient'; @@ -10,7 +10,6 @@ import Path from '../graphic/Path'; import { ImagePatternObject, PatternObject, SVGPatternObject } from '../graphic/Pattern'; import { RadialGradientObject } from '../graphic/RadialGradient'; import { parse } from '../tool/color'; -import env from '../core/env'; const mathRound = Math.round; @@ -173,14 +172,14 @@ export function getSRTTransformString( } export const encodeBase64 = (function () { - if (env.hasGlobalWindow && isFunction(window.btoa)) { + if (typeof Buffer !== 'undefined' && typeof Buffer.from === 'function') { return function (str: string) { - return window.btoa(unescape(encodeURIComponent(str))); + return Buffer.from(str).toString('base64'); }; } - if (typeof Buffer !== 'undefined') { + if (typeof btoa === 'function' && typeof unescape === 'function' && typeof encodeURIComponent === 'function') { return function (str: string) { - return Buffer.from(str).toString('base64'); + return btoa(unescape(encodeURIComponent(str))); }; } return function (str: string): string { diff --git a/test/svg-ssr.html b/test/svg-ssr.html index bad5ad70b..63ab01eb8 100644 --- a/test/svg-ssr.html +++ b/test/svg-ssr.html @@ -268,6 +268,38 @@ document.getElementById('main').innerHTML = svg; console.timeEnd('render'); + // base64 + console.log('window SSR base64:'); + console.log(zr.painter.toDataURL(true)); + + // worker base64 + const workerSource = ` + importScripts('${location.origin}/dist/zrender.js') + const zr = zrender.init(null, { + renderer: 'svg', + ssr: true, + width: 1200, + height: 1200 + }); + const el = new zrender.Circle({ + x: 50, + y: 50, + shape: { + cx: 0, + cy: 0, + r: 25 + }, + style: { + fill: 'red' + } + }); + zr.add(el); + console.log('worker SSR base64:'); + console.log(zr.painter.toDataURL(true)); + zr.dispose(); + `; + new Worker(URL.createObjectURL(new Blob([workerSource], { type: 'application/javascript' }))); + // var blob = new Blob([svg], { type: 'image/svg+xml' }); // var a = document.createElement('a'); // a.download = 'aaa.svg';