Compare commits

...

1 Commits

Author SHA1 Message Date
Sarah Fortune 50b253d45b Move StreamingHandlers type into a common location
This type is used by all host bridge clients, move it out of the vscode directory.
2025-06-18 12:51:50 -07:00
6 changed files with 15 additions and 15 deletions
+2 -2
View File
@@ -71,7 +71,7 @@ async function generateInterfacesFile(hostServices) {
const content = `// GENERATED CODE -- DO NOT EDIT!
// Generated by scripts/generate-host-bridge-client.mjs
import * as proto from "@shared/proto/index"
import { StreamingCallbacks } from "@hosts/vscode/host-grpc-handler"
import { StreamingCallbacks } from "@hosts/host-bridge-client"
${clientInterfaces.join("\n\n")}
`
@@ -128,7 +128,7 @@ async function generateImplementationFile(hostServices) {
// Generated by scripts/generate-host-bridge-client.mjs
import { asyncIteratorToCallbacks } from "@/standalone/utils"
import * as niceGrpc from "@generated/nice-grpc/index"
import { StreamingCallbacks } from "@hosts/vscode/host-grpc-handler"
import { StreamingCallbacks } from "@hosts/host-bridge-client"
import * as proto from "@shared/proto/index"
import { Channel, createClient } from "nice-grpc"
+9
View File
@@ -6,3 +6,12 @@ const Client = isHostBridgeExternal ? ExternalClient : VscodeClient
export const UriServiceClient: UriServiceClientInterface = Client.UriServiceClient
export const WatchServiceClient: WatchServiceClientInterface = Client.WatchServiceClient
/**
* Callback interface for streaming requests
*/
export interface StreamingCallbacks<T = any> {
onResponse: (response: T) => void
onError?: (error: Error) => void
onComplete?: () => void
}
@@ -1,5 +1,6 @@
import { v4 as uuidv4 } from "uuid"
import { GrpcHandler, StreamingCallbacks } from "../host-grpc-handler"
import { GrpcHandler } from "../host-grpc-handler"
import { StreamingCallbacks } from "@hosts/host-bridge-client"
// Generic type for any protobuf service definition
export type ProtoService = {
+1 -9
View File
@@ -1,3 +1,4 @@
import { StreamingCallbacks } from "@hosts/host-bridge-client"
import { HostServiceHandlerConfig, hostServiceHandlers } from "./host-grpc-service-config"
import { GrpcRequestRegistry } from "@core/controller/grpc-request-registry"
@@ -9,15 +10,6 @@ export type StreamingResponseHandler = (response: any, isLast?: boolean, sequenc
// Registry to track active gRPC requests and their cleanup functions
const requestRegistry = new GrpcRequestRegistry()
/**
* Callback interface for streaming requests
*/
export interface StreamingCallbacks<T = any> {
onResponse: (response: T) => void
onError?: (error: Error) => void
onComplete?: () => void
}
/**
* Handles gRPC requests for the host bridge.
*/
-2
View File
@@ -9,8 +9,6 @@ import { getPackageDefinition, log } from "./utils"
import { GrpcHandler, GrpcStreamingResponseHandler } from "./grpc-types"
import { addProtobusServices } from "@/generated/standalone/server-setup"
import { StreamingResponseHandler } from "@/core/controller/grpc-handler"
import { UriServiceClient } from "@/hosts/host-bridge-client"
import { StringRequest } from "@/shared/proto/common"
async function main() {
log("Starting service...")
+1 -1
View File
@@ -2,7 +2,7 @@ import * as fs from "fs"
import * as grpc from "@grpc/grpc-js"
import * as protoLoader from "@grpc/proto-loader"
import * as health from "grpc-health-check"
import { StreamingCallbacks } from "@hosts/vscode/host-grpc-handler"
import { StreamingCallbacks } from "@hosts/host-bridge-client"
const log = (...args: unknown[]) => {
const timestamp = new Date().toISOString()