| 1 | import type { MarkdownParseResult } from "./markdownPipeline"; |
| 2 | |
| 3 | export type MarkdownWorkerPriority = "interactive" | "visible" | "background"; |
| 4 | |
| 5 | export interface MarkdownParseRequest { |
| 6 | id: number; |
| 7 | op?: "parse"; |
| 8 | text: string; |
| 9 | } |
| 10 | |
| 11 | export type MarkdownDocumentRequest = |
| 12 | | { id: number; op: "open"; documentId: string; text: string } |
| 13 | | { id: number; op: "append"; documentId: string; text: string } |
| 14 | | { id: number; op: "replace"; documentId: string; text: string } |
| 15 | | { id: number; op: "finalize"; documentId: string; text: string } |
| 16 | | { id: number; op: "release"; documentId: string }; |
| 17 | |
| 18 | export type MarkdownWorkerRequest = MarkdownParseRequest | MarkdownDocumentRequest; |
| 19 | |
| 20 | export interface MarkdownParseResponse { |
| 21 | id: number; |
| 22 | result?: MarkdownParseResult; |
| 23 | error?: string; |
| 24 | } |
| 25 | |
| 26 | export function markdownPriorityRank(priority: MarkdownWorkerPriority): number { |
| 27 | if (priority === "interactive") return 0; |
| 28 | if (priority === "visible") return 1; |
| 29 | return 2; |
| 30 | } |
| 31 |