|
1 | 1 | export type SimDeckLaunchOptions = { |
2 | 2 | cliPath?: string; |
3 | 3 | projectRoot?: string; |
| 4 | + udid?: string; |
4 | 5 | keepDaemon?: boolean; |
5 | 6 | isolated?: boolean; |
6 | 7 | port?: number; |
7 | 8 | videoCodec?: "auto" | "hardware" | "software" | "h264-software"; |
8 | 9 | }; |
9 | 10 | export type QueryOptions = { |
10 | | - source?: "auto" | "nativescript" | "uikit" | "native-ax"; |
| 11 | + source?: |
| 12 | + | "auto" |
| 13 | + | "nativescript" |
| 14 | + | "react-native" |
| 15 | + | "swiftui" |
| 16 | + | "uikit" |
| 17 | + | "native-ax"; |
11 | 18 | maxDepth?: number; |
12 | 19 | includeHidden?: boolean; |
13 | 20 | }; |
14 | 21 | export type ElementSelector = { |
| 22 | + text?: string; |
15 | 23 | id?: string; |
16 | 24 | label?: string; |
17 | 25 | value?: string; |
18 | 26 | type?: string; |
| 27 | + index?: number; |
| 28 | + enabled?: boolean; |
| 29 | + checked?: boolean; |
| 30 | + focused?: boolean; |
| 31 | + selected?: boolean; |
| 32 | + regex?: boolean; |
19 | 33 | }; |
20 | 34 | export type TapOptions = QueryOptions & { |
21 | 35 | durationMs?: number; |
22 | 36 | waitTimeoutMs?: number; |
23 | 37 | pollMs?: number; |
24 | 38 | }; |
| 39 | +type DeviceMethod<TArgs extends unknown[], TResult> = { |
| 40 | + (...args: TArgs): Promise<TResult>; |
| 41 | + (udid: string, ...args: TArgs): Promise<TResult>; |
| 42 | +}; |
| 43 | +type DeviceNoArgMethod<TResult> = { |
| 44 | + (): Promise<TResult>; |
| 45 | + (udid: string): Promise<TResult>; |
| 46 | +}; |
25 | 47 | export type SimDeckSession = { |
26 | 48 | endpoint: string; |
27 | 49 | pid: number; |
28 | 50 | projectRoot: string; |
| 51 | + udid?: string; |
| 52 | + device(udid: string): SimDeckSession; |
29 | 53 | list(): Promise<unknown>; |
30 | | - install(udid: string, appPath: string): Promise<void>; |
31 | | - uninstall(udid: string, bundleId: string): Promise<void>; |
32 | | - launch(udid: string, bundleId: string): Promise<void>; |
33 | | - openUrl(udid: string, url: string): Promise<void>; |
34 | | - tap(udid: string, x: number, y: number): Promise<void>; |
35 | | - tapElement( |
36 | | - udid: string, |
37 | | - selector: ElementSelector, |
38 | | - options?: TapOptions, |
39 | | - ): Promise<void>; |
40 | | - touch(udid: string, x: number, y: number, phase: string): Promise<void>; |
41 | | - key(udid: string, keyCode: number, modifiers?: number): Promise<void>; |
42 | | - button(udid: string, button: string, durationMs?: number): Promise<void>; |
43 | | - pasteboardSet(udid: string, text: string): Promise<void>; |
44 | | - pasteboardGet(udid: string): Promise<string>; |
45 | | - chromeProfile(udid: string): Promise<unknown>; |
46 | | - tree(udid: string, options?: QueryOptions): Promise<unknown>; |
47 | | - query( |
48 | | - udid: string, |
49 | | - selector: ElementSelector, |
50 | | - options?: QueryOptions, |
51 | | - ): Promise<unknown[]>; |
52 | | - assert( |
53 | | - udid: string, |
54 | | - selector: ElementSelector, |
55 | | - options?: QueryOptions, |
56 | | - ): Promise<unknown>; |
57 | | - waitFor( |
58 | | - udid: string, |
59 | | - selector: ElementSelector, |
60 | | - options?: QueryOptions & { |
61 | | - timeoutMs?: number; |
62 | | - pollMs?: number; |
63 | | - }, |
64 | | - ): Promise<unknown>; |
65 | | - batch( |
66 | | - udid: string, |
67 | | - steps: unknown[], |
68 | | - continueOnError?: boolean, |
69 | | - ): Promise<unknown>; |
70 | | - screenshot(udid: string): Promise<Buffer>; |
| 54 | + install: DeviceMethod<[appPath: string], void>; |
| 55 | + uninstall: DeviceMethod<[bundleId: string], void>; |
| 56 | + launch: DeviceMethod<[bundleId: string], void>; |
| 57 | + openUrl: DeviceMethod<[url: string], void>; |
| 58 | + tap: DeviceMethod<[x: number, y: number], void>; |
| 59 | + tapElement: DeviceMethod< |
| 60 | + [selector: ElementSelector, options?: TapOptions], |
| 61 | + void |
| 62 | + >; |
| 63 | + touch: DeviceMethod<[x: number, y: number, phase: string], void>; |
| 64 | + key: DeviceMethod<[keyCode: number, modifiers?: number], void>; |
| 65 | + button: DeviceMethod<[button: string, durationMs?: number], void>; |
| 66 | + pasteboardSet: DeviceMethod<[text: string], void>; |
| 67 | + pasteboardGet: DeviceNoArgMethod<string>; |
| 68 | + chromeProfile: DeviceNoArgMethod<unknown>; |
| 69 | + tree: DeviceMethod<[options?: QueryOptions], unknown>; |
| 70 | + query: DeviceMethod< |
| 71 | + [selector: ElementSelector, options?: QueryOptions], |
| 72 | + unknown[] |
| 73 | + >; |
| 74 | + assert: DeviceMethod< |
| 75 | + [selector: ElementSelector, options?: QueryOptions], |
| 76 | + unknown |
| 77 | + >; |
| 78 | + assertNot: DeviceMethod< |
| 79 | + [selector: ElementSelector, options?: QueryOptions], |
| 80 | + unknown |
| 81 | + >; |
| 82 | + waitFor: DeviceMethod< |
| 83 | + [ |
| 84 | + selector: ElementSelector, |
| 85 | + options?: QueryOptions & { |
| 86 | + timeoutMs?: number; |
| 87 | + pollMs?: number; |
| 88 | + }, |
| 89 | + ], |
| 90 | + unknown |
| 91 | + >; |
| 92 | + waitForNot: DeviceMethod< |
| 93 | + [ |
| 94 | + selector: ElementSelector, |
| 95 | + options?: QueryOptions & { |
| 96 | + timeoutMs?: number; |
| 97 | + pollMs?: number; |
| 98 | + }, |
| 99 | + ], |
| 100 | + unknown |
| 101 | + >; |
| 102 | + scrollUntilVisible: DeviceMethod< |
| 103 | + [ |
| 104 | + selector: ElementSelector, |
| 105 | + options?: QueryOptions & { |
| 106 | + timeoutMs?: number; |
| 107 | + pollMs?: number; |
| 108 | + direction?: "up" | "down" | "left" | "right"; |
| 109 | + durationMs?: number; |
| 110 | + steps?: number; |
| 111 | + }, |
| 112 | + ], |
| 113 | + unknown |
| 114 | + >; |
| 115 | + batch: DeviceMethod<[steps: unknown[], continueOnError?: boolean], unknown>; |
| 116 | + screenshot: DeviceNoArgMethod<Buffer>; |
71 | 117 | close(): void; |
72 | 118 | }; |
73 | 119 | export declare function connect( |
74 | 120 | options?: SimDeckLaunchOptions, |
75 | 121 | ): Promise<SimDeckSession>; |
| 122 | +export {}; |
0 commit comments