67b6dc3a79
📁 Files changed: 8 📝 Lines changed: 1060 • package-lock.json • package.json • browser.ts • cli.ts • image.ts • index.ts • mcp.ts • types.ts
174 lines
2.7 KiB
TypeScript
174 lines
2.7 KiB
TypeScript
export interface BrowserOptions {
|
|
headless?: boolean;
|
|
width?: number;
|
|
height?: number;
|
|
}
|
|
|
|
export interface ElementInfo {
|
|
tag: string;
|
|
text: string;
|
|
attributes: Record<string, string>;
|
|
}
|
|
|
|
// Command types
|
|
export interface GotoCommand {
|
|
cmd: 'goto';
|
|
url: string;
|
|
}
|
|
|
|
export interface ClickCommand {
|
|
cmd: 'click';
|
|
selector: string;
|
|
}
|
|
|
|
export interface TypeCommand {
|
|
cmd: 'type';
|
|
selector: string;
|
|
text: string;
|
|
}
|
|
|
|
export interface QueryCommand {
|
|
cmd: 'query';
|
|
selector: string;
|
|
}
|
|
|
|
export interface ScreenshotCommand {
|
|
cmd: 'screenshot';
|
|
path?: string;
|
|
fullPage?: boolean;
|
|
}
|
|
|
|
export interface UrlCommand {
|
|
cmd: 'url';
|
|
}
|
|
|
|
export interface HtmlCommand {
|
|
cmd: 'html';
|
|
full?: boolean;
|
|
}
|
|
|
|
export interface BackCommand {
|
|
cmd: 'back';
|
|
}
|
|
|
|
export interface ForwardCommand {
|
|
cmd: 'forward';
|
|
}
|
|
|
|
export interface ReloadCommand {
|
|
cmd: 'reload';
|
|
}
|
|
|
|
export interface WaitCommand {
|
|
cmd: 'wait';
|
|
ms?: number;
|
|
}
|
|
|
|
export interface NewPageCommand {
|
|
cmd: 'newpage';
|
|
}
|
|
|
|
export interface CloseCommand {
|
|
cmd: 'close';
|
|
}
|
|
|
|
export interface EvalCommand {
|
|
cmd: 'eval';
|
|
script: string;
|
|
}
|
|
|
|
// Image processing commands
|
|
export interface FaviconCommand {
|
|
cmd: 'favicon';
|
|
input: string;
|
|
outputDir: string;
|
|
}
|
|
|
|
export interface ConvertCommand {
|
|
cmd: 'convert';
|
|
input: string;
|
|
output: string;
|
|
format: 'png' | 'jpeg' | 'webp' | 'avif';
|
|
}
|
|
|
|
export interface ResizeCommand {
|
|
cmd: 'resize';
|
|
input: string;
|
|
output: string;
|
|
width: number;
|
|
height?: number;
|
|
fit?: 'cover' | 'contain' | 'fill' | 'inside' | 'outside';
|
|
}
|
|
|
|
export interface CropCommand {
|
|
cmd: 'crop';
|
|
input: string;
|
|
output: string;
|
|
left: number;
|
|
top: number;
|
|
width: number;
|
|
height: number;
|
|
}
|
|
|
|
export interface CompressCommand {
|
|
cmd: 'compress';
|
|
input: string;
|
|
output: string;
|
|
quality?: number;
|
|
}
|
|
|
|
export interface ThumbnailCommand {
|
|
cmd: 'thumbnail';
|
|
input: string;
|
|
output: string;
|
|
size?: 'small' | 'medium' | 'large';
|
|
}
|
|
|
|
export type BrowserCommand =
|
|
| GotoCommand
|
|
| ClickCommand
|
|
| TypeCommand
|
|
| QueryCommand
|
|
| ScreenshotCommand
|
|
| UrlCommand
|
|
| HtmlCommand
|
|
| BackCommand
|
|
| ForwardCommand
|
|
| ReloadCommand
|
|
| WaitCommand
|
|
| NewPageCommand
|
|
| CloseCommand
|
|
| EvalCommand
|
|
| FaviconCommand
|
|
| ConvertCommand
|
|
| ResizeCommand
|
|
| CropCommand
|
|
| CompressCommand
|
|
| ThumbnailCommand;
|
|
|
|
// Response types
|
|
export interface SuccessResponse {
|
|
ok: true;
|
|
url?: string;
|
|
title?: string;
|
|
path?: string;
|
|
html?: string;
|
|
count?: number;
|
|
elements?: ElementInfo[];
|
|
result?: unknown;
|
|
// Image processing fields
|
|
files?: string[];
|
|
outputDir?: string;
|
|
width?: number;
|
|
height?: number;
|
|
format?: string;
|
|
size?: number;
|
|
}
|
|
|
|
export interface ErrorResponse {
|
|
ok: false;
|
|
error: string;
|
|
}
|
|
|
|
export type CommandResponse = SuccessResponse | ErrorResponse;
|