diff --git a/README.md b/README.md index 79b23ae..7f08df9 100644 --- a/README.md +++ b/README.md @@ -544,7 +544,7 @@ Enables or disables the identifiers widget. This widget can be used to set the i Enables or disables the phone widget. This widget can be used to send SMS or phone call the Android virtual device. -### `Baseband` +### `baseband` ... diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..137247f --- /dev/null +++ b/index.d.ts @@ -0,0 +1,122 @@ +type KeyEffectDistance = { + distanceX: number; + distanceY: number; +}; + +interface KeyEffect { + initialX: number; + initialY: number; + 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 VmEvent = 'beforeunload' | 'fingerprint' | 'gps' | 'BATTERY_LEVEL' | string // TODO Provide an exhaustive list + +type VmCommunication = { + disconnect(): void; + addEventListener(event: VmEvent, callback: (msg: string) => void): void; // TODO Verify if msg is always string + sendData(data: { channel: string; messages: string[] }): void; // TODO Verify typing +}; + +type RegisteredFunctionDoc = { + apiName: string, + apiDescription: string, +} + +type Utils = { + getRegisteredFunctions(): RegisteredFunctionDoc[]; +}; + +type Media = { + mute(): void; + unmute(): void; +}; + +type Video = { + fullscreen: () => void; +}; + +type Template = 'bootstrap' + | 'fullscreen' + | 'fullwindow' + | 'renderer' + | 'renderer_minimal' + | 'renderer_no_toolbar' + | 'renderer_partial'; + +interface Options { + baseband?: boolean; // Default: false + battery?: boolean; // Default: true + biometrics?: boolean; // Default: true + camera?: boolean; // Default: true + capture?: boolean; // Default: true + clipboard?: boolean; // Default: true + connectionFailedURL?: string; + diskIO?: boolean; // Default: true + fileUpload?: boolean; // Default: true + fileUploadUrl?: string; + fullscreen?: boolean; // Default: true + gamepad?: boolean; // Default: true + giveFeedbackLink?: string; + gps?: boolean; // Default: true + gpsSpeedSupport?: boolean; // Default: false + i18n?: Record; + identifiers?: boolean; // Default: true + keyboard?: boolean; // Default: true + keyboardMapping?: boolean; // Default: true + microphone?: boolean; // Default: false + mobilethrottling?: boolean; // Default: false + mouse?: boolean; // Default: true + navbar?: boolean; // Default: true + network?: boolean; // Default: true + phone?: boolean; // Default: true + power?: boolean; // Default: true + rotation?: boolean; // Default: true + streamBitrate?: boolean; // Default: false + streamResolution?: boolean; // Default: true + stun?: { urls?: string[] }; + template?: Template; // Default: 'renderer' + token?: string; + touch?: boolean; // Default: true + translateHomeKey?: boolean; // Default: false + turn?: { + urls?: string[]; + username?: string; + credential?: string; + default?: boolean; // Default: false + }; + volume?: boolean; // Default: true +} + +type DeviceRendererApi = { + keyMapping: true extends O['keyboardMapping'] ? DeviceRendererKeyMapping : undefined; // TODO Check + media: Media; + utils: Utils; + video?: Video; // Available if any plugin (e.g. fullscreen) using it is enabled. + VM_communication: VmCommunication; +}; + +declare class DeviceRendererFactory { + constructor(); + setupRenderer(targetElement: HTMLDivElement, webrtcAddress: string, options?: O): DeviceRendererApi; +} + +export { DeviceRendererApi, DeviceRendererFactory, KeyMappingConfig } diff --git a/package.json b/package.json index 661c329..6f036e6 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "files": [ "dist" ], + "types": "dist/index.d.ts", "engines": { "node": ">=16" },