nothing-browser 0.0.12 → 0.0.14
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/LICENSE +21 -0
- package/README.md +120 -887
- package/dist/piggy/cache/memory.d.ts +6 -0
- package/dist/piggy/client/index.d.ts +78 -0
- package/dist/piggy/human/index.d.ts +6 -0
- package/dist/piggy/intercept/scripts.d.ts +12 -0
- package/dist/piggy/launch/detect.d.ts +2 -0
- package/dist/piggy/launch/spawn.d.ts +5 -0
- package/dist/piggy/logger/index.d.ts +2 -0
- package/dist/piggy/open/index.d.ts +3 -0
- package/dist/piggy/register/index.d.ts +6 -0
- package/dist/piggy/server/index.d.ts +20 -0
- package/dist/piggy.d.ts +3 -0
- package/dist/register/index.js +1 -1
- package/package.json +16 -12
- package/piggy/cache/memory.d.ts +7 -0
- package/piggy/cache/memory.d.ts.map +1 -0
- package/piggy/client/index.d.ts +79 -0
- package/piggy/client/index.d.ts.map +1 -0
- package/piggy/human/index.d.ts +7 -0
- package/piggy/human/index.d.ts.map +1 -0
- package/piggy/intercept/scripts.d.ts +13 -0
- package/piggy/intercept/scripts.d.ts.map +1 -0
- package/piggy/launch/detect.d.ts +3 -0
- package/piggy/launch/detect.d.ts.map +1 -0
- package/piggy/launch/spawn.d.ts +6 -0
- package/piggy/launch/spawn.d.ts.map +1 -0
- package/piggy/logger/index.d.ts +3 -0
- package/piggy/logger/index.d.ts.map +1 -0
- package/piggy/open/index.d.ts +4 -0
- package/piggy/open/index.d.ts.map +1 -0
- package/piggy/register/index.d.ts +7 -0
- package/piggy/register/index.d.ts.map +1 -0
- package/piggy/register/index.ts +1 -1
- package/piggy/server/index.d.ts +21 -0
- package/piggy/server/index.d.ts.map +1 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function get(key: string): any | null;
|
|
2
|
+
export declare function set(key: string, data: any, ttlMs: number): void;
|
|
3
|
+
export declare function del(key: string): void;
|
|
4
|
+
export declare function clear(): void;
|
|
5
|
+
export declare function size(): number;
|
|
6
|
+
export declare function keys(): string[];
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
export declare class PiggyClient {
|
|
2
|
+
private socketPath;
|
|
3
|
+
private socket;
|
|
4
|
+
private reqId;
|
|
5
|
+
private pending;
|
|
6
|
+
private buf;
|
|
7
|
+
private eventBuffer;
|
|
8
|
+
private eventHandlers;
|
|
9
|
+
private globalEventHandlers;
|
|
10
|
+
constructor(socketPath?: string);
|
|
11
|
+
connect(): Promise<void>;
|
|
12
|
+
private handleEvent;
|
|
13
|
+
onEvent(eventName: string, tabId: string, handler: (data: any) => void): () => void;
|
|
14
|
+
disconnect(): void;
|
|
15
|
+
send<T = any>(cmd: string, payload?: Record<string, any>): Promise<T>;
|
|
16
|
+
newTab(): Promise<string>;
|
|
17
|
+
closeTab(tabId: string): Promise<void>;
|
|
18
|
+
listTabs(): Promise<string[]>;
|
|
19
|
+
navigate(url: string, tabId?: string): Promise<void>;
|
|
20
|
+
reload(tabId?: string): Promise<void>;
|
|
21
|
+
goBack(tabId?: string): Promise<void>;
|
|
22
|
+
goForward(tabId?: string): Promise<void>;
|
|
23
|
+
getTitle(tabId?: string): Promise<string>;
|
|
24
|
+
getUrl(tabId?: string): Promise<string>;
|
|
25
|
+
content(tabId?: string): Promise<string>;
|
|
26
|
+
evaluate(js: string, tabId?: string): Promise<any>;
|
|
27
|
+
addInitScript(js: string, tabId?: string): Promise<void>;
|
|
28
|
+
click(selector: string, tabId?: string): Promise<boolean>;
|
|
29
|
+
doubleClick(selector: string, tabId?: string): Promise<boolean>;
|
|
30
|
+
hover(selector: string, tabId?: string): Promise<boolean>;
|
|
31
|
+
type(selector: string, text: string, tabId?: string): Promise<boolean>;
|
|
32
|
+
select(selector: string, value: string, tabId?: string): Promise<boolean>;
|
|
33
|
+
keyPress(key: string, tabId?: string): Promise<boolean>;
|
|
34
|
+
keyCombo(combo: string, tabId?: string): Promise<boolean>;
|
|
35
|
+
mouseMove(x: number, y: number, tabId?: string): Promise<boolean>;
|
|
36
|
+
mouseDrag(from: {
|
|
37
|
+
x: number;
|
|
38
|
+
y: number;
|
|
39
|
+
}, to: {
|
|
40
|
+
x: number;
|
|
41
|
+
y: number;
|
|
42
|
+
}, tabId?: string): Promise<boolean>;
|
|
43
|
+
scrollTo(selector: string, tabId?: string): Promise<boolean>;
|
|
44
|
+
scrollBy(px: number, tabId?: string): Promise<boolean>;
|
|
45
|
+
fetchText(query: string, tabId?: string): Promise<string | null>;
|
|
46
|
+
fetchLinks(query: string, tabId?: string): Promise<string[]>;
|
|
47
|
+
fetchImages(query: string, tabId?: string): Promise<string[]>;
|
|
48
|
+
searchCss(query: string, tabId?: string): Promise<any>;
|
|
49
|
+
searchId(query: string, tabId?: string): Promise<any>;
|
|
50
|
+
waitForSelector(selector: string, timeout?: number, tabId?: string): Promise<void>;
|
|
51
|
+
waitForNavigation(tabId?: string): Promise<void>;
|
|
52
|
+
waitForResponse(urlPattern: string, timeout?: number, tabId?: string): Promise<void>;
|
|
53
|
+
screenshot(filePath?: string, tabId?: string): Promise<string>;
|
|
54
|
+
pdf(filePath?: string, tabId?: string): Promise<string>;
|
|
55
|
+
blockImages(tabId?: string): Promise<void>;
|
|
56
|
+
unblockImages(tabId?: string): Promise<void>;
|
|
57
|
+
setCookie(name: string, value: string, domain: string, path?: string, tabId?: string): Promise<void>;
|
|
58
|
+
getCookie(name: string, tabId?: string): Promise<any>;
|
|
59
|
+
deleteCookie(name: string, tabId?: string): Promise<void>;
|
|
60
|
+
listCookies(tabId?: string): Promise<any[]>;
|
|
61
|
+
addInterceptRule(action: "block" | "redirect" | "modifyHeaders", pattern: string, options?: {
|
|
62
|
+
redirectUrl?: string;
|
|
63
|
+
headers?: Record<string, string>;
|
|
64
|
+
}, tabId?: string): Promise<void>;
|
|
65
|
+
clearInterceptRules(tabId?: string): Promise<void>;
|
|
66
|
+
captureStart(tabId?: string): Promise<void>;
|
|
67
|
+
captureStop(tabId?: string): Promise<void>;
|
|
68
|
+
captureRequests(tabId?: string): Promise<any[]>;
|
|
69
|
+
captureWs(tabId?: string): Promise<any[]>;
|
|
70
|
+
captureCookies(tabId?: string): Promise<any[]>;
|
|
71
|
+
captureStorage(tabId?: string): Promise<any>;
|
|
72
|
+
captureClear(tabId?: string): Promise<void>;
|
|
73
|
+
sessionExport(tabId?: string): Promise<any>;
|
|
74
|
+
sessionImport(data: any, tabId?: string): Promise<void>;
|
|
75
|
+
exposeFunction(name: string, handler: (data: any) => Promise<any> | any, tabId?: string): Promise<void>;
|
|
76
|
+
unexposeFunction(name: string, tabId?: string): Promise<void>;
|
|
77
|
+
clearExposedFunctions(tabId?: string): Promise<void>;
|
|
78
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function randomDelay(min: number, max: number): Promise<void>;
|
|
2
|
+
/**
|
|
3
|
+
* Simulates human typing by introducing ~2 random typos and correcting them.
|
|
4
|
+
* Returns an array of { char, isBackspace } actions to replay.
|
|
5
|
+
*/
|
|
6
|
+
export declare function humanTypeSequence(text: string): string[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a script that short-circuits matching fetch/XHR requests
|
|
3
|
+
* and returns a static fake response — the request never hits the network.
|
|
4
|
+
*/
|
|
5
|
+
export declare function buildRespondScript(pattern: string, status: number, contentType: string, body: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Generates a script that lets the request hit the network, then calls
|
|
8
|
+
* an exposed function with { body, status, headers }.
|
|
9
|
+
* The exposed function returns { body?, status?, headers? } modifications
|
|
10
|
+
* or an empty object {} to pass through unchanged.
|
|
11
|
+
*/
|
|
12
|
+
export declare function buildModifyResponseScript(pattern: string, exposedFnName: string): string;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type BinaryMode } from "./detect";
|
|
2
|
+
export declare function killAllBrowsers(): void;
|
|
3
|
+
export declare function spawnBrowser(mode?: BinaryMode): Promise<string>;
|
|
4
|
+
export declare function spawnBrowserOnSocket(socketName: string, mode?: BinaryMode): Promise<void>;
|
|
5
|
+
export declare function killBrowser(): void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { PiggyClient } from "../client";
|
|
2
|
+
export declare let humanMode: boolean;
|
|
3
|
+
export declare function setClient(c: PiggyClient | null): void;
|
|
4
|
+
export declare function setHumanMode(v: boolean): void;
|
|
5
|
+
export declare function createSiteObject(name: string, registeredUrl: string, client: PiggyClient, tabId: string): any;
|
|
6
|
+
export declare function createExposedAPI<T extends Record<string, (data: any) => any>>(site: any, apiName: string, handlers: T): Promise<void>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Elysia } from "elysia";
|
|
2
|
+
export type BeforeMiddleware = (ctx: {
|
|
3
|
+
params: Record<string, string>;
|
|
4
|
+
query: Record<string, string>;
|
|
5
|
+
body: any;
|
|
6
|
+
headers: Record<string, string>;
|
|
7
|
+
set: any;
|
|
8
|
+
}) => void | Promise<void>;
|
|
9
|
+
export type RouteHandler = (params: Record<string, string>, query: Record<string, string>, body: any) => Promise<any>;
|
|
10
|
+
export interface RouteConfig {
|
|
11
|
+
path: string;
|
|
12
|
+
method: "GET" | "POST" | "PUT" | "DELETE";
|
|
13
|
+
handler: RouteHandler;
|
|
14
|
+
ttl: number;
|
|
15
|
+
before: BeforeMiddleware[];
|
|
16
|
+
}
|
|
17
|
+
export declare const routeRegistry: Map<string, RouteConfig>;
|
|
18
|
+
export declare const keepAliveSites: Set<string>;
|
|
19
|
+
export declare function startServer(port: number, hostname?: string): Promise<Elysia>;
|
|
20
|
+
export declare function stopServer(): void;
|
package/dist/piggy.d.ts
ADDED
package/dist/register/index.js
CHANGED
|
@@ -17252,7 +17252,7 @@ function createExposedAPI(site, apiName, handlers) {
|
|
|
17252
17252
|
try {
|
|
17253
17253
|
return await handler(args);
|
|
17254
17254
|
} catch (err) {
|
|
17255
|
-
logger_default.error(`[${site._name}] API error in ${method}
|
|
17255
|
+
logger_default.error(`[${site._name}] API error in ${method}: ${err}`);
|
|
17256
17256
|
throw err;
|
|
17257
17257
|
}
|
|
17258
17258
|
};
|
package/package.json
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nothing-browser",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"description": "Browser automation library powered by Nothing Browser",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"exports": {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
},
|
|
14
|
-
|
|
8
|
+
".": {
|
|
9
|
+
"bun": "./piggy.ts",
|
|
10
|
+
"node": "./dist/piggy.js",
|
|
11
|
+
"default": "./dist/piggy.js"
|
|
12
|
+
},
|
|
15
13
|
"./register": {
|
|
16
14
|
"bun": "./piggy/register/index.ts",
|
|
17
15
|
"node": "./dist/register/index.js",
|
|
@@ -28,10 +26,16 @@
|
|
|
28
26
|
"types": "./dist/logger/index.d.ts"
|
|
29
27
|
}
|
|
30
28
|
},
|
|
29
|
+
|
|
30
|
+
|
|
31
31
|
"scripts": {
|
|
32
|
-
"build": "
|
|
33
|
-
"
|
|
32
|
+
"build:types": "tsc -p tsconfig.types.json",
|
|
33
|
+
"build:js": "bun build ./piggy.ts --outdir ./dist --target node && bun build ./piggy/client/index.ts --outdir ./dist/client --target node && bun build ./piggy/register/index.ts --outdir ./dist/register --target node && bun build ./piggy/server/index.ts --outdir ./dist/server --target node && bun build ./piggy/logger/index.ts --outdir ./dist/logger --target node && bun build ./piggy/launch/detect.ts --outdir ./dist/launch --target node && bun build ./piggy/launch/spawn.ts --outdir ./dist/launch --target node && bun build ./piggy/cache/memory.ts --outdir ./dist/cache --target node && bun build ./piggy/human/index.ts --outdir ./dist/human --target node",
|
|
34
|
+
"build": "bun run build:types && bun run build:js",
|
|
35
|
+
"prepublishOnly": "bun run build"
|
|
34
36
|
},
|
|
37
|
+
|
|
38
|
+
|
|
35
39
|
"dependencies": {
|
|
36
40
|
"elysia": "^1.0.0"
|
|
37
41
|
},
|
|
@@ -39,9 +43,9 @@
|
|
|
39
43
|
"elysia": "^1.0.0"
|
|
40
44
|
},
|
|
41
45
|
"devDependencies": {
|
|
42
|
-
"@types/node": "^
|
|
46
|
+
"@types/node": "^25.6.0",
|
|
43
47
|
"bun-types": "latest",
|
|
44
|
-
"typescript": "^
|
|
48
|
+
"typescript": "^6.0.3"
|
|
45
49
|
},
|
|
46
50
|
"engines": {
|
|
47
51
|
"node": ">=18.0.0",
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function get(key: string): any | null;
|
|
2
|
+
export declare function set(key: string, data: any, ttlMs: number): void;
|
|
3
|
+
export declare function del(key: string): void;
|
|
4
|
+
export declare function clear(): void;
|
|
5
|
+
export declare function size(): number;
|
|
6
|
+
export declare function keys(): string[];
|
|
7
|
+
//# sourceMappingURL=memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["memory.ts"],"names":[],"mappings":"AASA,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,GAAG,IAAI,CAQ3C;AAED,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,QAExD;AAED,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,QAE9B;AAED,wBAAgB,KAAK,SAEpB;AAED,wBAAgB,IAAI,WAEnB;AAED,wBAAgB,IAAI,aAEnB"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export declare class PiggyClient {
|
|
2
|
+
private socketPath;
|
|
3
|
+
private socket;
|
|
4
|
+
private reqId;
|
|
5
|
+
private pending;
|
|
6
|
+
private buf;
|
|
7
|
+
private eventBuffer;
|
|
8
|
+
private eventHandlers;
|
|
9
|
+
private globalEventHandlers;
|
|
10
|
+
constructor(socketPath?: string);
|
|
11
|
+
connect(): Promise<void>;
|
|
12
|
+
private handleEvent;
|
|
13
|
+
onEvent(eventName: string, tabId: string, handler: (data: any) => void): () => void;
|
|
14
|
+
disconnect(): void;
|
|
15
|
+
send<T = any>(cmd: string, payload?: Record<string, any>): Promise<T>;
|
|
16
|
+
newTab(): Promise<string>;
|
|
17
|
+
closeTab(tabId: string): Promise<void>;
|
|
18
|
+
listTabs(): Promise<string[]>;
|
|
19
|
+
navigate(url: string, tabId?: string): Promise<void>;
|
|
20
|
+
reload(tabId?: string): Promise<void>;
|
|
21
|
+
goBack(tabId?: string): Promise<void>;
|
|
22
|
+
goForward(tabId?: string): Promise<void>;
|
|
23
|
+
getTitle(tabId?: string): Promise<string>;
|
|
24
|
+
getUrl(tabId?: string): Promise<string>;
|
|
25
|
+
content(tabId?: string): Promise<string>;
|
|
26
|
+
evaluate(js: string, tabId?: string): Promise<any>;
|
|
27
|
+
addInitScript(js: string, tabId?: string): Promise<void>;
|
|
28
|
+
click(selector: string, tabId?: string): Promise<boolean>;
|
|
29
|
+
doubleClick(selector: string, tabId?: string): Promise<boolean>;
|
|
30
|
+
hover(selector: string, tabId?: string): Promise<boolean>;
|
|
31
|
+
type(selector: string, text: string, tabId?: string): Promise<boolean>;
|
|
32
|
+
select(selector: string, value: string, tabId?: string): Promise<boolean>;
|
|
33
|
+
keyPress(key: string, tabId?: string): Promise<boolean>;
|
|
34
|
+
keyCombo(combo: string, tabId?: string): Promise<boolean>;
|
|
35
|
+
mouseMove(x: number, y: number, tabId?: string): Promise<boolean>;
|
|
36
|
+
mouseDrag(from: {
|
|
37
|
+
x: number;
|
|
38
|
+
y: number;
|
|
39
|
+
}, to: {
|
|
40
|
+
x: number;
|
|
41
|
+
y: number;
|
|
42
|
+
}, tabId?: string): Promise<boolean>;
|
|
43
|
+
scrollTo(selector: string, tabId?: string): Promise<boolean>;
|
|
44
|
+
scrollBy(px: number, tabId?: string): Promise<boolean>;
|
|
45
|
+
fetchText(query: string, tabId?: string): Promise<string | null>;
|
|
46
|
+
fetchLinks(query: string, tabId?: string): Promise<string[]>;
|
|
47
|
+
fetchImages(query: string, tabId?: string): Promise<string[]>;
|
|
48
|
+
searchCss(query: string, tabId?: string): Promise<any>;
|
|
49
|
+
searchId(query: string, tabId?: string): Promise<any>;
|
|
50
|
+
waitForSelector(selector: string, timeout?: number, tabId?: string): Promise<void>;
|
|
51
|
+
waitForNavigation(tabId?: string): Promise<void>;
|
|
52
|
+
waitForResponse(urlPattern: string, timeout?: number, tabId?: string): Promise<void>;
|
|
53
|
+
screenshot(filePath?: string, tabId?: string): Promise<string>;
|
|
54
|
+
pdf(filePath?: string, tabId?: string): Promise<string>;
|
|
55
|
+
blockImages(tabId?: string): Promise<void>;
|
|
56
|
+
unblockImages(tabId?: string): Promise<void>;
|
|
57
|
+
setCookie(name: string, value: string, domain: string, path?: string, tabId?: string): Promise<void>;
|
|
58
|
+
getCookie(name: string, tabId?: string): Promise<any>;
|
|
59
|
+
deleteCookie(name: string, tabId?: string): Promise<void>;
|
|
60
|
+
listCookies(tabId?: string): Promise<any[]>;
|
|
61
|
+
addInterceptRule(action: "block" | "redirect" | "modifyHeaders", pattern: string, options?: {
|
|
62
|
+
redirectUrl?: string;
|
|
63
|
+
headers?: Record<string, string>;
|
|
64
|
+
}, tabId?: string): Promise<void>;
|
|
65
|
+
clearInterceptRules(tabId?: string): Promise<void>;
|
|
66
|
+
captureStart(tabId?: string): Promise<void>;
|
|
67
|
+
captureStop(tabId?: string): Promise<void>;
|
|
68
|
+
captureRequests(tabId?: string): Promise<any[]>;
|
|
69
|
+
captureWs(tabId?: string): Promise<any[]>;
|
|
70
|
+
captureCookies(tabId?: string): Promise<any[]>;
|
|
71
|
+
captureStorage(tabId?: string): Promise<any>;
|
|
72
|
+
captureClear(tabId?: string): Promise<void>;
|
|
73
|
+
sessionExport(tabId?: string): Promise<any>;
|
|
74
|
+
sessionImport(data: any, tabId?: string): Promise<void>;
|
|
75
|
+
exposeFunction(name: string, handler: (data: any) => Promise<any> | any, tabId?: string): Promise<void>;
|
|
76
|
+
unexposeFunction(name: string, tabId?: string): Promise<void>;
|
|
77
|
+
clearExposedFunctions(tabId?: string): Promise<void>;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAWA,qBAAa,WAAW;IACtB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,OAAO,CAAgF;IAC/F,OAAO,CAAC,GAAG,CAAM;IACjB,OAAO,CAAC,WAAW,CAAM;IACzB,OAAO,CAAC,aAAa,CAA+D;IACpF,OAAO,CAAC,mBAAmB,CAA+C;gBAE9D,UAAU,SAAc;IAKpC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAmDxB,OAAO,CAAC,WAAW;IAqEnB,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,GAAG,MAAM,IAAI;IAUnF,UAAU;IAKV,IAAI,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAUnE,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IACtC,QAAQ,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAG7B,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,SAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IACvD,MAAM,CAAC,KAAK,SAAY,GAAG,OAAO,CAAC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O,CAAC,GAAG,EAAE,CAAC;IACjD,cAAc,CAAC,KAAK,SAAY,GAAG,OAAO,CAAC,GAAG,CAAC;IAC/C,YAAY,CAAC,KAAK,SAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAG9C,aAAa,CAAC,KAAK,SAAY,GAAG,OAAO,CAAC,GAAG,CAAC;IAC9C,aAAa,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,SAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAG1D,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,EAAE,KAAK,SAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAe1G,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,SAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAMhE,qBAAqB,CAAC,KAAK,SAAY,GAAG,OAAO,CAAC,IAAI,CAAC;CAI9D"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function randomDelay(min: number, max: number): Promise<void>;
|
|
2
|
+
/**
|
|
3
|
+
* Simulates human typing by introducing ~2 random typos and correcting them.
|
|
4
|
+
* Returns an array of { char, isBackspace } actions to replay.
|
|
5
|
+
*/
|
|
6
|
+
export declare function humanTypeSequence(text: string): string[];
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAEA,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEnE;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CA0CxD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a script that short-circuits matching fetch/XHR requests
|
|
3
|
+
* and returns a static fake response — the request never hits the network.
|
|
4
|
+
*/
|
|
5
|
+
export declare function buildRespondScript(pattern: string, status: number, contentType: string, body: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Generates a script that lets the request hit the network, then calls
|
|
8
|
+
* an exposed function with { body, status, headers }.
|
|
9
|
+
* The exposed function returns { body?, status?, headers? } modifications
|
|
10
|
+
* or an empty object {} to pass through unchanged.
|
|
11
|
+
*/
|
|
12
|
+
export declare function buildModifyResponseScript(pattern: string, exposedFnName: string): string;
|
|
13
|
+
//# sourceMappingURL=scripts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scripts.d.ts","sourceRoot":"","sources":["scripts.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,GACX,MAAM,CAyER;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CA0DxF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["detect.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,SAAS,CAAC;AAOhD,wBAAgB,YAAY,CAAC,IAAI,GAAE,UAAuB,GAAG,MAAM,GAAG,IAAI,CA+BzE"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type BinaryMode } from "./detect";
|
|
2
|
+
export declare function killAllBrowsers(): void;
|
|
3
|
+
export declare function spawnBrowser(mode?: BinaryMode): Promise<string>;
|
|
4
|
+
export declare function spawnBrowserOnSocket(socketName: string, mode?: BinaryMode): Promise<void>;
|
|
5
|
+
export declare function killBrowser(): void;
|
|
6
|
+
//# sourceMappingURL=spawn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["spawn.ts"],"names":[],"mappings":"AAIA,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AASzD,wBAAgB,eAAe,IAAI,IAAI,CAiBtC;AAED,wBAAsB,YAAY,CAAC,IAAI,GAAE,UAAuB,GAAG,OAAO,CAAC,MAAM,CAAC,CAqEjF;AAED,wBAAsB,oBAAoB,CACxC,UAAU,EAAE,MAAM,EAClB,IAAI,GAAE,UAAuB,GAC5B,OAAO,CAAC,IAAI,CAAC,CAqCf;AAED,wBAAgB,WAAW,IAAI,IAAI,CAmBlC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAIA,QAAA,MAAM,MAAM,gCAiDV,CAAC;AAKH,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,IAAI;;EAI3B"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PiggyClient } from "../client";
|
|
2
|
+
export declare let humanMode: boolean;
|
|
3
|
+
export declare function setClient(c: PiggyClient | null): void;
|
|
4
|
+
export declare function setHumanMode(v: boolean): void;
|
|
5
|
+
export declare function createSiteObject(name: string, registeredUrl: string, client: PiggyClient, tabId: string): any;
|
|
6
|
+
export declare function createExposedAPI<T extends Record<string, (data: any) => any>>(site: any, apiName: string, handlers: T): Promise<void>;
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAOxC,eAAO,IAAI,SAAS,SAAQ,CAAC;AAE7B,wBAAgB,SAAS,CAAC,CAAC,EAAE,WAAW,GAAG,IAAI,QAAuB;AACtE,wBAAgB,YAAY,CAAC,CAAC,EAAE,OAAO,QAAoB;AAgB3D,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,OAmcvG;AAED,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,GAAG,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CASrI"}
|
package/piggy/register/index.ts
CHANGED
|
@@ -484,7 +484,7 @@ export function createExposedAPI<T extends Record<string, (data: any) => any>>(s
|
|
|
484
484
|
const handler = handlers[method as keyof T];
|
|
485
485
|
if (!handler) throw new Error(`Unknown method: ${method}`);
|
|
486
486
|
try { return await handler(args); }
|
|
487
|
-
catch (err) { logger.error(`[${site._name}] API error in ${method}
|
|
487
|
+
catch (err) { logger.error(`[${site._name}] API error in ${method}: ${err}`); throw err; }
|
|
488
488
|
};
|
|
489
489
|
return site.exposeFunction(apiName, wrappedHandler);
|
|
490
490
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Elysia } from "elysia";
|
|
2
|
+
export type BeforeMiddleware = (ctx: {
|
|
3
|
+
params: Record<string, string>;
|
|
4
|
+
query: Record<string, string>;
|
|
5
|
+
body: any;
|
|
6
|
+
headers: Record<string, string>;
|
|
7
|
+
set: any;
|
|
8
|
+
}) => void | Promise<void>;
|
|
9
|
+
export type RouteHandler = (params: Record<string, string>, query: Record<string, string>, body: any) => Promise<any>;
|
|
10
|
+
export interface RouteConfig {
|
|
11
|
+
path: string;
|
|
12
|
+
method: "GET" | "POST" | "PUT" | "DELETE";
|
|
13
|
+
handler: RouteHandler;
|
|
14
|
+
ttl: number;
|
|
15
|
+
before: BeforeMiddleware[];
|
|
16
|
+
}
|
|
17
|
+
export declare const routeRegistry: Map<string, RouteConfig>;
|
|
18
|
+
export declare const keepAliveSites: Set<string>;
|
|
19
|
+
export declare function startServer(port: number, hostname?: string): Promise<Elysia>;
|
|
20
|
+
export declare function stopServer(): void;
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,MAAM,MAAM,gBAAgB,GAAG,CAAC,GAAG,EAAE;IACnC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,IAAI,EAAE,GAAG,CAAC;IACV,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,GAAG,EAAE,GAAG,CAAC;CACV,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE3B,MAAM,MAAM,YAAY,GAAG,CACzB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC7B,IAAI,EAAE,GAAG,KACN,OAAO,CAAC,GAAG,CAAC,CAAC;AAElB,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAC;IAC1C,OAAO,EAAE,YAAY,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,gBAAgB,EAAE,CAAC;CAC5B;AAED,eAAO,MAAM,aAAa,0BAAiC,CAAC;AAC5D,eAAO,MAAM,cAAc,aAAoB,CAAC;AAmBhD,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,SAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAoFrF;AAED,wBAAgB,UAAU,SAGzB"}
|