@astur-mobile/android 0.1.0-beta.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.
@@ -0,0 +1,10 @@
1
+ import { type ChildProcess } from 'node:child_process';
2
+ export interface CommandResult {
3
+ stdout: Buffer;
4
+ stderr: Buffer;
5
+ }
6
+ export declare function run(file: string, args: readonly string[], maxBuffer?: number): Promise<CommandResult>;
7
+ export declare function runText(file: string, args: readonly string[]): Promise<string>;
8
+ export declare function spawnDetached(file: string, args: readonly string[]): ChildProcess;
9
+ export declare function spawnCommand(file: string, args: readonly string[]): ChildProcess;
10
+ //# sourceMappingURL=command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,YAAY,EAA0B,MAAM,oBAAoB,CAAC;AAGhG,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,SAAS,SAAmB,GAAG,OAAO,CAAC,aAAa,CAAC,CAc/G;AAED,wBAAsB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAGpF;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,YAAY,CAYjF;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,YAAY,CAIhF"}
@@ -0,0 +1,49 @@
1
+ import { execFile, spawn } from 'node:child_process';
2
+ import { AsturError } from '@astur-mobile/core';
3
+ export function run(file, args, maxBuffer = 20 * 1024 * 1024) {
4
+ return new Promise((resolve, reject) => {
5
+ execFile(file, [...args], { encoding: 'buffer', maxBuffer }, (error, stdout, stderr) => {
6
+ if (error) {
7
+ reject(toCommandError(file, args, error, stdout, stderr));
8
+ return;
9
+ }
10
+ resolve({
11
+ stdout: Buffer.isBuffer(stdout) ? stdout : Buffer.from(stdout ?? ''),
12
+ stderr: Buffer.isBuffer(stderr) ? stderr : Buffer.from(stderr ?? '')
13
+ });
14
+ });
15
+ });
16
+ }
17
+ export async function runText(file, args) {
18
+ const result = await run(file, args);
19
+ return result.stdout.toString('utf8');
20
+ }
21
+ export function spawnDetached(file, args) {
22
+ const child = spawn(file, [...args], {
23
+ detached: true,
24
+ stdio: 'ignore'
25
+ });
26
+ // A ChildProcess with no 'error' listener throws an uncaught exception when the
27
+ // binary cannot be launched (e.g. ENOENT), which would crash the host process.
28
+ // Keep a default no-op listener so a failed launch is recoverable; callers can
29
+ // attach their own listener to observe the error.
30
+ child.on('error', () => { });
31
+ child.unref();
32
+ return child;
33
+ }
34
+ export function spawnCommand(file, args) {
35
+ return spawn(file, [...args], {
36
+ stdio: 'ignore'
37
+ });
38
+ }
39
+ function toCommandError(file, args, error, stdout, stderr) {
40
+ const stdoutText = Buffer.isBuffer(stdout) ? stdout.toString('utf8') : stdout;
41
+ const stderrText = Buffer.isBuffer(stderr) ? stderr.toString('utf8') : stderr;
42
+ const message = stderrText.trim() || stdoutText.trim() || error.message;
43
+ return new AsturError('COMMAND_FAILED', `${file} ${args.join(' ')} failed: ${message}`, {
44
+ code: error.code,
45
+ stdout: stdoutText,
46
+ stderr: stderrText
47
+ });
48
+ }
49
+ //# sourceMappingURL=command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command.js","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAA6C,MAAM,oBAAoB,CAAC;AAChG,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAOhD,MAAM,UAAU,GAAG,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ver, type PlatformSession } from '@astur-mobile/core';
3
+ export interface AndroidDriverOptions {
4
+ adbPath?: string;
5
+ emulatorPath?: string;
6
+ aaptPath?: string;
7
+ }
8
+ export interface AndroidApkMetadata {
9
+ packageName: string;
10
+ launchActivity?: string;
11
+ versionName?: string;
12
+ }
13
+ export declare function createAndroidDriver(options?: AndroidDriverOptions): AndroidDriver;
14
+ export declare class AndroidDriver implements PlatformDriver {
15
+ readonly platform: "android";
16
+ private readonly adbPath;
17
+ private readonly emulatorPath;
18
+ private readonly aaptPath?;
19
+ constructor(options?: AndroidDriverOptions);
20
+ doctor(): Promise<DoctorCheck[]>;
21
+ listDevices(): Promise<DeviceInfo[]>;
22
+ listAvds(): Promise<string[]>;
23
+ createSession(capabilities: NormalizedCapabilities): Promise<PlatformSession>;
24
+ private resolveNativeAgent;
25
+ private tryBootstrapBundledNativeAgent;
26
+ private resolveCapabilities;
27
+ private resolveApp;
28
+ private readApkMetadata;
29
+ private bootConfiguredEmulator;
30
+ private waitForBoot;
31
+ }
32
+ export declare function parseAdbDevices(output: string): DeviceInfo[];
33
+ export declare function parseAaptBadging(output: string): AndroidApkMetadata;
34
+ export declare function parseAndroidKeyboardState(output: string): KeyboardState;
35
+ export declare function parseAndroidLockState(output: string): boolean;
36
+ export declare function parseAndroidWebViewSockets(output: string): string[];
37
+ export declare function parseAndroidLs(output: string, remotePath: string): DeviceFileEntry[];
38
+ export declare function normalizeAndroidKey(key: string): string;
39
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAKV,eAAe,EACf,UAAU,EAGV,WAAW,EAWX,aAAa,EAQb,sBAAsB,EAKvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAUL,KAAK,cAAc,EACnB,KAAK,eAAe,EACrB,MAAM,oBAAoB,CAAC;AAI5B,MAAM,WAAW,oBAAoB;IACnC,OAAO,CA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