Skip to content

refactor: decompose useEcharts into internal hooks#345

Merged
chensid merged 1 commit intomainfrom
develop
Apr 12, 2026
Merged

refactor: decompose useEcharts into internal hooks#345
chensid merged 1 commit intomainfrom
develop

Conversation

@chensid
Copy link
Copy Markdown
Owner

@chensid chensid commented Apr 12, 2026

Summary

  • Split monolithic useEcharts hook (404 → 148 LOC) into orchestrator + 6 focused internal hooks under src/hooks/internal/
  • Add shallowEqual utility for option update deduplication, preventing unnecessary setOption calls
  • Extract syncGroupConnectivity in connect.ts to eliminate duplicated connect/disconnect logic
  • Fix clearInstanceCache to properly dispose all tracked instances before clearing
  • Make EChart component responsive with height: 100% + minHeight: 400px (was fixed 400px)
  • Add circular reference protection for theme objects in JSON.stringify
  • Fix RAF ID not cleared after execution in resize observer

Test plan

  • All 137 tests pass (vp test run)
  • Zero lint/type errors (vp check)
  • Build succeeds with correct outputs (vp pack)
  • dist/index.d.ts does not expose any internal hooks
  • Coverage: all internal hooks, utils, themes at 100%

🤖 Generated with Claude Code

… issues

- Split monolithic useEcharts (404 LOC) into orchestrator + 6 internal hooks:
  useInstanceLifecycle, useOptionSync, useLoading, useEvents, useGroup, useResizeObserver
- Add shallowEqual utility for option update deduplication
- Extract syncGroupConnectivity in connect.ts to eliminate duplicated logic
- Fix clearInstanceCache to dispose tracked instances before clearing
- Make EChart component responsive with height:100% + minHeight:400px
- Add circular reference protection for theme objects in JSON.stringify
- Fix RAF ID not cleared after execution in resize observer

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@chensid chensid merged commit 23113cc into main Apr 12, 2026
1 check passed
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 12, 2026

Codecov Report

❌ Patch coverage is 97.19101% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.87%. Comparing base (d2dc5ef) to head (468fa6d).
⚠️ Report is 14 commits behind head on main.

Files with missing lines Patch % Lines
src/hooks/use-echarts.ts 72.22% 5 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##              main     #345      +/-   ##
===========================================
- Coverage   100.00%   98.87%   -1.13%     
===========================================
  Files           10       18       +8     
  Lines          399      443      +44     
  Branches        92      104      +12     
===========================================
+ Hits           399      438      +39     
- Misses           0        5       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant