Skip to content

Commit

Permalink
feat(misskey-js): allow setting binaryType of WebSocket connection
Browse files Browse the repository at this point in the history
  • Loading branch information
cannorin committed Jan 10, 2025
1 parent 13439e0 commit d3f097f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
- Fix: ユーザーのプロフィール画面をアドレス入力などで直接表示した際に概要タブの描画に失敗する問題の修正( #15032 )
- Fix: 起動前の疎通チェックが機能しなくなっていた問題を修正
(Cherry-picked from https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/737)

### Misskey.js
- Feat: allow setting `binaryType` of WebSocket connection
- Fix: ロックダウンされた期間指定のノートがStreaming経由でLTLに出現するのを修正 ( #15200 )
- Fix: disableClustering設定時の初期化ロジックを調整( #15223 )
- Fix: ActivityPubリクエストかどうかの判定が正しくない問題を修正
Expand Down
3 changes: 3 additions & 0 deletions packages/misskey-js/etc/misskey-js.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
//
Expand Down Expand Up @@ -3151,6 +3152,7 @@ export class Stream extends EventEmitter<StreamEvents> implements IStream {
token: string;
} | null, options?: {
WebSocket?: Options['WebSocket'];
binaryType?: ReconnectingWebSocket['binaryType'];
});
// (undocumented)
close(): void;
Expand Down Expand Up @@ -3413,6 +3415,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

Expand Down
4 changes: 4 additions & 0 deletions packages/misskey-js/src/streaming.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export default class Stream extends EventEmitter<StreamEvents> implements IStrea

constructor(origin: string, user: { token: string; } | null, options?: {
WebSocket?: Options['WebSocket'];
binaryType?: ReconnectingWebSocket['binaryType'];
}) {
super();

Expand Down Expand Up @@ -86,6 +87,9 @@ export default class Stream extends EventEmitter<StreamEvents> 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);
Expand Down

0 comments on commit d3f097f

Please sign in to comment.