nothing-browser 0.1.3 → 0.1.4

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.
Files changed (120) hide show
  1. package/package.json +14 -26
  2. package/piggy/cache/{memory.ts → memory.js} +5 -10
  3. package/piggy/captcha/{index.ts → index.js} +19 -28
  4. package/piggy/capture/index.js +40 -0
  5. package/piggy/client/{index.ts → index.js} +133 -154
  6. package/piggy/dialog/{index.ts → index.js} +15 -31
  7. package/piggy/export/index.js +105 -0
  8. package/piggy/expose/index.js +24 -0
  9. package/piggy/find/{index.ts → index.js} +24 -39
  10. package/piggy/http/{index.ts → index.js} +7 -16
  11. package/piggy/human/{index.ts → index.js} +18 -49
  12. package/piggy/iframe/index.js +56 -0
  13. package/piggy/interactions/{index.ts → index.js} +20 -23
  14. package/piggy/intercept/{scripts.ts → scripts.js} +4 -13
  15. package/piggy/launch/{detect.ts → detect.js} +4 -6
  16. package/piggy/launch/{spawn.ts → spawn.js} +17 -22
  17. package/piggy/media/{index.ts → index.js} +13 -11
  18. package/piggy/navigation/{index.ts → index.js} +16 -14
  19. package/piggy/pool/index.js +76 -0
  20. package/piggy/provide/index.js +97 -0
  21. package/piggy/proxy/index.js +95 -0
  22. package/piggy/register/index.js +543 -0
  23. package/piggy/router/index.js +44 -0
  24. package/piggy/server/{index.ts → index.js} +16 -64
  25. package/piggy/session/index.js +69 -0
  26. package/piggy/store/{index.ts → index.js} +22 -62
  27. package/piggy/tabs/index.js +24 -0
  28. package/piggy/wait/index.js +77 -0
  29. package/{piggy.ts → piggy.js} +122 -146
  30. package/dist/cache/memory.js +0 -35
  31. package/dist/client/index.js +0 -1284
  32. package/dist/human/index.js +0 -82
  33. package/dist/launch/detect.js +0 -782
  34. package/dist/launch/spawn.js +0 -915
  35. package/dist/logger/index.js +0 -733
  36. package/dist/piggy/cache/memory.d.ts +0 -7
  37. package/dist/piggy/cache/memory.d.ts.map +0 -1
  38. package/dist/piggy/captcha/index.d.ts +0 -39
  39. package/dist/piggy/captcha/index.d.ts.map +0 -1
  40. package/dist/piggy/capture/index.d.ts +0 -48
  41. package/dist/piggy/capture/index.d.ts.map +0 -1
  42. package/dist/piggy/client/index.d.ts +0 -146
  43. package/dist/piggy/client/index.d.ts.map +0 -1
  44. package/dist/piggy/dialog/index.d.ts +0 -28
  45. package/dist/piggy/dialog/index.d.ts.map +0 -1
  46. package/dist/piggy/export/index.d.ts +0 -62
  47. package/dist/piggy/export/index.d.ts.map +0 -1
  48. package/dist/piggy/expose/index.d.ts +0 -6
  49. package/dist/piggy/expose/index.d.ts.map +0 -1
  50. package/dist/piggy/find/index.d.ts +0 -52
  51. package/dist/piggy/find/index.d.ts.map +0 -1
  52. package/dist/piggy/http/index.d.ts +0 -14
  53. package/dist/piggy/http/index.d.ts.map +0 -1
  54. package/dist/piggy/human/index.d.ts +0 -39
  55. package/dist/piggy/human/index.d.ts.map +0 -1
  56. package/dist/piggy/iframe/index.d.ts +0 -53
  57. package/dist/piggy/iframe/index.d.ts.map +0 -1
  58. package/dist/piggy/interactions/index.d.ts +0 -24
  59. package/dist/piggy/interactions/index.d.ts.map +0 -1
  60. package/dist/piggy/intercept/scripts.d.ts +0 -13
  61. package/dist/piggy/intercept/scripts.d.ts.map +0 -1
  62. package/dist/piggy/launch/detect.d.ts +0 -3
  63. package/dist/piggy/launch/detect.d.ts.map +0 -1
  64. package/dist/piggy/launch/spawn.d.ts +0 -6
  65. package/dist/piggy/launch/spawn.d.ts.map +0 -1
  66. package/dist/piggy/logger/index.d.ts +0 -3
  67. package/dist/piggy/logger/index.d.ts.map +0 -1
  68. package/dist/piggy/media/index.d.ts +0 -11
  69. package/dist/piggy/media/index.d.ts.map +0 -1
  70. package/dist/piggy/navigation/index.d.ts +0 -16
  71. package/dist/piggy/navigation/index.d.ts.map +0 -1
  72. package/dist/piggy/pool/index.d.ts +0 -23
  73. package/dist/piggy/pool/index.d.ts.map +0 -1
  74. package/dist/piggy/provide/index.d.ts +0 -98
  75. package/dist/piggy/provide/index.d.ts.map +0 -1
  76. package/dist/piggy/proxy/index.d.ts +0 -94
  77. package/dist/piggy/proxy/index.d.ts.map +0 -1
  78. package/dist/piggy/register/index.d.ts +0 -9
  79. package/dist/piggy/register/index.d.ts.map +0 -1
  80. package/dist/piggy/router/index.d.ts +0 -38
  81. package/dist/piggy/router/index.d.ts.map +0 -1
  82. package/dist/piggy/server/index.d.ts +0 -42
  83. package/dist/piggy/server/index.d.ts.map +0 -1
  84. package/dist/piggy/session/index.d.ts +0 -27
  85. package/dist/piggy/session/index.d.ts.map +0 -1
  86. package/dist/piggy/store/index.d.ts +0 -22
  87. package/dist/piggy/store/index.d.ts.map +0 -1
  88. package/dist/piggy/tabs/index.d.ts +0 -12
  89. package/dist/piggy/tabs/index.d.ts.map +0 -1
  90. package/dist/piggy/wait/index.d.ts +0 -28
  91. package/dist/piggy/wait/index.d.ts.map +0 -1
  92. package/dist/piggy.d.ts +0 -10
  93. package/dist/piggy.d.ts.map +0 -1
  94. package/dist/piggy.js +0 -30223
  95. package/dist/register/index.js +0 -23710
  96. package/dist/server/index.js +0 -26831
  97. package/piggy/capture/index.ts +0 -76
  98. package/piggy/export/index.d.ts +0 -117
  99. package/piggy/export/index.ts +0 -147
  100. package/piggy/expose/index.ts +0 -42
  101. package/piggy/iframe/index.ts +0 -79
  102. package/piggy/intercept/scripts.d.ts +0 -13
  103. package/piggy/intercept/scripts.d.ts.map +0 -1
  104. package/piggy/launch/detect.d.ts +0 -3
  105. package/piggy/launch/detect.d.ts.map +0 -1
  106. package/piggy/launch/spawn.d.ts +0 -6
  107. package/piggy/launch/spawn.d.ts.map +0 -1
  108. package/piggy/logger/index.d.ts +0 -3
  109. package/piggy/logger/index.d.ts.map +0 -1
  110. package/piggy/pool/index.d.ts +0 -12
  111. package/piggy/pool/index.ts +0 -75
  112. package/piggy/provide/index.ts +0 -170
  113. package/piggy/proxy/index.ts +0 -154
  114. package/piggy/register/index.ts +0 -575
  115. package/piggy/router/index.ts +0 -69
  116. package/piggy/session/index.ts +0 -76
  117. package/piggy/store/index.d.ts +0 -26
  118. package/piggy/tabs/index.ts +0 -23
  119. package/piggy/wait/index.ts +0 -90
  120. /package/piggy/logger/{index.ts → index.js} +0 -0
@@ -1,76 +0,0 @@
1
- // piggy/session/index.ts
2
- import { PiggyClient } from "../client";
3
- import type { CookieSetOptions, CookieDeleteOptions } from "../export";
4
-
5
- export interface SessionPaths {
6
- workDir: string;
7
- cookies: string;
8
- profile: string;
9
- ws: string;
10
- pings: string;
11
- }
12
-
13
- export class SessionClient {
14
- constructor(private client: PiggyClient) {}
15
-
16
- // Session lifecycle
17
- reload(tabId = "default"): Promise<void> {
18
- return this.client.send("session.reload", { tabId });
19
- }
20
-
21
- // Paths
22
- paths(): Promise<SessionPaths> {
23
- return this.client.send("session.paths", {});
24
- }
25
-
26
- cookiesPath(): Promise<string> {
27
- return this.client.send("session.cookies.path", {});
28
- }
29
-
30
- profilePath(): Promise<string> {
31
- return this.client.send("session.profile.path", {});
32
- }
33
-
34
- wsPath(): Promise<string> {
35
- return this.client.send("session.ws.path", {});
36
- }
37
-
38
- pingsPath(): Promise<string> {
39
- return this.client.send("session.pings.path", {});
40
- }
41
-
42
- // Opt-in persistence
43
- setWsSave(enabled: boolean): Promise<void> {
44
- return this.client.send("session.ws.save", { enabled });
45
- }
46
-
47
- setPingsSave(enabled: boolean): Promise<void> {
48
- return this.client.send("session.pings.save", { enabled });
49
- }
50
-
51
- // Export / import
52
- async export(tabId = "default"): Promise<any> {
53
- const raw = await this.client.send<string>("session.export", { tabId });
54
- return typeof raw === "string" ? JSON.parse(raw) : raw;
55
- }
56
-
57
- import(data: any, tabId = "default"): Promise<void> {
58
- return this.client.send("session.import", {
59
- data: JSON.stringify(data),
60
- tabId,
61
- });
62
- }
63
-
64
- // Cookies (using imported types from export)
65
- setCookie(opts: CookieSetOptions, tabId = "default"): Promise<void> {
66
- return this.client.send("cookie.set", { ...opts, tabId });
67
- }
68
-
69
- deleteCookie(opts: CookieDeleteOptions, tabId = "default"): Promise<void> {
70
- return this.client.send("cookie.delete", { ...opts, tabId });
71
- }
72
- }
73
-
74
- export function createSessionAPI(client: PiggyClient): SessionClient {
75
- return new SessionClient(client);
76
- }
@@ -1,26 +0,0 @@
1
- // piggy/store/index.d.ts
2
- export type FieldType = "string" | "number" | "boolean" | "object" | "array";
3
-
4
- export interface FieldSchema {
5
- type: FieldType;
6
- required?: boolean;
7
- default?: any;
8
- }
9
-
10
- export interface StoreSchema {
11
- name: string;
12
- destination: string;
13
- fields: Record<string, FieldSchema>;
14
- }
15
-
16
- export interface PiggyStoreConfig {
17
- stores: StoreSchema[];
18
- }
19
-
20
- export declare function loadStoreConfig(configPath?: string): PiggyStoreConfig;
21
- export declare function getSchema(storeName: string): StoreSchema | null;
22
- export declare function shapeRecord(data: Record<string, any>, schema: StoreSchema): Record<string, any>;
23
- export declare function storeRecord(
24
- storeName: string,
25
- data: Record<string, any> | Record<string, any>[]
26
- ): Promise<{ stored: number; skipped: number }>;
@@ -1,23 +0,0 @@
1
- // piggy/tabs/index.ts
2
- import { PiggyClient } from "../client";
3
-
4
- export class TabsClient {
5
- constructor(private client: PiggyClient) {}
6
-
7
- new(): Promise<string> {
8
- return this.client.send("tab.new", {});
9
- }
10
-
11
- close(opts: string | { tabId: string }): Promise<void> {
12
- const tabId = typeof opts === "string" ? opts : opts.tabId;
13
- return this.client.send("tab.close", { tabId });
14
- }
15
-
16
- list(): Promise<string[]> {
17
- return this.client.send("tab.list", {});
18
- }
19
- }
20
-
21
- export function createTabsAPI(client: PiggyClient): TabsClient {
22
- return new TabsClient(client);
23
- }
@@ -1,90 +0,0 @@
1
- // piggy/wait/index.ts
2
- import { PiggyClient } from "../client";
3
-
4
- export type WaitSelectorState = "attached" | "detached" | "visible" | "hidden";
5
-
6
- // ─── WaitClient ───────────────────────────────────────────────────────────────
7
- // Maps to PiggyWait.cpp
8
-
9
- export class WaitClient {
10
- constructor(private client: PiggyClient) {}
11
-
12
- // wait.function — poll every 100ms until JS expr is truthy
13
- function(js: string, timeout = 10000, tabId = "default"): Promise<void> {
14
- return this.client.send("wait.function", { js, timeout, tabId });
15
- }
16
-
17
- // wait.selector — with full state support (attached|detached|visible|hidden)
18
- selector(
19
- selector: string,
20
- state: WaitSelectorState = "attached",
21
- timeout = 10000,
22
- tabId = "default"
23
- ): Promise<void> {
24
- return this.client.send("wait.selector", { selector, state, timeout, tabId });
25
- }
26
- }
27
-
28
- // ─── EvaluateClient ───────────────────────────────────────────────────────────
29
- // Maps to the evaluate command in PiggyWait.cpp (with timeout support)
30
- // and PiggyInteractions.cpp (without timeout)
31
-
32
- export class EvaluateClient {
33
- constructor(private client: PiggyClient) {}
34
-
35
- // evaluate with optional wall-clock timeout
36
- run(js: string, timeout?: number, tabId = "default"): Promise<unknown> {
37
- return this.client.send("evaluate", {
38
- js,
39
- tabId,
40
- ...(timeout !== undefined ? { timeout } : {}),
41
- });
42
- }
43
- }
44
-
45
- // ─── FetchClient ──────────────────────────────────────────────────────────────
46
- // Maps to fetch.textAll / fetch.attr / fetch.attrAll in PiggyWait.cpp
47
- // and fetch.text / fetch.links / fetch.image in PiggyExport.cpp
48
-
49
- export class FetchClient {
50
- constructor(private client: PiggyClient) {}
51
-
52
- // fetch.text — single element innerText
53
- text(selector: string, tabId = "default"): Promise<string | null> {
54
- return this.client.send("fetch.text", { query: selector, tabId });
55
- }
56
-
57
- // fetch.textAll — all matching elements innerText
58
- textAll(selector: string, tabId = "default"): Promise<string[]> {
59
- return this.client.send("fetch.textAll", { selector, tabId });
60
- }
61
-
62
- // fetch.attr — single attribute from first match
63
- attr(selector: string, attr: string, tabId = "default"): Promise<string | null> {
64
- return this.client.send("fetch.attr", { selector, attr, tabId });
65
- }
66
-
67
- // fetch.attrAll — attribute from all matches
68
- attrAll(selector: string, attr: string, tabId = "default"): Promise<string[]> {
69
- return this.client.send("fetch.attrAll", { selector, attr, tabId });
70
- }
71
-
72
- // fetch.links — links inside a selector
73
- links(selector: string, tabId = "default"): Promise<string[]> {
74
- return this.client.send("fetch.links", { query: selector, tabId });
75
- }
76
-
77
- // fetch.links.all — all links on page
78
- linksAll(tabId = "default"): Promise<string[]> {
79
- return this.client.send("fetch.links.all", { tabId });
80
- }
81
-
82
- // fetch.image — images inside a selector
83
- images(selector: string, tabId = "default"): Promise<string[]> {
84
- return this.client.send("fetch.image", { query: selector, tabId });
85
- }
86
- }
87
-
88
- export function createWaitAPI(client: PiggyClient): WaitClient { return new WaitClient(client); }
89
- export function createEvaluateAPI(client: PiggyClient): EvaluateClient { return new EvaluateClient(client); }
90
- export function createFetchAPI(client: PiggyClient): FetchClient { return new FetchClient(client); }
File without changes