>((resolve) => {
- const id = nanoid();
- pyApi[method].receive((response) => {
- console.log(method, "Received response: ", { response });
- resolve(response);
- }, id);
-
- pyApi[method].dispatch({ ...args, op_key: id });
- });
+ console.log("Calling API", method, args);
+ return (window as any)[method](args);
};
const deserialize =
@@ -161,15 +67,3 @@ const deserialize =
alert(`Error parsing JSON: ${e}`);
}
};
-
-// Create the API object
-
-const pyApi: PyApi = {} as PyApi;
-
-operationNames.forEach((opName) => {
- const name = opName as OperationNames;
- // @ts-expect-error - TODO: Fix this. Typescript is not recognizing the receive function correctly
- pyApi[name] = createFunctions(name);
-});
-
-export { pyApi };
diff --git a/pkgs/webview-ui/app/src/routes/hosts/view.tsx b/pkgs/webview-ui/app/src/routes/hosts/view.tsx
index 8c1523e44..c9bb8396f 100644
--- a/pkgs/webview-ui/app/src/routes/hosts/view.tsx
+++ b/pkgs/webview-ui/app/src/routes/hosts/view.tsx
@@ -1,5 +1,5 @@
import { type Component, createSignal, For, Show } from "solid-js";
-import { OperationResponse, pyApi } from "@/src/api";
+import { OperationResponse, callApi } from "@/src/api";
import { Button } from "@/src/components/button";
import Icon from "@/src/components/icon";
@@ -16,7 +16,7 @@ export const HostList: Component = () => {