From 319f7e6a862d1ec943329f8d6bfaaf04f77337ba Mon Sep 17 00:00:00 2001 From: cannorin <13620400+cannorin@users.noreply.github.com> Date: Tue, 14 Jan 2025 21:20:24 +0900 Subject: feat(misskey-js): allow setting binaryType of WebSocket connection (#15190) Co-authored-by: cannorin Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com> --- packages/misskey-js/etc/misskey-js.api.md | 3 +++ packages/misskey-js/src/streaming.ts | 4 ++++ 2 files changed, 7 insertions(+) (limited to 'packages') diff --git a/packages/misskey-js/etc/misskey-js.api.md b/packages/misskey-js/etc/misskey-js.api.md index 3ff8fdc844..211ddb8287 100644 --- a/packages/misskey-js/etc/misskey-js.api.md +++ b/packages/misskey-js/etc/misskey-js.api.md @@ -8,6 +8,7 @@ import type { AuthenticationResponseJSON } from '@simplewebauthn/types'; import { EventEmitter } from 'eventemitter3'; import { Options } from 'reconnecting-websocket'; import type { PublicKeyCredentialRequestOptionsJSON } from '@simplewebauthn/types'; +import _ReconnectingWebSocket from 'reconnecting-websocket'; // Warning: (ae-forgotten-export) The symbol "components" needs to be exported by the entry point index.d.ts // @@ -3159,6 +3160,7 @@ export class Stream extends EventEmitter implements IStream { token: string; } | null, options?: { WebSocket?: Options['WebSocket']; + binaryType?: ReconnectingWebSocket['binaryType']; }); // (undocumented) close(): void; @@ -3421,6 +3423,7 @@ type UsersUpdateMemoRequest = operations['users___update-memo']['requestBody'][' // Warnings were encountered during analysis: // // src/entities.ts:50:2 - (ae-forgotten-export) The symbol "ModerationLogPayloads" needs to be exported by the entry point index.d.ts +// src/streaming.ts:57:3 - (ae-forgotten-export) The symbol "ReconnectingWebSocket" needs to be exported by the entry point index.d.ts // src/streaming.types.ts:220:4 - (ae-forgotten-export) The symbol "ReversiUpdateKey" needs to be exported by the entry point index.d.ts // src/streaming.types.ts:230:4 - (ae-forgotten-export) The symbol "ReversiUpdateSettings" needs to be exported by the entry point index.d.ts diff --git a/packages/misskey-js/src/streaming.ts b/packages/misskey-js/src/streaming.ts index fec6114cca..0ef2d1e7a1 100644 --- a/packages/misskey-js/src/streaming.ts +++ b/packages/misskey-js/src/streaming.ts @@ -54,6 +54,7 @@ export default class Stream extends EventEmitter implements IStrea constructor(origin: string, user: { token: string; } | null, options?: { WebSocket?: Options['WebSocket']; + binaryType?: ReconnectingWebSocket['binaryType']; }) { super(); @@ -86,6 +87,9 @@ export default class Stream extends EventEmitter implements IStrea minReconnectionDelay: 1, // https://github.com/pladaria/reconnecting-websocket/issues/91 WebSocket: options.WebSocket, }); + if (options.binaryType) { + this.stream.binaryType = options.binaryType; + } this.stream.addEventListener('open', this.onOpen); this.stream.addEventListener('close', this.onClose); this.stream.addEventListener('message', this.onMessage); -- cgit v1.2.3-freya