From ec4358d1e8c9a59a0702d19182c37d91510b3736 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=8B=E3=81=A3=E3=81=93=E3=81=8B=E3=82=8A?= <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Mon, 28 Oct 2024 11:43:05 +0900 Subject: [PATCH] =?UTF-8?q?fix(misskey-js):=20WebSocket=E3=81=AE=E5=9E=8B?= =?UTF-8?q?=E5=AE=9A=E7=BE=A9=E3=82=92ReconnectingWebsocket=E3=81=AB?= =?UTF-8?q?=E4=BE=9D=E5=AD=98=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=20(#14850)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(misskey-js): WebSocketの型定義をReconnectingWebsocketに依存するように * Update Changelog * run api extractor * fix * fix --- CHANGELOG.md | 3 +++ packages/backend/test-federation/test/utils.ts | 2 -- packages/misskey-js/etc/misskey-js.api.md | 3 ++- packages/misskey-js/src/streaming.ts | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 40ad0b639b..90ad015dab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,9 @@ - Fix: 招待コードの発行可能な残り数算出に使用すべきロールポリシーの値が違う問題を修正 (Cherry-picked from https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/706) +### Misskey.js +- Fix: Stream初期化時、別途WebSocketを指定する場合の型定義を修正 + ## 2024.10.1 ### Note diff --git a/packages/backend/test-federation/test/utils.ts b/packages/backend/test-federation/test/utils.ts index 483bf4b254..093277cdb4 100644 --- a/packages/backend/test-federation/test/utils.ts +++ b/packages/backend/test-federation/test/utils.ts @@ -232,7 +232,6 @@ export async function isFired { return new Promise(async (resolve, reject) => { - // @ts-expect-error TODO: why? const stream = new Misskey.Stream(`wss://${host}`, { token: user.i }, { WebSocket }); const connection = stream.useChannel(channel, params); connection.on(type as any, ((msg: any) => { @@ -266,7 +265,6 @@ export async function isNoteUpdatedEventFired( cond: (msg: Parameters[0]) => boolean, ): Promise { return new Promise(async (resolve, reject) => { - // @ts-expect-error TODO: why? const stream = new Misskey.Stream(`wss://${host}`, { token: user.i }, { WebSocket }); stream.send('s', { id: noteId }); stream.on('noteUpdated', msg => { diff --git a/packages/misskey-js/etc/misskey-js.api.md b/packages/misskey-js/etc/misskey-js.api.md index 72c236373d..61de8b8c7e 100644 --- a/packages/misskey-js/etc/misskey-js.api.md +++ b/packages/misskey-js/etc/misskey-js.api.md @@ -7,6 +7,7 @@ import type { AuthenticationResponseJSON } from '@simplewebauthn/types'; import { EventEmitter } from 'eventemitter3'; 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 // @@ -3137,7 +3138,7 @@ export class Stream extends EventEmitter implements IStream { constructor(origin: string, user: { token: string; } | null, options?: { - WebSocket?: WebSocket; + WebSocket?: _ReconnectingWebsocket.Options['WebSocket']; }); // (undocumented) close(): void; diff --git a/packages/misskey-js/src/streaming.ts b/packages/misskey-js/src/streaming.ts index ffb46c77f6..6e34ec1508 100644 --- a/packages/misskey-js/src/streaming.ts +++ b/packages/misskey-js/src/streaming.ts @@ -51,7 +51,7 @@ export default class Stream extends EventEmitter implements IStrea private idCounter = 0; constructor(origin: string, user: { token: string; } | null, options?: { - WebSocket?: WebSocket; + WebSocket?: _ReconnectingWebsocket.Options['WebSocket']; }) { super();