From 2c70093d77fd74ae9540e70162514db85110b289 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Sat, 17 Jul 2021 14:08:25 +0200 Subject: [PATCH] use typescript optional properties. --- src/component/internal/messages.ts | 4 +-- src/component/internal/webrtc.ts | 2 +- src/component/types/messages.ts | 46 +++++++++++++++--------------- src/component/types/state.ts | 2 +- src/component/utils/reconnecter.ts | 4 +-- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/component/internal/messages.ts b/src/component/internal/messages.ts index 4f98e05a..48c59c2c 100644 --- a/src/component/internal/messages.ts +++ b/src/component/internal/messages.ts @@ -34,10 +34,10 @@ export interface NekoEvents { ['session.updated']: (id: string) => void // room events - ['room.control.host']: (hasHost: boolean, hostID: string | undefined) => void + ['room.control.host']: (hasHost: boolean, hostID?: string) => void ['room.screen.updated']: (width: number, height: number, rate: number) => void ['room.clipboard.updated']: (text: string) => void - ['room.broadcast.status']: (isActive: boolean, url: string | undefined) => void + ['room.broadcast.status']: (isActive: boolean, url?: string) => void } export class NekoMessages extends EventEmitter { diff --git a/src/component/internal/webrtc.ts b/src/component/internal/webrtc.ts index 49dd49d9..b1d3e4cb 100644 --- a/src/component/internal/webrtc.ts +++ b/src/component/internal/webrtc.ts @@ -16,7 +16,7 @@ export interface WebRTCStats { fps: number width: number height: number - muted: boolean | undefined + muted?: boolean } export interface ICEServer { diff --git a/src/component/types/messages.ts b/src/component/types/messages.ts index 340a57aa..c8523682 100644 --- a/src/component/types/messages.ts +++ b/src/component/types/messages.ts @@ -1,7 +1,7 @@ import { ICEServer } from '../internal/webrtc' export interface Message { - event: string | undefined + event?: string payload: any } @@ -10,12 +10,12 @@ export interface Message { ///////////////////////////// export interface SystemWebRTC { - event: string | undefined + event?: string videos: string[] } export interface SystemInit { - event: string | undefined + event?: string session_id: string control_host: ControlHost screen_size: ScreenSize @@ -26,13 +26,13 @@ export interface SystemInit { } export interface SystemAdmin { - event: string | undefined + event?: string screen_sizes_list: ScreenSize[] broadcast_status: BroadcastStatus } export interface SystemDisconnect { - event: string | undefined + event?: string message: string } @@ -41,23 +41,23 @@ export interface SystemDisconnect { ///////////////////////////// export interface SignalProvide { - event: string | undefined + event?: string sdp: string iceservers: ICEServer[] video: string } export interface SignalCandidate extends RTCIceCandidateInit { - event: string | undefined + event?: string } export interface SignalAnswer { - event: string | undefined + event?: string sdp: string } export interface SignalVideo { - event: string | undefined + event?: string video: string } @@ -66,12 +66,12 @@ export interface SignalVideo { ///////////////////////////// export interface SessionID { - event: string | undefined + event?: string id: string } export interface MemberProfile { - event: string | undefined + event?: string id: string name: string is_admin: boolean @@ -83,14 +83,14 @@ export interface MemberProfile { } export interface SessionState { - event: string | undefined + event?: string id: string is_connected: boolean is_watching: boolean } export interface SessionData { - event: string | undefined + event?: string id: string profile: MemberProfile is_connected: boolean @@ -102,28 +102,28 @@ export interface SessionData { ///////////////////////////// export interface ControlHost { - event: string | undefined + event?: string has_host: boolean host_id: string | undefined } // TODO: New. export interface ControlMove { - event: string | undefined + event?: string x: number y: number } // TODO: New. export interface ControlScroll { - event: string | undefined + event?: string x: number y: number } // TODO: New. export interface ControlKey { - event: string | undefined + event?: string key: number } @@ -132,7 +132,7 @@ export interface ControlKey { ///////////////////////////// export interface ScreenSize { - event: string | undefined + event?: string width: number height: number rate: number @@ -143,7 +143,7 @@ export interface ScreenSize { ///////////////////////////// export interface ClipboardData { - event: string | undefined + event?: string text: string } @@ -152,14 +152,14 @@ export interface ClipboardData { ///////////////////////////// export interface KeyboardModifiers { - event: string | undefined + event?: string caps_lock: boolean num_lock: boolean scroll_lock: boolean } export interface KeyboardMap { - event: string | undefined + event?: string layout: string variant: string } @@ -169,7 +169,7 @@ export interface KeyboardMap { ///////////////////////////// export interface BroadcastStatus { - event: string | undefined + event?: string is_active: boolean url: string | undefined } @@ -179,7 +179,7 @@ export interface BroadcastStatus { ///////////////////////////// export interface SendMessage { - event: string | undefined + event?: string sender: string subject: string body: string diff --git a/src/component/types/state.ts b/src/component/types/state.ts index 72e3b21d..76f52ebf 100644 --- a/src/component/types/state.ts +++ b/src/component/types/state.ts @@ -32,7 +32,7 @@ export interface WebRTCStats { fps: number width: number height: number - muted: boolean | undefined + muted?: boolean } ///////////////////////////// diff --git a/src/component/utils/reconnecter.ts b/src/component/utils/reconnecter.ts index f18f16ef..b7269d8e 100644 --- a/src/component/utils/reconnecter.ts +++ b/src/component/utils/reconnecter.ts @@ -39,12 +39,12 @@ export interface ReconnecterConfig { export class Reconnecter extends EventEmitter { private _conn: ReconnecterAbstract private _config: ReconnecterConfig - private _timeout: number | undefined + private _timeout?: number private _open = false private _connected = false private _total_reconnects = 0 - private _last_connected: Date | undefined + private _last_connected?: Date constructor(conn: ReconnecterAbstract, config?: ReconnecterConfig) { super()