browser-pilot 0.0.14 → 0.0.15

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.
@@ -168,7 +168,8 @@ function buildCDPClient(transport, options = {}) {
168
168
  pending.delete(response.id);
169
169
  clearTimeout(request.timer);
170
170
  if (response.error) {
171
- request.reject(new CDPError(response.error));
171
+ const error = typeof response.error === "string" ? { code: -32e3, message: response.error } : response.error;
172
+ request.reject(new CDPError(error));
172
173
  } else {
173
174
  request.resolve(response.result);
174
175
  }
@@ -284,6 +285,9 @@ function buildCDPClient(transport, options = {}) {
284
285
  get sessionId() {
285
286
  return currentSessionId;
286
287
  },
288
+ setSessionId(sessionId) {
289
+ currentSessionId = sessionId;
290
+ },
287
291
  get isConnected() {
288
292
  return connected;
289
293
  }
@@ -0,0 +1,35 @@
1
+ // src/cdp/protocol.ts
2
+ var CDPError = class extends Error {
3
+ code;
4
+ data;
5
+ constructor(error) {
6
+ super(error.message);
7
+ this.name = "CDPError";
8
+ this.code = error.code;
9
+ this.data = error.data;
10
+ }
11
+ };
12
+
13
+ // src/utils/json.ts
14
+ function isRecord(value) {
15
+ return typeof value === "object" && value !== null;
16
+ }
17
+ function stringifyUnknown(value) {
18
+ if (typeof value === "string") return value;
19
+ if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
20
+ return String(value);
21
+ }
22
+ if (value === null) return "null";
23
+ if (value === void 0) return "undefined";
24
+ try {
25
+ return JSON.stringify(value);
26
+ } catch {
27
+ return Object.prototype.toString.call(value);
28
+ }
29
+ }
30
+
31
+ export {
32
+ CDPError,
33
+ isRecord,
34
+ stringifyUnknown
35
+ };
@@ -1,32 +1,7 @@
1
- // src/utils/json.ts
2
- function isRecord(value) {
3
- return typeof value === "object" && value !== null;
4
- }
5
- function stringifyUnknown(value) {
6
- if (typeof value === "string") return value;
7
- if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
8
- return String(value);
9
- }
10
- if (value === null) return "null";
11
- if (value === void 0) return "undefined";
12
- try {
13
- return JSON.stringify(value);
14
- } catch {
15
- return Object.prototype.toString.call(value);
16
- }
17
- }
18
-
19
- // src/cdp/protocol.ts
20
- var CDPError = class extends Error {
21
- code;
22
- data;
23
- constructor(error) {
24
- super(error.message);
25
- this.name = "CDPError";
26
- this.code = error.code;
27
- this.data = error.data;
28
- }
29
- };
1
+ import {
2
+ CDPError,
3
+ isRecord
4
+ } from "./chunk-DTVRFXKI.mjs";
30
5
 
31
6
  // src/cdp/transport.ts
32
7
  function createTransport(wsUrl, options = {}) {
@@ -176,7 +151,8 @@ function buildCDPClient(transport, options = {}) {
176
151
  pending.delete(response.id);
177
152
  clearTimeout(request.timer);
178
153
  if (response.error) {
179
- request.reject(new CDPError(response.error));
154
+ const error = typeof response.error === "string" ? { code: -32e3, message: response.error } : response.error;
155
+ request.reject(new CDPError(error));
180
156
  } else {
181
157
  request.resolve(response.result);
182
158
  }
@@ -292,6 +268,9 @@ function buildCDPClient(transport, options = {}) {
292
268
  get sessionId() {
293
269
  return currentSessionId;
294
270
  },
271
+ setSessionId(sessionId) {
272
+ currentSessionId = sessionId;
273
+ },
295
274
  get isConnected() {
296
275
  return connected;
297
276
  }
@@ -300,9 +279,6 @@ function buildCDPClient(transport, options = {}) {
300
279
  }
301
280
 
302
281
  export {
303
- CDPError,
304
- isRecord,
305
- stringifyUnknown,
306
282
  createCDPClientFromTransport,
307
283
  createCDPClient
308
284
  };