@unbound-app/debugger-protocol 2.0.1 → 2.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.
@@ -1,4 +1,4 @@
1
- import { g as PushedAddonKind, h as PushResult, s as DeviceInfo, u as EvalResult } from "./index-DwVwBIbm.mjs";
1
+ import { b as PushedAddonKind, d as DeviceInfo, m as EvalResult, y as PushResult } from "./index-CxErH5OQ.mjs";
2
2
  import { PushedManifest } from "@unbound-app/types";
3
3
  /**
4
4
  * The controller half of the bridge: dials the `?mcp` endpoint and settles id-correlated evals
@@ -12,6 +12,10 @@ type AddonPush = {
12
12
  bytecode?: Record<string, string>;
13
13
  files?: Record<string, string>;
14
14
  };
15
+ type ControllerOptions = {
16
+ /** Runs before every dial, such as starting the bridge when none listens; the dial waits for it. */
17
+ beforeConnect?: () => Promise<unknown>;
18
+ };
15
19
  export declare class ControllerClient {
16
20
  private ws;
17
21
  /** Each pending eval keeps the console output seen since its dispatch, so side effects surface too. */
@@ -21,9 +25,11 @@ export declare class ControllerClient {
21
25
  private deviceInfo;
22
26
  private closed;
23
27
  private readonly url;
24
- constructor(url: string);
28
+ private readonly beforeConnect;
29
+ constructor(url: string, { beforeConnect }?: ControllerOptions);
25
30
  /** @description Opens the socket and keeps it open, reconnecting on drop until {@link close}d. */
26
31
  connect(): void;
32
+ private open;
27
33
  /** @description Tears the client down and fails any in-flight evals. Twin of {@link connect}. */
28
34
  close(): void;
29
35
  get isDeviceConnected(): boolean;
@@ -1,4 +1,4 @@
1
- import { c as resolveEvalTimeout, l as serializeMessage, o as PUSH_TIMEOUT_MS, s as parseMessage, t as BRIDGE_REPLY_GRACE_MS } from "./src-D0Oi4NXs.mjs";
1
+ import { c as PUSH_TIMEOUT_MS, d as resolveEvalTimeout, f as serializeMessage, t as BRIDGE_REPLY_GRACE_MS, u as parseMessage } from "./src-D7-HmLkb.mjs";
2
2
  import { PendingRequests } from "./pending-requests.mjs";
3
3
  // src/controller.ts
4
4
  const RECONNECT_DELAY_MS = 1e3;
@@ -11,11 +11,21 @@ var ControllerClient = class {
11
11
  deviceInfo;
12
12
  closed = false;
13
13
  url;
14
- constructor(url) {
14
+ beforeConnect;
15
+ constructor(url, { beforeConnect } = {}) {
15
16
  this.url = url;
17
+ this.beforeConnect = beforeConnect;
16
18
  }
17
19
  /** @description Opens the socket and keeps it open, reconnecting on drop until {@link close}d. */
18
20
  connect() {
21
+ if (this.closed) return;
22
+ if (!this.beforeConnect) {
23
+ this.open();
24
+ return;
25
+ }
26
+ this.beforeConnect().catch(() => void 0).then(() => this.open());
27
+ }
28
+ open() {
19
29
  if (this.closed) return;
20
30
  this.ws = new WebSocket(this.url);
21
31
  this.ws.addEventListener("message", (event) => this.onMessage(String(event.data)));