nothing-browser 0.0.18 → 0.0.19

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.
@@ -739,6 +739,14 @@ var BINARY_NAMES = {
739
739
  headful: "nothing-browser-headful"
740
740
  };
741
741
  function detectBinary(mode = "headless") {
742
+ if (mode !== "headless" && mode !== "headful") {
743
+ if (existsSync(mode)) {
744
+ logger_default.success(`Binary found (custom path): ${mode}`);
745
+ return mode;
746
+ }
747
+ logger_default.error(`❌ Binary not found at custom path: ${mode}`);
748
+ return null;
749
+ }
742
750
  const cwd = process.cwd();
743
751
  const name = BINARY_NAMES[mode];
744
752
  if (process.platform === "win32") {
@@ -744,6 +744,14 @@ var BINARY_NAMES = {
744
744
  headful: "nothing-browser-headful"
745
745
  };
746
746
  function detectBinary(mode = "headless") {
747
+ if (mode !== "headless" && mode !== "headful") {
748
+ if (existsSync(mode)) {
749
+ logger_default.success(`Binary found (custom path): ${mode}`);
750
+ return mode;
751
+ }
752
+ logger_default.error(`❌ Binary not found at custom path: ${mode}`);
753
+ return null;
754
+ }
747
755
  const cwd = process.cwd();
748
756
  const name = BINARY_NAMES[mode];
749
757
  if (process.platform === "win32") {
@@ -1,3 +1,3 @@
1
- export type BinaryMode = 'headless' | 'headful';
1
+ export type BinaryMode = 'headless' | 'headful' | (string & {});
2
2
  export declare function detectBinary(mode?: BinaryMode): string | null;
3
3
  //# sourceMappingURL=detect.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../../../piggy/launch/detect.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,SAAS,CAAC;AAOhD,wBAAgB,YAAY,CAAC,IAAI,GAAE,UAAuB,GAAG,MAAM,GAAG,IAAI,CA+BzE"}
1
+ {"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../../../piggy/launch/detect.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,SAAS,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAOhE,wBAAgB,YAAY,CAAC,IAAI,GAAE,UAAuB,GAAG,MAAM,GAAG,IAAI,CAwCzE"}
package/dist/piggy.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { type SiteObject } from "./piggy/register";
2
+ export type BinaryMode = "headless" | "headfull" | (string & {});
2
3
  declare const piggy: any;
3
4
  type TypedPiggy<Sites extends string> = typeof piggy & {
4
5
  [K in Sites]: SiteObject;
@@ -1 +1 @@
1
- {"version":3,"file":"piggy.d.ts","sourceRoot":"","sources":["../piggy.ts"],"names":[],"mappings":"AAIA,OAAO,EAA6C,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAY9F,QAAA,MAAM,KAAK,EAAE,GAwLZ,CAAC;AAMF,KAAK,UAAU,CAAC,KAAK,SAAS,MAAM,IAAI,OAAO,KAAK,GAAG;KACpD,CAAC,IAAI,KAAK,GAAG,UAAU;CACzB,CAAC;AAEF,wBAAgB,QAAQ,CAAC,KAAK,SAAS,MAAM,KAAK,UAAU,CAAC,KAAK,CAAC,CAElE;AAED,YAAY,EAAE,UAAU,EAAE,CAAC;AAC3B,eAAe,KAAK,CAAC;AACrB,OAAO,EAAE,KAAK,EAAE,CAAC"}
1
+ {"version":3,"file":"piggy.d.ts","sourceRoot":"","sources":["../piggy.ts"],"names":[],"mappings":"AAIA,OAAO,EAA6C,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAa9F,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,UAAU,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAOjE,QAAA,MAAM,KAAK,EAAE,GAwLZ,CAAC;AAGF,KAAK,UAAU,CAAC,KAAK,SAAS,MAAM,IAAI,OAAO,KAAK,GAAG;KACpD,CAAC,IAAI,KAAK,GAAG,UAAU;CACzB,CAAC;AAEF,wBAAgB,QAAQ,CAAC,KAAK,SAAS,MAAM,KAAK,UAAU,CAAC,KAAK,CAAC,CAElE;AAED,YAAY,EAAE,UAAU,EAAE,CAAC;AAC3B,eAAe,KAAK,CAAC;AACrB,OAAO,EAAE,KAAK,EAAE,CAAC"}
package/dist/piggy.js CHANGED
@@ -6870,6 +6870,14 @@ var BINARY_NAMES = {
6870
6870
  headful: "nothing-browser-headful"
6871
6871
  };
6872
6872
  function detectBinary(mode = "headless") {
6873
+ if (mode !== "headless" && mode !== "headful") {
6874
+ if (existsSync(mode)) {
6875
+ logger_default.success(`Binary found (custom path): ${mode}`);
6876
+ return mode;
6877
+ }
6878
+ logger_default.error(`❌ Binary not found at custom path: ${mode}`);
6879
+ return null;
6880
+ }
6873
6881
  const cwd = process.cwd();
6874
6882
  const name = BINARY_NAMES[mode];
6875
6883
  if (process.platform === "win32") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nothing-browser",
3
- "version": "0.0.18",
3
+ "version": "0.0.19",
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": {
@@ -2,16 +2,26 @@ import { existsSync } from 'fs';
2
2
  import { join } from 'path';
3
3
  import logger from '../logger';
4
4
 
5
- export type BinaryMode = 'headless' | 'headful';
5
+ export type BinaryMode = 'headless' | 'headful' | (string & {});
6
6
 
7
- const BINARY_NAMES: Record<BinaryMode, string> = {
7
+ const BINARY_NAMES: Record<'headless' | 'headful', string> = {
8
8
  headless: 'nothing-browser-headless',
9
9
  headful: 'nothing-browser-headful',
10
10
  };
11
11
 
12
12
  export function detectBinary(mode: BinaryMode = 'headless'): string | null {
13
+ // If it's an arbitrary path, just verify it exists and return it as-is
14
+ if (mode !== 'headless' && mode !== 'headful') {
15
+ if (existsSync(mode)) {
16
+ logger.success(`Binary found (custom path): ${mode}`);
17
+ return mode;
18
+ }
19
+ logger.error(`❌ Binary not found at custom path: ${mode}`);
20
+ return null;
21
+ }
22
+
13
23
  const cwd = process.cwd();
14
- const name = BINARY_NAMES[mode];
24
+ const name = BINARY_NAMES[mode as 'headless' | 'headful'];
15
25
 
16
26
  // Windows
17
27
  if (process.platform === 'win32') {
@@ -38,6 +48,5 @@ export function detectBinary(mode: BinaryMode = 'headless'): string | null {
38
48
  if (process.platform !== 'win32') {
39
49
  logger.error(`Then run: chmod +x ${name}`);
40
50
  }
41
-
42
51
  return null;
43
52
  }
package/piggy.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  // piggy.ts
2
- import { detectBinary, type BinaryMode } from "./piggy/launch/detect";
2
+ import { detectBinary } from "./piggy/launch/detect";
3
3
  import { spawnBrowser, killBrowser, spawnBrowserOnSocket } from "./piggy/launch/spawn";
4
4
  import { PiggyClient } from "./piggy/client";
5
5
  import { setClient, setHumanMode, createSiteObject, type SiteObject } from "./piggy/register";
@@ -9,6 +9,14 @@ import logger from "./piggy/logger";
9
9
 
10
10
  type TabMode = "tab" | "process";
11
11
 
12
+ // "headless" and "headfull" are the built-in modes.
13
+ // Any other string is treated as a raw path to a binary —
14
+ // e.g. "../my-browser/browser", "C:\\browsers\\mybrowser.exe",
15
+ // "/opt/weird-browser/bin/wb", etc.
16
+ // The (string & {}) trick keeps autocomplete for the two literals
17
+ // while still accepting any arbitrary string.
18
+ export type BinaryMode = "headless" | "headfull" | (string & {});
19
+
12
20
  let _client: PiggyClient | null = null;
13
21
  let _tabMode: TabMode = "tab";
14
22
  const _extraProcs: { socket: string; client: PiggyClient }[] = [];
@@ -201,9 +209,6 @@ const piggy: any = {
201
209
  };
202
210
 
203
211
  // ── usePiggy ──────────────────────────────────────────────────────────────────
204
- // Typed accessor — call AFTER register() so sites exist on piggy.
205
- // const { amazon, ebay } = usePiggy<"amazon" | "ebay">()
206
-
207
212
  type TypedPiggy<Sites extends string> = typeof piggy & {
208
213
  [K in Sites]: SiteObject;
209
214
  };