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

binaryPreviewProtocol.ts

29 lines1.0 KB

1import type { PreviewFailure } from "./previewFailure";
2import { ARCHIVE_MAX_BYTES } from "@t3tools/client-runtime/zip/bounded-zip";
3​
4export {
5 ARCHIVE_ENTRY_MAX_BYTES,
6 ARCHIVE_MAX_ENTRIES,
7 ARCHIVE_MAX_RATIO,
8} from "@t3tools/client-runtime/zip/bounded-zip";
9export const BINARY_PREVIEW_MAX_BYTES = ARCHIVE_MAX_BYTES;
10export const SQLITE_PAGE_SIZE = 50;
11​
12export interface ArchiveEntry {
13 path: string;
14 size: number;
15 modified: string | null;
16 directory: boolean;
18​
19export type BinaryWorkerRequest =
20 | { type: "open"; kind: "archive" | "sqlite"; name: string; bytes: ArrayBuffer }
21 | { type: "entry"; path: string }
22 | { type: "rows"; table: string; page: number };
23​
24export type BinaryWorkerResult =
25 | ({ type: "error" } & PreviewFailure)
26 | { type: "archive"; entries: ArchiveEntry[] }
27 | { type: "entry"; path: string; bytes: Uint8Array<ArrayBuffer> }
28 | { type: "sqlite"; tables: { name: string; count: number }[] }
29 | { type: "rows"; table: string; page: number; columns: string[]; rows: string[][] };