peerpigeon 1.0.4 → 1.0.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/README.md +60 -1
- package/dist/peerpigeon-browser.js +800 -36
- package/dist/peerpigeon-browser.js.map +3 -3
- package/docs/BINARY_IMPLEMENTATION_SUMMARY.md +304 -0
- package/docs/BINARY_MESSAGES.md +332 -0
- package/docs/BROADCAST_STREAMING.md +388 -0
- package/docs/PEER_DISCOVERY_FIXES.md +140 -0
- package/docs/STREAMING_API.md +542 -0
- package/docs/STREAMING_IMPLEMENTATION_SUMMARY.md +286 -0
- package/examples/binary-message-demo.html +496 -0
- package/examples/broadcast-stream-demo.html +539 -0
- package/examples/browser-2/EXPRESS_SOLUTION.md +183 -0
- package/examples/browser-2/ICE_DEBUG.md +171 -0
- package/examples/browser-2/IMPLEMENTATION.md +218 -0
- package/examples/browser-2/QUICK_START.md +149 -0
- package/examples/browser-2/README.md +303 -0
- package/examples/browser-2/dist/assets/index-Cck_6WJV.css +1 -0
- package/examples/browser-2/dist/assets/index-D8-cNlWQ.js +57 -0
- package/examples/browser-2/dist/index.html +32 -0
- package/examples/browser-2/dist/peerpigeon-browser.js +12483 -0
- package/examples/browser-2/index.html +2 -1
- package/examples/browser-2/package-lock.json +1276 -0
- package/examples/browser-2/package.json +5 -3
- package/examples/browser-2/public/peerpigeon-browser.js +12483 -0
- package/examples/browser-2/src/App.vue +7 -4
- package/examples/browser-2/src/components/CryptoView.vue +4 -4
- package/examples/browser-2/src/components/TestingView.vue +794 -0
- package/examples/browser-2/src/main.js +7 -1
- package/examples/browser-2/src/router.js +63 -0
- package/examples/browser-2/src/stores/peerpigeon.js +68 -7
- package/examples/browser-2/vite.config.js +15 -1
- package/examples/stream-file-transfer-demo.html +935 -0
- package/package.json +1 -1
- package/server/index.js +175 -38
- package/src/ConnectionManager.js +68 -8
- package/src/GossipManager.js +22 -0
- package/src/PeerConnection.js +421 -11
- package/src/PeerDiscovery.js +33 -18
- package/src/PeerPigeonMesh.js +453 -1
- package/src/SignalingClient.js +12 -5
- package/src/SignalingHandler.js +18 -5
- package/src/browser-entry.js +5 -1
package/README.md
CHANGED
|
@@ -19,7 +19,9 @@ PeerPigeon is a production-ready library for building decentralized applications
|
|
|
19
19
|
- **🌐 Network Namespaces** - Isolated peer networks with automatic global fallback
|
|
20
20
|
- **🗄️ Distributed Storage** - Encrypted, CRDT-enabled storage across the mesh
|
|
21
21
|
- **🎥 Selective Streaming** - Efficient audio/video streaming with bandwidth management
|
|
22
|
-
-
|
|
22
|
+
- **📦 Binary Messages** - Native support for efficient binary data transfer (Uint8Array/ArrayBuffer)
|
|
23
|
+
- **� Stream API** - Transfer large files with ReadableStream/WritableStream (memory-efficient, backpressure handling)
|
|
24
|
+
- **�🏢 Hub System** - Connect multiple signaling servers for global peer discovery
|
|
23
25
|
- **🔐 End-to-End Encryption** - Built-in crypto for secure communication
|
|
24
26
|
- **💰 Cost Optimized** - Smart routing reduces server costs by ~95%
|
|
25
27
|
- **📱 Multi-Platform** - Browser, Node.js, NativeScript support
|
|
@@ -78,6 +80,59 @@ See [docs/LOCAL_TESTING.md](docs/LOCAL_TESTING.md) for full details.
|
|
|
78
80
|
|
|
79
81
|
## 📚 Examples
|
|
80
82
|
|
|
83
|
+
### Streaming File Transfer
|
|
84
|
+
|
|
85
|
+
```javascript
|
|
86
|
+
// Send a file using streams (memory-efficient for large files)
|
|
87
|
+
const file = fileInput.files[0];
|
|
88
|
+
await mesh.sendFile(targetPeerId, file);
|
|
89
|
+
|
|
90
|
+
// Receive files
|
|
91
|
+
mesh.on('streamReceived', async (event) => {
|
|
92
|
+
const { stream, metadata } = event;
|
|
93
|
+
console.log(`Receiving ${metadata.filename} (${metadata.totalSize} bytes)`);
|
|
94
|
+
|
|
95
|
+
// Read stream and create blob
|
|
96
|
+
const chunks = [];
|
|
97
|
+
const reader = stream.getReader();
|
|
98
|
+
while (true) {
|
|
99
|
+
const { done, value } = await reader.read();
|
|
100
|
+
if (done) break;
|
|
101
|
+
chunks.push(value);
|
|
102
|
+
}
|
|
103
|
+
const blob = new Blob(chunks, { type: metadata.mimeType });
|
|
104
|
+
|
|
105
|
+
// Download file
|
|
106
|
+
const url = URL.createObjectURL(blob);
|
|
107
|
+
const a = document.createElement('a');
|
|
108
|
+
a.href = url;
|
|
109
|
+
a.download = metadata.filename;
|
|
110
|
+
a.click();
|
|
111
|
+
});
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Binary Messages
|
|
115
|
+
|
|
116
|
+
```javascript
|
|
117
|
+
// Send binary data to specific peer
|
|
118
|
+
const binaryData = new Uint8Array([1, 2, 3, 4, 5]);
|
|
119
|
+
await mesh.sendBinaryData(targetPeerId, binaryData);
|
|
120
|
+
|
|
121
|
+
// Broadcast binary to all peers
|
|
122
|
+
const count = await mesh.broadcastBinaryData(binaryData);
|
|
123
|
+
|
|
124
|
+
// Receive binary messages
|
|
125
|
+
mesh.on('binaryMessageReceived', ({ from, data, size }) => {
|
|
126
|
+
console.log(`Received ${size} bytes from ${from}`);
|
|
127
|
+
// data is Uint8Array
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// Send files
|
|
131
|
+
const file = fileInput.files[0];
|
|
132
|
+
const buffer = await file.arrayBuffer();
|
|
133
|
+
await mesh.sendBinaryData(peerId, new Uint8Array(buffer));
|
|
134
|
+
```
|
|
135
|
+
|
|
81
136
|
### Distributed Storage
|
|
82
137
|
|
|
83
138
|
```javascript
|
|
@@ -150,6 +205,8 @@ await hub2.start();
|
|
|
150
205
|
### Core Guides
|
|
151
206
|
- **[API Documentation](docs/API_DOCUMENTATION.md)** - Complete API reference
|
|
152
207
|
- **[CLI Guide](docs/CLI_README.md)** - Command-line interface
|
|
208
|
+
- **[Binary Messages](docs/BINARY_MESSAGES.md)** - Efficient binary data transfer
|
|
209
|
+
- **[Streaming API](docs/STREAMING_API.md)** - Large file transfers with ReadableStream/WritableStream
|
|
153
210
|
- **[Network Namespaces](docs/NETWORK_NAMESPACES.md)** - Isolated peer networks
|
|
154
211
|
- **[Selective Streaming](docs/SELECTIVE_STREAMING_GUIDE.md)** - Media streaming optimization
|
|
155
212
|
|
|
@@ -161,6 +218,8 @@ await hub2.start();
|
|
|
161
218
|
|
|
162
219
|
### Examples
|
|
163
220
|
- **[Browser Examples](examples/browser/)** - Web applications
|
|
221
|
+
- **[Binary Message Demo](examples/binary-message-demo.html)** - Interactive binary transfer demo
|
|
222
|
+
- **[Stream File Transfer Demo](examples/stream-file-transfer-demo.html)** - Large file transfer with progress
|
|
164
223
|
- **[Node.js Examples](examples/node/)** - Server-side usage
|
|
165
224
|
- **[NativeScript Examples](examples/nativescript/)** - Mobile apps
|
|
166
225
|
|