nothing-browser 0.1.2 → 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.
- package/package.json +14 -26
- package/piggy/cache/{memory.ts → memory.js} +5 -10
- package/piggy/captcha/{index.ts → index.js} +19 -28
- package/piggy/capture/index.js +40 -0
- package/piggy/client/{index.ts → index.js} +133 -154
- package/piggy/dialog/{index.ts → index.js} +15 -31
- package/piggy/export/index.js +105 -0
- package/piggy/expose/index.js +24 -0
- package/piggy/find/{index.ts → index.js} +24 -39
- package/piggy/http/{index.ts → index.js} +7 -16
- package/piggy/human/{index.ts → index.js} +18 -49
- package/piggy/iframe/index.js +56 -0
- package/piggy/interactions/{index.ts → index.js} +20 -23
- package/piggy/intercept/{scripts.ts → scripts.js} +4 -13
- package/piggy/launch/{detect.ts → detect.js} +4 -6
- package/piggy/launch/{spawn.ts → spawn.js} +17 -22
- package/piggy/media/{index.ts → index.js} +13 -11
- package/piggy/navigation/{index.ts → index.js} +16 -14
- package/piggy/pool/index.js +76 -0
- package/piggy/provide/index.js +97 -0
- package/piggy/proxy/index.js +95 -0
- package/piggy/register/index.js +543 -0
- package/piggy/router/index.js +44 -0
- package/piggy/server/{index.ts → index.js} +16 -64
- package/piggy/session/index.js +69 -0
- package/piggy/store/{index.ts → index.js} +22 -62
- package/piggy/tabs/index.js +24 -0
- package/piggy/wait/index.js +77 -0
- package/piggy.js +316 -0
- package/dist/cache/memory.js +0 -35
- package/dist/client/index.js +0 -1284
- package/dist/human/index.js +0 -82
- package/dist/launch/detect.js +0 -782
- package/dist/launch/spawn.js +0 -915
- package/dist/logger/index.js +0 -733
- package/dist/piggy/cache/memory.d.ts +0 -7
- package/dist/piggy/cache/memory.d.ts.map +0 -1
- package/dist/piggy/captcha/index.d.ts +0 -39
- package/dist/piggy/captcha/index.d.ts.map +0 -1
- package/dist/piggy/capture/index.d.ts +0 -48
- package/dist/piggy/capture/index.d.ts.map +0 -1
- package/dist/piggy/client/index.d.ts +0 -146
- package/dist/piggy/client/index.d.ts.map +0 -1
- package/dist/piggy/dialog/index.d.ts +0 -28
- package/dist/piggy/dialog/index.d.ts.map +0 -1
- package/dist/piggy/export/index.d.ts +0 -62
- package/dist/piggy/export/index.d.ts.map +0 -1
- package/dist/piggy/expose/index.d.ts +0 -6
- package/dist/piggy/expose/index.d.ts.map +0 -1
- package/dist/piggy/find/index.d.ts +0 -52
- package/dist/piggy/find/index.d.ts.map +0 -1
- package/dist/piggy/http/index.d.ts +0 -14
- package/dist/piggy/http/index.d.ts.map +0 -1
- package/dist/piggy/human/index.d.ts +0 -39
- package/dist/piggy/human/index.d.ts.map +0 -1
- package/dist/piggy/iframe/index.d.ts +0 -53
- package/dist/piggy/iframe/index.d.ts.map +0 -1
- package/dist/piggy/interactions/index.d.ts +0 -24
- package/dist/piggy/interactions/index.d.ts.map +0 -1
- package/dist/piggy/intercept/scripts.d.ts +0 -13
- package/dist/piggy/intercept/scripts.d.ts.map +0 -1
- package/dist/piggy/launch/detect.d.ts +0 -3
- package/dist/piggy/launch/detect.d.ts.map +0 -1
- package/dist/piggy/launch/spawn.d.ts +0 -6
- package/dist/piggy/launch/spawn.d.ts.map +0 -1
- package/dist/piggy/logger/index.d.ts +0 -3
- package/dist/piggy/logger/index.d.ts.map +0 -1
- package/dist/piggy/media/index.d.ts +0 -11
- package/dist/piggy/media/index.d.ts.map +0 -1
- package/dist/piggy/navigation/index.d.ts +0 -16
- package/dist/piggy/navigation/index.d.ts.map +0 -1
- package/dist/piggy/pool/index.d.ts +0 -23
- package/dist/piggy/pool/index.d.ts.map +0 -1
- package/dist/piggy/provide/index.d.ts +0 -98
- package/dist/piggy/provide/index.d.ts.map +0 -1
- package/dist/piggy/proxy/index.d.ts +0 -94
- package/dist/piggy/proxy/index.d.ts.map +0 -1
- package/dist/piggy/register/index.d.ts +0 -9
- package/dist/piggy/register/index.d.ts.map +0 -1
- package/dist/piggy/router/index.d.ts +0 -38
- package/dist/piggy/router/index.d.ts.map +0 -1
- package/dist/piggy/server/index.d.ts +0 -42
- package/dist/piggy/server/index.d.ts.map +0 -1
- package/dist/piggy/session/index.d.ts +0 -27
- package/dist/piggy/session/index.d.ts.map +0 -1
- package/dist/piggy/store/index.d.ts +0 -22
- package/dist/piggy/store/index.d.ts.map +0 -1
- package/dist/piggy/tabs/index.d.ts +0 -12
- package/dist/piggy/tabs/index.d.ts.map +0 -1
- package/dist/piggy/wait/index.d.ts +0 -28
- package/dist/piggy/wait/index.d.ts.map +0 -1
- package/dist/piggy.d.ts +0 -10
- package/dist/piggy.d.ts.map +0 -1
- package/dist/piggy.js +0 -30186
- package/dist/register/index.js +0 -23710
- package/dist/server/index.js +0 -26831
- package/piggy/capture/index.ts +0 -76
- package/piggy/export/index.d.ts +0 -117
- package/piggy/export/index.ts +0 -147
- package/piggy/expose/index.ts +0 -42
- package/piggy/iframe/index.ts +0 -79
- package/piggy/intercept/scripts.d.ts +0 -13
- package/piggy/intercept/scripts.d.ts.map +0 -1
- package/piggy/launch/detect.d.ts +0 -3
- package/piggy/launch/detect.d.ts.map +0 -1
- package/piggy/launch/spawn.d.ts +0 -6
- package/piggy/launch/spawn.d.ts.map +0 -1
- package/piggy/logger/index.d.ts +0 -3
- package/piggy/logger/index.d.ts.map +0 -1
- package/piggy/pool/index.d.ts +0 -12
- package/piggy/pool/index.ts +0 -75
- package/piggy/provide/index.ts +0 -170
- package/piggy/proxy/index.ts +0 -154
- package/piggy/register/index.ts +0 -575
- package/piggy/router/index.ts +0 -69
- package/piggy/session/index.ts +0 -76
- package/piggy/store/index.d.ts +0 -26
- package/piggy/tabs/index.ts +0 -23
- package/piggy/wait/index.ts +0 -90
- package/piggy.ts +0 -274
- /package/piggy/logger/{index.ts → index.js} +0 -0
package/piggy/provide/index.ts
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
// piggy/provide/index.ts
|
|
2
|
-
import { PiggyClient } from "../client";
|
|
3
|
-
|
|
4
|
-
// ─── Shared base option ───────────────────────────────────────────────────────
|
|
5
|
-
// Every provide method targets a selector, and optionally scopes under a parent.
|
|
6
|
-
|
|
7
|
-
export interface ProvideOptions {
|
|
8
|
-
/** CSS selector for the target element(s). */
|
|
9
|
-
selector: string;
|
|
10
|
-
/**
|
|
11
|
-
* Optional parent selector to scope the query under.
|
|
12
|
-
* Equivalent to: parent.querySelector(selector)
|
|
13
|
-
*/
|
|
14
|
-
parent?: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface ProvideAttrOptions extends ProvideOptions {
|
|
18
|
-
/** The attribute name to extract. */
|
|
19
|
-
attr: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface ProvideListOptions extends ProvideOptions {
|
|
23
|
-
/** Optional child selector to scope list items. */
|
|
24
|
-
itemSel?: string;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// ─── Return types ─────────────────────────────────────────────────────────────
|
|
28
|
-
|
|
29
|
-
export interface ProvideTable {
|
|
30
|
-
headers: string[];
|
|
31
|
-
rows: string[][];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface ProvideLink {
|
|
35
|
-
text: string;
|
|
36
|
-
href: string;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export interface ProvideImage {
|
|
40
|
-
alt: string;
|
|
41
|
-
src: string;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface ProvideForm {
|
|
45
|
-
[name: string]: string;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export interface ProvidePage {
|
|
49
|
-
title: string;
|
|
50
|
-
url: string;
|
|
51
|
-
html: string;
|
|
52
|
-
text: string;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export interface ProvideDiv {
|
|
56
|
-
tag: string;
|
|
57
|
-
id: string;
|
|
58
|
-
cls: string;
|
|
59
|
-
text: string;
|
|
60
|
-
html: string;
|
|
61
|
-
children: ProvideDiv[];
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export interface ProvideMeta {
|
|
65
|
-
[name: string]: string;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export interface ProvideSelectOption {
|
|
69
|
-
text: string;
|
|
70
|
-
value: string;
|
|
71
|
-
selected: boolean;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export interface ProvideSelect {
|
|
75
|
-
value: string;
|
|
76
|
-
options: ProvideSelectOption[];
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// ─── ProvideClient ────────────────────────────────────────────────────────────
|
|
80
|
-
// provide answers ONE question: "give me the actual value from this element."
|
|
81
|
-
// All methods take an options object { selector, parent? } so scoping is consistent.
|
|
82
|
-
// If you just want to know if something exists, use find instead.
|
|
83
|
-
|
|
84
|
-
export class ProvideClient {
|
|
85
|
-
constructor(private client: PiggyClient) {}
|
|
86
|
-
|
|
87
|
-
/** innerText of the first matched element. */
|
|
88
|
-
text(opts: ProvideOptions, tabId = "default"): Promise<string> {
|
|
89
|
-
return this.client.send("provide.text", { ...opts, tabId });
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/** innerText of all matched elements. */
|
|
93
|
-
textAll(opts: ProvideOptions, tabId = "default"): Promise<string[]> {
|
|
94
|
-
return this.client.send("provide.textAll", { ...opts, tabId });
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/** Single attribute value from the first matched element. */
|
|
98
|
-
attr(opts: ProvideAttrOptions, tabId = "default"): Promise<string> {
|
|
99
|
-
return this.client.send("provide.attr", { ...opts, tabId });
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/** Attribute value from all matched elements. */
|
|
103
|
-
attrAll(opts: ProvideAttrOptions, tabId = "default"): Promise<string[]> {
|
|
104
|
-
return this.client.send("provide.attrAll", { ...opts, tabId });
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/** innerHTML of the first matched element. */
|
|
108
|
-
html(opts: ProvideOptions, tabId = "default"): Promise<string> {
|
|
109
|
-
return this.client.send("provide.html", { ...opts, tabId });
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/** Extract a table into headers + rows. */
|
|
113
|
-
table(opts: ProvideOptions, tabId = "default"): Promise<ProvideTable> {
|
|
114
|
-
return this.client.send("provide.table", { ...opts, tabId });
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/** Extract a list of text items, optionally scoped to child items. */
|
|
118
|
-
list(opts: ProvideListOptions, tabId = "default"): Promise<string[]> {
|
|
119
|
-
return this.client.send("provide.list", { ...opts, tabId });
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/** All links inside the matched selector. */
|
|
123
|
-
links(opts: ProvideOptions, tabId = "default"): Promise<ProvideLink[]> {
|
|
124
|
-
return this.client.send("provide.links", { ...opts, tabId });
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/** All images inside the matched selector. */
|
|
128
|
-
images(opts: ProvideOptions, tabId = "default"): Promise<ProvideImage[]> {
|
|
129
|
-
return this.client.send("provide.images", { ...opts, tabId });
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/** Form field name→value map. */
|
|
133
|
-
form(opts: ProvideOptions, tabId = "default"): Promise<ProvideForm> {
|
|
134
|
-
return this.client.send("provide.form", { ...opts, tabId });
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/** Full page info: title, url, html, text. No selector needed. */
|
|
138
|
-
page(tabId = "default"): Promise<ProvidePage> {
|
|
139
|
-
return this.client.send("provide.page", { tabId });
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/** Structured div tree: tag, id, cls, text, html, children[]. */
|
|
143
|
-
div(opts: ProvideOptions, tabId = "default"): Promise<ProvideDiv> {
|
|
144
|
-
return this.client.send("provide.div", { ...opts, tabId });
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/** All <meta> name→content pairs. No selector needed. */
|
|
148
|
-
meta(tabId = "default"): Promise<ProvideMeta> {
|
|
149
|
-
return this.client.send("provide.meta", { tabId });
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/** <select> current value + all options. */
|
|
153
|
-
select(opts: ProvideOptions, tabId = "default"): Promise<ProvideSelect> {
|
|
154
|
-
return this.client.send("provide.select", { ...opts, tabId });
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Parse JSON from element innerText or script[type=application/json].
|
|
159
|
-
* selector is optional — defaults to the first matching JSON script tag.
|
|
160
|
-
*/
|
|
161
|
-
json(opts?: Partial<ProvideOptions>, tabId = "default"): Promise<unknown> {
|
|
162
|
-
return this.client.send("provide.json", { ...opts, tabId });
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// ─── Factory helper ───────────────────────────────────────────────────────────
|
|
167
|
-
|
|
168
|
-
export function createProvideAPI(client: PiggyClient): ProvideClient {
|
|
169
|
-
return new ProvideClient(client);
|
|
170
|
-
}
|
package/piggy/proxy/index.ts
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
// piggy/proxy/index.ts
|
|
2
|
-
import { PiggyClient } from "../client";
|
|
3
|
-
|
|
4
|
-
// ─── Types ────────────────────────────────────────────────────────────────────
|
|
5
|
-
|
|
6
|
-
export type ProxyType = "http" | "https" | "socks5";
|
|
7
|
-
export type ProxyHealth = "alive" | "dead" | "checking" | "unchecked";
|
|
8
|
-
export type RotationMode = "none" | "timed" | "perrequest";
|
|
9
|
-
|
|
10
|
-
export interface ProxyEntry {
|
|
11
|
-
index: number;
|
|
12
|
-
host: string;
|
|
13
|
-
port: number;
|
|
14
|
-
type: ProxyType;
|
|
15
|
-
user: string;
|
|
16
|
-
proxy: string; // full string e.g. "socks5://user:pass@host:port"
|
|
17
|
-
latency: number;
|
|
18
|
-
health: ProxyHealth;
|
|
19
|
-
current: boolean;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface ProxyStats {
|
|
23
|
-
total: number;
|
|
24
|
-
alive: number;
|
|
25
|
-
dead: number;
|
|
26
|
-
index: number;
|
|
27
|
-
active: boolean;
|
|
28
|
-
checking: boolean;
|
|
29
|
-
skipDead: boolean;
|
|
30
|
-
autoCheck: boolean;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface ProxyListResult {
|
|
34
|
-
proxies: ProxyEntry[];
|
|
35
|
-
total: number;
|
|
36
|
-
shown: number;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export interface ProxyCurrent {
|
|
40
|
-
active: boolean;
|
|
41
|
-
host?: string;
|
|
42
|
-
port?: number;
|
|
43
|
-
type?: ProxyType;
|
|
44
|
-
user?: string;
|
|
45
|
-
proxy?: string;
|
|
46
|
-
latency?: number;
|
|
47
|
-
health?: ProxyHealth;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export interface ProxyConfig {
|
|
51
|
-
skipDead: boolean;
|
|
52
|
-
autoCheck: boolean;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// ─── Inline set options ───────────────────────────────────────────────────────
|
|
56
|
-
|
|
57
|
-
export type ProxySetOptions =
|
|
58
|
-
| { proxy: string }
|
|
59
|
-
| { host: string; port: number; type?: ProxyType; user?: string; pass?: string };
|
|
60
|
-
|
|
61
|
-
// ─── ProxyClient ──────────────────────────────────────────────────────────────
|
|
62
|
-
|
|
63
|
-
export class ProxyClient {
|
|
64
|
-
constructor(private client: PiggyClient) {}
|
|
65
|
-
|
|
66
|
-
/** Load proxies from a local file path. */
|
|
67
|
-
load(path: string): Promise<void> {
|
|
68
|
-
return this.client.send("proxy.load", { path });
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/** Fetch proxies from a URL. Result comes via proxy:loaded / proxy:fetch:failed events. */
|
|
72
|
-
fetch(url: string): Promise<void> {
|
|
73
|
-
return this.client.send("proxy.fetch", { url });
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/** Load an .ovpn config file. */
|
|
77
|
-
ovpn(path: string): Promise<void> {
|
|
78
|
-
return this.client.send("proxy.ovpn", { path });
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/** Set a single proxy inline. */
|
|
82
|
-
set(opts: ProxySetOptions): Promise<void> {
|
|
83
|
-
return this.client.send("proxy.set", opts);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/** Health-check all loaded proxies. Results come via events. */
|
|
87
|
-
test(): Promise<void> {
|
|
88
|
-
return this.client.send("proxy.test", {});
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/** Abort an in-progress health check. */
|
|
92
|
-
testStop(): Promise<void> {
|
|
93
|
-
return this.client.send("proxy.test.stop", {});
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/** Rotate to the next proxy in the pool. */
|
|
97
|
-
next(): Promise<string> {
|
|
98
|
-
return this.client.send("proxy.next", {});
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/** Alias for next(). */
|
|
102
|
-
rotate(): Promise<string> {
|
|
103
|
-
return this.client.send("proxy.rotate", {});
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/** Disable the proxy — use the real IP. */
|
|
107
|
-
disable(): Promise<void> {
|
|
108
|
-
return this.client.send("proxy.disable", {});
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/** Re-enable the current proxy. */
|
|
112
|
-
enable(): Promise<void> {
|
|
113
|
-
return this.client.send("proxy.enable", {});
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/** Get the current active proxy details. */
|
|
117
|
-
current(): Promise<ProxyCurrent> {
|
|
118
|
-
return this.client.send("proxy.current", {});
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/** Get pool stats: total, alive, dead, index, active, checking. */
|
|
122
|
-
stats(): Promise<ProxyStats> {
|
|
123
|
-
return this.client.send("proxy.stats", {});
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/** List all proxies with health info. limit defaults to 500. */
|
|
127
|
-
list(limit?: number): Promise<ProxyListResult> {
|
|
128
|
-
return this.client.send("proxy.list", { limit });
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/** Set rotation mode and interval (seconds, only used for "timed"). */
|
|
132
|
-
rotation(mode: RotationMode, interval?: number): Promise<void> {
|
|
133
|
-
return this.client.send("proxy.rotation", { mode, interval });
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/** Set skipDead / autoCheck flags. */
|
|
137
|
-
config(opts: Partial<ProxyConfig>): Promise<ProxyConfig> {
|
|
138
|
-
return this.client.send("proxy.config", opts);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Save the current proxy list to a file.
|
|
143
|
-
* filter: "all" | "alive" | "dead" — defaults to "all".
|
|
144
|
-
*/
|
|
145
|
-
save(path: string, filter?: "all" | "alive" | "dead"): Promise<void> {
|
|
146
|
-
return this.client.send("proxy.save", { path, filter });
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// ─── Factory helper ───────────────────────────────────────────────────────────
|
|
151
|
-
|
|
152
|
-
export function createProxyAPI(client: PiggyClient): ProxyClient {
|
|
153
|
-
return new ProxyClient(client);
|
|
154
|
-
}
|