@allwright.dev/core 0.1.20 → 0.1.22
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/README.md +1 -1
- package/dist/bootstrap.js +1 -1
- package/dist/desktop.d.ts +2 -0
- package/dist/desktop.js +73 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -0
- package/dist/mobile.d.ts +27 -1
- package/dist/mobile.js +1 -1
- package/dist/types.d.ts +53 -1
- package/package.json +1 -1
- package/proto/core/v1/surface.proto +5 -0
- package/proto/surfaces/desktop/v1/desktop.proto +40 -0
package/README.md
CHANGED
|
@@ -51,7 +51,7 @@ Paths passed to `setFiles` and `saveAs` belong to the test process, even when
|
|
|
51
51
|
the Allwright server is remote. Android apps support the same `fileChooser` and
|
|
52
52
|
`download` hook shape; Android `newPage` hooks are not applicable.
|
|
53
53
|
|
|
54
|
-
Runnable examples live in [examples/web-basic.ts](./examples/web-basic.ts)
|
|
54
|
+
Runnable examples live in [examples/web-basic.ts](./examples/web-basic.ts), [examples/android-basic.ts](./examples/android-basic.ts), and [examples/ios-basic.ts](./examples/ios-basic.ts).
|
|
55
55
|
|
|
56
56
|
Shared config files are stack-agnostic and can live in `allwright.config.yaml` or `allwright.config.json`.
|
|
57
57
|
The shared schema lives at the repo root in `allwright.schema.json`.
|
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.22";
|
|
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/desktop.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { createBrowserSessionHandle, getRuntime } from "./runtime.js";
|
|
2
|
+
import { MobileAndroidAppImpl } from "./mobile.js";
|
|
3
|
+
function retryOptions(timeoutMs) {
|
|
4
|
+
return timeoutMs === undefined ? undefined : { timeoutMs };
|
|
5
|
+
}
|
|
6
|
+
class DesktopMacImpl {
|
|
7
|
+
sessionId;
|
|
8
|
+
surfaceSessionId;
|
|
9
|
+
runtime;
|
|
10
|
+
stream;
|
|
11
|
+
queue;
|
|
12
|
+
#closed = false;
|
|
13
|
+
#currentApp;
|
|
14
|
+
constructor(sessionId, surfaceSessionId, runtime, stream, queue, initialAppSessionId) {
|
|
15
|
+
this.sessionId = sessionId;
|
|
16
|
+
this.surfaceSessionId = surfaceSessionId;
|
|
17
|
+
this.runtime = runtime;
|
|
18
|
+
this.stream = stream;
|
|
19
|
+
this.queue = queue;
|
|
20
|
+
this.#currentApp = new MobileAndroidAppImpl(runtime, surfaceSessionId, initialAppSessionId);
|
|
21
|
+
}
|
|
22
|
+
app() {
|
|
23
|
+
return this.#currentApp;
|
|
24
|
+
}
|
|
25
|
+
async launch(options) {
|
|
26
|
+
if (this.#closed)
|
|
27
|
+
throw new Error(`macOS desktop session ${this.sessionId} is closed`);
|
|
28
|
+
this.stream.write({
|
|
29
|
+
launchDesktopApp: {
|
|
30
|
+
appId: options.appId,
|
|
31
|
+
terminateRunning: options.terminateRunning ?? false,
|
|
32
|
+
retryOptions: retryOptions(options.timeoutMs),
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
while (true) {
|
|
36
|
+
const event = await this.queue.next();
|
|
37
|
+
if (event.desktopAppLaunched?.appSessionId) {
|
|
38
|
+
this.#currentApp = new MobileAndroidAppImpl(this.runtime, this.surfaceSessionId, event.desktopAppLaunched.appSessionId);
|
|
39
|
+
return this.#currentApp;
|
|
40
|
+
}
|
|
41
|
+
if (event.error?.message)
|
|
42
|
+
throw new Error(event.error.message);
|
|
43
|
+
if (event.closed) {
|
|
44
|
+
this.#closed = true;
|
|
45
|
+
throw new Error(`macOS desktop session ${this.sessionId} closed while launching app`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
class DesktopMacSurfaceImpl {
|
|
51
|
+
async connect(options = {}) {
|
|
52
|
+
const runtime = await getRuntime();
|
|
53
|
+
const { stream, queue } = await createBrowserSessionHandle(runtime);
|
|
54
|
+
stream.write({
|
|
55
|
+
connectDesktop: {
|
|
56
|
+
platform: 1,
|
|
57
|
+
agentEndpoint: options.agentEndpoint,
|
|
58
|
+
retryOptions: retryOptions(options.timeoutMs),
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
while (true) {
|
|
62
|
+
const event = await queue.next();
|
|
63
|
+
if (event.desktopConnected?.initialAppSessionId) {
|
|
64
|
+
return new DesktopMacImpl(event.desktopConnected.desktopSessionId ?? event.sessionId ?? "", event.sessionId ?? "", runtime, stream, queue, event.desktopConnected.initialAppSessionId);
|
|
65
|
+
}
|
|
66
|
+
if (event.error?.message)
|
|
67
|
+
throw new Error(event.error.message);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
export const desktop = {
|
|
72
|
+
mac: new DesktopMacSurfaceImpl(),
|
|
73
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { BrowserImpl, BrowserTypeImpl } from "./browser.js";
|
|
2
2
|
import { findConfigFile, loadConfigFile, resolveConfig } from "./config.js";
|
|
3
3
|
import { mobile } from "./mobile.js";
|
|
4
|
+
import { desktop } from "./desktop.js";
|
|
4
5
|
import { PageImpl } from "./page.js";
|
|
5
6
|
import { setServerAddr, shutdown } from "./runtime.js";
|
|
6
7
|
import type { Browser, BrowserKind, BrowserType, LaunchOptions, Page, Dialog, FileChooser, Download, HookType, ResolveConfigOptions, ResolvedAllwrightConfig } from "./types.js";
|
|
7
8
|
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, 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
|
+
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, DesktopMacApp, DesktopMacConnectOptions, DesktopMacDesktop, DesktopMacLaunchOptions, DesktopMacLocator, DesktopSurfaceNamespace, NavigateResult, Page, PageInfo, PressOptions, PressResult, ResolveConfigOptions, ResolvedAllwrightConfig, RetryConfig, ScreenshotOptions, ScreenshotResult, TextResult, WaitForSelectorOptions, WaitForSelectorResult, } from "./types.js";
|
|
9
10
|
export declare const chromium: BrowserType;
|
|
10
11
|
export declare const firefox: BrowserType;
|
|
11
12
|
export declare const hooks: {
|
|
@@ -15,6 +16,7 @@ export declare const hooks: {
|
|
|
15
16
|
download: HookType<Download>;
|
|
16
17
|
};
|
|
17
18
|
export { mobile };
|
|
19
|
+
export { desktop };
|
|
18
20
|
export type Tab = Page;
|
|
19
21
|
export declare function ping(): Promise<string>;
|
|
20
22
|
export declare function launchChrome(options?: LaunchOptions): Promise<Browser>;
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { BrowserImpl, BrowserTypeImpl } from "./browser.js";
|
|
|
2
2
|
import { formatActionError } from "./errors.js";
|
|
3
3
|
import { findConfigFile, loadConfigFile, resolveConfig } from "./config.js";
|
|
4
4
|
import { mobile } from "./mobile.js";
|
|
5
|
+
import { desktop } from "./desktop.js";
|
|
5
6
|
import { PageImpl } from "./page.js";
|
|
6
7
|
import { createBrowserSessionHandle, getRuntime, launchConfiguredBrowser as launchConfiguredBrowserWithResolver, ping as runtimePing, resolveLaunchBrowserArgs, setServerAddr, shutdown, } from "./runtime.js";
|
|
7
8
|
export { findConfigFile, loadConfigFile, resolveConfig, setServerAddr, shutdown };
|
|
@@ -14,6 +15,7 @@ export const hooks = {
|
|
|
14
15
|
download: Object.freeze({ name: "download" }),
|
|
15
16
|
};
|
|
16
17
|
export { mobile };
|
|
18
|
+
export { desktop };
|
|
17
19
|
export async function ping() {
|
|
18
20
|
return runtimePing();
|
|
19
21
|
}
|
package/dist/mobile.d.ts
CHANGED
|
@@ -1,2 +1,28 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type RoleOptions, type TextMatcher, type TextOptions } from "./web-locators.js";
|
|
2
|
+
import type { AccessibilitySnapshotOptions, CommandOptions, Hook, HookType, MobileAndroidLocator, MobileAndroidApp, MobileSurfaceNamespace, PressOptions, RuntimeClient, ScreenshotOptions, WaitForSelectorOptions } from "./types.js";
|
|
3
|
+
export declare class MobileAndroidAppImpl implements MobileAndroidApp {
|
|
4
|
+
#private;
|
|
5
|
+
readonly sessionId: string;
|
|
6
|
+
constructor(runtime: RuntimeClient, surfaceSessionId: string, sessionId: string);
|
|
7
|
+
locator(selector: string): MobileAndroidLocator;
|
|
8
|
+
getByRole(role: string, options?: RoleOptions): MobileAndroidLocator;
|
|
9
|
+
getByText(text: TextMatcher, options?: TextOptions): MobileAndroidLocator;
|
|
10
|
+
getByLabel(text: TextMatcher, options?: TextOptions): MobileAndroidLocator;
|
|
11
|
+
getByTestId(text: TextMatcher): MobileAndroidLocator;
|
|
12
|
+
registerHook<T>(type: HookType<T>): Promise<Hook<T>>;
|
|
13
|
+
setChooserFiles(fileChooserId: string, files: string[], options: CommandOptions): Promise<void>;
|
|
14
|
+
saveMobileDownload(downloadId: string, path: string, options: CommandOptions): Promise<void>;
|
|
15
|
+
click(selector: string, options?: CommandOptions): Promise<void>;
|
|
16
|
+
goto(url: string, options?: CommandOptions): Promise<void>;
|
|
17
|
+
navigate(url: string, options?: CommandOptions): Promise<void>;
|
|
18
|
+
count(selector: string, options?: CommandOptions): Promise<number>;
|
|
19
|
+
focus(selector: string, options?: CommandOptions): Promise<void>;
|
|
20
|
+
fill(selector: string, value: string, options?: CommandOptions): Promise<void>;
|
|
21
|
+
press(selector: string, key: string, options?: PressOptions): Promise<void>;
|
|
22
|
+
textContent(selector: string, options?: CommandOptions): Promise<string | null>;
|
|
23
|
+
innerText(selector: string, options?: CommandOptions): Promise<string>;
|
|
24
|
+
waitForSelector(selector: string, options?: WaitForSelectorOptions): Promise<void>;
|
|
25
|
+
accessibilitySnapshot(options?: AccessibilitySnapshotOptions): Promise<string>;
|
|
26
|
+
screenshot(options?: ScreenshotOptions): Promise<Uint8Array>;
|
|
27
|
+
}
|
|
2
28
|
export declare const mobile: MobileSurfaceNamespace;
|
package/dist/mobile.js
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -255,6 +255,27 @@ export interface MobileSurfaceNamespace {
|
|
|
255
255
|
connect(options?: MobileIosConnectOptions): Promise<MobileIosDevice>;
|
|
256
256
|
};
|
|
257
257
|
}
|
|
258
|
+
export interface DesktopMacConnectOptions {
|
|
259
|
+
agentEndpoint?: string;
|
|
260
|
+
timeoutMs?: number;
|
|
261
|
+
}
|
|
262
|
+
export interface DesktopMacLaunchOptions {
|
|
263
|
+
appId: string;
|
|
264
|
+
terminateRunning?: boolean;
|
|
265
|
+
timeoutMs?: number;
|
|
266
|
+
}
|
|
267
|
+
export type DesktopMacApp = MobileAndroidApp;
|
|
268
|
+
export type DesktopMacLocator = MobileAndroidLocator;
|
|
269
|
+
export interface DesktopMacDesktop {
|
|
270
|
+
readonly sessionId: string;
|
|
271
|
+
app(): DesktopMacApp;
|
|
272
|
+
launch(options: DesktopMacLaunchOptions): Promise<DesktopMacApp>;
|
|
273
|
+
}
|
|
274
|
+
export interface DesktopSurfaceNamespace {
|
|
275
|
+
mac: {
|
|
276
|
+
connect(options?: DesktopMacConnectOptions): Promise<DesktopMacDesktop>;
|
|
277
|
+
};
|
|
278
|
+
}
|
|
258
279
|
export interface Locator extends WebLocators {
|
|
259
280
|
inputValue(options?: CommandOptions): Promise<string>;
|
|
260
281
|
selectedOptions(options?: CommandOptions): Promise<CapturedOption[]>;
|
|
@@ -417,6 +438,19 @@ export interface SurfaceSessionEvent {
|
|
|
417
438
|
activityName?: string;
|
|
418
439
|
webviewContext?: string;
|
|
419
440
|
};
|
|
441
|
+
desktopConnected?: {
|
|
442
|
+
platform?: number | string;
|
|
443
|
+
hostName?: string;
|
|
444
|
+
note?: string;
|
|
445
|
+
backend?: string;
|
|
446
|
+
desktopSessionId?: string;
|
|
447
|
+
initialAppSessionId?: string;
|
|
448
|
+
};
|
|
449
|
+
desktopAppLaunched?: {
|
|
450
|
+
appSessionId?: string;
|
|
451
|
+
appId?: string;
|
|
452
|
+
note?: string;
|
|
453
|
+
};
|
|
420
454
|
contextOpened?: {
|
|
421
455
|
contextSessionId?: string;
|
|
422
456
|
note?: string;
|
|
@@ -736,6 +770,24 @@ export interface LaunchAppRequest {
|
|
|
736
770
|
};
|
|
737
771
|
};
|
|
738
772
|
}
|
|
773
|
+
export interface ConnectDesktopRequest {
|
|
774
|
+
connectDesktop: {
|
|
775
|
+
platform: number;
|
|
776
|
+
agentEndpoint?: string;
|
|
777
|
+
retryOptions?: {
|
|
778
|
+
timeoutMs?: number;
|
|
779
|
+
};
|
|
780
|
+
};
|
|
781
|
+
}
|
|
782
|
+
export interface LaunchDesktopAppRequest {
|
|
783
|
+
launchDesktopApp: {
|
|
784
|
+
appId: string;
|
|
785
|
+
terminateRunning?: boolean;
|
|
786
|
+
retryOptions?: {
|
|
787
|
+
timeoutMs?: number;
|
|
788
|
+
};
|
|
789
|
+
};
|
|
790
|
+
}
|
|
739
791
|
export interface SurfacePingRequest {
|
|
740
792
|
ping: {
|
|
741
793
|
message: string;
|
|
@@ -892,7 +944,7 @@ export interface CloseContextRequest {
|
|
|
892
944
|
contextSessionId: string;
|
|
893
945
|
close: Record<string, never>;
|
|
894
946
|
}
|
|
895
|
-
export type SurfaceSessionRequest = LaunchBrowserRequest | LaunchChromeRequest | OpenContextRequest | ConnectMobileRequest | LaunchAppRequest | SurfacePingRequest | CloseSurfaceRequest;
|
|
947
|
+
export type SurfaceSessionRequest = LaunchBrowserRequest | LaunchChromeRequest | OpenContextRequest | ConnectMobileRequest | LaunchAppRequest | ConnectDesktopRequest | LaunchDesktopAppRequest | SurfacePingRequest | CloseSurfaceRequest;
|
|
896
948
|
export type ContextSessionRequest = {
|
|
897
949
|
surfaceSessionId: string;
|
|
898
950
|
contextSessionId: string;
|
package/package.json
CHANGED
|
@@ -6,6 +6,7 @@ option java_package = "dev.allwright.engine.v1";
|
|
|
6
6
|
option java_multiple_files = true;
|
|
7
7
|
|
|
8
8
|
import "core/v1/common.proto";
|
|
9
|
+
import "surfaces/desktop/v1/desktop.proto";
|
|
9
10
|
import "surfaces/mobile/v1/mobile.proto";
|
|
10
11
|
import "surfaces/web/v1/web.proto";
|
|
11
12
|
|
|
@@ -18,6 +19,8 @@ message SurfaceSessionCommand {
|
|
|
18
19
|
LaunchBrowserCommand launch_browser = 5;
|
|
19
20
|
ConnectMobileCommand connect_mobile = 6;
|
|
20
21
|
LaunchAppCommand launch_app = 7;
|
|
22
|
+
ConnectDesktopCommand connect_desktop = 8;
|
|
23
|
+
LaunchDesktopAppCommand launch_desktop_app = 9;
|
|
21
24
|
}
|
|
22
25
|
}
|
|
23
26
|
|
|
@@ -43,6 +46,8 @@ message SurfaceSessionEvent {
|
|
|
43
46
|
BrowserLaunchedEvent browser_launched = 7;
|
|
44
47
|
MobileConnectedEvent mobile_connected = 8;
|
|
45
48
|
AppLaunchedEvent app_launched = 9;
|
|
49
|
+
DesktopConnectedEvent desktop_connected = 10;
|
|
50
|
+
DesktopAppLaunchedEvent desktop_app_launched = 11;
|
|
46
51
|
}
|
|
47
52
|
}
|
|
48
53
|
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package allwright.engine.v1;
|
|
4
|
+
option go_package = "allwright.dev/gen/allwright/engine/v1;enginev1";
|
|
5
|
+
option java_package = "dev.allwright.engine.v1";
|
|
6
|
+
option java_multiple_files = true;
|
|
7
|
+
|
|
8
|
+
import "core/v1/common.proto";
|
|
9
|
+
|
|
10
|
+
enum DesktopPlatform {
|
|
11
|
+
DESKTOP_PLATFORM_UNSPECIFIED = 0;
|
|
12
|
+
DESKTOP_PLATFORM_MAC = 1;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
message ConnectDesktopCommand {
|
|
16
|
+
DesktopPlatform platform = 1;
|
|
17
|
+
optional string agent_endpoint = 2;
|
|
18
|
+
optional CommandRetryOptions retry_options = 3;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
message DesktopConnectedEvent {
|
|
22
|
+
DesktopPlatform platform = 1;
|
|
23
|
+
string host_name = 2;
|
|
24
|
+
string note = 3;
|
|
25
|
+
string backend = 4;
|
|
26
|
+
string desktop_session_id = 5;
|
|
27
|
+
string initial_app_session_id = 6;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
message LaunchDesktopAppCommand {
|
|
31
|
+
string app_id = 1;
|
|
32
|
+
bool terminate_running = 2;
|
|
33
|
+
optional CommandRetryOptions retry_options = 3;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
message DesktopAppLaunchedEvent {
|
|
37
|
+
string app_session_id = 1;
|
|
38
|
+
string app_id = 2;
|
|
39
|
+
string note = 3;
|
|
40
|
+
}
|