peerpigeon 0.0.7 → 0.0.8
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 +59 -1
- package/examples/browser/app.js +3 -2
- package/examples/browser/index.html +163 -0
- package/examples/browser/styles.css +279 -47
- package/examples/browser/ui.js +560 -14
- package/examples/node/README.md +110 -0
- package/examples/node/basic-storage-example.js +90 -0
- package/examples/node/package.json +17 -0
- package/examples/node/storage-test.js +520 -0
- package/index.js +10 -9
- package/package.json +4 -2
- package/src/DistributedStorageManager.js +1334 -0
- package/src/PeerPigeonMesh.js +41 -0
package/src/PeerPigeonMesh.js
CHANGED
|
@@ -11,6 +11,7 @@ import { GossipManager } from './GossipManager.js';
|
|
|
11
11
|
import { MediaManager } from './MediaManager.js';
|
|
12
12
|
import { WebDHT } from './WebDHT.js';
|
|
13
13
|
import { CryptoManager } from './CryptoManager.js';
|
|
14
|
+
import { DistributedStorageManager } from './DistributedStorageManager.js';
|
|
14
15
|
import { environmentDetector } from './EnvironmentDetector.js';
|
|
15
16
|
|
|
16
17
|
export class PeerPigeonMesh extends EventEmitter {
|
|
@@ -51,6 +52,7 @@ export class PeerPigeonMesh extends EventEmitter {
|
|
|
51
52
|
this.signalingHandler = new SignalingHandler(this, this.connectionManager);
|
|
52
53
|
this.gossipManager = new GossipManager(this, this.connectionManager);
|
|
53
54
|
this.webDHT = null; // Will be initialized after peerId is set
|
|
55
|
+
this.distributedStorage = null; // Will be initialized after WebDHT is set
|
|
54
56
|
|
|
55
57
|
// Initialize crypto manager if enabled
|
|
56
58
|
this.cryptoManager = null;
|
|
@@ -250,6 +252,13 @@ export class PeerPigeonMesh extends EventEmitter {
|
|
|
250
252
|
|
|
251
253
|
// Setup WebDHT event handlers now that it's initialized
|
|
252
254
|
this.setupWebDHTEventHandlers();
|
|
255
|
+
|
|
256
|
+
// Initialize DistributedStorageManager if WebDHT is enabled
|
|
257
|
+
this.distributedStorage = new DistributedStorageManager(this);
|
|
258
|
+
console.log('DistributedStorageManager initialized');
|
|
259
|
+
|
|
260
|
+
// Setup DistributedStorageManager event handlers
|
|
261
|
+
this.setupDistributedStorageEventHandlers();
|
|
253
262
|
} else {
|
|
254
263
|
console.log('WebDHT disabled by configuration');
|
|
255
264
|
}
|
|
@@ -831,6 +840,38 @@ export class PeerPigeonMesh extends EventEmitter {
|
|
|
831
840
|
}
|
|
832
841
|
}
|
|
833
842
|
|
|
843
|
+
/**
|
|
844
|
+
* Setup event handlers for DistributedStorageManager
|
|
845
|
+
*/
|
|
846
|
+
setupDistributedStorageEventHandlers() {
|
|
847
|
+
// Only set up if distributedStorage exists
|
|
848
|
+
if (this.distributedStorage) {
|
|
849
|
+
this.distributedStorage.addEventListener('dataStored', (data) => {
|
|
850
|
+
this.emit('storageDataStored', data);
|
|
851
|
+
});
|
|
852
|
+
|
|
853
|
+
this.distributedStorage.addEventListener('dataRetrieved', (data) => {
|
|
854
|
+
this.emit('storageDataRetrieved', data);
|
|
855
|
+
});
|
|
856
|
+
|
|
857
|
+
this.distributedStorage.addEventListener('dataUpdated', (data) => {
|
|
858
|
+
this.emit('storageDataUpdated', data);
|
|
859
|
+
});
|
|
860
|
+
|
|
861
|
+
this.distributedStorage.addEventListener('dataDeleted', (data) => {
|
|
862
|
+
this.emit('storageDataDeleted', data);
|
|
863
|
+
});
|
|
864
|
+
|
|
865
|
+
this.distributedStorage.addEventListener('accessGranted', (data) => {
|
|
866
|
+
this.emit('storageAccessGranted', data);
|
|
867
|
+
});
|
|
868
|
+
|
|
869
|
+
this.distributedStorage.addEventListener('accessRevoked', (data) => {
|
|
870
|
+
this.emit('storageAccessRevoked', data);
|
|
871
|
+
});
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
|
|
834
875
|
/**
|
|
835
876
|
* Connect to a specific peer by ID
|
|
836
877
|
*/
|