*Update dist

This commit is contained in:
Derrick Hammer 2023-04-08 21:21:14 -04:00
parent 4829b48058
commit f7a5628a91
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 157 additions and 166 deletions

2
dist/index.d.ts vendored
View File

@ -47,6 +47,6 @@ export declare class Socket extends Client {
private ensureEvent; private ensureEvent;
private trackEvent; private trackEvent;
} }
export declare const MODULE = "_AVKgzVYC8Sb_qiTA6kw5BDzQ4Ch-8D4sldQJl8dXF9oTw"; export declare const MODULE = "_AV0jHIhooJYvu8a9_9os4aTHQP-QlDymCtvbFCuPcpetw";
export declare const createClient: (...args: any) => SwarmClient; export declare const createClient: (...args: any) => SwarmClient;
//# sourceMappingURL=index.d.ts.map //# sourceMappingURL=index.d.ts.map

21
dist/index.js vendored
View File

@ -71,12 +71,8 @@ export class SwarmClient extends Client {
} }
async _listen() { async _listen() {
if (!this._connectionListener) { if (!this._connectionListener) {
this._connectionListener = this.connectModule( this._connectionListener = this.connectModule("listenConnections", { swarm: this.swarm }, async (socketId) => {
"listenConnections", const socket = this._sockets.get(socketId) ?? (await createSocket(socketId, this));
{ swarm: this.swarm },
async (socketId) => {
const socket =
this._sockets.get(socketId) ?? (await createSocket(socketId, this));
socket.on("close", () => { socket.on("close", () => {
this._sockets.delete(socketId); this._sockets.delete(socketId);
}); });
@ -84,8 +80,7 @@ export class SwarmClient extends Client {
this._sockets.set(socketId, socket); this._sockets.set(socketId, socket);
} }
this.emit("connection", socket); this.emit("connection", socket);
} });
);
} }
await this._connectionListener[1]; await this._connectionListener[1];
this._connectionListener = undefined; this._connectionListener = undefined;
@ -137,13 +132,9 @@ export class Socket extends Client {
await this.swarm.emitAsync("setup", this); await this.swarm.emitAsync("setup", this);
} }
on(event, listener, options) { on(event, listener, options) {
const [update, promise] = this.connectModule( const [update, promise] = this.connectModule("socketListenEvent", { id: this.id, event: event }, (data) => {
"socketListenEvent",
{ id: this.id, event: event },
(data) => {
this.emit(event, data); this.emit(event, data);
} });
);
this.trackEvent(event, update); this.trackEvent(event, update);
promise.then(() => { promise.then(() => {
this.off(event, listener); this.off(event, listener);
@ -178,7 +169,7 @@ export class Socket extends Client {
this.eventUpdates[event].push(update); this.eventUpdates[event].push(update);
} }
} }
export const MODULE = "_AVbH2uOdd4s4hypKB3QqaP1kxJO_Q5m6y4hsEro6dpVJQ"; export const MODULE = "_AV0jHIhooJYvu8a9_9os4aTHQP-QlDymCtvbFCuPcpetw";
export const createClient = factory(SwarmClient, MODULE); export const createClient = factory(SwarmClient, MODULE);
const socketFactory = factory(Socket, MODULE); const socketFactory = factory(Socket, MODULE);
const createSocket = async (...args) => { const createSocket = async (...args) => {