@allwright.dev/core 0.1.0 → 0.1.2

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 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.0";
15
+ const DEFAULT_RELEASE_VERSION = "0.1.2";
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, ResolveConfigOptions, ResolvedAllwrightConfig } from "./types.js";
7
7
  export { findConfigFile, loadConfigFile, resolveConfig, setServerAddr, shutdown };
8
- export type { AllwrightConfig, Browser, BrowserInfo, BrowserKind, BrowserType, 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 { AccessibilitySnapshotOptions, AllwrightConfig, Browser, BrowserInfo, BrowserKind, BrowserType, 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";
9
9
  export declare const chromium: BrowserType;
10
10
  export declare const firefox: BrowserType;
11
11
  export { mobile };
package/dist/page.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ClickResult, CommandOptions, CountResult, ElementResult, FillResult, HighlightOptions, HighlightResult, Locator, NavigateResult, Page, PageInfo, PressOptions, PressResult, RuntimeClient, ScreenshotOptions, ScreenshotResult, TextResult, WaitForSelectorOptions, WaitForSelectorResult } from "./types.js";
1
+ import type { AccessibilitySnapshotOptions, ClickResult, CommandOptions, CountResult, ElementResult, FillResult, HighlightOptions, HighlightResult, Locator, NavigateResult, Page, PageInfo, PressOptions, PressResult, RuntimeClient, ScreenshotOptions, ScreenshotResult, TextResult, WaitForSelectorOptions, WaitForSelectorResult } from "./types.js";
2
2
  export declare class PageImpl implements Page {
3
3
  #private;
4
4
  constructor(input: PageInfo & {
@@ -18,6 +18,7 @@ export declare class PageImpl implements Page {
18
18
  textContent(selector: string, options?: CommandOptions): Promise<TextResult>;
19
19
  innerText(selector: string, options?: CommandOptions): Promise<TextResult>;
20
20
  waitForSelector(selector: string, options?: WaitForSelectorOptions): Promise<WaitForSelectorResult>;
21
+ accessibilitySnapshot(options?: AccessibilitySnapshotOptions): Promise<string>;
21
22
  screenshot(options?: ScreenshotOptions): Promise<ScreenshotResult>;
22
23
  close(): Promise<void>;
23
24
  ping(message?: string): Promise<string>;
package/dist/page.js CHANGED
@@ -305,6 +305,38 @@ export class PageImpl {
305
305
  }
306
306
  }
307
307
  }
308
+ async accessibilitySnapshot(options = {}) {
309
+ const mode = options.mode ?? "default";
310
+ if (!["default", "ai", "autoexpect", "codegen"].includes(mode)) {
311
+ throw new Error("invalid accessibility snapshot mode");
312
+ }
313
+ const format = options.format ?? "json";
314
+ if (format !== "json" && format !== "yaml") {
315
+ throw new Error("accessibility snapshot format must be 'json' or 'yaml'");
316
+ }
317
+ const handle = await this.#getHandle();
318
+ this.#ensureOpen(handle);
319
+ handle.stream.write({
320
+ surfaceSessionId: this.browserSessionId,
321
+ contextSessionId: this.sessionId,
322
+ accessibilitySnapshot: {
323
+ format,
324
+ mode,
325
+ retryOptions: options.timeoutMs ? { timeoutMs: options.timeoutMs } : undefined,
326
+ },
327
+ });
328
+ while (true) {
329
+ const event = await handle.queue.next();
330
+ if (event.accessibilitySnapshotCaptured)
331
+ return event.accessibilitySnapshotCaptured.snapshot ?? "";
332
+ if (event.error?.message)
333
+ throw formatActionError("accessibility snapshot", event.error.message);
334
+ if (event.closed) {
335
+ handle.closed = true;
336
+ throw new Error(`page session ${this.sessionId} closed while waiting for accessibility snapshot`);
337
+ }
338
+ }
339
+ }
308
340
  async screenshot(options = {}) {
309
341
  const handle = await this.#getHandle();
310
342
  this.#ensureOpen(handle);
package/dist/types.d.ts CHANGED
@@ -8,6 +8,10 @@ export type BrowserKind = "chromium" | "firefox";
8
8
  export interface CommandOptions {
9
9
  timeoutMs?: number;
10
10
  }
11
+ export interface AccessibilitySnapshotOptions extends CommandOptions {
12
+ format?: "json" | "yaml";
13
+ mode?: "default" | "ai" | "autoexpect" | "codegen";
14
+ }
11
15
  export interface NavigateResult {
12
16
  url: string;
13
17
  note: string;
@@ -105,6 +109,7 @@ export interface Browser extends BrowserInfo {
105
109
  browserInfo(): BrowserInfo;
106
110
  }
107
111
  export interface Page extends PageInfo {
112
+ accessibilitySnapshot(options?: AccessibilitySnapshotOptions): Promise<string>;
108
113
  locator(selector: string): Locator;
109
114
  goto(url: string, options?: CommandOptions): Promise<NavigateResult>;
110
115
  navigate(url: string, options?: CommandOptions): Promise<NavigateResult>;
@@ -337,6 +342,10 @@ export interface SurfaceSessionEvent {
337
342
  };
338
343
  }
339
344
  export interface ContextSessionEvent {
345
+ accessibilitySnapshotCaptured?: {
346
+ snapshot?: string;
347
+ format?: string;
348
+ };
340
349
  contextSessionId?: string;
341
350
  event?: string;
342
351
  attached?: {
@@ -591,6 +600,17 @@ export interface WaitForSelectorRequest {
591
600
  };
592
601
  };
593
602
  }
603
+ export interface AccessibilitySnapshotRequest {
604
+ surfaceSessionId: string;
605
+ contextSessionId: string;
606
+ accessibilitySnapshot: {
607
+ format: string;
608
+ mode: string;
609
+ retryOptions?: {
610
+ timeoutMs?: number;
611
+ };
612
+ };
613
+ }
594
614
  export interface ScreenshotRequest {
595
615
  surfaceSessionId: string;
596
616
  contextSessionId: string;
@@ -607,7 +627,7 @@ export interface CloseContextRequest {
607
627
  close: Record<string, never>;
608
628
  }
609
629
  export type SurfaceSessionRequest = LaunchBrowserRequest | LaunchChromeRequest | OpenContextRequest | ConnectMobileRequest | LaunchAppRequest | SurfacePingRequest | CloseSurfaceRequest;
610
- export type ContextSessionRequest = ContextPingRequest | NavigateRequest | ClickRequest | CountRequest | HighlightRequest | FocusRequest | FillRequest | HoverRequest | PressRequest | TextContentRequest | InnerTextRequest | WaitForSelectorRequest | ScreenshotRequest | CloseContextRequest;
630
+ export type ContextSessionRequest = ContextPingRequest | NavigateRequest | ClickRequest | CountRequest | HighlightRequest | FocusRequest | FillRequest | HoverRequest | PressRequest | TextContentRequest | InnerTextRequest | WaitForSelectorRequest | AccessibilitySnapshotRequest | ScreenshotRequest | CloseContextRequest;
611
631
  export type SurfaceSessionStream = grpc.ClientDuplexStream<SurfaceSessionRequest, SurfaceSessionEvent>;
612
632
  export type ContextSessionStream = grpc.ClientDuplexStream<ContextSessionRequest, ContextSessionEvent>;
613
633
  export interface EngineServiceClientShape {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allwright.dev/core",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "High-level TypeScript client for the allwright automation engine.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -2,8 +2,11 @@ syntax = "proto3";
2
2
 
3
3
  package allwright.engine.v1;
4
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;
5
7
 
6
8
  import "core/v1/common.proto";
9
+ import "surfaces/web/v1/web.proto";
7
10
 
8
11
  message ContextSessionCommand {
9
12
  string surface_session_id = 1;
@@ -24,6 +27,7 @@ message ContextSessionCommand {
24
27
  GetInnerTextCommand get_inner_text = 14;
25
28
  WaitForSelectorCommand wait_for_selector = 15;
26
29
  ScreenshotCommand screenshot = 16;
30
+ AccessibilitySnapshotCommand accessibility_snapshot = 17;
27
31
  }
28
32
  }
29
33
 
@@ -54,6 +58,7 @@ message ContextSessionEvent {
54
58
  InnerTextResolvedEvent inner_text_resolved = 16;
55
59
  SelectorWaitSatisfiedEvent selector_wait_satisfied = 17;
56
60
  ScreenshotCapturedEvent screenshot_captured = 18;
61
+ AccessibilitySnapshotCapturedEvent accessibility_snapshot_captured = 19;
57
62
  }
58
63
  }
59
64
 
@@ -2,6 +2,8 @@ syntax = "proto3";
2
2
 
3
3
  package allwright.engine.v1;
4
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;
5
7
 
6
8
  import "core/v1/common.proto";
7
9
 
@@ -37,3 +39,18 @@ message ChromeLaunchedEvent {
37
39
  string user_data_dir = 4;
38
40
  string initial_page_session_id = 5;
39
41
  }
42
+
43
+ // Empty format defaults to JSON. Accepted values are "json" and "yaml".
44
+ message AccessibilitySnapshotCommand {
45
+ // Empty mode defaults to default. AI injects queryable aria-ref attributes.
46
+ // Supported: default, ai, autoexpect, codegen.
47
+ string mode = 3;
48
+ string format = 1;
49
+ optional CommandRetryOptions retry_options = 2;
50
+ }
51
+
52
+ // Both formats encode the same versioned, structured document.
53
+ message AccessibilitySnapshotCapturedEvent {
54
+ string snapshot = 1;
55
+ string format = 2;
56
+ }