@appium/coresim 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +66 -0
- package/binding.gyp +53 -0
- package/lib/src/commands/app.d.ts +88 -0
- package/lib/src/commands/app.d.ts.map +1 -0
- package/lib/src/commands/app.js +133 -0
- package/lib/src/commands/app.js.map +1 -0
- package/lib/src/commands/biometric.d.ts +33 -0
- package/lib/src/commands/biometric.d.ts.map +1 -0
- package/lib/src/commands/biometric.js +44 -0
- package/lib/src/commands/biometric.js.map +1 -0
- package/lib/src/commands/darwin-notification.d.ts +36 -0
- package/lib/src/commands/darwin-notification.d.ts.map +1 -0
- package/lib/src/commands/darwin-notification.js +35 -0
- package/lib/src/commands/darwin-notification.js.map +1 -0
- package/lib/src/commands/interaction.d.ts +48 -0
- package/lib/src/commands/interaction.d.ts.map +1 -0
- package/lib/src/commands/interaction.js +48 -0
- package/lib/src/commands/interaction.js.map +1 -0
- package/lib/src/commands/keychain.d.ts +25 -0
- package/lib/src/commands/keychain.d.ts.map +1 -0
- package/lib/src/commands/keychain.js +52 -0
- package/lib/src/commands/keychain.js.map +1 -0
- package/lib/src/commands/lifecycle.d.ts +101 -0
- package/lib/src/commands/lifecycle.d.ts.map +1 -0
- package/lib/src/commands/lifecycle.js +165 -0
- package/lib/src/commands/lifecycle.js.map +1 -0
- package/lib/src/commands/media.d.ts +28 -0
- package/lib/src/commands/media.d.ts.map +1 -0
- package/lib/src/commands/media.js +27 -0
- package/lib/src/commands/media.js.map +1 -0
- package/lib/src/commands/misc.d.ts +15 -0
- package/lib/src/commands/misc.d.ts.map +1 -0
- package/lib/src/commands/misc.js +12 -0
- package/lib/src/commands/misc.js.map +1 -0
- package/lib/src/commands/pasteboard.d.ts +24 -0
- package/lib/src/commands/pasteboard.d.ts.map +1 -0
- package/lib/src/commands/pasteboard.js +22 -0
- package/lib/src/commands/pasteboard.js.map +1 -0
- package/lib/src/commands/permissions.d.ts +48 -0
- package/lib/src/commands/permissions.d.ts.map +1 -0
- package/lib/src/commands/permissions.js +84 -0
- package/lib/src/commands/permissions.js.map +1 -0
- package/lib/src/commands/process.d.ts +16 -0
- package/lib/src/commands/process.d.ts.map +1 -0
- package/lib/src/commands/process.js +68 -0
- package/lib/src/commands/process.js.map +1 -0
- package/lib/src/commands/screenshot.d.ts +29 -0
- package/lib/src/commands/screenshot.d.ts.map +1 -0
- package/lib/src/commands/screenshot.js +30 -0
- package/lib/src/commands/screenshot.js.map +1 -0
- package/lib/src/commands/spawn.d.ts +48 -0
- package/lib/src/commands/spawn.d.ts.map +1 -0
- package/lib/src/commands/spawn.js +108 -0
- package/lib/src/commands/spawn.js.map +1 -0
- package/lib/src/commands/ui.d.ts +42 -0
- package/lib/src/commands/ui.d.ts.map +1 -0
- package/lib/src/commands/ui.js +44 -0
- package/lib/src/commands/ui.js.map +1 -0
- package/lib/src/commands/webinspector.d.ts +19 -0
- package/lib/src/commands/webinspector.d.ts.map +1 -0
- package/lib/src/commands/webinspector.js +16 -0
- package/lib/src/commands/webinspector.js.map +1 -0
- package/lib/src/errors.d.ts +51 -0
- package/lib/src/errors.d.ts.map +1 -0
- package/lib/src/errors.js +82 -0
- package/lib/src/errors.js.map +1 -0
- package/lib/src/index.d.ts +7 -0
- package/lib/src/index.d.ts.map +1 -0
- package/lib/src/index.js +5 -0
- package/lib/src/index.js.map +1 -0
- package/lib/src/native-simctl.d.ts +62 -0
- package/lib/src/native-simctl.d.ts.map +1 -0
- package/lib/src/native-simctl.js +221 -0
- package/lib/src/native-simctl.js.map +1 -0
- package/lib/src/types.d.ts +267 -0
- package/lib/src/types.d.ts.map +1 -0
- package/lib/src/types.js +29 -0
- package/lib/src/types.js.map +1 -0
- package/lib/src/utils/index.d.ts +3 -0
- package/lib/src/utils/index.d.ts.map +1 -0
- package/lib/src/utils/index.js +3 -0
- package/lib/src/utils/index.js.map +1 -0
- package/lib/src/utils/pkg-root.d.ts +6 -0
- package/lib/src/utils/pkg-root.d.ts.map +1 -0
- package/lib/src/utils/pkg-root.js +12 -0
- package/lib/src/utils/pkg-root.js.map +1 -0
- package/lib/src/utils/run-catching.d.ts +3 -0
- package/lib/src/utils/run-catching.d.ts.map +1 -0
- package/lib/src/utils/run-catching.js +11 -0
- package/lib/src/utils/run-catching.js.map +1 -0
- package/package.json +73 -0
- package/scripts/install.mjs +22 -0
- package/src/commands/app.ts +186 -0
- package/src/commands/biometric.ts +69 -0
- package/src/commands/darwin-notification.ts +51 -0
- package/src/commands/interaction.ts +74 -0
- package/src/commands/keychain.ts +63 -0
- package/src/commands/lifecycle.ts +210 -0
- package/src/commands/media.ts +38 -0
- package/src/commands/misc.ts +20 -0
- package/src/commands/pasteboard.ts +31 -0
- package/src/commands/permissions.ts +122 -0
- package/src/commands/process.ts +80 -0
- package/src/commands/screenshot.ts +46 -0
- package/src/commands/spawn.ts +133 -0
- package/src/commands/ui.ts +61 -0
- package/src/commands/webinspector.ts +23 -0
- package/src/coresim.mm +1066 -0
- package/src/errors.ts +93 -0
- package/src/index.ts +23 -0
- package/src/native/async_bridge.h +164 -0
- package/src/native/nserror_bridge.h +64 -0
- package/src/native/nserror_bridge.mm +30 -0
- package/src/native/objc_runtime.h +45 -0
- package/src/native/objc_runtime.mm +76 -0
- package/src/native/safe_dispatch.h +38 -0
- package/src/native/sim_device.h +143 -0
- package/src/native/sim_device.mm +355 -0
- package/src/native/sim_device_set.h +16 -0
- package/src/native/sim_device_set.mm +40 -0
- package/src/native/sim_pasteboard.h +16 -0
- package/src/native/sim_pasteboard.mm +295 -0
- package/src/native/sim_process.h +13 -0
- package/src/native/sim_process.mm +139 -0
- package/src/native/sim_screenshot.h +28 -0
- package/src/native/sim_screenshot.mm +226 -0
- package/src/native/sim_service_context.h +42 -0
- package/src/native/sim_service_context.mm +92 -0
- package/src/native/tcc_privacy.h +35 -0
- package/src/native/tcc_privacy.mm +256 -0
- package/src/native/value_bridge.h +18 -0
- package/src/native/value_bridge.mm +111 -0
- package/src/native-simctl.ts +288 -0
- package/src/types.ts +302 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/pkg-root.ts +14 -0
- package/src/utils/run-catching.ts +10 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
/** Raw `SimDeviceState` enum values, as returned by `SimDevice.state`. */
|
|
2
|
+
export enum SimDeviceState {
|
|
3
|
+
Creating = 0,
|
|
4
|
+
Shutdown = 1,
|
|
5
|
+
Booting = 2,
|
|
6
|
+
Booted = 3,
|
|
7
|
+
ShuttingDown = 4,
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** A device in the default device set, as returned by `NativeSimctl.getDevices()`/`createDevice()`. */
|
|
11
|
+
export interface SimDeviceInfo {
|
|
12
|
+
/** e.g. `"D768CB90-CBB4-4557-82F6-B89E1CD0E80B"`. */
|
|
13
|
+
udid: string;
|
|
14
|
+
/** Display name, e.g. `"iPhone 17"`. */
|
|
15
|
+
name: string;
|
|
16
|
+
state: SimDeviceState;
|
|
17
|
+
/** e.g. `com.apple.CoreSimulator.SimDeviceType.iPhone-15` — `""` if that device type is no longer installed. */
|
|
18
|
+
deviceTypeIdentifier: string;
|
|
19
|
+
/** e.g. `com.apple.CoreSimulator.SimRuntime.iOS-17-4` — `""` if that runtime is no longer installed. */
|
|
20
|
+
runtimeIdentifier: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** A simulator device type this CoreSimulator install supports, as returned by `getSupportedDeviceTypes()`. */
|
|
24
|
+
export interface SimDeviceTypeInfo {
|
|
25
|
+
/** e.g. `com.apple.CoreSimulator.SimDeviceType.iPhone-15`. */
|
|
26
|
+
identifier: string;
|
|
27
|
+
/** Display name, e.g. `"iPhone 15"`. */
|
|
28
|
+
name: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** A simulator runtime this CoreSimulator install supports, as returned by `getSupportedRuntimes()`. */
|
|
32
|
+
export interface SimRuntimeInfo {
|
|
33
|
+
/** e.g. `com.apple.CoreSimulator.SimRuntime.iOS-17-4`. */
|
|
34
|
+
identifier: string;
|
|
35
|
+
/** Display name, e.g. `"iOS 17.4"`. */
|
|
36
|
+
name: string;
|
|
37
|
+
/** e.g. `"17.4"`. */
|
|
38
|
+
versionString: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Raw `SimDeviceBootInfo.status` values — a separate, more granular boot-progress signal than
|
|
43
|
+
* {@link SimDeviceState}, and the one `simctl bootstatus` itself actually monitors (see CLAUDE.md
|
|
44
|
+
* for how this was confirmed: runtime introspection against the loaded framework, and empirical
|
|
45
|
+
* polling during a real boot). `SimDeviceState` reaching `Booted`
|
|
46
|
+
* only means the OS kernel/launchd has started — data migration and system-app (SpringBoard)
|
|
47
|
+
* startup, which these values track, can still take **20+ seconds longer** after that.
|
|
48
|
+
* `simctl bootstatus`'s own output also names a `WaitingOnBackboard` phase whose numeric value
|
|
49
|
+
* wasn't observed in testing (not every boot passes through it) — a `status` outside this enum's
|
|
50
|
+
* values should be treated as "not yet terminal, keep waiting", not as an error.
|
|
51
|
+
*/
|
|
52
|
+
export enum SimBootStatus {
|
|
53
|
+
Booting = 0,
|
|
54
|
+
WaitingOnDataMigration = 2,
|
|
55
|
+
WaitingOnSystemApp = 4,
|
|
56
|
+
/** The only terminal value observed — `0xFFFFFFFF`. */
|
|
57
|
+
Finished = 0xffffffff,
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** What `NativeSimctl.getBootStatus()` resolves with when the device has been booted at least once. */
|
|
61
|
+
export interface SimBootInfo {
|
|
62
|
+
/** One of {@link SimBootStatus}'s values, or an unrecognized/undocumented one — see there. */
|
|
63
|
+
status: number;
|
|
64
|
+
/**
|
|
65
|
+
* Whether this boot attempt has fully settled (success or failure). Confirmed empirically to
|
|
66
|
+
* **stay `true` after shutdown**, reflecting the *previous* boot session — this alone does not
|
|
67
|
+
* mean "currently booted"; check `SimDeviceState` too (see `getBootStatus()`).
|
|
68
|
+
*/
|
|
69
|
+
isTerminal: boolean;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Result of `NativeSimctl.getPermission` — mirrors the TCC database's own auth states rather than
|
|
74
|
+
* a plain boolean, since `'unset'` (never prompted/decided) and `'denied'` (explicitly refused)
|
|
75
|
+
* are different states with different UI implications. `'limited'` only applies to `photos`
|
|
76
|
+
* ("selected photos" access) and is never produced by `grantPermission` itself, but can already be
|
|
77
|
+
* present if something else set it.
|
|
78
|
+
*/
|
|
79
|
+
export type SimPermissionStatus = 'unset' | 'denied' | 'granted' | 'limited';
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* A privacy permission grantable via `NativeSimctl.grantPermission`/`revokePermission`/
|
|
83
|
+
* `resetPermission`. Each is backed by a row in the simulator's own TCC (privacy) database —
|
|
84
|
+
* `location` isn't included since CoreLocation simulation has its own subsystem, not a plain TCC
|
|
85
|
+
* row (see CLAUDE.md).
|
|
86
|
+
*/
|
|
87
|
+
export type SimPermissionService =
|
|
88
|
+
| 'calendar'
|
|
89
|
+
| 'camera'
|
|
90
|
+
| 'contacts'
|
|
91
|
+
| 'health'
|
|
92
|
+
| 'homekit'
|
|
93
|
+
| 'medialibrary'
|
|
94
|
+
| 'microphone'
|
|
95
|
+
| 'motion'
|
|
96
|
+
| 'photos'
|
|
97
|
+
| 'reminders'
|
|
98
|
+
| 'siri'
|
|
99
|
+
| 'speech';
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* A device's renderable display, as returned by `NativeSimctl.getDisplays()`.
|
|
103
|
+
*/
|
|
104
|
+
export interface SimDisplayInfo {
|
|
105
|
+
/** Port UUID identifying this display — pass as `getScreenshot`'s `displayId` option to target it. */
|
|
106
|
+
id: string;
|
|
107
|
+
/** Raw `SimDisplayDescriptorState.displayClass` — 0 is always the primary display. */
|
|
108
|
+
displayClass: number;
|
|
109
|
+
/** Whether this is the primary display (`displayClass === 0`). */
|
|
110
|
+
isMain: boolean;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** Options for `NativeSimctl.getScreenshot`. */
|
|
114
|
+
export interface ScreenshotOptions {
|
|
115
|
+
/** Image encoding — defaults to `'png'`. */
|
|
116
|
+
format?: 'png' | 'jpeg';
|
|
117
|
+
/**
|
|
118
|
+
* Which display to capture, by `id` from `getDisplays()`. Defaults to the primary display
|
|
119
|
+
* (falling back to the first renderable display if none is primary, e.g. tvOS).
|
|
120
|
+
*/
|
|
121
|
+
displayId?: string;
|
|
122
|
+
/**
|
|
123
|
+
* JPEG quality as a percentage (0 = smallest/most compressed, 100 = largest/least compressed).
|
|
124
|
+
* Only meaningful with `format: 'jpeg'` — ignored for `'png'`, which is always lossless.
|
|
125
|
+
* Defaults to ImageIO's own default (near-lossless) when omitted.
|
|
126
|
+
*/
|
|
127
|
+
quality?: number;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Options for `NativeSimctl.spawnProcess`, passed through to CoreSimulator's
|
|
132
|
+
* `spawnWithPath:options:terminationQueue:terminationHandler:error:`. Only keys confirmed
|
|
133
|
+
* empirically (see CLAUDE.md) are typed here. CoreSimulator also recognizes
|
|
134
|
+
* `binpref`/`standalone`/`wait_for_debugger`/`enableCheckedAllocations`/`stdin`/`stdout`/`stderr`,
|
|
135
|
+
* but the latter three's expected value shape (`NSFileHandle`/XPC file descriptor/`NSNumber`,
|
|
136
|
+
* never a path string) isn't yet confirmed safe — passing the wrong type crashes the whole process
|
|
137
|
+
* instead of throwing a catchable error (see CLAUDE.md) — so they're deliberately omitted here.
|
|
138
|
+
*/
|
|
139
|
+
export interface SpawnOptions {
|
|
140
|
+
/** Fully replaces argv, including argv[0] — `path` only selects the executable. */
|
|
141
|
+
arguments?: string[];
|
|
142
|
+
/** Merged additively into the spawned process's environment. */
|
|
143
|
+
environment?: Record<string, string>;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** One running process/launchd job inside a device, as reported by `NativeSimctl.listProcesses`. */
|
|
147
|
+
export interface SimProcessInfo {
|
|
148
|
+
/** The process's real host OS pid (the simulator shares the host kernel). */
|
|
149
|
+
pid: number;
|
|
150
|
+
/** The launchd job's group, parsed from a label like `UIKitApplication:com.apple.app[...]` — `null` if the label has no group prefix. */
|
|
151
|
+
group: string | null;
|
|
152
|
+
/** The launchd job's name — a bundle identifier for an app process. */
|
|
153
|
+
name: string;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** The `alert` field of {@link ApnsPayload}, when it's a dictionary rather than a plain string. */
|
|
157
|
+
export interface ApnsAlert {
|
|
158
|
+
title?: string;
|
|
159
|
+
subtitle?: string;
|
|
160
|
+
body?: string;
|
|
161
|
+
'title-loc-key'?: string;
|
|
162
|
+
'title-loc-args'?: string[];
|
|
163
|
+
'subtitle-loc-key'?: string;
|
|
164
|
+
'subtitle-loc-args'?: string[];
|
|
165
|
+
'loc-key'?: string;
|
|
166
|
+
'loc-args'?: string[];
|
|
167
|
+
'action-loc-key'?: string;
|
|
168
|
+
'launch-image'?: string;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** The `sound` field of {@link ApnsPayload}, when it's a dictionary rather than a plain string. */
|
|
172
|
+
export interface ApnsSound {
|
|
173
|
+
critical?: 0 | 1;
|
|
174
|
+
name?: string;
|
|
175
|
+
volume?: number;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* The `aps` dictionary of a simulated push notification payload — see Apple's
|
|
180
|
+
* {@link https://developer.apple.com/documentation/usernotifications/generating-a-remote-notification | Generating a Remote Notification}.
|
|
181
|
+
* Only the commonly used fields are typed; `[key: string]: unknown` covers newer/less common ones
|
|
182
|
+
* (e.g. Live Activity fields like `event`/`content-state`/`attributes-type`) without blocking them.
|
|
183
|
+
*/
|
|
184
|
+
export interface ApnsPayload {
|
|
185
|
+
alert?: string | ApnsAlert;
|
|
186
|
+
badge?: number;
|
|
187
|
+
sound?: string | ApnsSound;
|
|
188
|
+
'thread-id'?: string;
|
|
189
|
+
category?: string;
|
|
190
|
+
'content-available'?: 0 | 1;
|
|
191
|
+
'mutable-content'?: 0 | 1;
|
|
192
|
+
'target-content-id'?: string;
|
|
193
|
+
'interruption-level'?: 'passive' | 'active' | 'time-sensitive' | 'critical';
|
|
194
|
+
'relevance-score'?: number;
|
|
195
|
+
'filter-criteria'?: string;
|
|
196
|
+
[key: string]: unknown;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Payload for `NativeSimctl.pushNotification` — an `aps` key with valid Apple Push Notification
|
|
201
|
+
* content is required; a top-level `"Simulator Target Bundle"` key is not (the separate `bundleId`
|
|
202
|
+
* argument covers it). Additional top-level keys are allowed — APNs delivers them to the app as
|
|
203
|
+
* custom data alongside `aps`.
|
|
204
|
+
*/
|
|
205
|
+
export interface PushNotificationPayload {
|
|
206
|
+
aps: ApnsPayload;
|
|
207
|
+
[key: string]: unknown;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Shape of the native addon's exports (see src/coresim.mm) — internal to native-simctl.ts, never
|
|
211
|
+
// exported from index.ts. Consumers only ever see NativeSimctl and the public types above.
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* What `NativeDeviceHandle.spawn()` resolves with once the process has started — `stdoutFd`/
|
|
215
|
+
* `stderrFd` are raw, already-`dup()`'d file descriptors (see coresim.mm) ready to be wrapped in a
|
|
216
|
+
* `net.Socket({fd, readable: true, writable: false})` (not `fs.createReadStream`, which would
|
|
217
|
+
* block a shared libuv threadpool worker for as long as the pipe stays quiet — see
|
|
218
|
+
* commands/spawn.ts); `pid` is a real host OS process id, killable directly.
|
|
219
|
+
*/
|
|
220
|
+
export interface NativeSpawnResult {
|
|
221
|
+
pid: number;
|
|
222
|
+
stdoutFd: number;
|
|
223
|
+
stderrFd: number;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Decoded wait(2)-style exit status (see CLAUDE.md for how the raw status was confirmed),
|
|
228
|
+
* mirroring Node's own `ChildProcess` `'exit'` event — exactly one of `code`/`signal` is set.
|
|
229
|
+
*/
|
|
230
|
+
export type NativeSpawnExitCallback = (code: number | null, signal: number | null) => void;
|
|
231
|
+
|
|
232
|
+
/** A `SimDevice`, wrapped by `coresim.mm`'s `NativeDevice` — what `NativeSimctl`'s `_findDevice()` resolves to. */
|
|
233
|
+
export interface NativeDeviceHandle {
|
|
234
|
+
// Trivial in-memory accessors — kept synchronous on the native side (see coresim.mm), never a
|
|
235
|
+
// CoreSimulator dispatch that could block.
|
|
236
|
+
udid(): string;
|
|
237
|
+
name(): string;
|
|
238
|
+
state(): number;
|
|
239
|
+
deviceTypeIdentifier(): string;
|
|
240
|
+
runtimeIdentifier(): string;
|
|
241
|
+
/** @internal Not part of the public API — see coresim.mm's RuntimeRootPath. */
|
|
242
|
+
runtimeRootPath(): string;
|
|
243
|
+
boot(options?: Record<string, unknown>): Promise<void>;
|
|
244
|
+
getBootStatus(): Promise<SimBootInfo | null>;
|
|
245
|
+
shutdown(): Promise<void>;
|
|
246
|
+
erase(): Promise<void>;
|
|
247
|
+
getenv(name: string): Promise<string>;
|
|
248
|
+
installApp(path: string, options?: Record<string, unknown>): Promise<void>;
|
|
249
|
+
uninstallApp(bundleId: string, options?: Record<string, unknown>): Promise<void>;
|
|
250
|
+
launchApp(bundleId: string, options?: Record<string, unknown>): Promise<number>;
|
|
251
|
+
terminateApp(bundleId: string): Promise<void>;
|
|
252
|
+
propertiesOfApplication(bundleId: string): Promise<Record<string, unknown>>;
|
|
253
|
+
installedApps(): Promise<Record<string, unknown>>;
|
|
254
|
+
openUrl(url: string): Promise<void>;
|
|
255
|
+
setLocation(latitude: number, longitude: number): Promise<void>;
|
|
256
|
+
clearLocation(): Promise<void>;
|
|
257
|
+
sendPushNotification(bundleId: string, payload: PushNotificationPayload): Promise<void>;
|
|
258
|
+
addCertificate(path: string, trustAsRoot: boolean): Promise<void>;
|
|
259
|
+
resetKeychain(): Promise<void>;
|
|
260
|
+
getUIAppearance(): Promise<number>;
|
|
261
|
+
setUIAppearance(style: number): Promise<void>;
|
|
262
|
+
getIncreaseContrast(): Promise<number>;
|
|
263
|
+
setIncreaseContrast(enabled: boolean): Promise<void>;
|
|
264
|
+
getContentSize(): Promise<number>;
|
|
265
|
+
setContentSize(category: number): Promise<void>;
|
|
266
|
+
grantPermission(service: string, bundleId: string): Promise<void>;
|
|
267
|
+
revokePermission(service: string, bundleId: string): Promise<void>;
|
|
268
|
+
resetPermission(service: string, bundleId: string): Promise<void>;
|
|
269
|
+
getPermission(service: string, bundleId: string): Promise<SimPermissionStatus>;
|
|
270
|
+
darwinNotificationGetState(name: string): Promise<bigint>;
|
|
271
|
+
darwinNotificationSetState(name: string, state: bigint): Promise<void>;
|
|
272
|
+
postDarwinNotification(name: string): Promise<void>;
|
|
273
|
+
addMedia(filePaths: string[]): Promise<void>;
|
|
274
|
+
addPhoto(filePath: string): Promise<void>;
|
|
275
|
+
addVideo(filePath: string): Promise<void>;
|
|
276
|
+
getPasteboard(): Promise<string>;
|
|
277
|
+
setPasteboard(content: string): Promise<void>;
|
|
278
|
+
getWebInspectorSocket(): Promise<string>;
|
|
279
|
+
screenshot(options?: {format?: 'png' | 'jpeg'; displayId?: string; quality?: number}): Promise<Buffer>;
|
|
280
|
+
getDisplays(): Promise<SimDisplayInfo[]>;
|
|
281
|
+
spawn(path: string, options: SpawnOptions | undefined, onExit: NativeSpawnExitCallback): Promise<NativeSpawnResult>;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/** A `SimDeviceSet`, wrapped by `coresim.mm`'s `NativeDeviceSet`. */
|
|
285
|
+
export interface NativeDeviceSetHandle {
|
|
286
|
+
devices(): Promise<NativeDeviceHandle[]>;
|
|
287
|
+
createDevice(deviceTypeIdentifier: string, runtimeIdentifier: string, name: string): Promise<NativeDeviceHandle>;
|
|
288
|
+
deleteDevice(device: NativeDeviceHandle): Promise<void>;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/** A `SimServiceContext`, wrapped by `coresim.mm`'s `NativeServiceContext`. */
|
|
292
|
+
export interface NativeServiceContextHandle {
|
|
293
|
+
defaultDeviceSet(): Promise<NativeDeviceSetHandle>;
|
|
294
|
+
supportedDeviceTypes(): Promise<SimDeviceTypeInfo[]>;
|
|
295
|
+
supportedRuntimes(): Promise<SimRuntimeInfo[]>;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/** The addon's module-level exports (`coresim.mm`'s `Init`) — the return value of `require('node-gyp-build')(...)`. */
|
|
299
|
+
export interface NativeCoreSimModule {
|
|
300
|
+
sharedServiceContext(developerDir: string): Promise<NativeServiceContextHandle>;
|
|
301
|
+
frameworkVersion(): Promise<string>;
|
|
302
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {fileURLToPath} from 'node:url';
|
|
2
|
+
|
|
3
|
+
import {node, util} from '@appium/support';
|
|
4
|
+
|
|
5
|
+
export const PACKAGE_NAME = '@appium/coresim';
|
|
6
|
+
|
|
7
|
+
/** Package root (contains binding.gyp, prebuilds/, or build/ after compile). */
|
|
8
|
+
export const getPkgRoot = util.memoize(function resolvePkgRoot(): string {
|
|
9
|
+
const root = node.getModuleRootSync(PACKAGE_NAME, fileURLToPath(import.meta.url));
|
|
10
|
+
if (!root) {
|
|
11
|
+
throw new Error(`Could not locate the root of the '${PACKAGE_NAME}' package`);
|
|
12
|
+
}
|
|
13
|
+
return root;
|
|
14
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {wrapNativeError} from '../errors.js';
|
|
2
|
+
|
|
3
|
+
/** Shared by NativeSimctl and every `src/commands/*.ts` mixin — maps a raw error surfaced by the addon to a typed one. */
|
|
4
|
+
export async function runCatchingAsync<T>(fn: () => Promise<T>): Promise<T> {
|
|
5
|
+
try {
|
|
6
|
+
return await fn();
|
|
7
|
+
} catch (err) {
|
|
8
|
+
wrapNativeError(err);
|
|
9
|
+
}
|
|
10
|
+
}
|