From 41984ae5882fbfb9e3cd63519e20b9fc3fab63c5 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Fri, 3 Mar 2023 05:22:55 -0500 Subject: [PATCH] *Update dist --- dist/peer.d.ts | 6 +++++- dist/peer.js | 5 ++++- dist/proxy.d.ts | 2 +- dist/proxy.js | 3 ++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/dist/peer.d.ts b/dist/peer.d.ts index 4cf3ae7..57c2627 100644 --- a/dist/peer.d.ts +++ b/dist/peer.d.ts @@ -9,6 +9,7 @@ export type OnData = (peer: Peer, data: any) => void; export type OnReceive = OnData; export type OnClose = OnData; export type OnSend = OnData; +export type OnChannel = (peer: Peer, channel: any) => void; export type OnOpenBound = (socket: Socket, data: any) => { connect: boolean; } | Promise<{ @@ -18,11 +19,13 @@ export type OnDataBound = (data: any) => void; export type OnReceiveBound = OnDataBound; export type OnCloseBound = OnDataBound; export type OnSendBound = OnDataBound; +export type OnChannelBound = (channel: any) => void; export interface DataSocketOptions { onopen?: OnOpen; onreceive?: OnReceive; onsend?: OnSend; onclose?: OnClose; + onchannel?: OnChannel; emulateWebsocket?: boolean; } export interface PeerOptions { @@ -41,8 +44,9 @@ export default class Peer { private _onreceive; private _onsend; private _onclose; + private _onchannel; private _emulateWebsocket; - constructor({ proxy, peer, muxer, onopen, onreceive, onsend, onclose, emulateWebsocket, }: PeerOptionsWithProxy & DataSocketOptions); + constructor({ proxy, peer, muxer, onopen, onreceive, onsend, onclose, onchannel, emulateWebsocket, }: PeerOptionsWithProxy & DataSocketOptions); private _channel?; get channel(): any; init(): Promise; diff --git a/dist/peer.js b/dist/peer.js index 1e4ecf7..a1e9e23 100644 --- a/dist/peer.js +++ b/dist/peer.js @@ -14,8 +14,9 @@ class Peer { _onreceive; _onsend; _onclose; + _onchannel; _emulateWebsocket; - constructor({ proxy, peer, muxer, onopen, onreceive, onsend, onclose, emulateWebsocket = false, }) { + constructor({ proxy, peer, muxer, onopen, onreceive, onsend, onclose, onchannel, emulateWebsocket = false, }) { this._proxy = proxy; this._peer = peer; this._muxer = muxer; @@ -23,6 +24,7 @@ class Peer { this._onreceive = onreceive?.bind(undefined, this); this._onsend = onsend?.bind(undefined, this); this._onclose = onclose?.bind(undefined, this); + this._onchannel = onchannel?.bind(undefined, this); this._emulateWebsocket = emulateWebsocket; } _channel; @@ -74,6 +76,7 @@ class Peer { await self._onreceive?.(m); }, }); + await this._onchannel?.(this._channel); await this._channel.open(); } } diff --git a/dist/proxy.d.ts b/dist/proxy.d.ts index a3f62dc..b5e1b40 100644 --- a/dist/proxy.d.ts +++ b/dist/proxy.d.ts @@ -9,7 +9,7 @@ export default class Proxy { private _listen; private _socketOptions; private _autostart; - constructor({ swarm, protocol, onopen, onreceive, onsend, onclose, listen, autostart, emulateWebsocket, }: ProxyOptions); + constructor({ swarm, protocol, onopen, onreceive, onsend, onclose, onchannel, listen, autostart, emulateWebsocket, }: ProxyOptions); private _swarm; get swarm(): any; private _protocol; diff --git a/dist/proxy.js b/dist/proxy.js index 8be98fa..f21045f 100644 --- a/dist/proxy.js +++ b/dist/proxy.js @@ -9,7 +9,7 @@ class Proxy { _listen; _socketOptions; _autostart; - constructor({ swarm, protocol, onopen, onreceive, onsend, onclose, listen = false, autostart = false, emulateWebsocket = false, }) { + constructor({ swarm, protocol, onopen, onreceive, onsend, onclose, onchannel, listen = false, autostart = false, emulateWebsocket = false, }) { this._swarm = swarm; this._protocol = protocol; this._listen = listen; @@ -19,6 +19,7 @@ class Proxy { onreceive, onsend, onclose, + onchannel, emulateWebsocket, }; this.init();