@allwright.dev/core 0.0.54 → 0.0.57

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.0.54";
15
+ const DEFAULT_RELEASE_VERSION = "0.0.57";
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, ScreenshotResult, TextResult, WaitForSelectorOptions, WaitForSelectorResult, } from "./types.js";
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";
9
9
  export declare const chromium: BrowserType;
10
10
  export declare const firefox: BrowserType;
11
11
  export { mobile };
package/dist/mobile.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { createBrowserSessionHandle, createPageHandle, getRuntime } from "./runtime.js";
2
+ import { writeFile } from "node:fs/promises";
2
3
  import { chainMobileSelectorForTransport, normalizeMobileSelectorForTransport } from "./mobileSelectors.js";
3
4
  function retryOptions(timeoutMs) {
4
5
  return timeoutMs ? { timeoutMs } : undefined;
@@ -45,6 +46,63 @@ class MobileAndroidAppImpl {
45
46
  }
46
47
  }
47
48
  }
49
+ async count(selector, options = {}) {
50
+ const handle = await this.#getHandle();
51
+ this.#ensureOpen(handle);
52
+ handle.stream.write({
53
+ surfaceSessionId: this.#surfaceSessionId,
54
+ contextSessionId: this.sessionId,
55
+ countElements: {
56
+ cssSelector: normalizeMobileSelectorForTransport(selector),
57
+ retryOptions: retryOptions(options.timeoutMs),
58
+ },
59
+ });
60
+ while (true) {
61
+ const event = await handle.queue.next();
62
+ if (event.elementCounted) {
63
+ return {
64
+ selector: event.elementCounted.cssSelector ?? "",
65
+ count: event.elementCounted.count ?? 0,
66
+ note: event.elementCounted.note ?? "",
67
+ };
68
+ }
69
+ if (event.error?.message) {
70
+ throw new Error(event.error.message);
71
+ }
72
+ if (event.closed) {
73
+ handle.closed = true;
74
+ throw new Error(`android app session ${this.sessionId} closed while counting elements`);
75
+ }
76
+ }
77
+ }
78
+ async focus(selector, options = {}) {
79
+ const handle = await this.#getHandle();
80
+ this.#ensureOpen(handle);
81
+ handle.stream.write({
82
+ surfaceSessionId: this.#surfaceSessionId,
83
+ contextSessionId: this.sessionId,
84
+ focusElement: {
85
+ cssSelector: normalizeMobileSelectorForTransport(selector),
86
+ retryOptions: retryOptions(options.timeoutMs),
87
+ },
88
+ });
89
+ while (true) {
90
+ const event = await handle.queue.next();
91
+ if (event.elementFocused) {
92
+ return {
93
+ selector: event.elementFocused.cssSelector ?? "",
94
+ note: event.elementFocused.note ?? "",
95
+ };
96
+ }
97
+ if (event.error?.message) {
98
+ throw new Error(event.error.message);
99
+ }
100
+ if (event.closed) {
101
+ handle.closed = true;
102
+ throw new Error(`android app session ${this.sessionId} closed while focusing`);
103
+ }
104
+ }
105
+ }
48
106
  async fill(selector, value, options = {}) {
49
107
  const handle = await this.#getHandle();
50
108
  this.#ensureOpen(handle);
@@ -75,6 +133,73 @@ class MobileAndroidAppImpl {
75
133
  }
76
134
  }
77
135
  }
136
+ async press(selector, key, options = {}) {
137
+ const handle = await this.#getHandle();
138
+ this.#ensureOpen(handle);
139
+ handle.stream.write({
140
+ surfaceSessionId: this.#surfaceSessionId,
141
+ contextSessionId: this.sessionId,
142
+ pressKey: {
143
+ cssSelector: normalizeMobileSelectorForTransport(selector),
144
+ key,
145
+ text: options.text,
146
+ retryOptions: retryOptions(options.timeoutMs),
147
+ },
148
+ });
149
+ while (true) {
150
+ const event = await handle.queue.next();
151
+ if (event.keyPressed) {
152
+ return {
153
+ selector: event.keyPressed.cssSelector ?? "",
154
+ key: event.keyPressed.key ?? "",
155
+ note: event.keyPressed.note ?? "",
156
+ };
157
+ }
158
+ if (event.error?.message) {
159
+ throw new Error(event.error.message);
160
+ }
161
+ if (event.closed) {
162
+ handle.closed = true;
163
+ throw new Error(`android app session ${this.sessionId} closed while pressing key`);
164
+ }
165
+ }
166
+ }
167
+ async textContent(selector, options = {}) {
168
+ return this.#readText(selector, options, true);
169
+ }
170
+ async innerText(selector, options = {}) {
171
+ return this.#readText(selector, options, false);
172
+ }
173
+ async waitForSelector(selector, options = {}) {
174
+ const handle = await this.#getHandle();
175
+ this.#ensureOpen(handle);
176
+ handle.stream.write({
177
+ surfaceSessionId: this.#surfaceSessionId,
178
+ contextSessionId: this.sessionId,
179
+ waitForSelector: {
180
+ cssSelector: normalizeMobileSelectorForTransport(selector),
181
+ visible: options.visible,
182
+ retryOptions: retryOptions(options.timeoutMs),
183
+ },
184
+ });
185
+ while (true) {
186
+ const event = await handle.queue.next();
187
+ if (event.selectorWaitSatisfied) {
188
+ return {
189
+ selector: event.selectorWaitSatisfied.cssSelector ?? "",
190
+ visible: event.selectorWaitSatisfied.visible ?? false,
191
+ note: event.selectorWaitSatisfied.note ?? "",
192
+ };
193
+ }
194
+ if (event.error?.message) {
195
+ throw new Error(event.error.message);
196
+ }
197
+ if (event.closed) {
198
+ handle.closed = true;
199
+ throw new Error(`android app session ${this.sessionId} closed while waiting for selector`);
200
+ }
201
+ }
202
+ }
78
203
  async screenshot(options = {}) {
79
204
  const handle = await this.#getHandle();
80
205
  this.#ensureOpen(handle);
@@ -83,15 +208,20 @@ class MobileAndroidAppImpl {
83
208
  contextSessionId: this.sessionId,
84
209
  screenshot: {
85
210
  retryOptions: retryOptions(options.timeoutMs),
211
+ fullPage: options.fullPage,
86
212
  },
87
213
  });
88
214
  while (true) {
89
215
  const event = await handle.queue.next();
90
216
  if (event.screenshotCaptured?.pngData) {
91
- return {
217
+ const screenshot = {
92
218
  pngData: event.screenshotCaptured.pngData,
93
219
  note: event.screenshotCaptured.note ?? "",
94
220
  };
221
+ if (options.path) {
222
+ await writeFile(options.path, screenshot.pngData);
223
+ }
224
+ return screenshot;
95
225
  }
96
226
  if (event.error?.message) {
97
227
  throw new Error(event.error.message);
@@ -113,6 +243,52 @@ class MobileAndroidAppImpl {
113
243
  throw new Error(`android app session ${this.sessionId} is closed`);
114
244
  }
115
245
  }
246
+ async #readText(selector, options, textContent) {
247
+ const handle = await this.#getHandle();
248
+ this.#ensureOpen(handle);
249
+ const transportSelector = normalizeMobileSelectorForTransport(selector);
250
+ handle.stream.write(textContent
251
+ ? {
252
+ surfaceSessionId: this.#surfaceSessionId,
253
+ contextSessionId: this.sessionId,
254
+ getTextContent: {
255
+ cssSelector: transportSelector,
256
+ retryOptions: retryOptions(options.timeoutMs),
257
+ },
258
+ }
259
+ : {
260
+ surfaceSessionId: this.#surfaceSessionId,
261
+ contextSessionId: this.sessionId,
262
+ getInnerText: {
263
+ cssSelector: transportSelector,
264
+ retryOptions: retryOptions(options.timeoutMs),
265
+ },
266
+ });
267
+ while (true) {
268
+ const event = await handle.queue.next();
269
+ if (event.textContentResolved) {
270
+ return {
271
+ selector: event.textContentResolved.cssSelector ?? "",
272
+ text: event.textContentResolved.text ?? "",
273
+ note: event.textContentResolved.note ?? "",
274
+ };
275
+ }
276
+ if (event.innerTextResolved) {
277
+ return {
278
+ selector: event.innerTextResolved.cssSelector ?? "",
279
+ text: event.innerTextResolved.text ?? "",
280
+ note: event.innerTextResolved.note ?? "",
281
+ };
282
+ }
283
+ if (event.error?.message) {
284
+ throw new Error(event.error.message);
285
+ }
286
+ if (event.closed) {
287
+ handle.closed = true;
288
+ throw new Error(`android app session ${this.sessionId} closed while reading text`);
289
+ }
290
+ }
291
+ }
116
292
  }
117
293
  class MobileAndroidLocatorImpl {
118
294
  page;
@@ -127,6 +303,24 @@ class MobileAndroidLocatorImpl {
127
303
  async fill(value, options = {}) {
128
304
  return this.page.fill(this.selector, value, options);
129
305
  }
306
+ async count(options = {}) {
307
+ return this.page.count(this.selector, options);
308
+ }
309
+ async focus(options = {}) {
310
+ return this.page.focus(this.selector, options);
311
+ }
312
+ async press(key, options = {}) {
313
+ return this.page.press(this.selector, key, options);
314
+ }
315
+ async textContent(options = {}) {
316
+ return this.page.textContent(this.selector, options);
317
+ }
318
+ async innerText(options = {}) {
319
+ return this.page.innerText(this.selector, options);
320
+ }
321
+ async waitFor(options = {}) {
322
+ return this.page.waitForSelector(this.selector, options);
323
+ }
130
324
  locator(selector) {
131
325
  return new MobileAndroidLocatorImpl(this.page, chainMobileSelectorForTransport(this.selector, selector));
132
326
  }
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, ScreenshotResult, TextResult, WaitForSelectorOptions, WaitForSelectorResult } from "./types.js";
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";
2
2
  export declare class PageImpl implements Page {
3
3
  #private;
4
4
  constructor(input: PageInfo & {
@@ -18,7 +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
- screenshot(options?: CommandOptions): Promise<ScreenshotResult>;
21
+ screenshot(options?: ScreenshotOptions): Promise<ScreenshotResult>;
22
22
  close(): Promise<void>;
23
23
  ping(message?: string): Promise<string>;
24
24
  pageInfo(): PageInfo;
package/dist/page.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { LocatorImpl } from "./locator.js";
2
+ import { writeFile } from "node:fs/promises";
2
3
  import { formatActionError } from "./errors.js";
3
4
  import { normalizeSelectorForTransport } from "./selectors.js";
4
5
  import { createPageHandle } from "./runtime.js";
@@ -312,15 +313,20 @@ export class PageImpl {
312
313
  contextSessionId: this.sessionId,
313
314
  screenshot: {
314
315
  retryOptions: options.timeoutMs ? { timeoutMs: options.timeoutMs } : undefined,
316
+ fullPage: options.fullPage,
315
317
  },
316
318
  });
317
319
  while (true) {
318
320
  const event = await handle.queue.next();
319
321
  if (event.screenshotCaptured?.pngData) {
320
- return {
322
+ const screenshot = {
321
323
  pngData: event.screenshotCaptured.pngData,
322
324
  note: event.screenshotCaptured.note ?? "",
323
325
  };
326
+ if (options.path) {
327
+ await writeFile(options.path, screenshot.pngData);
328
+ }
329
+ return screenshot;
324
330
  }
325
331
  if (event.error?.message) {
326
332
  throw formatActionError("screenshot", event.error.message);
package/dist/types.d.ts CHANGED
@@ -71,6 +71,10 @@ export interface ScreenshotResult {
71
71
  pngData: Uint8Array;
72
72
  note: string;
73
73
  }
74
+ export interface ScreenshotOptions extends CommandOptions {
75
+ fullPage?: boolean;
76
+ path?: string;
77
+ }
74
78
  export interface BrowserInfo {
75
79
  sessionId: string;
76
80
  browserName: string;
@@ -114,7 +118,7 @@ export interface Page extends PageInfo {
114
118
  textContent(selector: string, options?: CommandOptions): Promise<TextResult>;
115
119
  innerText(selector: string, options?: CommandOptions): Promise<TextResult>;
116
120
  waitForSelector(selector: string, options?: WaitForSelectorOptions): Promise<WaitForSelectorResult>;
117
- screenshot(options?: CommandOptions): Promise<ScreenshotResult>;
121
+ screenshot(options?: ScreenshotOptions): Promise<ScreenshotResult>;
118
122
  close(): Promise<void>;
119
123
  ping(message?: string): Promise<string>;
120
124
  pageInfo(): PageInfo;
@@ -136,15 +140,27 @@ export interface MobileAndroidLocator {
136
140
  readonly page: MobileAndroidApp;
137
141
  readonly selector: string;
138
142
  click(options?: CommandOptions): Promise<ClickResult>;
143
+ count(options?: CommandOptions): Promise<CountResult>;
144
+ focus(options?: CommandOptions): Promise<ElementResult>;
139
145
  fill(value: string, options?: CommandOptions): Promise<FillResult>;
146
+ press(key: string, options?: PressOptions): Promise<PressResult>;
147
+ textContent(options?: CommandOptions): Promise<TextResult>;
148
+ innerText(options?: CommandOptions): Promise<TextResult>;
149
+ waitFor(options?: WaitForSelectorOptions): Promise<WaitForSelectorResult>;
140
150
  locator(selector: string): MobileAndroidLocator;
141
151
  }
142
152
  export interface MobileAndroidApp {
143
153
  readonly sessionId: string;
144
154
  locator(selector: string): MobileAndroidLocator;
145
155
  click(selector: string, options?: CommandOptions): Promise<ClickResult>;
156
+ count(selector: string, options?: CommandOptions): Promise<CountResult>;
157
+ focus(selector: string, options?: CommandOptions): Promise<ElementResult>;
146
158
  fill(selector: string, value: string, options?: CommandOptions): Promise<FillResult>;
147
- screenshot(options?: CommandOptions): Promise<ScreenshotResult>;
159
+ press(selector: string, key: string, options?: PressOptions): Promise<PressResult>;
160
+ textContent(selector: string, options?: CommandOptions): Promise<TextResult>;
161
+ innerText(selector: string, options?: CommandOptions): Promise<TextResult>;
162
+ waitForSelector(selector: string, options?: WaitForSelectorOptions): Promise<WaitForSelectorResult>;
163
+ screenshot(options?: ScreenshotOptions): Promise<ScreenshotResult>;
148
164
  }
149
165
  export interface MobileAndroidDevice {
150
166
  readonly sessionId: string;
@@ -582,6 +598,7 @@ export interface ScreenshotRequest {
582
598
  retryOptions?: {
583
599
  timeoutMs?: number;
584
600
  };
601
+ fullPage?: boolean;
585
602
  };
586
603
  }
587
604
  export interface CloseContextRequest {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allwright.dev/core",
3
- "version": "0.0.54",
3
+ "version": "0.0.57",
4
4
  "description": "High-level TypeScript client for the allwright automation engine.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -135,6 +135,7 @@ message WaitForSelectorCommand {
135
135
 
136
136
  message ScreenshotCommand {
137
137
  optional CommandRetryOptions retry_options = 1;
138
+ optional bool full_page = 2;
138
139
  }
139
140
 
140
141
  message PageNavigatedEvent {