@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/README.md +5 -2
- package/dist/bootstrap.d.ts +0 -2
- package/dist/bootstrap.js +1 -97
- package/dist/browser.js +8 -5
- package/dist/index.d.ts +1 -1
- package/dist/mobile.js +169 -78
- package/dist/page.d.ts +3 -1
- package/dist/page.js +78 -27
- package/dist/runtime.d.ts +3 -3
- package/dist/runtime.js +41 -3
- package/dist/types.d.ts +117 -54
- package/package.json +3 -2
- package/proto/core/v1/context.proto +214 -0
- package/proto/core/v1/{browser.proto → surface.proto} +18 -13
- package/proto/engine/v1/engine.proto +4 -4
- package/proto/surfaces/mobile/v1/mobile.proto +56 -0
- package/proto/surfaces/web/v1/web.proto +2 -133
- package/proto/core/v1/tab.proto +0 -72
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
|
-
|
|
23
|
-
|
|
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
|
-
|
|
64
|
-
|
|
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
|
-
|
|
94
|
-
|
|
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
|
-
|
|
124
|
-
|
|
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
|
-
|
|
155
|
-
|
|
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
|
-
|
|
184
|
-
|
|
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
|
-
|
|
215
|
-
|
|
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
|
-
|
|
244
|
-
|
|
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
|
-
|
|
282
|
-
|
|
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
|
-
|
|
314
|
-
|
|
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
|
-
|
|
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
|
-
|
|
334
|
-
|
|
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
|
-
|
|
369
|
-
|
|
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
|
-
|
|
377
|
-
|
|
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 {
|
|
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:
|
|
10
|
-
queue: EventQueue<
|
|
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.
|
|
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.
|
|
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
|
-
|
|
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:
|
|
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
|
|
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
|
-
|
|
146
|
-
|
|
147
|
-
launch(options?: MobileAndroidLaunchOptions): Promise<
|
|
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
|
-
|
|
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
|
-
|
|
283
|
+
initialPageSessionId?: string;
|
|
278
284
|
}
|
|
279
|
-
export interface
|
|
285
|
+
export interface SurfaceSessionEvent {
|
|
280
286
|
sessionId?: string;
|
|
281
287
|
event?: string;
|
|
282
288
|
chromeLaunched?: ChromeLaunchedPayload;
|
|
283
289
|
browserLaunched?: BrowserLaunchedPayload;
|
|
284
|
-
|
|
285
|
-
|
|
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
|
|
299
|
-
|
|
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
|
|
391
|
-
|
|
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
|
|
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
|
|
453
|
+
export interface CloseSurfaceRequest {
|
|
403
454
|
close: Record<string, never>;
|
|
404
455
|
}
|
|
405
|
-
export interface
|
|
406
|
-
|
|
407
|
-
|
|
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
|
-
|
|
414
|
-
|
|
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
|
-
|
|
424
|
-
|
|
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
|
-
|
|
434
|
-
|
|
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
|
-
|
|
444
|
-
|
|
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
|
-
|
|
455
|
-
|
|
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
|
-
|
|
465
|
-
|
|
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
|
-
|
|
476
|
-
|
|
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
|
-
|
|
486
|
-
|
|
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
|
-
|
|
498
|
-
|
|
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
|
-
|
|
508
|
-
|
|
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
|
-
|
|
518
|
-
|
|
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
|
|
528
|
-
|
|
529
|
-
|
|
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
|
|
533
|
-
export type
|
|
534
|
-
export type
|
|
535
|
-
export type
|
|
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
|
-
|
|
539
|
-
|
|
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:
|
|
557
|
-
queue: EventQueue<
|
|
619
|
+
stream: SurfaceSessionStream;
|
|
620
|
+
queue: EventQueue<SurfaceSessionEvent>;
|
|
558
621
|
sessionId: string;
|
|
559
622
|
launched: BrowserLaunchedPayload;
|
|
560
623
|
}
|
|
561
624
|
export interface PageHandle {
|
|
562
|
-
stream:
|
|
563
|
-
queue: EventQueue<
|
|
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.
|
|
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:
|
|
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": {
|