Open History to see the last commit
1import type { OfficePreviewKind } from "@t3tools/shared/filePreview";
2
3export const OFFICE_PREVIEW_MAX_BYTES = 50 * 1024 * 1024;
4export const OFFICE_PREVIEW_MAX_ROWS = 250_000;
5export const OFFICE_PREVIEW_MAX_COLUMNS = 1024;
6
7/** What a workbook's views ask of the preview that its engine does not read. */
8export type WorkbookView = {
9 /** The sheets, by index in workbook order, whose view hides gridlines. */
10 readonly hiddenGridlines: readonly number[];
11 /** The theme's heading and body fonts, which chart text names as `+mj-lt` and `+mn-lt`. */
12 readonly themeFonts: { readonly major: string; readonly minor: string };
13};
14
15export type OfficeWorkerRequest =
16 | { readonly type: "open"; readonly kind: OfficePreviewKind; readonly bytes: ArrayBuffer }
17 | { readonly type: "sheet-page"; readonly sheet: number; readonly index: number };
18
19export type NotebookCell = {
20 readonly kind: "markdown" | "code" | "raw";
21 readonly source: string;
22 readonly outputs: { readonly kind: "text" | "image" | "html"; readonly text: string }[];
23};
24
25export type OfficeWorkerResult =
26 | {
27 readonly type: "document";
28 readonly navigation: "page" | "slide" | "chapter";
29 readonly pages: { title: string; html: string }[];
30 }
31 | { readonly type: "notebook"; readonly language: string; readonly cells: NotebookCell[] }
32 | { readonly type: "error"; readonly message: string }
33 | {
34 readonly type: "docx" | "xlsx" | "pptx";
35 readonly bytes: ArrayBuffer;
36 readonly truncated: boolean;
37 /** For a workbook; undefined for other files. */
38 readonly view: WorkbookView | undefined;
39 }
40 | {
41 readonly type: "ods";
42 readonly sheets: {
43 name: string;
44 rows: string[][];
45 truncated: boolean;
46 rowCount: number;
47 columns: number;
48 }[];
49 }
50 | {
51 readonly type: "sheet-page";
52 readonly sheet: number;
53 readonly index: number;
54 readonly rows: string[][];
55 };