compile.ts 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. export type Chunk = {
  2. start: number
  3. end: number
  4. }
  5. export type PrefetchedChunk<ChunkType extends Chunk> = ChunkType & {
  6. buffer: Uint8Array
  7. }
  8. export type PDFRange<ObjectIdType = Uint8Array | string> = Chunk & {
  9. objectId: ObjectIdType
  10. hash: string
  11. size: number
  12. totalUsage: number
  13. }
  14. type OutputFileBase = {
  15. path: string
  16. url: string
  17. type: string
  18. build: string
  19. downloadURL: string
  20. // assigned by buildFileList in frontend
  21. main?: boolean
  22. }
  23. type PDFFileBase = OutputFileBase & {
  24. clsiCacheShard: string
  25. contentId: string
  26. editorId: string
  27. pdfDownloadUrl: string
  28. pdfUrl: string
  29. size: number
  30. startXRefTable?: number
  31. }
  32. export type PDFFile = PDFFileBase & {
  33. createdAt?: string
  34. ranges: PDFRange<string>[]
  35. prefetched?: PrefetchedChunk<PDFRange<Uint8Array>>[]
  36. }
  37. export type ProcessedPDFFile = PDFFileBase & {
  38. preprocessed: true
  39. createdAt: Date
  40. prefetched: PrefetchedChunk<PDFRange<Uint8Array>>[]
  41. ranges: PDFRange<Uint8Array>[]
  42. }
  43. // This type is a little bit of a hack to work around the fact that we mutate
  44. // the PDFFile object directly when processed into a ProcessedPDFFile
  45. export type PartiallyProcessedPDFFile = PDFFileBase & {
  46. preprocessed?: boolean
  47. createdAt?: Date | string
  48. prefetched?: PrefetchedChunk<PDFRange<Uint8Array>>[]
  49. ranges: PDFRange<Uint8Array>[] | PDFRange<string>[]
  50. }
  51. export type CompileOutputFile = OutputFileBase | PDFFile
  52. export type CompileResponseData = {
  53. fromCache?: boolean
  54. status: string
  55. outputFiles: CompileOutputFile[]
  56. compileGroup?: string
  57. clsiServerId?: string
  58. clsiCacheShard?: string
  59. pdfDownloadDomain?: string
  60. pdfCachingMinChunkSize: number
  61. validationProblems: any
  62. stats?: Record<string, number>
  63. timings?: Record<string, number>
  64. outputFilesArchive?: CompileOutputFile
  65. // assigned on response body by DocumentCompiler in frontend
  66. rootDocId?: string | null
  67. options: CompileOptions
  68. }
  69. export type CompileOptions = {
  70. draft?: boolean
  71. stopOnFirstError?: boolean
  72. isAutoCompileOnLoad?: boolean
  73. isAutoCompileOnChange?: boolean
  74. rootResourcePath?: string
  75. imageName?: string
  76. compiler?: string
  77. }