Files
t3code/apps/web/src/rpc/environmentAtomRpc.ts
T
Julius Marminge 8c48db4409 Extract shared RPC atom runtime helpers
- Move environment RPC setup into `packages/client-runtime`
- Replace web-side server atom indirection with shared helpers
- Remove obsolete `serverAtomRpc` wrapper
2026-05-05 20:47:50 -07:00

27 lines
873 B
TypeScript

import { createT3RpcAtomRuntime, type T3RpcAtomRuntime } from "@t3tools/client-runtime";
import type { EnvironmentId } from "@t3tools/contracts";
import {
createWsRpcProtocolLayer,
type WsProtocolLifecycleHandlers,
type WsRpcProtocolSocketUrlProvider,
} from "./protocol";
export type EnvironmentAtomRpcClient = T3RpcAtomRuntime;
export interface EnvironmentAtomRpcClientInput {
readonly environmentId: EnvironmentId;
readonly url: WsRpcProtocolSocketUrlProvider;
readonly lifecycleHandlers?: WsProtocolLifecycleHandlers;
}
export function createEnvironmentAtomRpcClient(
input: EnvironmentAtomRpcClientInput,
): EnvironmentAtomRpcClient {
return createT3RpcAtomRuntime({
environmentId: input.environmentId,
protocol: createWsRpcProtocolLayer(input.url, input.lifecycleHandlers),
spanPrefix: `EnvironmentRpc:${input.environmentId}`,
});
}