From 3835bfa59daac31e35fb260acb841885c03f1739 Mon Sep 17 00:00:00 2001 From: "lixuefei.1313" Date: Mon, 6 Jul 2026 16:42:09 +0800 Subject: [PATCH 1/6] ci: remove BytePack smoke from release workflow --- .github/workflows/release.yml | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bc29ec8978..f3658441d3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -342,13 +342,6 @@ jobs: with: path: packages/vchart - - name: BytePack CDN smoke test (release) - if: startsWith(github.ref_name, 'release/') - env: - BYTEPACK_SMOKE_ATTEMPTS: 12 - BYTEPACK_SMOKE_DELAY_MS: 30000 - run: node --experimental-network-imports common/scripts/bytepack-smoke-test.mjs ${{ steps.package_version_release.outputs.current_version }} - - name: Commit & Push changes (release) if: startsWith(github.ref_name, 'release/') run: | @@ -414,13 +407,6 @@ jobs: with: path: packages/vchart - - name: BytePack CDN smoke test (hotfix) - if: startsWith(github.ref_name, 'hotfix/') - env: - BYTEPACK_SMOKE_ATTEMPTS: 12 - BYTEPACK_SMOKE_DELAY_MS: 30000 - run: node --experimental-network-imports common/scripts/bytepack-smoke-test.mjs ${{ steps.package_version_hotfix.outputs.current_version }} - - name: Commit & Push changes (hotfix) if: startsWith(github.ref_name, 'hotfix/') run: | @@ -458,13 +444,6 @@ jobs: with: path: packages/vchart - - name: BytePack CDN smoke test (pre-release) - if: startsWith(github.ref_name, 'pre-release/') - env: - BYTEPACK_SMOKE_ATTEMPTS: 12 - BYTEPACK_SMOKE_DELAY_MS: 30000 - run: node --experimental-network-imports common/scripts/bytepack-smoke-test.mjs ${{ steps.package_version_prerelease.outputs.current_version }} - - name: Commit & Push changes (pre-release) if: startsWith(github.ref_name, 'pre-release/') run: | From 9b4e042769577eff4400f41eb524b402da729017 Mon Sep 17 00:00:00 2001 From: "lixuefei.1313" Date: Mon, 6 Jul 2026 16:42:24 +0800 Subject: [PATCH 2/6] fix: stabilize BytePack VRender integration --- common/config/rush/pnpm-lock.yaml | 196 +++++++++--------- docs/package.json | 4 +- packages/openinula-vchart/package.json | 4 +- packages/react-vchart/package.json | 4 +- .../__tests__/runtime/browser/vite.config.js | 2 + packages/vchart-extension/package.json | 8 +- .../vchart-extension/src/charts/3d/arc-3d.ts | 5 +- .../src/charts/3d/graphic-creator.ts | 1 + .../vchart-extension/src/charts/3d/plugin.ts | 6 +- .../src/charts/3d/pyramid-3d.ts | 5 +- .../vchart-extension/src/charts/3d/rect-3d.ts | 5 +- .../src/charts/pie-3d/chart.ts | 2 + packages/vchart-extension/tsconfig.json | 6 +- .../tooltip/dom-tooltip-handler.test.ts | 64 ++++++ packages/vchart/bundler.config.js | 26 +++ packages/vchart/package.json | 10 +- packages/vchart/src/animation/index.ts | 3 +- .../vchart/src/animation/state-transition.ts | 2 +- packages/vchart/src/chart/util.ts | 2 +- packages/vchart/src/compile/compiler.ts | 2 +- .../src/component/axis/cartesian/axis.ts | 2 +- .../src/component/base/base-component.ts | 3 +- packages/vchart/src/component/label/util.ts | 2 +- .../tooltip/processor/mark-tooltip.ts | 2 +- .../component/tooltip/tooltip-transformer.ts | 2 +- packages/vchart/src/core/factory-registry.ts | 89 ++++++++ packages/vchart/src/core/factory.ts | 56 +++-- packages/vchart/src/core/index.ts | 4 +- packages/vchart/src/core/vchart.ts | 2 +- packages/vchart/src/env/env.ts | 2 +- packages/vchart/src/index-harmony-simple.ts | 2 +- packages/vchart/src/index-harmony.ts | 2 +- packages/vchart/src/index.ts | 28 +-- packages/vchart/src/mark/arc.ts | 4 +- packages/vchart/src/mark/area.ts | 4 +- packages/vchart/src/mark/base/base-mark.ts | 2 +- packages/vchart/src/mark/box-plot.ts | 5 +- packages/vchart/src/mark/cell.ts | 4 +- packages/vchart/src/mark/glyph.ts | 4 +- packages/vchart/src/mark/group.ts | 3 +- packages/vchart/src/mark/image.ts | 4 +- packages/vchart/src/mark/line.ts | 4 +- packages/vchart/src/mark/link-path.ts | 3 +- packages/vchart/src/mark/liquid.ts | 4 +- packages/vchart/src/mark/path.ts | 4 +- packages/vchart/src/mark/polygon/polygon.ts | 4 +- packages/vchart/src/mark/rect.ts | 4 +- packages/vchart/src/mark/ripple.ts | 4 +- packages/vchart/src/mark/rule.ts | 4 +- packages/vchart/src/mark/symbol.ts | 4 +- packages/vchart/src/mark/text.ts | 5 +- .../tooltip-handler/dom-tooltip-handler.ts | 38 +++- .../tooltip-handler/utils/attribute.ts | 2 +- .../components/tooltip-handler/utils/svg.ts | 3 +- packages/vchart/src/plugin/other.ts | 4 +- packages/vchart/src/series/bar/bar.ts | 2 +- .../vchart/src/series/box-plot/animation.ts | 3 +- packages/vchart/src/series/liquid/liquid.ts | 2 +- packages/vchart/src/series/polar/animation.ts | 3 +- .../polar/progress-like/progress-like.ts | 2 +- packages/vchart/src/series/radar/animation.ts | 5 +- .../vchart/src/series/sankey/animation.ts | 3 +- packages/vchart/src/series/venn/animation.ts | 3 +- packages/vchart/src/series/word-cloud/base.ts | 3 +- packages/vchart/src/util/env.ts | 2 +- packages/vchart/src/vrender-bridge.ts | 132 ++++++++++++ packages/vchart/src/vrender-tools.ts | 2 +- packages/vchart/tsconfig.json | 1 + tools/bundler/src/bootstrap.ts | 28 ++- tools/bundler/src/logic/config.ts | 7 +- tools/bundler/src/logic/rollup.config.ts | 7 +- tools/story-player/package.json | 6 +- 72 files changed, 617 insertions(+), 264 deletions(-) create mode 100644 packages/vchart-extension/src/charts/3d/graphic-creator.ts create mode 100644 packages/vchart/__tests__/unit/component/tooltip/dom-tooltip-handler.test.ts create mode 100644 packages/vchart/src/core/factory-registry.ts create mode 100644 packages/vchart/src/vrender-bridge.ts diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index dd25304271..686ad63f0f 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -37,11 +37,11 @@ importers: specifier: 1.2.4-alpha.5 version: 1.2.4-alpha.5 '@visactor/vrender': - specifier: ^1.1.3 - version: 1.1.3 + specifier: ~1.1.4 + version: 1.1.4 '@visactor/vrender-kits': - specifier: ^1.1.3 - version: 1.1.3 + specifier: ~1.1.4 + version: 1.1.4 '@visactor/vtable': specifier: 1.19.0-alpha.0 version: 1.19.0-alpha.0 @@ -203,11 +203,11 @@ importers: specifier: workspace:2.1.1 version: link:../vchart '@visactor/vrender-core': - specifier: ^1.1.3 - version: 1.1.3 + specifier: ~1.1.4 + version: 1.1.4 '@visactor/vrender-kits': - specifier: ^1.1.3 - version: 1.1.3 + specifier: ~1.1.4 + version: 1.1.4 '@visactor/vutils': specifier: ~1.0.23 version: 1.0.23 @@ -294,11 +294,11 @@ importers: specifier: workspace:2.1.1 version: link:../vchart-extension '@visactor/vrender-core': - specifier: ^1.1.3 - version: 1.1.3 + specifier: ~1.1.4 + version: 1.1.4 '@visactor/vrender-kits': - specifier: ^1.1.3 - version: 1.1.3 + specifier: ~1.1.4 + version: 1.1.4 '@visactor/vutils': specifier: ~1.0.23 version: 1.0.23 @@ -529,20 +529,20 @@ importers: specifier: ~1.0.23 version: 1.0.23 '@visactor/vrender': - specifier: ^1.1.3 - version: 1.1.3 + specifier: ~1.1.4 + version: 1.1.4 '@visactor/vrender-animate': - specifier: ^1.1.3 - version: 1.1.3 + specifier: ~1.1.4 + version: 1.1.4 '@visactor/vrender-components': - specifier: ^1.1.3 - version: 1.1.3 + specifier: ~1.1.4 + version: 1.1.4 '@visactor/vrender-core': - specifier: ^1.1.3 - version: 1.1.3 + specifier: ~1.1.4 + version: 1.1.4 '@visactor/vrender-kits': - specifier: ^1.1.3 - version: 1.1.3 + specifier: ~1.1.4 + version: 1.1.4 '@visactor/vscale': specifier: ~1.0.23 version: 1.0.23 @@ -695,17 +695,17 @@ importers: specifier: ~1.0.23 version: 1.0.23 '@visactor/vrender-animate': - specifier: ^1.1.3 - version: 1.1.3 + specifier: ~1.1.4 + version: 1.1.4 '@visactor/vrender-components': - specifier: ^1.1.3 - version: 1.1.3 + specifier: ~1.1.4 + version: 1.1.4 '@visactor/vrender-core': - specifier: ^1.1.3 - version: 1.1.3 + specifier: ~1.1.4 + version: 1.1.4 '@visactor/vrender-kits': - specifier: ^1.1.3 - version: 1.1.3 + specifier: ~1.1.4 + version: 1.1.4 '@visactor/vutils': specifier: ~1.0.23 version: 1.0.23 @@ -1263,14 +1263,14 @@ importers: specifier: workspace:2.1.1 version: link:../../packages/vchart '@visactor/vrender': - specifier: ^1.1.3 - version: 1.1.3 + specifier: ~1.1.4 + version: 1.1.4 '@visactor/vrender-core': - specifier: ^1.1.3 - version: 1.1.3 + specifier: ~1.1.4 + version: 1.1.4 '@visactor/vrender-kits': - specifier: ^1.1.3 - version: 1.1.3 + specifier: ~1.1.4 + version: 1.1.4 '@visactor/vutils': specifier: ~1.0.23 version: 1.0.23 @@ -2942,8 +2942,8 @@ packages: '@types/unist@2.0.11': resolution: {integrity: sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA==} - '@types/vinyl-fs@3.0.7': - resolution: {integrity: sha512-ojGFhBnh5pj5Crf2yBOk3rjJXUX2U4W9z6tZ7hn6pUbQa/J8KH8NrXem0POYVQWI3ifnx4T65DPktuWfxc3iiA==} + '@types/vinyl-fs@3.0.8': + resolution: {integrity: sha512-L36QEbDQVv5zaPawqqjrpOOR03BIK3iQ4wa2Rrk376CER8Vbu0Ao8XPNhjM14anStU28solakJLThY7GPp40Jw==} '@types/vinyl@2.0.7': resolution: {integrity: sha512-4UqPv+2567NhMQuMLdKAyK4yzrfCqwaTt6bLhHEs8PFcxbHILsrxaY63n4wgE/BRLDWDQeI+WcTmkXKExh9hQg==} @@ -3079,29 +3079,29 @@ packages: '@visactor/vrender-animate@1.0.0-alpha.18': resolution: {integrity: sha512-9kTtvp1ef+1t+AtUiza6A7qBQP7SmvOu3/ILGrqs/HGdZVj1XGjbYvD/X/zwKJ3LEb7gGV5fa8x95e4czTvRSA==} - '@visactor/vrender-animate@1.1.3': - resolution: {integrity: sha512-uqm0ihI+0dIGxMvvoDUbK6a1ifSTIXWjJmyLYOO3vldcmtvzbokaDk44h3RT9l+NwwswxO6TtTRykmBZZ6Ql+Q==} + '@visactor/vrender-animate@1.1.4': + resolution: {integrity: sha512-XBaCXMLSNw9E+htAEaqjby28mdINyVokNkLjKJ/ukmGobi3XX8siekXTNzCfe9M9UG4QGRTqyph848sxLB02Tw==} '@visactor/vrender-components@1.0.0-alpha.18': resolution: {integrity: sha512-7Euq+ZfswL74n2pgkaqZSsPxoSa5SPIGyXatN1eUrdzM2Z0kX6U0RcJg01fctvRs4op6WhcecRLqGvnHcBeb9Q==} - '@visactor/vrender-components@1.1.3': - resolution: {integrity: sha512-l5O9sUXF99V3b4t2swfgD91VxdmPB/t5SQGz/cMl7nyecuBU6IK0kVDzp1OC3G35nxYxCGp3S1IHT6Qk8K+Ndw==} + '@visactor/vrender-components@1.1.4': + resolution: {integrity: sha512-N1bnIuefe6Lms7Ij8NGjKfNUYQpZ+M8RYsnjBR2So0wmnxAnXUTgqbpWDT9DiXzRF17qYSkF0HZJIdS/wN2o3Q==} '@visactor/vrender-core@1.0.0-alpha.18': resolution: {integrity: sha512-0ihtNvCyNkOsWPFgRqowHzq0IcQgS2Wl/nPpKbVtxWKveenwlhA+ZKoQvam6VJyBY7jeNe1pROy0mJMDyVAJQw==} - '@visactor/vrender-core@1.1.3': - resolution: {integrity: sha512-6vsx0J5wX/QHfBk8cJ9o2/QVoodUYyjYCWJR+SuSLzldWXsV6+e1Lyrh2lFmwZvdSzz69FlwSMYcQ5i/IZ6OVQ==} + '@visactor/vrender-core@1.1.4': + resolution: {integrity: sha512-AyMKFohr/iK1Wc5jxvE/04MLcFI0VAR5qleDy+b2WwLi7UoeXn0tBhtzz72xIOKU1OrzvmflWsVmdnlh6ittwg==} '@visactor/vrender-kits@1.0.0-alpha.18': resolution: {integrity: sha512-Tvolkq+4G8qiPFZo0Aj8M//Yr6jR2h8FNkFEyWM9gbQbEiTkjpmHAJOYnoSsaPtPrcMSlG4EhJSFDk6ymANHVg==} - '@visactor/vrender-kits@1.1.3': - resolution: {integrity: sha512-Nw+JjBhtNQLUYZCs8KBpf5CHNM2FzrKFsNPTzry5+Qphj4hfpbGr0CsUeIZuVkwRRYEYAgqycINxdZEPsPvpgA==} + '@visactor/vrender-kits@1.1.4': + resolution: {integrity: sha512-YD1y2TWh5yl6AzpW47HPcYogk0d6KntuwUrGocXqSkLXwzsGnYntE9RvAEGTu4ketdeahh+8/0w34d6BU0Hzig==} - '@visactor/vrender@1.1.3': - resolution: {integrity: sha512-Ccu8erRCvDtHdSN5+VQqGUOSg7Cw37FqiQ6RlkZGzVi47DjOqgUy7AVW9r9lPm8ogDb/z5oAQStgIoFm3Nyeng==} + '@visactor/vrender@1.1.4': + resolution: {integrity: sha512-+T09pS5EJ2HizxMCa3r8MuvgcWnoJpGUK2ykLZLcR6w+5kfpfbu2B8uQzetTOKn1CVIhDbuO05monfI7mCYGQA==} '@visactor/vscale@0.18.18': resolution: {integrity: sha512-iRG4kv+5Fv4KX3AxEfV95XU3I6OmF0QizyAhqHxKa7L1MaT+MRvDDk5zHWf1E8gialLbL2xDe3GnT6g/4u5jhA==} @@ -4053,8 +4053,8 @@ packages: resolution: {integrity: sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==} engines: {node: '>=0.10.0'} - baseline-browser-mapping@2.10.40: - resolution: {integrity: sha512-BSSLZ9/Cjjv7Gtj5B68ZzXcXUg8iOf3fme+FCuh8rC/Go+Kmh8cox7M3A8dolou16s64QjLPOSdngh7GxXvkSw==} + baseline-browser-mapping@2.10.42: + resolution: {integrity: sha512-c/jurFrDLyui7o1J86yLkRu4LMsTYcBohveus7/I2Hzdn9KIP2bdJPTue/lR1KH46enoPbD77GKeSYNdyPoD3Q==} engines: {node: '>=6.0.0'} hasBin: true @@ -4362,8 +4362,8 @@ packages: camelize@1.0.1: resolution: {integrity: sha512-dU+Tx2fsypxTgtLoE36npi3UqcjSSMNYfkqgmoEhtZrraP5VWq0K7FkWVTYa8eMPtnU/G2txVsfdCJTn9uzpuQ==} - caniuse-lite@1.0.30001799: - resolution: {integrity: sha512-hG1bReV+OUU+MOqK4t/ZWI0tZOyz3rqS9XuhOUz1cIcbwBKjOyJEJuw9ER5JuNyqxNk8u/JUVbGibBOL1yrjFw==} + caniuse-lite@1.0.30001800: + resolution: {integrity: sha512-MMHtuAz9Ys840zAY5F4k6fV5GaivZ9sPk+nz0mY+GYVzRBnYkN0mpqkSR92oWRQ19yQWo4HvBV/FnC16AJX8MA==} canvas@2.11.2: resolution: {integrity: sha512-ItanGBMrmRV7Py2Z+Xhs7cT+FNt5K0vPL4p9EZ/UX/Mu7hFbkxSjKF2KVtPwX7UYWp7dRKnrTvReflgrItJbdw==} @@ -5439,8 +5439,8 @@ packages: engines: {node: '>=0.10.0'} hasBin: true - electron-to-chromium@1.5.381: - resolution: {integrity: sha512-n9Wa6yB+vDsGuA8AKbl/0z7HbvWqt5jxIdvr1IUicd0ryPrk7/xzwqLv8D9AbbvZ6avVNtXYLTfmgFHkwkyelg==} + electron-to-chromium@1.5.387: + resolution: {integrity: sha512-TaxwufTFDufvPEoXdhwVrA3UdFWBeWGkYoJ1K8ldF1xe6gKfth6iRNS5lTQ5JPNOHdGQm8PT1QYKUqFLCiUefQ==} electron@11.5.0: resolution: {integrity: sha512-WjNDd6lGpxyiNjE3LhnFCAk/D9GIj1rU3GSDealVShhkkkPR3Vh4q8ErXGDl1OAO/faomVa10KoFPUN/pLbNxg==} @@ -5745,8 +5745,8 @@ packages: eslint-import-resolver-node@0.3.10: resolution: {integrity: sha512-tRrKqFyCaKict5hOd244sL6EQFNycnMQnBe+j8uqGNXYzsImGbGUU4ibtoaBmv5FLwJwcFJNeg1GeVjQfbMrDQ==} - eslint-module-utils@2.13.0: - resolution: {integrity: sha512-bLohSkT6469rRs8czj0tLTD8vaeIS/whvPRJVjDr7IuoTT1k5DYDERlNycjDj/HkOlvQdYurmfZ/g3fG5bgeLQ==} + eslint-module-utils@2.14.0: + resolution: {integrity: sha512-W2WCRZ9Dqntd+2u8jJcVMV2PKulc6RdLgUUoh/yQr3uB6lo/ZOeGx11sv60/8S4QFFKNslAlWhr9u0Ef7ZW6Ig==} engines: {node: '>=4'} peerDependencies: eslint: '*' @@ -9391,8 +9391,8 @@ packages: resolution: {integrity: sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==} engines: {node: '>=8.6'} - picomatch@4.0.4: - resolution: {integrity: sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==} + picomatch@4.0.5: + resolution: {integrity: sha512-RvwwcruNjI1ncT5xRakeyS9Lf8lcItv34KD+aif+VH9kduAyfYBipGh12274xtenIPZ119/R9BdTBa8gAwSh0A==} engines: {node: '>=12'} pidtree@0.5.0: @@ -10695,8 +10695,8 @@ packages: simple-get@3.1.1: resolution: {integrity: sha512-CQ5LTKGfCpvE1K0n2us+kuMPbk/q0EKl82s4aheV9oXjFEz6W/Y7oQFVJuU6QG77hRT4Ghb5RURteF5vnWjupA==} - simple-statistics@7.9.1: - resolution: {integrity: sha512-F2KqbV8mNYuARZdIuKtqv8Ax0s5KLKy9kEsaAFnKJxkTU+ZjmBae5ssp6mtPqpAj+D29OITOSbm9aiSkEPo1cA==} + simple-statistics@7.9.3: + resolution: {integrity: sha512-WXpxUfo7BJCRpyl4besiuMV7wNj9xiPIq7IKmUQO4upIaF8pK2AXwhjttHN5L8KXZrLkGMCHGHq4p+pJXiIahQ==} simple-swizzle@0.2.4: resolution: {integrity: sha512-nAu1WFPQSMNr2Zn9PGSZK9AGn4t/y97lEm+MXTtUDwfP0ksAIX4nO+6ruD9Jwut4C49SB1Ws+fbXsm/yScWOHw==} @@ -14031,7 +14031,7 @@ snapshots: dependencies: '@types/estree': 1.0.9 estree-walker: 2.0.2 - picomatch: 4.0.4 + picomatch: 4.0.5 optionalDependencies: rollup: 3.20.5 @@ -14643,7 +14643,7 @@ snapshots: '@types/gulp@4.0.10': dependencies: '@types/undertaker': 1.2.8 - '@types/vinyl-fs': 3.0.7 + '@types/vinyl-fs': 3.0.8 chokidar: 3.6.0 '@types/highlightjs@9.12.6': {} @@ -14792,7 +14792,7 @@ snapshots: '@types/unist@2.0.11': {} - '@types/vinyl-fs@3.0.7': + '@types/vinyl-fs@3.0.8': dependencies: '@types/glob-stream': 8.0.3 '@types/node': 20.14.10 @@ -14973,7 +14973,7 @@ snapshots: path-browserify: 1.0.1 pbf: 3.3.0 point-at-length: 1.1.0 - simple-statistics: 7.9.1 + simple-statistics: 7.9.3 simplify-geojson: 1.0.5 topojson-client: 3.1.0 @@ -14993,7 +14993,7 @@ snapshots: path-browserify: 1.0.1 pbf: 3.3.0 point-at-length: 1.1.0 - simple-statistics: 7.9.1 + simple-statistics: 7.9.3 simplify-geojson: 1.0.5 topojson-client: 3.1.0 @@ -15013,7 +15013,7 @@ snapshots: path-browserify: 1.0.1 pbf: 3.3.0 point-at-length: 1.1.0 - simple-statistics: 7.9.1 + simple-statistics: 7.9.3 simplify-geojson: 1.0.5 topojson-client: 3.1.0 @@ -15047,9 +15047,9 @@ snapshots: '@visactor/vrender-core': 1.0.0-alpha.18 '@visactor/vutils': 1.0.4 - '@visactor/vrender-animate@1.1.3': + '@visactor/vrender-animate@1.1.4': dependencies: - '@visactor/vrender-core': 1.1.3 + '@visactor/vrender-core': 1.1.4 '@visactor/vutils': 1.0.23 '@visactor/vrender-components@1.0.0-alpha.18': @@ -15060,11 +15060,11 @@ snapshots: '@visactor/vscale': 1.0.4 '@visactor/vutils': 1.0.4 - '@visactor/vrender-components@1.1.3': + '@visactor/vrender-components@1.1.4': dependencies: - '@visactor/vrender-animate': 1.1.3 - '@visactor/vrender-core': 1.1.3 - '@visactor/vrender-kits': 1.1.3 + '@visactor/vrender-animate': 1.1.4 + '@visactor/vrender-core': 1.1.4 + '@visactor/vrender-kits': 1.1.4 '@visactor/vscale': 1.0.23 '@visactor/vutils': 1.0.23 @@ -15073,7 +15073,7 @@ snapshots: '@visactor/vutils': 1.0.4 color-convert: 2.0.1 - '@visactor/vrender-core@1.1.3': + '@visactor/vrender-core@1.1.4': dependencies: '@visactor/vutils': 1.0.23 color-convert: 2.0.1 @@ -15087,21 +15087,21 @@ snapshots: lottie-web: 5.13.0 roughjs: 4.5.2 - '@visactor/vrender-kits@1.1.3': + '@visactor/vrender-kits@1.1.4': dependencies: '@resvg/resvg-js': 2.4.1 - '@visactor/vrender-core': 1.1.3 + '@visactor/vrender-core': 1.1.4 '@visactor/vutils': 1.0.23 gifuct-js: 2.1.2 lottie-web: 5.13.0 roughjs: 4.6.6 - '@visactor/vrender@1.1.3': + '@visactor/vrender@1.1.4': dependencies: - '@visactor/vrender-animate': 1.1.3 - '@visactor/vrender-components': 1.1.3 - '@visactor/vrender-core': 1.1.3 - '@visactor/vrender-kits': 1.1.3 + '@visactor/vrender-animate': 1.1.4 + '@visactor/vrender-components': 1.1.4 + '@visactor/vrender-core': 1.1.4 + '@visactor/vrender-kits': 1.1.4 '@visactor/vscale@0.18.18': dependencies: @@ -15887,7 +15887,7 @@ snapshots: autoprefixer@10.4.13(postcss@8.4.21): dependencies: browserslist: 4.28.4 - caniuse-lite: 1.0.30001799 + caniuse-lite: 1.0.30001800 fraction.js: 4.3.7 normalize-range: 0.1.2 picocolors: 1.1.1 @@ -15897,7 +15897,7 @@ snapshots: autoprefixer@8.6.5: dependencies: browserslist: 3.2.8 - caniuse-lite: 1.0.30001799 + caniuse-lite: 1.0.30001800 normalize-range: 0.1.2 num2fraction: 1.2.2 postcss: 6.0.23 @@ -15906,7 +15906,7 @@ snapshots: autoprefixer@9.7.4: dependencies: browserslist: 4.28.4 - caniuse-lite: 1.0.30001799 + caniuse-lite: 1.0.30001800 chalk: 2.4.2 normalize-range: 0.1.2 num2fraction: 1.2.2 @@ -15916,7 +15916,7 @@ snapshots: autoprefixer@9.8.8: dependencies: browserslist: 4.28.4 - caniuse-lite: 1.0.30001799 + caniuse-lite: 1.0.30001800 normalize-range: 0.1.2 num2fraction: 1.2.2 picocolors: 0.2.1 @@ -16400,7 +16400,7 @@ snapshots: mixin-deep: 1.3.2 pascalcase: 0.1.1 - baseline-browser-mapping@2.10.40: {} + baseline-browser-mapping@2.10.42: {} batch@0.6.1: {} @@ -16593,14 +16593,14 @@ snapshots: browserslist@3.2.8: dependencies: - caniuse-lite: 1.0.30001799 - electron-to-chromium: 1.5.381 + caniuse-lite: 1.0.30001800 + electron-to-chromium: 1.5.387 browserslist@4.28.4: dependencies: - baseline-browser-mapping: 2.10.40 - caniuse-lite: 1.0.30001799 - electron-to-chromium: 1.5.381 + baseline-browser-mapping: 2.10.42 + caniuse-lite: 1.0.30001800 + electron-to-chromium: 1.5.387 node-releases: 2.0.50 update-browserslist-db: 1.2.3(browserslist@4.28.4) @@ -16815,7 +16815,7 @@ snapshots: camelize@1.0.1: {} - caniuse-lite@1.0.30001799: {} + caniuse-lite@1.0.30001800: {} canvas@2.11.2(encoding@0.1.13): dependencies: @@ -18089,7 +18089,7 @@ snapshots: dependencies: jake: 10.9.4 - electron-to-chromium@1.5.381: {} + electron-to-chromium@1.5.387: {} electron@11.5.0: dependencies: @@ -18430,13 +18430,13 @@ snapshots: is-core-module: 2.16.2 resolve: 2.0.0-next.7 - eslint-module-utils@2.13.0(eslint@6.8.0): + eslint-module-utils@2.14.0(eslint@6.8.0): dependencies: debug: 3.2.7 optionalDependencies: eslint: 6.8.0 - eslint-module-utils@2.13.0(eslint@8.18.0): + eslint-module-utils@2.14.0(eslint@8.18.0): dependencies: debug: 3.2.7 optionalDependencies: @@ -18453,7 +18453,7 @@ snapshots: doctrine: 2.1.0 eslint: 6.8.0 eslint-import-resolver-node: 0.3.10 - eslint-module-utils: 2.13.0(eslint@6.8.0) + eslint-module-utils: 2.14.0(eslint@6.8.0) hasown: 2.0.4 is-core-module: 2.16.2 is-glob: 4.0.3 @@ -18476,7 +18476,7 @@ snapshots: doctrine: 2.1.0 eslint: 8.18.0 eslint-import-resolver-node: 0.3.10 - eslint-module-utils: 2.13.0(eslint@8.18.0) + eslint-module-utils: 2.14.0(eslint@8.18.0) hasown: 2.0.4 is-core-module: 2.16.2 is-glob: 4.0.3 @@ -23356,7 +23356,7 @@ snapshots: picomatch@2.3.2: {} - picomatch@4.0.4: {} + picomatch@4.0.5: {} pidtree@0.5.0: {} @@ -24895,7 +24895,7 @@ snapshots: once: 1.4.0 simple-concat: 1.0.1 - simple-statistics@7.9.1: {} + simple-statistics@7.9.3: {} simple-swizzle@0.2.4: dependencies: diff --git a/docs/package.json b/docs/package.json index 5f21c55fe5..3c27e73266 100644 --- a/docs/package.json +++ b/docs/package.json @@ -19,8 +19,8 @@ "@visactor/vchart-theme": "~1.6.6", "@visactor/vmind": "1.2.4-alpha.5", "@visactor/vutils": "~1.0.23", - "@visactor/vrender": "^1.1.3", - "@visactor/vrender-kits": "^1.1.3", + "@visactor/vrender": "~1.1.4", + "@visactor/vrender-kits": "~1.1.4", "@visactor/vtable": "1.19.0-alpha.0", "@visactor/vtable-editors": "1.19.0-alpha.0", "@visactor/vtable-gantt": "1.19.0-alpha.0", diff --git a/packages/openinula-vchart/package.json b/packages/openinula-vchart/package.json index f9df7e877f..454d5570ff 100644 --- a/packages/openinula-vchart/package.json +++ b/packages/openinula-vchart/package.json @@ -30,8 +30,8 @@ "dependencies": { "@visactor/vchart": "workspace:2.1.1", "@visactor/vutils": "~1.0.23", - "@visactor/vrender-core": "^1.1.3", - "@visactor/vrender-kits": "^1.1.3", + "@visactor/vrender-core": "~1.1.4", + "@visactor/vrender-kits": "~1.1.4", "react-is": "^18.2.0" }, "devDependencies": { diff --git a/packages/react-vchart/package.json b/packages/react-vchart/package.json index 15f5ae3b07..99a61dc7a0 100644 --- a/packages/react-vchart/package.json +++ b/packages/react-vchart/package.json @@ -36,8 +36,8 @@ "@visactor/vchart": "workspace:2.1.1", "@visactor/vchart-extension": "workspace:2.1.1", "@visactor/vutils": "~1.0.23", - "@visactor/vrender-core": "^1.1.3", - "@visactor/vrender-kits": "^1.1.3", + "@visactor/vrender-core": "~1.1.4", + "@visactor/vrender-kits": "~1.1.4", "react-is": "^18.2.0" }, "devDependencies": { diff --git a/packages/vchart-extension/__tests__/runtime/browser/vite.config.js b/packages/vchart-extension/__tests__/runtime/browser/vite.config.js index ad4c250691..23865ed036 100644 --- a/packages/vchart-extension/__tests__/runtime/browser/vite.config.js +++ b/packages/vchart-extension/__tests__/runtime/browser/vite.config.js @@ -44,6 +44,8 @@ export default { ...localConf?.resolve, alias: { ...localConf?.resolve?.alias, + '@visactor/vchart/esm': path.resolve(__dirname, '../../../../vchart/src'), + '@visactor/vchart/src': path.resolve(__dirname, '../../../../vchart/src'), '@visactor/vutils-extension': path.resolve(__dirname, '../../../../vutils-extension/src/index.ts'), '@visactor/vchart': path.resolve(__dirname, '../../../../vchart/src/index.ts') } diff --git a/packages/vchart-extension/package.json b/packages/vchart-extension/package.json index cf23dd94c7..ed28298718 100644 --- a/packages/vchart-extension/package.json +++ b/packages/vchart-extension/package.json @@ -26,10 +26,10 @@ "start": "ts-node __tests__/runtime/browser/scripts/initVite.ts && vite serve __tests__/runtime/browser" }, "dependencies": { - "@visactor/vrender-core": "^1.1.3", - "@visactor/vrender-kits": "^1.1.3", - "@visactor/vrender-components": "^1.1.3", - "@visactor/vrender-animate": "^1.1.3", + "@visactor/vrender-core": "~1.1.4", + "@visactor/vrender-kits": "~1.1.4", + "@visactor/vrender-components": "~1.1.4", + "@visactor/vrender-animate": "~1.1.4", "@visactor/vchart": "workspace:2.1.1", "@visactor/vutils": "~1.0.23", "@visactor/vdataset": "~1.0.23", diff --git a/packages/vchart-extension/src/charts/3d/arc-3d.ts b/packages/vchart-extension/src/charts/3d/arc-3d.ts index 6ca8ea4aea..8c042f64f6 100644 --- a/packages/vchart-extension/src/charts/3d/arc-3d.ts +++ b/packages/vchart-extension/src/charts/3d/arc-3d.ts @@ -1,9 +1,8 @@ -import { registerArc3d } from '@visactor/vrender-kits/register/register-arc3d'; -import { registerShadowRoot } from '@visactor/vrender-kits/register/register-shadowRoot'; -import { createArc3d } from '@visactor/vrender-core'; +import { createArc3d } from './graphic-creator'; import { registerArcAnimation } from '@visactor/vchart/esm/animation/config'; import { Factory } from '@visactor/vchart/esm/core/factory'; import { BaseArcMark } from '@visactor/vchart/esm/mark/arc'; +import { registerArc3d, registerShadowRoot } from '@visactor/vchart/esm/vrender-bridge'; import { MarkType3dEnum } from './enum'; import type { IArc3dMark, IArc3dMarkSpec } from './interface'; diff --git a/packages/vchart-extension/src/charts/3d/graphic-creator.ts b/packages/vchart-extension/src/charts/3d/graphic-creator.ts new file mode 100644 index 0000000000..4b2fbaed6f --- /dev/null +++ b/packages/vchart-extension/src/charts/3d/graphic-creator.ts @@ -0,0 +1 @@ +export { createArc3d, createPyramid3d, createRect3d } from '@visactor/vchart/esm/vrender-bridge'; diff --git a/packages/vchart-extension/src/charts/3d/plugin.ts b/packages/vchart-extension/src/charts/3d/plugin.ts index 3349722c4f..ff6208a514 100644 --- a/packages/vchart-extension/src/charts/3d/plugin.ts +++ b/packages/vchart-extension/src/charts/3d/plugin.ts @@ -1,4 +1,8 @@ -import { registerDirectionalLight, registerOrthoCamera, registerViewTransform3dPlugin } from '@visactor/vrender-core'; +import { + registerDirectionalLight, + registerOrthoCamera, + registerViewTransform3dPlugin +} from '@visactor/vrender-core/plugin/3d'; import type { VChartRenderActionSource } from '@visactor/vchart/esm/core/interface'; import { BasePlugin } from '@visactor/vchart/esm/plugin/base/base-plugin'; import type { IChartPlugin, IChartPluginService } from '@visactor/vchart/esm/plugin/chart/interface'; diff --git a/packages/vchart-extension/src/charts/3d/pyramid-3d.ts b/packages/vchart-extension/src/charts/3d/pyramid-3d.ts index d483164d02..f7fb0f98f1 100644 --- a/packages/vchart-extension/src/charts/3d/pyramid-3d.ts +++ b/packages/vchart-extension/src/charts/3d/pyramid-3d.ts @@ -1,9 +1,8 @@ -import { createPyramid3d } from '@visactor/vrender-core'; -import { registerPyramid3d } from '@visactor/vrender-kits/register/register-pyramid3d'; -import { registerShadowRoot } from '@visactor/vrender-kits/register/register-shadowRoot'; +import { createPyramid3d } from './graphic-creator'; import { registerPolygonAnimation } from '@visactor/vchart/esm/animation/config'; import { Factory } from '@visactor/vchart/esm/core/factory'; import { BasePolygonMark } from '@visactor/vchart/esm/mark/polygon/base-polygon'; +import { registerPyramid3d, registerShadowRoot } from '@visactor/vchart/esm/vrender-bridge'; import type { IPyramid3dMark, IPyramid3dMarkSpec } from './interface'; import { MarkType3dEnum } from './enum'; diff --git a/packages/vchart-extension/src/charts/3d/rect-3d.ts b/packages/vchart-extension/src/charts/3d/rect-3d.ts index de4121ddff..c68fb63782 100644 --- a/packages/vchart-extension/src/charts/3d/rect-3d.ts +++ b/packages/vchart-extension/src/charts/3d/rect-3d.ts @@ -1,9 +1,8 @@ -import { createRect3d } from '@visactor/vrender-core'; -import { registerRect3d } from '@visactor/vrender-kits/register/register-rect3d'; -import { registerShadowRoot } from '@visactor/vrender-kits/register/register-shadowRoot'; +import { createRect3d } from './graphic-creator'; import { registerRectAnimation } from '@visactor/vchart/esm/animation/config'; import { Factory } from '@visactor/vchart/esm/core/factory'; import { BaseMark } from '@visactor/vchart/esm/mark/base/base-mark'; +import { registerRect3d, registerShadowRoot } from '@visactor/vchart/esm/vrender-bridge'; import type { IMarkStyle } from '@visactor/vchart/esm/mark/interface/common'; import type { IRect3dMark, IRect3dMarkSpec } from './interface'; import { MarkType3dEnum } from './enum'; diff --git a/packages/vchart-extension/src/charts/pie-3d/chart.ts b/packages/vchart-extension/src/charts/pie-3d/chart.ts index 523867bc36..860bfa52d6 100644 --- a/packages/vchart-extension/src/charts/pie-3d/chart.ts +++ b/packages/vchart-extension/src/charts/pie-3d/chart.ts @@ -2,6 +2,7 @@ import { Factory } from '@visactor/vchart/esm/core/factory'; import type { AdaptiveSpec } from '@visactor/vchart/esm/typings/spec/common'; import { BasePieChart } from '@visactor/vchart/esm/chart/pie/base/base'; import { registerMarkTooltipProcessor } from '@visactor/vchart/esm/component/tooltip/processor/mark-tooltip'; +import { registerAnimate } from '@visactor/vchart/esm/plugin/other'; import type { IPie3dChartSpec } from './interface'; import { ChartType3dEnum, SeriesType3dEnum } from '../3d/enum'; import { register3DPlugin } from '../3d/plugin'; @@ -20,6 +21,7 @@ export class Pie3dChart extends Bas } export const registerPie3dChart = () => { + registerAnimate(); registerMarkTooltipProcessor(); register3DPlugin(); registerLayout3d(); diff --git a/packages/vchart-extension/tsconfig.json b/packages/vchart-extension/tsconfig.json index 633fb132e3..e1f9044afc 100644 --- a/packages/vchart-extension/tsconfig.json +++ b/packages/vchart-extension/tsconfig.json @@ -5,7 +5,11 @@ "baseUrl": "./", "rootDir": "./src", "outDir": "./esm", - "composite": true + "composite": true, + "paths": { + "@visactor/vrender-core": ["./node_modules/@visactor/vrender-core/es/index"], + "@visactor/vrender-core/*": ["./node_modules/@visactor/vrender-core/es/*"] + } }, "ts-node": { "transpileOnly": true, diff --git a/packages/vchart/__tests__/unit/component/tooltip/dom-tooltip-handler.test.ts b/packages/vchart/__tests__/unit/component/tooltip/dom-tooltip-handler.test.ts new file mode 100644 index 0000000000..2bf51c1667 --- /dev/null +++ b/packages/vchart/__tests__/unit/component/tooltip/dom-tooltip-handler.test.ts @@ -0,0 +1,64 @@ +import { DomTooltipHandler } from '../../../../src/plugin/components/tooltip-handler/dom-tooltip-handler'; +import { TOOLTIP_CONTAINER_EL_CLASS_NAME } from '../../../../src/plugin/components/tooltip-handler/constants'; +import { createDiv, removeDom } from '../../../util/dom'; + +const createTooltipSpec = (spec: any) => ({ + className: 'vchart-tooltip', + style: { + shape: {}, + keyLabel: {}, + valueLabel: {} + }, + ...spec +}); + +const createHandler = (spec: any, chartContainer?: HTMLElement) => { + const handler = new DomTooltipHandler() as any; + + handler._component = { + getSpec: () => createTooltipSpec(spec) + }; + handler._chartOption = { + getTheme: (): undefined => undefined + }; + handler._chartContainer = chartContainer; + handler._initStyle(); + + return handler as DomTooltipHandler; +}; + +describe('DomTooltipHandler', () => { + let container: HTMLElement; + + beforeEach(() => { + container = createDiv(); + }); + + afterEach(() => { + removeDom(container); + }); + + it('falls back to chart container when tooltip parentElement is not a dom element', () => { + const handler = createHandler( + { + parentElement: {} + }, + container + ); + + expect(() => handler.initRootDom()).not.toThrow(); + expect(container.querySelector(`.${TOOLTIP_CONTAINER_EL_CLASS_NAME}`)).toBe(handler.getTooltipContainer()); + expect(container.querySelector('.vchart-tooltip')).toBe(handler.getRootDom()); + }); + + it('creates tooltip container under an empty valid parentElement', () => { + const parentElement = createDiv(container); + const handler = createHandler({ + parentElement + }); + + handler.initEl(); + + expect(parentElement.querySelector(`.${TOOLTIP_CONTAINER_EL_CLASS_NAME}`)).toBe(handler.getTooltipContainer()); + }); +}); diff --git a/packages/vchart/bundler.config.js b/packages/vchart/bundler.config.js index 966f04c555..cb0ea5d111 100644 --- a/packages/vchart/bundler.config.js +++ b/packages/vchart/bundler.config.js @@ -69,12 +69,34 @@ const umdEntries = Object.keys(crossEnvs) .filter((input, index, arr) => arr.indexOf(input, 0) === index); const multiEnvRuntimeEntries = new Set(['index-lark', 'index-wx', 'index-wx-simple', ...esEntries]); +const factoryRegistryExternalId = '@visactor/vchart/esm/core/factory-registry'; +const vrenderExternalRE = /^@visactor\/vrender(?:-[^/]+)?(?:\/.*)?$/; function isBrowserRuntimeEntry(entry) { const entryName = path.basename(entry, path.extname(entry)); return !multiEnvRuntimeEntries.has(entryName); } +function externalizeFactoryRegistryForEsTotal() { + return { + name: 'externalize-vchart-factory-registry', + resolveId(source, importer) { + if ( + (source === './factory-registry' || source === factoryRegistryExternalId) && + importer && + path.normalize(importer).endsWith(path.normalize('src/core/factory.ts')) + ) { + return { + id: factoryRegistryExternalId, + external: true + }; + } + + return null; + } + }; +} + /** * @type {import('@internal/bundler').Config} */ @@ -98,6 +120,10 @@ module.exports = { rollupOptions: { plugins }, + esTotalRollupOptions: { + external: id => vrenderExternalRE.test(id), + prePlugins: [externalizeFactoryRegistryForEsTotal()] + }, nodeResolveOptions: entry => isBrowserRuntimeEntry(entry) ? { diff --git a/packages/vchart/package.json b/packages/vchart/package.json index 979793f82c..08190c93da 100644 --- a/packages/vchart/package.json +++ b/packages/vchart/package.json @@ -128,11 +128,11 @@ "@visactor/vdataset": "~1.0.23", "@visactor/vscale": "~1.0.23", "@visactor/vlayouts": "~1.0.23", - "@visactor/vrender": "^1.1.3", - "@visactor/vrender-core": "^1.1.3", - "@visactor/vrender-kits": "^1.1.3", - "@visactor/vrender-components": "^1.1.3", - "@visactor/vrender-animate": "^1.1.3", + "@visactor/vrender": "~1.1.4", + "@visactor/vrender-core": "~1.1.4", + "@visactor/vrender-kits": "~1.1.4", + "@visactor/vrender-components": "~1.1.4", + "@visactor/vrender-animate": "~1.1.4", "@visactor/vutils-extension": "workspace:2.1.1" }, "publishConfig": { diff --git a/packages/vchart/src/animation/index.ts b/packages/vchart/src/animation/index.ts index 1305461a69..3e0fc6d9e7 100644 --- a/packages/vchart/src/animation/index.ts +++ b/packages/vchart/src/animation/index.ts @@ -1,4 +1,5 @@ -export { registerAnimate as registerVRenderAnimate, registerCustomAnimate } from '@visactor/vrender-animate'; +export { registerVRenderAnimate } from '../vrender-bridge'; +export { registerCustomAnimate } from '@visactor/vrender-animate/custom/register'; export { registerStateTransition } from './state-transition'; export { registerSequentialAnimate } from './sequential-animate'; export { diff --git a/packages/vchart/src/animation/state-transition.ts b/packages/vchart/src/animation/state-transition.ts index 2233565fe9..593ee7e50b 100644 --- a/packages/vchart/src/animation/state-transition.ts +++ b/packages/vchart/src/animation/state-transition.ts @@ -1,4 +1,4 @@ -import { AnimationTransitionRegistry } from '@visactor/vrender-animate'; +import { AnimationTransitionRegistry } from '@visactor/vrender-animate/state/animation-states-registry'; export function registerStateTransition() { const animationTransitionRegistry = AnimationTransitionRegistry.getInstance(); diff --git a/packages/vchart/src/chart/util.ts b/packages/vchart/src/chart/util.ts index bb40e90053..4167886d83 100644 --- a/packages/vchart/src/chart/util.ts +++ b/packages/vchart/src/chart/util.ts @@ -7,7 +7,7 @@ import { mergeSpec } from '@visactor/vutils-extension'; import type { ICartesianChartSpec } from './cartesian/interface'; import type { IChartOption } from './interface/common'; import type { IUpdateSpecEffects, IUpdateSpecResult } from '../model/interface'; -import { vglobal } from '@visactor/vrender-core'; +import { vglobal } from '../vrender-bridge'; export function setDefaultCrosshairForCartesianChart(spec: ICartesianChartSpec) { spec.crosshair = array(spec.crosshair || {}).map(crosshairCfg => { diff --git a/packages/vchart/src/compile/compiler.ts b/packages/vchart/src/compile/compiler.ts index d4d35cc791..173563ea0a 100644 --- a/packages/vchart/src/compile/compiler.ts +++ b/packages/vchart/src/compile/compiler.ts @@ -9,7 +9,7 @@ import type { IBoundsLike } from '@visactor/vutils'; import { array, isArray, isObject, isValid } from '@visactor/vutils'; import type { EventSourceType } from '../event/interface'; import type { IChart } from '../chart/interface'; -import { createGroup, vglobal, waitForAllSubLayers } from '@visactor/vrender-core'; +import { createGroup, vglobal, waitForAllSubLayers } from '../vrender-bridge'; import type { IColor, IEventTarget, IGroup, IStage } from '@visactor/vrender-core'; import type { IMorphConfig } from '../animation/spec'; import type { IVChart, IVChartRenderOption } from '../core/interface'; diff --git a/packages/vchart/src/component/axis/cartesian/axis.ts b/packages/vchart/src/component/axis/cartesian/axis.ts index a058a91b11..9d866d10d5 100644 --- a/packages/vchart/src/component/axis/cartesian/axis.ts +++ b/packages/vchart/src/component/axis/cartesian/axis.ts @@ -47,7 +47,7 @@ import type { DataSet } from '@visactor/vdataset'; import { AxisComponent } from '../base-axis'; import type { IGraphic, IText } from '@visactor/vrender-core'; // eslint-disable-next-line no-duplicate-imports -import { createText } from '@visactor/vrender-core'; +import { createText } from '../../../vrender-bridge'; import type { ICartesianChartSpec } from '../../../chart/cartesian/interface'; import { getCombinedSizeOfRegions } from '../../../util/region'; diff --git a/packages/vchart/src/component/base/base-component.ts b/packages/vchart/src/component/base/base-component.ts index 60b2d5e814..ff4e83455e 100644 --- a/packages/vchart/src/component/base/base-component.ts +++ b/packages/vchart/src/component/base/base-component.ts @@ -1,4 +1,5 @@ -import { CustomEvent, type IGraphicAttribute, type IGraphic, type IGroup, type INode } from '@visactor/vrender-core'; +import type { IGraphicAttribute, IGraphic, IGroup, INode } from '@visactor/vrender-core'; +import { CustomEvent } from '@visactor/vrender-core/event/constant'; import type { IRegion } from '../../region/interface'; import type { IComponent, IComponentOption } from '../interface'; import { ComponentPluginService } from '../../plugin/components/plugin-service'; diff --git a/packages/vchart/src/component/label/util.ts b/packages/vchart/src/component/label/util.ts index d1221c9757..2ddb744dbf 100644 --- a/packages/vchart/src/component/label/util.ts +++ b/packages/vchart/src/component/label/util.ts @@ -5,7 +5,7 @@ import type { BaseLabelAttrs, LabelItem, OverlapAttrs, Strategy } from '@visacto import { SeriesTypeEnum, type ICartesianSeries } from '../../series/interface'; import { isBoolean, isFunction, isObject, isString } from '@visactor/vutils'; import type { IGlyph, IGraphic, IText } from '@visactor/vrender-core'; -import { createText } from '@visactor/vrender-core'; +import { createText } from '../../vrender-bridge'; import type { IWaterfallSeriesSpec } from '../../series/waterfall/interface'; import type { ILabelInfo, ILabelSpec } from './interface'; import { getFormatFunction } from '../util'; diff --git a/packages/vchart/src/component/tooltip/processor/mark-tooltip.ts b/packages/vchart/src/component/tooltip/processor/mark-tooltip.ts index beb4bcc82d..27b3bfda72 100644 --- a/packages/vchart/src/component/tooltip/processor/mark-tooltip.ts +++ b/packages/vchart/src/component/tooltip/processor/mark-tooltip.ts @@ -4,7 +4,7 @@ import type { ITooltipSpec, TooltipHandlerParams } from '../interface'; import type { MarkTooltipInfo, MouseEventData } from './interface'; import { BaseTooltipProcessor } from './base'; import type { ISeries } from '../../../series/interface'; -import { IContainPointMode } from '@visactor/vrender-core'; +import { IContainPointMode } from '@visactor/vrender-core/event/constant'; import type { IDimensionData } from '../../../event/events/dimension/interface'; import type { Label } from '../../label'; import { getDatumOfGraphic } from '../../../util/mark'; diff --git a/packages/vchart/src/component/tooltip/tooltip-transformer.ts b/packages/vchart/src/component/tooltip/tooltip-transformer.ts index bd3d43d486..24a5f0a19a 100644 --- a/packages/vchart/src/component/tooltip/tooltip-transformer.ts +++ b/packages/vchart/src/component/tooltip/tooltip-transformer.ts @@ -1,4 +1,4 @@ -import { vglobal } from '@visactor/vrender-core'; +import { vglobal } from '../../vrender-bridge'; import type { IChartSpecInfo } from '../../chart/interface'; import { domDocument, isMiniAppLikeMode, isString, isTrueBrowser, isValid } from '../../util'; import { BaseComponentSpecTransformer } from '../base'; diff --git a/packages/vchart/src/core/factory-registry.ts b/packages/vchart/src/core/factory-registry.ts new file mode 100644 index 0000000000..81d697295b --- /dev/null +++ b/packages/vchart/src/core/factory-registry.ts @@ -0,0 +1,89 @@ +import type { Transform, Parser } from '@visactor/vdataset'; +// eslint-disable-next-line no-duplicate-imports +import { fields, filter, fold, csvParser, dsvParser, tsvParser } from '@visactor/vdataset'; +import type { IChartConstructor } from '../chart/interface'; +import type { ISeriesConstructor } from '../series/interface'; +import type { IComponentConstructor } from '../component/interface'; +import type { MarkConstructor } from '../mark/interface'; +import type { IRegionConstructor } from '../region/interface'; +import type { ILayoutConstructor } from '../layout/interface'; +import type { IChartPluginConstructor } from '../plugin/chart/interface'; +import type { IComponentPluginConstructor } from '../plugin/components/interface'; +import type { IGraphic } from '@visactor/vrender-core'; +import type { GrammarTransformOption, IStageEventPlugin, VRenderComponentOptions } from './interface'; +import type { MarkAnimationSpec } from '../animation/interface'; +import type { ITriggerConstructor } from '../interaction/interface/trigger'; +import type { IComposedEventConstructor } from '../index-harmony-simple'; +import type { ITooltipProcessorConstructor } from '../component/tooltip/processor/interface'; +import type { IVChartPluginConstructor } from '../plugin/vchart'; + +export interface IFactoryRegistry { + charts: { [key: string]: IChartConstructor }; + series: { [key: string]: ISeriesConstructor }; + components: { + [key: string]: { + cmp: IComponentConstructor; + alwaysCheck?: boolean; + createOrder: number; + }; + }; + graphicComponents: Record IGraphic>; + marks: { [key: string]: MarkConstructor }; + regions: { [key: string]: IRegionConstructor }; + animations: { [key: string]: (params?: any, preset?: any) => MarkAnimationSpec }; + implements: { [key: string]: (...args: any) => void }; + chartPlugin: { [key: string]: IChartPluginConstructor }; + vChartPlugin: { [key: string]: IVChartPluginConstructor }; + componentPlugin: { [key: string]: IComponentPluginConstructor }; + transforms: { [key: string]: Transform }; + dataParser: { [key: string]: Parser }; + layout: { [key: string]: ILayoutConstructor }; + grammarTransforms: Record; + stageEventPlugins: Record>; + interactionTriggers: Record; + composedEventMap: Record; + tooltipProcessors: Record; + formatter?: (text: string | number | string[] | number[], datum: any, formatter: string | string[]) => any; +} + +const createFactoryRegistry = (): IFactoryRegistry => ({ + charts: {}, + series: {}, + components: {}, + graphicComponents: {}, + marks: {}, + regions: {}, + animations: {}, + implements: {}, + chartPlugin: {}, + vChartPlugin: {}, + componentPlugin: {}, + transforms: { + // buildIn transforms + fields, + filter, + fold + }, + dataParser: { + // buildIn parser + csv: csvParser, + dsv: dsvParser, + tsv: tsvParser + }, + layout: {}, + grammarTransforms: {}, + stageEventPlugins: {}, + interactionTriggers: {}, + composedEventMap: {}, + tooltipProcessors: {}, + formatter: undefined +}); + +const factoryRegistryVersion = typeof __VERSION__ === 'undefined' ? 'unknown' : __VERSION__; +const factoryRegistryKey = Symbol.for(`@visactor/vchart/factory-registry@${factoryRegistryVersion}`); +const globalFactoryRegistry = globalThis as typeof globalThis & { + [factoryRegistryKey]?: IFactoryRegistry; +}; + +export const factoryRegistry: IFactoryRegistry = + globalFactoryRegistry[factoryRegistryKey] ?? (globalFactoryRegistry[factoryRegistryKey] = createFactoryRegistry()); diff --git a/packages/vchart/src/core/factory.ts b/packages/vchart/src/core/factory.ts index 3b5780644e..a56650de60 100644 --- a/packages/vchart/src/core/factory.ts +++ b/packages/vchart/src/core/factory.ts @@ -13,8 +13,6 @@ import { MarkTypeEnum } from '../mark/interface/type'; import type { IRegion, IRegionConstructor } from '../region/interface'; import type { IBaseModelSpecTransformer, IBaseModelSpecTransformerOption, IModelOption } from '../model/interface'; import type { Transform, Parser } from '@visactor/vdataset'; -// eslint-disable-next-line no-duplicate-imports -import { fields, filter, fold, csvParser, dsvParser, tsvParser } from '@visactor/vdataset'; import type { ILayoutConstructor } from '../layout/interface'; import type { IChartPluginConstructor } from '../plugin/chart/interface'; import type { IComponentPluginConstructor } from '../plugin/components/interface'; @@ -26,44 +24,37 @@ import type { IComposedEventConstructor } from '../index-harmony-simple'; import type { ITooltipProcessorConstructor } from '../component/tooltip/processor/interface'; import type { ITooltip } from '../component'; import type { IVChartPluginConstructor } from '../plugin/vchart'; +import { factoryRegistry } from './factory-registry'; export class Factory { - private static _charts: { [key: string]: IChartConstructor } = {}; - private static _series: { [key: string]: ISeriesConstructor } = {}; + private static _charts: { [key: string]: IChartConstructor } = factoryRegistry.charts; + private static _series: { [key: string]: ISeriesConstructor } = factoryRegistry.series; private static _components: { [key: string]: { cmp: IComponentConstructor; alwaysCheck?: boolean; createOrder: number; }; - } = {}; - private static _graphicComponents: Record IGraphic> = {}; - private static _marks: { [key: string]: MarkConstructor } = {}; - private static _regions: { [key: string]: IRegionConstructor } = {}; - private static _animations: { [key: string]: (params?: any, preset?: any) => MarkAnimationSpec } = {}; - private static _implements: { [key: string]: (...args: any) => void } = {}; - private static _chartPlugin: { [key: string]: IChartPluginConstructor } = {}; - private static _vChartPlugin: { [key: string]: IVChartPluginConstructor } = {}; - private static _componentPlugin: { [key: string]: IComponentPluginConstructor } = {}; + } = factoryRegistry.components; + private static _graphicComponents: Record IGraphic> = + factoryRegistry.graphicComponents; + private static _marks: { [key: string]: MarkConstructor } = factoryRegistry.marks; + private static _regions: { [key: string]: IRegionConstructor } = factoryRegistry.regions; + private static _animations: { [key: string]: (params?: any, preset?: any) => MarkAnimationSpec } = + factoryRegistry.animations; + private static _implements: { [key: string]: (...args: any) => void } = factoryRegistry.implements; + private static _chartPlugin: { [key: string]: IChartPluginConstructor } = factoryRegistry.chartPlugin; + private static _vChartPlugin: { [key: string]: IVChartPluginConstructor } = factoryRegistry.vChartPlugin; + private static _componentPlugin: { [key: string]: IComponentPluginConstructor } = factoryRegistry.componentPlugin; private static _formatter: ( text: string | number | string[] | number[], datum: any, formatter: string | string[] ) => any; - static transforms: { [key: string]: Transform } = { - // buildIn transforms - fields: fields, - filter: filter, - fold: fold - }; - static dataParser: { [key: string]: Parser } = { - // buildIn parser - csv: csvParser, - dsv: dsvParser, - tsv: tsvParser - }; - static _layout: { [key: string]: ILayoutConstructor } = {}; + static transforms: { [key: string]: Transform } = factoryRegistry.transforms; + static dataParser: { [key: string]: Parser } = factoryRegistry.dataParser; + static _layout: { [key: string]: ILayoutConstructor } = factoryRegistry.layout; static registerChart(key: string, chart: IChartConstructor) { Factory._charts[key] = chart; @@ -98,7 +89,7 @@ export class Factory { Factory.transforms[key] = transform; } - private static _grammarTransforms: Record = {}; + private static _grammarTransforms: Record = factoryRegistry.grammarTransforms; static registerGrammarTransform(type: string, transform: GrammarTransformOption) { Factory._grammarTransforms[type] = transform; @@ -288,13 +279,14 @@ export class Factory { static registerFormatter(func: typeof Factory['_formatter']) { this._formatter = func; + factoryRegistry.formatter = func; } static getFormatter() { - return this._formatter; + return factoryRegistry.formatter ?? this._formatter; } - private static _stageEventPlugins: Record> = {}; + private static _stageEventPlugins: Record> = factoryRegistry.stageEventPlugins; static registerStageEventPlugin = (type: string, Plugin: IStageEventPlugin) => { Factory._stageEventPlugins[type] = Plugin; @@ -304,7 +296,7 @@ export class Factory { return Factory._stageEventPlugins[type]; }; - private static _interactionTriggers: Record = {}; + private static _interactionTriggers: Record = factoryRegistry.interactionTriggers; static registerInteractionTrigger = (interactionType: string, interaction: ITriggerConstructor) => { Factory._interactionTriggers[interactionType] = interaction; @@ -323,7 +315,7 @@ export class Factory { return !!Factory._interactionTriggers[interactionType]; } - private static _composedEventMap: Record = {}; + private static _composedEventMap: Record = factoryRegistry.composedEventMap; static registerComposedEvent = (eType: string, composedEvent: IComposedEventConstructor) => { Factory._composedEventMap[eType] = composedEvent; @@ -333,7 +325,7 @@ export class Factory { return Factory._composedEventMap[eType]; } - private static _tooltipProcessors: Record = {}; + private static _tooltipProcessors: Record = factoryRegistry.tooltipProcessors; static registerTooltipProcessor = (type: string, processor: ITooltipProcessorConstructor) => { Factory._tooltipProcessors[type] = processor; }; diff --git a/packages/vchart/src/core/index.ts b/packages/vchart/src/core/index.ts index 3b270476e8..3c4ba28ddb 100644 --- a/packages/vchart/src/core/index.ts +++ b/packages/vchart/src/core/index.ts @@ -45,8 +45,8 @@ export * from '../typings/tooltip'; export * from '../theme/index'; // vrender +export { vglobal } from '../vrender-bridge'; export { - vglobal, createGroup, createRichText, createText, @@ -55,7 +55,7 @@ export { createRect, createLine, createSymbol -} from '@visactor/vrender-core'; +} from '../vrender-bridge'; export { ManualTicker } from '@visactor/vrender-animate/ticker/manual-ticker'; export { StreamLight } from '@visactor/vrender-animate/custom/streamLight'; diff --git a/packages/vchart/src/core/vchart.ts b/packages/vchart/src/core/vchart.ts index cdcfaf6cc1..feabe57a81 100644 --- a/packages/vchart/src/core/vchart.ts +++ b/packages/vchart/src/core/vchart.ts @@ -30,7 +30,7 @@ import type { IParserOptions, IFields, Transform } from '@visactor/vdataset'; import { DataSet, dataViewParser, DataView } from '@visactor/vdataset'; import type { IGraphic, IStage, Stage } from '@visactor/vrender-core'; // eslint-disable-next-line no-duplicate-imports -import { vglobal } from '@visactor/vrender-core'; +import { vglobal } from '../vrender-bridge'; import { isString, isValid, isNil, array, specTransform, functionTransform, removeUndefined } from '../util'; import { createID } from '../util/id'; import { convertPoint } from '../util/space'; diff --git a/packages/vchart/src/env/env.ts b/packages/vchart/src/env/env.ts index 630a2c4d92..cb05e3634f 100644 --- a/packages/vchart/src/env/env.ts +++ b/packages/vchart/src/env/env.ts @@ -9,7 +9,7 @@ import { loadTTEnv, loadHarmonyEnv } from '@visactor/vrender-kits/env'; -import { container } from '@visactor/vrender-core'; +import { container } from '@visactor/vrender-core/container'; /** * 加载所有环境兼容代码 diff --git a/packages/vchart/src/index-harmony-simple.ts b/packages/vchart/src/index-harmony-simple.ts index 2e216cf893..c1a1825dcb 100644 --- a/packages/vchart/src/index-harmony-simple.ts +++ b/packages/vchart/src/index-harmony-simple.ts @@ -55,7 +55,7 @@ import { registerCustomMark } from './component/custom-mark'; import { registerGridLayout } from './layout/grid-layout/grid-layout'; import { registerPoptip } from './component/poptip'; import { registerCanvasTooltipHandler } from './plugin/components/tooltip-handler'; -import { DefaultTicker } from '@visactor/vrender-animate'; +import { DefaultTicker } from '@visactor/vrender-animate/ticker/default-ticker'; import { registerAnimate } from './plugin/other'; import { registerElementSelect } from './interaction/triggers/element-select'; import { registerElementHighlight } from './interaction/triggers/element-highlight'; diff --git a/packages/vchart/src/index-harmony.ts b/packages/vchart/src/index-harmony.ts index f6393ecc5d..8c5dffc250 100644 --- a/packages/vchart/src/index-harmony.ts +++ b/packages/vchart/src/index-harmony.ts @@ -55,7 +55,7 @@ import { registerCustomMark } from './component/custom-mark'; import { registerGridLayout } from './layout/grid-layout/grid-layout'; import { registerPoptip } from './component/poptip'; import { registerCanvasTooltipHandler } from './plugin/components/tooltip-handler'; -import { DefaultTicker } from '@visactor/vrender-animate'; +import { DefaultTicker } from '@visactor/vrender-animate/ticker/default-ticker'; import { registerAnimate } from './plugin/other'; import { registerElementHighlight } from './interaction/triggers/element-highlight'; import { registerElementSelect } from './interaction/triggers/element-select'; diff --git a/packages/vchart/src/index.ts b/packages/vchart/src/index.ts index e0df93ebe9..a283653c10 100644 --- a/packages/vchart/src/index.ts +++ b/packages/vchart/src/index.ts @@ -38,16 +38,24 @@ export * from './compile/data/compilable-data'; export * from './animation'; export * from './interaction'; +export { createImage, createPath, graphicCreator } from './vrender-bridge'; export { - createImage, - createPath, createArc3d, createPyramid3d, createRect3d, + registerArc3d, + registerLine, + registerPyramid3d, + registerRect, + registerRect3d, + registerShadowRoot +} from './vrender-bridge'; +export { registerDirectionalLight, registerOrthoCamera, - registerViewTransform3dPlugin, - graphicCreator, + registerViewTransform3dPlugin +} from '@visactor/vrender-core/plugin/3d'; +export { type IGraphic, type IGlyph, type IGroup, @@ -69,7 +77,9 @@ export { type ISymbolGraphicAttribute } from '@visactor/vrender-core'; -export { ACustomAnimate, AnimateExecutor, RotateBySphereAnimate } from '@visactor/vrender-animate'; +export { ACustomAnimate } from '@visactor/vrender-animate/custom/custom-animate'; +export { AnimateExecutor } from '@visactor/vrender-animate/executor/animate-executor'; +export { RotateBySphereAnimate } from '@visactor/vrender-animate/custom/sphere'; // vrender-components export { @@ -80,14 +90,6 @@ export { type Point } from '@visactor/vrender-components'; -// vrender-kits -export { registerLine } from '@visactor/vrender-kits/register/register-line'; -export { registerRect } from '@visactor/vrender-kits/register/register-rect'; -export { registerArc3d } from '@visactor/vrender-kits/register/register-arc3d'; -export { registerPyramid3d } from '@visactor/vrender-kits/register/register-pyramid3d'; -export { registerRect3d } from '@visactor/vrender-kits/register/register-rect3d'; -export { registerShadowRoot } from '@visactor/vrender-kits/register/register-shadowRoot'; - // vlayouts export * from '@visactor/vlayouts'; diff --git a/packages/vchart/src/mark/arc.ts b/packages/vchart/src/mark/arc.ts index c1ad2c3264..dd90dbf78b 100644 --- a/packages/vchart/src/mark/arc.ts +++ b/packages/vchart/src/mark/arc.ts @@ -9,10 +9,8 @@ import type { IArcMark, IMarkOption, IMarkRaw, IMarkStyle } from './interface'; import { MarkTypeEnum } from './interface/type'; import { registerArcAnimation } from '../animation/config'; import { polarToCartesian } from '@visactor/vutils'; -import { createArc } from '@visactor/vrender-core'; +import { createArc, registerArc, registerShadowRoot } from '../vrender-bridge'; import { registerArcDataLabel } from '@visactor/vrender-components/label'; -import { registerArc } from '@visactor/vrender-kits/register/register-arc'; -import { registerShadowRoot } from '@visactor/vrender-kits/register/register-shadowRoot'; export class BaseArcMark extends BaseMark implements IMarkRaw { readonly type: string = ArcMark.type; diff --git a/packages/vchart/src/mark/area.ts b/packages/vchart/src/mark/area.ts index 49751f957d..8acbf9f423 100644 --- a/packages/vchart/src/mark/area.ts +++ b/packages/vchart/src/mark/area.ts @@ -5,11 +5,9 @@ import type { IAreaMark, IMarkStyle } from './interface'; // eslint-disable-next-line no-duplicate-imports import { MarkTypeEnum } from './interface/type'; import { registerLineOrAreaAnimation } from '../animation/config'; -import { registerArea } from '@visactor/vrender-kits/register/register-area'; -import { registerShadowRoot } from '@visactor/vrender-kits/register/register-shadowRoot'; import { registerLineDataLabel } from '@visactor/vrender-components/label/line'; import { registerSymbolDataLabel } from '@visactor/vrender-components/label/symbol'; -import { createArea } from '@visactor/vrender-core'; +import { createArea, registerArea, registerShadowRoot } from '../vrender-bridge'; const AREA_SEGMENT_ATTRIBUTES = [ ...LINE_SEGMENT_ATTRIBUTES, diff --git a/packages/vchart/src/mark/base/base-mark.ts b/packages/vchart/src/mark/base/base-mark.ts index f7e468d1c0..a2e46d34bc 100644 --- a/packages/vchart/src/mark/base/base-mark.ts +++ b/packages/vchart/src/mark/base/base-mark.ts @@ -63,7 +63,7 @@ import type { StateDefinitionsInput, StateResolveContext } from '@visactor/vrender-core'; -import { createGroup, CustomPath2D } from '@visactor/vrender-core'; +import { createGroup, CustomPath2D } from '../../vrender-bridge'; import { isStateAttrChangeable } from '../../compile/mark/util'; import { Factory } from '../../core/factory'; import { DEFAULT_DATA_KEY } from '../../constant/data'; diff --git a/packages/vchart/src/mark/box-plot.ts b/packages/vchart/src/mark/box-plot.ts index c2d44f1697..9ccc218acf 100644 --- a/packages/vchart/src/mark/box-plot.ts +++ b/packages/vchart/src/mark/box-plot.ts @@ -3,12 +3,11 @@ import type { BoxPlotShaftShape, IBoxPlotMarkSpec } from '../typings/visual'; import type { IBoxPlotMark, IMarkStyle } from './interface'; // eslint-disable-next-line no-duplicate-imports import { MarkTypeEnum } from './interface/type'; -import { createLine, createRect, type IGlyph, type ILineGraphicAttribute } from '@visactor/vrender-core'; +import type { IGlyph, ILineGraphicAttribute } from '@visactor/vrender-core'; +import { createLine, createRect, registerLine, registerRect } from '../vrender-bridge'; import { GlyphMark, registerGlyphMark } from './glyph'; import type { Datum } from '../typings/common'; import { isValidNumber } from '@visactor/vutils'; -import { registerLine } from '@visactor/vrender-kits/register/register-line'; -import { registerRect } from '@visactor/vrender-kits/register/register-rect'; const BAR_BOX_PLOT_CHANNELS = [ 'x', diff --git a/packages/vchart/src/mark/cell.ts b/packages/vchart/src/mark/cell.ts index df3ccc0f2a..90b9037db3 100644 --- a/packages/vchart/src/mark/cell.ts +++ b/packages/vchart/src/mark/cell.ts @@ -3,11 +3,9 @@ import type { ICellMarkSpec } from '../typings'; import type { ICellMark, IMarkGraphic, IMarkStyle } from './interface'; // eslint-disable-next-line no-duplicate-imports import { MarkTypeEnum } from './interface/type'; -import { registerShadowRoot } from '@visactor/vrender-kits/register/register-shadowRoot'; -import { registerSymbol } from '@visactor/vrender-kits/register/register-symbol'; import { registerSymbolDataLabel } from '@visactor/vrender-components'; import type { IGraphic, ISymbolGraphicAttribute } from '@visactor/vrender-core'; -import { createSymbol } from '@visactor/vrender-core'; +import { createSymbol, registerShadowRoot, registerSymbol } from '../vrender-bridge'; import { isNil } from '@visactor/vutils'; import { BaseMark } from './base'; diff --git a/packages/vchart/src/mark/glyph.ts b/packages/vchart/src/mark/glyph.ts index c1c07cdabd..c95a329114 100644 --- a/packages/vchart/src/mark/glyph.ts +++ b/packages/vchart/src/mark/glyph.ts @@ -1,13 +1,11 @@ import type { ICommonSpec } from '../typings/visual'; import { BaseMark } from './base/base-mark'; import type { IGlyph, IGlyphGraphicAttribute, IGraphic } from '@visactor/vrender-core'; -import { createGlyph } from '@visactor/vrender-core'; +import { createGlyph, registerGlyph, registerShadowRoot } from '../vrender-bridge'; import type { IGlyphMark } from './interface/mark'; import type { MarkType } from './interface/type'; import { Factory } from '../core/factory'; import type { Datum } from '../typings/common'; -import { registerGlyph } from '@visactor/vrender-kits/register/register-glyph'; -import { registerShadowRoot } from '@visactor/vrender-kits/register/register-shadowRoot'; import type { IMarkGraphic } from './interface/common'; import { DiffState } from './interface/enum'; import { merge } from '@visactor/vutils'; diff --git a/packages/vchart/src/mark/group.ts b/packages/vchart/src/mark/group.ts index 0d68f1537f..5239629739 100644 --- a/packages/vchart/src/mark/group.ts +++ b/packages/vchart/src/mark/group.ts @@ -16,8 +16,7 @@ import { import { MarkTypeEnum } from './interface/type'; import { type IMarkCompileOption } from '../compile/mark'; import type { IGroup, IGroupGraphicAttribute } from '@visactor/vrender-core'; -import { registerGroup } from '@visactor/vrender-kits/register/register-group'; -import { registerShadowRoot } from '@visactor/vrender-kits/register/register-shadowRoot'; +import { registerGroup, registerShadowRoot } from '../vrender-bridge'; import { isNil } from '@visactor/vutils'; import { traverseGroupMark } from '../compile/util'; import { getDiffAttributesOfGraphic } from '../util/mark'; diff --git a/packages/vchart/src/mark/image.ts b/packages/vchart/src/mark/image.ts index e7e5f02c61..b0e856f3a1 100644 --- a/packages/vchart/src/mark/image.ts +++ b/packages/vchart/src/mark/image.ts @@ -4,9 +4,7 @@ import { BaseMark } from './base/base-mark'; import type { IImageMark, IMarkStyle, MarkConstructor } from './interface'; // eslint-disable-next-line no-duplicate-imports import { MarkTypeEnum } from './interface/type'; -import { registerImage } from '@visactor/vrender-kits/register/register-image'; -import { registerShadowRoot } from '@visactor/vrender-kits/register/register-shadowRoot'; -import { createImage } from '@visactor/vrender-core'; +import { createImage, registerImage, registerShadowRoot } from '../vrender-bridge'; export class ImageMark extends BaseMark implements IImageMark { static readonly type = MarkTypeEnum.image; diff --git a/packages/vchart/src/mark/line.ts b/packages/vchart/src/mark/line.ts index 5d898ff096..4c491216be 100644 --- a/packages/vchart/src/mark/line.ts +++ b/packages/vchart/src/mark/line.ts @@ -7,9 +7,7 @@ import type { ILineMark, IMarkStyle } from './interface'; import { MarkTypeEnum } from './interface/type'; import { registerLineOrAreaAnimation } from '../animation/config'; import type { IGraphic, ILineGraphicAttribute } from '@visactor/vrender-core'; -import { createLine } from '@visactor/vrender-core'; -import { registerLine } from '@visactor/vrender-kits/register/register-line'; -import { registerShadowRoot } from '@visactor/vrender-kits/register/register-shadowRoot'; +import { createLine, registerLine, registerShadowRoot } from '../vrender-bridge'; import { registerLineDataLabel } from '@visactor/vrender-components/label/line'; import { registerSymbolDataLabel } from '@visactor/vrender-components/label/symbol'; diff --git a/packages/vchart/src/mark/link-path.ts b/packages/vchart/src/mark/link-path.ts index 5ea97b7503..3a4eabc791 100644 --- a/packages/vchart/src/mark/link-path.ts +++ b/packages/vchart/src/mark/link-path.ts @@ -5,8 +5,7 @@ import type { ILinkPathConfig, ILinkPathMark, IMarkStyle } from './interface'; import { MarkTypeEnum } from './interface/type'; import { GlyphMark, registerGlyphMark } from './glyph'; import type { IGlyph, IPathGraphicAttribute } from '@visactor/vrender-core'; -import { createPath } from '@visactor/vrender-core'; -import { registerPath } from '@visactor/vrender-kits/register/register-path'; +import { createPath, registerPath } from '../vrender-bridge'; import type { Datum } from '../typings/common'; export const getHorizontalPath = (options: ILinkPathMarkSpec, ratio?: number) => { diff --git a/packages/vchart/src/mark/liquid.ts b/packages/vchart/src/mark/liquid.ts index 8ac7479f84..6813856a62 100644 --- a/packages/vchart/src/mark/liquid.ts +++ b/packages/vchart/src/mark/liquid.ts @@ -4,9 +4,9 @@ import type { IMarkStyle } from './interface'; import { MarkTypeEnum } from './interface/type'; import type { ILiquidMark } from '../series/liquid/liquid'; import { GlyphMark, registerGlyphMark } from './glyph'; -import { createArea, type IAreaGraphicAttribute, type IGlyph } from '@visactor/vrender-core'; +import type { IAreaGraphicAttribute, IGlyph } from '@visactor/vrender-core'; +import { createArea, registerArea } from '../vrender-bridge'; import type { IPointLike } from '@visactor/vutils'; -import { registerArea } from '@visactor/vrender-kits/register/register-area'; import type { ILiquidMarkSpec } from '../typings/visual'; import type { Datum } from '../typings/common'; diff --git a/packages/vchart/src/mark/path.ts b/packages/vchart/src/mark/path.ts index ea65c0ee05..aaf7ad3fcd 100644 --- a/packages/vchart/src/mark/path.ts +++ b/packages/vchart/src/mark/path.ts @@ -4,9 +4,7 @@ import { BaseMark } from './base/base-mark'; import type { IMarkStyle, IPathMark } from './interface'; // eslint-disable-next-line no-duplicate-imports import { MarkTypeEnum } from './interface/type'; -import { registerPath } from '@visactor/vrender-kits/register/register-path'; -import { registerShadowRoot } from '@visactor/vrender-kits/register/register-shadowRoot'; -import { createPath } from '@visactor/vrender-core'; +import { createPath, registerPath, registerShadowRoot } from '../vrender-bridge'; export class PathMark extends BaseMark implements IPathMark { static readonly type = MarkTypeEnum.path; diff --git a/packages/vchart/src/mark/polygon/polygon.ts b/packages/vchart/src/mark/polygon/polygon.ts index 433ce44982..b5b76ac993 100644 --- a/packages/vchart/src/mark/polygon/polygon.ts +++ b/packages/vchart/src/mark/polygon/polygon.ts @@ -5,9 +5,7 @@ import { BasePolygonMark } from './base-polygon'; import type { IMarkStyle, IPolygonMark } from '../interface'; import { MarkTypeEnum } from '../interface/type'; import { registerPolygonAnimation } from '../../animation/config'; -import { registerPolygon } from '@visactor/vrender-kits/register/register-polygon'; -import { registerShadowRoot } from '@visactor/vrender-kits/register/register-shadowRoot'; -import { createPolygon } from '@visactor/vrender-core'; +import { createPolygon, registerPolygon, registerShadowRoot } from '../../vrender-bridge'; export class PolygonMark extends BasePolygonMark implements IPolygonMark { static readonly type = MarkTypeEnum.polygon; diff --git a/packages/vchart/src/mark/rect.ts b/packages/vchart/src/mark/rect.ts index bb8dfa716c..dd9335a773 100644 --- a/packages/vchart/src/mark/rect.ts +++ b/packages/vchart/src/mark/rect.ts @@ -5,10 +5,8 @@ import type { IMarkStyle, IRectMark } from './interface'; // eslint-disable-next-line no-duplicate-imports import { MarkTypeEnum } from './interface/type'; import { registerRectAnimation } from '../animation/config'; -import { registerRect } from '@visactor/vrender-kits/register/register-rect'; -import { registerShadowRoot } from '@visactor/vrender-kits/register/register-shadowRoot'; import { registerRectDataLabel } from '@visactor/vrender-components/label'; -import { createRect } from '@visactor/vrender-core'; +import { createRect, registerRect, registerShadowRoot } from '../vrender-bridge'; export class RectMark extends BaseMark implements IRectMark { static readonly type = MarkTypeEnum.rect; diff --git a/packages/vchart/src/mark/ripple.ts b/packages/vchart/src/mark/ripple.ts index 9bba3a4ac4..b37212a55e 100644 --- a/packages/vchart/src/mark/ripple.ts +++ b/packages/vchart/src/mark/ripple.ts @@ -5,9 +5,9 @@ import type { IMarkStyle, IRippleMark } from './interface'; import { MarkTypeEnum } from './interface/type'; import { GlyphMark, registerGlyphMark } from './glyph'; import type { Datum } from '../typings/common'; -import { createSymbol, type IGlyph, type ISymbolGraphicAttribute } from '@visactor/vrender-core'; +import type { IGlyph, ISymbolGraphicAttribute } from '@visactor/vrender-core'; +import { createSymbol, registerSymbol } from '../vrender-bridge'; import { clamp } from '@visactor/vutils'; -import { registerSymbol } from '@visactor/vrender-kits/register/register-symbol'; export class RippleMark extends GlyphMark implements IRippleMark { static readonly type = MarkTypeEnum.ripple; diff --git a/packages/vchart/src/mark/rule.ts b/packages/vchart/src/mark/rule.ts index eab6ccbfed..106f12f6b8 100644 --- a/packages/vchart/src/mark/rule.ts +++ b/packages/vchart/src/mark/rule.ts @@ -4,10 +4,8 @@ import { BaseMark } from './base/base-mark'; import type { IMarkGraphic, IMarkStyle, IRuleMark } from './interface'; // eslint-disable-next-line no-duplicate-imports import { MarkTypeEnum } from './interface/type'; -import { registerLine } from '@visactor/vrender-kits/register/register-line'; -import { registerShadowRoot } from '@visactor/vrender-kits/register/register-shadowRoot'; import type { IGraphic, ILineGraphicAttribute } from '@visactor/vrender-core'; -import { createLine } from '@visactor/vrender-core'; +import { createLine, registerLine, registerShadowRoot } from '../vrender-bridge'; export class RuleMark extends BaseMark implements IRuleMark { static readonly type = MarkTypeEnum.rule; diff --git a/packages/vchart/src/mark/symbol.ts b/packages/vchart/src/mark/symbol.ts index cbd5cc9e8d..906494063b 100644 --- a/packages/vchart/src/mark/symbol.ts +++ b/packages/vchart/src/mark/symbol.ts @@ -5,9 +5,7 @@ import type { IMarkGraphic, IMarkStyle, ISymbolMark } from './interface'; // eslint-disable-next-line no-duplicate-imports import { MarkTypeEnum } from './interface/type'; import type { ISymbolGraphicAttribute } from '@visactor/vrender-core'; -import { createSymbol } from '@visactor/vrender-core'; -import { registerShadowRoot } from '@visactor/vrender-kits/register/register-shadowRoot'; -import { registerSymbol } from '@visactor/vrender-kits/register/register-symbol'; +import { createSymbol, registerShadowRoot, registerSymbol } from '../vrender-bridge'; import { registerSymbolDataLabel } from '@visactor/vrender-components/label/symbol'; import { isNil } from '@visactor/vutils'; diff --git a/packages/vchart/src/mark/text.ts b/packages/vchart/src/mark/text.ts index 2d43f7edc2..0130c9afa5 100644 --- a/packages/vchart/src/mark/text.ts +++ b/packages/vchart/src/mark/text.ts @@ -5,11 +5,8 @@ import type { IMarkGraphic, IMarkOption, IMarkStyle } from './interface'; // eslint-disable-next-line no-duplicate-imports import { MarkTypeEnum } from './interface'; import type { ITextMark, ITextSpec } from './interface/mark'; -import { registerRichtext } from '@visactor/vrender-kits/register/register-richtext'; -import { registerShadowRoot } from '@visactor/vrender-kits/register/register-shadowRoot'; -import { registerText } from '@visactor/vrender-kits/register/register-text'; import type { IGraphic, IRichTextGraphicAttribute, ITextGraphicAttribute } from '@visactor/vrender-core'; -import { createRichText, createText } from '@visactor/vrender-core'; +import { createRichText, createText, registerRichtext, registerShadowRoot, registerText } from '../vrender-bridge'; import { isObject, isValid } from '@visactor/vutils'; export class TextMark extends BaseMark implements ITextMark { diff --git a/packages/vchart/src/plugin/components/tooltip-handler/dom-tooltip-handler.ts b/packages/vchart/src/plugin/components/tooltip-handler/dom-tooltip-handler.ts index de0e533239..98b212a39e 100644 --- a/packages/vchart/src/plugin/components/tooltip-handler/dom-tooltip-handler.ts +++ b/packages/vchart/src/plugin/components/tooltip-handler/dom-tooltip-handler.ts @@ -20,6 +20,13 @@ import { getSvgHtml } from './utils/svg'; import { formatContent } from './utils/common'; import { token } from '../../../theme/token'; import { calcLayoutNumber } from '../../../util/space'; + +const isTooltipParentElement = (element: unknown): element is HTMLElement | HTMLCanvasElement => + !!element && + (element as HTMLElement).nodeType === 1 && + typeof (element as HTMLElement).appendChild === 'function' && + !!(element as HTMLElement).children; + /** * The tooltip handler class. */ @@ -69,10 +76,26 @@ export class DomTooltipHandler extends BaseTooltipHandler { this.initEl(); } + protected _getTooltipParentElement(tooltipSpec: ITooltipSpec) { + if (isTooltipParentElement(tooltipSpec.parentElement)) { + return tooltipSpec.parentElement; + } + + if (isTooltipParentElement(this._chartContainer)) { + return this._chartContainer; + } + + if (isTooltipParentElement(domDocument?.body)) { + return domDocument.body; + } + + return undefined; + } + initEl() { const tooltipSpec = this._component.getSpec() as ITooltipSpec; - const parentElement = tooltipSpec.parentElement as HTMLElement | HTMLCanvasElement; - if (domDocument && parentElement && parentElement.children && parentElement.children.length) { + const parentElement = this._getTooltipParentElement(tooltipSpec); + if (domDocument && parentElement) { for (let i = 0; i < parentElement.children.length; i++) { if (parentElement.children[i].classList.contains(TOOLTIP_CONTAINER_EL_CLASS_NAME)) { this._container = parentElement.children[i] as HTMLDivElement; @@ -90,8 +113,15 @@ export class DomTooltipHandler extends BaseTooltipHandler { } initRootDom() { + if (!this._container) { + this.initEl(); + } + if (!this._container) { + return; + } + const tooltipSpec = this._component.getSpec() as ITooltipSpec; - const tooltipElement = document.createElement('div'); + const tooltipElement = domDocument.createElement('div'); const themeFontFamily = this._chartOption?.getTheme('fontFamily'); setStyleToDom(tooltipElement, { left: '0', @@ -394,7 +424,7 @@ export class DomTooltipHandler extends BaseTooltipHandler { } protected _getParentElement(spec: ITooltipSpec): HTMLElement { - return this._container ?? super._getParentElement(spec); + return this._container ?? (this._getTooltipParentElement(spec) as HTMLElement); } isTooltipShown() { diff --git a/packages/vchart/src/plugin/components/tooltip-handler/utils/attribute.ts b/packages/vchart/src/plugin/components/tooltip-handler/utils/attribute.ts index b76899df7a..27ff4f72ad 100644 --- a/packages/vchart/src/plugin/components/tooltip-handler/utils/attribute.ts +++ b/packages/vchart/src/plugin/components/tooltip-handler/utils/attribute.ts @@ -15,7 +15,7 @@ import type { ITheme } from '../../../../theme'; import type { ITooltipSpec, ITooltipTextTheme, ITooltipTheme } from '../../../../component/tooltip'; import { token } from '../../../../theme/token'; // eslint-disable-next-line no-duplicate-imports -import { getRichTextBounds } from '@visactor/vrender-core'; +import { getRichTextBounds } from '@visactor/vrender-core/text'; // eslint-disable-next-line no-duplicate-imports import type { IRichTextCharacter, IRichTextParagraphCharacter } from '@visactor/vrender-core'; diff --git a/packages/vchart/src/plugin/components/tooltip-handler/utils/svg.ts b/packages/vchart/src/plugin/components/tooltip-handler/utils/svg.ts index fafd449f8d..75b46c8413 100644 --- a/packages/vchart/src/plugin/components/tooltip-handler/utils/svg.ts +++ b/packages/vchart/src/plugin/components/tooltip-handler/utils/svg.ts @@ -1,7 +1,8 @@ import { escapeHTML } from './common'; // eslint-disable-next-line no-duplicate-imports import type { CustomSymbolClass, IColor, IGradientColor, ILinearGradient } from '@visactor/vrender-core'; -import { Symbol, GradientParser } from '@visactor/vrender-core'; +import { Symbol } from '@visactor/vrender-core/graphic/symbol'; +import { GradientParser } from '@visactor/vrender-core/svg'; import { Bounds, isObject, isString } from '@visactor/vutils'; import type { ITooltipShapeActual } from '../../../../typings'; diff --git a/packages/vchart/src/plugin/other.ts b/packages/vchart/src/plugin/other.ts index 49bcf4f3f1..f1563d3a38 100644 --- a/packages/vchart/src/plugin/other.ts +++ b/packages/vchart/src/plugin/other.ts @@ -1,9 +1,7 @@ -import { registerHtmlAttributePlugin, registerReactAttributePlugin } from '@visactor/vrender-core'; - -import { registerAnimate as registerVRenderAnimate } from '@visactor/vrender-animate/register'; import { DragNDrop, Gesture } from '@visactor/vrender-kits/event/extension'; import { Factory } from '../core/factory'; import { registerBuiltInAnimation, registerStageAnimation } from '../animation/config'; +import { registerHtmlAttributePlugin, registerReactAttributePlugin, registerVRenderAnimate } from '../vrender-bridge'; export const registerAnimate = () => { registerVRenderAnimate(); diff --git a/packages/vchart/src/series/bar/bar.ts b/packages/vchart/src/series/bar/bar.ts index 689f77a7e3..8df32f83c0 100644 --- a/packages/vchart/src/series/bar/bar.ts +++ b/packages/vchart/src/series/bar/bar.ts @@ -39,7 +39,7 @@ import { getGroupAnimationParams } from '../util/utils'; import { BarSeriesSpecTransformer } from './bar-transformer'; import { ComponentTypeEnum } from '../../component/interface'; import { RECT_X, RECT_X1, RECT_Y, RECT_Y1 } from '../base/constant'; -import { createRect } from '@visactor/vrender-core'; +import { createRect } from '../../vrender-bridge'; import { registerCartesianLinearAxis, registerCartesianBandAxis } from '../../component/axis/cartesian'; import type { ICompilableData } from '../../compile/data'; import { CompilableData } from '../../compile/data'; diff --git a/packages/vchart/src/series/box-plot/animation.ts b/packages/vchart/src/series/box-plot/animation.ts index 4c84257ed6..b5d8fe0a70 100644 --- a/packages/vchart/src/series/box-plot/animation.ts +++ b/packages/vchart/src/series/box-plot/animation.ts @@ -2,7 +2,8 @@ import type { EasingType, ILineAttribute, IRectAttribute } from '@visactor/vrend import type { IGlyph } from '@visactor/vrender-core'; import type { IAnimationParameters } from '../../animation/interface'; import { isValidNumber } from '@visactor/vutils'; -import { ACustomAnimate, AnimateExecutor } from '@visactor/vrender-animate'; +import { ACustomAnimate } from '@visactor/vrender-animate/custom/custom-animate'; +import { AnimateExecutor } from '@visactor/vrender-animate/executor/animate-executor'; export interface IBoxplotScaleAnimationOptions { center?: number; } diff --git a/packages/vchart/src/series/liquid/liquid.ts b/packages/vchart/src/series/liquid/liquid.ts index b32a034f42..a8fddd4aa6 100644 --- a/packages/vchart/src/series/liquid/liquid.ts +++ b/packages/vchart/src/series/liquid/liquid.ts @@ -19,7 +19,7 @@ import { BaseSeries } from '../base'; // eslint-disable-next-line no-duplicate-imports import { registerGroupMark } from '../../mark/group'; import { getShapes } from './util'; -import { createRect, createSymbol } from '@visactor/vrender-core'; +import { createRect, createSymbol } from '../../vrender-bridge'; import type { IColor, IGlyph } from '@visactor/vrender-core'; import { labelSmartInvert } from '@visactor/vrender-components'; import { normalizeLayoutPaddingSpec } from '../../util'; diff --git a/packages/vchart/src/series/polar/animation.ts b/packages/vchart/src/series/polar/animation.ts index 8441446674..cea266b3a4 100644 --- a/packages/vchart/src/series/polar/animation.ts +++ b/packages/vchart/src/series/polar/animation.ts @@ -1,7 +1,8 @@ /* eslint-disable no-duplicate-imports */ import type { EasingType, ILineAttribute } from '@visactor/vrender-core'; import type { IPointLike } from '@visactor/vutils'; -import { ACustomAnimate, TagPointsUpdate } from '@visactor/vrender-animate'; +import { ACustomAnimate } from '@visactor/vrender-animate/custom/custom-animate'; +import { TagPointsUpdate } from '@visactor/vrender-animate/custom/tag-points'; import { Point, isValidNumber, polarToCartesian, cartesianToPolar } from '@visactor/vutils'; import { isClose, isValidPoint, normalizeAngle } from '../../util'; import type { IPoint } from '../../typings'; diff --git a/packages/vchart/src/series/polar/progress-like/progress-like.ts b/packages/vchart/src/series/polar/progress-like/progress-like.ts index 07a278d91a..3802a64785 100644 --- a/packages/vchart/src/series/polar/progress-like/progress-like.ts +++ b/packages/vchart/src/series/polar/progress-like/progress-like.ts @@ -8,7 +8,7 @@ import { valueInScaleRange } from '../../../util/scale'; import { PolarSeries } from '../polar'; import type { IContinuousTickData, IProgressLikeSeriesSpec } from './interface'; import type { IPolarAxis, IPolarAxisSpec } from '../../../component/axis'; -import { createArc, createRect } from '@visactor/vrender-core'; +import { createArc, createRect } from '../../../vrender-bridge'; import type { SeriesMarkMap } from '../../interface'; import { progressLikeSeriesMark } from './constant'; import type { ISeriesSpecUpdatePolicy } from '../../base/base-series'; diff --git a/packages/vchart/src/series/radar/animation.ts b/packages/vchart/src/series/radar/animation.ts index b8d70fd035..8004507b86 100644 --- a/packages/vchart/src/series/radar/animation.ts +++ b/packages/vchart/src/series/radar/animation.ts @@ -1,9 +1,10 @@ import type { IGraphic } from '@visactor/vrender-core'; -import { ClipAngleAnimate, AnimateExecutor } from '@visactor/vrender-animate'; +import { ClipAngleAnimate } from '@visactor/vrender-animate/custom/clip-graphic'; +import { AnimateExecutor } from '@visactor/vrender-animate/executor/animate-executor'; import { Factory } from '../../core/factory'; import { PolarPointUpdate, PolarTagPointsUpdate } from '../polar/animation'; import { DEFAULT_ANIMATION_CONFIG } from '../../animation/config'; -import { registerArc } from '@visactor/vrender-kits/register/register-arc'; +import { registerArc } from '../../vrender-bridge'; import type { IRadarAnimationParams, RadarAppearPreset } from './interface'; import type { IAnimationTypeConfig, MarkAnimationSpec } from '../../animation/interface'; import type { Datum } from '../../typings/common'; diff --git a/packages/vchart/src/series/sankey/animation.ts b/packages/vchart/src/series/sankey/animation.ts index be0f80d64c..5c37f60758 100644 --- a/packages/vchart/src/series/sankey/animation.ts +++ b/packages/vchart/src/series/sankey/animation.ts @@ -5,7 +5,8 @@ import { DEFAULT_ANIMATION_CONFIG } from '../../animation/config'; import { FadeInOutAnimation } from '../../animation/config'; import type { ISankeyAnimationParams, SankeyAppearPreset } from './interface'; import type { IAnimationTypeConfig, IAnimationParameters } from '../../animation/interface'; -import { ACustomAnimate, AnimateExecutor } from '@visactor/vrender-animate'; +import { ACustomAnimate } from '@visactor/vrender-animate/custom/custom-animate'; +import { AnimateExecutor } from '@visactor/vrender-animate/executor/animate-executor'; import type { IGraphic } from '@visactor/vrender-core'; import type { ILinkPathMarkSpec } from '../../typings'; diff --git a/packages/vchart/src/series/venn/animation.ts b/packages/vchart/src/series/venn/animation.ts index 3b81f266f5..ecb01d949f 100644 --- a/packages/vchart/src/series/venn/animation.ts +++ b/packages/vchart/src/series/venn/animation.ts @@ -1,10 +1,9 @@ -import { ACustomAnimate } from '@visactor/vrender-animate'; +import { ACustomAnimate } from '@visactor/vrender-animate/custom/custom-animate'; import type { IVennCircle, IVennOverlapArc, VennCircleName } from '@visactor/vlayouts'; import { getArcsFromCircles, getCirclesFromArcs, getPathFromArcs } from '@visactor/vlayouts'; import type { VennAppearPreset } from './interface'; import type { IAnimationTypeConfig } from '../../animation/interface'; -// import { ACustomAnimate } from '@visactor/vrender-animate'; import { Factory } from '../../core/factory'; import { DEFAULT_ANIMATION_CONFIG } from '../../animation/config'; diff --git a/packages/vchart/src/series/word-cloud/base.ts b/packages/vchart/src/series/word-cloud/base.ts index c5371c0d58..297182a371 100644 --- a/packages/vchart/src/series/word-cloud/base.ts +++ b/packages/vchart/src/series/word-cloud/base.ts @@ -39,7 +39,8 @@ import type { IMark, IRectMark, ITextMark } from '../../mark/interface'; import { LinearScale } from '@visactor/vscale'; import type { GeometricMaskShape, TextShapeMask } from '@visactor/vlayouts'; import type { ITransformSpec } from '../../compile/interface'; -import { vglobal, getTextBounds, createImage } from '@visactor/vrender-core'; +import { createImage, vglobal } from '../../vrender-bridge'; +import { getTextBounds } from '@visactor/vrender-core/text'; import { wordCloud } from '../../theme/builtin/common/series/word-cloud'; import { LayoutZIndex } from '../../constant/layout'; import { ChartEvent } from '../../core'; diff --git a/packages/vchart/src/util/env.ts b/packages/vchart/src/util/env.ts index 3e8da27820..49e6b7a5f1 100644 --- a/packages/vchart/src/util/env.ts +++ b/packages/vchart/src/util/env.ts @@ -1,4 +1,4 @@ -import { isBrowserEnv } from '@visactor/vrender-core'; +import { isBrowserEnv } from '@visactor/vrender-core/env'; import type { RenderMode } from '../typings/spec'; export const isBrowser = isBrowserEnv(); diff --git a/packages/vchart/src/vrender-bridge.ts b/packages/vchart/src/vrender-bridge.ts new file mode 100644 index 0000000000..8830e383f8 --- /dev/null +++ b/packages/vchart/src/vrender-bridge.ts @@ -0,0 +1,132 @@ +import { + createArc, + createArea, + createGlyph, + createGraphic, + createGroup, + createImage, + createLine, + createPath, + createPolygon, + createRect, + createRichText, + createSymbol, + createText, + graphicCreator +} from '@visactor/vrender-core/graphic/creator'; +import { vglobal } from '@visactor/vrender-core/global'; +import { CustomPath2D } from '@visactor/vrender-core/path'; +import { registerHtmlAttributePlugin, registerReactAttributePlugin } from '@visactor/vrender-core/plugin/attribute'; +import { registerAnimate as registerVRenderAnimate } from '@visactor/vrender-animate/register'; +import { registerArc } from '@visactor/vrender-kits/register/register-arc'; +import { registerArc3d } from '@visactor/vrender-kits/register/register-arc3d'; +import { registerArea } from '@visactor/vrender-kits/register/register-area'; +import { registerGlyph } from '@visactor/vrender-kits/register/register-glyph'; +import { registerGroup } from '@visactor/vrender-kits/register/register-group'; +import { registerImage } from '@visactor/vrender-kits/register/register-image'; +import { registerLine } from '@visactor/vrender-kits/register/register-line'; +import { registerPath } from '@visactor/vrender-kits/register/register-path'; +import { registerPolygon } from '@visactor/vrender-kits/register/register-polygon'; +import { registerPyramid3d } from '@visactor/vrender-kits/register/register-pyramid3d'; +import { registerRect } from '@visactor/vrender-kits/register/register-rect'; +import { registerRect3d } from '@visactor/vrender-kits/register/register-rect3d'; +import { registerRichtext } from '@visactor/vrender-kits/register/register-richtext'; +import { registerShadowRoot } from '@visactor/vrender-kits/register/register-shadowRoot'; +import { registerSymbol } from '@visactor/vrender-kits/register/register-symbol'; +import { registerText } from '@visactor/vrender-kits/register/register-text'; +import type { + IArc3d, + IArc3dGraphicAttribute, + IPyramid3d, + IPyramid3dGraphicAttribute, + IRect3d, + IRect3dGraphicAttribute, + IStage +} from '@visactor/vrender-core'; + +export { + createArc, + createArea, + createGlyph, + createGraphic, + createGroup, + createImage, + createLine, + createPath, + createPolygon, + createRect, + createRichText, + createSymbol, + createText, + graphicCreator, + CustomPath2D, + registerHtmlAttributePlugin, + registerReactAttributePlugin, + registerVRenderAnimate, + registerArc, + registerArc3d, + registerArea, + registerGlyph, + registerGroup, + registerImage, + registerLine, + registerPath, + registerPolygon, + registerPyramid3d, + registerRect, + registerRect3d, + registerRichtext, + registerShadowRoot, + registerSymbol, + registerText, + vglobal +}; + +export const createArc3d = (attributes: IArc3dGraphicAttribute): IArc3d => { + registerArc3d(); + return createGraphic('arc3d', attributes) as IArc3d; +}; + +export const createPyramid3d = (attributes: IPyramid3dGraphicAttribute): IPyramid3d => { + registerPyramid3d(); + return createGraphic('pyramid3d', attributes) as IPyramid3d; +}; + +export const createRect3d = (attributes: IRect3dGraphicAttribute): IRect3d => { + registerRect3d(); + return createGraphic('rect3d', attributes) as IRect3d; +}; + +export const waitForAllSubLayers = (stage: IStage) => + new Promise(resolve => { + vglobal.getRequestAnimationFrame()(() => { + resolve(null); + }); + }).then(() => { + const promiseList: Promise[] = []; + const layers = stage.getChildren(); + + layers.forEach((layer: any) => { + if (!layer.subLayers?.size) { + return; + } + + layer.subLayers.forEach((subLayer: any) => { + const drawContribution = subLayer.drawContribution; + if (drawContribution?.hooks && drawContribution.rendering) { + promiseList.push( + new Promise(resolve => { + drawContribution.hooks.completeDraw.tap('outWait', () => { + drawContribution.hooks.completeDraw.taps = drawContribution.hooks.completeDraw.taps.filter( + (item: { name: string }) => item.name !== 'outWait' + ); + resolve(null); + }); + }) + ); + } + }); + }); + + return Promise.all(promiseList); + }); diff --git a/packages/vchart/src/vrender-tools.ts b/packages/vchart/src/vrender-tools.ts index 07c887c8c9..372a83859b 100644 --- a/packages/vchart/src/vrender-tools.ts +++ b/packages/vchart/src/vrender-tools.ts @@ -19,4 +19,4 @@ export { centerToCorner, pulseWave, particleEffect -} from '@visactor/vrender-kits'; +} from '@visactor/vrender-kits/tools/dynamicTexture/effect'; diff --git a/packages/vchart/tsconfig.json b/packages/vchart/tsconfig.json index 1e3b27a0e5..3b33aa74c3 100644 --- a/packages/vchart/tsconfig.json +++ b/packages/vchart/tsconfig.json @@ -12,6 +12,7 @@ "@visactor/vrender": ["./node_modules/@visactor/vrender/es/index"], "@visactor/vrender/*": ["./node_modules/@visactor/vrender/es/*"], "@visactor/vrender-core": ["./node_modules/@visactor/vrender-core/es/index"], + "@visactor/vrender-core/event/constant": ["./node_modules/@visactor/vrender-core/es/event/public-constant"], "@visactor/vrender-core/*": ["./node_modules/@visactor/vrender-core/es/*"], "@visactor/vrender-animate": ["./node_modules/@visactor/vrender-animate/es/index"], "@visactor/vrender-animate/*": ["./node_modules/@visactor/vrender-animate/es/*"], diff --git a/tools/bundler/src/bootstrap.ts b/tools/bundler/src/bootstrap.ts index 8890cba042..df69dfd3ed 100644 --- a/tools/bundler/src/bootstrap.ts +++ b/tools/bundler/src/bootstrap.ts @@ -4,7 +4,7 @@ import ms from 'ms'; import watcher from 'glob-watcher'; import { DebugConfig } from './logic/debug'; import { parserCLIArgs, getDefaultConfig, getFinalConfig, loadConfigFile, DEFAULT_CONFIG_FILE } from './logic/config'; -import type { _ModuleKind } from './logic/config'; +import type { _ModuleKind, Config } from './logic/config'; import { loadPackageJson } from './logic/package'; import Undertaker, { Task } from 'undertaker'; import Spinnies from '@trufflesuite/spinnies'; @@ -32,6 +32,19 @@ enum Tasks { // COPY_DIST = "Copy dist", COPY_FILES = 'Copy files' } + +function mergeRollupOptions( + base: Config['rollupOptions'], + extra: Config['esTotalRollupOptions'] +): Config['rollupOptions'] { + return { + ...base, + ...extra, + prePlugins: [...(base.prePlugins ?? []), ...(extra.prePlugins ?? [])], + plugins: [...((base.plugins ?? []) as any[]), ...((extra.plugins ?? []) as any[])] + }; +} + async function bootstrap() { const args = parserCLIArgs(process.argv.slice(2)); DebugConfig('CLI args', args); @@ -104,7 +117,18 @@ async function bootstrap() { return; } else if (format === 'es' && config.esTotalFile) { subBuildTasks.push(`${taskName}_total`); - _task(`${taskName}_total`, () => buildES({ ...config, minify: false }, PROJECT_ROOT, rawPackageJson, false)); + _task(`${taskName}_total`, () => + buildES( + { + ...config, + minify: false, + rollupOptions: mergeRollupOptions(config.rollupOptions, config.esTotalRollupOptions) + }, + PROJECT_ROOT, + rawPackageJson, + false + ) + ); } _task(taskName, () => diff --git a/tools/bundler/src/logic/config.ts b/tools/bundler/src/logic/config.ts index 5a60828403..1d17103baf 100644 --- a/tools/bundler/src/logic/config.ts +++ b/tools/bundler/src/logic/config.ts @@ -1,6 +1,6 @@ import ArgsParser, { Arguments } from 'yargs-parser'; import type { RawPackageJson } from './package'; -import type { RollupOptions } from 'rollup'; +import type { Plugin, RollupOptions } from 'rollup'; import type { Alias } from '@rollup/plugin-alias'; import type { RollupNodeResolveOptions } from '@rollup/plugin-node-resolve'; @@ -102,7 +102,9 @@ export interface Config { // 构建 UMD 产物时,传递给 @rollup/plugin-alias 作为 entries 的选项 alias: Array; // 额外的 rollup 配置项 - rollupOptions: Omit; + rollupOptions: Omit & { prePlugins?: Plugin[] }; + // 仅用于 esTotalFile 产物的额外 rollup 配置项 + esTotalRollupOptions: Omit & { prePlugins?: Plugin[] }; // 传给 @rollup/plugin-node-resolve 的配置项 nodeResolveOptions: | RollupNodeResolveOptions @@ -159,6 +161,7 @@ export function getDefaultConfig(): Config { external: [], alias: [], rollupOptions: {}, + esTotalRollupOptions: {}, nodeResolveOptions: {}, preTasks: {}, postTasks: {}, diff --git a/tools/bundler/src/logic/rollup.config.ts b/tools/bundler/src/logic/rollup.config.ts index 788b8ce5d8..ffc5e1af7c 100644 --- a/tools/bundler/src/logic/rollup.config.ts +++ b/tools/bundler/src/logic/rollup.config.ts @@ -42,11 +42,14 @@ export function getRollupOptions( babelPlugins: BabelPlugins, config: Config ): RollupOptions { + const { prePlugins = [], plugins = [], ...rollupOptions } = config.rollupOptions; + return { input: entry, external: getExternal(rawPackageJson, config.external), - ...config.rollupOptions, + ...rollupOptions, plugins: [ + ...prePlugins, resolve(getNodeResolveOptions(entry, config)), commonjs(), babel({ ...babelPlugins, babelHelpers: 'bundled' }), @@ -68,7 +71,7 @@ export function getRollupOptions( }), Alias({ entries: config.alias }), ...(config.minify ? [terser()] : []), - ...((config.rollupOptions.plugins as Plugin[]) || []) + ...(plugins as Plugin[]) ] }; } diff --git a/tools/story-player/package.json b/tools/story-player/package.json index ee891ed506..47a8064444 100644 --- a/tools/story-player/package.json +++ b/tools/story-player/package.json @@ -56,10 +56,10 @@ "vite": "3.2.6" }, "dependencies": { - "@visactor/vrender-core": "^1.1.3", - "@visactor/vrender-kits": "^1.1.3", + "@visactor/vrender-core": "~1.1.4", + "@visactor/vrender-kits": "~1.1.4", "@visactor/vchart": "workspace:2.1.1", - "@visactor/vrender": "^1.1.3", + "@visactor/vrender": "~1.1.4", "@visactor/vutils": "~1.0.23" } } From 73636be1e9b2e95605cfa1899148a1e84d194f0d Mon Sep 17 00:00:00 2001 From: "lixuefei.1313" Date: Mon, 6 Jul 2026 16:43:44 +0800 Subject: [PATCH 3/6] fix: preserve seriesStyle on theme update --- .../vchart/__tests__/unit/theme/radar.test.ts | 96 +++++++++++++++++++ .../vchart/src/series/base/base-series.ts | 1 + packages/vchart/tsconfig.test.json | 1 + 3 files changed, 98 insertions(+) diff --git a/packages/vchart/__tests__/unit/theme/radar.test.ts b/packages/vchart/__tests__/unit/theme/radar.test.ts index 7e59b6271a..8a09578ca3 100644 --- a/packages/vchart/__tests__/unit/theme/radar.test.ts +++ b/packages/vchart/__tests__/unit/theme/radar.test.ts @@ -88,4 +88,100 @@ describe('radar theme test', () => { expect(series?.getSpec()?.area?.visible).toBe(true); expect(series?.getSpec()?.area?.style?.lineDash).toEqual([2, 2]); }); + + it('should preserve radar seriesStyle after setting current theme', async () => { + vchart = new VChart( + { + type: 'radar', + data: [ + { + id: 'd', + values: [ + { key: 'A', value: 90, group: 'S1' }, + { key: 'B', value: 60, group: 'S1' }, + { key: 'C', value: 70, group: 'S1' }, + { key: 'D', value: 80, group: 'S1' }, + { key: 'A', value: 40, group: 'S2' }, + { key: 'B', value: 80, group: 'S2' }, + { key: 'C', value: 55, group: 'S2' }, + { key: 'D', value: 65, group: 'S2' } + ] + } + ], + categoryField: 'key', + valueField: 'value', + seriesField: 'group', + animation: false, + tooltip: { + visible: false + }, + area: { + visible: true + }, + seriesStyle: [ + { + name: 'S1', + area: { + style: { + fill: '#ff00ff', + fillOpacity: 0.9 + } + }, + line: { + style: { + stroke: '#ff00ff' + } + } + }, + { + name: 'S2', + area: { + style: { + fill: '#00ffff', + fillOpacity: 0.9 + } + }, + line: { + style: { + stroke: '#00ffff' + } + } + } + ], + axes: [ + { orient: 'radius', min: 0, max: 100, grid: { visible: true } }, + { orient: 'angle', grid: { visible: true } } + ] + } as IRadarChartSpec, + { + renderCanvas: canvasDom, + background: 'yellow', + autoFit: true, + animation: false + } + ); + + await vchart.renderAsync(); + + const series = vchart.getChart()?.getAllSeries()?.[0]; + const getMarkAttributes = (markName: string) => + series + ?.getMarkInName(markName) + ?.getGraphics() + .map(graphic => graphic.attribute); + + expect(getMarkAttributes('area')?.map(attribute => [attribute.fill, attribute.fillOpacity])).toEqual([ + ['#ff00ff', 0.9], + ['#00ffff', 0.9] + ]); + expect(getMarkAttributes('line')?.map(attribute => attribute.stroke)).toEqual(['#ff00ff', '#00ffff']); + + await vchart.setCurrentTheme(vchart.getCurrentThemeName()); + + expect(getMarkAttributes('area')?.map(attribute => [attribute.fill, attribute.fillOpacity])).toEqual([ + ['#ff00ff', 0.9], + ['#00ffff', 0.9] + ]); + expect(getMarkAttributes('line')?.map(attribute => attribute.stroke)).toEqual(['#ff00ff', '#00ffff']); + }); }); diff --git a/packages/vchart/src/series/base/base-series.ts b/packages/vchart/src/series/base/base-series.ts index 104f4fa120..0e0b816711 100644 --- a/packages/vchart/src/series/base/base-series.ts +++ b/packages/vchart/src/series/base/base-series.ts @@ -1274,6 +1274,7 @@ export abstract class BaseSeries extends BaseModel imp (this._spec as any)[mark.name] && this.initMarkStyleWithSpec(mark, (this._spec as any)[mark.name]); }); this.initMarkStyle(); + this.initMarkState(); marks.forEach(mark => { mark.commit(false); }); diff --git a/packages/vchart/tsconfig.test.json b/packages/vchart/tsconfig.test.json index aaa5165387..06403a02e0 100644 --- a/packages/vchart/tsconfig.test.json +++ b/packages/vchart/tsconfig.test.json @@ -6,6 +6,7 @@ "@visactor/vrender": ["./node_modules/@visactor/vrender/es/index"], "@visactor/vrender/*": ["./node_modules/@visactor/vrender/es/*"], "@visactor/vrender-core": ["./node_modules/@visactor/vrender-core/es/index"], + "@visactor/vrender-core/event/constant": ["./node_modules/@visactor/vrender-core/es/event/public-constant"], "@visactor/vrender-core/*": ["./node_modules/@visactor/vrender-core/es/*"], "@visactor/vrender-animate": ["./node_modules/@visactor/vrender-animate/es/index"], "@visactor/vrender-animate/*": ["./node_modules/@visactor/vrender-animate/es/*"], From 2a8e4ae046e38092c42fce8bd1511b0abb33bb09 Mon Sep 17 00:00:00 2001 From: "lixuefei.1313" Date: Mon, 6 Jul 2026 16:44:24 +0800 Subject: [PATCH 4/6] docs: update changelog of rush --- .../chore-vrender-1-1-4-deps_2026-07-06.json | 11 +++++++++++ .../chore-vrender-1-1-4-deps_2026-07-06.json | 11 +++++++++++ .../fix-bytepack-3d-entry_2026-07-06.json | 11 +++++++++++ .../fix-bytepack-vrender-theme-update_2026-07-06.json | 11 +++++++++++ 4 files changed, 44 insertions(+) create mode 100644 common/changes/@visactor/openinula-vchart/chore-vrender-1-1-4-deps_2026-07-06.json create mode 100644 common/changes/@visactor/react-vchart/chore-vrender-1-1-4-deps_2026-07-06.json create mode 100644 common/changes/@visactor/vchart-extension/fix-bytepack-3d-entry_2026-07-06.json create mode 100644 common/changes/@visactor/vchart/fix-bytepack-vrender-theme-update_2026-07-06.json diff --git a/common/changes/@visactor/openinula-vchart/chore-vrender-1-1-4-deps_2026-07-06.json b/common/changes/@visactor/openinula-vchart/chore-vrender-1-1-4-deps_2026-07-06.json new file mode 100644 index 0000000000..1f876b8939 --- /dev/null +++ b/common/changes/@visactor/openinula-vchart/chore-vrender-1-1-4-deps_2026-07-06.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "packageName": "@visactor/openinula-vchart", + "comment": "chore: align VRender runtime dependencies with the VChart VRender 1.1.4 upgrade", + "type": "patch" + } + ], + "packageName": "@visactor/openinula-vchart", + "email": "openai@example.com" +} diff --git a/common/changes/@visactor/react-vchart/chore-vrender-1-1-4-deps_2026-07-06.json b/common/changes/@visactor/react-vchart/chore-vrender-1-1-4-deps_2026-07-06.json new file mode 100644 index 0000000000..7a1a0f5eaa --- /dev/null +++ b/common/changes/@visactor/react-vchart/chore-vrender-1-1-4-deps_2026-07-06.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "packageName": "@visactor/react-vchart", + "comment": "chore: align VRender runtime dependencies with the VChart VRender 1.1.4 upgrade", + "type": "patch" + } + ], + "packageName": "@visactor/react-vchart", + "email": "openai@example.com" +} diff --git a/common/changes/@visactor/vchart-extension/fix-bytepack-3d-entry_2026-07-06.json b/common/changes/@visactor/vchart-extension/fix-bytepack-3d-entry_2026-07-06.json new file mode 100644 index 0000000000..ff36986e30 --- /dev/null +++ b/common/changes/@visactor/vchart-extension/fix-bytepack-3d-entry_2026-07-06.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "packageName": "@visactor/vchart-extension", + "comment": "fix: keep 3D chart entries on narrow VChart and VRender subpaths for BytePack ESM loading", + "type": "patch" + } + ], + "packageName": "@visactor/vchart-extension", + "email": "openai@example.com" +} diff --git a/common/changes/@visactor/vchart/fix-bytepack-vrender-theme-update_2026-07-06.json b/common/changes/@visactor/vchart/fix-bytepack-vrender-theme-update_2026-07-06.json new file mode 100644 index 0000000000..2570ca632a --- /dev/null +++ b/common/changes/@visactor/vchart/fix-bytepack-vrender-theme-update_2026-07-06.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "packageName": "@visactor/vchart", + "comment": "fix: stabilize BytePack ESM VRender registration paths and preserve seriesStyle after theme updates", + "type": "patch" + } + ], + "packageName": "@visactor/vchart", + "email": "openai@example.com" +} From 903be440efb5986ff71401ad366854595ce8313f Mon Sep 17 00:00:00 2001 From: "lixuefei.1313" Date: Mon, 6 Jul 2026 17:55:11 +0800 Subject: [PATCH 5/6] fix: stabilize vrender plugin and glyph state handling --- packages/vchart/src/compile/compiler.ts | 29 ++- .../vchart/src/compile/interface/compiler.ts | 4 + packages/vchart/src/component/poptip/index.ts | 15 +- packages/vchart/src/core/factory-registry.ts | 4 +- packages/vchart/src/core/factory.ts | 13 +- packages/vchart/src/core/vchart.ts | 9 +- packages/vchart/src/mark/glyph.ts | 12 +- packages/vchart/src/series/sankey/sankey.ts | 168 ++++++++++++------ 8 files changed, 187 insertions(+), 67 deletions(-) diff --git a/packages/vchart/src/compile/compiler.ts b/packages/vchart/src/compile/compiler.ts index 173563ea0a..4562c77c2e 100644 --- a/packages/vchart/src/compile/compiler.ts +++ b/packages/vchart/src/compile/compiler.ts @@ -10,7 +10,7 @@ import { array, isArray, isObject, isValid } from '@visactor/vutils'; import type { EventSourceType } from '../event/interface'; import type { IChart } from '../chart/interface'; import { createGroup, vglobal, waitForAllSubLayers } from '../vrender-bridge'; -import type { IColor, IEventTarget, IGroup, IStage } from '@visactor/vrender-core'; +import type { IColor, IEventTarget, IGroup, IPlugin, IStage } from '@visactor/vrender-core'; import type { IMorphConfig } from '../animation/spec'; import type { IVChart, IVChartRenderOption } from '../core/interface'; import type { AnimationStateValues } from '../mark/interface'; @@ -111,6 +111,31 @@ export class Compiler implements ICompiler { return this._stage; } + private _dedupeStagePlugins() { + const { pluginList } = this._option; + const pluginService = this._stage?.pluginService; + if (!pluginList?.length || !pluginService?.findPluginsByName) { + return; + } + + array(pluginList).forEach(pluginName => { + const plugins = pluginService.findPluginsByName(pluginName); + if (plugins.length <= 1) { + return; + } + + const plugin = plugins[0] as IPlugin; + if (pluginService.uninstall) { + pluginService.uninstall(pluginName); + pluginService.register(plugin); + } else { + plugins.slice(1).forEach(duplicatePlugin => { + pluginService.unRegister(duplicatePlugin as IPlugin); + }); + } + }); + } + initView() { if (this._released) { return; @@ -145,6 +170,7 @@ export class Compiler implements ICompiler { modeParams }); this._releaseVRenderAppRef = resolvedApp.releaseAppRef; + this._option.runtimePluginInstallers?.forEach(install => install(resolvedApp.app)); try { // Canvas view binding is stage-scoped. Keep it out of app envParams so @@ -186,6 +212,7 @@ export class Compiler implements ICompiler { } } + this._dedupeStagePlugins(); this._stage.enableIncrementalAutoRender(); // 之前vgrammar 设置了一些默认配置 diff --git a/packages/vchart/src/compile/interface/compiler.ts b/packages/vchart/src/compile/interface/compiler.ts index d69d0d9a0e..d2cc3e8998 100644 --- a/packages/vchart/src/compile/interface/compiler.ts +++ b/packages/vchart/src/compile/interface/compiler.ts @@ -184,6 +184,10 @@ export interface IRenderOption { * vrender 的插件列表 */ pluginList?: string[]; + /** + * stage 创建前需要安装到当前 VRender app 的插件。 + */ + runtimePluginInstallers?: ((app?: IApp) => void)[]; /** * vrender 的 ticker */ diff --git a/packages/vchart/src/component/poptip/index.ts b/packages/vchart/src/component/poptip/index.ts index 4f4b1553f8..2a6db3a977 100644 --- a/packages/vchart/src/component/poptip/index.ts +++ b/packages/vchart/src/component/poptip/index.ts @@ -1,5 +1,16 @@ -import { loadPoptip } from '@visactor/vrender-components'; +import { installPoptipToApp, loadPoptip } from '@visactor/vrender-components/poptip'; +import type { IApp } from '@visactor/vrender-core'; +import { Factory } from '../../core/factory'; + +const installPoptip = (app?: IApp) => { + if (app) { + installPoptipToApp(app); + } else { + loadPoptip(); + } +}; export const registerPoptip = () => { - loadPoptip(); + Factory.registerRuntimePluginInstaller('poptipForText', installPoptip); + installPoptip(); }; diff --git a/packages/vchart/src/core/factory-registry.ts b/packages/vchart/src/core/factory-registry.ts index 81d697295b..95ea84f5c0 100644 --- a/packages/vchart/src/core/factory-registry.ts +++ b/packages/vchart/src/core/factory-registry.ts @@ -9,7 +9,7 @@ import type { IRegionConstructor } from '../region/interface'; import type { ILayoutConstructor } from '../layout/interface'; import type { IChartPluginConstructor } from '../plugin/chart/interface'; import type { IComponentPluginConstructor } from '../plugin/components/interface'; -import type { IGraphic } from '@visactor/vrender-core'; +import type { IApp, IGraphic } from '@visactor/vrender-core'; import type { GrammarTransformOption, IStageEventPlugin, VRenderComponentOptions } from './interface'; import type { MarkAnimationSpec } from '../animation/interface'; import type { ITriggerConstructor } from '../interaction/interface/trigger'; @@ -43,6 +43,7 @@ export interface IFactoryRegistry { interactionTriggers: Record; composedEventMap: Record; tooltipProcessors: Record; + runtimePluginInstallers: Record void>; formatter?: (text: string | number | string[] | number[], datum: any, formatter: string | string[]) => any; } @@ -76,6 +77,7 @@ const createFactoryRegistry = (): IFactoryRegistry => ({ interactionTriggers: {}, composedEventMap: {}, tooltipProcessors: {}, + runtimePluginInstallers: {}, formatter: undefined }); diff --git a/packages/vchart/src/core/factory.ts b/packages/vchart/src/core/factory.ts index a56650de60..631c72d686 100644 --- a/packages/vchart/src/core/factory.ts +++ b/packages/vchart/src/core/factory.ts @@ -16,7 +16,7 @@ import type { Transform, Parser } from '@visactor/vdataset'; import type { ILayoutConstructor } from '../layout/interface'; import type { IChartPluginConstructor } from '../plugin/chart/interface'; import type { IComponentPluginConstructor } from '../plugin/components/interface'; -import type { IGraphic } from '@visactor/vrender-core'; +import type { IApp, IGraphic } from '@visactor/vrender-core'; import type { GrammarTransformOption, IStageEventPlugin, VRenderComponentOptions } from './interface'; import type { MarkAnimationSpec } from '../animation/interface'; import type { IBaseTriggerOptions, ITriggerConstructor } from '../interaction/interface/trigger'; @@ -336,4 +336,15 @@ export class Factory { } return new Cror(tooltip); }; + + private static _runtimePluginInstallers: Record void> = + factoryRegistry.runtimePluginInstallers; + + static registerRuntimePluginInstaller = (type: string, installer: (app?: IApp) => void) => { + Factory._runtimePluginInstallers[type] = installer; + }; + + static getRuntimePluginInstaller = (type: string) => { + return Factory._runtimePluginInstallers[type]; + }; } diff --git a/packages/vchart/src/core/vchart.ts b/packages/vchart/src/core/vchart.ts index feabe57a81..27cfca67f3 100644 --- a/packages/vchart/src/core/vchart.ts +++ b/packages/vchart/src/core/vchart.ts @@ -28,7 +28,7 @@ import type { import type { IParserOptions, IFields, Transform } from '@visactor/vdataset'; // eslint-disable-next-line no-duplicate-imports import { DataSet, dataViewParser, DataView } from '@visactor/vdataset'; -import type { IGraphic, IStage, Stage } from '@visactor/vrender-core'; +import type { IApp, IGraphic, IStage, Stage } from '@visactor/vrender-core'; // eslint-disable-next-line no-duplicate-imports import { vglobal } from '../vrender-bridge'; import { isString, isValid, isNil, array, specTransform, functionTransform, removeUndefined } from '../util'; @@ -420,8 +420,14 @@ export class VChart implements IVChart { this._updateCurrentTheme(); this._currentSize = this.getCurrentSize(); const pluginList: string[] = []; + const runtimePluginInstallers: ((app?: IApp) => void)[] = []; if (poptip !== false) { + const poptipInstaller = Factory.getRuntimePluginInstaller('poptipForText'); + if (poptipInstaller) { + poptipInstaller(); + runtimePluginInstallers.push(poptipInstaller); + } pluginList.push('poptipForText'); } @@ -446,6 +452,7 @@ export class VChart implements IVChart { mode: this._option.mode, stage, pluginList, + runtimePluginInstallers, ...restOptions, background: this._getBackground(), onError: this._onError diff --git a/packages/vchart/src/mark/glyph.ts b/packages/vchart/src/mark/glyph.ts index c95a329114..6e33a44368 100644 --- a/packages/vchart/src/mark/glyph.ts +++ b/packages/vchart/src/mark/glyph.ts @@ -145,7 +145,7 @@ export abstract class GlyphMark }; } - protected _setStateOfGraphic = (g: IMarkGraphic) => { + protected _setStateOfGraphic = (g: IMarkGraphic, hasAnimation?: boolean) => { g.clearStates(); if (g.context.diffState === DiffState.enter || g.context.diffState === DiffState.update) { @@ -167,18 +167,20 @@ export abstract class GlyphMark return glyphAttrs; }; - g.useStates(g.context.states); + g.useStates(g.context.states, hasAnimation); } }; protected _createGraphic(attrs: IGlyphGraphicAttribute = {}): IGraphic { const glyph = createGlyph(attrs); glyph.onBeforeAttributeUpdate = this._onGlyphAttributeUpdate(glyph); - glyph.addEventListener('afterAttributeUpdate', (event: any) => { - if (event?.detail?.type === GLYPH_STATE_ATTRIBUTE_UPDATE_TYPE) { + const onAttributeUpdate = glyph.onAttributeUpdate.bind(glyph); + glyph.onAttributeUpdate = (context: any) => { + onAttributeUpdate(context); + if (context?.type === GLYPH_STATE_ATTRIBUTE_UPDATE_TYPE) { this._syncInheritedStyleAttrs(glyph, glyph.attribute); } - }); + }; const subMarks = this._subMarks; if (subMarks) { diff --git a/packages/vchart/src/series/sankey/sankey.ts b/packages/vchart/src/series/sankey/sankey.ts index 135dc837c9..d751e23f05 100644 --- a/packages/vchart/src/series/sankey/sankey.ts +++ b/packages/vchart/src/series/sankey/sankey.ts @@ -3,7 +3,7 @@ import { CartesianSeries } from '../cartesian/cartesian'; import type { SeriesMarkMap } from '../interface'; import { SeriesMarkNameEnum, SeriesTypeEnum } from '../interface/type'; import type { Datum, IRectMarkSpec, ILinkPathMarkSpec, IComposedTextMarkSpec, StringOrNumber } from '../../typings'; -import { animationConfig, userAnimationConfig } from '../../animation/utils'; +import { animationConfig, isAnimationEnabledForSeries, userAnimationConfig } from '../../animation/utils'; import { registerFadeInOutAnimation } from '../../animation/config'; import { registerDataSetInstanceTransform } from '../../data/register'; import type { ISankeyOpt } from '../../data/transforms/sankey'; @@ -71,6 +71,19 @@ export class SankeySeries exten get direction() { return this._spec.direction ?? 'horizontal'; } + + private _hasStateAnimation(mark?: IMark) { + return isAnimationEnabledForSeries(this) && !!(mark as any)?.hasAnimationByState?.('state'); + } + + private _hasLinkStateAnimation() { + return this._hasStateAnimation(this._linkMark); + } + + private _hasNodeStateAnimation() { + return this._hasStateAnimation(this._nodeMark); + } + getCategoryField() { return this._categoryField; } @@ -114,41 +127,42 @@ export class SankeySeries exten viewData.transform({ type: 'sankeyLayout', - options: () => ({ - view: () => { - return { - x0: this._viewBox.x1, - x1: this._viewBox.x2, - y0: this._viewBox.y1, - y1: this._viewBox.y2 - }; - }, - sourceField: this._spec.sourceField, - targetField: this._spec.targetField, - valueField: this._spec.valueField, - direction: this.direction, - crossNodeAlign: this._spec.crossNodeAlign, - nodeAlign: this._spec.nodeAlign ?? 'justify', - nodeGap: this._spec.nodeGap ?? 8, - nodeWidth: this._spec.nodeWidth ?? 10, - linkWidth: this._spec.linkWidth, - minStepWidth: this._spec.minStepWidth, - minNodeHeight: this._spec.minNodeHeight ?? 4, - maxNodeHeight: this._spec.maxNodeHeight, - minLinkHeight: this._spec.minLinkHeight, - maxLinkHeight: this._spec.maxLinkHeight, - iterations: this._spec.iterations, - nodeKey: this._spec.nodeKey, - linkSortBy: this._spec.linkSortBy, - nodeSortBy: this._spec.nodeSortBy, - setNodeLayer: this._spec.setNodeLayer, - dropIsolatedNode: this._spec.dropIsolatedNode, - nodeHeight: this._spec.nodeHeight, - linkHeight: this._spec.linkHeight, - equalNodeHeight: this._spec.equalNodeHeight, - linkOverlap: this._spec.linkOverlap, - inverse: this._spec.inverse - } as ISankeyOpt), + options: () => + ({ + view: () => { + return { + x0: this._viewBox.x1, + x1: this._viewBox.x2, + y0: this._viewBox.y1, + y1: this._viewBox.y2 + }; + }, + sourceField: this._spec.sourceField, + targetField: this._spec.targetField, + valueField: this._spec.valueField, + direction: this.direction, + crossNodeAlign: this._spec.crossNodeAlign, + nodeAlign: this._spec.nodeAlign ?? 'justify', + nodeGap: this._spec.nodeGap ?? 8, + nodeWidth: this._spec.nodeWidth ?? 10, + linkWidth: this._spec.linkWidth, + minStepWidth: this._spec.minStepWidth, + minNodeHeight: this._spec.minNodeHeight ?? 4, + maxNodeHeight: this._spec.maxNodeHeight, + minLinkHeight: this._spec.minLinkHeight, + maxLinkHeight: this._spec.maxLinkHeight, + iterations: this._spec.iterations, + nodeKey: this._spec.nodeKey, + linkSortBy: this._spec.linkSortBy, + nodeSortBy: this._spec.nodeSortBy, + setNodeLayer: this._spec.setNodeLayer, + dropIsolatedNode: this._spec.dropIsolatedNode, + nodeHeight: this._spec.nodeHeight, + linkHeight: this._spec.linkHeight, + equalNodeHeight: this._spec.equalNodeHeight, + linkOverlap: this._spec.linkOverlap, + inverse: this._spec.inverse + } as ISankeyOpt), level: TransformLevel.sankeyLayout }); @@ -551,7 +565,7 @@ export class SankeySeries exten } removeGraphicState(linkEl, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS_REVERSE); - addGraphicState(linkEl, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS, true); // 设置上用户配置选中状态 + addGraphicState(linkEl, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS, true, this._hasLinkStateAnimation()); // 设置上用户配置选中状态 } else if (linkDatum.target === nodeDatum.key) { // 上游link if (!highlightNodes.includes(linkDatum.source)) { @@ -559,10 +573,10 @@ export class SankeySeries exten } removeGraphicState(linkEl, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS_REVERSE); - addGraphicState(linkEl, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS, true); // 设置上用户配置选中状态 + addGraphicState(linkEl, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS, true, this._hasLinkStateAnimation()); // 设置上用户配置选中状态 } else { removeGraphicState(linkEl, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS); - addGraphicState(linkEl, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS_REVERSE, true); + addGraphicState(linkEl, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS_REVERSE, true, this._hasLinkStateAnimation()); } }); } @@ -587,10 +601,16 @@ export class SankeySeries exten if (linkEl === graphic) { removeGraphicState(linkEl, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS_REVERSE); - addRuntimeState(linkEl, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS, { ratio: 1 }); + addRuntimeState( + linkEl, + STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS, + { ratio: 1 }, + true, + this._hasLinkStateAnimation() + ); } else { removeGraphicState(linkEl, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS); - addGraphicState(linkEl, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS_REVERSE, true); + addGraphicState(linkEl, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS_REVERSE, true, this._hasLinkStateAnimation()); } }); } @@ -717,10 +737,15 @@ export class SankeySeries exten if (highlightLinks.includes(linkDatum.key ?? linkDatum.index)) { removeGraphicState(linkEl, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS_REVERSE); - addGraphicState(linkEl, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS, true); + addGraphicState(linkEl, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS, true, this._hasLinkStateAnimation()); } else { removeGraphicState(linkEl, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS); - addGraphicState(linkEl, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS_REVERSE, true); + addGraphicState( + linkEl, + STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS_REVERSE, + true, + this._hasLinkStateAnimation() + ); } }); } @@ -787,7 +812,13 @@ export class SankeySeries exten removeGraphicState(linkEl, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS_REVERSE); - addRuntimeState(linkEl, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS, { ratio }); + addRuntimeState( + linkEl, + STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS, + { ratio }, + true, + this._hasLinkStateAnimation() + ); return; } @@ -804,15 +835,21 @@ export class SankeySeries exten removeGraphicState(linkEl, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS_REVERSE); - addRuntimeState(linkEl, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS, { - ratio: upSelectedLink.value / linkDatum.value - }); // 设置默认的部分高亮 + addRuntimeState( + linkEl, + STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS, + { + ratio: upSelectedLink.value / linkDatum.value + }, + true, + this._hasLinkStateAnimation() + ); // 设置默认的部分高亮 return; } removeGraphicState(linkEl, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS); - addGraphicState(linkEl, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS_REVERSE, true); + addGraphicState(linkEl, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS_REVERSE, true, this._hasLinkStateAnimation()); return; }); @@ -897,7 +934,13 @@ export class SankeySeries exten if (linkDatum.source === curLinkDatum.source && linkDatum.target === curLinkDatum.target) { // 自身 removeGraphicState(linkEl, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS_REVERSE); - addRuntimeState(linkEl, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS, { ratio: 1 }); + addRuntimeState( + linkEl, + STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS, + { ratio: 1 }, + true, + this._hasLinkStateAnimation() + ); return; } @@ -932,7 +975,14 @@ export class SankeySeries exten removeGraphicState(linkEl, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS_REVERSE); - addRuntimeState(linkEl, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS, { ratio }); // 设置默认的部分高亮 + // 设置默认的部分高亮 + addRuntimeState( + linkEl, + STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS, + { ratio }, + true, + this._hasLinkStateAnimation() + ); return; } @@ -951,14 +1001,20 @@ export class SankeySeries exten } removeGraphicState(linkEl, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS_REVERSE); - addRuntimeState(linkEl, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS, { - ratio: upSelectedLink.value / (linkDatum as Datum).value - }); // 设置默认的部分高亮 + addRuntimeState( + linkEl, + STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS, + { + ratio: upSelectedLink.value / (linkDatum as Datum).value + }, + true, + this._hasLinkStateAnimation() + ); // 设置默认的部分高亮 return; } removeGraphicState(linkEl, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS); - addGraphicState(linkEl, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS_REVERSE, true); + addGraphicState(linkEl, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS_REVERSE, true, this._hasLinkStateAnimation()); return; }); @@ -978,9 +1034,9 @@ export class SankeySeries exten removeGraphicState(g, [STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS_REVERSE, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS]); if (highlightNodes.includes((getDatumOfGraphic(g) as Datum).key)) { - addGraphicState(g, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS, true); + addGraphicState(g, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS, true, this._hasNodeStateAnimation()); } else { - addGraphicState(g, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS_REVERSE, true); + addGraphicState(g, STATE_VALUE_ENUM.STATE_SANKEY_EMPHASIS_REVERSE, true, this._hasNodeStateAnimation()); } }); } From 2eb53d19780367684030ef599bf5398b0b4130f3 Mon Sep 17 00:00:00 2001 From: "lixuefei.1313" Date: Tue, 7 Jul 2026 11:15:45 +0800 Subject: [PATCH 6/6] fix: scope poptip plugin dedupe --- packages/vchart/src/compile/compiler.ts | 47 ++++++++++++++----------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/packages/vchart/src/compile/compiler.ts b/packages/vchart/src/compile/compiler.ts index 4562c77c2e..cca524c522 100644 --- a/packages/vchart/src/compile/compiler.ts +++ b/packages/vchart/src/compile/compiler.ts @@ -6,7 +6,7 @@ import { isMobileLikeMode, isTrueBrowser } from '../util/env'; import { isClass, isString } from '../util/type'; import type { IBoundsLike } from '@visactor/vutils'; // eslint-disable-next-line no-duplicate-imports -import { array, isArray, isObject, isValid } from '@visactor/vutils'; +import { isArray, isObject, isValid } from '@visactor/vutils'; import type { EventSourceType } from '../event/interface'; import type { IChart } from '../chart/interface'; import { createGroup, vglobal, waitForAllSubLayers } from '../vrender-bridge'; @@ -30,6 +30,8 @@ type EventListener = { callback: (...args: any[]) => void; }; +const POPTIP_FOR_TEXT_PLUGIN_NAME = 'poptipForText'; + export class Compiler implements ICompiler { private _count: number = 0; /** @@ -111,29 +113,34 @@ export class Compiler implements ICompiler { return this._stage; } - private _dedupeStagePlugins() { - const { pluginList } = this._option; + private _dedupeStagePlugin(pluginName: string) { const pluginService = this._stage?.pluginService; - if (!pluginList?.length || !pluginService?.findPluginsByName) { + if (!pluginService?.findPluginsByName) { return; } - array(pluginList).forEach(pluginName => { - const plugins = pluginService.findPluginsByName(pluginName); - if (plugins.length <= 1) { - return; - } + const plugins = pluginService.findPluginsByName(pluginName); + if (plugins.length <= 1) { + return; + } - const plugin = plugins[0] as IPlugin; - if (pluginService.uninstall) { - pluginService.uninstall(pluginName); - pluginService.register(plugin); - } else { - plugins.slice(1).forEach(duplicatePlugin => { - pluginService.unRegister(duplicatePlugin as IPlugin); - }); - } - }); + const plugin = plugins[0] as IPlugin; + if (pluginService.uninstall) { + pluginService.uninstall(pluginName); + pluginService.register(plugin); + } else { + plugins.slice(1).forEach(duplicatePlugin => { + pluginService.unRegister(duplicatePlugin as IPlugin); + }); + } + } + + private _dedupePoptipPlugin() { + if (!this._option.pluginList?.includes(POPTIP_FOR_TEXT_PLUGIN_NAME)) { + return; + } + + this._dedupeStagePlugin(POPTIP_FOR_TEXT_PLUGIN_NAME); } initView() { @@ -212,7 +219,7 @@ export class Compiler implements ICompiler { } } - this._dedupeStagePlugins(); + this._dedupePoptipPlugin(); this._stage.enableIncrementalAutoRender(); // 之前vgrammar 设置了一些默认配置