peerpigeon 0.1.1 โ 1.0.0
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 +141 -1365
- package/cli.js +1382 -0
- package/dist/peerpigeon-browser.js +12290 -0
- package/dist/peerpigeon-browser.js.map +7 -0
- package/docs/API_DOCUMENTATION.md +1945 -0
- package/docs/BOOTSTRAP_HUBS.md +319 -0
- package/docs/CLI_README.md +371 -0
- package/docs/DOCUMENTATION_REORGANIZATION.md +172 -0
- package/docs/HUB_QUICK_REF.md +107 -0
- package/docs/HUB_SCRIPTS.md +331 -0
- package/docs/HUB_SYSTEM.md +552 -0
- package/docs/MIGRATION_COMPLETE.md +93 -0
- package/docs/NETWORK_NAMESPACES.md +212 -0
- package/docs/README.md +107 -0
- package/docs/SELECTIVE_STREAMING_GUIDE.md +427 -0
- package/docs/TEST_CLEANUP_COMPLETE.md +80 -0
- package/examples/bootstrap-hub-example.js +292 -0
- package/examples/browser/README.md +278 -0
- package/examples/browser/app.js +2426 -49
- package/examples/browser/index.html +481 -630
- package/examples/browser/minimal/README.md +55 -0
- package/examples/browser/minimal/index.html +75 -0
- package/examples/browser/minimal/minimal.js +234 -0
- package/examples/browser/styles.css +687 -1425
- package/examples/browser/test-bundle.html +35 -0
- package/examples/browser-2/index.html +30 -0
- package/examples/browser-2/package.json +21 -0
- package/examples/browser-2/src/App-simple.vue +21 -0
- package/examples/browser-2/src/App.vue +420 -0
- package/examples/browser-2/src/components/CryptoView.vue +1661 -0
- package/examples/browser-2/src/components/DHTView.vue +1281 -0
- package/examples/browser-2/src/components/DebugView.vue +1773 -0
- package/examples/browser-2/src/components/MediaView.vue +1048 -0
- package/examples/browser-2/src/components/MessagingView.vue +775 -0
- package/examples/browser-2/src/components/NetworkView.vue +930 -0
- package/examples/browser-2/src/components/StorageView.vue +1376 -0
- package/examples/browser-2/src/main.js +5 -0
- package/examples/browser-2/src/stores/peerpigeon.js +895 -0
- package/examples/browser-2/vite.config.js +6 -0
- package/examples/hub-example.js +186 -0
- package/examples/multi-hub-test.js +186 -0
- package/examples/node/README.md +2 -2
- package/examples/selective-streaming-demo.html +698 -0
- package/examples/standard-events-demo.js +126 -0
- package/package.json +33 -16
- package/server/index.js +1032 -98
- package/server/start.js +49 -0
- package/src/ConnectionManager.js +239 -225
- package/src/CryptoManager.js +147 -18
- package/src/DebugLogger.js +0 -7
- package/src/DistributedStorageManager.js +224 -205
- package/src/EnvironmentDetector.js +109 -2
- package/src/EventEmitter.js +79 -1
- package/src/EvictionManager.js +10 -9
- package/src/GossipManager.js +163 -11
- package/src/PeerConnection.js +333 -310
- package/src/PeerPigeonMesh.js +577 -135
- package/src/SignalingClient.js +14 -243
- package/src/SignalingHandler.js +31 -10
- package/src/StorageManager.js +0 -39
- package/src/WebDHT-Simple.js +389 -0
- package/src/WebDHT.js +363 -1165
- package/src/browser-entry.js +40 -0
- package/examples/browser/assets/images/favicon.png +0 -0
- package/examples/browser/assets/images/pigeon.png +0 -0
- package/examples/browser/crypto-test.html +0 -427
- package/examples/browser/ui-old.js +0 -1926
- package/examples/browser/ui.js +0 -3391
- package/websocket-server/README.md +0 -247
- package/websocket-server/server.js +0 -391
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Example demonstrating the new standard EventEmitter methods
|
|
5
|
+
* Shows both traditional and Node.js-style event handling
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { PeerPigeonMesh } from '../index.js';
|
|
9
|
+
|
|
10
|
+
console.log('๐ฆ PeerPigeon Standard Event Methods Demo\n');
|
|
11
|
+
|
|
12
|
+
// Create mesh instance
|
|
13
|
+
const mesh = new PeerPigeonMesh({
|
|
14
|
+
peerId: `demo-${Date.now()}`,
|
|
15
|
+
maxPeers: 3,
|
|
16
|
+
enableWebDHT: true,
|
|
17
|
+
enableCrypto: true
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// Traditional style event handling
|
|
21
|
+
console.log('๐ Setting up traditional event listeners...');
|
|
22
|
+
mesh.addEventListener('connected', () => {
|
|
23
|
+
console.log('๐ [Traditional] Connected to signaling server');
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// Standard Node.js style with method chaining
|
|
27
|
+
console.log('โ๏ธ Setting up standard event listeners with chaining...');
|
|
28
|
+
mesh
|
|
29
|
+
.on('statusChanged', (data) => {
|
|
30
|
+
console.log(`๐ [Standard] Status: ${data.type}${data.message ? ' - ' + data.message : ''}`);
|
|
31
|
+
})
|
|
32
|
+
.on('peerConnected', (data) => {
|
|
33
|
+
console.log(`๐ [Standard] Peer connected: ${data.peerId.substring(0, 8)}...`);
|
|
34
|
+
console.log(`๐ Total connected peers: ${mesh.getConnectedPeers().length}`);
|
|
35
|
+
})
|
|
36
|
+
.on('peerDisconnected', (data) => {
|
|
37
|
+
console.log(`๐ [Standard] Peer disconnected: ${data.peerId.substring(0, 8)}... (${data.reason})`);
|
|
38
|
+
})
|
|
39
|
+
.on('messageReceived', (data) => {
|
|
40
|
+
console.log(`๐ฌ [Standard] Message from ${data.from.substring(0, 8)}...: "${data.content}"`);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// One-time listeners
|
|
44
|
+
console.log('๐ฏ Setting up one-time listeners...');
|
|
45
|
+
mesh.once('initialized', () => {
|
|
46
|
+
console.log('๐ [Once] Mesh initialized - this will only be logged once!');
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// Demonstrate listener management
|
|
50
|
+
console.log('๐งฎ Demonstrating listener management...');
|
|
51
|
+
|
|
52
|
+
const temporaryHandler = (data) => {
|
|
53
|
+
console.log(`โฐ [Temporary] Status update: ${data.type}`);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// Add and immediately remove a temporary listener
|
|
57
|
+
mesh.on('statusChanged', temporaryHandler);
|
|
58
|
+
console.log(`๐ Status listeners before removal: ${mesh.listenerCount('statusChanged')}`);
|
|
59
|
+
|
|
60
|
+
mesh.off('statusChanged', temporaryHandler);
|
|
61
|
+
console.log(`๐ Status listeners after removal: ${mesh.listenerCount('statusChanged')}`);
|
|
62
|
+
|
|
63
|
+
// Show all active event names
|
|
64
|
+
console.log(`๐ท๏ธ Active event types: ${mesh.eventNames().join(', ')}\n`);
|
|
65
|
+
|
|
66
|
+
// Initialize mesh
|
|
67
|
+
console.log('๐ Initializing mesh...');
|
|
68
|
+
try {
|
|
69
|
+
await mesh.init();
|
|
70
|
+
console.log('โ
Mesh initialization complete');
|
|
71
|
+
|
|
72
|
+
// Try to connect to a signaling server
|
|
73
|
+
console.log('๐ Attempting to connect to signaling server...');
|
|
74
|
+
try {
|
|
75
|
+
await mesh.connect('ws://localhost:3000');
|
|
76
|
+
console.log('โ
Connected to signaling server');
|
|
77
|
+
|
|
78
|
+
// Send a test message after a short delay
|
|
79
|
+
setTimeout(() => {
|
|
80
|
+
console.log('๐ค Sending test broadcast message...');
|
|
81
|
+
mesh.sendMessage('Hello from the standard events demo!');
|
|
82
|
+
}, 2000);
|
|
83
|
+
|
|
84
|
+
// Demonstrate cleanup after 10 seconds
|
|
85
|
+
setTimeout(() => {
|
|
86
|
+
console.log('\n๐งน Demonstrating cleanup...');
|
|
87
|
+
console.log(`๐ Events with listeners before cleanup: ${mesh.eventNames()}`);
|
|
88
|
+
|
|
89
|
+
// Remove all listeners for messageReceived
|
|
90
|
+
mesh.removeAllListeners('messageReceived');
|
|
91
|
+
console.log('๐๏ธ Removed all messageReceived listeners');
|
|
92
|
+
|
|
93
|
+
console.log(`๐ Events with listeners after cleanup: ${mesh.eventNames()}`);
|
|
94
|
+
console.log('๐ Demo complete - disconnecting...');
|
|
95
|
+
|
|
96
|
+
mesh.disconnect();
|
|
97
|
+
process.exit(0);
|
|
98
|
+
}, 10000);
|
|
99
|
+
|
|
100
|
+
} catch (connectError) {
|
|
101
|
+
console.log('โ ๏ธ Could not connect to signaling server (this is expected if no server is running)');
|
|
102
|
+
console.log('๐ก To test with a real connection, start a server with: node cli.js server');
|
|
103
|
+
|
|
104
|
+
// Still demonstrate the events work
|
|
105
|
+
setTimeout(() => {
|
|
106
|
+
console.log('\n๐งน Demonstrating cleanup without connection...');
|
|
107
|
+
console.log(`๐ Active events: ${mesh.eventNames()}`);
|
|
108
|
+
mesh.removeAllListeners();
|
|
109
|
+
console.log('๐๏ธ Removed all listeners');
|
|
110
|
+
console.log('๐ Demo complete');
|
|
111
|
+
process.exit(0);
|
|
112
|
+
}, 3000);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
} catch (error) {
|
|
116
|
+
console.error('โ Error during mesh initialization:', error.message);
|
|
117
|
+
process.exit(1);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Handle graceful shutdown
|
|
121
|
+
process.on('SIGINT', () => {
|
|
122
|
+
console.log('\n๐ Received interrupt signal, cleaning up...');
|
|
123
|
+
mesh.removeAllListeners();
|
|
124
|
+
mesh.disconnect();
|
|
125
|
+
process.exit(0);
|
|
126
|
+
});
|
package/package.json
CHANGED
|
@@ -1,41 +1,56 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "peerpigeon",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "WebRTC-based peer-to-peer mesh networking library with intelligent routing and signaling server",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"peerpigeon": "./cli.js"
|
|
9
|
+
},
|
|
7
10
|
"exports": {
|
|
8
11
|
".": {
|
|
12
|
+
"browser": "./dist/peerpigeon-browser.js",
|
|
9
13
|
"import": "./index.js"
|
|
10
14
|
}
|
|
11
15
|
},
|
|
12
16
|
"scripts": {
|
|
13
|
-
"
|
|
17
|
+
"build": "node scripts/build-browser.js",
|
|
18
|
+
"prebuild": "mkdir -p dist",
|
|
19
|
+
"cli": "node cli.js",
|
|
20
|
+
"cli:server": "node cli.js server",
|
|
21
|
+
"cli:interactive": "node cli.js interactive",
|
|
22
|
+
"dev": "npm run build && node dev-runner.js",
|
|
14
23
|
"dev:http": "node dev-server.js",
|
|
15
|
-
"start": "node
|
|
16
|
-
"server": "node
|
|
17
|
-
"
|
|
18
|
-
"lint
|
|
19
|
-
"
|
|
24
|
+
"start": "node server/start.js",
|
|
25
|
+
"server": "node server/start.js",
|
|
26
|
+
"hub": "node scripts/start-hub.js",
|
|
27
|
+
"lint": "node -c src/*.js examples/**/*.js server/*.js",
|
|
28
|
+
"lint:fix": "eslint --cache --cache-location .eslintcache src/ examples/ server/ --ext .js --fix",
|
|
29
|
+
"test": "node test/browser-integration-test.js",
|
|
20
30
|
"test:storage": "node examples/node/storage-test.js",
|
|
21
|
-
"test:browser": "node test/browser-integration-test.js",
|
|
22
|
-
"test:
|
|
23
|
-
"test:
|
|
31
|
+
"test:browser:visual": "HEADLESS=false node test/browser-integration-test.js",
|
|
32
|
+
"test:video": "node test/video-streaming-test.js",
|
|
33
|
+
"test:video:visual": "HEADLESS=false node test/video-streaming-test.js",
|
|
34
|
+
"test:video:manual": "node test/manual-video-streaming-test.js",
|
|
35
|
+
"test:video:manual:visual": "HEADLESS=false node test/manual-video-streaming-test.js",
|
|
24
36
|
"ci": "npm run lint && npm run test",
|
|
25
|
-
"prepublishOnly": "npm run ci"
|
|
37
|
+
"prepublishOnly": "npm run build && npm run ci"
|
|
26
38
|
},
|
|
27
39
|
"files": [
|
|
28
40
|
"index.js",
|
|
41
|
+
"cli.js",
|
|
42
|
+
"cli-examples.js",
|
|
29
43
|
"src/",
|
|
30
44
|
"server/",
|
|
31
|
-
"websocket-server/",
|
|
32
45
|
"examples/",
|
|
46
|
+
"dist/",
|
|
47
|
+
"docs/",
|
|
33
48
|
"README.md",
|
|
34
49
|
"LICENSE"
|
|
35
50
|
],
|
|
36
51
|
"repository": {
|
|
37
52
|
"type": "git",
|
|
38
|
-
"url": "git+https://github.com/
|
|
53
|
+
"url": "git+https://github.com/PeerPigeon/PeerPigeon.git"
|
|
39
54
|
},
|
|
40
55
|
"keywords": [
|
|
41
56
|
"webrtc",
|
|
@@ -57,21 +72,23 @@
|
|
|
57
72
|
"author": "Daniel Raeder",
|
|
58
73
|
"license": "MIT",
|
|
59
74
|
"bugs": {
|
|
60
|
-
"url": "https://github.com/
|
|
75
|
+
"url": "https://github.com/PeerPigeon/PeerPigeon/issues"
|
|
61
76
|
},
|
|
62
|
-
"homepage": "https://github.com/
|
|
77
|
+
"homepage": "https://github.com/PeerPigeon/PeerPigeon#readme",
|
|
63
78
|
"dependencies": {
|
|
64
79
|
"@koush/wrtc": "^0.5.3",
|
|
65
|
-
"unsea": "^1.1.
|
|
80
|
+
"unsea": "^1.1.2",
|
|
66
81
|
"ws": "^8.18.0",
|
|
67
82
|
"yamljs": "^0.3.0"
|
|
68
83
|
},
|
|
69
84
|
"devDependencies": {
|
|
70
85
|
"concurrently": "^9.2.0",
|
|
86
|
+
"esbuild": "^0.25.8",
|
|
71
87
|
"eslint": "^8.57.1",
|
|
72
88
|
"eslint-config-standard": "^17.1.0",
|
|
73
89
|
"express": "^4.19.2",
|
|
74
90
|
"jsdoc": "^4.0.4",
|
|
91
|
+
"nodemon": "^3.1.10",
|
|
75
92
|
"puppeteer": "^22.0.0"
|
|
76
93
|
},
|
|
77
94
|
"engines": {
|