Skip to content

docs: update package name and add MessageChannel mock - #524

Merged
afc163 merged 1 commit into
masterfrom
fix/ci-bug
Nov 28, 2025
Merged

docs: update package name and add MessageChannel mock#524
afc163 merged 1 commit into
masterfrom
fix/ci-bug

Conversation

@afc163

@afc163 afc163 commented Nov 28, 2025

Copy link
Copy Markdown
Member

Summary by CodeRabbit

发行说明

  • Chores
    • 项目包名已重新品牌化为 @rc-component/dialog,请更新安装命令和导入语句以引用新包名
    • 测试基础设施已更新以支持新的消息通道功能

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel

vercel Bot commented Nov 28, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
dialog Error Error Nov 28, 2025 3:41am

@coderabbitai

coderabbitai Bot commented Nov 28, 2025

Copy link
Copy Markdown

总体概览

本次变更包括两个主要部分:重新品牌化项目名称(README.md 中将 rc-dialog 更新为 @rc-component/dialog),以及在测试设置中添加 MessageChannel 的全局 polyfill 实现,用于模拟端口之间的消息传递。

变更清单

变更集 / 文件(s) 变更摘要
项目品牌化
README.md
将项目名称从 rc-dialog 重新品牌化为 @rc-component/dialog,更新 npm 包名称、代码示例、徽章元数据及相关链接。
测试基础设施
tests/setup.js
添加全局 MessageChannel 类,实现双向端口通信模拟,支持 postMessage 和 onmessage 回调机制。

代码审查工作量估计

🎯 2 (简单) | ⏱️ ~8 分钟

需要关注的区域:

  • MessageChannel 实现中端口间的消息路由逻辑是否正确处理异步场景
  • 确认 MessageChannel polyfill 与现有测试框架的兼容性

建议审查人员

  • zombieJ
  • thinkasany

庆祝诗

🐰 README 换新装,品牌焕发光芒,
MessageChannel 来助阵,端口通信畅通无阻,
小改变,大能量,测试框架更坚强!✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately describes the two main changes: documentation update for package name rebranding and addition of MessageChannel mock in tests/setup.js.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/ci-bug

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @afc163, 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 primarily focuses on updating the package name in the project's documentation and enhancing the testing environment. The package name has been standardized to "@rc-component/dialog" throughout the README, and a mock for "window.MessageChannel" has been introduced to the test setup to improve test reliability.

Highlights

  • Package Name Update: The package name has been updated from "rc-dialog" to "@rc-component/dialog" across the documentation, including the README title, badges, installation instructions, usage examples, API section, and license declaration.
  • MessageChannel Mock: A mock implementation for "window.MessageChannel" has been added to the test setup file ("tests/setup.js") to ensure consistent testing environments.
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.

@codecov

codecov Bot commented Nov 28, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.46%. Comparing base (61c6be6) to head (b6febbf).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #524   +/-   ##
=======================================
  Coverage   98.46%   98.46%           
=======================================
  Files           8        8           
  Lines         195      195           
  Branches       68       68           
=======================================
  Hits          192      192           
  Misses          3        3           

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

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the package name from rc-dialog to @rc-component/dialog across the documentation and adds a mock for MessageChannel in the test setup. The changes are straightforward and correct. I've added a suggestion to clean up some unused badge definitions in the README.md file to improve its maintainability.

Comment thread README.md
Comment on lines +9 to +18
[travis-image]: https://img.shields.io/travis/react-component/dialog/master?style=flat-square
[travis-url]: https://travis-ci.com/react-component/dialog
[github-actions-image]: https://github.com/react-component/dialog/actions/workflows/ci.yml/badge.svg
[github-actions-url]: https://github.com/react-component/dialog/actions/workflows/ci.yml
[codecov-image]: https://img.shields.io/codecov/c/github/react-component/dialog/master.svg?style=flat-square
[codecov-url]: https://app.codecov.io/gh/react-component/dialog
[download-image]: https://img.shields.io/npm/dm/rc-dialog.svg?style=flat-square
[download-url]: https://npmjs.org/package/rc-dialog
[bundlephobia-url]: https://bundlephobia.com/result?p=rc-dialog
[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/rc-dialog
[david-url]: https://david-dm.org/react-component/dialog
[david-image]: https://david-dm.org/react-component/dialog/status.svg?style=flat-square
[david-dev-url]: https://david-dm.org/react-component/dialog?type=dev
[david-dev-image]: https://david-dm.org/react-component/dialog/dev-status.svg?style=flat-square

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

There are several unused badge definitions here for Travis CI and David DM. To keep the documentation clean and maintainable, it's best to remove definitions that aren't being used in the badge list at the top of the file.

Suggested change
[travis-image]: https://img.shields.io/travis/react-component/dialog/master?style=flat-square
[travis-url]: https://travis-ci.com/react-component/dialog
[github-actions-image]: https://github.com/react-component/dialog/actions/workflows/ci.yml/badge.svg
[github-actions-url]: https://github.com/react-component/dialog/actions/workflows/ci.yml
[codecov-image]: https://img.shields.io/codecov/c/github/react-component/dialog/master.svg?style=flat-square
[codecov-url]: https://app.codecov.io/gh/react-component/dialog
[download-image]: https://img.shields.io/npm/dm/rc-dialog.svg?style=flat-square
[download-url]: https://npmjs.org/package/rc-dialog
[bundlephobia-url]: https://bundlephobia.com/result?p=rc-dialog
[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/rc-dialog
[david-url]: https://david-dm.org/react-component/dialog
[david-image]: https://david-dm.org/react-component/dialog/status.svg?style=flat-square
[david-dev-url]: https://david-dm.org/react-component/dialog?type=dev
[david-dev-image]: https://david-dm.org/react-component/dialog/dev-status.svg?style=flat-square
[github-actions-image]: https://github.com/react-component/dialog/actions/workflows/ci.yml/badge.svg
[github-actions-url]: https://github.com/react-component/dialog/actions/workflows/ci.yml
[codecov-image]: https://img.shields.io/codecov/c/github/react-component/dialog/master.svg?style=flat-square
[codecov-url]: https://app.codecov.io/gh/react-component/dialog

@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: 1

🧹 Nitpick comments (1)
README.md (1)

9-10: 考虑移除未使用的链接引用以消除 markdownlint 告警

travis-image/travis-url 以及一组 david-* 链接定义目前在文档中已经不再使用,但仍然保留在引用区,触发 MD053(Unused link or image reference definition)。可以选择:

  • 要么恢复对应徽章到第 5 行的徽章列表中;
  • 要么直接删除这些未用的引用定义,保持 README 更干净。

Also applies to: 15-18

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f360db8 and b6febbf.

📒 Files selected for processing (2)
  • README.md (4 hunks)
  • tests/setup.js (1 hunks)
🧰 Additional context used
🪛 LanguageTool
README.md

[style] ~5-~5: Using many exclamation marks might seem excessive (in this case: 4 exclamation marks for a text that’s 2878 characters long)
Context: .... [![NPM version][npm-image]][npm-url] [![npm download][download-image]][download-url] [![build status][github-actions-image]][github-actions-url] [![Codecov][codecov-image]][codecov-url] [![bundle size][bundlephobia-image]][bundl...

(EN_EXCESSIVE_EXCLAMATION)

🪛 markdownlint-cli2 (0.18.1)
README.md

9-9: Link and image reference definitions should be needed
Unused link or image reference definition: "travis-image"

(MD053, link-image-reference-definitions)


10-10: Link and image reference definitions should be needed
Unused link or image reference definition: "travis-url"

(MD053, link-image-reference-definitions)


15-15: Link and image reference definitions should be needed
Unused link or image reference definition: "david-url"

(MD053, link-image-reference-definitions)


16-16: Link and image reference definitions should be needed
Unused link or image reference definition: "david-image"

(MD053, link-image-reference-definitions)


17-17: Link and image reference definitions should be needed
Unused link or image reference definition: "david-dev-url"

(MD053, link-image-reference-definitions)


18-18: Link and image reference definitions should be needed
Unused link or image reference definition: "david-dev-image"

(MD053, link-image-reference-definitions)

🔇 Additional comments (1)
README.md (1)

1-5: 项目更名与包名更新整体一致

标题、npm 徽章、下载量、bundlephobia、安装示例、require 用法、API 标题和 License 文案都已经统一成 @rc-component/dialog,没有明显遗漏的 rc-dialog 残留,看起来是一次干净的文档重命名。

Also applies to: 7-8, 19-22, 39-40, 44-45, 57-57, 112-112

Comment thread tests/setup.js
Comment on lines +28 to +54
window.MessageChannel = class {
port1;
port2;
constructor() {
const createPort = () => {
const port = {
onmessage: null,
postMessage: (message) => {
setTimeout(() => {
if (port._target && typeof port._target.onmessage === 'function') {
port._target.onmessage({ data: message });
}
}, 0);
},
_target: null,
};
return port;
};

const port1 = createPort();
const port2 = createPort();
port1._target = port2;
port2._target = port1;
this.port1 = port1;
this.port2 = port2;
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for MessageChannel usage patterns
echo "=== MessageChannel direct usage ==="
rg -n "MessageChannel" -C2

echo -e "\n=== addEventListener with 'message' ==="
rg -n "addEventListener\s*\(\s*['\"]message['\"]" -C2

echo -e "\n=== removeEventListener usage ==="
rg -n "removeEventListener" -C2

echo -e "\n=== port.close usage ==="
rg -n "\.close\s*\(" -C2 | grep -i "port\|channel" -C2

Repository: react-component/dialog

Length of output: 347


🏁 Script executed:

#!/bin/bash
# Check if setup.js is imported/required anywhere
echo "=== setup.js imports/requires ==="
rg -n "setup\.js" -C2

echo -e "\n=== Check for dynamic MessageChannel access ==="
rg -n "\[.*MessageChannel.*\]|MessageChannel\s*\[" -C2

echo -e "\n=== Check for global. or window. patterns that might reference MessageChannel ==="
rg -n "global\.|window\." | head -20

echo -e "\n=== Check if setup.js is in test configuration ==="
find . -name "*.config.*" -o -name "*.conf.*" -o -name "jest.config.*" -o -name "vitest.config.*" 2>/dev/null | head -10
</parameter>

Repository: react-component/dialog

Length of output: 1936


🏁 Script executed:

#!/bin/bash
# Search for Worker usage or web worker patterns
echo "=== Worker usage ==="
rg -n "Worker|worker" -C2 --type=ts --type=tsx --type=js --type=jsx

echo -e "\n=== Check setupFilesAfterEnv to see what else is configured ==="
cat tests/setupFilesAfterEnv.ts 2>/dev/null || echo "File not found or cannot read"

Repository: react-component/dialog

Length of output: 232


Add global.MessageChannel assignment for consistency with other polyfills; skip extending API methods

The mock currently sets MessageChannel only on window, but other polyfills in the same file (requestAnimationFrame, cancelAnimationFrame) are assigned to both global and window. For consistency and to ensure broader compatibility in Node.js/Jest environment, add a global mapping:

 window.MessageChannel = class {
   port1;
   port2;
   constructor() {
@@
     this.port1 = port1;
     this.port2 = port2;
   }
-}
+};
+
+if (typeof global !== 'undefined') {
+  global.MessageChannel = window.MessageChannel;
+}

The codebase does not currently use addEventListener, removeEventListener, or close on MessageChannel instances, so expanding the mock API is unnecessary at this time. The basic postMessage and onmessage implementation is sufficient.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
window.MessageChannel = class {
port1;
port2;
constructor() {
const createPort = () => {
const port = {
onmessage: null,
postMessage: (message) => {
setTimeout(() => {
if (port._target && typeof port._target.onmessage === 'function') {
port._target.onmessage({ data: message });
}
}, 0);
},
_target: null,
};
return port;
};
const port1 = createPort();
const port2 = createPort();
port1._target = port2;
port2._target = port1;
this.port1 = port1;
this.port2 = port2;
}
}
window.MessageChannel = class {
port1;
port2;
constructor() {
const createPort = () => {
const port = {
onmessage: null,
postMessage: (message) => {
setTimeout(() => {
if (port._target && typeof port._target.onmessage === 'function') {
port._target.onmessage({ data: message });
}
}, 0);
},
_target: null,
};
return port;
};
const port1 = createPort();
const port2 = createPort();
port1._target = port2;
port2._target = port1;
this.port1 = port1;
this.port2 = port2;
}
};
if (typeof global !== 'undefined') {
global.MessageChannel = window.MessageChannel;
}
🤖 Prompt for AI Agents
In tests/setup.js around lines 28 to 54, the mock defines window.MessageChannel
but not global.MessageChannel; add an assignment so global.MessageChannel
references the same mock (e.g., global.MessageChannel = window.MessageChannel)
to match how other polyfills are exported, and do not extend the mock with
addEventListener/removeEventListener/close since those APIs are not used—keep
only postMessage and onmessage behavior.

@afc163
afc163 merged commit 7ddf07c into master Nov 28, 2025
11 of 12 checks passed
@afc163
afc163 deleted the fix/ci-bug branch November 28, 2025 03:46
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