Skip to content

chore: rm resize-observer-polyfill#218

Merged
zombieJ merged 2 commits into
masterfrom
rm-legacy
Jan 23, 2025
Merged

chore: rm resize-observer-polyfill#218
zombieJ merged 2 commits into
masterfrom
rm-legacy

Conversation

@zombieJ

@zombieJ zombieJ commented Jan 23, 2025

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • 包管理

    • 包名从 rc-resize-observer 更改为 @rc-component/resize-observer
    • 版本重置为 1.0.0-0
    • 更新发布脚本和依赖项
  • 开发工具

    • 更新开发依赖项版本
    • 替换发布工具为 @rc-component/np
  • 测试

    • ResizeObserver 添加模拟实现,以支持单元测试
  • 性能优化

    • 优化 ResizeObserver 的初始化策略,改为延迟加载
  • 配置变更

    • 删除了 now.json 配置文件,影响部署配置和路由逻辑

@vercel

vercel Bot commented Jan 23, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
resize-observer ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 23, 2025 3:43am

@coderabbitai

coderabbitai Bot commented Jan 23, 2025

Copy link
Copy Markdown

概述

演练

此次拉取请求主要涉及 package.jsonsrc/utils/observerUtil.tstests/setup.js 的修改。包名从 rc-resize-observer 更改为 @rc-component/resize-observer,版本重置为 1.0.0-0。在 observerUtil.ts 中引入了 ResizeObserver 的延迟初始化模式,并在 tests/setup.js 中为测试添加了 ResizeObserver 的模拟实现。now.json 配置文件被删除,意味着项目的部署配置不再可用。

变更

文件 变更摘要
package.json - 包名变更为 @rc-component/resize-observer
- 版本更新为 1.0.0-0
- 发布脚本从 np 改为 rc-np
- 移除 @babel/runtimeresize-observer-polyfill 依赖
- 更新 @rc-component/father-plugin 版本为 ^2.0.2
- 将 np 替换为 @rc-component/np
src/utils/observerUtil.ts - 添加 observer 变量
- 引入 ensureResizeObserver() 函数实现延迟初始化
tests/setup.js - 添加 ResizeObserver 全局模拟实现
now.json - 删除该文件,移除部署配置

可能相关的 PR

诗歌

🐰 调整大小的兔子,代码优雅轻盈
延迟初始化,性能如风行
依赖精简,版本重启
测试模拟,兔子欢畅
开源之路,技术飞翔!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1768bc9 and b02aa36.

📒 Files selected for processing (1)
  • now.json (0 hunks)
💤 Files with no reviewable changes (1)
  • now.json

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codecov

codecov Bot commented Jan 23, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.07%. Comparing base (6774b1e) to head (b02aa36).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #218      +/-   ##
==========================================
+ Coverage   93.93%   94.07%   +0.13%     
==========================================
  Files           5        5              
  Lines         132      135       +3     
  Branches       37       38       +1     
==========================================
+ Hits          124      127       +3     
  Misses          7        7              
  Partials        1        1              

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
tests/setup.js (1)

18-28: 需要完善 ResizeObserver 模拟实现

模拟实现缺少了标准 ResizeObserver 接口中的 disconnect() 方法,建议补充以确保完整性。另外,当前实现在 observe 时立即触发回调,这可能与实际行为有所不同。

建议按照以下方式修改实现:

 global.ResizeObserver = class ResizeObserver {
   constructor(callback) {
     this.callback = callback;
+    this.targets = new Set();
   }

   observe(target) {
+    this.targets.add(target);
     this.callback([{ target }]);
   }

-  unobserve() {}
+  unobserve(target) {
+    this.targets.delete(target);
+  }
+
+  disconnect() {
+    this.targets.clear();
+  }
 };
src/utils/observerUtil.ts (1)

31-31: 建议添加错误处理

在调用 ensureResizeObserver() 时,如果浏览器不支持 ResizeObserver,可能会抛出异常。建议添加错误处理。

建议修改如下:

-    ensureResizeObserver().observe(element);
+    try {
+      ensureResizeObserver().observe(element);
+    } catch (e) {
+      console.warn('ResizeObserver not supported');
+    }

Also applies to: 41-41

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6774b1e and 1768bc9.

📒 Files selected for processing (3)
  • package.json (4 hunks)
  • src/utils/observerUtil.ts (3 hunks)
  • tests/setup.js (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Socket Security: Pull Request Alerts
🔇 Additional comments (3)
src/utils/observerUtil.ts (1)

13-21: 延迟初始化 ResizeObserver 的实现很棒!

通过延迟初始化 ResizeObserver 可以很好地解决服务端渲染的问题。实现简洁有效。

package.json (2)

2-3: 重大变更提醒

  1. 包名变更为 @rc-component/resize-observer
  2. 移除了 resize-observer-polyfill 依赖
  3. 版本重置为 1.0.0-0

这些都是破坏性变更,请确保:

  1. 更新 CHANGELOG.md 文档
  2. 在发布说明中明确说明这些变更
  3. 提醒用户可能需要自行处理不支持 ResizeObserver 的浏览器兼容性问题

Also applies to: 45-45


48-48: 开发依赖更新看起来不错

升级到 @rc-component/father-plugin@^2.0.2 和迁移到 @rc-component/np 的变更是好的改进。

Also applies to: 64-64

@socket-security

socket-security Bot commented Jan 23, 2025

Copy link
Copy Markdown

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