- 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
27 lines
860 B
TypeScript
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;
|
|
}
|