diff --git a/src/BareClient.ts b/src/BareClient.ts index b8eb277..b32def5 100644 --- a/src/BareClient.ts +++ b/src/BareClient.ts @@ -211,37 +211,6 @@ export class BareClient { }, ) - // const socket = this.client.connect( - // remote, - // protocols, - // async () => { - // const resolvedHeaders = - // typeof options.headers === 'function' - // ? await options.headers() - // : options.headers || {}; - // - // const requestHeaders: BareHeaders = - // resolvedHeaders instanceof Headers - // ? Object.fromEntries(resolvedHeaders) - // : resolvedHeaders; - // - // // user is expected to specify user-agent and origin - // // both are in spec - // - // - // return requestHeaders; - // }, - // (meta) => { - // fakeProtocol = meta.protocol; - // if (options.setCookiesCallback) - // options.setCookiesCallback(meta.setCookies); - // }, - // (readyState) => { - // fakeReadyState = readyState; - // }, - // options.webSocketImpl || WebSocket - // ); - // protocol is always an empty before connecting // updated when we receive the metadata // this value doesn't change when it's CLOSING or CLOSED etc diff --git a/src/RemoteClient.ts b/src/RemoteClient.ts index 64d03d8..745d2c0 100644 --- a/src/RemoteClient.ts +++ b/src/RemoteClient.ts @@ -91,93 +91,4 @@ export default class RemoteTransport implements BareTransport { ): (data: Blob | ArrayBuffer | string) => void { throw "why are you calling connect from remoteclient" } -} -// -// declare const self: ServiceWorkerGlobalScope; -// export default class RemoteClient extends Client { -// static singleton: RemoteClient; -// private callbacks: Record) => void> = {}; -// -// private uid = uuid(); -// constructor() { -// if (RemoteClient.singleton) return RemoteClient.singleton; -// super(); -// // this should be fine -// // if (!("ServiceWorkerGlobalScope" in self)) { -// // throw new TypeError("Attempt to construct RemoteClient from outside a service worker") -// // } -// -// addEventListener("message", (event) => { -// if (event.data.__remote_target === this.uid) { -// const callback = this.callbacks[event.data.__remote_id]; -// callback(event.data.__remote_value); -// } -// }); -// -// RemoteClient.singleton = this; -// } -// -// async send(message: Record, id?: string) { -// const clients = await self.clients.matchAll(); -// if (clients.length < 1) -// throw new Error("no available clients"); -// -// for (const client of clients) { -// client.postMessage({ -// __remote_target: this.uid, -// __remote_id: id, -// __remote_value: message -// }) -// } -// -// } -// -// async sendWithResponse(message: Record): Promise { -// const id = uuid(); -// return new Promise((resolve) => { -// this.callbacks[id] = resolve; -// this.send(message, id); -// }); -// } -// -// connect( -// ...args: any -// ) { -// throw "why are you calling connect from remoteclient" -// } -// async request( -// method: BareMethod, -// requestHeaders: BareHeaders, -// body: BodyInit | null, -// remote: URL, -// cache: BareCache | undefined, -// duplex: string | undefined, -// signal: AbortSignal | undefined -// ): Promise { -// -// const response = await this.sendWithResponse({ -// type: "request", -// options: { -// method, -// requestHeaders, -// body, -// remote: remote.toString(), -// }, -// }); -// // const readResponse = await this.readBareResponse(response); -// -// const result: Response & Partial = new Response( -// statusEmpty.includes(response.status!) ? undefined : response.body, -// { -// status: response.status, -// statusText: response.statusText ?? undefined, -// headers: new Headers(response.headers as HeadersInit), -// } -// ); -// -// result.rawHeaders = response.rawHeaders; -// result.rawResponse = response; -// -// return result as BareResponse; -// } -// } +} \ No newline at end of file