Skip to content

Commit

Permalink
chore: enhance readme
Browse files Browse the repository at this point in the history
  • Loading branch information
ulivz committed Nov 16, 2023
1 parent 0a0dbbf commit c0cb75e
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,27 @@

</div>

## 🛰️ Unport
## 🛰️ What's Unport?

Unport is a Universal Port with strict type inference capability for cross-JSContext communication.

Unport is designed to solve the complexity of JSContext environments such as Node.js, Webview, subprocess, Web Worker, worker_threads, WebSocket, iframe, MessageChannel, ServiceWorker, etc. Each JSContext communicates with the outside world in different ways, and the lack of types makes the code for complex cross JSContext communication projects difficult. In complex large projects, it is often difficult to know where the message is going and what fields the recipient needs.
Unport is designed to solve the complexity of JSContext environments such as [Node.js](https://nodejs.org/), [ChildProcess](https://nodejs.org/api/child_process.html), [Webview](https://en.wikipedia.org/wiki/WebView), [Web Worker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers), [worker_threads](https://nodejs.org/api/worker_threads.html), [WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API), [iframe](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe), [MessageChannel](https://developer.mozilla.org/en-US/docs/Web/API/MessageChannel), [ServiceWorker](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API), etc. Each JSContext communicates with the outside world in different ways, and the lack of types makes the code for complex cross JSContext communication projects difficult. In complex large projects, it is often difficult to know where the message is going and what fields the recipient needs.

## 💡 Features

1. Provides a unified Port paradigm. You only need to define the message types that different JSContexts need to pass, and you will have a complete type of unified Port (Unport).
2. 100% type inference. Users only need to maintain the types of communication between JSContexts, and leave the rest to unport.
3. Lightweight and succinct API.

## 🛠️ Install

```bash
npm i unport -S
```

## ⚡️ Quick Start

To implement a process of sending messages after a parent-child process is connected:
Let's take ChildProcess as an example to implement a process of sending messages after a parent-child process is connected:

1. Define Message Definition:

Expand Down Expand Up @@ -119,9 +125,25 @@ childPort.onMessage('syn', () => {
childPort.onMessage('body', payload => {
payload.
});

```

## 🤝 Contributing

Contributions, issues and feature requests are welcome!

Here are some ways you can contribute:

1. 🐛 Submit a [Bug Report](https://github.com/ulivz/unport/issues) if you found something isn't working correctly.
2. 🆕 Suggest a new [Feature Request](https://github.com/ulivz/unport/issues) if you'd like to see new functionality added.
3. 📖 Improve documentation or write tutorials to help other users.
4. 🌐 Translate the documentation to other languages.
5. 💻 Contribute code changes by [Forking the Repository](https://github.com/ulivz/unport/fork), making changes, and submitting a Pull Request.


## LICENSE

MIT License © [ULIVZ](https://github.com/ulivz)

[npm-badge]: https://img.shields.io/npm/v/unport.svg?style=flat
[npm-url]: https://www.npmjs.com/package/unport
[ci-badge]: https://github.com/ulivz/unport/actions/workflows/ci.yml/badge.svg?event=push&branch=main
Expand Down

0 comments on commit c0cb75e

Please sign in to comment.