From c92916b0093adc1f5af538c4632752c897ed1a72 Mon Sep 17 00:00:00 2001 From: 7PH Date: Wed, 24 Apr 2024 01:05:59 +0200 Subject: [PATCH] Export SkyChatClient state event & Publish v1.1.1 --- app/api/SkyChatClient.ts | 37 ++++++++++++++++++++++++++++++++++++- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/app/api/SkyChatClient.ts b/app/api/SkyChatClient.ts index c5341e82..19668c3c 100644 --- a/app/api/SkyChatClient.ts +++ b/app/api/SkyChatClient.ts @@ -34,6 +34,39 @@ const defaultUser: SanitizedUser = { }, }; +export type SkyChatClientState = { + websocketReadyState: number; + user: SanitizedUser; + config: PublicConfig | null; + stickers: Record; + custom: CustomizationElements; + token: AuthToken | null; + connectedList: Array; + messageIdToLastSeenUsers: { [id: number]: Array }; + roomConnectedUsers: { [roomId: number]: Array }; + playerChannelUsers: { [roomId: number]: Array }; + rooms: SanitizedRoom[]; + currentRoomId: number | null; + currentRoom: SanitizedRoom | null; + lastMention: { roomId: number; identifier: string; messageId: number } | null; + typingList: SanitizedUser[]; + polls: { [id: number]: SanitizedPoll }; + cursors: { [identifier: string]: { date: Date; cursor: { x: number; y: number; user: SanitizedUser } } }; + roll: { state: boolean }; + op: boolean; + files: string[]; + file: { filePath: string; content: string } | null; + gallery: FolderContent | null; + videoStreamInfo: VideoStreamInfo | null; + ongoingConverts: OngoingConvert[]; + playerChannels: SanitizedPlayerChannel[]; + currentPlayerChannelId: number | null; + currentPlayerChannel: SanitizedPlayerChannel | null; + playerApiSearchResult: { type: string; items: Array } | null; + player: { current: QueuedVideoInfo | null; queue: QueuedVideoInfo[]; cursor: number }; + playerLastUpdate: Date | null; +}; + export declare interface SkyChatClient { on(event: 'config', listener: (config: PublicConfig) => any): this; on(event: 'sticker-list', listener: (stickers: Record) => any): this; @@ -66,6 +99,8 @@ export declare interface SkyChatClient { on(event: 'player-channel', listener: (channelId: number | null) => any): this; on(event: 'player-search', listener: (data: { type: string; items: Array }) => any): this; on(event: 'player-sync', listener: (data: { current: QueuedVideoInfo | null; queue: QueuedVideoInfo[]; cursor: number }) => any): this; + + on(event: 'update', listener: (state: SkyChatClientState) => any): this; } // eslint-disable-next-line no-redeclare @@ -382,7 +417,7 @@ export class SkyChatClient extends EventEmitter { * Get the client current state. Sums up all that is relevant for the client. * Messages are not accumulated here. It is up to the client to decide what to do with them. */ - get state() { + get state(): SkyChatClientState { return { websocketReadyState: this._websocket ? this._websocket.readyState : WebSocket.CLOSED, user: this._user, diff --git a/package-lock.json b/package-lock.json index 662f667d..645f72e6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "skychat", - "version": "1.1.0", + "version": "1.1.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "skychat", - "version": "1.1.0", + "version": "1.1.1", "license": "ISC", "dependencies": { "events": "^3.3.0", diff --git a/package.json b/package.json index ae96c78e..fc3288eb 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "skychat", "private": false, - "version": "1.1.0", + "version": "1.1.1", "description": "Future-proof virtual cinema platform", "types": "build/api/index.d.ts", "main": "build/api/index.js",