support safari with a workaround, clean up code a bit

This commit is contained in:
Toshit Chawda 2024-07-12 21:13:11 -07:00
parent e82c0f0d08
commit 63211161f1
No known key found for this signature in database
GPG key ID: 91480ED99E2B3D9D
3 changed files with 29 additions and 11 deletions

View file

@ -1,5 +1,5 @@
import { BareHeaders, BareTransport, maxRedirects } from './baretypes';
import { WorkerConnection, WorkerMessage, WorkerResponse } from './connection';
import { BareHeaders, maxRedirects } from './baretypes';
import { WorkerConnection, WorkerMessage } from './connection';
import { WebSocketFields } from './snapshot';
const validChars =
@ -17,12 +17,6 @@ export function validProtocol(protocol: string): boolean {
return true;
}
// get the unhooked value
const getRealReadyState = Object.getOwnPropertyDescriptor(
WebSocket.prototype,
'readyState'
)!.get!;
const wsProtocols = ['ws:', 'wss:'];
const statusEmpty = [101, 204, 205, 304];
const statusRedirect = [301, 302, 303, 307, 308];
@ -238,7 +232,7 @@ export class BareClient {
}
};
const onclose = (code, reason) => {
const onclose = (code: number, reason: string) => {
fakeReadyState = WebSocketFields.CLOSED;
socket.dispatchEvent(new CloseEvent("close", { code, reason }));
};