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