@peerbit/pubsub 1.1.12 → 2.0.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.
- package/lib/esm/index.d.ts +17 -28
- package/lib/esm/index.js +261 -229
- package/lib/esm/index.js.map +1 -1
- package/package.json +6 -9
- package/src/index.ts +360 -300
package/lib/esm/index.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import type { PeerId as Libp2pPeerId } from "@libp2p/interface/peer-id";
|
|
2
|
-
import { DataMessage } from "@peerbit/stream-interface";
|
|
2
|
+
import { AcknowledgeDelivery, DataMessage, SeekDelivery, SilentDelivery } from "@peerbit/stream-interface";
|
|
3
3
|
import { DirectStream, DirectStreamComponents, DirectStreamOptions, PeerStreams } from "@peerbit/stream";
|
|
4
4
|
import { PubSub, SubscriptionData } from "@peerbit/pubsub-interface";
|
|
5
5
|
import { PublicSignKey } from "@peerbit/crypto";
|
|
6
|
-
import { Connection } from "@libp2p/interface/connection";
|
|
7
6
|
import { PubSubEvents } from "@peerbit/pubsub-interface";
|
|
8
|
-
export declare const logger: import("pino").Logger<
|
|
7
|
+
export declare const logger: import("pino").Logger<never>;
|
|
9
8
|
export interface PeerStreamsInit {
|
|
10
9
|
id: Libp2pPeerId;
|
|
11
10
|
protocol: string;
|
|
@@ -21,25 +20,16 @@ export declare class DirectSub extends DirectStream<PubSubEvents> implements Pub
|
|
|
21
20
|
topicsToPeers: Map<string, Set<string>>;
|
|
22
21
|
subscriptions: Map<string, {
|
|
23
22
|
counter: number;
|
|
24
|
-
data?: Uint8Array;
|
|
25
23
|
}>;
|
|
26
24
|
lastSubscriptionMessages: Map<string, Map<string, DataMessage>>;
|
|
27
25
|
constructor(components: DirectSubComponents, props?: DirectStreamOptions);
|
|
28
26
|
stop(): Promise<void>;
|
|
29
|
-
onPeerReachable(publicKey: PublicSignKey): Promise<void>;
|
|
30
|
-
onPeerDisconnected(peerId: Libp2pPeerId, conn?: Connection): Promise<void>;
|
|
31
27
|
private initializeTopic;
|
|
32
28
|
private initializePeer;
|
|
33
29
|
/**
|
|
34
30
|
* Subscribes to a given topic.
|
|
35
31
|
*/
|
|
36
|
-
|
|
37
|
-
* @param topic,
|
|
38
|
-
* @param data, metadata associated with the subscription, shared with peers
|
|
39
|
-
*/
|
|
40
|
-
subscribe(topic: string | string[], options?: {
|
|
41
|
-
data?: Uint8Array;
|
|
42
|
-
}): Promise<void>;
|
|
32
|
+
subscribe(topic: string): Promise<void>;
|
|
43
33
|
/**
|
|
44
34
|
*
|
|
45
35
|
* @param topic
|
|
@@ -50,26 +40,25 @@ export declare class DirectSub extends DirectStream<PubSubEvents> implements Pub
|
|
|
50
40
|
force: boolean;
|
|
51
41
|
data: Uint8Array;
|
|
52
42
|
}): Promise<boolean>;
|
|
53
|
-
getSubscribers(topic: string):
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
publish(data: Uint8Array, options: {
|
|
61
|
-
topics?: string[];
|
|
62
|
-
to?: (string | PeerId)[];
|
|
63
|
-
strict?: false;
|
|
43
|
+
getSubscribers(topic: string): PublicSignKey[] | undefined;
|
|
44
|
+
private listenForSubscribers;
|
|
45
|
+
requestSubscribers(topic: string | string[], to?: PublicSignKey): Promise<void>;
|
|
46
|
+
getPeersOnTopics(topics: string[]): Set<string>;
|
|
47
|
+
publish(data: Uint8Array | undefined, options?: ({
|
|
48
|
+
topics: string[];
|
|
49
|
+
to?: (string | PublicSignKey | PeerId)[];
|
|
64
50
|
} | {
|
|
65
51
|
topics: string[];
|
|
66
|
-
|
|
67
|
-
|
|
52
|
+
mode?: SilentDelivery | SeekDelivery | AcknowledgeDelivery;
|
|
53
|
+
}) & {
|
|
54
|
+
client?: string;
|
|
68
55
|
}): Promise<Uint8Array>;
|
|
69
56
|
private deletePeerFromTopic;
|
|
70
|
-
|
|
57
|
+
onPeerReachable(publicKey: PublicSignKey): Promise<void>;
|
|
58
|
+
onPeerUnreachable(publicKeyHash: string): void;
|
|
71
59
|
private subscriptionMessageIsLatest;
|
|
72
|
-
|
|
60
|
+
private addPeersOnTopic;
|
|
61
|
+
onDataMessage(from: PublicSignKey, stream: PeerStreams, message: DataMessage, seenBefore: number): Promise<boolean | undefined>;
|
|
73
62
|
}
|
|
74
63
|
export declare const waitForSubscribers: (libp2p: {
|
|
75
64
|
services: {
|