*Update dist

This commit is contained in:
Derrick Hammer 2023-02-17 19:36:14 -05:00
parent df63f8be30
commit 8061477c0b
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
3 changed files with 16 additions and 2 deletions

5
dist/index.d.ts vendored
View File

@ -9,6 +9,7 @@ export declare class SwarmClient extends Client {
private _autoReconnect;
private _connectBackoff;
private _ready?;
private _topics;
constructor(useDefaultDht?: boolean, autoReconnect?: boolean);
get swarm(): number | undefined;
connect(pubkey: string | Uint8Array): Promise<Socket>;
@ -20,7 +21,7 @@ export declare class SwarmClient extends Client {
removeRelay(pubkey: string): Promise<void>;
clearRelays(): Promise<void>;
getRelays(): Promise<string[]>;
join(topic: Buffer): Promise<void>;
join(topic: Buffer | Uint8Array): Promise<void>;
}
export declare class Socket extends Client {
private id;
@ -32,7 +33,9 @@ export declare class Socket extends Client {
get rawStream(): Uint8Array;
setup(): Promise<void>;
on<T extends EventEmitter.EventNames<string | symbol>>(event: T, fn: EventEmitter.EventListener<string | symbol, T>, context?: any): this;
onSelf<T extends EventEmitter.EventNames<string | symbol>>(event: T, fn: EventEmitter.EventListener<string | symbol, T>, context?: any): this;
off<T extends EventEmitter.EventNames<string | symbol>>(event: T, fn?: EventEmitter.EventListener<string | symbol, T>, context?: any, once?: boolean): this;
offSelf<T extends EventEmitter.EventNames<string | symbol>>(event: T, fn?: EventEmitter.EventListener<string | symbol, T>, context?: any, once?: boolean): this;
write(message: string | Buffer): void;
end(): void;
private ensureEvent;

2
dist/index.d.ts.map vendored
View File

@ -1 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,MAAM,EAAW,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAU,QAAQ,EAAY,MAAM,gBAAgB,CAAC;AAE5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAKlD,qBAAa,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,EAAE,YAAY,CAAC,aAAa,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC,EACnD,OAAO,CAAC,EAAE,GAAG,EACb,IAAI,CAAC,EAAE,OAAO,GACb,IAAI;IASP,OAAO,CAAC,CAAC,SAAS,YAAY,CAAC,UAAU,CAAC,MAAM,GAAG,MAAM,CAAC,EACxD,KAAK,EAAE,CAAC,EACR,EAAE,CAAC,EAAE,YAAY,CAAC,aAAa,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC,EACnD,OAAO,CAAC,EAAE,GAAG,EACb,IAAI,CAAC,EAAE,OAAO,GACb,IAAI;IAIP,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAIrC,GAAG,IAAI,IAAI;IAUX,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,UAAU;CAInB;AAID,eAAO,MAAM,YAAY,+BAA4C,CAAC"}

11
dist/index.js vendored
View File

@ -8,6 +8,7 @@ export class SwarmClient extends Client {
_autoReconnect;
_connectBackoff;
_ready;
_topics = new Set();
constructor(useDefaultDht = true, autoReconnect = false) {
super();
this.useDefaultSwarm = useDefaultDht;
@ -42,6 +43,9 @@ export class SwarmClient extends Client {
this._ready = this.callModuleReturn("ready", { swarm: this.swarm });
await this._ready;
this._ready = undefined;
for (const topic of this._topics) {
await this.join(topic);
}
}
async start() {
await this._connectBackoff.run(() => this.init());
@ -70,6 +74,7 @@ export class SwarmClient extends Client {
return this.callModuleReturn("getRelays", { swarm: this.swarm });
}
async join(topic) {
this._topics.add(topic);
this.callModule("join", { id: this.id, topic });
}
}
@ -103,6 +108,9 @@ export class Socket extends Client {
});
return super.on(event, fn, context);
}
onSelf(event, fn, context) {
return super.on(event, fn, context);
}
off(event, fn, context, once) {
const updates = [...this.eventUpdates[event]];
this.eventUpdates[event] = [];
@ -111,6 +119,9 @@ export class Socket extends Client {
}
return super.off(event, fn, context, once);
}
offSelf(event, fn, context, once) {
return super.off(event, fn, context, once);
}
write(message) {
this.callModule("socketWrite", { id: this.id, message });
}