@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,44 @@
|
|
|
1
|
+
import { runCatchingAsync } from '../utils/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* @param udid — UDID of the device to read from
|
|
4
|
+
* @returns the device's current UI appearance style, as a raw `UIUserInterfaceStyle` value
|
|
5
|
+
*/
|
|
6
|
+
export async function getAppearance(udid) {
|
|
7
|
+
return runCatchingAsync(async () => (await this._findDevice(udid)).getUIAppearance());
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* @param udid — UDID of the target device
|
|
11
|
+
* @param style — a raw `UIUserInterfaceStyle` value to apply
|
|
12
|
+
*/
|
|
13
|
+
export async function setAppearance(udid, style) {
|
|
14
|
+
return runCatchingAsync(async () => (await this._findDevice(udid)).setUIAppearance(style));
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* @param udid — UDID of the device to read from
|
|
18
|
+
* @returns the device's current Increase Contrast accessibility setting
|
|
19
|
+
*/
|
|
20
|
+
export async function getIncreaseContrast(udid) {
|
|
21
|
+
return runCatchingAsync(async () => (await this._findDevice(udid)).getIncreaseContrast());
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* @param udid — UDID of the target device
|
|
25
|
+
* @param enabled — whether Increase Contrast should be enabled
|
|
26
|
+
*/
|
|
27
|
+
export async function setIncreaseContrast(udid, enabled) {
|
|
28
|
+
return runCatchingAsync(async () => (await this._findDevice(udid)).setIncreaseContrast(enabled));
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* @param udid — UDID of the device to read from
|
|
32
|
+
* @returns the device's current Dynamic Type content size category
|
|
33
|
+
*/
|
|
34
|
+
export async function getContentSize(udid) {
|
|
35
|
+
return runCatchingAsync(async () => (await this._findDevice(udid)).getContentSize());
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* @param udid — UDID of the target device
|
|
39
|
+
* @param category — the Dynamic Type content size category to apply
|
|
40
|
+
*/
|
|
41
|
+
export async function setContentSize(udid, category) {
|
|
42
|
+
return runCatchingAsync(async () => (await this._findDevice(udid)).setContentSize(category));
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=ui.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../../../src/commands/ui.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AAanD;;;GAGG;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,eAAe,EAAE,CAAC,CAAC;AACxF,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAqB,IAAY,EAAE,KAAa;IACjF,OAAO,gBAAgB,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC;AAC7F,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAqB,IAAY;IACxE,OAAO,gBAAgB,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,mBAAmB,EAAE,CAAC,CAAC;AAC5F,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAqB,IAAY,EAAE,OAAgB;IAC1F,OAAO,gBAAgB,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC;AACnG,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAqB,IAAY;IACnE,OAAO,gBAAgB,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,EAAE,CAAC,CAAC;AACvF,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAqB,IAAY,EAAE,QAAgB;IACrF,OAAO,gBAAgB,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC/F,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { NativeSimctl } from '../native-simctl.js';
|
|
2
|
+
declare module '../native-simctl.js' {
|
|
3
|
+
interface NativeSimctl {
|
|
4
|
+
getWebInspectorSocket(udid: string): Promise<string>;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Locates the Unix-domain socket a booted device's WebInspector service listens on, for WebKit
|
|
9
|
+
* remote-debugging tools to connect to directly.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const socketPath = await sim.getWebInspectorSocket(udid);
|
|
13
|
+
* const socket = net.connect(socketPath); // speak the WebInspector wire protocol from here
|
|
14
|
+
*
|
|
15
|
+
* @param udid — UDID of the device to inspect; must be booted
|
|
16
|
+
* @returns the socket's filesystem path
|
|
17
|
+
*/
|
|
18
|
+
export declare function getWebInspectorSocket(this: NativeSimctl, udid: string): Promise<string>;
|
|
19
|
+
//# sourceMappingURL=webinspector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webinspector.d.ts","sourceRoot":"","sources":["../../../src/commands/webinspector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,qBAAqB,CAAC;AAGtD,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAU,YAAY;QACpB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;KACtD;CACF;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAE7F"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { runCatchingAsync } from '../utils/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Locates the Unix-domain socket a booted device's WebInspector service listens on, for WebKit
|
|
4
|
+
* remote-debugging tools to connect to directly.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* const socketPath = await sim.getWebInspectorSocket(udid);
|
|
8
|
+
* const socket = net.connect(socketPath); // speak the WebInspector wire protocol from here
|
|
9
|
+
*
|
|
10
|
+
* @param udid — UDID of the device to inspect; must be booted
|
|
11
|
+
* @returns the socket's filesystem path
|
|
12
|
+
*/
|
|
13
|
+
export async function getWebInspectorSocket(udid) {
|
|
14
|
+
return runCatchingAsync(async () => (await this._findDevice(udid)).getWebInspectorSocket());
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=webinspector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webinspector.js","sourceRoot":"","sources":["../../../src/commands/webinspector.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AAQnD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAqB,IAAY;IAC1E,OAAO,gBAAgB,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,qBAAqB,EAAE,CAAC,CAAC;AAC9F,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** Base error for every failure raised by the native CoreSimulator addon. */
|
|
2
|
+
export declare class NativeSimError extends Error {
|
|
3
|
+
name: string;
|
|
4
|
+
constructor(message: string);
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The class/selector a call needed doesn't exist on the currently loaded CoreSimulator.framework,
|
|
8
|
+
* or a dynamic dispatch raised an NSException that got caught instead of crashing the process.
|
|
9
|
+
* Distinct from {@link NativeSimOperationError}: this means "not supported on this simulator
|
|
10
|
+
* runtime", not "the call ran and Apple's own code rejected it".
|
|
11
|
+
*/
|
|
12
|
+
export declare class NativeSimUnavailableError extends NativeSimError {
|
|
13
|
+
readonly kind: string;
|
|
14
|
+
readonly missing: string;
|
|
15
|
+
readonly frameworkVersion: string;
|
|
16
|
+
name: string;
|
|
17
|
+
/**
|
|
18
|
+
* @param message — human-readable description
|
|
19
|
+
* @param kind — `'class'` | `'selector'` | `'framework'`
|
|
20
|
+
* @param missing — the missing class/selector/framework name
|
|
21
|
+
* @param frameworkVersion — `CFBundleVersion` of the loaded CoreSimulator.framework
|
|
22
|
+
*/
|
|
23
|
+
constructor(message: string, kind: string, missing: string, frameworkVersion: string);
|
|
24
|
+
}
|
|
25
|
+
/** A dynamic dispatch raised an NSException that was caught rather than crashing the process. */
|
|
26
|
+
export declare class NativeSimDispatchError extends NativeSimError {
|
|
27
|
+
readonly exceptionName: string;
|
|
28
|
+
readonly reason: string;
|
|
29
|
+
name: string;
|
|
30
|
+
/**
|
|
31
|
+
* @param message — human-readable description
|
|
32
|
+
* @param exceptionName — the caught `NSException`'s `name`
|
|
33
|
+
* @param reason — the caught `NSException`'s `reason`
|
|
34
|
+
*/
|
|
35
|
+
constructor(message: string, exceptionName: string, reason: string);
|
|
36
|
+
}
|
|
37
|
+
/** The call reached CoreSimulator and Apple's own code rejected it (a structured `NSError`). */
|
|
38
|
+
export declare class NativeSimOperationError extends NativeSimError {
|
|
39
|
+
readonly domain: string;
|
|
40
|
+
readonly code: number;
|
|
41
|
+
name: string;
|
|
42
|
+
/**
|
|
43
|
+
* @param message — `NSError.localizedDescription`
|
|
44
|
+
* @param domain — `NSError.domain`
|
|
45
|
+
* @param code — `NSError.code`
|
|
46
|
+
*/
|
|
47
|
+
constructor(message: string, domain: string, code: number);
|
|
48
|
+
}
|
|
49
|
+
/** Re-throws a raw error surfaced by the native addon as the matching typed {@link NativeSimError}. */
|
|
50
|
+
export declare function wrapNativeError(err: unknown): never;
|
|
51
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,qBAAa,cAAe,SAAQ,KAAK;IACvB,IAAI,SAAoB;gBAE5B,OAAO,EAAE,MAAM;CAG5B;AAED;;;;;GAKG;AACH,qBAAa,yBAA0B,SAAQ,cAAc;aAWzC,IAAI,EAAE,MAAM;aACZ,OAAO,EAAE,MAAM;aACf,gBAAgB,EAAE,MAAM;IAZ1B,IAAI,SAA+B;IAEnD;;;;;OAKG;gBAED,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,gBAAgB,EAAE,MAAM;CAI3C;AAED,iGAAiG;AACjG,qBAAa,sBAAuB,SAAQ,cAAc;aAUtC,aAAa,EAAE,MAAM;aACrB,MAAM,EAAE,MAAM;IAVhB,IAAI,SAA4B;IAEhD;;;;OAIG;gBAED,OAAO,EAAE,MAAM,EACC,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,MAAM;CAIjC;AAED,gGAAgG;AAChG,qBAAa,uBAAwB,SAAQ,cAAc;aAUvC,MAAM,EAAE,MAAM;aACd,IAAI,EAAE,MAAM;IAVd,IAAI,SAA6B;IAEjD;;;;OAIG;gBAED,OAAO,EAAE,MAAM,EACC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM;CAI/B;AAED,uGAAuG;AACvG,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,KAAK,CAqBnD"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/** Base error for every failure raised by the native CoreSimulator addon. */
|
|
2
|
+
export class NativeSimError extends Error {
|
|
3
|
+
name = 'NativeSimError';
|
|
4
|
+
constructor(message) {
|
|
5
|
+
super(message);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The class/selector a call needed doesn't exist on the currently loaded CoreSimulator.framework,
|
|
10
|
+
* or a dynamic dispatch raised an NSException that got caught instead of crashing the process.
|
|
11
|
+
* Distinct from {@link NativeSimOperationError}: this means "not supported on this simulator
|
|
12
|
+
* runtime", not "the call ran and Apple's own code rejected it".
|
|
13
|
+
*/
|
|
14
|
+
export class NativeSimUnavailableError extends NativeSimError {
|
|
15
|
+
kind;
|
|
16
|
+
missing;
|
|
17
|
+
frameworkVersion;
|
|
18
|
+
name = 'NativeSimUnavailableError';
|
|
19
|
+
/**
|
|
20
|
+
* @param message — human-readable description
|
|
21
|
+
* @param kind — `'class'` | `'selector'` | `'framework'`
|
|
22
|
+
* @param missing — the missing class/selector/framework name
|
|
23
|
+
* @param frameworkVersion — `CFBundleVersion` of the loaded CoreSimulator.framework
|
|
24
|
+
*/
|
|
25
|
+
constructor(message, kind, missing, frameworkVersion) {
|
|
26
|
+
super(message);
|
|
27
|
+
this.kind = kind;
|
|
28
|
+
this.missing = missing;
|
|
29
|
+
this.frameworkVersion = frameworkVersion;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/** A dynamic dispatch raised an NSException that was caught rather than crashing the process. */
|
|
33
|
+
export class NativeSimDispatchError extends NativeSimError {
|
|
34
|
+
exceptionName;
|
|
35
|
+
reason;
|
|
36
|
+
name = 'NativeSimDispatchError';
|
|
37
|
+
/**
|
|
38
|
+
* @param message — human-readable description
|
|
39
|
+
* @param exceptionName — the caught `NSException`'s `name`
|
|
40
|
+
* @param reason — the caught `NSException`'s `reason`
|
|
41
|
+
*/
|
|
42
|
+
constructor(message, exceptionName, reason) {
|
|
43
|
+
super(message);
|
|
44
|
+
this.exceptionName = exceptionName;
|
|
45
|
+
this.reason = reason;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/** The call reached CoreSimulator and Apple's own code rejected it (a structured `NSError`). */
|
|
49
|
+
export class NativeSimOperationError extends NativeSimError {
|
|
50
|
+
domain;
|
|
51
|
+
code;
|
|
52
|
+
name = 'NativeSimOperationError';
|
|
53
|
+
/**
|
|
54
|
+
* @param message — `NSError.localizedDescription`
|
|
55
|
+
* @param domain — `NSError.domain`
|
|
56
|
+
* @param code — `NSError.code`
|
|
57
|
+
*/
|
|
58
|
+
constructor(message, domain, code) {
|
|
59
|
+
super(message);
|
|
60
|
+
this.domain = domain;
|
|
61
|
+
this.code = code;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/** Re-throws a raw error surfaced by the native addon as the matching typed {@link NativeSimError}. */
|
|
65
|
+
export function wrapNativeError(err) {
|
|
66
|
+
if (err instanceof NativeSimError) {
|
|
67
|
+
throw err;
|
|
68
|
+
}
|
|
69
|
+
const error = err;
|
|
70
|
+
const message = error?.message ?? String(err);
|
|
71
|
+
switch (error?.name) {
|
|
72
|
+
case 'NativeSimUnavailableError':
|
|
73
|
+
throw new NativeSimUnavailableError(message, String(error.kind ?? ''), String(error.missing ?? ''), String(error.frameworkVersion ?? ''));
|
|
74
|
+
case 'NativeSimDispatchError':
|
|
75
|
+
throw new NativeSimDispatchError(message, String(error.exceptionName ?? ''), String(error.reason ?? ''));
|
|
76
|
+
case 'NativeSimOperationError':
|
|
77
|
+
throw new NativeSimOperationError(message, String(error.domain ?? ''), Number(error.code ?? 0));
|
|
78
|
+
default:
|
|
79
|
+
throw new NativeSimError(message);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file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sC,CAAC;IACrD,MAAM,OAAO,GAAG,KAAK,EAAE,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC;IAC9C,QAAQ,KAAK,EAAE,IAAI,EAAE,CAAC;QACpB,KAAK,2BAA2B;YAC9B,MAAM,IAAI,yBAAyB,CACjC,OAAO,EACP,MAAM,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,EACxB,MAAM,CAAC,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC,EAC3B,MAAM,CAAC,KAAK,CAAC,gBAAgB,IAAI,EAAE,CAAC,CACrC,CAAC;QACJ,KAAK,wBAAwB;YAC3B,MAAM,IAAI,sBAAsB,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,aAAa,IAAI,EAAE,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC;QAC3G,KAAK,yBAAyB;YAC5B,MAAM,IAAI,uBAAuB,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;QAClG;YACE,MAAM,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { NativeSimError, NativeSimUnavailableError, NativeSimDispatchError, NativeSimOperationError } from './errors.js';
|
|
2
|
+
export { NativeSimctl } from './native-simctl.js';
|
|
3
|
+
export { SpawnedProcess } from './commands/spawn.js';
|
|
4
|
+
export type { AppContainerType } from './commands/app.js';
|
|
5
|
+
export type { BiometricName } from './commands/biometric.js';
|
|
6
|
+
export { SimBootStatus, SimDeviceState, type ApnsAlert, type ApnsPayload, type ApnsSound, type PushNotificationPayload, type ScreenshotOptions, type SimBootInfo, type SimDeviceInfo, type SimDeviceTypeInfo, type SimDisplayInfo, type SimPermissionService, type SimPermissionStatus, type SimProcessInfo, type SimRuntimeInfo, type SpawnOptions, } from './types.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,uBAAuB,EAAC,MAAM,aAAa,CAAC;AACvH,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAC,cAAc,EAAC,MAAM,qBAAqB,CAAC;AACnD,YAAY,EAAC,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AACxD,YAAY,EAAC,aAAa,EAAC,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EACL,aAAa,EACb,cAAc,EACd,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,uBAAuB,EAC5B,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,YAAY,GAClB,MAAM,YAAY,CAAC"}
|
package/lib/src/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { NativeSimError, NativeSimUnavailableError, NativeSimDispatchError, NativeSimOperationError } from './errors.js';
|
|
2
|
+
export { NativeSimctl } from './native-simctl.js';
|
|
3
|
+
export { SpawnedProcess } from './commands/spawn.js';
|
|
4
|
+
export { SimBootStatus, SimDeviceState, } from './types.js';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,uBAAuB,EAAC,MAAM,aAAa,CAAC;AACvH,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAC,cAAc,EAAC,MAAM,qBAAqB,CAAC;AAGnD,OAAO,EACL,aAAa,EACb,cAAc,GAef,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import './commands/app.js';
|
|
2
|
+
import './commands/biometric.js';
|
|
3
|
+
import './commands/darwin-notification.js';
|
|
4
|
+
import './commands/interaction.js';
|
|
5
|
+
import './commands/keychain.js';
|
|
6
|
+
import './commands/lifecycle.js';
|
|
7
|
+
import './commands/media.js';
|
|
8
|
+
import './commands/misc.js';
|
|
9
|
+
import './commands/pasteboard.js';
|
|
10
|
+
import './commands/permissions.js';
|
|
11
|
+
import './commands/process.js';
|
|
12
|
+
import './commands/screenshot.js';
|
|
13
|
+
import './commands/spawn.js';
|
|
14
|
+
import './commands/ui.js';
|
|
15
|
+
import './commands/webinspector.js';
|
|
16
|
+
import './commands/app.js';
|
|
17
|
+
import './commands/biometric.js';
|
|
18
|
+
import './commands/darwin-notification.js';
|
|
19
|
+
import './commands/interaction.js';
|
|
20
|
+
import './commands/keychain.js';
|
|
21
|
+
import './commands/lifecycle.js';
|
|
22
|
+
import './commands/media.js';
|
|
23
|
+
import './commands/misc.js';
|
|
24
|
+
import './commands/pasteboard.js';
|
|
25
|
+
import './commands/permissions.js';
|
|
26
|
+
import './commands/process.js';
|
|
27
|
+
import './commands/screenshot.js';
|
|
28
|
+
import './commands/spawn.js';
|
|
29
|
+
import './commands/ui.js';
|
|
30
|
+
import './commands/webinspector.js';
|
|
31
|
+
/**
|
|
32
|
+
* Drives `CoreSimulator.framework` directly — no `simctl`/`xcrun` subprocess — for the operations
|
|
33
|
+
* `node-simctl`'s `Simctl` class exposes over the CLI. Devices are addressed by UDID; each call
|
|
34
|
+
* re-resolves the native handle from the live device set, so a device deleted by another process
|
|
35
|
+
* surfaces as a normal "not found" error rather than stale state.
|
|
36
|
+
*
|
|
37
|
+
* Every method that can trigger a CoreSimulator dispatch is `async`: the native layer runs the
|
|
38
|
+
* underlying call on a libuv threadpool thread (see coresim.mm/async_bridge.h), so a slow
|
|
39
|
+
* install/erase/create/etc. never blocks Node's event loop.
|
|
40
|
+
*
|
|
41
|
+
* The public command surface (everything except the constructor, `frameworkVersion`, and the
|
|
42
|
+
* `_`-prefixed internal helpers below) lives in `src/commands/*.ts`, grouped by topic and mixed
|
|
43
|
+
* into this class via `Object.assign(NativeSimctl.prototype, ...)` at the bottom of this file —
|
|
44
|
+
* mirroring how `@appium/base-driver`'s `BaseDriver` composes its own command surface from
|
|
45
|
+
* `basedriver/commands/*.ts`. Each command module also declares a `declare module
|
|
46
|
+
* './native-simctl.js'` augmentation so `NativeSimctl`'s emitted type includes methods it doesn't
|
|
47
|
+
* textually define.
|
|
48
|
+
*/
|
|
49
|
+
export declare class NativeSimctl {
|
|
50
|
+
private readonly developerDir?;
|
|
51
|
+
private cachedServiceContext;
|
|
52
|
+
/**
|
|
53
|
+
* @param developerDir — defaults to `xcode-select -p` (the active Xcode's Developer dir).
|
|
54
|
+
* Constructing a NativeSimctl must never throw — the platform check and the native
|
|
55
|
+
* sharedServiceContext call both happen lazily in the `_serviceContext` getter below, so only a
|
|
56
|
+
* method that actually needs the simulator (getDevices(), createDevice(), ...) can raise.
|
|
57
|
+
*/
|
|
58
|
+
constructor(developerDir?: string | undefined);
|
|
59
|
+
/** @returns `CFBundleVersion` of the loaded `CoreSimulator.framework` (e.g. `"1171.6"`). */
|
|
60
|
+
static frameworkVersion(): Promise<string>;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=native-simctl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-simctl.d.ts","sourceRoot":"","sources":["../../src/native-simctl.ts"],"names":[],"mappings":"AAKA,OASO,mBAAmB,CAAC;AAC3B,OAAuE,yBAAyB,CAAC;AACjG,OAIO,mCAAmC,CAAC;AAC3C,OAA4E,2BAA2B,CAAC;AACxG,OAAgE,wBAAwB,CAAC;AACzF,OAYO,yBAAyB,CAAC;AACjC,OAA2C,qBAAqB,CAAC;AACjE,OAAoB,oBAAoB,CAAC;AACzC,OAA2C,0BAA0B,CAAC;AACtE,OAAgF,2BAA2B,CAAC;AAC5G,OAA4B,uBAAuB,CAAC;AACpD,OAAyC,0BAA0B,CAAC;AACpE,OAA2B,qBAAqB,CAAC;AACjD,OAOO,kBAAkB,CAAC;AAC1B,OAAoC,4BAA4B,CAAC;AAKjE,OAAO,mBAAmB,CAAC;AAC3B,OAAO,yBAAyB,CAAC;AACjC,OAAO,mCAAmC,CAAC;AAC3C,OAAO,2BAA2B,CAAC;AACnC,OAAO,wBAAwB,CAAC;AAChC,OAAO,yBAAyB,CAAC;AACjC,OAAO,qBAAqB,CAAC;AAC7B,OAAO,oBAAoB,CAAC;AAC5B,OAAO,0BAA0B,CAAC;AAClC,OAAO,2BAA2B,CAAC;AACnC,OAAO,uBAAuB,CAAC;AAC/B,OAAO,0BAA0B,CAAC;AAClC,OAAO,qBAAqB,CAAC;AAC7B,OAAO,kBAAkB,CAAC;AAC1B,OAAO,4BAA4B,CAAC;AAYpC;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,YAAY;IASX,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;IAR1C,OAAO,CAAC,oBAAoB,CAAkD;IAE9E;;;;;OAKG;gBAC0B,YAAY,CAAC,EAAE,MAAM,YAAA;IAElD,4FAA4F;WAC/E,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC;CA6CjD"}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import { util } from '@appium/support';
|
|
4
|
+
import { appInfo, getAppContainer, installApp, installedApps, isAppInstalled, launchApp, removeApp, terminateApp, } from './commands/app.js';
|
|
5
|
+
import { enrollBiometric, isBiometricEnrolled, sendBiometricMatch } from './commands/biometric.js';
|
|
6
|
+
import { getDarwinNotificationState, postDarwinNotification, setDarwinNotificationState, } from './commands/darwin-notification.js';
|
|
7
|
+
import { clearLocation, getEnv, openUrl, pushNotification, setLocation } from './commands/interaction.js';
|
|
8
|
+
import { addCertificate, addRootCertificate, resetKeychain } from './commands/keychain.js';
|
|
9
|
+
import { bootDevice, createDevice, deleteDevice, eraseDevice, getBootStatus, getDevices, getSupportedDeviceTypes, getSupportedRuntimes, shutdownAllDevices, shutdownDevice, waitForBoot, } from './commands/lifecycle.js';
|
|
10
|
+
import { addMedia, addPhoto, addVideo } from './commands/media.js';
|
|
11
|
+
import { shake } from './commands/misc.js';
|
|
12
|
+
import { getPasteboard, setPasteboard } from './commands/pasteboard.js';
|
|
13
|
+
import { getPermission, grantPermission, resetPermission, revokePermission } from './commands/permissions.js';
|
|
14
|
+
import { listProcesses } from './commands/process.js';
|
|
15
|
+
import { getDisplays, getScreenshot } from './commands/screenshot.js';
|
|
16
|
+
import { spawnProcess } from './commands/spawn.js';
|
|
17
|
+
import { getAppearance, getContentSize, getIncreaseContrast, setAppearance, setContentSize, setIncreaseContrast, } from './commands/ui.js';
|
|
18
|
+
import { getWebInspectorSocket } from './commands/webinspector.js';
|
|
19
|
+
// Bare re-imports so `declare module './native-simctl.js'` augmentations in the command modules
|
|
20
|
+
// (which add their methods to NativeSimctl's type) reach downstream consumers' emitted .d.ts
|
|
21
|
+
// import graph — the named imports above alone aren't part of NativeSimctl's emitted type
|
|
22
|
+
// surface, so `tsc` would otherwise drop them from the declaration output.
|
|
23
|
+
import './commands/app.js';
|
|
24
|
+
import './commands/biometric.js';
|
|
25
|
+
import './commands/darwin-notification.js';
|
|
26
|
+
import './commands/interaction.js';
|
|
27
|
+
import './commands/keychain.js';
|
|
28
|
+
import './commands/lifecycle.js';
|
|
29
|
+
import './commands/media.js';
|
|
30
|
+
import './commands/misc.js';
|
|
31
|
+
import './commands/pasteboard.js';
|
|
32
|
+
import './commands/permissions.js';
|
|
33
|
+
import './commands/process.js';
|
|
34
|
+
import './commands/screenshot.js';
|
|
35
|
+
import './commands/spawn.js';
|
|
36
|
+
import './commands/ui.js';
|
|
37
|
+
import './commands/webinspector.js';
|
|
38
|
+
import { NativeSimUnavailableError } from './errors.js';
|
|
39
|
+
import { getPkgRoot, PACKAGE_NAME, runCatchingAsync } from './utils/index.js';
|
|
40
|
+
const require = createRequire(import.meta.url);
|
|
41
|
+
/**
|
|
42
|
+
* Drives `CoreSimulator.framework` directly — no `simctl`/`xcrun` subprocess — for the operations
|
|
43
|
+
* `node-simctl`'s `Simctl` class exposes over the CLI. Devices are addressed by UDID; each call
|
|
44
|
+
* re-resolves the native handle from the live device set, so a device deleted by another process
|
|
45
|
+
* surfaces as a normal "not found" error rather than stale state.
|
|
46
|
+
*
|
|
47
|
+
* Every method that can trigger a CoreSimulator dispatch is `async`: the native layer runs the
|
|
48
|
+
* underlying call on a libuv threadpool thread (see coresim.mm/async_bridge.h), so a slow
|
|
49
|
+
* install/erase/create/etc. never blocks Node's event loop.
|
|
50
|
+
*
|
|
51
|
+
* The public command surface (everything except the constructor, `frameworkVersion`, and the
|
|
52
|
+
* `_`-prefixed internal helpers below) lives in `src/commands/*.ts`, grouped by topic and mixed
|
|
53
|
+
* into this class via `Object.assign(NativeSimctl.prototype, ...)` at the bottom of this file —
|
|
54
|
+
* mirroring how `@appium/base-driver`'s `BaseDriver` composes its own command surface from
|
|
55
|
+
* `basedriver/commands/*.ts`. Each command module also declares a `declare module
|
|
56
|
+
* './native-simctl.js'` augmentation so `NativeSimctl`'s emitted type includes methods it doesn't
|
|
57
|
+
* textually define.
|
|
58
|
+
*/
|
|
59
|
+
export class NativeSimctl {
|
|
60
|
+
developerDir;
|
|
61
|
+
cachedServiceContext;
|
|
62
|
+
/**
|
|
63
|
+
* @param developerDir — defaults to `xcode-select -p` (the active Xcode's Developer dir).
|
|
64
|
+
* Constructing a NativeSimctl must never throw — the platform check and the native
|
|
65
|
+
* sharedServiceContext call both happen lazily in the `_serviceContext` getter below, so only a
|
|
66
|
+
* method that actually needs the simulator (getDevices(), createDevice(), ...) can raise.
|
|
67
|
+
*/
|
|
68
|
+
constructor(developerDir) {
|
|
69
|
+
this.developerDir = developerDir;
|
|
70
|
+
}
|
|
71
|
+
/** @returns `CFBundleVersion` of the loaded `CoreSimulator.framework` (e.g. `"1171.6"`). */
|
|
72
|
+
static async frameworkVersion() {
|
|
73
|
+
return runCatchingAsync(() => loadNative().frameworkVersion());
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* @internal Not part of the public API — exposed (not `private`) only so `src/commands/*.ts`
|
|
77
|
+
* mixins can call it. Resolves and memoizes the native `SimServiceContext` on first access —
|
|
78
|
+
* never in the constructor. `loadNative()` must run (and throw its typed platform error) before
|
|
79
|
+
* `defaultDeveloperDir()` ever shells out to `xcode-select`, which doesn't exist off macOS — so
|
|
80
|
+
* the fallback is resolved as an argument to the native call, not eagerly, preserving that
|
|
81
|
+
* evaluation order. Caching the in-flight promise (not just its resolved value) means concurrent
|
|
82
|
+
* callers before the first resolution still only trigger one `sharedServiceContext` call. On
|
|
83
|
+
* rejection the cache is cleared again — a Promise is truthy even once rejected, so leaving a
|
|
84
|
+
* failed one cached would otherwise make every later call reuse that same stale rejection
|
|
85
|
+
* forever instead of retrying once the underlying condition clears.
|
|
86
|
+
*/
|
|
87
|
+
async _serviceContext() {
|
|
88
|
+
if (!this.cachedServiceContext) {
|
|
89
|
+
this.cachedServiceContext = runCatchingAsync(() => loadNative().sharedServiceContext(this.developerDir ?? defaultDeveloperDir())).catch((err) => {
|
|
90
|
+
this.cachedServiceContext = undefined;
|
|
91
|
+
throw err;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return this.cachedServiceContext;
|
|
95
|
+
}
|
|
96
|
+
/** @internal Not part of the public API — exposed only so `src/commands/*.ts` mixins can call it. */
|
|
97
|
+
async _deviceSet() {
|
|
98
|
+
const context = await this._serviceContext();
|
|
99
|
+
return runCatchingAsync(() => context.defaultDeviceSet());
|
|
100
|
+
}
|
|
101
|
+
/** @internal Not part of the public API — exposed only so `src/commands/*.ts` mixins can call it. */
|
|
102
|
+
async _findDevice(udid) {
|
|
103
|
+
return runCatchingAsync(async () => {
|
|
104
|
+
const deviceSet = await this._deviceSet();
|
|
105
|
+
const device = (await deviceSet.devices()).find((candidate) => candidate.udid() === udid);
|
|
106
|
+
if (!device) {
|
|
107
|
+
throw new Error(`No simulator device found with udid '${udid}'`);
|
|
108
|
+
}
|
|
109
|
+
return device;
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
Object.assign(NativeSimctl.prototype, {
|
|
114
|
+
// lifecycle
|
|
115
|
+
getDevices,
|
|
116
|
+
getSupportedDeviceTypes,
|
|
117
|
+
getSupportedRuntimes,
|
|
118
|
+
createDevice,
|
|
119
|
+
deleteDevice,
|
|
120
|
+
bootDevice,
|
|
121
|
+
getBootStatus,
|
|
122
|
+
waitForBoot,
|
|
123
|
+
shutdownDevice,
|
|
124
|
+
shutdownAllDevices,
|
|
125
|
+
eraseDevice,
|
|
126
|
+
// app
|
|
127
|
+
installApp,
|
|
128
|
+
removeApp,
|
|
129
|
+
launchApp,
|
|
130
|
+
terminateApp,
|
|
131
|
+
isAppInstalled,
|
|
132
|
+
appInfo,
|
|
133
|
+
installedApps,
|
|
134
|
+
getAppContainer,
|
|
135
|
+
// media
|
|
136
|
+
addMedia,
|
|
137
|
+
addPhoto,
|
|
138
|
+
addVideo,
|
|
139
|
+
// biometric
|
|
140
|
+
isBiometricEnrolled,
|
|
141
|
+
enrollBiometric,
|
|
142
|
+
sendBiometricMatch,
|
|
143
|
+
// misc
|
|
144
|
+
shake,
|
|
145
|
+
// interaction
|
|
146
|
+
getEnv,
|
|
147
|
+
openUrl,
|
|
148
|
+
setLocation,
|
|
149
|
+
clearLocation,
|
|
150
|
+
pushNotification,
|
|
151
|
+
// keychain
|
|
152
|
+
addCertificate,
|
|
153
|
+
addRootCertificate,
|
|
154
|
+
resetKeychain,
|
|
155
|
+
// ui
|
|
156
|
+
getAppearance,
|
|
157
|
+
setAppearance,
|
|
158
|
+
getIncreaseContrast,
|
|
159
|
+
setIncreaseContrast,
|
|
160
|
+
getContentSize,
|
|
161
|
+
setContentSize,
|
|
162
|
+
// permissions
|
|
163
|
+
grantPermission,
|
|
164
|
+
revokePermission,
|
|
165
|
+
resetPermission,
|
|
166
|
+
getPermission,
|
|
167
|
+
// process
|
|
168
|
+
listProcesses,
|
|
169
|
+
// darwin notification
|
|
170
|
+
getDarwinNotificationState,
|
|
171
|
+
setDarwinNotificationState,
|
|
172
|
+
postDarwinNotification,
|
|
173
|
+
// pasteboard
|
|
174
|
+
getPasteboard,
|
|
175
|
+
setPasteboard,
|
|
176
|
+
// screenshot
|
|
177
|
+
getScreenshot,
|
|
178
|
+
getDisplays,
|
|
179
|
+
// webinspector
|
|
180
|
+
getWebInspectorSocket,
|
|
181
|
+
// spawn
|
|
182
|
+
spawnProcess,
|
|
183
|
+
});
|
|
184
|
+
// Loaded lazily (not at module import time) so merely depending on/importing @appium/coresim —
|
|
185
|
+
// e.g. for its error classes or types — works on any platform; only actually using it (booting a
|
|
186
|
+
// simulator, etc.) requires macOS, where CoreSimulator.framework exists. `npm install` never
|
|
187
|
+
// attempts to build the addon on other platforms either (see scripts/install.mjs). Any macOS arch
|
|
188
|
+
// works — node-gyp-build falls back to compiling from source on an arch with no matching
|
|
189
|
+
// prebuild (e.g. an Intel Mac, since only darwin-arm64 is prebuilt today). util.memoize only
|
|
190
|
+
// caches a normal return, never a throw (see @appium/support's util.js), so the platform check
|
|
191
|
+
// below re-runs — and re-throws — on every call until it actually succeeds once.
|
|
192
|
+
const loadNative = util.memoize(function loadNative() {
|
|
193
|
+
if (process.platform !== 'darwin') {
|
|
194
|
+
throw new NativeSimUnavailableError(`${PACKAGE_NAME} requires macOS — CoreSimulator.framework does not exist on ${process.platform}`, 'platform', process.platform, 'n/a');
|
|
195
|
+
}
|
|
196
|
+
return require('node-gyp-build')(getPkgRoot());
|
|
197
|
+
});
|
|
198
|
+
const DEFAULT_DEVELOPER_DIR_TIMEOUT_MS = 15_000;
|
|
199
|
+
function defaultDeveloperDir() {
|
|
200
|
+
try {
|
|
201
|
+
return execFileSync('xcode-select', ['-p'], {
|
|
202
|
+
encoding: 'utf8',
|
|
203
|
+
timeout: DEFAULT_DEVELOPER_DIR_TIMEOUT_MS,
|
|
204
|
+
}).trim();
|
|
205
|
+
}
|
|
206
|
+
catch (err) {
|
|
207
|
+
// A non-zero exit (e.g. CLT installed but no Xcode selected) already carries a clear stderr
|
|
208
|
+
// message from xcode-select itself; only ENOENT (the binary isn't on PATH at all) and
|
|
209
|
+
// ETIMEDOUT need a friendlier message than Node's raw "spawnSync xcode-select ENOENT/ETIMEDOUT".
|
|
210
|
+
if (err?.code === 'ENOENT') {
|
|
211
|
+
throw new Error('xcode-select not found on PATH — install Xcode or the Xcode Command Line Tools', {
|
|
212
|
+
cause: err,
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
if (err?.code === 'ETIMEDOUT') {
|
|
216
|
+
throw new Error(`xcode-select -p did not respond within ${DEFAULT_DEVELOPER_DIR_TIMEOUT_MS}ms`, { cause: err });
|
|
217
|
+
}
|
|
218
|
+
throw err;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
//# sourceMappingURL=native-simctl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-simctl.js","sourceRoot":"","sources":["../../src/native-simctl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAC,aAAa,EAAC,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAC,IAAI,EAAC,MAAM,iBAAiB,CAAC;AAErC,OAAO,EACL,OAAO,EACP,eAAe,EACf,UAAU,EACV,aAAa,EACb,cAAc,EACd,SAAS,EACT,SAAS,EACT,YAAY,GACb,MAAM,mBA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