Switch to double quotes and reformat codebase with Biome
This commit is contained in:
@@ -32,7 +32,7 @@ export function createRelayE2eeTransportFactory(args: {
|
||||
export function createEncryptedTransport(
|
||||
base: DaemonTransport,
|
||||
daemonPublicKeyB64: string,
|
||||
logger: TransportLogger
|
||||
logger: TransportLogger,
|
||||
): DaemonTransport {
|
||||
let channel: EncryptedChannel | null = null;
|
||||
let opened = false;
|
||||
@@ -124,9 +124,7 @@ export function createEncryptedTransport(
|
||||
emitClose(event);
|
||||
});
|
||||
base.onError((event) => {
|
||||
relayTransport.onerror?.(
|
||||
event instanceof Error ? event : new Error(String(event))
|
||||
);
|
||||
relayTransport.onerror?.(event instanceof Error ? event : new Error(String(event)));
|
||||
emitError(event);
|
||||
});
|
||||
|
||||
@@ -181,10 +179,7 @@ function emitHandlers<TArgs extends unknown[]>(
|
||||
}
|
||||
}
|
||||
|
||||
function invokeHandler<TArgs extends unknown[]>(
|
||||
handler: (...args: TArgs) => void,
|
||||
...args: TArgs
|
||||
) {
|
||||
function invokeHandler<TArgs extends unknown[]>(handler: (...args: TArgs) => void, ...args: TArgs) {
|
||||
try {
|
||||
handler(...args);
|
||||
} catch {
|
||||
|
||||
@@ -35,10 +35,8 @@ export class TerminalStreamManager {
|
||||
private readonly maxBufferedBytes: number;
|
||||
|
||||
constructor(private readonly config: TerminalStreamManagerConfig) {
|
||||
this.maxBufferedChunks =
|
||||
config.maxBufferedChunks ?? DEFAULT_MAX_BUFFERED_CHUNKS;
|
||||
this.maxBufferedBytes =
|
||||
config.maxBufferedBytes ?? DEFAULT_MAX_BUFFERED_BYTES;
|
||||
this.maxBufferedChunks = config.maxBufferedChunks ?? DEFAULT_MAX_BUFFERED_CHUNKS;
|
||||
this.maxBufferedBytes = config.maxBufferedBytes ?? DEFAULT_MAX_BUFFERED_BYTES;
|
||||
}
|
||||
|
||||
clearAll(): void {
|
||||
@@ -53,10 +51,7 @@ export class TerminalStreamManager {
|
||||
this.ackOffsets.delete(input.streamId);
|
||||
}
|
||||
|
||||
subscribe(input: {
|
||||
streamId: number;
|
||||
handler: TerminalChunkHandler;
|
||||
}): () => void {
|
||||
subscribe(input: { streamId: number; handler: TerminalChunkHandler }): () => void {
|
||||
const { streamId, handler } = input;
|
||||
if (!this.handlers.has(streamId)) {
|
||||
this.handlers.set(streamId, new Set());
|
||||
@@ -111,10 +106,7 @@ export class TerminalStreamManager {
|
||||
}
|
||||
}
|
||||
|
||||
private flushBufferedChunks(input: {
|
||||
streamId: number;
|
||||
handler: TerminalChunkHandler;
|
||||
}): void {
|
||||
private flushBufferedChunks(input: { streamId: number; handler: TerminalChunkHandler }): void {
|
||||
const buffered = this.bufferedChunks.get(input.streamId);
|
||||
if (!buffered || buffered.chunks.length === 0) {
|
||||
return;
|
||||
@@ -143,10 +135,7 @@ export class TerminalStreamManager {
|
||||
queue.chunks.push(input.chunk);
|
||||
queue.bytes += input.chunk.data.byteLength;
|
||||
|
||||
while (
|
||||
queue.chunks.length > this.maxBufferedChunks ||
|
||||
queue.bytes > this.maxBufferedBytes
|
||||
) {
|
||||
while (queue.chunks.length > this.maxBufferedChunks || queue.bytes > this.maxBufferedBytes) {
|
||||
const removed = queue.chunks.shift();
|
||||
if (!removed) {
|
||||
break;
|
||||
|
||||
@@ -14,7 +14,7 @@ export type DaemonTransportFactory = (options: {
|
||||
|
||||
export type WebSocketFactory = (
|
||||
url: string,
|
||||
options?: { headers?: Record<string, string> }
|
||||
options?: { headers?: Record<string, string> },
|
||||
) => WebSocketLike;
|
||||
|
||||
export type WebSocketLike = {
|
||||
|
||||
@@ -6,7 +6,7 @@ export function copyArrayBufferViewToBuffer(data: ArrayBufferView): ArrayBuffer
|
||||
}
|
||||
|
||||
export function normalizeTransportPayload(
|
||||
data: string | Uint8Array | ArrayBuffer
|
||||
data: string | Uint8Array | ArrayBuffer,
|
||||
): string | ArrayBuffer {
|
||||
if (typeof data === "string" || data instanceof ArrayBuffer) {
|
||||
return data;
|
||||
|
||||
@@ -40,7 +40,7 @@ describe("daemon-client transport helpers", () => {
|
||||
onMessage: () => () => {},
|
||||
},
|
||||
"daemon-public-key",
|
||||
{ warn: vi.fn() }
|
||||
{ warn: vi.fn() },
|
||||
);
|
||||
|
||||
expect(openHandler).not.toBeNull();
|
||||
|
||||
@@ -6,7 +6,7 @@ import type {
|
||||
|
||||
export function defaultWebSocketFactory(
|
||||
url: string,
|
||||
_options?: { headers?: Record<string, string> }
|
||||
_options?: { headers?: Record<string, string> },
|
||||
): WebSocketLike {
|
||||
const globalWs = (globalThis as { WebSocket?: any }).WebSocket;
|
||||
if (!globalWs) {
|
||||
@@ -15,9 +15,7 @@ export function defaultWebSocketFactory(
|
||||
return new globalWs(url);
|
||||
}
|
||||
|
||||
export function createWebSocketTransportFactory(
|
||||
factory: WebSocketFactory
|
||||
): DaemonTransportFactory {
|
||||
export function createWebSocketTransportFactory(factory: WebSocketFactory): DaemonTransportFactory {
|
||||
return ({ url, headers }) => {
|
||||
const ws = factory(url, { headers });
|
||||
if ("binaryType" in ws) {
|
||||
@@ -46,7 +44,7 @@ export function createWebSocketTransportFactory(
|
||||
export function bindWsHandler(
|
||||
ws: WebSocketLike,
|
||||
event: "open" | "close" | "error" | "message",
|
||||
handler: (...args: any[]) => void
|
||||
handler: (...args: any[]) => void,
|
||||
): () => void {
|
||||
if (typeof ws.addEventListener === "function") {
|
||||
ws.addEventListener(event, handler);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+1298
-1296
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user