docs: update package name and add MessageChannel mock - #524
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
总体概览本次变更包括两个主要部分:重新品牌化项目名称(README.md 中将 rc-dialog 更新为 变更清单
代码审查工作量估计🎯 2 (简单) | ⏱️ ~8 分钟 需要关注的区域:
建议审查人员
庆祝诗
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
Summary of ChangesHello @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
Using Gemini Code AssistThe 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
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 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
|
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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.
| [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 |
There was a problem hiding this comment.
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.
| [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 |
There was a problem hiding this comment.
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
📒 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
| 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; | ||
| } | ||
| } |
There was a problem hiding this comment.
🧩 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" -C2Repository: 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.
| 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.
Summary by CodeRabbit
发行说明
✏️ Tip: You can customize this high-level summary in your review settings.