Skip to content

Conversation

@Alexzjt
Copy link
Contributor

@Alexzjt Alexzjt commented Jan 23, 2026

👀 PR includes

✨ Feature

  • New feature

🎨 Enhance

  • Code style optimization
  • Refactoring
  • Change the UI
  • Improve the performance
  • Type optimization

🐛 Bugfix

  • Solve the issue and close #0

🔧 Chore

  • Test case
  • Docs / demos update
  • CI / workflow
  • Release version
  • Other ()

📝 Description

🖼️ Screenshot

Before After

🔗 Related issue link

🔍 Self-Check before the merge

  • Add or update relevant docs.
  • Add or update relevant demos.
  • Add or update test case.
  • Add or update relevant TypeScript definitions.

@github-actions
Copy link
Contributor

你好 @Alexzjt,非常感谢你的贡献.
为了让代码更健壮, 请根据 贡献指南 补充相应单元测试 (文档改动或其他特殊场景除外), 如果有 API 改动, 请修改 相应的文档.
同时请检查 linttest 相关 CI 是否通过, 如果失败, 请点击 [Details] 按钮查看, 并根据日志修复.

Hello, @Alexzjt, Thanks for your contribution. In order to make the code more robust, please add the corresponding unit tests, and update the docs if there are API changes.
At the same time, please check whether the CI related to lint and test passes. If the CI fails, please click [Details] button to check and repair according to the log.

@github-actions github-actions bot added pr(refactor) refactor next 2.0-next 版本的问题 labels Jan 23, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Alexzjt, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the media cache used in the BaseRenderer to improve performance and memory management by implementing an LRU cache. This change ensures that the cache evicts the least recently used items when it reaches its maximum size, preventing excessive memory consumption.

Highlights

  • Media Cache Refactor: The media cache in BaseRenderer has been refactored to use an LRU (Least Recently Used) cache implemented by the flru library. This replaces the previous Map implementation.
  • Type Update: The type of mediaCache in BaseRenderer and asyncDrawImage has been updated to flruCache from flru.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

本次 PR 将媒体缓存从 Map 切换到了 LRU 缓存策略,这是一个很好的重构。使用 LRU 缓存可以限制缓存大小,避免了 Map 可能导致的无限增长和潜在的内存泄漏问题。代码改动清晰,符合预期。我有一个关于魔法数字的小建议,以提高代码的可读性和可维护性。


export abstract class BaseRenderer {
static mediaCache = new Map<string, HTMLElement | null>();
static mediaCache: flruCache<HTMLElement | null> = flru(200);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

建议将魔法数字 200 提取为具名常量,以提高代码的可读性和可维护性。例如,可以定义一个私有静态只读属性来存储这个值。

Suggested change
static mediaCache: flruCache<HTMLElement | null> = flru(200);
private static readonly MEDIA_CACHE_MAX_SIZE = 200;
static mediaCache: flruCache<HTMLElement | null> = flru(BaseRenderer.MEDIA_CACHE_MAX_SIZE);

@codecov-commenter
Copy link

codecov-commenter commented Jan 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.86%. Comparing base (ecdc9c8) to head (6271f0d).
⚠️ Report is 771 commits behind head on next.

Additional details and impacted files
@@            Coverage Diff             @@
##             next    #3300      +/-   ##
==========================================
+ Coverage   75.77%   78.86%   +3.09%     
==========================================
  Files         257      223      -34     
  Lines       11994    12271     +277     
  Branches     2464     2760     +296     
==========================================
+ Hits         9088     9678     +590     
+ Misses       1398      928     -470     
- Partials     1508     1665     +157     

☔ 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.

@github-actions
Copy link
Contributor

Size Change: +139 B (+0.02%)

Total Size: 725 kB

Filename Size Change
./packages/s2-core/dist/s2-extends.min.js 207 kB +141 B (+0.07%)
./packages/s2-core/dist/s2.min.css 581 B -2 B (-0.34%)
ℹ️ View Unchanged
Filename Size
./packages/s2-core/dist/s2.min.js 306 kB
./packages/s2-react-components/dist/s2-react-components.min.css 2.55 kB
./packages/s2-react-components/dist/s2-react-components.min.js 123 kB
./packages/s2-react/dist/s2-react.min.css 1.3 kB
./packages/s2-react/dist/s2-react.min.js 38.5 kB
./packages/s2-vue/dist/s2-vue.min.css 2 kB
./packages/s2-vue/dist/s2-vue.min.js 43.6 kB

compressed-size-action

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

Labels

next 2.0-next 版本的问题 pr(refactor) refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants