-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added DeviceRendererFactory typing #88
Merged
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9d1cb7c
Added DeviceRendererFactory typing
OoDeLally 0055d51
typo
OoDeLally 7e8be17
uncessary undefined
OoDeLally ae58303
export RendererSetupOptions
OoDeLally fcc558a
RendererSetupOptions
OoDeLally a8f4390
update gulpfile to ship declarations TS file *.d.ts
jparez 7313c6e
added typescript as dev dep
OoDeLally 81c2be9
added events, removed todos
OoDeLally d8b3e65
removed duplicates
OoDeLally 46c0fe4
indent
OoDeLally File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
type KeyEffectDistance = { | ||
distanceX: number; | ||
distanceY: number; | ||
}; | ||
|
||
interface KeyEffect { | ||
initialX: number; | ||
initialY: number; | ||
name?: string; | ||
description?: string; | ||
} | ||
|
||
interface KeyMap<E> { | ||
keys: Record<string, E>; | ||
name?: string; | ||
description?: string; | ||
} | ||
|
||
interface KeyMappingConfig { | ||
dpad?: KeyMap<KeyEffect & KeyEffectDistance>[]; | ||
tap?: KeyMap<KeyEffect>[]; | ||
swipe?: KeyMap<KeyEffect & KeyEffectDistance>[]; | ||
} | ||
|
||
type DeviceRendererKeyMapping = { | ||
enable(isEnable: boolean): void; | ||
setConfig(config: KeyMappingConfig): void; | ||
activeKeyMappingDebug(isTraceActivate?: boolean, isGridActivate?: boolean): void; | ||
}; | ||
|
||
type VmEvent = | ||
| 'ANDROID_ID' | ||
| 'baseband' | ||
| 'BATTERY_LEVEL' | ||
| 'BATTERY_LEVEL' | ||
| 'BATTERY_STATUS' | ||
| 'battery' | ||
| 'beforeunload' | ||
| 'BLK' | ||
| 'CLIPBOARD' | ||
| 'diskio' | ||
| 'fingerprint' | ||
| 'fingerprint' | ||
| 'framework' | ||
| 'gps' | ||
| 'gps' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. twice gps |
||
| 'IMEI' | ||
| 'network_profile' | ||
| 'NETWORK' | ||
| 'settings' | ||
| 'SYSTEM_PATCHER_LAST_RESULT' | ||
| 'SYSTEM_PATCHER_STATUS' | ||
| '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 | ||
translateHomeKey?: boolean; // Default: false | ||
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 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8794,6 +8794,11 @@ typescript@^4.6.2: | |
resolved "https://registry.npmjs.org/typescript/-/typescript-4.7.4.tgz" | ||
integrity sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ== | ||
|
||
typescript@^5.5.4: | ||
version "5.5.4" | ||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.5.4.tgz#d9852d6c82bad2d2eda4fd74a5762a8f5909e9ba" | ||
integrity sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q== | ||
|
||
[email protected]: | ||
version "1.0.2" | ||
resolved "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-1.0.2.tgz" | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
twice fingerprint