|
1 | 1 | # Changelog
|
2 | 2 |
|
| 3 | +## v0.3.0 |
| 4 | + |
| 5 | +[compare changes](https://github.com/unjs/crossws/compare/v0.2.4...v0.3.0) |
| 6 | + |
| 7 | +## 🌟 What is new? |
| 8 | + |
| 9 | +### Better stability |
| 10 | + |
| 11 | +Crossws 0.3.x includes an overhaul of refactors, stability improvements, and new features. A new codebase and testing matrix had been implemented ([#55](https://github.com/unjs/crossws/pull/55)) to make sure all supported adapters and runtimes work as expected and are consistent with each other. |
| 12 | + |
| 13 | +### Refined Peer API |
| 14 | + |
| 15 | +The peer object allows easy interaction with connected WebSocket clients from server route hooks ([peer docs](https://crossws.unjs.io/guide/peer)). |
| 16 | + |
| 17 | +To improve Web standards compatibility, accessing upgrade URL and headers is now possible with `peer.request.url` and `peer.request.headers` (**breaking change**), and `peer.addr` is also renamed to `peer.remoteAddress` to improve readability (**breaking change**) and support is increased across providers. You can also use new lazy-generated and secure `peer.id` (UUID v4) for various purposes including temporary sessions or persistent state. |
| 18 | + |
| 19 | +Two new methods are now supported to close connected peers using `peer.close(code, reason)` and `peer.terminate()`. With this new version, you can access a standard [`WebSocket`](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) interface using `peer.websocket`. |
| 20 | + |
| 21 | +> [!NOTE] |
| 22 | +> Today many of the server runtimes don't provide a spec-compliant `WebSocket` API. Crossws uses an internal proxy to polyfill consistent access to `extensions`, `protocol`, and `readyState`. See [compatibility table](https://crossws.unjs.io/guide/peer#compatibility) for more details. |
| 23 | +
|
| 24 | +### Refined Message API |
| 25 | + |
| 26 | +On `message` [hook](https://crossws.unjs.io/guide/hooks), you receive a message object containing data from the client ([message docs](https://crossws.unjs.io/guide/message)). |
| 27 | + |
| 28 | +Parsing incoming messages can be tricky across runtimes. Message object now has stable methods `.text()`, `.json()`, `.uint8Array()`, `.arrayBuffer()`, `.blob()` to safely read message as desired format. If you need, you can also access `.rawData`, `.peer`, `.event` (if available), and lazy generated secure UUID v4 `.id` |
| 29 | + |
| 30 | +### Authentication via `upgrade` hook |
| 31 | + |
| 32 | +When you need to authenticate and validate WebSocket clients before they can upgrade, you can now easily use the `upgrade` hook to check incoming URLs and headers/cookies and return a Web Standard [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) in case you need to abort the upgrade. |
| 33 | + |
| 34 | +### Pubsub with Deno and Cloudflare Durable Objects |
| 35 | + |
| 36 | +One of the common use cases of WebSockets is pubsub. This release adds pub-sub support to [Deno provider](https://crossws.unjs.io/adapters/deno) and also you can globally broadcast messages using `ws.publish` for advanced use cases. |
| 37 | + |
| 38 | +Normally with cloudflare workers, it is not possible to connect multiple peers with each other. Cloudflare [Durable Objects](https://developers.cloudflare.com/durable-objects/) (available on paid plans) allows building collaborative editing tools, interactive chat, multiplayer games, and applications that need coordination among multiple clients. |
| 39 | + |
| 40 | +Crossws provides a new composable method to easily integrate WebSocket handlers with Durable Objects. Hibernation is supported out of the box to reduce billing costs when connected clients are inactive. ([durable object peer docs](https://crossws.unjs.io/adapters/cloudflare#durable-objects)) |
| 41 | + |
| 42 | +## Changelog |
| 43 | + |
| 44 | +### 🚀 Enhancements |
| 45 | + |
| 46 | +- ⚠️ Overhaul internal implementation ([#55](https://github.com/unjs/crossws/pull/55)) |
| 47 | +- ⚠️ Overhaul peer and message interface ([#70](https://github.com/unjs/crossws/pull/70)) |
| 48 | +- **node, uws:** Automatically detect binary message type ([#53](https://github.com/unjs/crossws/pull/53)) |
| 49 | +- **peer:** Add `peer.close()` and `peer.terminate()` support ([#36](https://github.com/unjs/crossws/pull/36)) |
| 50 | +- Cloudflare durable objects support ([#54](https://github.com/unjs/crossws/pull/54)) ([docs](https://crossws.unjs.io/adapters/cloudflare#durable-objects)) |
| 51 | +- **deno:** Support pub/sub ([#58](https://github.com/unjs/crossws/pull/58)) |
| 52 | +- Universal access to all peers ([#60](https://github.com/unjs/crossws/pull/60)) |
| 53 | +- Global publish using `ws.publish` ([#61](https://github.com/unjs/crossws/pull/61)) |
| 54 | +- Experimental SSE-based adapter to support websocket in limited runtimes ([#62](https://github.com/unjs/crossws/pull/62), [#66](https://github.com/unjs/crossws/pull/66), [#68](https://github.com/unjs/crossws/pull/68)) ([docs](https://crossws.unjs.io/adapters/sse) |
| 55 | +- **peer:** Use secure lazy random UUID v4 ([#64](https://github.com/unjs/crossws/pull/64)) |
| 56 | + |
| 57 | +### 🩹 Fixes |
| 58 | + |
| 59 | +- Should not serailize binary messages ([#39](https://github.com/unjs/crossws/pull/39)) |
| 60 | +- **cloudflare-durable:** Restore peer url and id after hibernation ([#71](https://github.com/unjs/crossws/pull/71)) |
| 61 | + |
| 62 | +### 💅 Refactors |
| 63 | + |
| 64 | +- ⚠️ Move `peer.ctx` to `peer._internal` ([#59](https://github.com/unjs/crossws/pull/59)) |
| 65 | +- ⚠️ Remove adapter hooks ([#72](https://github.com/unjs/crossws/pull/72)) |
| 66 | +- Rename internal crossws to hooks ([bb4c917](https://github.com/unjs/crossws/commit/bb4c917)) |
| 67 | +- Better internal organization ([2744f21](https://github.com/unjs/crossws/commit/2744f21)) |
| 68 | + |
| 69 | +### 📖 Documentation |
| 70 | + |
| 71 | +[#22](https://github.com/unjs/crossws/pull/22), [76fc105](https://github.com/unjs/crossws/commit/76fc105), [7dacb00](https://github.com/unjs/crossws/commit/7dacb00), [#46](https://github.com/unjs/crossws/pull/46), [#45](https://github.com/unjs/crossws/pull/45), [#44](https://github.com/unjs/crossws/pull/44), [a96dca3](https://github.com/unjs/crossws/commit/a96dca3), [898ab49](https://github.com/unjs/crossws/commit/898ab49), [2e49cc3](https://github.com/unjs/crossws/commit/2e49cc3) |
| 72 | + |
| 73 | +### 📦 Build |
| 74 | + |
| 75 | +- Remove optional `uWebSockets.js` dependency ([#52](https://github.com/unjs/crossws/pull/52), [b23b76d](https://github.com/unjs/crossws/commit/b23b76d)) |
| 76 | +- ⚠️ Esm-only build ([#63](https://github.com/unjs/crossws/pull/63)) |
| 77 | + |
| 78 | +### ✅ Tests |
| 79 | + |
| 80 | +- Add adapter tests ([#56](https://github.com/unjs/crossws/pull/56)) |
| 81 | +- **cloudflare:** Use random port for wrangler inspector ([a46265c](https://github.com/unjs/crossws/commit/a46265c)) |
| 82 | +- Run tests with web standard `WebSocket` and `EventSource` ([#67](https://github.com/unjs/crossws/pull/67)) |
| 83 | + |
| 84 | +### ❤️ Contributors |
| 85 | + |
| 86 | +- Pooya Parsa ([@pi0](http://github.com/pi0)) |
| 87 | +- Eduardo San Martin Morote ([@posva](http://github.com/posva)) |
| 88 | +- Alex ([@alexzhang1030](http://github.com/alexzhang1030)) |
| 89 | +- 39sho ([@39sho](http://github.com/39sho)) |
| 90 | +- @beer ([@iiio2](http://github.com/iiio2)) |
| 91 | +- Sébastien Chopin ([@atinux](http://github.com/atinux)) |
| 92 | +- Pierre Golfier <[email protected]> |
3 | 93 |
|
4 | 94 | ## v0.2.4
|
5 | 95 |
|
|
81 | 171 |
|
82 | 172 | ### 💅 Refactors
|
83 | 173 |
|
84 |
| -- ⚠️ Improve types and api ([2ebacd3](https://github.com/unjs/crossws/commit/2ebacd3)) |
| 174 | +- ⚠️ Improve types and api ([2ebacd3](https://github.com/unjs/crossws/commit/2ebacd3)) |
85 | 175 |
|
86 | 176 | ### 🏡 Chore
|
87 | 177 |
|
|
90 | 180 |
|
91 | 181 | #### ⚠️ Breaking Changes
|
92 | 182 |
|
93 |
| -- ⚠️ Improve types and api ([2ebacd3](https://github.com/unjs/crossws/commit/2ebacd3)) |
| 183 | +- ⚠️ Improve types and api ([2ebacd3](https://github.com/unjs/crossws/commit/2ebacd3)) |
94 | 184 |
|
95 | 185 | ### ❤️ Contributors
|
96 | 186 |
|
|
169 | 259 |
|
170 | 260 | ## v0.0.1
|
171 | 261 |
|
172 |
| - |
173 | 262 | ### 🏡 Chore
|
174 | 263 |
|
175 | 264 | - Update readme ([af705a6](https://github.com/unjs/crossws/commit/af705a6))
|
|
178 | 267 | ### ❤️ Contributors
|
179 | 268 |
|
180 | 269 | - Pooya Parsa ([@pi0](http://github.com/pi0))
|
181 |
| - |
|
0 commit comments