feat(protocol): define streamed diff revisions and resolve tag bases

This commit is contained in:
Mohamed Boudra
2026-11-06 04:01:48 +01:00
parent 3ed57e9dd7
commit 8bc533279a
12 changed files with 749 additions and 8 deletions
@@ -1,3 +1,4 @@
import { decodeDiffFrame, DiffOpcode, type DiffFrame } from "./diff.js";
import { HOST_ROUTE_OPCODE, decodeHostRouteFrame, type HostRouteFrame } from "./host-route.js";
import {
decodeFileTransferFrame,
@@ -12,12 +13,20 @@ import {
} from "./terminal.js";
export type BinaryFrame =
| { kind: "diff"; frame: DiffFrame }
| { kind: "host_route"; frame: HostRouteFrame }
| { kind: "terminal"; frame: TerminalStreamFrame }
| { kind: "file_transfer"; frame: FileTransferFrame }
| { kind: "plugin"; frame: PluginFrame };
export function decodeBinaryFrame(bytes: Uint8Array): BinaryFrame | null {
if (Object.values(DiffOpcode).some((opcode) => opcode === bytes[0])) {
return { kind: "diff", frame: decodeDiffFrame(bytes) };
}
return decodeExistingBinaryFrame(bytes);
}
function decodeExistingBinaryFrame(bytes: Uint8Array): BinaryFrame | null {
switch (bytes[0]) {
case HOST_ROUTE_OPCODE: {
const frame = decodeHostRouteFrame(bytes);