From b6febbfd5294cd6b0fb20e11f8bad60660220ddc Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 28 Nov 2025 11:41:26 +0800 Subject: [PATCH] \ndocs: update package name and add MessageChannel mock --- README.md | 41 ++++++++++++++++++++++++----------------- tests/setup.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index e1fb934d..57155033 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,28 @@ -# rc-dialog +# @rc-component/dialog -react dialog component +react dialog component. -[![NPM version][npm-image]][npm-url] [![dumi](https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square)](https://github.com/umijs/dumi) [![build status][github-actions-image]][github-actions-url] [![Test coverage][codecov-image]][codecov-url] [![npm download][download-image]][download-url] [![bundle size][bundlephobia-image]][bundlephobia-url] +[![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]][bundlephobia-url] [![dumi][dumi-image]][dumi-url] -[npm-image]: http://img.shields.io/npm/v/rc-dialog.svg?style=flat-square -[npm-url]: http://npmjs.org/package/rc-dialog -[github-actions-image]: https://github.com/react-component/dialog/workflows/CI/badge.svg -[github-actions-url]: https://github.com/react-component/dialog/actions -[circleci-image]: https://img.shields.io/circleci/react-component/dialog/master?style=flat-square -[circleci-url]: https://circleci.com/gh/react-component/dialog +[npm-image]: https://img.shields.io/npm/v/@rc-component/dialog.svg?style=flat-square +[npm-url]: https://npmjs.org/package/@rc-component/dialog +[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 +[download-image]: https://img.shields.io/npm/dm/@rc-component/dialog.svg?style=flat-square +[download-url]: https://npmjs.org/package/@rc-component/dialog +[bundlephobia-url]: https://bundlephobia.com/package/@rc-component/dialog +[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/@rc-component/dialog +[dumi-url]: https://github.com/umijs/dumi +[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square + ## Screenshot @@ -29,12 +36,12 @@ online example: https://dialog.react-component.vercel.app/ ## Install -[![rc-dialog](https://nodei.co/npm/rc-dialog.png)](https://npmjs.org/package/rc-dialog) +[![@rc-component/dialog](https://nodei.co/npm/@rc-component/dialog.png)](https://npmjs.org/package/@rc-component/dialog) ## Usage ```js -var Dialog = require('rc-dialog'); +var Dialog = require('@rc-component/dialog'); ReactDOM.render( @@ -47,7 +54,7 @@ ReactDOM.render( ## API -### rc-dialog +### @rc-component/dialog | Name | Type | Default | Description | Version | | --- | --- | --- | --- | --- | @@ -102,7 +109,7 @@ open coverage/ dir ## License -rc-dialog is released under the MIT license. +@rc-component/dialog is released under the MIT license. ## 🤝 Contributing diff --git a/tests/setup.js b/tests/setup.js index c0abb843..4f06b392 100644 --- a/tests/setup.js +++ b/tests/setup.js @@ -24,3 +24,31 @@ console.error = (...args) => { originError(...args); }; + +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; + } +}