Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

largeTextProtocol.ts

20 lines1.1 KB

1import type { PreviewFailure } from "./previewFailure";
2export const LARGE_TEXT_MAX_BYTES = 256 * 1024 * 1024;
3export const LARGE_TEXT_MAX_ROWS = 5_000_000;
4export const LARGE_TEXT_MAX_COLUMNS = 1024;
5export const PREVIEW_PAGE_ROWS = 32;
6// Browsers stop laying out an element near 33.5M px. Rendered Markdown measured about 22 px per
7// source line, so files taller than this stay in the scaled plain viewer.
8export const RENDERED_MAX_LINES = 1_200_000;
9// Rendered Markdown and highlighted source hold the whole file on the main thread; larger files
10// use the worker-backed plain viewer.
11export const FULL_TEXT_MAX_BYTES = 64 * 1024 * 1024;
12export type TextPreviewRequest =
13 | { type: "open"; src?: string; text?: string; sizeBytes?: number; delimiter: "," | "\t" | null }
14 | { type: "page"; index: number }
15 | { type: "copy" };
16export type TextPreviewResult =
17 | { type: "meta"; count: number; columns: number; complete: boolean; sizeBytes?: number }
18 | { type: "page"; index: number; rows: string[][] }
19 | { type: "copy"; text: string }
20 | ({ type: "error"; operation: TextPreviewRequest["type"] } & PreviewFailure);