add nodejs support

This commit is contained in:
ading2210 2025-02-13 16:12:03 -05:00
parent 3a2ab40e75
commit 87b887a4b7
13 changed files with 78 additions and 18 deletions

View file

@ -0,0 +1,10 @@
/* REPLACE
__dirname
*/
globalThis.__dirname
/* DELETE
if ?\(ENVIRONMENT_IS_NODE\) ?{\s*peer\.socket\.on.+?else ?(?={\s*peer\.socket\.onopen)
*/

View file

@ -12,3 +12,8 @@ var parts = addr.split("/");
url = Module.websocket.url;
if (!url.endsWith("/")) url += "/";
url += parts[0] + ":" + port;
/* DELETE
var WebSocketConstructor.+?WebSocketConstructor ?= ?WebSocket;?\s*}
*/

View file

@ -3,10 +3,10 @@ ws ?= ?new WebSocketConstructor\(url, ?opts\)
*/
try {
if (api.transport === "wisp") {
ws = new WispWebSocket(url);
ws = new WispWebSocket(url, WSImpl);
}
else if (api.transport === "wsproxy") {
ws = new WebSocket(url);
ws = new WSImpl(url);
}
else if (typeof api.transport === "string") {
throw new TypeError("invalid transport type");