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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nothing-browser",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Browser automation library powered by Nothing Browser",
|
|
5
5
|
"homepage": "https://github.com/ernest-tech-house-co-operation/nothing-browser#readme",
|
|
6
6
|
"repository": {
|
|
@@ -16,37 +16,28 @@
|
|
|
16
16
|
"url": "https://github.com/ernest-tech-house-co-operation"
|
|
17
17
|
},
|
|
18
18
|
"license": "MIT",
|
|
19
|
-
"main": "./
|
|
20
|
-
"types": "./dist/piggy.d.ts",
|
|
19
|
+
"main": "./piggy.js",
|
|
21
20
|
"exports": {
|
|
22
21
|
".": {
|
|
23
|
-
"bun": "./piggy.
|
|
24
|
-
"node": "./
|
|
25
|
-
"default": "./
|
|
26
|
-
"types": "./dist/piggy.d.ts"
|
|
22
|
+
"bun": "./piggy.js",
|
|
23
|
+
"node": "./piggy.js",
|
|
24
|
+
"default": "./piggy.js"
|
|
27
25
|
},
|
|
28
26
|
"./register": {
|
|
29
|
-
"bun": "./piggy/register/index.
|
|
30
|
-
"node": "./
|
|
31
|
-
"types": "./dist/register/index.d.ts"
|
|
27
|
+
"bun": "./piggy/register/index.js",
|
|
28
|
+
"node": "./piggy/register/index.js"
|
|
32
29
|
},
|
|
33
30
|
"./server": {
|
|
34
|
-
"bun": "./piggy/server/index.
|
|
35
|
-
"node": "./
|
|
36
|
-
"types": "./dist/server/index.d.ts"
|
|
31
|
+
"bun": "./piggy/server/index.js",
|
|
32
|
+
"node": "./piggy/server/index.js"
|
|
37
33
|
},
|
|
38
34
|
"./logger": {
|
|
39
|
-
"bun": "./piggy/logger/index.
|
|
40
|
-
"node": "./
|
|
41
|
-
"types": "./dist/logger/index.d.ts"
|
|
35
|
+
"bun": "./piggy/logger/index.js",
|
|
36
|
+
"node": "./piggy/logger/index.js"
|
|
42
37
|
}
|
|
43
38
|
},
|
|
44
39
|
"scripts": {
|
|
45
|
-
"clean": "rm -rf dist"
|
|
46
|
-
"build:types": "tsc --project tsconfig.json --emitDeclarationOnly --outDir dist",
|
|
47
|
-
"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",
|
|
48
|
-
"build": "bun run clean && bun run build:types && bun run build:js",
|
|
49
|
-
"prepublishOnly": "bun run build"
|
|
40
|
+
"clean": "rm -rf dist"
|
|
50
41
|
},
|
|
51
42
|
"dependencies": {
|
|
52
43
|
"@elysiajs/openapi": "^1.4.15",
|
|
@@ -58,17 +49,14 @@
|
|
|
58
49
|
"elysia": "^1.0.0"
|
|
59
50
|
},
|
|
60
51
|
"devDependencies": {
|
|
61
|
-
"@types/node": "^20.0.0"
|
|
62
|
-
"bun-types": "latest",
|
|
63
|
-
"typescript": "^6.0.3"
|
|
52
|
+
"@types/node": "^20.0.0"
|
|
64
53
|
},
|
|
65
54
|
"engines": {
|
|
66
55
|
"node": ">=18.0.0",
|
|
67
56
|
"bun": ">=1.0.0"
|
|
68
57
|
},
|
|
69
58
|
"files": [
|
|
70
|
-
"
|
|
71
|
-
"piggy.ts",
|
|
59
|
+
"piggy.js",
|
|
72
60
|
"piggy",
|
|
73
61
|
"README.md",
|
|
74
62
|
"nothing_browser_pig_pink.svg"
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
// piggy/cache/memory.
|
|
1
|
+
// piggy/cache/memory.js
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
data: any;
|
|
5
|
-
expires: number;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const store = new Map<string, CacheEntry>();
|
|
3
|
+
const store = new Map();
|
|
9
4
|
|
|
10
|
-
export function get(key
|
|
5
|
+
export function get(key) {
|
|
11
6
|
const entry = store.get(key);
|
|
12
7
|
if (!entry) return null;
|
|
13
8
|
if (Date.now() > entry.expires) {
|
|
@@ -17,11 +12,11 @@ export function get(key: string): any | null {
|
|
|
17
12
|
return entry.data;
|
|
18
13
|
}
|
|
19
14
|
|
|
20
|
-
export function set(key
|
|
15
|
+
export function set(key, data, ttlMs) {
|
|
21
16
|
store.set(key, { data, expires: Date.now() + ttlMs });
|
|
22
17
|
}
|
|
23
18
|
|
|
24
|
-
export function del(key
|
|
19
|
+
export function del(key) {
|
|
25
20
|
store.delete(key);
|
|
26
21
|
}
|
|
27
22
|
|
|
@@ -1,74 +1,65 @@
|
|
|
1
|
-
// piggy/captcha/index.
|
|
2
|
-
import { PiggyClient } from "../client";
|
|
3
|
-
import logger from "../logger";
|
|
4
|
-
|
|
5
|
-
export interface CaptchaState {
|
|
6
|
-
detected: boolean;
|
|
7
|
-
paused: boolean;
|
|
8
|
-
type: string; // "cloudflare" | "recaptcha" | "hcaptcha" | "generic"
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface BlockState {
|
|
12
|
-
detected: boolean;
|
|
13
|
-
type: string; // "403" | "access-denied" | "firewall" | "rate-limit"
|
|
14
|
-
}
|
|
1
|
+
// piggy/captcha/index.js
|
|
2
|
+
import { PiggyClient } from "../client.js";
|
|
3
|
+
import logger from "../logger.js";
|
|
15
4
|
|
|
16
5
|
export class CaptchaClient {
|
|
17
|
-
constructor(
|
|
6
|
+
constructor(client) {
|
|
7
|
+
this.client = client;
|
|
8
|
+
}
|
|
18
9
|
|
|
19
10
|
// ── Captcha ───────────────────────────────────────────────────────────────
|
|
20
11
|
|
|
21
|
-
status(tabId = "default")
|
|
12
|
+
status(tabId = "default") {
|
|
22
13
|
return this.client.send("captcha.status", { tabId });
|
|
23
14
|
}
|
|
24
15
|
|
|
25
|
-
resolve(tabId = "default")
|
|
16
|
+
resolve(tabId = "default") {
|
|
26
17
|
return this.client.send("captcha.resolve", { tabId });
|
|
27
18
|
}
|
|
28
19
|
|
|
29
|
-
pause(tabId = "default")
|
|
20
|
+
pause(tabId = "default") {
|
|
30
21
|
return this.client.send("captcha.pause", { tabId });
|
|
31
22
|
}
|
|
32
23
|
|
|
33
|
-
check(tabId = "default")
|
|
24
|
+
check(tabId = "default") {
|
|
34
25
|
return this.client.send("captcha.check", { tabId });
|
|
35
26
|
}
|
|
36
27
|
|
|
37
|
-
setAutoRetry(enabled
|
|
28
|
+
setAutoRetry(enabled) {
|
|
38
29
|
return this.client.send("captcha.autoRetry", { enabled });
|
|
39
30
|
}
|
|
40
31
|
|
|
41
32
|
// ── Block ─────────────────────────────────────────────────────────────────
|
|
42
33
|
|
|
43
|
-
blockStatus(tabId = "default")
|
|
34
|
+
blockStatus(tabId = "default") {
|
|
44
35
|
return this.client.send("block.status", { tabId });
|
|
45
36
|
}
|
|
46
37
|
|
|
47
|
-
blockRetry(tabId = "default")
|
|
38
|
+
blockRetry(tabId = "default") {
|
|
48
39
|
return this.client.send("block.retry", { tabId });
|
|
49
40
|
}
|
|
50
41
|
|
|
51
42
|
// ── Event subscriptions ───────────────────────────────────────────────────
|
|
52
43
|
|
|
53
|
-
onCaptcha(tabId
|
|
44
|
+
onCaptcha(tabId, handler) {
|
|
54
45
|
return this.client.onEvent("captcha", tabId, handler);
|
|
55
46
|
}
|
|
56
47
|
|
|
57
|
-
onCaptchaResolved(tabId
|
|
48
|
+
onCaptchaResolved(tabId, handler) {
|
|
58
49
|
return this.client.onEvent("captcha:resolved", tabId, handler);
|
|
59
50
|
}
|
|
60
51
|
|
|
61
|
-
onBlocked(tabId
|
|
52
|
+
onBlocked(tabId, handler) {
|
|
62
53
|
return this.client.onEvent("blocked", tabId, handler);
|
|
63
54
|
}
|
|
64
55
|
|
|
65
|
-
onBlockRetry(tabId
|
|
56
|
+
onBlockRetry(tabId, handler) {
|
|
66
57
|
return this.client.onEvent("block:retry", tabId, handler);
|
|
67
58
|
}
|
|
68
59
|
|
|
69
60
|
// ── Convenience: wait until captcha is resolved ───────────────────────────
|
|
70
61
|
|
|
71
|
-
waitForResolution(tabId = "default", timeoutMs = 300_000)
|
|
62
|
+
waitForResolution(tabId = "default", timeoutMs = 300_000) {
|
|
72
63
|
return new Promise((resolve, reject) => {
|
|
73
64
|
const timer = setTimeout(() => {
|
|
74
65
|
unsub();
|
|
@@ -88,6 +79,6 @@ export class CaptchaClient {
|
|
|
88
79
|
|
|
89
80
|
// ── Factory helper so site objects can expose a .captcha sub-namespace ────────
|
|
90
81
|
|
|
91
|
-
export function createCaptchaAPI(client
|
|
82
|
+
export function createCaptchaAPI(client) {
|
|
92
83
|
return new CaptchaClient(client);
|
|
93
84
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// piggy/capture/index.js
|
|
2
|
+
import { PiggyClient } from "../client.js";
|
|
3
|
+
|
|
4
|
+
export class CaptureClient {
|
|
5
|
+
constructor(client) {
|
|
6
|
+
this.client = client;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
start(tabId = "default") {
|
|
10
|
+
return this.client.send("capture.start", { tabId });
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
stop(tabId = "default") {
|
|
14
|
+
return this.client.send("capture.stop", { tabId });
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
requests(tabId = "default") {
|
|
18
|
+
return this.client.send("capture.requests", { tabId });
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
ws(tabId = "default") {
|
|
22
|
+
return this.client.send("capture.ws", { tabId });
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
cookies(tabId = "default") {
|
|
26
|
+
return this.client.send("capture.cookies", { tabId });
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
storage(tabId = "default") {
|
|
30
|
+
return this.client.send("capture.storage", { tabId });
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
clear(tabId = "default") {
|
|
34
|
+
return this.client.send("capture.clear", { tabId });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function createCaptureAPI(client) {
|
|
39
|
+
return new CaptureClient(client);
|
|
40
|
+
}
|