import { DebugProtocol } from "@vscode/debugprotocol";
import {handle_request} from "./request-handler"

export class DebuggerWorker {
  onmessage: (data: { data: DebugProtocol.Response; }) => any;

  constructor() {
    // Note that `onmessage` should be overwritten by the code using the worker.
    this.onmessage = () => { };
  }

  postMessage(data: any) {
    handle_request(data).then(
      (res) => {
        this.onmessage({ data: res });
      }
    );
  }
}
