@allwright.dev/core 0.0.52 → 0.0.54

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/page.js CHANGED
@@ -19,8 +19,8 @@ export class PageImpl {
19
19
  const handle = await this.#getHandle();
20
20
  this.#ensureOpen(handle);
21
21
  handle.stream.write({
22
- browserSessionId: this.browserSessionId,
23
- tabSessionId: this.sessionId,
22
+ surfaceSessionId: this.browserSessionId,
23
+ contextSessionId: this.sessionId,
24
24
  navigate: {
25
25
  url,
26
26
  retryOptions: options.timeoutMs ? { timeoutMs: options.timeoutMs } : undefined,
@@ -60,8 +60,8 @@ export class PageImpl {
60
60
  this.#ensureOpen(handle);
61
61
  const transportSelector = normalizeSelectorForTransport(selector);
62
62
  handle.stream.write({
63
- browserSessionId: this.browserSessionId,
64
- tabSessionId: this.sessionId,
63
+ surfaceSessionId: this.browserSessionId,
64
+ contextSessionId: this.sessionId,
65
65
  clickElement: {
66
66
  cssSelector: transportSelector,
67
67
  retryOptions: options.timeoutMs ? { timeoutMs: options.timeoutMs } : undefined,
@@ -90,8 +90,8 @@ export class PageImpl {
90
90
  this.#ensureOpen(handle);
91
91
  const transportSelector = normalizeSelectorForTransport(selector);
92
92
  handle.stream.write({
93
- browserSessionId: this.browserSessionId,
94
- tabSessionId: this.sessionId,
93
+ surfaceSessionId: this.browserSessionId,
94
+ contextSessionId: this.sessionId,
95
95
  countElements: {
96
96
  cssSelector: transportSelector,
97
97
  retryOptions: options.timeoutMs ? { timeoutMs: options.timeoutMs } : undefined,
@@ -120,8 +120,8 @@ export class PageImpl {
120
120
  this.#ensureOpen(handle);
121
121
  const transportSelector = normalizeSelectorForTransport(selector);
122
122
  handle.stream.write({
123
- browserSessionId: this.browserSessionId,
124
- tabSessionId: this.sessionId,
123
+ surfaceSessionId: this.browserSessionId,
124
+ contextSessionId: this.sessionId,
125
125
  highlightElements: {
126
126
  cssSelector: transportSelector,
127
127
  durationMs: options.durationMs,
@@ -151,8 +151,8 @@ export class PageImpl {
151
151
  this.#ensureOpen(handle);
152
152
  const transportSelector = normalizeSelectorForTransport(selector);
153
153
  handle.stream.write({
154
- browserSessionId: this.browserSessionId,
155
- tabSessionId: this.sessionId,
154
+ surfaceSessionId: this.browserSessionId,
155
+ contextSessionId: this.sessionId,
156
156
  focusElement: {
157
157
  cssSelector: transportSelector,
158
158
  retryOptions: options.timeoutMs ? { timeoutMs: options.timeoutMs } : undefined,
@@ -180,8 +180,8 @@ export class PageImpl {
180
180
  this.#ensureOpen(handle);
181
181
  const transportSelector = normalizeSelectorForTransport(selector);
182
182
  handle.stream.write({
183
- browserSessionId: this.browserSessionId,
184
- tabSessionId: this.sessionId,
183
+ surfaceSessionId: this.browserSessionId,
184
+ contextSessionId: this.sessionId,
185
185
  fillElement: {
186
186
  cssSelector: transportSelector,
187
187
  value,
@@ -211,8 +211,8 @@ export class PageImpl {
211
211
  this.#ensureOpen(handle);
212
212
  const transportSelector = normalizeSelectorForTransport(selector);
213
213
  handle.stream.write({
214
- browserSessionId: this.browserSessionId,
215
- tabSessionId: this.sessionId,
214
+ surfaceSessionId: this.browserSessionId,
215
+ contextSessionId: this.sessionId,
216
216
  hoverElement: {
217
217
  cssSelector: transportSelector,
218
218
  retryOptions: options.timeoutMs ? { timeoutMs: options.timeoutMs } : undefined,
@@ -240,8 +240,8 @@ export class PageImpl {
240
240
  this.#ensureOpen(handle);
241
241
  const transportSelector = normalizeSelectorForTransport(selector);
242
242
  handle.stream.write({
243
- browserSessionId: this.browserSessionId,
244
- tabSessionId: this.sessionId,
243
+ surfaceSessionId: this.browserSessionId,
244
+ contextSessionId: this.sessionId,
245
245
  pressKey: {
246
246
  cssSelector: transportSelector,
247
247
  key,
@@ -278,8 +278,8 @@ export class PageImpl {
278
278
  this.#ensureOpen(handle);
279
279
  const transportSelector = normalizeSelectorForTransport(selector);
280
280
  handle.stream.write({
281
- browserSessionId: this.browserSessionId,
282
- tabSessionId: this.sessionId,
281
+ surfaceSessionId: this.browserSessionId,
282
+ contextSessionId: this.sessionId,
283
283
  waitForSelector: {
284
284
  cssSelector: transportSelector,
285
285
  visible: options.visible,
@@ -304,21 +304,48 @@ export class PageImpl {
304
304
  }
305
305
  }
306
306
  }
307
+ async screenshot(options = {}) {
308
+ const handle = await this.#getHandle();
309
+ this.#ensureOpen(handle);
310
+ handle.stream.write({
311
+ surfaceSessionId: this.browserSessionId,
312
+ contextSessionId: this.sessionId,
313
+ screenshot: {
314
+ retryOptions: options.timeoutMs ? { timeoutMs: options.timeoutMs } : undefined,
315
+ },
316
+ });
317
+ while (true) {
318
+ const event = await handle.queue.next();
319
+ if (event.screenshotCaptured?.pngData) {
320
+ return {
321
+ pngData: event.screenshotCaptured.pngData,
322
+ note: event.screenshotCaptured.note ?? "",
323
+ };
324
+ }
325
+ if (event.error?.message) {
326
+ throw formatActionError("screenshot", event.error.message);
327
+ }
328
+ if (event.closed) {
329
+ handle.closed = true;
330
+ throw new Error(`page session ${this.sessionId} closed while waiting for screenshot`);
331
+ }
332
+ }
333
+ }
307
334
  async close() {
308
335
  const handle = await this.#getHandle();
309
336
  if (handle.closed) {
310
337
  return;
311
338
  }
312
339
  handle.stream.write({
313
- browserSessionId: this.browserSessionId,
314
- tabSessionId: this.sessionId,
340
+ surfaceSessionId: this.browserSessionId,
341
+ contextSessionId: this.sessionId,
315
342
  close: {},
316
343
  });
317
344
  while (true) {
318
345
  const event = await handle.queue.next();
319
346
  if (event.closed) {
320
347
  handle.closed = true;
321
- handle.stream.end();
348
+ this.dispose();
322
349
  return;
323
350
  }
324
351
  if (event.error?.message) {
@@ -330,8 +357,8 @@ export class PageImpl {
330
357
  const handle = await this.#getHandle();
331
358
  this.#ensureOpen(handle);
332
359
  handle.stream.write({
333
- browserSessionId: this.browserSessionId,
334
- tabSessionId: this.sessionId,
360
+ surfaceSessionId: this.browserSessionId,
361
+ contextSessionId: this.sessionId,
335
362
  ping: {
336
363
  message,
337
364
  },
@@ -365,16 +392,16 @@ export class PageImpl {
365
392
  const transportSelector = normalizeSelectorForTransport(selector);
366
393
  handle.stream.write(textContent
367
394
  ? {
368
- browserSessionId: this.browserSessionId,
369
- tabSessionId: this.sessionId,
395
+ surfaceSessionId: this.browserSessionId,
396
+ contextSessionId: this.sessionId,
370
397
  getTextContent: {
371
398
  cssSelector: transportSelector,
372
399
  retryOptions: options.timeoutMs ? { timeoutMs: options.timeoutMs } : undefined,
373
400
  },
374
401
  }
375
402
  : {
376
- browserSessionId: this.browserSessionId,
377
- tabSessionId: this.sessionId,
403
+ surfaceSessionId: this.browserSessionId,
404
+ contextSessionId: this.sessionId,
378
405
  getInnerText: {
379
406
  cssSelector: transportSelector,
380
407
  retryOptions: options.timeoutMs ? { timeoutMs: options.timeoutMs } : undefined,
@@ -416,4 +443,28 @@ export class PageImpl {
416
443
  }
417
444
  return this.#handlePromise;
418
445
  }
446
+ dispose() {
447
+ const handlePromise = this.#handlePromise;
448
+ if (!handlePromise) {
449
+ return;
450
+ }
451
+ void handlePromise.then((handle) => {
452
+ if (handle.closed) {
453
+ return;
454
+ }
455
+ handle.closed = true;
456
+ try {
457
+ handle.stream.end();
458
+ }
459
+ catch {
460
+ // Best-effort local teardown during page disposal.
461
+ }
462
+ try {
463
+ handle.stream.cancel();
464
+ }
465
+ catch {
466
+ // grpc-js may reject cancel/end ordering depending on stream state.
467
+ }
468
+ });
469
+ }
419
470
  }
package/dist/runtime.d.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import { EventQueue } from "./types.js";
2
- import type { BrowserSessionEvent, BrowserSessionStream, Browser, BrowserKind, LaunchOptions, PageHandle, ResolveConfigOptions, ResolvedAllwrightConfig, RuntimeClient } from "./types.js";
2
+ import type { SurfaceSessionEvent, SurfaceSessionStream, Browser, BrowserKind, LaunchOptions, PageHandle, ResolveConfigOptions, ResolvedAllwrightConfig, RuntimeClient } from "./types.js";
3
3
  export declare function setServerAddr(serverAddr: string): void;
4
4
  export declare function shutdown(): Promise<void>;
5
5
  export declare function ping(): Promise<string>;
6
6
  export declare function getRuntime(): Promise<RuntimeClient>;
7
7
  export declare function createPageHandle(runtime: RuntimeClient): Promise<PageHandle>;
8
8
  export declare function createBrowserSessionHandle(runtime: RuntimeClient): Promise<{
9
- stream: BrowserSessionStream;
10
- queue: EventQueue<BrowserSessionEvent>;
9
+ stream: SurfaceSessionStream;
10
+ queue: EventQueue<SurfaceSessionEvent>;
11
11
  }>;
12
12
  export declare function launchConfiguredBrowser(config: ResolvedAllwrightConfig, launchBrowserKind: (browserKind: BrowserKind, options?: LaunchOptions) => Promise<Browser>): Promise<Browser>;
13
13
  export declare function normalizeServerAddr(raw: string): string;
package/dist/runtime.js CHANGED
@@ -20,6 +20,10 @@ export async function shutdown() {
20
20
  return;
21
21
  }
22
22
  const runtime = await runtimePromise;
23
+ for (const stream of runtime.openStreams ?? []) {
24
+ closeTrackedStream(stream);
25
+ runtime.unregisterStream(stream);
26
+ }
23
27
  runtime.client.close();
24
28
  runtimePromise = null;
25
29
  await shutdownManagedServer();
@@ -43,7 +47,12 @@ export async function getRuntime() {
43
47
  return runtimePromise;
44
48
  }
45
49
  export async function createPageHandle(runtime) {
46
- const stream = runtime.client.TabSession();
50
+ const stream = runtime.client.ContextSession();
51
+ runtime.registerStream(stream);
52
+ const unregister = () => runtime.unregisterStream(stream);
53
+ stream.on("close", unregister);
54
+ stream.on("end", unregister);
55
+ stream.on("error", unregister);
47
56
  const queue = bindStreamQueue(stream);
48
57
  return {
49
58
  stream,
@@ -52,7 +61,12 @@ export async function createPageHandle(runtime) {
52
61
  };
53
62
  }
54
63
  export async function createBrowserSessionHandle(runtime) {
55
- const stream = runtime.client.BrowserSession();
64
+ const stream = runtime.client.SurfaceSession();
65
+ runtime.registerStream(stream);
66
+ const unregister = () => runtime.unregisterStream(stream);
67
+ stream.on("close", unregister);
68
+ stream.on("end", unregister);
69
+ stream.on("error", unregister);
56
70
  const queue = bindStreamQueue(stream);
57
71
  return { stream, queue };
58
72
  }
@@ -93,7 +107,17 @@ async function createRuntime() {
93
107
  const proto = grpc.loadPackageDefinition(loaded);
94
108
  const ClientCtor = proto.allwright.engine.v1.EngineService;
95
109
  const client = new ClientCtor(resolvedServerAddr, grpc.credentials.createInsecure());
96
- return { client };
110
+ const openStreams = new Set();
111
+ return {
112
+ client,
113
+ openStreams,
114
+ registerStream(stream) {
115
+ openStreams.add(stream);
116
+ },
117
+ unregisterStream(stream) {
118
+ openStreams.delete(stream);
119
+ },
120
+ };
97
121
  }
98
122
  function configuredServerAddr() {
99
123
  if (serverAddrOverride) {
@@ -114,3 +138,17 @@ function bindStreamQueue(stream) {
114
138
  });
115
139
  return queue;
116
140
  }
141
+ function closeTrackedStream(stream) {
142
+ try {
143
+ stream.end();
144
+ }
145
+ catch {
146
+ // Some grpc-js stream states reject end() during teardown; keep going.
147
+ }
148
+ try {
149
+ stream.cancel();
150
+ }
151
+ catch {
152
+ // Best-effort shutdown so dangling streams do not keep the process alive.
153
+ }
154
+ }
package/dist/types.d.ts CHANGED
@@ -67,6 +67,10 @@ export interface WaitForSelectorResult {
67
67
  visible: boolean;
68
68
  note: string;
69
69
  }
70
+ export interface ScreenshotResult {
71
+ pngData: Uint8Array;
72
+ note: string;
73
+ }
70
74
  export interface BrowserInfo {
71
75
  sessionId: string;
72
76
  browserName: string;
@@ -110,6 +114,7 @@ export interface Page extends PageInfo {
110
114
  textContent(selector: string, options?: CommandOptions): Promise<TextResult>;
111
115
  innerText(selector: string, options?: CommandOptions): Promise<TextResult>;
112
116
  waitForSelector(selector: string, options?: WaitForSelectorOptions): Promise<WaitForSelectorResult>;
117
+ screenshot(options?: CommandOptions): Promise<ScreenshotResult>;
113
118
  close(): Promise<void>;
114
119
  ping(message?: string): Promise<string>;
115
120
  pageInfo(): PageInfo;
@@ -128,23 +133,24 @@ export interface MobileAndroidLaunchOptions {
128
133
  timeoutMs?: number;
129
134
  }
130
135
  export interface MobileAndroidLocator {
131
- readonly page: MobileAndroidPage;
136
+ readonly page: MobileAndroidApp;
132
137
  readonly selector: string;
133
138
  click(options?: CommandOptions): Promise<ClickResult>;
134
139
  fill(value: string, options?: CommandOptions): Promise<FillResult>;
135
140
  locator(selector: string): MobileAndroidLocator;
136
141
  }
137
- export interface MobileAndroidPage {
142
+ export interface MobileAndroidApp {
138
143
  readonly sessionId: string;
139
144
  locator(selector: string): MobileAndroidLocator;
140
145
  click(selector: string, options?: CommandOptions): Promise<ClickResult>;
141
146
  fill(selector: string, value: string, options?: CommandOptions): Promise<FillResult>;
147
+ screenshot(options?: CommandOptions): Promise<ScreenshotResult>;
142
148
  }
143
149
  export interface MobileAndroidDevice {
144
150
  readonly sessionId: string;
145
- page(): MobileAndroidPage;
146
- initialPage(): MobileAndroidPage;
147
- launch(options?: MobileAndroidLaunchOptions): Promise<MobileAndroidPage>;
151
+ app(): MobileAndroidApp;
152
+ initialApp(): MobileAndroidApp;
153
+ launch(options?: MobileAndroidLaunchOptions): Promise<MobileAndroidApp>;
148
154
  }
149
155
  export interface MobileSurfaceNamespace {
150
156
  android: {
@@ -267,22 +273,41 @@ export interface ChromeLaunchedPayload {
267
273
  note?: string;
268
274
  cdpWebsocketUrl?: string;
269
275
  userDataDir?: string;
270
- initialTabSessionId?: string;
276
+ initialPageSessionId?: string;
271
277
  }
272
278
  export interface BrowserLaunchedPayload {
273
279
  browserKind?: number;
274
280
  browser?: string;
275
281
  note?: string;
276
282
  userDataDir?: string;
277
- initialTabSessionId?: string;
283
+ initialPageSessionId?: string;
278
284
  }
279
- export interface BrowserSessionEvent {
285
+ export interface SurfaceSessionEvent {
280
286
  sessionId?: string;
281
287
  event?: string;
282
288
  chromeLaunched?: ChromeLaunchedPayload;
283
289
  browserLaunched?: BrowserLaunchedPayload;
284
- tabOpened?: {
285
- tabSessionId?: string;
290
+ mobileConnected?: {
291
+ platform?: number | string;
292
+ deviceName?: string;
293
+ note?: string;
294
+ deviceId?: string;
295
+ connectionKind?: number | string;
296
+ backend?: string;
297
+ deviceSessionId?: string;
298
+ initialAppSessionId?: string;
299
+ packageName?: string;
300
+ activityName?: string;
301
+ };
302
+ appLaunched?: {
303
+ appSessionId?: string;
304
+ note?: string;
305
+ packageName?: string;
306
+ activityName?: string;
307
+ webviewContext?: string;
308
+ };
309
+ contextOpened?: {
310
+ contextSessionId?: string;
286
311
  note?: string;
287
312
  };
288
313
  pong?: {
@@ -295,8 +320,8 @@ export interface BrowserSessionEvent {
295
320
  message?: string;
296
321
  };
297
322
  }
298
- export interface TabSessionEvent {
299
- tabSessionId?: string;
323
+ export interface ContextSessionEvent {
324
+ contextSessionId?: string;
300
325
  event?: string;
301
326
  attached?: {
302
327
  note?: string;
@@ -369,6 +394,10 @@ export interface TabSessionEvent {
369
394
  visible?: boolean;
370
395
  note?: string;
371
396
  };
397
+ screenshotCaptured?: {
398
+ pngData?: Uint8Array;
399
+ note?: string;
400
+ };
372
401
  }
373
402
  export interface LaunchChromeRequest {
374
403
  launchChrome: {
@@ -387,31 +416,53 @@ export interface LaunchBrowserRequest {
387
416
  };
388
417
  };
389
418
  }
390
- export interface OpenTabRequest {
391
- openTab: {
419
+ export interface OpenContextRequest {
420
+ openContext: {
421
+ retryOptions?: {
422
+ timeoutMs?: number;
423
+ };
424
+ };
425
+ }
426
+ export interface ConnectMobileRequest {
427
+ connectMobile: {
428
+ platform: number;
429
+ device?: string;
430
+ adbEndpoint?: string;
431
+ preserveAppState?: boolean;
392
432
  retryOptions?: {
393
433
  timeoutMs?: number;
394
434
  };
395
435
  };
396
436
  }
397
- export interface BrowserPingRequest {
437
+ export interface LaunchAppRequest {
438
+ launchApp: {
439
+ apkPath?: string;
440
+ appId?: string;
441
+ launchActivity?: string;
442
+ stopBeforeLaunch?: boolean;
443
+ retryOptions?: {
444
+ timeoutMs?: number;
445
+ };
446
+ };
447
+ }
448
+ export interface SurfacePingRequest {
398
449
  ping: {
399
450
  message: string;
400
451
  };
401
452
  }
402
- export interface CloseBrowserRequest {
453
+ export interface CloseSurfaceRequest {
403
454
  close: Record<string, never>;
404
455
  }
405
- export interface TabPingRequest {
406
- browserSessionId: string;
407
- tabSessionId: string;
456
+ export interface ContextPingRequest {
457
+ surfaceSessionId: string;
458
+ contextSessionId: string;
408
459
  ping: {
409
460
  message: string;
410
461
  };
411
462
  }
412
463
  export interface NavigateRequest {
413
- browserSessionId: string;
414
- tabSessionId: string;
464
+ surfaceSessionId: string;
465
+ contextSessionId: string;
415
466
  navigate: {
416
467
  url: string;
417
468
  retryOptions?: {
@@ -420,8 +471,8 @@ export interface NavigateRequest {
420
471
  };
421
472
  }
422
473
  export interface ClickRequest {
423
- browserSessionId: string;
424
- tabSessionId: string;
474
+ surfaceSessionId: string;
475
+ contextSessionId: string;
425
476
  clickElement: {
426
477
  cssSelector: string;
427
478
  retryOptions?: {
@@ -430,8 +481,8 @@ export interface ClickRequest {
430
481
  };
431
482
  }
432
483
  export interface CountRequest {
433
- browserSessionId: string;
434
- tabSessionId: string;
484
+ surfaceSessionId: string;
485
+ contextSessionId: string;
435
486
  countElements: {
436
487
  cssSelector: string;
437
488
  retryOptions?: {
@@ -440,8 +491,8 @@ export interface CountRequest {
440
491
  };
441
492
  }
442
493
  export interface HighlightRequest {
443
- browserSessionId: string;
444
- tabSessionId: string;
494
+ surfaceSessionId: string;
495
+ contextSessionId: string;
445
496
  highlightElements: {
446
497
  cssSelector: string;
447
498
  durationMs?: number;
@@ -451,8 +502,8 @@ export interface HighlightRequest {
451
502
  };
452
503
  }
453
504
  export interface FocusRequest {
454
- browserSessionId: string;
455
- tabSessionId: string;
505
+ surfaceSessionId: string;
506
+ contextSessionId: string;
456
507
  focusElement: {
457
508
  cssSelector: string;
458
509
  retryOptions?: {
@@ -461,8 +512,8 @@ export interface FocusRequest {
461
512
  };
462
513
  }
463
514
  export interface FillRequest {
464
- browserSessionId: string;
465
- tabSessionId: string;
515
+ surfaceSessionId: string;
516
+ contextSessionId: string;
466
517
  fillElement: {
467
518
  cssSelector: string;
468
519
  value: string;
@@ -472,8 +523,8 @@ export interface FillRequest {
472
523
  };
473
524
  }
474
525
  export interface HoverRequest {
475
- browserSessionId: string;
476
- tabSessionId: string;
526
+ surfaceSessionId: string;
527
+ contextSessionId: string;
477
528
  hoverElement: {
478
529
  cssSelector: string;
479
530
  retryOptions?: {
@@ -482,8 +533,8 @@ export interface HoverRequest {
482
533
  };
483
534
  }
484
535
  export interface PressRequest {
485
- browserSessionId: string;
486
- tabSessionId: string;
536
+ surfaceSessionId: string;
537
+ contextSessionId: string;
487
538
  pressKey: {
488
539
  cssSelector: string;
489
540
  key: string;
@@ -494,8 +545,8 @@ export interface PressRequest {
494
545
  };
495
546
  }
496
547
  export interface TextContentRequest {
497
- browserSessionId: string;
498
- tabSessionId: string;
548
+ surfaceSessionId: string;
549
+ contextSessionId: string;
499
550
  getTextContent: {
500
551
  cssSelector: string;
501
552
  retryOptions?: {
@@ -504,8 +555,8 @@ export interface TextContentRequest {
504
555
  };
505
556
  }
506
557
  export interface InnerTextRequest {
507
- browserSessionId: string;
508
- tabSessionId: string;
558
+ surfaceSessionId: string;
559
+ contextSessionId: string;
509
560
  getInnerText: {
510
561
  cssSelector: string;
511
562
  retryOptions?: {
@@ -514,8 +565,8 @@ export interface InnerTextRequest {
514
565
  };
515
566
  }
516
567
  export interface WaitForSelectorRequest {
517
- browserSessionId: string;
518
- tabSessionId: string;
568
+ surfaceSessionId: string;
569
+ contextSessionId: string;
519
570
  waitForSelector: {
520
571
  cssSelector: string;
521
572
  visible?: boolean;
@@ -524,19 +575,28 @@ export interface WaitForSelectorRequest {
524
575
  };
525
576
  };
526
577
  }
527
- export interface CloseTabRequest {
528
- browserSessionId: string;
529
- tabSessionId: string;
578
+ export interface ScreenshotRequest {
579
+ surfaceSessionId: string;
580
+ contextSessionId: string;
581
+ screenshot: {
582
+ retryOptions?: {
583
+ timeoutMs?: number;
584
+ };
585
+ };
586
+ }
587
+ export interface CloseContextRequest {
588
+ surfaceSessionId: string;
589
+ contextSessionId: string;
530
590
  close: Record<string, never>;
531
591
  }
532
- export type BrowserSessionRequest = LaunchBrowserRequest | LaunchChromeRequest | OpenTabRequest | BrowserPingRequest | CloseBrowserRequest;
533
- export type TabSessionRequest = TabPingRequest | NavigateRequest | ClickRequest | CountRequest | HighlightRequest | FocusRequest | FillRequest | HoverRequest | PressRequest | TextContentRequest | InnerTextRequest | WaitForSelectorRequest | CloseTabRequest;
534
- export type BrowserSessionStream = grpc.ClientDuplexStream<BrowserSessionRequest, BrowserSessionEvent>;
535
- export type PageSessionStream = grpc.ClientDuplexStream<TabSessionRequest, TabSessionEvent>;
592
+ export type SurfaceSessionRequest = LaunchBrowserRequest | LaunchChromeRequest | OpenContextRequest | ConnectMobileRequest | LaunchAppRequest | SurfacePingRequest | CloseSurfaceRequest;
593
+ export type ContextSessionRequest = ContextPingRequest | NavigateRequest | ClickRequest | CountRequest | HighlightRequest | FocusRequest | FillRequest | HoverRequest | PressRequest | TextContentRequest | InnerTextRequest | WaitForSelectorRequest | ScreenshotRequest | CloseContextRequest;
594
+ export type SurfaceSessionStream = grpc.ClientDuplexStream<SurfaceSessionRequest, SurfaceSessionEvent>;
595
+ export type ContextSessionStream = grpc.ClientDuplexStream<ContextSessionRequest, ContextSessionEvent>;
536
596
  export interface EngineServiceClientShape {
537
597
  Ping(request: Record<string, never>, callback: (error: grpc.ServiceError | null, response: PingResponse) => void): void;
538
- BrowserSession(): BrowserSessionStream;
539
- TabSession(): PageSessionStream;
598
+ SurfaceSession(): SurfaceSessionStream;
599
+ ContextSession(): ContextSessionStream;
540
600
  close(): void;
541
601
  }
542
602
  export interface EngineProtoRoot {
@@ -550,17 +610,20 @@ export interface EngineProtoRoot {
550
610
  }
551
611
  export interface RuntimeClient {
552
612
  client: EngineServiceClientShape;
613
+ openStreams: Set<SurfaceSessionStream | ContextSessionStream>;
614
+ registerStream(stream: SurfaceSessionStream | ContextSessionStream): void;
615
+ unregisterStream(stream: SurfaceSessionStream | ContextSessionStream): void;
553
616
  }
554
617
  export interface BrowserLaunchState {
555
618
  runtime: RuntimeClient;
556
- stream: BrowserSessionStream;
557
- queue: EventQueue<BrowserSessionEvent>;
619
+ stream: SurfaceSessionStream;
620
+ queue: EventQueue<SurfaceSessionEvent>;
558
621
  sessionId: string;
559
622
  launched: BrowserLaunchedPayload;
560
623
  }
561
624
  export interface PageHandle {
562
- stream: PageSessionStream;
563
- queue: EventQueue<TabSessionEvent>;
625
+ stream: ContextSessionStream;
626
+ queue: EventQueue<ContextSessionEvent>;
564
627
  closed: boolean;
565
628
  }
566
629
  export declare class EventQueue<T> {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allwright.dev/core",
3
- "version": "0.0.52",
3
+ "version": "0.0.54",
4
4
  "description": "High-level TypeScript client for the allwright automation engine.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -37,7 +37,8 @@
37
37
  },
38
38
  "scripts": {
39
39
  "build": "tsc -p tsconfig.json",
40
- "example:playground": "bun run examples/playground.ts",
40
+ "example:web": "bun run examples/web-basic.ts",
41
+ "example:android": "bun run examples/android-basic.ts",
41
42
  "prepublishOnly": "bun run build"
42
43
  },
43
44
  "dependencies": {