@allwright.dev/core 0.1.14 → 0.1.15
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 +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -0
- package/dist/page.js +32 -7
- package/dist/types.d.ts +32 -1
- package/package.json +1 -1
- package/proto/core/v1/context.proto +4 -0
- package/proto/surfaces/web/v1/web.proto +17 -0
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.15";
|
|
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
|
@@ -3,12 +3,13 @@ import { findConfigFile, loadConfigFile, resolveConfig } from "./config.js";
|
|
|
3
3
|
import { mobile } from "./mobile.js";
|
|
4
4
|
import { PageImpl } from "./page.js";
|
|
5
5
|
import { setServerAddr, shutdown } from "./runtime.js";
|
|
6
|
-
import type { Browser, BrowserKind, BrowserType, LaunchOptions, Page, FileChooser, Download, HookType, ResolveConfigOptions, ResolvedAllwrightConfig } from "./types.js";
|
|
6
|
+
import type { Browser, BrowserKind, BrowserType, LaunchOptions, Page, Dialog, FileChooser, Download, HookType, ResolveConfigOptions, ResolvedAllwrightConfig } from "./types.js";
|
|
7
7
|
export { findConfigFile, loadConfigFile, resolveConfig, setServerAddr, shutdown };
|
|
8
|
-
export type { CapturedOption, BoundingBox, AccessibilitySnapshotOptions, AllwrightConfig, Browser, BrowserInfo, BrowserKind, BrowserType, Hook, HookType, FileChooser, Download, 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 { 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, 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 declare const hooks: {
|
|
12
|
+
dialog: HookType<Dialog>;
|
|
12
13
|
newPage: HookType<Page>;
|
|
13
14
|
fileChooser: HookType<FileChooser>;
|
|
14
15
|
download: HookType<Download>;
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ export { findConfigFile, loadConfigFile, resolveConfig, setServerAddr, shutdown
|
|
|
8
8
|
export const chromium = new BrowserTypeImpl("chromium");
|
|
9
9
|
export const firefox = new BrowserTypeImpl("firefox");
|
|
10
10
|
export const hooks = {
|
|
11
|
+
dialog: Object.freeze({ name: "dialog" }),
|
|
11
12
|
newPage: Object.freeze({ name: "newPage" }),
|
|
12
13
|
fileChooser: Object.freeze({ name: "fileChooser" }),
|
|
13
14
|
download: Object.freeze({ name: "download" }),
|
package/dist/page.js
CHANGED
|
@@ -42,7 +42,7 @@ export class PageImpl extends WebLocatorBuilders {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
async registerHook(type) {
|
|
45
|
-
if (type.name !== "newPage" && type.name !== "fileChooser" && type.name !== "download") {
|
|
45
|
+
if (type.name !== "dialog" && type.name !== "newPage" && type.name !== "fileChooser" && type.name !== "download") {
|
|
46
46
|
throw formatActionError("register hook", `unsupported hook type: ${type.name}`);
|
|
47
47
|
}
|
|
48
48
|
const handle = await this.#getHandle();
|
|
@@ -50,11 +50,8 @@ export class PageImpl extends WebLocatorBuilders {
|
|
|
50
50
|
handle.stream.write({
|
|
51
51
|
surfaceSessionId: this.browserSessionId,
|
|
52
52
|
contextSessionId: this.sessionId,
|
|
53
|
-
registerHook: type.name === "newPage"
|
|
54
|
-
? { newPage: {} }
|
|
55
|
-
: type.name === "fileChooser"
|
|
56
|
-
? { fileChooser: {} }
|
|
57
|
-
: { download: {} },
|
|
53
|
+
registerHook: type.name === "dialog" ? { dialog: {} } : type.name === "newPage"
|
|
54
|
+
? { newPage: {} } : type.name === "fileChooser" ? { fileChooser: {} } : { download: {} },
|
|
58
55
|
});
|
|
59
56
|
while (true) {
|
|
60
57
|
const event = await handle.queue.next();
|
|
@@ -79,12 +76,21 @@ export class PageImpl extends WebLocatorBuilders {
|
|
|
79
76
|
contextSessionId: this.sessionId,
|
|
80
77
|
waitForHook: {
|
|
81
78
|
hookId,
|
|
82
|
-
retryOptions: options.timeoutMs ? { timeoutMs: options.timeoutMs } : undefined,
|
|
79
|
+
retryOptions: options.timeoutMs !== undefined ? { timeoutMs: options.timeoutMs } : undefined,
|
|
83
80
|
},
|
|
84
81
|
});
|
|
85
82
|
while (true) {
|
|
86
83
|
const event = await handle.queue.next();
|
|
87
84
|
if (event.hookCompleted?.hookId === hookId) {
|
|
85
|
+
if (type.name === "dialog" && event.hookCompleted.dialog?.dialogId) {
|
|
86
|
+
const result = event.hookCompleted.dialog;
|
|
87
|
+
const id = result.dialogId;
|
|
88
|
+
return {
|
|
89
|
+
id, page: this, type: result.type ?? "", message: result.message ?? "", defaultValue: result.defaultValue ?? "",
|
|
90
|
+
accept: (promptText, options = {}) => this.#handleDialog(id, true, promptText, options),
|
|
91
|
+
dismiss: (options = {}) => this.#handleDialog(id, false, undefined, options),
|
|
92
|
+
};
|
|
93
|
+
}
|
|
88
94
|
if (type.name === "newPage" && event.hookCompleted.newPage?.contextSessionId) {
|
|
89
95
|
return this.#createPage(event.hookCompleted.newPage.contextSessionId);
|
|
90
96
|
}
|
|
@@ -101,6 +107,25 @@ export class PageImpl extends WebLocatorBuilders {
|
|
|
101
107
|
}
|
|
102
108
|
}
|
|
103
109
|
}
|
|
110
|
+
async #handleDialog(dialogId, accept, promptText, options) {
|
|
111
|
+
const handle = await this.#getHandle();
|
|
112
|
+
this.#ensureOpen(handle);
|
|
113
|
+
handle.stream.write({ surfaceSessionId: this.browserSessionId, contextSessionId: this.sessionId,
|
|
114
|
+
handleDialog: { dialogId, accept, promptText,
|
|
115
|
+
...(options.timeoutMs !== undefined ? { retryOptions: { timeoutMs: options.timeoutMs } } : {}),
|
|
116
|
+
} });
|
|
117
|
+
while (true) {
|
|
118
|
+
const event = await handle.queue.next();
|
|
119
|
+
if (event.dialogHandled?.dialogId === dialogId)
|
|
120
|
+
return;
|
|
121
|
+
if (event.error?.message)
|
|
122
|
+
throw formatActionError("handle dialog", event.error.message);
|
|
123
|
+
if (event.closed) {
|
|
124
|
+
handle.closed = true;
|
|
125
|
+
throw new Error("page closed while handling dialog");
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
104
129
|
async setFileChooserFiles(fileChooserId, files, options = {}) {
|
|
105
130
|
const handle = await this.#getHandle();
|
|
106
131
|
this.#ensureOpen(handle);
|
package/dist/types.d.ts
CHANGED
|
@@ -108,6 +108,15 @@ export interface Hook<T> {
|
|
|
108
108
|
readonly type: HookType<T>;
|
|
109
109
|
wait(options?: CommandOptions): Promise<T>;
|
|
110
110
|
}
|
|
111
|
+
export interface Dialog {
|
|
112
|
+
readonly id: string;
|
|
113
|
+
readonly page: Page;
|
|
114
|
+
readonly type: string;
|
|
115
|
+
readonly message: string;
|
|
116
|
+
readonly defaultValue: string;
|
|
117
|
+
accept(promptText?: string, options?: CommandOptions): Promise<void>;
|
|
118
|
+
dismiss(options?: CommandOptions): Promise<void>;
|
|
119
|
+
}
|
|
111
120
|
export interface FileChooser {
|
|
112
121
|
readonly id: string;
|
|
113
122
|
readonly page: Page | MobileAndroidApp;
|
|
@@ -415,8 +424,17 @@ export interface ContextSessionEvent {
|
|
|
415
424
|
hookRegistered?: {
|
|
416
425
|
hookId?: string;
|
|
417
426
|
};
|
|
427
|
+
dialogHandled?: {
|
|
428
|
+
dialogId?: string;
|
|
429
|
+
};
|
|
418
430
|
hookCompleted?: {
|
|
419
431
|
hookId?: string;
|
|
432
|
+
dialog?: {
|
|
433
|
+
dialogId?: string;
|
|
434
|
+
type?: string;
|
|
435
|
+
message?: string;
|
|
436
|
+
defaultValue?: string;
|
|
437
|
+
};
|
|
420
438
|
newPage?: {
|
|
421
439
|
contextSessionId?: string;
|
|
422
440
|
note?: string;
|
|
@@ -567,10 +585,23 @@ export interface OpenContextRequest {
|
|
|
567
585
|
};
|
|
568
586
|
};
|
|
569
587
|
}
|
|
588
|
+
export interface HandleDialogRequest {
|
|
589
|
+
surfaceSessionId: string;
|
|
590
|
+
contextSessionId: string;
|
|
591
|
+
handleDialog: {
|
|
592
|
+
dialogId: string;
|
|
593
|
+
accept: boolean;
|
|
594
|
+
promptText?: string;
|
|
595
|
+
retryOptions?: {
|
|
596
|
+
timeoutMs?: number;
|
|
597
|
+
};
|
|
598
|
+
};
|
|
599
|
+
}
|
|
570
600
|
export interface RegisterHookRequest {
|
|
571
601
|
surfaceSessionId: string;
|
|
572
602
|
contextSessionId: string;
|
|
573
603
|
registerHook: {
|
|
604
|
+
dialog?: Record<string, never>;
|
|
574
605
|
newPage?: Record<string, never>;
|
|
575
606
|
fileChooser?: Record<string, never>;
|
|
576
607
|
download?: Record<string, never>;
|
|
@@ -849,7 +880,7 @@ export type ContextSessionRequest = {
|
|
|
849
880
|
timeoutMs: number;
|
|
850
881
|
};
|
|
851
882
|
};
|
|
852
|
-
} | ContextPingRequest | RegisterHookRequest | WaitForHookRequest | SetFileChooserFilesRequest | SaveDownloadRequest | UploadFileChunkRequest | ReadFileChunkRequest | SetMobileFileChooserFilesRequest | SaveMobileDownloadRequest | NavigateRequest | ClickRequest | CountRequest | HighlightRequest | FocusRequest | FillRequest | HoverRequest | PressRequest | TextContentRequest | InnerTextRequest | WaitForSelectorRequest | AccessibilitySnapshotRequest | ScreenshotRequest | CloseContextRequest;
|
|
883
|
+
} | ContextPingRequest | RegisterHookRequest | WaitForHookRequest | HandleDialogRequest | SetFileChooserFilesRequest | SaveDownloadRequest | UploadFileChunkRequest | ReadFileChunkRequest | SetMobileFileChooserFilesRequest | SaveMobileDownloadRequest | NavigateRequest | ClickRequest | CountRequest | HighlightRequest | FocusRequest | FillRequest | HoverRequest | PressRequest | TextContentRequest | InnerTextRequest | WaitForSelectorRequest | AccessibilitySnapshotRequest | ScreenshotRequest | CloseContextRequest;
|
|
853
884
|
export type SurfaceSessionStream = grpc.ClientDuplexStream<SurfaceSessionRequest, SurfaceSessionEvent>;
|
|
854
885
|
export type ContextSessionStream = grpc.ClientDuplexStream<ContextSessionRequest, ContextSessionEvent>;
|
|
855
886
|
export interface EngineServiceClientShape {
|
package/package.json
CHANGED
|
@@ -39,6 +39,7 @@ message ContextSessionCommand {
|
|
|
39
39
|
SaveMobileDownloadCommand save_mobile_download = 25;
|
|
40
40
|
ResolveFrameCommand resolve_frame = 26;
|
|
41
41
|
CaptureCommand capture = 27;
|
|
42
|
+
HandleDialogCommand handle_dialog = 28;
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
|
|
@@ -80,6 +81,7 @@ message ContextSessionEvent {
|
|
|
80
81
|
MobileDownloadSavedEvent mobile_download_saved = 27;
|
|
81
82
|
FrameResolvedEvent frame_resolved = 28;
|
|
82
83
|
CaptureResolvedEvent capture_resolved = 29;
|
|
84
|
+
DialogHandledEvent dialog_handled = 30;
|
|
83
85
|
}
|
|
84
86
|
}
|
|
85
87
|
|
|
@@ -106,6 +108,7 @@ message RegisterHookCommand {
|
|
|
106
108
|
RegisterDownloadHook download = 3;
|
|
107
109
|
RegisterMobileFileChooserHook mobile_file_chooser = 4;
|
|
108
110
|
RegisterMobileDownloadHook mobile_download = 5;
|
|
111
|
+
RegisterDialogHook dialog = 6;
|
|
109
112
|
}
|
|
110
113
|
}
|
|
111
114
|
|
|
@@ -127,6 +130,7 @@ message HookCompletedEvent {
|
|
|
127
130
|
DownloadHookResult download = 4;
|
|
128
131
|
MobileFileChooserHookResult mobile_file_chooser = 5;
|
|
129
132
|
MobileDownloadHookResult mobile_download = 6;
|
|
133
|
+
DialogHookResult dialog = 7;
|
|
130
134
|
}
|
|
131
135
|
}
|
|
132
136
|
|
|
@@ -40,6 +40,23 @@ message ChromeLaunchedEvent {
|
|
|
40
40
|
string initial_page_session_id = 5;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
// Register before the triggering action; wait returns a pending JavaScript dialog.
|
|
44
|
+
message RegisterDialogHook {}
|
|
45
|
+
message DialogHookResult {
|
|
46
|
+
string dialog_id = 1;
|
|
47
|
+
string type = 2;
|
|
48
|
+
string message = 3;
|
|
49
|
+
string default_value = 4;
|
|
50
|
+
}
|
|
51
|
+
message HandleDialogCommand {
|
|
52
|
+
string dialog_id = 1;
|
|
53
|
+
bool accept = 2;
|
|
54
|
+
optional string prompt_text = 3;
|
|
55
|
+
// A single-attempt deadline, not a retry request.
|
|
56
|
+
optional CommandRetryOptions retry_options = 4;
|
|
57
|
+
}
|
|
58
|
+
message DialogHandledEvent { string dialog_id = 1; }
|
|
59
|
+
|
|
43
60
|
message RegisterNewPageHook {}
|
|
44
61
|
|
|
45
62
|
message NewPageHookResult {
|