@pinixai/browser 0.2.0
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/package.json +15 -0
- package/src/client.ts +24 -0
- package/src/index.ts +14 -0
- package/src/types.ts +59 -0
package/package.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pinixai/browser",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Browser capability client for Pinix Clips",
|
|
5
|
+
"main": "src/index.ts",
|
|
6
|
+
"module": "src/index.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"files": [
|
|
9
|
+
"src"
|
|
10
|
+
],
|
|
11
|
+
"dependencies": {},
|
|
12
|
+
"peerDependencies": {
|
|
13
|
+
"@pinixai/core": ">=0.5.0"
|
|
14
|
+
}
|
|
15
|
+
}
|
package/src/client.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { invoke } from "@pinixai/core";
|
|
2
|
+
import type {
|
|
3
|
+
BrowserCapability,
|
|
4
|
+
ClickOptions,
|
|
5
|
+
CookieResult,
|
|
6
|
+
EvaluateOptions,
|
|
7
|
+
EvaluateResult,
|
|
8
|
+
NavigateOptions,
|
|
9
|
+
NavigateResult,
|
|
10
|
+
ScreenshotOptions,
|
|
11
|
+
ScreenshotResult,
|
|
12
|
+
TypeOptions,
|
|
13
|
+
WaitForSelectorOptions,
|
|
14
|
+
} from "./types";
|
|
15
|
+
|
|
16
|
+
export const browser: BrowserCapability = {
|
|
17
|
+
navigate: (opts: NavigateOptions) => invoke("browser", "navigate", opts) as Promise<NavigateResult>,
|
|
18
|
+
click: (opts: ClickOptions) => invoke("browser", "click", opts) as Promise<void>,
|
|
19
|
+
type: (opts: TypeOptions) => invoke("browser", "type", opts) as Promise<void>,
|
|
20
|
+
evaluate: (opts: EvaluateOptions) => invoke("browser", "evaluate", opts) as Promise<EvaluateResult>,
|
|
21
|
+
waitForSelector: (opts: WaitForSelectorOptions) => invoke("browser", "waitForSelector", opts) as Promise<void>,
|
|
22
|
+
screenshot: (opts?: ScreenshotOptions) => invoke("browser", "screenshot", opts ?? {}) as Promise<ScreenshotResult>,
|
|
23
|
+
getCookies: () => invoke("browser", "getCookies", {}) as Promise<CookieResult>,
|
|
24
|
+
};
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { browser } from "./client";
|
|
2
|
+
export type {
|
|
3
|
+
BrowserCapability,
|
|
4
|
+
ClickOptions,
|
|
5
|
+
CookieResult,
|
|
6
|
+
EvaluateOptions,
|
|
7
|
+
EvaluateResult,
|
|
8
|
+
NavigateOptions,
|
|
9
|
+
NavigateResult,
|
|
10
|
+
ScreenshotOptions,
|
|
11
|
+
ScreenshotResult,
|
|
12
|
+
TypeOptions,
|
|
13
|
+
WaitForSelectorOptions,
|
|
14
|
+
} from "./types";
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export interface NavigateOptions {
|
|
2
|
+
url: string;
|
|
3
|
+
waitUntil?: "load" | "domcontentloaded" | "networkidle";
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface ClickOptions {
|
|
7
|
+
selector: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface TypeOptions {
|
|
11
|
+
selector: string;
|
|
12
|
+
text: string;
|
|
13
|
+
delay?: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface EvaluateOptions {
|
|
17
|
+
js: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface WaitForSelectorOptions {
|
|
21
|
+
selector: string;
|
|
22
|
+
timeout?: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface ScreenshotOptions {
|
|
26
|
+
fullPage?: boolean;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface NavigateResult {
|
|
30
|
+
url: string;
|
|
31
|
+
title: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface EvaluateResult {
|
|
35
|
+
result: unknown;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface ScreenshotResult {
|
|
39
|
+
base64: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface CookieResult {
|
|
43
|
+
cookies: Array<{
|
|
44
|
+
name: string;
|
|
45
|
+
value: string;
|
|
46
|
+
domain: string;
|
|
47
|
+
path: string;
|
|
48
|
+
}>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface BrowserCapability {
|
|
52
|
+
navigate(options: NavigateOptions): Promise<NavigateResult>;
|
|
53
|
+
click(options: ClickOptions): Promise<void>;
|
|
54
|
+
type(options: TypeOptions): Promise<void>;
|
|
55
|
+
evaluate(options: EvaluateOptions): Promise<EvaluateResult>;
|
|
56
|
+
waitForSelector(options: WaitForSelectorOptions): Promise<void>;
|
|
57
|
+
screenshot(options?: ScreenshotOptions): Promise<ScreenshotResult>;
|
|
58
|
+
getCookies(): Promise<CookieResult>;
|
|
59
|
+
}
|