From baf0ac31e6962da9a97c8267b9df07bb16e7b8bf Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Thu, 2 Mar 2023 05:37:30 -0500 Subject: [PATCH] *Update dist --- dist/peer.d.ts | 13 +++++++++++-- dist/peer.js | 8 ++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/dist/peer.d.ts b/dist/peer.d.ts index 7ddd7a8..bc516b9 100644 --- a/dist/peer.d.ts +++ b/dist/peer.d.ts @@ -1,14 +1,23 @@ import Proxy from "./proxy.js"; import Socket from "./socket.js"; -export type OnOpen = (socket: Socket, data: any) => { +export type OnOpen = (peer: Peer, socket: Socket, data: any) => { connect: boolean; } | Promise<{ connect: boolean; }> | Promise | void; -export type OnData = (data: any) => void; +export type OnData = (peer: Peer, data: any) => void; export type OnReceive = OnData; export type OnClose = OnData; export type OnSend = OnData; +export type OnOpenBound = (socket: Socket, data: any) => { + connect: boolean; +} | Promise<{ + connect: boolean; +}> | Promise | void; +export type OnDataBound = (data: any) => void; +export type OnReceiveBound = OnDataBound; +export type OnCloseBound = OnDataBound; +export type OnSendBound = OnDataBound; export interface DataSocketOptions { onopen?: OnOpen; onreceive?: OnReceive; diff --git a/dist/peer.js b/dist/peer.js index e79c42e..b46a4ca 100644 --- a/dist/peer.js +++ b/dist/peer.js @@ -20,10 +20,10 @@ class Peer { this._proxy = proxy; this._peer = peer; this._muxer = muxer; - this._onopen = onopen?.bind(this); - this._onreceive = onreceive?.bind(this); - this._onsend = onsend?.bind(this); - this._onclose = onclose?.bind(this); + this._onopen = onopen?.bind(undefined, this); + this._onreceive = onreceive?.bind(undefined, this); + this._onsend = onsend?.bind(undefined, this); + this._onclose = onclose?.bind(undefined, this); this._emulateWebsocket = emulateWebsocket; } async init() {