Files
t3code/apps/web/src/components/preview/openPreviewSession.ts
T
Julius Marminge dd739c880d Port browser preview annotations to desktop
- Add IPC and runtime plumbing for preview annotation theming
- Generate and ship annotation CSS for the desktop overlay
- Add pointer and artifact handling for browser preview interactions
2026-06-13 22:18:37 -07:00

27 lines
860 B
TypeScript

import type { EnvironmentApi, PreviewSessionSnapshot, ScopedThreadRef } from "@t3tools/contracts";
import type { PreviewStateStoreState } from "~/previewStateStore";
interface OpenPreviewSessionInput {
previewApi: Pick<EnvironmentApi["preview"], "open">;
threadRef: ScopedThreadRef;
url: string;
applyServerSnapshot: PreviewStateStoreState["applyServerSnapshot"];
rememberUrl: PreviewStateStoreState["rememberUrl"];
}
export async function openPreviewSession(
input: OpenPreviewSessionInput,
): Promise<PreviewSessionSnapshot> {
const snapshot = await input.previewApi.open({
threadId: input.threadRef.threadId,
url: input.url,
});
input.applyServerSnapshot(input.threadRef, snapshot);
input.rememberUrl(
input.threadRef,
snapshot.navStatus._tag === "Idle" ? input.url : snapshot.navStatus.url,
);
return snapshot;
}