From c395c4ec556bf15079f690c4022a13419c61e0c7 Mon Sep 17 00:00:00 2001 From: Pascal Heitz Date: Thu, 1 Aug 2024 17:34:16 +0200 Subject: [PATCH] better typing --- index.d.ts | 201 ++++++++++++++++++++++++++++------------------------- 1 file changed, 105 insertions(+), 96 deletions(-) diff --git a/index.d.ts b/index.d.ts index 33af721..60ca46f 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,102 +1,111 @@ -declare module '@genymotion/device-web-player' { - interface KeyEffect { - initialX: number; - initialY: number; - name?: string; - description?: string; - } +type Distance = { + distanceX: number; + distanceY: number; +}; - type Distance = { - distanceX: number; - distanceY: number; - }; +interface KeyEffect { + initialX: number; + initialY: number; + name?: string; + description?: string; +} - interface KeyMap { - keys: Record; - name?: string; - description?: string; - } +interface KeyMap { + keys: Record; + name?: string; + description?: string; +} - interface KeyMappingConfig { - dpad?: KeyMap[]; - tap?: KeyMap[]; - swipe?: KeyMap[]; - } - type DeviceRendererKeyMapping = { - enable(isEnable: boolean): void; - setConfig(config: KeyMappingConfig): void; - activeKeyMappingDebug(isTraceActivate: boolean, isGridActivate: boolean): void; - }; - type VmCommunication = { - disconnect(): void; - addEventListener(event: string, callback: (msg: unknown) => void): void; - sendData(data: { channel: string; messages: string[] }); - }; - type Utils = { - getRegisteredFunctions(): unknown[]; - }; - type Media = { - mute(): void; - unmute(): void; - }; - type DeviceRenderer = { - VM_communication: VmCommunication; - utils: Utils; - keyMapping: DeviceRendererKeyMapping; - media: Media; - video: HTMLVideoElement; +interface KeyMappingConfig { + dpad?: KeyMap[]; + tap?: KeyMap[]; + swipe?: KeyMap[]; +} + +type DeviceRendererKeyMapping = { + enable(isEnable: boolean): void; + setConfig(config: KeyMappingConfig): void; + activeKeyMappingDebug(isTraceActivate: boolean, isGridActivate: boolean): void; +}; + +type VmEvent = 'beforeunload' | 'fingerprint' | 'gps' | 'BATTERY_LEVEL' + +type VmCommunication = { + disconnect(): void; + addEventListener(event: VmEvent, callback: (msg: unknown) => void): void; + sendData(data: { channel: string; messages: string[] }); +}; + +type Utils = { + getRegisteredFunctions(): unknown[]; +}; + +type Media = { + mute(): void; + unmute(): void; +}; + +type Template = 'bootstrap' + | 'fullscreen' + | 'fullwindow' + | 'renderer' + | 'renderer_minimal' + | 'renderer_no_toolbar' + | 'renderer_partial'; + +interface Options { + token?: string; + template?: Template; // Default: 'renderer' + i18n?: Record; + stun?: { urls?: Record }; + turn?: { + urls?: string[]; + username?: string; + credential?: string; + default?: boolean; // Default: false }; - interface Options { - token?: string; - template?: - | 'bootstrap' - | 'fullscreen' - | 'fullwindow' - | 'renderer' // Default - | 'renderer_minimal' - | 'renderer_no_toolbar' - | 'renderer_partial'; - i18n?: Record; - stun?: { urls?: Record }; - turn?: { - urls?: string[]; - username?: string; - credential?: string; - default?: boolean; // Default: false - }; - streamResolution?: boolean; // Default: true - streamBitrate?: boolean; // Default: false - touch?: boolean; // Default: true - mouse?: boolean; // Default: true - keyboard?: boolean; // Default: true - volume?: boolean; // Default: true - rotation?: boolean; // Default: true - navbar?: boolean; // Default: true - power?: boolean; // Default: true - fullscreen?: boolean; // Default: true - camera?: boolean; // Default: true - microphone?: boolean; // Default: false - fileUpload?: boolean; // Default: true - fileUploadUrl?: string; - clipboard?: boolean; // Default: true - battery?: boolean; // Default: true - gps?: boolean; // Default: true - gpsSpeedSupport?: boolean; // Default: false - capture?: boolean; // Default: true - identifiers?: boolean; // Default: true - network?: boolean; // Default: true - phone?: boolean; // Default: true - Baseband?: boolean; // Default: false - diskIO?: boolean; // Default: true - gamepad?: boolean; // Default: true - biometrics?: boolean; // Default: true - translateHomeKey?: boolean; // Default: false - connectionFailedURL?: string; - giveFeedbackLink?: string; - } - declare class DeviceRendererFactory { - constructor(); - setupRenderer(targetElement: HTMLDivElement, vmUrl: string, options?: Options): DeviceRenderer; - } + streamResolution?: boolean; // Default: true + streamBitrate?: boolean; // Default: false + touch?: boolean; // Default: true + mouse?: boolean; // Default: true + keyboard?: boolean; // Default: true + volume?: boolean; // Default: true + rotation?: boolean; // Default: true + navbar?: boolean; // Default: true + power?: boolean; // Default: true + fullscreen?: boolean; // Default: true + camera?: boolean; // Default: true + microphone?: boolean; // Default: false + fileUpload?: boolean; // Default: true + fileUploadUrl?: string; + clipboard?: boolean; // Default: true + battery?: boolean; // Default: true + gps?: boolean; // Default: true + gpsSpeedSupport?: boolean; // Default: false + capture?: boolean; // Default: true + identifiers?: boolean; // Default: true + network?: boolean; // Default: true + phone?: boolean; // Default: true + Baseband?: boolean; // Default: false + diskIO?: boolean; // Default: true + gamepad?: boolean; // Default: true + biometrics?: boolean; // Default: true + translateHomeKey?: boolean; // Default: false + connectionFailedURL?: string; + giveFeedbackLink?: string; +} + +type DeviceRenderer = { + VM_communication: VmCommunication; + utils: Utils; + keyMapping: DeviceRendererKeyMapping; + media: Media; + video: HTMLVideoElement; +}; + +declare class DeviceRendererFactory { + constructor(); + setupRenderer(targetElement: HTMLDivElement, webrtcAddress: string, options?: Options): DeviceRenderer; } +export { DeviceRenderer, DeviceRendererFactory, KeyMappingConfig }