@allwright.dev/core 0.1.15 → 0.1.17
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/dist/bootstrap.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/mobile.js +70 -0
- package/dist/types.d.ts +23 -0
- package/package.json +2 -1
package/dist/bootstrap.js
CHANGED
|
@@ -12,7 +12,7 @@ const ALLWRIGHT_HOME_ENV_VAR = "ALLWRIGHT_HOME";
|
|
|
12
12
|
const ALLWRIGHT_REPOSITORY_ENV_VAR = "ALLWRIGHT_REPOSITORY";
|
|
13
13
|
const ALLWRIGHT_VERSION_ENV_VAR = "ALLWRIGHT_VERSION";
|
|
14
14
|
const DEFAULT_RELEASE_REPOSITORY = "allwright-dev/allwright";
|
|
15
|
-
const DEFAULT_RELEASE_VERSION = "0.1.
|
|
15
|
+
const DEFAULT_RELEASE_VERSION = "0.1.17";
|
|
16
16
|
const STARTUP_TIMEOUT_MS = 20_000;
|
|
17
17
|
const PING_TIMEOUT_MS = 1_000;
|
|
18
18
|
const PROTO_ROOT = fileURLToPath(new URL("../proto/", import.meta.url));
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { PageImpl } from "./page.js";
|
|
|
5
5
|
import { setServerAddr, shutdown } from "./runtime.js";
|
|
6
6
|
import type { Browser, BrowserKind, BrowserType, LaunchOptions, Page, Dialog, FileChooser, Download, HookType, ResolveConfigOptions, ResolvedAllwrightConfig } from "./types.js";
|
|
7
7
|
export { findConfigFile, loadConfigFile, resolveConfig, setServerAddr, shutdown };
|
|
8
|
-
export type { CapturedOption, BoundingBox, AccessibilitySnapshotOptions, AllwrightConfig, Browser, BrowserInfo, BrowserKind, BrowserType, Hook, HookType, Dialog, FileChooser, Download, ClickResult, CommandOptions, CountResult, ElementResult, FillResult, HighlightOptions, HighlightResult, LaunchOptions, MobileAndroidConnectOptions, MobileAndroidDevice, MobileAndroidLaunchOptions, MobileAndroidLocator, MobileAndroidApp, Locator, LocatorInfo, MobileSurfaceNamespace, NavigateResult, Page, PageInfo, PressOptions, PressResult, ResolveConfigOptions, ResolvedAllwrightConfig, RetryConfig, ScreenshotOptions, ScreenshotResult, TextResult, WaitForSelectorOptions, WaitForSelectorResult, } from "./types.js";
|
|
8
|
+
export type { CapturedOption, BoundingBox, AccessibilitySnapshotOptions, AllwrightConfig, Browser, BrowserInfo, BrowserKind, BrowserType, Hook, HookType, Dialog, FileChooser, Download, ClickResult, CommandOptions, CountResult, ElementResult, FillResult, HighlightOptions, HighlightResult, LaunchOptions, MobileAndroidConnectOptions, MobileAndroidDevice, MobileAndroidLaunchOptions, MobileAndroidLocator, MobileAndroidApp, MobileIosConnectOptions, MobileIosDevice, MobileIosLaunchOptions, MobileIosLocator, MobileIosApp, Locator, LocatorInfo, MobileSurfaceNamespace, NavigateResult, Page, PageInfo, PressOptions, PressResult, ResolveConfigOptions, ResolvedAllwrightConfig, RetryConfig, ScreenshotOptions, ScreenshotResult, TextResult, WaitForSelectorOptions, WaitForSelectorResult, } from "./types.js";
|
|
9
9
|
export declare const chromium: BrowserType;
|
|
10
10
|
export declare const firefox: BrowserType;
|
|
11
11
|
export declare const hooks: {
|
package/dist/mobile.js
CHANGED
|
@@ -605,6 +605,50 @@ class MobileAndroidDeviceImpl {
|
|
|
605
605
|
}
|
|
606
606
|
}
|
|
607
607
|
}
|
|
608
|
+
class MobileIosDeviceImpl {
|
|
609
|
+
sessionId;
|
|
610
|
+
surfaceSessionId;
|
|
611
|
+
runtime;
|
|
612
|
+
#stream;
|
|
613
|
+
#queue;
|
|
614
|
+
#closed = false;
|
|
615
|
+
#currentApp;
|
|
616
|
+
constructor(sessionId, surfaceSessionId, runtime, stream, queue, initialAppSessionId) {
|
|
617
|
+
this.sessionId = sessionId;
|
|
618
|
+
this.surfaceSessionId = surfaceSessionId;
|
|
619
|
+
this.runtime = runtime;
|
|
620
|
+
this.#stream = stream;
|
|
621
|
+
this.#queue = queue;
|
|
622
|
+
this.#currentApp = new MobileAndroidAppImpl(runtime, surfaceSessionId, initialAppSessionId);
|
|
623
|
+
}
|
|
624
|
+
app() { return this.#currentApp; }
|
|
625
|
+
initialApp() { return this.#currentApp; }
|
|
626
|
+
async launch(options = {}) {
|
|
627
|
+
if (this.#closed)
|
|
628
|
+
throw new Error(`ios device session ${this.sessionId} is closed`);
|
|
629
|
+
this.#stream.write({
|
|
630
|
+
launchApp: {
|
|
631
|
+
apkPath: options.appPath,
|
|
632
|
+
appId: options.appId,
|
|
633
|
+
stopBeforeLaunch: options.stopBeforeLaunch ?? false,
|
|
634
|
+
retryOptions: retryOptions(options.timeoutMs),
|
|
635
|
+
},
|
|
636
|
+
});
|
|
637
|
+
while (true) {
|
|
638
|
+
const event = await this.#queue.next();
|
|
639
|
+
if (event.appLaunched?.appSessionId) {
|
|
640
|
+
this.#currentApp = new MobileAndroidAppImpl(this.runtime, this.surfaceSessionId, event.appLaunched.appSessionId);
|
|
641
|
+
return this.#currentApp;
|
|
642
|
+
}
|
|
643
|
+
if (event.error?.message)
|
|
644
|
+
throw new Error(event.error.message);
|
|
645
|
+
if (event.closed) {
|
|
646
|
+
this.#closed = true;
|
|
647
|
+
throw new Error(`ios device session ${this.sessionId} closed while launching app`);
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
}
|
|
608
652
|
class MobileAndroidSurfaceImpl {
|
|
609
653
|
async connect(options = {}) {
|
|
610
654
|
const runtime = await getRuntime();
|
|
@@ -629,6 +673,32 @@ class MobileAndroidSurfaceImpl {
|
|
|
629
673
|
}
|
|
630
674
|
}
|
|
631
675
|
}
|
|
676
|
+
class MobileIosSurfaceImpl {
|
|
677
|
+
async connect(options = {}) {
|
|
678
|
+
const runtime = await getRuntime();
|
|
679
|
+
const { stream, queue } = await createBrowserSessionHandle(runtime);
|
|
680
|
+
stream.write({
|
|
681
|
+
connectMobile: {
|
|
682
|
+
platform: 2,
|
|
683
|
+
device: options.device,
|
|
684
|
+
// The protobuf slot is transport-internal and shared with the older
|
|
685
|
+
// Android endpoint field; the public iOS API names it accurately.
|
|
686
|
+
adbEndpoint: options.agentEndpoint,
|
|
687
|
+
preserveAppState: options.preserveAppState ?? false,
|
|
688
|
+
retryOptions: retryOptions(options.timeoutMs),
|
|
689
|
+
},
|
|
690
|
+
});
|
|
691
|
+
while (true) {
|
|
692
|
+
const event = await queue.next();
|
|
693
|
+
if (event.mobileConnected?.initialAppSessionId) {
|
|
694
|
+
return new MobileIosDeviceImpl(event.mobileConnected.deviceSessionId ?? event.sessionId ?? "", event.sessionId ?? "", runtime, stream, queue, event.mobileConnected.initialAppSessionId);
|
|
695
|
+
}
|
|
696
|
+
if (event.error?.message)
|
|
697
|
+
throw new Error(event.error.message);
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
}
|
|
632
701
|
export const mobile = {
|
|
633
702
|
android: new MobileAndroidSurfaceImpl(),
|
|
703
|
+
ios: new MobileIosSurfaceImpl(),
|
|
634
704
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -217,10 +217,33 @@ export interface MobileAndroidDevice {
|
|
|
217
217
|
initialApp(): MobileAndroidApp;
|
|
218
218
|
launch(options?: MobileAndroidLaunchOptions): Promise<MobileAndroidApp>;
|
|
219
219
|
}
|
|
220
|
+
export interface MobileIosConnectOptions {
|
|
221
|
+
device?: string;
|
|
222
|
+
agentEndpoint?: string;
|
|
223
|
+
preserveAppState?: boolean;
|
|
224
|
+
timeoutMs?: number;
|
|
225
|
+
}
|
|
226
|
+
export interface MobileIosLaunchOptions {
|
|
227
|
+
appPath?: string;
|
|
228
|
+
appId?: string;
|
|
229
|
+
stopBeforeLaunch?: boolean;
|
|
230
|
+
timeoutMs?: number;
|
|
231
|
+
}
|
|
232
|
+
export type MobileIosLocator = MobileAndroidLocator;
|
|
233
|
+
export type MobileIosApp = MobileAndroidApp;
|
|
234
|
+
export interface MobileIosDevice {
|
|
235
|
+
readonly sessionId: string;
|
|
236
|
+
app(): MobileIosApp;
|
|
237
|
+
initialApp(): MobileIosApp;
|
|
238
|
+
launch(options?: MobileIosLaunchOptions): Promise<MobileIosApp>;
|
|
239
|
+
}
|
|
220
240
|
export interface MobileSurfaceNamespace {
|
|
221
241
|
android: {
|
|
222
242
|
connect(options?: MobileAndroidConnectOptions): Promise<MobileAndroidDevice>;
|
|
223
243
|
};
|
|
244
|
+
ios: {
|
|
245
|
+
connect(options?: MobileIosConnectOptions): Promise<MobileIosDevice>;
|
|
246
|
+
};
|
|
224
247
|
}
|
|
225
248
|
export interface Locator extends WebLocators {
|
|
226
249
|
inputValue(options?: CommandOptions): Promise<string>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allwright.dev/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
4
4
|
"description": "High-level TypeScript client for the allwright automation engine.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"build": "tsc -p tsconfig.json",
|
|
40
40
|
"example:web": "bun run examples/web-basic.ts",
|
|
41
41
|
"example:android": "bun run examples/android-basic.ts",
|
|
42
|
+
"example:ios": "bun run examples/ios-basic.ts",
|
|
42
43
|
"prepublishOnly": "bun run build"
|
|
43
44
|
},
|
|
44
45
|
"dependencies": {
|