@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
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { NativeSimctl } from '../native-simctl.js';
|
|
2
|
+
declare module '../native-simctl.js' {
|
|
3
|
+
interface NativeSimctl {
|
|
4
|
+
getDarwinNotificationState(udid: string, name: string): Promise<bigint>;
|
|
5
|
+
setDarwinNotificationState(udid: string, name: string, state: bigint): Promise<void>;
|
|
6
|
+
postDarwinNotification(udid: string, name: string): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The "state" here is Darwin's low-level `notify(3)` per-name state value (`notify_get_state`) —
|
|
11
|
+
* a full 64-bit integer any process can attach to a notification name independently of posting
|
|
12
|
+
* it, so a reader can check the last-set value without having been listening at post time.
|
|
13
|
+
* Returned as `bigint`, not `number` — a JS `number` only has 53 bits of safe integer precision,
|
|
14
|
+
* not enough for an arbitrary 64-bit counter or bit field another process may have stored.
|
|
15
|
+
*
|
|
16
|
+
* @see https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/notify.3.html
|
|
17
|
+
* @param udid — UDID of the device to read from
|
|
18
|
+
* @param name — Darwin notification name
|
|
19
|
+
* @returns the last-set state value for that notification (`0n` if never set)
|
|
20
|
+
*/
|
|
21
|
+
export declare function getDarwinNotificationState(this: NativeSimctl, udid: string, name: string): Promise<bigint>;
|
|
22
|
+
/**
|
|
23
|
+
* Sets the state value of a Darwin notification on the given device, without posting it (see
|
|
24
|
+
* {@link getDarwinNotificationState} for what "state" means here — `notify(3)`'s `notify_set_state`).
|
|
25
|
+
*
|
|
26
|
+
* @param udid — UDID of the target device
|
|
27
|
+
* @param name — Darwin notification name
|
|
28
|
+
* @param state — state value to store; must fit in an unsigned 64-bit integer (`0n` to `2n**64n-1n`)
|
|
29
|
+
*/
|
|
30
|
+
export declare function setDarwinNotificationState(this: NativeSimctl, udid: string, name: string, state: bigint): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* @param udid — UDID of the target device
|
|
33
|
+
* @param name — Darwin notification name to post
|
|
34
|
+
*/
|
|
35
|
+
export declare function postDarwinNotification(this: NativeSimctl, udid: string, name: string): Promise<void>;
|
|
36
|
+
//# sourceMappingURL=darwin-notification.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"darwin-notification.d.ts","sourceRoot":"","sources":["../../../src/commands/darwin-notification.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,qBAAqB,CAAC;AAGtD,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAU,YAAY;QACpB,0BAA0B,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;QACxE,0BAA0B,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QACrF,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;KACnE;CACF;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,0BAA0B,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAEhH;AAED;;;;;;;GAOG;AACH,wBAAsB,0BAA0B,CAC9C,IAAI,EAAE,YAAY,EAClB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CAEf;AAED;;;GAGG;AACH,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE1G"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { runCatchingAsync } from '../utils/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* The "state" here is Darwin's low-level `notify(3)` per-name state value (`notify_get_state`) —
|
|
4
|
+
* a full 64-bit integer any process can attach to a notification name independently of posting
|
|
5
|
+
* it, so a reader can check the last-set value without having been listening at post time.
|
|
6
|
+
* Returned as `bigint`, not `number` — a JS `number` only has 53 bits of safe integer precision,
|
|
7
|
+
* not enough for an arbitrary 64-bit counter or bit field another process may have stored.
|
|
8
|
+
*
|
|
9
|
+
* @see https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/notify.3.html
|
|
10
|
+
* @param udid — UDID of the device to read from
|
|
11
|
+
* @param name — Darwin notification name
|
|
12
|
+
* @returns the last-set state value for that notification (`0n` if never set)
|
|
13
|
+
*/
|
|
14
|
+
export async function getDarwinNotificationState(udid, name) {
|
|
15
|
+
return runCatchingAsync(async () => (await this._findDevice(udid)).darwinNotificationGetState(name));
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Sets the state value of a Darwin notification on the given device, without posting it (see
|
|
19
|
+
* {@link getDarwinNotificationState} for what "state" means here — `notify(3)`'s `notify_set_state`).
|
|
20
|
+
*
|
|
21
|
+
* @param udid — UDID of the target device
|
|
22
|
+
* @param name — Darwin notification name
|
|
23
|
+
* @param state — state value to store; must fit in an unsigned 64-bit integer (`0n` to `2n**64n-1n`)
|
|
24
|
+
*/
|
|
25
|
+
export async function setDarwinNotificationState(udid, name, state) {
|
|
26
|
+
return runCatchingAsync(async () => (await this._findDevice(udid)).darwinNotificationSetState(name, state));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* @param udid — UDID of the target device
|
|
30
|
+
* @param name — Darwin notification name to post
|
|
31
|
+
*/
|
|
32
|
+
export async function postDarwinNotification(udid, name) {
|
|
33
|
+
return runCatchingAsync(async () => (await this._findDevice(udid)).postDarwinNotification(name));
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=darwin-notification.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"darwin-notification.js","sourceRoot":"","sources":["../../../src/commands/darwin-notification.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AAUnD;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAAqB,IAAY,EAAE,IAAY;IAC7F,OAAO,gBAAgB,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,0BAA0B,CAAC,IAAI,CAAC,CAAC,CAAC;AACvG,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAE9C,IAAY,EACZ,IAAY,EACZ,KAAa;IAEb,OAAO,gBAAgB,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,0BAA0B,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;AAC9G,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAqB,IAAY,EAAE,IAAY;IACzF,OAAO,gBAAgB,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC,CAAC;AACnG,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { NativeSimctl } from '../native-simctl.js';
|
|
2
|
+
import type { PushNotificationPayload } from '../types.js';
|
|
3
|
+
declare module '../native-simctl.js' {
|
|
4
|
+
interface NativeSimctl {
|
|
5
|
+
getEnv(udid: string, name: string): Promise<string>;
|
|
6
|
+
openUrl(udid: string, url: string): Promise<void>;
|
|
7
|
+
setLocation(udid: string, latitude: number, longitude: number): Promise<void>;
|
|
8
|
+
clearLocation(udid: string): Promise<void>;
|
|
9
|
+
pushNotification(udid: string, bundleId: string, payload: PushNotificationPayload): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* @param udid — UDID of the (booted) device to read from
|
|
14
|
+
* @param name — environment variable name
|
|
15
|
+
* @returns the variable's value
|
|
16
|
+
*/
|
|
17
|
+
export declare function getEnv(this: NativeSimctl, udid: string, name: string): Promise<string>;
|
|
18
|
+
/**
|
|
19
|
+
* Opens a URL on the given device; iOS resolves the app matching the URL's scheme.
|
|
20
|
+
*
|
|
21
|
+
* @param udid — UDID of the target device
|
|
22
|
+
* @param url — the URL to open, e.g. `https://appium.io`
|
|
23
|
+
*/
|
|
24
|
+
export declare function openUrl(this: NativeSimctl, udid: string, url: string): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Sets the given device's simulated GPS location.
|
|
27
|
+
*
|
|
28
|
+
* @param udid — UDID of the target device
|
|
29
|
+
* @param latitude — location latitude
|
|
30
|
+
* @param longitude — location longitude
|
|
31
|
+
*/
|
|
32
|
+
export declare function setLocation(this: NativeSimctl, udid: string, latitude: number, longitude: number): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Stops simulating a GPS location previously set via {@link setLocation}, reverting the device to
|
|
35
|
+
* its default (no simulated location) behavior.
|
|
36
|
+
*
|
|
37
|
+
* @param udid — UDID of the target device
|
|
38
|
+
*/
|
|
39
|
+
export declare function clearLocation(this: NativeSimctl, udid: string): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Delivers a simulated push notification to the given device.
|
|
42
|
+
*
|
|
43
|
+
* @param udid — UDID of the target device
|
|
44
|
+
* @param bundleId — bundle identifier of the app to receive the notification
|
|
45
|
+
* @param payload — see {@link PushNotificationPayload}
|
|
46
|
+
*/
|
|
47
|
+
export declare function pushNotification(this: NativeSimctl, udid: string, bundleId: string, payload: PushNotificationPayload): Promise<void>;
|
|
48
|
+
//# sourceMappingURL=interaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interaction.d.ts","sourceRoot":"","sources":["../../../src/commands/interaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,aAAa,CAAC;AAGzD,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAU,YAAY;QACpB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;QACpD,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAClD,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAC9E,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAC3C,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;KACnG;CACF;AAED;;;;GAIG;AACH,wBAAsB,MAAM,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAE5F;AAED;;;;;GAKG;AACH,wBAAsB,OAAO,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE1F;AAED;;;;;;GAMG;AACH,wBAAsB,WAAW,CAC/B,IAAI,EAAE,YAAY,EAClB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC,CAEf;AAED;;;;;GAKG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEnF;AAED;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,YAAY,EAClB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,IAAI,CAAC,CAEf"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { runCatchingAsync } from '../utils/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* @param udid — UDID of the (booted) device to read from
|
|
4
|
+
* @param name — environment variable name
|
|
5
|
+
* @returns the variable's value
|
|
6
|
+
*/
|
|
7
|
+
export async function getEnv(udid, name) {
|
|
8
|
+
return runCatchingAsync(async () => (await this._findDevice(udid)).getenv(name));
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Opens a URL on the given device; iOS resolves the app matching the URL's scheme.
|
|
12
|
+
*
|
|
13
|
+
* @param udid — UDID of the target device
|
|
14
|
+
* @param url — the URL to open, e.g. `https://appium.io`
|
|
15
|
+
*/
|
|
16
|
+
export async function openUrl(udid, url) {
|
|
17
|
+
return runCatchingAsync(async () => (await this._findDevice(udid)).openUrl(url));
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Sets the given device's simulated GPS location.
|
|
21
|
+
*
|
|
22
|
+
* @param udid — UDID of the target device
|
|
23
|
+
* @param latitude — location latitude
|
|
24
|
+
* @param longitude — location longitude
|
|
25
|
+
*/
|
|
26
|
+
export async function setLocation(udid, latitude, longitude) {
|
|
27
|
+
return runCatchingAsync(async () => (await this._findDevice(udid)).setLocation(latitude, longitude));
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Stops simulating a GPS location previously set via {@link setLocation}, reverting the device to
|
|
31
|
+
* its default (no simulated location) behavior.
|
|
32
|
+
*
|
|
33
|
+
* @param udid — UDID of the target device
|
|
34
|
+
*/
|
|
35
|
+
export async function clearLocation(udid) {
|
|
36
|
+
return runCatchingAsync(async () => (await this._findDevice(udid)).clearLocation());
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Delivers a simulated push notification to the given device.
|
|
40
|
+
*
|
|
41
|
+
* @param udid — UDID of the target device
|
|
42
|
+
* @param bundleId — bundle identifier of the app to receive the notification
|
|
43
|
+
* @param payload — see {@link PushNotificationPayload}
|
|
44
|
+
*/
|
|
45
|
+
export async function pushNotification(udid, bundleId, payload) {
|
|
46
|
+
return runCatchingAsync(async () => (await this._findDevice(udid)).sendPushNotification(bundleId, payload));
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=interaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interaction.js","sourceRoot":"","sources":["../../../src/commands/interaction.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AAYnD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAqB,IAAY,EAAE,IAAY;IACzE,OAAO,gBAAgB,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AACnF,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAqB,IAAY,EAAE,GAAW;IACzE,OAAO,gBAAgB,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;AACnF,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAE/B,IAAY,EACZ,QAAgB,EAChB,SAAiB;IAEjB,OAAO,gBAAgB,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;AACvG,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAqB,IAAY;IAClE,OAAO,gBAAgB,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC,CAAC;AACtF,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAEpC,IAAY,EACZ,QAAgB,EAChB,OAAgC;IAEhC,OAAO,gBAAgB,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,oBAAoB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;AAC9G,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { NativeSimctl } from '../native-simctl.js';
|
|
2
|
+
declare module '../native-simctl.js' {
|
|
3
|
+
interface NativeSimctl {
|
|
4
|
+
addCertificate(udid: string, cert: string | Buffer): Promise<void>;
|
|
5
|
+
addRootCertificate(udid: string, cert: string | Buffer): Promise<void>;
|
|
6
|
+
resetKeychain(udid: string): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Adds a certificate to the given device's keychain (not trusted as root).
|
|
11
|
+
*
|
|
12
|
+
* @param udid — UDID of the target device
|
|
13
|
+
* @param cert — path to a `.cert`/`.pem` file on disk, or the raw certificate content
|
|
14
|
+
*/
|
|
15
|
+
export declare function addCertificate(this: NativeSimctl, udid: string, cert: string | Buffer): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Adds a certificate to the given device's Trusted Root Store.
|
|
18
|
+
*
|
|
19
|
+
* @param udid — UDID of the target device
|
|
20
|
+
* @param cert — path to a `.cert`/`.pem` file on disk, or the raw certificate content
|
|
21
|
+
*/
|
|
22
|
+
export declare function addRootCertificate(this: NativeSimctl, udid: string, cert: string | Buffer): Promise<void>;
|
|
23
|
+
/** @param udid — UDID of the device whose keychain should be reset */
|
|
24
|
+
export declare function resetKeychain(this: NativeSimctl, udid: string): Promise<void>;
|
|
25
|
+
//# sourceMappingURL=keychain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keychain.d.ts","sourceRoot":"","sources":["../../../src/commands/keychain.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,qBAAqB,CAAC;AAGtD,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAU,YAAY;QACpB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QACnE,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QACvE,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;KAC5C;CACF;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAO3G;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAO/G;AAED,sEAAsE;AACtE,wBAAsB,aAAa,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEnF"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { rm, writeFile } from 'node:fs/promises';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { runCatchingAsync } from '../utils/index.js';
|
|
6
|
+
/**
|
|
7
|
+
* Adds a certificate to the given device's keychain (not trusted as root).
|
|
8
|
+
*
|
|
9
|
+
* @param udid — UDID of the target device
|
|
10
|
+
* @param cert — path to a `.cert`/`.pem` file on disk, or the raw certificate content
|
|
11
|
+
*/
|
|
12
|
+
export async function addCertificate(udid, cert) {
|
|
13
|
+
const { path: certPath, cleanup } = await resolveCertPath(cert);
|
|
14
|
+
try {
|
|
15
|
+
return await runCatchingAsync(async () => (await this._findDevice(udid)).addCertificate(certPath, false));
|
|
16
|
+
}
|
|
17
|
+
finally {
|
|
18
|
+
await cleanup();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Adds a certificate to the given device's Trusted Root Store.
|
|
23
|
+
*
|
|
24
|
+
* @param udid — UDID of the target device
|
|
25
|
+
* @param cert — path to a `.cert`/`.pem` file on disk, or the raw certificate content
|
|
26
|
+
*/
|
|
27
|
+
export async function addRootCertificate(udid, cert) {
|
|
28
|
+
const { path: certPath, cleanup } = await resolveCertPath(cert);
|
|
29
|
+
try {
|
|
30
|
+
return await runCatchingAsync(async () => (await this._findDevice(udid)).addCertificate(certPath, true));
|
|
31
|
+
}
|
|
32
|
+
finally {
|
|
33
|
+
await cleanup();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** @param udid — UDID of the device whose keychain should be reset */
|
|
37
|
+
export async function resetKeychain(udid) {
|
|
38
|
+
return runCatchingAsync(async () => (await this._findDevice(udid)).resetKeychain());
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The native call only accepts a file path — a `Buffer` is written to a throwaway temp file first,
|
|
42
|
+
* cleaned up by the caller once done.
|
|
43
|
+
*/
|
|
44
|
+
async function resolveCertPath(cert) {
|
|
45
|
+
if (typeof cert === 'string') {
|
|
46
|
+
return { path: cert, cleanup: async () => { } };
|
|
47
|
+
}
|
|
48
|
+
const tmpPath = path.join(os.tmpdir(), `${randomUUID()}.pem`);
|
|
49
|
+
await writeFile(tmpPath, cert);
|
|
50
|
+
return { path: tmpPath, cleanup: () => rm(tmpPath, { force: true }) };
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=keychain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keychain.js","sourceRoot":"","sources":["../../../src/commands/keychain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AACvC,OAAO,EAAC,EAAE,EAAE,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,EAAC,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AAUnD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAqB,IAAY,EAAE,IAAqB;IAC1F,MAAM,EAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAC,GAAG,MAAM,eAAe,CAAC,IAAI,CAAC,CAAC;IAC9D,IAAI,CAAC;QACH,OAAO,MAAM,gBAAgB,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;IAC5G,CAAC;YAAS,CAAC;QACT,MAAM,OAAO,EAAE,CAAC;IAClB,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,C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Info } from '../types.js';
|
|
3
|
+
import type { SimDeviceTypeInfo, SimRuntimeInfo } from '../types.js';
|
|
4
|
+
declare module '../native-simctl.js' {
|
|
5
|
+
interface NativeSimctl {
|
|
6
|
+
getDevices(): Promise<SimDeviceInfo[]>;
|
|
7
|
+
getSupportedDeviceTypes(): Promise<SimDeviceTypeInfo[]>;
|
|
8
|
+
getSupportedRuntimes(): Promise<SimRuntimeInfo[]>;
|
|
9
|
+
createDevice(name: string, deviceTypeIdentifier: string, runtimeIdentifier: string): Promise<SimDeviceInfo>;
|
|
10
|
+
deleteDevice(udid: string): Promise<void>;
|
|
11
|
+
bootDevice(udid: string, options?: Record<string, unknown>): Promise<void>;
|
|
12
|
+
getBootStatus(udid: string): Promise<SimBootInfo | null>;
|
|
13
|
+
waitForBoot(udid: string, options?: {
|
|
14
|
+
timeoutMs?: number;
|
|
15
|
+
}): Promise<void>;
|
|
16
|
+
shutdownDevice(udid: string): Promise<void>;
|
|
17
|
+
shutdownAllDevices(): Promise<void>;
|
|
18
|
+
eraseDevice(udid: string): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/** @returns every device in the default device set. */
|
|
22
|
+
export declare function getDevices(this: NativeSimctl): Promise<SimDeviceInfo[]>;
|
|
23
|
+
/** @returns every simulator device type this CoreSimulator install supports (e.g. "iPhone 15"). */
|
|
24
|
+
export declare function getSupportedDeviceTypes(this: NativeSimctl): Promise<SimDeviceTypeInfo[]>;
|
|
25
|
+
/** @returns every simulator runtime this CoreSimulator install supports (e.g. iOS 17.4). */
|
|
26
|
+
export declare function getSupportedRuntimes(this: NativeSimctl): Promise<SimRuntimeInfo[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Creates a new device in the default device set. Settles into the `Shutdown` state — never
|
|
29
|
+
* observed as `Creating` (see CLAUDE.md).
|
|
30
|
+
*
|
|
31
|
+
* @param name — display name for the new device
|
|
32
|
+
* @param deviceTypeIdentifier — e.g. `com.apple.CoreSimulator.SimDeviceType.iPhone-15`
|
|
33
|
+
* @param runtimeIdentifier — e.g. `com.apple.CoreSimulator.SimRuntime.iOS-17-4`
|
|
34
|
+
* @returns the newly created device
|
|
35
|
+
*/
|
|
36
|
+
export declare function createDevice(this: NativeSimctl, name: string, deviceTypeIdentifier: string, runtimeIdentifier: string): Promise<SimDeviceInfo>;
|
|
37
|
+
/**
|
|
38
|
+
* Deletes the given device from the default device set. Returns before the underlying
|
|
39
|
+
* filesystem cleanup finishes — eventually consistent (see CLAUDE.md).
|
|
40
|
+
*
|
|
41
|
+
* @param udid — UDID of the device to delete
|
|
42
|
+
*/
|
|
43
|
+
export declare function deleteDevice(this: NativeSimctl, udid: string): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Boots the given device; resolves only once CoreSimulator's own async completion handler
|
|
46
|
+
* fires (see CLAUDE.md for a rare eventual-consistency caveat on the resulting `state`).
|
|
47
|
+
*
|
|
48
|
+
* @param udid — UDID of the device to boot
|
|
49
|
+
* @param options — passed through to `bootWithOptions:`/`bootAsyncWithOptions:...:`; the
|
|
50
|
+
* option-dictionary keys are currently unverified (see CLAUDE.md)
|
|
51
|
+
*/
|
|
52
|
+
export declare function bootDevice(this: NativeSimctl, udid: string, options?: Record<string, unknown>): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Reads the device's current boot-progress status — the same underlying signal `simctl bootstatus`
|
|
55
|
+
* itself monitors (see CLAUDE.md), distinct from and more granular than `SimDeviceState`.
|
|
56
|
+
*
|
|
57
|
+
* @param udid — UDID of the device to read from
|
|
58
|
+
* @returns `null` if the device has never been booted; otherwise its most recent {@link SimBootInfo}.
|
|
59
|
+
* Confirmed empirically to **not** reset after shutdown — a shut-down device that was booted
|
|
60
|
+
* before still reports its last boot's terminal status, so check `getDevices()`'s `state` too if
|
|
61
|
+
* you need to know whether the device is *currently* booted (see {@link waitForBoot}, which does).
|
|
62
|
+
*/
|
|
63
|
+
export declare function getBootStatus(this: NativeSimctl, udid: string): Promise<SimBootInfo | null>;
|
|
64
|
+
/**
|
|
65
|
+
* Waits for the given device's boot to fully settle — matching `simctl bootstatus`'s own notion of
|
|
66
|
+
* "done" (`SimBootInfo.isTerminal`), not just `SimDeviceState` reaching `Booted`, which happens
|
|
67
|
+
* *tens of seconds* earlier while data migration/system-app startup are still in progress (see
|
|
68
|
+
* CLAUDE.md). Returns immediately if the device is already fully booted (its very first status
|
|
69
|
+
* check already sees `isTerminal`).
|
|
70
|
+
*
|
|
71
|
+
* @param udid — UDID of the device to monitor
|
|
72
|
+
* @param options.timeoutMs — how long to wait before giving up (default 4 minutes, matching
|
|
73
|
+
* `simctl bootstatus`'s own default timeout)
|
|
74
|
+
* @throws if the device isn't currently `Booting` or `Booted` — there's nothing to monitor
|
|
75
|
+
* @throws if the device stops booting (e.g. is shut down) before it finishes
|
|
76
|
+
* @throws if `timeoutMs` elapses before boot settles
|
|
77
|
+
*/
|
|
78
|
+
export declare function waitForBoot(this: NativeSimctl, udid: string, options?: {
|
|
79
|
+
timeoutMs?: number;
|
|
80
|
+
}): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* @param udid — UDID of the device to shut down
|
|
83
|
+
* @throws if the device is already `Shutdown` — this is not an idempotent no-op
|
|
84
|
+
*/
|
|
85
|
+
export declare function shutdownDevice(this: NativeSimctl, udid: string): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* Best-effort shutdown of every device in the default device set that isn't already `Shutdown` —
|
|
88
|
+
* the native equivalent of `xcrun simctl shutdown all`. A fan-out over {@link shutdownDevice}
|
|
89
|
+
* rather than `SimDeviceSet`'s own bulk method, whose completion-block signature couldn't be
|
|
90
|
+
* confirmed safely (see commit message). Per-device failures are swallowed.
|
|
91
|
+
*/
|
|
92
|
+
export declare function shutdownAllDevices(this: NativeSimctl): Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* Resets the given device's content and settings. Requires it to already be `Shutdown` — call
|
|
95
|
+
* {@link shutdownDevice} first if it's booted (see CLAUDE.md).
|
|
96
|
+
*
|
|
97
|
+
* @param udid — UDID of the device to erase
|
|
98
|
+
* @throws if the device isn't currently `Shutdown`
|
|
99
|
+
*/
|
|
100
|
+
export declare function eraseDevice(this: NativeSimctl, udid: string): Promise<void>;
|
|
101
|
+
//# sourceMappingURL=lifecycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../../src/commands/lifecycle.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAA0C,KAAK,WAAW,EAAE,KAAK,aAAa,EAAC,MAAM,aAAa,CAAC;AAC1G,OAAO,KAAK,EAAC,iBAAiB,EAAE,cAAc,EAAC,MAAM,aAAa,CAAC;AAKnE,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAU,YAAY;QACpB,UAAU,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;QACvC,uBAAuB,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC;QACxD,oBAAoB,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;QAClD,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;QAC5G,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAC1C,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAC3E,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;QACzD,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;YAAC,SAAS,CAAC,EAAE,MAAM,CAAA;SAAC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AY,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAyCrH;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEpF;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAU1E;AAED;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEjF"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { waitForCondition } from 'asyncbox';
|
|
2
|
+
import { SimDeviceState } from '../types.js';
|
|
3
|
+
import { runCatchingAsync } from '../utils/index.js';
|
|
4
|
+
const DEFAULT_BOOT_TIMEOUT_MS = 240_000;
|
|
5
|
+
/** @returns every device in the default device set. */
|
|
6
|
+
export async function getDevices() {
|
|
7
|
+
return runCatchingAsync(async () => {
|
|
8
|
+
const deviceSet = await this._deviceSet();
|
|
9
|
+
return (await deviceSet.devices()).map(toDeviceInfo);
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
/** @returns every simulator device type this CoreSimulator install supports (e.g. "iPhone 15"). */
|
|
13
|
+
export async function getSupportedDeviceTypes() {
|
|
14
|
+
return runCatchingAsync(async () => (await this._serviceContext()).supportedDeviceTypes());
|
|
15
|
+
}
|
|
16
|
+
/** @returns every simulator runtime this CoreSimulator install supports (e.g. iOS 17.4). */
|
|
17
|
+
export async function getSupportedRuntimes() {
|
|
18
|
+
return runCatchingAsync(async () => (await this._serviceContext()).supportedRuntimes());
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Creates a new device in the default device set. Settles into the `Shutdown` state — never
|
|
22
|
+
* observed as `Creating` (see CLAUDE.md).
|
|
23
|
+
*
|
|
24
|
+
* @param name — display name for the new device
|
|
25
|
+
* @param deviceTypeIdentifier — e.g. `com.apple.CoreSimulator.SimDeviceType.iPhone-15`
|
|
26
|
+
* @param runtimeIdentifier — e.g. `com.apple.CoreSimulator.SimRuntime.iOS-17-4`
|
|
27
|
+
* @returns the newly created device
|
|
28
|
+
*/
|
|
29
|
+
export async function createDevice(name, deviceTypeIdentifier, runtimeIdentifier) {
|
|
30
|
+
return runCatchingAsync(async () => {
|
|
31
|
+
const deviceSet = await this._deviceSet();
|
|
32
|
+
return toDeviceInfo(await deviceSet.createDevice(deviceTypeIdentifier, runtimeIdentifier, name));
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Deletes the given device from the default device set. Returns before the underlying
|
|
37
|
+
* filesystem cleanup finishes — eventually consistent (see CLAUDE.md).
|
|
38
|
+
*
|
|
39
|
+
* @param udid — UDID of the device to delete
|
|
40
|
+
*/
|
|
41
|
+
export async function deleteDevice(udid) {
|
|
42
|
+
return runCatchingAsync(async () => {
|
|
43
|
+
const [deviceSet, device] = await Promise.all([this._deviceSet(), this._findDevice(udid)]);
|
|
44
|
+
await deviceSet.deleteDevice(device);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Boots the given device; resolves only once CoreSimulator's own async completion handler
|
|
49
|
+
* fires (see CLAUDE.md for a rare eventual-consistency caveat on the resulting `state`).
|
|
50
|
+
*
|
|
51
|
+
* @param udid — UDID of the device to boot
|
|
52
|
+
* @param options — passed through to `bootWithOptions:`/`bootAsyncWithOptions:...:`; the
|
|
53
|
+
* option-dictionary keys are currently unverified (see CLAUDE.md)
|
|
54
|
+
*/
|
|
55
|
+
export async function bootDevice(udid, options = {}) {
|
|
56
|
+
return runCatchingAsync(async () => (await this._findDevice(udid)).boot(options));
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Reads the device's current boot-progress status — the same underlying signal `simctl bootstatus`
|
|
60
|
+
* itself monitors (see CLAUDE.md), distinct from and more granular than `SimDeviceState`.
|
|
61
|
+
*
|
|
62
|
+
* @param udid — UDID of the device to read from
|
|
63
|
+
* @returns `null` if the device has never been booted; otherwise its most recent {@link SimBootInfo}.
|
|
64
|
+
* Confirmed empirically to **not** reset after shutdown — a shut-down device that was booted
|
|
65
|
+
* before still reports its last boot's terminal status, so check `getDevices()`'s `state` too if
|
|
66
|
+
* you need to know whether the device is *currently* booted (see {@link waitForBoot}, which does).
|
|
67
|
+
*/
|
|
68
|
+
export async function getBootStatus(udid) {
|
|
69
|
+
return runCatchingAsync(async () => (await this._findDevice(udid)).getBootStatus());
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Waits for the given device's boot to fully settle — matching `simctl bootstatus`'s own notion of
|
|
73
|
+
* "done" (`SimBootInfo.isTerminal`), not just `SimDeviceState` reaching `Booted`, which happens
|
|
74
|
+
* *tens of seconds* earlier while data migration/system-app startup are still in progress (see
|
|
75
|
+
* CLAUDE.md). Returns immediately if the device is already fully booted (its very first status
|
|
76
|
+
* check already sees `isTerminal`).
|
|
77
|
+
*
|
|
78
|
+
* @param udid — UDID of the device to monitor
|
|
79
|
+
* @param options.timeoutMs — how long to wait before giving up (default 4 minutes, matching
|
|
80
|
+
* `simctl bootstatus`'s own default timeout)
|
|
81
|
+
* @throws if the device isn't currently `Booting` or `Booted` — there's nothing to monitor
|
|
82
|
+
* @throws if the device stops booting (e.g. is shut down) before it finishes
|
|
83
|
+
* @throws if `timeoutMs` elapses before boot settles
|
|
84
|
+
*/
|
|
85
|
+
export async function waitForBoot(udid, options = {}) {
|
|
86
|
+
const { timeoutMs = DEFAULT_BOOT_TIMEOUT_MS } = options;
|
|
87
|
+
return runCatchingAsync(async () => {
|
|
88
|
+
const initialState = (await this._findDevice(udid)).state();
|
|
89
|
+
if (initialState !== SimDeviceState.Booting && initialState !== SimDeviceState.Booted) {
|
|
90
|
+
throw new Error(`Device '${udid}' is not booting or booted (state: ${initialState})`);
|
|
91
|
+
}
|
|
92
|
+
// Re-resolves the device handle on every check (never caches it across the wait), matching
|
|
93
|
+
// every other method here — a device deleted mid-wait then surfaces as a normal "not found"
|
|
94
|
+
// error instead of a stale native reference failing in some less obvious way.
|
|
95
|
+
await waitForCondition(async () => {
|
|
96
|
+
const device = await this._findDevice(udid);
|
|
97
|
+
const stateBefore = device.state();
|
|
98
|
+
if (stateBefore !== SimDeviceState.Booting && stateBefore !== SimDeviceState.Booted) {
|
|
99
|
+
// getBootStatus()'s isTerminal is confirmed to never reset on shutdown, so it would
|
|
100
|
+
// still read true from a *previous* boot session here if the device stopped booting
|
|
101
|
+
// partway through this wait (e.g. shut down by another caller) — checking current state
|
|
102
|
+
// too prevents reporting that stale old boot as this wait having succeeded.
|
|
103
|
+
throw new Error(`Device '${udid}' stopped booting before it finished (state: ${stateBefore})`);
|
|
104
|
+
}
|
|
105
|
+
const bootInfo = await device.getBootStatus();
|
|
106
|
+
// getBootStatus() is itself an async native call — the device can stop booting while it's
|
|
107
|
+
// in flight, which would otherwise let a stale isTerminal from the check above pass this
|
|
108
|
+
// predicate. Rechecking afterward, and requiring Booted specifically (not just Booting):
|
|
109
|
+
// isTerminal only ever turns true once state has already reached Booted (see CLAUDE.md —
|
|
110
|
+
// SimDeviceState reaches Booted well before boot info settles), so Booting + isTerminal can
|
|
111
|
+
// only mean a stale status from a previous boot session, never real completion.
|
|
112
|
+
const stateAfter = device.state();
|
|
113
|
+
if (stateAfter !== SimDeviceState.Booting && stateAfter !== SimDeviceState.Booted) {
|
|
114
|
+
throw new Error(`Device '${udid}' stopped booting before it finished (state: ${stateAfter})`);
|
|
115
|
+
}
|
|
116
|
+
return stateAfter === SimDeviceState.Booted && bootInfo?.isTerminal === true;
|
|
117
|
+
}, {
|
|
118
|
+
waitMs: timeoutMs,
|
|
119
|
+
intervalMs: 500,
|
|
120
|
+
error: `Device '${udid}' did not finish booting within ${timeoutMs}ms`,
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* @param udid — UDID of the device to shut down
|
|
126
|
+
* @throws if the device is already `Shutdown` — this is not an idempotent no-op
|
|
127
|
+
*/
|
|
128
|
+
export async function shutdownDevice(udid) {
|
|
129
|
+
return runCatchingAsync(async () => (await this._findDevice(udid)).shutdown());
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Best-effort shutdown of every device in the default device set that isn't already `Shutdown` —
|
|
133
|
+
* the native equivalent of `xcrun simctl shutdown all`. A fan-out over {@link shutdownDevice}
|
|
134
|
+
* rather than `SimDeviceSet`'s own bulk method, whose completion-block signature couldn't be
|
|
135
|
+
* confirmed safely (see commit message). Per-device failures are swallowed.
|
|
136
|
+
*/
|
|
137
|
+
export async function shutdownAllDevices() {
|
|
138
|
+
return runCatchingAsync(async () => {
|
|
139
|
+
const deviceSet = await this._deviceSet();
|
|
140
|
+
const devices = await deviceSet.devices();
|
|
141
|
+
await Promise.all(devices
|
|
142
|
+
.filter((device) => device.state() !== SimDeviceState.Shutdown)
|
|
143
|
+
.map((device) => device.shutdown().catch(() => { })));
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Resets the given device's content and settings. Requires it to already be `Shutdown` — call
|
|
148
|
+
* {@link shutdownDevice} first if it's booted (see CLAUDE.md).
|
|
149
|
+
*
|
|
150
|
+
* @param udid — UDID of the device to erase
|
|
151
|
+
* @throws if the device isn't currently `Shutdown`
|
|
152
|
+
*/
|
|
153
|
+
export async function eraseDevice(udid) {
|
|
154
|
+
return runCatchingAsync(async () => (await this._findDevice(udid)).erase());
|
|
155
|
+
}
|
|
156
|
+
function toDeviceInfo(device) {
|
|
157
|
+
return {
|
|
158
|
+
udid: device.udid(),
|
|
159
|
+
name: device.name(),
|
|
160
|
+
state: device.state(),
|
|
161
|
+
deviceTypeIdentifier: device.deviceTypeIdentifier(),
|
|
162
|
+
runtimeIdentifier: device.runtimeIdentifier(),
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=lifecycle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../../../src/commands/lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,UAAU,CAAC;AAG1C,OAAO,EAAC,cAAc,EAAgE,MAAM,aAAa,CAAC;AAE1G,OAAO,EAAC,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AAEnD,MAAM,uBAAuB,GAAG,OAAO,CAAC;AAkBxC,uDAAuD;AACvD,MAAM,CAAC,KAAK,UAAU,UAAU;IAC9B,OAAO,gBAAgB,CAAC,KAAK,IAAI,EAAE;QACjC,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;QAC1C,OAAO,CAAC,MAAM,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;AACL,CAAC;AAED,mGAAmG;AACnG,MAAM,CAAC,KAAK,UAAU,uBAAuB;IAC3C,OAAO,gBAAgB,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC,oBAAoB,EAAE,CAAC,CAAC;AAC7F,CAAC;AAED,4FAA4F;AAC5F,MAAM,CAAC,KAAK,UAAU,oBAAoB;IACxC,OAAO,gBAAgB,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC,iBAAiB,EAAE,CAAC,CAAC;AAC1F,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAEhC,IAAY,EACZ,oBAA4B,EAC5B,iBAAyB;IAEzB,OAAO,gBAAgB,CAAC,KAAK,IAAI,EAAE;QACjC,MAAM,SAAS,GAAG,MAAM,IAAI,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QACvC,oBAAoB,EAAE,MAAM,CAAC,oBAAoB,EAAE;QACnD,iBAAiB,EAAE,MAAM,CAAC,iBAAiB,EAAE;KAC9C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { NativeSimctl } from '../native-simctl.js';
|
|
2
|
+
declare module '../native-simctl.js' {
|
|
3
|
+
interface NativeSimctl {
|
|
4
|
+
addMedia(udid: string, filePaths: string[]): Promise<void>;
|
|
5
|
+
addPhoto(udid: string, filePath: string): Promise<void>;
|
|
6
|
+
addVideo(udid: string, filePath: string): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Adds one or more photo/video files to the device's Photos library — the native equivalent of
|
|
11
|
+
* `simctl addmedia`. Each file's type is auto-detected; use {@link addPhoto}/{@link addVideo}
|
|
12
|
+
* instead when the file's kind is already known.
|
|
13
|
+
*
|
|
14
|
+
* @param udid — UDID of the target device
|
|
15
|
+
* @param filePaths — paths to the media files on the local filesystem
|
|
16
|
+
*/
|
|
17
|
+
export declare function addMedia(this: NativeSimctl, udid: string, filePaths: string[]): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* @param udid — UDID of the target device
|
|
20
|
+
* @param filePath — path to a photo file on the local filesystem
|
|
21
|
+
*/
|
|
22
|
+
export declare function addPhoto(this: NativeSimctl, udid: string, filePath: string): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* @param udid — UDID of the target device
|
|
25
|
+
* @param filePath — path to a video file on the local filesystem
|
|
26
|
+
*/
|
|
27
|
+
export declare function addVideo(this: NativeSimctl, udid: string, filePath: string): Promise<void>;
|
|
28
|
+
//# sourceMappingURL=media.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../../../src/commands/media.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,qBAAqB,CAAC;AAGtD,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAU,YAAY;QACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAC3D,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QACxD,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;KACzD;CACF;AAED;;;;;;;GAOG;AACH,wBAAsB,QAAQ,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAEnG;AAED;;;GAGG;AACH,wBAAsB,QAAQ,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEhG;AAED;;;GAGG;AACH,wBAAsB,QAAQ,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEhG"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { runCatchingAsync } from '../utils/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Adds one or more photo/video files to the device's Photos library — the native equivalent of
|
|
4
|
+
* `simctl addmedia`. Each file's type is auto-detected; use {@link addPhoto}/{@link addVideo}
|
|
5
|
+
* instead when the file's kind is already known.
|
|
6
|
+
*
|
|
7
|
+
* @param udid — UDID of the target device
|
|
8
|
+
* @param filePaths — paths to the media files on the local filesystem
|
|
9
|
+
*/
|
|
10
|
+
export async function addMedia(udid, filePaths) {
|
|
11
|
+
return runCatchingAsync(async () => (await this._findDevice(udid)).addMedia(filePaths));
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* @param udid — UDID of the target device
|
|
15
|
+
* @param filePath — path to a photo file on the local filesystem
|
|
16
|
+
*/
|
|
17
|
+
export async function addPhoto(udid, filePath) {
|
|
18
|
+
return runCatchingAsync(async () => (await this._findDevice(udid)).addPhoto(filePath));
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* @param udid — UDID of the target device
|
|
22
|
+
* @param filePath — path to a video file on the local filesystem
|
|
23
|
+
*/
|
|
24
|
+
export async function addVideo(udid, filePath) {
|
|
25
|
+
return runCatchingAsync(async () => (await this._findDevice(udid)).addVideo(filePath));
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=media.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.js","sourceRoot":"","sources":["../../../src/commands/media.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AAUnD;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAqB,IAAY,EAAE,SAAmB;IAClF,OAAO,gBAAgB,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;AAC1F,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAqB,IAAY,EAAE,QAAgB;IAC/E,OAAO,gBAAgB,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;AACzF,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAqB,IAAY,EAAE,QAAgB;IAC/E,OAAO,gBAAgB,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;AACzF,CAAC"}
|