durablews 2.0.0-alpha.0 → 2.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +52 -34
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,44 +1,48 @@
1
1
  # DurableWS
2
2
 
3
- > A resilient, modern, zero-dependency WebSocket **client** for TypeScript — built on the standard `WebSocket`, durable by default, and the same in every modern runtime.
4
-
5
- > ⚠️ **v2 is under active development (`2.0.0-alpha`).** The API is changing and several headline features below are still being built. See the [v2 architecture RFC](https://github.com/imnsco/DurableWS/blob/main/rfcs/0001-v2-architecture.md) for the design and live status. The current npm release (`1.x`) predates this redesign.
6
-
7
- DurableWS aims to be "the Hono of WebSockets": tiny, ergonomic, Web-Standards-based, and **durable by default** — automatic reconnection, message queueing, and idle detection out of the box — with a middleware + codec pipeline for extensibility (custom wire formats, auth, a socket.io-compatibility layer, and more).
8
-
9
- ## Status
10
-
11
- DurableWS v2 is being built in the open. To be accurate about what exists today vs. what's planned:
12
-
13
- **Working now**
14
-
15
- - Connect / send / close and incoming-message handling over the standard `WebSocket`
16
- - Event subscriptions (`on` / `off`)
17
- - A middleware pipeline (`use`)
18
- - Built-in JSON-safe message parsing and a ping/pong middleware
19
-
20
- **Planned for v2 (not yet implemented)**
21
-
22
- - Automatic reconnection with exponential backoff
23
- - Message queueing while disconnected, flushed on reconnect
24
- - Idle detection
25
- - A typed connection state machine
26
- - Pluggable codecs (msgpack, socket.io framing, …) and an authentication helper
27
- - Channels / subscriptions
28
-
29
- Until these land, treat the durability features as a roadmap, not a guarantee.
3
+ > The WebSocket client that survives the real world automatic reconnection,
4
+ > bounded queueing, and typed messages. Zero dependencies, every modern
5
+ > runtime, durable by default.
6
+
7
+ > ⚠️ **v2 is in alpha** (`npm install durablews@alpha`). The features below
8
+ > are built and tested (unit, integration, real-browser e2e); the API may
9
+ > still shift before 2.0. The
10
+ > [architecture RFC](https://github.com/imnsco/DurableWS/blob/main/rfcs/0001-v2-architecture.md)
11
+ > tracks design and status. The `1.x` release predates this rewrite don't
12
+ > use it.
13
+
14
+ ## What you get
15
+
16
+ - **Automatic reconnection, on by default** — full-jitter exponential
17
+ backoff, unlimited retries, a `shouldReconnect` veto, and `reconnecting`
18
+ events for your UI.
19
+ - **Message queueing while disconnected, on by default** — bounded,
20
+ drop-oldest, flushed in order on open. Every dropped message fires a `drop`
21
+ event; nothing is silently lost.
22
+ - **Opt-in heartbeat / idle detection** — quietly-dead links are closed (code
23
+ `4408`) and recovered through the normal reconnect machinery.
24
+ - **Typed + validated messages** — pass any
25
+ [Standard Schema](https://standardschema.dev) (zod, valibot, arktype, …)
26
+ and inbound messages are type-inferred *and* runtime-validated.
27
+ - **Middleware, inbound and outbound** — an onion pipeline with async-safe,
28
+ ordered outbound execution (auth/token-refresh ready).
29
+ - **Pluggable codec** JSON by default; swap in msgpack or anything else.
30
+ - **Vue & React bindings in the box** — `durablews/vue` (composable) and
31
+ `durablews/react` (hook); the frameworks are optional peers.
32
+ - **A drop-in `WebSocket` class** — `durablews/compat` for one-line migration
33
+ or `webSocketImpl` injection, with a published known-deviations table.
34
+ - **Zero runtime dependencies**, built on the standard global `WebSocket`.
30
35
 
31
36
  ## Requirements
32
37
 
33
- DurableWS targets the **standard global `WebSocket`** and ships **zero runtime dependencies**. That means:
34
-
35
- - **Node.js 22** the first release where the global `WebSocket` is available unflagged. (There is no `ws` dependency, by design.)
36
- - Any modern runtime with a global `WebSocket`: current browsers, Deno, Bun, and Cloudflare Workers.
38
+ - **Node.js 22** the first release where the global `WebSocket` is
39
+ available unflagged. (There is no `ws` dependency, by design.)
40
+ - Any modern runtime with a global `WebSocket`: current browsers, Deno, Bun,
41
+ and Cloudflare Workers.
37
42
 
38
43
  ## Installation
39
44
 
40
45
  ```bash
41
- # v2 is not yet published; once the alpha ships it will be:
42
46
  npm install durablews@alpha
43
47
  ```
44
48
 
@@ -60,10 +64,24 @@ client.send({ type: "hello", message: "world" });
60
64
  client.close();
61
65
  ```
62
66
 
67
+ Typed and validated, with any Standard Schema:
68
+
69
+ ```ts
70
+ import { z } from "zod";
71
+
72
+ const Message = z.object({ type: z.string(), body: z.string() });
73
+ const client = defineClient({ url, schema: Message });
74
+
75
+ client.on("message", (msg) => {
76
+ // msg: { type: string; body: string } — validated at runtime
77
+ });
78
+ ```
79
+
63
80
  ## Documentation
64
81
 
65
- - [v2 architecture RFC](https://github.com/imnsco/DurableWS/blob/main/rfcs/0001-v2-architecture.md)
66
- - A full documentation site (Astro + Starlight) is coming as part of v2.
82
+ **[durablews.imns.co](https://durablews.imns.co)** — getting started, guides
83
+ (durability tuning, middleware, codecs, drop-in compat), framework pages, the
84
+ API reference, and an honest comparison with the alternatives.
67
85
 
68
86
  ## Contributing
69
87
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "durablews",
3
- "version": "2.0.0-alpha.0",
3
+ "version": "2.0.0-alpha.1",
4
4
  "description": "A resilient, TypeScript-based WebSocket client",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",