@afterrealism/dendri-client 2.3.7

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Afterrealism
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,141 @@
1
+ # @afterrealism/dendri-client
2
+
3
+ Framework-neutral TypeScript client SDK for Dendri WebRTC signaling.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @afterrealism/dendri-client
9
+ ```
10
+
11
+ ## Connect To Your Server
12
+
13
+ Dendri is self-host-first. You must provide the signaling server that your app should use:
14
+
15
+ ```ts
16
+ import { Dendri } from "@afterrealism/dendri-client";
17
+
18
+ const peer = new Dendri({
19
+ host: "signal.example.com",
20
+ port: 443,
21
+ secure: true,
22
+ path: "/",
23
+ });
24
+ ```
25
+
26
+ Local development usually looks like:
27
+
28
+ ```ts
29
+ const peer = new Dendri({
30
+ host: "localhost",
31
+ port: 9876,
32
+ secure: false,
33
+ path: "/",
34
+ });
35
+ ```
36
+
37
+ ## Room Store
38
+
39
+ Use `createDendriStore()` when integrating with UI frameworks:
40
+
41
+ ```ts
42
+ import { createDendriStore } from "@afterrealism/dendri-client";
43
+
44
+ const store = createDendriStore({
45
+ host: "localhost",
46
+ port: 9876,
47
+ secure: false,
48
+ path: "/",
49
+ });
50
+
51
+ const unsubscribe = store.subscribe(() => {
52
+ console.log(store.connectionState, store.peers);
53
+ });
54
+
55
+ store.join("my-room");
56
+ ```
57
+
58
+ React can wrap `store.subscribe` and `store.getSnapshot()` with `useSyncExternalStore`. Vue can mirror snapshots into `shallowRef`. Svelte can create the store in `onMount` or a `.svelte.ts` factory and call `destroy()` during cleanup.
59
+
60
+ ## SSR
61
+
62
+ Importing the package is safe in SSR code, but creating peers and joining rooms should happen only in browser/client lifecycle code because WebRTC and WebSocket connections are browser/runtime side effects.
63
+
64
+ ## Browser Global Build
65
+
66
+ The package still builds browser global assets in `dist/` for CDN/script-tag workflows:
67
+
68
+ - `dist/dendri.browser.global.js`
69
+ - `dist/dendri.min.global.js`
70
+
71
+ Prefer npm imports for framework apps.
72
+ # @afterrealism/dendri-client
73
+
74
+ WebRTC P2P signaling library for the browser and Node.js.
75
+
76
+ ## Install
77
+
78
+ ```bash
79
+ npm install @afterrealism/dendri-client
80
+ ```
81
+
82
+ ## Quick Start
83
+
84
+ ```typescript
85
+ import Dendri from "@afterrealism/dendri-client";
86
+
87
+ const peer = new Dendri("my-peer-id", {
88
+ host: "signal.example.com",
89
+ secure: true,
90
+ });
91
+
92
+ // Connect to another peer
93
+ const conn = peer.connect("other-peer-id");
94
+
95
+ conn.on("open", () => {
96
+ conn.send("hello");
97
+ });
98
+
99
+ conn.on("data", (data) => {
100
+ console.log("Received:", data);
101
+ });
102
+
103
+ // Receive connections
104
+ peer.on("connection", (conn) => {
105
+ conn.on("data", (data) => {
106
+ console.log("Received:", data);
107
+ });
108
+ });
109
+ ```
110
+
111
+ ## Features
112
+
113
+ - **P2P Data Channels** - Send data directly between browsers
114
+ - **Media Calls** - Video and audio streaming via WebRTC
115
+ - **Rooms** - Group peers into rooms with automatic peer discovery
116
+ - **Presence** - Track online status and custom metadata across peers
117
+ - **Topics** - Pub/sub messaging with named topics
118
+ - **RPC** - Request/response pattern over data channels
119
+ - **Host Migration** - Automatic leader election when the host disconnects
120
+ - **Hybrid Connections** - Seamless fallback between data channel and relay
121
+ - **Relay Encryption** - End-to-end encryption for relayed messages
122
+ - **Store** - Shared synchronized state across peers
123
+ - **Auto Reconnect** - Exponential backoff with jitter
124
+ - **MsgPack Serializer** - Binary serialization for smaller payloads
125
+
126
+ ## MsgPack Serializer
127
+
128
+ For binary serialization instead of JSON:
129
+
130
+ ```typescript
131
+ import { MsgPackDendri } from "@afterrealism/dendri-client";
132
+
133
+ const peer = new MsgPackDendri("my-peer-id", {
134
+ host: "signal.example.com",
135
+ secure: true,
136
+ });
137
+ ```
138
+
139
+ ## License
140
+
141
+ MIT