nothing-browser 0.1.0 → 0.1.2

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.
@@ -6,7 +6,14 @@ import { routeRegistry, keepAliveSites, type RouteHandler, type BeforeMiddleware
6
6
  import { buildRespondScript, buildModifyResponseScript } from "../intercept/scripts";
7
7
  import { storeRecord } from "../store";
8
8
  import { TabPool } from "../pool";
9
-
9
+ import { createFindAPI } from "../find";
10
+ import { createProvideAPI } from "../provide";
11
+ import { createHumanAPI } from "../human";
12
+ import { createSessionAPI } from "../session";
13
+ import { DialogClient } from "../dialog";
14
+ import { createIframeAPI } from "../iframe";
15
+ import { exposeFunction, unexposeFunction, clearExposedFunctions, exposeAndInject } from "../expose";
16
+ import { createCaptchaAPI } from "../captcha";
10
17
  let globalClient: PiggyClient | null = null;
11
18
  export let humanMode = false;
12
19
 
@@ -105,6 +112,18 @@ export function createSiteObject(
105
112
  return client.waitForSelector(selector, timeout, t);
106
113
  }),
107
114
 
115
+ exposeFunction: (fnName: string, handler: (data: any) => Promise<any> | any) =>
116
+ exposeFunction(client, fnName, handler, tabId).then(() => site),
117
+
118
+ unexposeFunction: (fnName: string) =>
119
+ unexposeFunction(client, fnName, tabId).then(() => site),
120
+
121
+ clearExposedFunctions: () =>
122
+ clearExposedFunctions(client, tabId).then(() => site),
123
+
124
+ exposeAndInject: (fnName: string, handler: (data: any) => Promise<any> | any, injectionJs: string | ((fnName: string) => string)) =>
125
+ exposeAndInject(client, fnName, handler, injectionJs, tabId).then(() => site),
126
+
108
127
  waitForVisible: (selector: string, timeout = 30000) =>
109
128
  withTab(t => client.waitForSelector(selector, timeout, t)),
110
129
 
@@ -257,6 +276,69 @@ export function createSiteObject(
257
276
  css: (query: string) => withTab(t => client.searchCss(query, t)),
258
277
  id: (query: string) => withTab(t => client.searchId(query, t)),
259
278
  },
279
+ captcha: {
280
+ status: () => withTab(t => createCaptchaAPI(client).status(t)),
281
+ resolve: () => withTab(t => createCaptchaAPI(client).resolve(t)),
282
+ pause: () => withTab(t => createCaptchaAPI(client).pause(t)),
283
+ check: () => withTab(t => createCaptchaAPI(client).check(t)),
284
+ autoRetry: (opts: { enabled: boolean }) => withTab(t => createCaptchaAPI(client).setAutoRetry(opts.enabled)),
285
+ onCaptcha: (handler: any) => createCaptchaAPI(client).onCaptcha(tabId, handler),
286
+ onResolved:(handler: any) => createCaptchaAPI(client).onCaptchaResolved(tabId, handler),
287
+ },
288
+ block: {
289
+ status: () => withTab(t => createCaptchaAPI(client).blockStatus(t)),
290
+ retry: () => withTab(t => createCaptchaAPI(client).blockRetry(t)),
291
+ onBlocked: (handler: any) => createCaptchaAPI(client).onBlocked(tabId, handler),
292
+ onRetry: (handler: any) => createCaptchaAPI(client).onBlockRetry(tabId, handler),
293
+ },
294
+ find: {
295
+ css: (selector: string) => withTab(t => {
296
+ console.log("[DEBUG] find.css tabId:", t);
297
+ return createFindAPI(client).css(selector, t);
298
+ }),
299
+ all: (selector: string) => withTab(t => createFindAPI(client).all(selector, t)),
300
+ first: (selector: string) => withTab(t => createFindAPI(client).first(selector, t)),
301
+ byText: (text: string) => withTab(t => createFindAPI(client).byText(text, t)),
302
+ byAttr: (attr: string, value?: string) => withTab(t => createFindAPI(client).byAttr(attr, value, t)),
303
+ byTag: (tag: string) => withTab(t => createFindAPI(client).byTag(tag, t)),
304
+ byPlaceholder: (text: string) => withTab(t => createFindAPI(client).byPlaceholder(text, t)),
305
+ byRole: (role: string, name?: string) => withTab(t => createFindAPI(client).byRole(role, name, t)),
306
+ children: (selector: string) => withTab(t => createFindAPI(client).children(selector, t)),
307
+ parent: (selector: string) => withTab(t => createFindAPI(client).parent(selector, t)),
308
+ closest: (selector: string, ancestor: string) => withTab(t => createFindAPI(client).closest(selector, ancestor, t)),
309
+ count: (selector: string) => withTab(t => createFindAPI(client).count(selector, t)),
310
+ exists: (selector: string) => withTab(t => createFindAPI(client).exists(selector, t)),
311
+ visible: (selector: string) => withTab(t => createFindAPI(client).visible(selector, t)),
312
+ enabled: (selector: string) => withTab(t => createFindAPI(client).enabled(selector, t)),
313
+ checked: (selector: string) => withTab(t => createFindAPI(client).checked(selector, t)),
314
+ },
315
+
316
+ provide: {
317
+ text: (opts: any) => withTab(t => createProvideAPI(client).text(opts, t)),
318
+ textAll: (opts: any) => withTab(t => createProvideAPI(client).textAll(opts, t)),
319
+ attr: (opts: any) => withTab(t => createProvideAPI(client).attr(opts, t)),
320
+ attrAll: (opts: any) => withTab(t => createProvideAPI(client).attrAll(opts, t)),
321
+ html: (opts: any) => withTab(t => createProvideAPI(client).html(opts, t)),
322
+ table: (opts: any) => withTab(t => createProvideAPI(client).table(opts, t)),
323
+ list: (opts: any) => withTab(t => createProvideAPI(client).list(opts, t)),
324
+ links: (opts: any) => withTab(t => createProvideAPI(client).links(opts, t)),
325
+ images: (opts: any) => withTab(t => createProvideAPI(client).images(opts, t)),
326
+ form: (opts: any) => withTab(t => createProvideAPI(client).form(opts, t)),
327
+ page: () => withTab(t => createProvideAPI(client).page(t)),
328
+ div: (opts: any) => withTab(t => createProvideAPI(client).div(opts, t)),
329
+ meta: () => withTab(t => createProvideAPI(client).meta(t)),
330
+ select: (opts: any) => withTab(t => createProvideAPI(client).select(opts, t)),
331
+ json: (opts?: any) => withTab(t => createProvideAPI(client).json(opts, t)),
332
+ },
333
+ iframe: {
334
+ list: () => withTab(t => createIframeAPI(client).list(t)),
335
+ evaluate:(opts: any) => withTab(t => createIframeAPI(client).evaluate(opts, t)),
336
+ click: (opts: any) => withTab(t => createIframeAPI(client).click(opts, t)),
337
+ type: (opts: any) => withTab(t => createIframeAPI(client).type(opts, t)),
338
+ text: (opts: any) => withTab(t => createIframeAPI(client).text(opts, t)),
339
+ html: (opts: any) => withTab(t => createIframeAPI(client).html(opts, t)),
340
+ waitSel: (opts: any) => withTab(t => createIframeAPI(client).waitSel(opts, t)),
341
+ },
260
342
 
261
343
  screenshot: async (filePath?: string) => {
262
344
  const r = await withTab(t => client.screenshot(filePath, t));
@@ -269,6 +351,13 @@ export function createSiteObject(
269
351
  logger.success(`[${name}] pdf → ${filePath ?? "base64"}`);
270
352
  return r;
271
353
  },
354
+ human: {
355
+ set: (opts: any) => withTab(t => createHumanAPI(client).set(opts, t)),
356
+ get: () => withTab(t => createHumanAPI(client).get(t)),
357
+ type: (opts: any) => withTab(t => createHumanAPI(client).type(opts, t)),
358
+ click: (opts: any) => withTab(t => createHumanAPI(client).click(opts, t)),
359
+ },
360
+
272
361
 
273
362
  blockImages: () => withTab(async t => { await client.blockImages(t); logger.info(`[${name}] images blocked`); }),
274
363
  unblockImages: () => withTab(async t => { await client.unblockImages(t); logger.info(`[${name}] images unblocked`); }),
@@ -278,14 +367,14 @@ export function createSiteObject(
278
367
  await withTab(t => client.setCookie(cookieName, value, domain, path, t));
279
368
  logger.info(`[${name}] cookie set: ${cookieName} @ ${domain}`);
280
369
  },
281
- get: (cookieName: string) => withTab(t => client.getCookie(cookieName, t)),
282
- delete: async (cookieName: string) => {
283
- await withTab(t => client.deleteCookie(cookieName, t));
370
+ get: (cookieName: string, domain = "") => withTab(t => client.getCookie(cookieName, domain, t)),
371
+ delete: async (cookieName: string, domain?: string) => {
372
+ const d = domain ?? new URL(registeredUrl).hostname;
373
+ await withTab(t => client.deleteCookie(cookieName, d, t));
284
374
  logger.info(`[${name}] cookie deleted: ${cookieName}`);
285
375
  },
286
- list: () => withTab(t => client.listCookies(t)),
376
+ list: (domain = "") => withTab(t => client.listCookies(domain, t)),
287
377
  },
288
-
289
378
  intercept: {
290
379
  block: async (pattern: string) => {
291
380
  await withTab(t => client.addInterceptRule("block", pattern, {}, t));
@@ -385,6 +474,16 @@ export function createSiteObject(
385
474
  logger.info(`[${name}] intercept rules cleared`);
386
475
  },
387
476
  },
477
+ dialog: {
478
+ accept: (tabId = "default", text?: string) => new DialogClient(client).accept(tabId, text),
479
+ dismiss: (tabId = "default") => new DialogClient(client).dismiss(tabId),
480
+ status: (tabId = "default") => new DialogClient(client).status(tabId),
481
+ setAutoAction: (tabId = "default", action: "accept" | "dismiss" | "") => new DialogClient(client).setAutoAction(tabId, action),
482
+ upload: (selector: string, filePath: string, tabId = "default") => new DialogClient(client).upload(selector, filePath, tabId),
483
+ onDialog: (tabId: string, handler: (data: any) => void) => new DialogClient(client).onDialog(tabId, handler),
484
+ waitAndAccept: (tabId = "default", text?: string, timeoutMs = 30000) => new DialogClient(client).waitAndAccept(tabId, text, timeoutMs),
485
+ waitAndDismiss:(tabId = "default", timeoutMs = 30000) => new DialogClient(client).waitAndDismiss(tabId, timeoutMs),
486
+ },
388
487
 
389
488
  capture: {
390
489
  start: () => withTab(async t => { await client.captureStart(t); logger.info(`[${name}] capture started`); }),
@@ -396,40 +495,16 @@ export function createSiteObject(
396
495
  clear: () => withTab(async t => { await client.captureClear(t); logger.info(`[${name}] capture cleared`); }),
397
496
  },
398
497
 
399
- session: {
400
- export: async () => {
401
- const data = await withTab(t => client.sessionExport(t));
402
- logger.success(`[${name}] session exported`);
403
- return data;
404
- },
405
- import: async (data: any) => {
406
- await withTab(t => client.sessionImport(data, t));
407
- logger.success(`[${name}] session imported`);
408
- },
409
- },
410
-
411
- exposeFunction: async (fnName: string, handler: (data: any) => Promise<any> | any) => {
412
- await client.exposeFunction(fnName, handler, tabId);
413
- logger.success(`[${name}] exposed function: ${fnName}`);
414
- return site;
415
- },
416
- unexposeFunction: async (fnName: string) => {
417
- await client.unexposeFunction(fnName, tabId);
418
- logger.info(`[${name}] unexposed function: ${fnName}`);
419
- return site;
420
- },
421
- clearExposedFunctions: async () => {
422
- await client.clearExposedFunctions(tabId);
423
- logger.info(`[${name}] cleared all exposed functions`);
424
- return site;
425
- },
426
- exposeAndInject: async (fnName: string, handler: (data: any) => Promise<any> | any, injectionJs: string | ((fnName: string) => string)) => {
427
- await client.exposeFunction(fnName, handler, tabId);
428
- const js = typeof injectionJs === "function" ? injectionJs(fnName) : injectionJs;
429
- await withTab(t => client.evaluate(js, t));
430
- logger.success(`[${name}] exposed and injected: ${fnName}`);
431
- return site;
432
- },
498
+ session: {
499
+ export: () => withTab(t => createSessionAPI(client).export(t)),
500
+ import: (data: any) => withTab(t => createSessionAPI(client).import(data, t)),
501
+ reload: () => withTab(t => createSessionAPI(client).reload(t)),
502
+ paths: () => createSessionAPI(client).paths(),
503
+ cookies: { path: () => createSessionAPI(client).cookiesPath() },
504
+ profile: { path: () => createSessionAPI(client).profilePath() },
505
+ ws: { save: (opts: any) => createSessionAPI(client).setWsSave(opts.enabled) },
506
+ pings: { save: (opts: any) => createSessionAPI(client).setPingsSave(opts.enabled) },
507
+ },
433
508
 
434
509
  store: async (
435
510
  data: Record<string, any> | Record<string, any>[],
@@ -8,7 +8,8 @@ export class TabsClient {
8
8
  return this.client.send("tab.new", {});
9
9
  }
10
10
 
11
- close(tabId: string): Promise<void> {
11
+ close(opts: string | { tabId: string }): Promise<void> {
12
+ const tabId = typeof opts === "string" ? opts : opts.tabId;
12
13
  return this.client.send("tab.close", { tabId });
13
14
  }
14
15
 
package/piggy.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  // piggy.ts
2
+ //the main file
2
3
  import { detectBinary, type BinaryMode } from "./piggy/launch/detect";
3
4
  import { spawnBrowser, killBrowser, spawnBrowserOnSocket } from "./piggy/launch/spawn";
4
5
  import { PiggyClient } from "./piggy/client";
@@ -121,7 +122,8 @@ const piggy: any = {
121
122
 
122
123
  // ── Sub-APIs (1:1 with C++ files, available after launch/connect) ─────────
123
124
 
124
- get tabs() { return _router?.tabs ?? createTabsAPI(guardClient()); },
125
+ get tabs() { return _router?.tabs ?? createTabsAPI(guardClient()); },
126
+ get tab() { return _router?.tabs ?? createTabsAPI(guardClient()); },
125
127
  get navigation() { return _router?.navigation ?? createNavigationAPI(guardClient()); },
126
128
  get interactions() { return _router?.interactions ?? createInteractionsAPI(guardClient()); },
127
129
  get media() { return _router?.media ?? createMediaAPI(guardClient()); },
@@ -1,7 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,35 +0,0 @@
1
- // piggy/captcha/index.d.ts
2
- import { PiggyClient } from "../client";
3
-
4
- export interface CaptchaState {
5
- detected: boolean;
6
- paused: boolean;
7
- type: string;
8
- }
9
-
10
- export interface BlockState {
11
- detected: boolean;
12
- type: string;
13
- }
14
-
15
- export declare class CaptchaClient {
16
- constructor(client: PiggyClient);
17
-
18
- status(tabId?: string): Promise<CaptchaState>;
19
- resolve(tabId?: string): Promise<void>;
20
- pause(tabId?: string): Promise<void>;
21
- check(tabId?: string): Promise<void>;
22
- setAutoRetry(enabled: boolean): Promise<void>;
23
-
24
- blockStatus(tabId?: string): Promise<BlockState>;
25
- blockRetry(tabId?: string): Promise<void>;
26
-
27
- onCaptcha(tabId: string, handler: (data: { captchaType: string; tabId: string }) => void): () => void;
28
- onCaptchaResolved(tabId: string, handler: (data: { tabId: string }) => void): () => void;
29
- onBlocked(tabId: string, handler: (data: { blockType: string; tabId: string }) => void): () => void;
30
- onBlockRetry(tabId: string, handler: (data: { tabId: string; proxy: string }) => void): () => void;
31
-
32
- waitForResolution(tabId?: string, timeoutMs?: number): Promise<void>;
33
- }
34
-
35
- export declare function createCaptchaAPI(client: PiggyClient): CaptchaClient;
@@ -1,79 +0,0 @@
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
@@ -1 +0,0 @@
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,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AI,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"}
@@ -1,29 +0,0 @@
1
- // piggy/dialog/index.d.ts
2
- import { PiggyClient } from "../client";
3
-
4
- export interface DialogState {
5
- pending: boolean;
6
- type: string;
7
- message: string;
8
- defaultValue: string;
9
- }
10
-
11
- export declare class DialogClient {
12
- constructor(client: PiggyClient);
13
-
14
- accept(tabId?: string, text?: string): Promise<void>;
15
- dismiss(tabId?: string): Promise<void>;
16
- status(tabId?: string): Promise<DialogState>;
17
- setAutoAction(tabId?: string, action: "accept" | "dismiss" | ""): Promise<void>;
18
- upload(selector: string, filePath: string, tabId?: string): Promise<void>;
19
-
20
- onDialog(
21
- tabId: string,
22
- handler: (data: { dialogType: string; message: string; defaultValue: string; tabId: string }) => void
23
- ): () => void;
24
-
25
- waitAndAccept(tabId?: string, text?: string, timeoutMs?: number): Promise<DialogState>;
26
- waitAndDismiss(tabId?: string, timeoutMs?: number): Promise<DialogState>;
27
- }
28
-
29
- export declare function createDialogAPI(client: PiggyClient): DialogClient;
@@ -1,79 +0,0 @@
1
- // piggy/find/index.d.ts
2
- import { PiggyClient } from "../client";
3
-
4
- // ─── Element descriptor ───────────────────────────────────────────────────────
5
-
6
- export interface ElementDescriptor {
7
- tag: string;
8
- id: string;
9
- cls: string;
10
- /** First 400 chars of innerText */
11
- text: string;
12
- /** First 800 chars of innerHTML */
13
- html: string;
14
- href: string;
15
- src: string;
16
- value: string;
17
- attrs: Record<string, string>;
18
- }
19
-
20
- // ─── Option types ─────────────────────────────────────────────────────────────
21
-
22
- export interface FindByTextOptions {
23
- text: string;
24
- selector?: string;
25
- exact?: boolean;
26
- }
27
-
28
- export interface FindByAttrOptions {
29
- attr: string;
30
- value?: string;
31
- selector?: string;
32
- }
33
-
34
- export interface FindByRoleOptions {
35
- role: string;
36
- name?: string;
37
- }
38
-
39
- export interface FindClosestOptions {
40
- selector: string;
41
- ancestor: string;
42
- }
43
-
44
- export interface FindFilterOptions {
45
- selector: string;
46
- attr: string;
47
- value: string;
48
- }
49
-
50
- // ─── FindClient ───────────────────────────────────────────────────────────────
51
-
52
- export declare class FindClient {
53
- constructor(client: PiggyClient);
54
-
55
- // Multi-result
56
- css(selector: string, tabId?: string): Promise<ElementDescriptor[]>;
57
- all(selector: string, tabId?: string): Promise<ElementDescriptor[]>;
58
- first(selector: string, tabId?: string): Promise<ElementDescriptor[]>;
59
- byText(opts: FindByTextOptions, tabId?: string): Promise<ElementDescriptor[]>;
60
- byAttr(opts: FindByAttrOptions, tabId?: string): Promise<ElementDescriptor[]>;
61
- byTag(tag: string, tabId?: string): Promise<ElementDescriptor[]>;
62
- byPlaceholder(text: string, tabId?: string): Promise<ElementDescriptor[]>;
63
- byRole(opts: FindByRoleOptions, tabId?: string): Promise<ElementDescriptor[]>;
64
- children(selector: string, tabId?: string): Promise<ElementDescriptor[]>;
65
- filter(opts: FindFilterOptions, tabId?: string): Promise<ElementDescriptor[]>;
66
-
67
- // Traversal
68
- closest(opts: FindClosestOptions, tabId?: string): Promise<ElementDescriptor[]>;
69
- parent(selector: string, tabId?: string): Promise<ElementDescriptor[]>;
70
-
71
- // Boolean / numeric
72
- count(selector: string, tabId?: string): Promise<number>;
73
- exists(selector: string, tabId?: string): Promise<boolean>;
74
- visible(selector: string, tabId?: string): Promise<boolean>;
75
- enabled(selector: string, tabId?: string): Promise<boolean>;
76
- checked(selector: string, tabId?: string): Promise<boolean>;
77
- }
78
-
79
- export declare function createFindAPI(client: PiggyClient): FindClient;
@@ -1,7 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,7 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,58 +0,0 @@
1
- // piggy/server/index.d.ts
2
- import { Elysia } from "elysia";
3
-
4
- export type BeforeMiddleware = (ctx: {
5
- params: Record<string, string>;
6
- query: Record<string, string>;
7
- body: any;
8
- headers: Record<string, string>;
9
- set: any;
10
- }) => void | Promise<void>;
11
-
12
- export type RouteHandler = (
13
- params: Record<string, string>,
14
- query: Record<string, string>,
15
- body: any
16
- ) => Promise<any>;
17
-
18
- export interface RouteParameter {
19
- name: string;
20
- in: "query" | "path" | "header" | "cookie";
21
- description?: string;
22
- required?: boolean;
23
- schema?: Record<string, any>;
24
- }
25
-
26
- export interface RouteDetail {
27
- tags?: string[];
28
- summary?: string;
29
- description?: string;
30
- deprecated?: boolean;
31
- hide?: boolean;
32
- parameters?: RouteParameter[];
33
- }
34
-
35
- export interface RouteConfig {
36
- path: string;
37
- method: "GET" | "POST" | "PUT" | "DELETE";
38
- handler: RouteHandler;
39
- ttl: number;
40
- before: BeforeMiddleware[];
41
- detail?: RouteDetail;
42
- }
43
-
44
- export declare const routeRegistry: Map<string, RouteConfig>;
45
- export declare const keepAliveSites: Set<string>;
46
-
47
- export declare function startServer(
48
- port: number,
49
- hostname?: string,
50
- openapiOpts?: {
51
- title?: string;
52
- version?: string;
53
- description?: string;
54
- path?: string;
55
- }
56
- ): Promise<Elysia>;
57
-
58
- export declare function stopServer(): void;
@@ -1 +0,0 @@
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"}