-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathindex.d.ts
155 lines (137 loc) · 4.13 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
type KeyEffectDistance = {
distanceX: number;
distanceY: number;
};
interface KeyEffect {
initialX: number;
initialY: number;
name?: string;
description?: string;
}
interface KeyList<E> {
keys: Key<E>[];
name?: string;
description?: string;
}
interface Key<E> {
key: string;
effect: E;
name?: string;
description?: string;
}
interface KeyMappingConfig {
dpad?: KeyList<KeyEffect & KeyEffectDistance>[];
tap?: Key<KeyEffect>[];
swipe?: Key<KeyEffect & KeyEffectDistance>[];
}
type DeviceRendererKeyMapping = {
enable(isEnable: boolean): void;
setConfig(config: KeyMappingConfig): void;
activeKeyMappingDebug(isTraceActivate?: boolean, isGridActivate?: boolean): void;
};
type VmEvent =
| 'baseband'
| 'battery'
| 'beforeunload'
| 'diskio'
| 'fingerprint'
| 'framework'
| 'gps'
| 'network_profile'
| 'settings'
| 'systempatcher'
| 'vinput'
| string; // This list is not exhaustive and should be completed
type VmCommunication = {
disconnect(): void;
addEventListener(event: VmEvent, callback: (msg: string) => void): void;
sendData(data: {channel: string; messages: string[]}): void;
};
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 RendererSetupOptions {
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<string, string>;
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
turn?: {
urls?: string[];
username?: string;
credential?: string;
default?: boolean; // Default: false
};
volume?: boolean; // Default: true
}
type DefaultTrue<B, T> = B extends void
? T // Key is not present
: B extends true | undefined
? T // Key is true or undefined
: B extends false
? undefined // Key is false
: T | undefined; // Key is true, false or undefined (we cannot infer anything)
type ExtractKey<O, K extends keyof O> = O extends {[P in K]: infer T} ? T : void;
type DeviceRendererApi<O extends RendererSetupOptions = RendererSetupOptions> = {
keyMapping: DefaultTrue<ExtractKey<O, 'keyboardMapping'>, DeviceRendererKeyMapping>;
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<O extends RendererSetupOptions>(
targetElement: HTMLDivElement,
webrtcAddress: string,
options?: O,
): DeviceRendererApi<O>;
}
export {DeviceRendererApi, DeviceRendererFactory, RendererSetupOptions, KeyMappingConfig};