open-browser-sdk 0.1.0

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.
@@ -0,0 +1,10 @@
1
+ import type { BrowserServerOptions, GetBrowserResponse, StartBrowserOptions, StartBrowserResponse, StopBrowserResponse } from "./types.js";
2
+ export declare class BrowserServer {
3
+ private readonly hostUrl;
4
+ constructor(options: BrowserServerOptions);
5
+ start(options?: StartBrowserOptions): Promise<StartBrowserResponse>;
6
+ stop(id: string): Promise<StopBrowserResponse>;
7
+ get(id: string): Promise<GetBrowserResponse>;
8
+ private request;
9
+ }
10
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,YAAY,CAAC;AAEpB,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAErB,OAAO,EAAE,oBAAoB;IAInC,KAAK,CACT,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,oBAAoB,CAAC;IAO1B,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAO9C,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;YAMpC,OAAO;CAoBtB"}
package/dist/client.js ADDED
@@ -0,0 +1,35 @@
1
+ import { BrowserServerError } from "./errors.js";
2
+ export class BrowserServer {
3
+ hostUrl;
4
+ constructor(options) {
5
+ this.hostUrl = options.hostUrl.replace(/\/$/, "");
6
+ }
7
+ async start(options = {}) {
8
+ return this.request("/browser/start", {
9
+ method: "POST",
10
+ body: options,
11
+ });
12
+ }
13
+ async stop(id) {
14
+ return this.request("/browser/stop", {
15
+ method: "POST",
16
+ body: { id },
17
+ });
18
+ }
19
+ async get(id) {
20
+ return this.request(`/browser/${encodeURIComponent(id)}`);
21
+ }
22
+ async request(path, init) {
23
+ const res = await fetch(`${this.hostUrl}${path}`, {
24
+ method: init?.method ?? "GET",
25
+ headers: init?.body ? { "content-type": "application/json" } : undefined,
26
+ body: init?.body ? JSON.stringify(init.body) : undefined,
27
+ });
28
+ const payload = await res.json().catch(() => undefined);
29
+ if (!res.ok) {
30
+ const message = payload?.error ?? res.statusText;
31
+ throw new BrowserServerError(message, res.status);
32
+ }
33
+ return payload;
34
+ }
35
+ }
@@ -0,0 +1,5 @@
1
+ export declare class BrowserServerError extends Error {
2
+ readonly status: number;
3
+ constructor(message: string, status: number);
4
+ }
5
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAK5C"}
package/dist/errors.js ADDED
@@ -0,0 +1,8 @@
1
+ export class BrowserServerError extends Error {
2
+ status;
3
+ constructor(message, status) {
4
+ super(message);
5
+ this.name = "BrowserServerError";
6
+ this.status = status;
7
+ }
8
+ }
@@ -0,0 +1,4 @@
1
+ export { BrowserServer } from "./client.js";
2
+ export { BrowserServerError } from "./errors.js";
3
+ export type { BrowserServerOptions, CookieData, GetBrowserResponse, ProxyOptions, StartBrowserOptions, StartBrowserResponse, StopBrowserResponse, } from "./types.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,YAAY,EACV,oBAAoB,EACpB,UAAU,EACV,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { BrowserServer } from "./client.js";
2
+ export { BrowserServerError } from "./errors.js";
@@ -0,0 +1,5 @@
1
+ export interface BrowserServerOptions {
2
+ hostUrl: string;
3
+ }
4
+ export type { CookieData, GetBrowserResponse, ProxyOptions, StartBrowserOptions, StartBrowserResponse, StopBrowserResponse, } from "@repo/types";
5
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,YAAY,EACV,UAAU,EACV,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,aAAa,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "open-browser-sdk",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "private": false,
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/index.d.ts",
9
+ "default": "./dist/index.js"
10
+ }
11
+ },
12
+ "files": ["dist"],
13
+ "scripts": {
14
+ "build": "tsc && tsc-alias",
15
+ "dev": "tsc --watch --preserveWatchOutput & tsc-alias --watch",
16
+ "lint": "eslint --max-warnings 0",
17
+ "check-types": "tsc --noEmit",
18
+ "prepublishOnly": "pnpm run check-types && pnpm run lint && pnpm run build"
19
+ },
20
+ "devDependencies": {
21
+ "@repo/eslint-config": "workspace:*",
22
+ "@repo/types": "workspace:*",
23
+ "@repo/typescript-config": "workspace:*",
24
+ "@types/node": "^22.15.3",
25
+ "eslint": "^9.39.1",
26
+ "tsc-alias": "^1.8.17",
27
+ "typescript": "5.9.2"
28
+ }
29
+ }