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.
Files changed (121) 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.js +316 -0
  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 -30186
  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.ts +0 -274
  121. /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.2",
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": "./dist/piggy.js",
20
- "types": "./dist/piggy.d.ts",
19
+ "main": "./piggy.js",
21
20
  "exports": {
22
21
  ".": {
23
- "bun": "./piggy.ts",
24
- "node": "./dist/piggy.js",
25
- "default": "./dist/piggy.js",
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.ts",
30
- "node": "./dist/register/index.js",
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.ts",
35
- "node": "./dist/server/index.js",
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.ts",
40
- "node": "./dist/logger/index.js",
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
- "dist",
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.ts
1
+ // piggy/cache/memory.js
2
2
 
3
- interface CacheEntry {
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: string): any | null {
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: string, data: any, ttlMs: number) {
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: string) {
19
+ export function del(key) {
25
20
  store.delete(key);
26
21
  }
27
22
 
@@ -1,74 +1,65 @@
1
- // piggy/captcha/index.ts
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(private client: PiggyClient) {}
6
+ constructor(client) {
7
+ this.client = client;
8
+ }
18
9
 
19
10
  // ── Captcha ───────────────────────────────────────────────────────────────
20
11
 
21
- status(tabId = "default"): Promise<CaptchaState> {
12
+ status(tabId = "default") {
22
13
  return this.client.send("captcha.status", { tabId });
23
14
  }
24
15
 
25
- resolve(tabId = "default"): Promise<void> {
16
+ resolve(tabId = "default") {
26
17
  return this.client.send("captcha.resolve", { tabId });
27
18
  }
28
19
 
29
- pause(tabId = "default"): Promise<void> {
20
+ pause(tabId = "default") {
30
21
  return this.client.send("captcha.pause", { tabId });
31
22
  }
32
23
 
33
- check(tabId = "default"): Promise<void> {
24
+ check(tabId = "default") {
34
25
  return this.client.send("captcha.check", { tabId });
35
26
  }
36
27
 
37
- setAutoRetry(enabled: boolean): Promise<void> {
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"): Promise<BlockState> {
34
+ blockStatus(tabId = "default") {
44
35
  return this.client.send("block.status", { tabId });
45
36
  }
46
37
 
47
- blockRetry(tabId = "default"): Promise<void> {
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: string, handler: (data: { captchaType: string; tabId: string }) => void): () => void {
44
+ onCaptcha(tabId, handler) {
54
45
  return this.client.onEvent("captcha", tabId, handler);
55
46
  }
56
47
 
57
- onCaptchaResolved(tabId: string, handler: (data: { tabId: string }) => void): () => void {
48
+ onCaptchaResolved(tabId, handler) {
58
49
  return this.client.onEvent("captcha:resolved", tabId, handler);
59
50
  }
60
51
 
61
- onBlocked(tabId: string, handler: (data: { blockType: string; tabId: string }) => void): () => void {
52
+ onBlocked(tabId, handler) {
62
53
  return this.client.onEvent("blocked", tabId, handler);
63
54
  }
64
55
 
65
- onBlockRetry(tabId: string, handler: (data: { tabId: string; proxy: string }) => void): () => void {
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): Promise<void> {
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: PiggyClient): CaptchaClient {
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
+ }