@docmentis/udoc-viewer 0.2.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/package.json +1 -1
  2. package/dist/src/UDocClient.d.ts +113 -3
  3. package/dist/src/UDocClient.d.ts.map +1 -1
  4. package/dist/src/UDocClient.js +181 -24
  5. package/dist/src/UDocClient.js.map +1 -1
  6. package/dist/src/UDocViewer.d.ts +21 -5
  7. package/dist/src/UDocViewer.d.ts.map +1 -1
  8. package/dist/src/UDocViewer.js +45 -35
  9. package/dist/src/UDocViewer.js.map +1 -1
  10. package/dist/src/ui/viewer/components/LeftPanel.d.ts +2 -2
  11. package/dist/src/ui/viewer/components/LeftPanel.d.ts.map +1 -1
  12. package/dist/src/ui/viewer/components/LeftPanel.js +6 -6
  13. package/dist/src/ui/viewer/components/LeftPanel.js.map +1 -1
  14. package/dist/src/ui/viewer/components/Spread.d.ts +2 -2
  15. package/dist/src/ui/viewer/components/Spread.d.ts.map +1 -1
  16. package/dist/src/ui/viewer/components/Spread.js +2 -2
  17. package/dist/src/ui/viewer/components/Spread.js.map +1 -1
  18. package/dist/src/ui/viewer/components/ThumbnailPanel.d.ts +2 -2
  19. package/dist/src/ui/viewer/components/ThumbnailPanel.d.ts.map +1 -1
  20. package/dist/src/ui/viewer/components/ThumbnailPanel.js +5 -5
  21. package/dist/src/ui/viewer/components/ThumbnailPanel.js.map +1 -1
  22. package/dist/src/ui/viewer/components/Viewport.d.ts +2 -2
  23. package/dist/src/ui/viewer/components/Viewport.d.ts.map +1 -1
  24. package/dist/src/ui/viewer/components/Viewport.js +9 -9
  25. package/dist/src/ui/viewer/components/Viewport.js.map +1 -1
  26. package/dist/src/ui/viewer/effects.d.ts +2 -2
  27. package/dist/src/ui/viewer/effects.d.ts.map +1 -1
  28. package/dist/src/ui/viewer/effects.js +7 -6
  29. package/dist/src/ui/viewer/effects.js.map +1 -1
  30. package/dist/src/ui/viewer/shell.d.ts +2 -5
  31. package/dist/src/ui/viewer/shell.d.ts.map +1 -1
  32. package/dist/src/ui/viewer/shell.js +4 -6
  33. package/dist/src/ui/viewer/shell.js.map +1 -1
  34. package/dist/src/wasm/udoc.d.ts +107 -27
  35. package/dist/src/wasm/udoc.js +223 -44
  36. package/dist/src/wasm/udoc_bg.wasm +0 -0
  37. package/dist/src/wasm/udoc_bg.wasm.d.ts +6 -1
  38. package/dist/src/worker/WorkerClient.d.ts +93 -9
  39. package/dist/src/worker/WorkerClient.d.ts.map +1 -1
  40. package/dist/src/worker/WorkerClient.js +295 -15
  41. package/dist/src/worker/WorkerClient.js.map +1 -1
  42. package/dist/src/worker/index.d.ts +1 -1
  43. package/dist/src/worker/index.d.ts.map +1 -1
  44. package/dist/src/worker/worker.d.ts +94 -3
  45. package/dist/src/worker/worker.d.ts.map +1 -1
  46. package/dist/src/worker/worker.js +47 -3
  47. package/dist/src/worker/worker.js.map +1 -1
  48. package/package.json +1 -1
  49. package/dist/src/ui/viewer/rendering/RenderManager.d.ts +0 -76
  50. package/dist/src/ui/viewer/rendering/RenderManager.d.ts.map +0 -1
  51. package/dist/src/ui/viewer/rendering/RenderManager.js +0 -236
  52. package/dist/src/ui/viewer/rendering/RenderManager.js.map +0 -1
@@ -256,50 +256,6 @@ export class UDoc {
256
256
  wasm.__wbindgen_add_to_stack_pointer(16);
257
257
  }
258
258
  }
259
- /**
260
- * Compose new PDF documents by cherry-picking pages from source documents.
261
- *
262
- * The original documents remain unchanged.
263
- *
264
- * # Arguments
265
- * * `compositions` - Array of compositions. Each composition is an array of picks.
266
- * Each pick is `{ doc: docIndex, pages: "0-2,4" }` where `docIndex` is the index
267
- * in the `doc_ids` array and `pages` is a page range string (0-based).
268
- * * `doc_ids` - Array of document IDs to use as sources (order matters for doc indices)
269
- *
270
- * # Example
271
- * ```js
272
- * // Create two documents: first has pages 0-2 from doc A, second has page 0 from A and 1 from B
273
- * const newDocIds = udoc.compose_pdf(
274
- * [
275
- * [{ doc: 0, pages: "0-2" }],
276
- * [{ doc: 0, pages: "0" }, { doc: 1, pages: "1" }]
277
- * ],
278
- * ["doc_0", "doc_1"]
279
- * );
280
- * ```
281
- *
282
- * # Returns
283
- * Array of IDs for the newly created documents (one per composition).
284
- * @param {any} compositions
285
- * @param {any} doc_ids
286
- * @returns {any}
287
- */
288
- compose_pdf(compositions, doc_ids) {
289
- try {
290
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
291
- wasm.udoc_compose_pdf(retptr, this.__wbg_ptr, addHeapObject(compositions), addHeapObject(doc_ids));
292
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
293
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
294
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
295
- if (r2) {
296
- throw takeObject(r1);
297
- }
298
- return takeObject(r0);
299
- } finally {
300
- wasm.__wbindgen_add_to_stack_pointer(16);
301
- }
302
- }
303
259
  /**
304
260
  * Get the document outline (bookmarks/table of contents).
305
261
  *
@@ -376,6 +332,50 @@ export class UDoc {
376
332
  wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
377
333
  }
378
334
  }
335
+ /**
336
+ * Compose new PDF documents by cherry-picking pages from source documents.
337
+ *
338
+ * The original documents remain unchanged.
339
+ *
340
+ * # Arguments
341
+ * * `compositions` - Array of compositions. Each composition is an array of picks.
342
+ * Each pick is `{ doc: docIndex, pages: "0-2,4" }` where `docIndex` is the index
343
+ * in the `doc_ids` array and `pages` is a page range string (0-based).
344
+ * * `doc_ids` - Array of document IDs to use as sources (order matters for doc indices)
345
+ *
346
+ * # Example
347
+ * ```js
348
+ * // Create two documents: first has pages 0-2 from doc A, second has page 0 from A and 1 from B
349
+ * const newDocIds = udoc.pdf_compose(
350
+ * [
351
+ * [{ doc: 0, pages: "0-2" }],
352
+ * [{ doc: 0, pages: "0" }, { doc: 1, pages: "1" }]
353
+ * ],
354
+ * ["doc_0", "doc_1"]
355
+ * );
356
+ * ```
357
+ *
358
+ * # Returns
359
+ * Array of IDs for the newly created documents (one per composition).
360
+ * @param {any} compositions
361
+ * @param {any} doc_ids
362
+ * @returns {any}
363
+ */
364
+ pdf_compose(compositions, doc_ids) {
365
+ try {
366
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
367
+ wasm.udoc_pdf_compose(retptr, this.__wbg_ptr, addHeapObject(compositions), addHeapObject(doc_ids));
368
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
369
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
370
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
371
+ if (r2) {
372
+ throw takeObject(r1);
373
+ }
374
+ return takeObject(r0);
375
+ } finally {
376
+ wasm.__wbindgen_add_to_stack_pointer(16);
377
+ }
378
+ }
379
379
  /**
380
380
  * Set the license key.
381
381
  *
@@ -436,6 +436,43 @@ export class UDoc {
436
436
  const ret = wasm.udoc_has_document(this.__wbg_ptr, ptr0, len0);
437
437
  return ret !== 0;
438
438
  }
439
+ /**
440
+ * Compress a PDF document.
441
+ *
442
+ * Saves the document with full compression options enabled:
443
+ * - Compress stream data using FlateDecode
444
+ * - Pack objects into compressed object streams (PDF 1.5+)
445
+ * - Use compressed xref streams (PDF 1.5+)
446
+ * - Remove unreferenced objects
447
+ *
448
+ * # Arguments
449
+ * * `doc_id` - Document ID to compress
450
+ *
451
+ * # Returns
452
+ * Compressed PDF data as Uint8Array
453
+ * @param {string} doc_id
454
+ * @returns {Uint8Array}
455
+ */
456
+ pdf_compress(doc_id) {
457
+ try {
458
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
459
+ const ptr0 = passStringToWasm0(doc_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
460
+ const len0 = WASM_VECTOR_LEN;
461
+ wasm.udoc_pdf_compress(retptr, this.__wbg_ptr, ptr0, len0);
462
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
463
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
464
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
465
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
466
+ if (r3) {
467
+ throw takeObject(r2);
468
+ }
469
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
470
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
471
+ return v2;
472
+ } finally {
473
+ wasm.__wbindgen_add_to_stack_pointer(16);
474
+ }
475
+ }
439
476
  /**
440
477
  * Get info for all pages in one call.
441
478
  *
@@ -488,6 +525,40 @@ export class UDoc {
488
525
  wasm.__wbindgen_add_to_stack_pointer(16);
489
526
  }
490
527
  }
528
+ /**
529
+ * Decompress a PDF document.
530
+ *
531
+ * Removes all filter encodings from streams, resulting in raw,
532
+ * uncompressed stream data. Useful for debugging or inspection.
533
+ *
534
+ * # Arguments
535
+ * * `doc_id` - Document ID to decompress
536
+ *
537
+ * # Returns
538
+ * Decompressed PDF data as Uint8Array
539
+ * @param {string} doc_id
540
+ * @returns {Uint8Array}
541
+ */
542
+ pdf_decompress(doc_id) {
543
+ try {
544
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
545
+ const ptr0 = passStringToWasm0(doc_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
546
+ const len0 = WASM_VECTOR_LEN;
547
+ wasm.udoc_pdf_decompress(retptr, this.__wbg_ptr, ptr0, len0);
548
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
549
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
550
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
551
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
552
+ if (r3) {
553
+ throw takeObject(r2);
554
+ }
555
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
556
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
557
+ return v2;
558
+ } finally {
559
+ wasm.__wbindgen_add_to_stack_pointer(16);
560
+ }
561
+ }
491
562
  /**
492
563
  * Get all annotations in the document, grouped by page index.
493
564
  *
@@ -525,6 +596,73 @@ export class UDoc {
525
596
  const ret = wasm.udoc_remove_document(this.__wbg_ptr, ptr0, len0);
526
597
  return ret !== 0;
527
598
  }
599
+ /**
600
+ * Extract all embedded fonts from a PDF document.
601
+ *
602
+ * # Arguments
603
+ * * `doc_id` - Document ID to extract fonts from
604
+ *
605
+ * # Returns
606
+ * Array of extracted font objects, each with:
607
+ * - `name`: Font name from the resource dictionary
608
+ * - `fontType`: Font type (Type1, TrueType, etc.)
609
+ * - `extension`: File extension (ttf, cff, t1, etc.)
610
+ * - `data`: Raw font data as Uint8Array
611
+ * @param {string} doc_id
612
+ * @returns {any}
613
+ */
614
+ pdf_extract_fonts(doc_id) {
615
+ try {
616
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
617
+ const ptr0 = passStringToWasm0(doc_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
618
+ const len0 = WASM_VECTOR_LEN;
619
+ wasm.udoc_pdf_extract_fonts(retptr, this.__wbg_ptr, ptr0, len0);
620
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
621
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
622
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
623
+ if (r2) {
624
+ throw takeObject(r1);
625
+ }
626
+ return takeObject(r0);
627
+ } finally {
628
+ wasm.__wbindgen_add_to_stack_pointer(16);
629
+ }
630
+ }
631
+ /**
632
+ * Extract all embedded images from a PDF document.
633
+ *
634
+ * # Arguments
635
+ * * `doc_id` - Document ID to extract images from
636
+ * * `convert_raw_to_png` - When true, converts raw pixel data to PNG format
637
+ *
638
+ * # Returns
639
+ * Array of extracted image objects, each with:
640
+ * - `name`: Image name from the resource dictionary
641
+ * - `format`: Image format (jpeg, png, jp2, etc.)
642
+ * - `width`: Width in pixels
643
+ * - `height`: Height in pixels
644
+ * - `data`: Raw image data as Uint8Array
645
+ * @param {string} doc_id
646
+ * @param {boolean} convert_raw_to_png
647
+ * @returns {any}
648
+ */
649
+ pdf_extract_images(doc_id, convert_raw_to_png) {
650
+ try {
651
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
652
+ const ptr0 = passStringToWasm0(doc_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
653
+ const len0 = WASM_VECTOR_LEN;
654
+ wasm.udoc_pdf_extract_images(retptr, this.__wbg_ptr, ptr0, len0, convert_raw_to_png);
655
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
656
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
657
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
658
+ if (r2) {
659
+ throw takeObject(r1);
660
+ }
661
+ return takeObject(r0);
662
+ } finally {
663
+ wasm.__wbindgen_add_to_stack_pointer(16);
664
+ }
665
+ }
528
666
  /**
529
667
  * Render a page to PNG bytes.
530
668
  *
@@ -628,6 +766,42 @@ export class UDoc {
628
766
  wasm.__wbindgen_add_to_stack_pointer(16);
629
767
  }
630
768
  }
769
+ /**
770
+ * Split a PDF document by its outline (bookmarks) structure.
771
+ *
772
+ * Creates multiple documents, one for each outline section at the specified level.
773
+ *
774
+ * # Arguments
775
+ * * `doc_id` - Document ID to split
776
+ * * `max_level` - Maximum outline level to consider (1 = top level only)
777
+ * * `split_mid_page` - When true, filters page content when sections share a page
778
+ *
779
+ * # Returns
780
+ * Object with:
781
+ * - `documentIds`: Array of IDs for the newly created documents
782
+ * - `sections`: Array of section info objects with `title`, `startPage`, `level`
783
+ * @param {string} doc_id
784
+ * @param {number} max_level
785
+ * @param {boolean} split_mid_page
786
+ * @returns {any}
787
+ */
788
+ pdf_split_by_outline(doc_id, max_level, split_mid_page) {
789
+ try {
790
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
791
+ const ptr0 = passStringToWasm0(doc_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
792
+ const len0 = WASM_VECTOR_LEN;
793
+ wasm.udoc_pdf_split_by_outline(retptr, this.__wbg_ptr, ptr0, len0, max_level, split_mid_page);
794
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
795
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
796
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
797
+ if (r2) {
798
+ throw takeObject(r1);
799
+ }
800
+ return takeObject(r0);
801
+ } finally {
802
+ wasm.__wbindgen_add_to_stack_pointer(16);
803
+ }
804
+ }
631
805
  /**
632
806
  * Create a new document viewer.
633
807
  */
@@ -1073,6 +1247,11 @@ function __wbg_get_imports() {
1073
1247
  const ret = BigInt.asUintN(64, arg0);
1074
1248
  return addHeapObject(ret);
1075
1249
  };
1250
+ imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
1251
+ // Cast intrinsic for `I64 -> Externref`.
1252
+ const ret = arg0;
1253
+ return addHeapObject(ret);
1254
+ };
1076
1255
  imports.wbg.__wbindgen_cast_cb9088102bce6b30 = function(arg0, arg1) {
1077
1256
  // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
1078
1257
  const ret = getArrayU8FromWasm0(arg0, arg1);
Binary file
@@ -3,7 +3,6 @@
3
3
  export const memory: WebAssembly.Memory;
4
4
  export const __wbg_udoc_free: (a: number, b: number) => void;
5
5
  export const udoc_all_page_info: (a: number, b: number, c: number, d: number) => void;
6
- export const udoc_compose_pdf: (a: number, b: number, c: number, d: number) => void;
7
6
  export const udoc_document_count: (a: number) => number;
8
7
  export const udoc_document_ids: (a: number, b: number) => void;
9
8
  export const udoc_get_annotations: (a: number, b: number, c: number, d: number) => void;
@@ -19,6 +18,12 @@ export const udoc_new: () => number;
19
18
  export const udoc_page_count: (a: number, b: number, c: number, d: number) => void;
20
19
  export const udoc_page_info: (a: number, b: number, c: number, d: number, e: number) => void;
21
20
  export const udoc_page_layout: (a: number, b: number, c: number, d: number) => void;
21
+ export const udoc_pdf_compose: (a: number, b: number, c: number, d: number) => void;
22
+ export const udoc_pdf_compress: (a: number, b: number, c: number, d: number) => void;
23
+ export const udoc_pdf_decompress: (a: number, b: number, c: number, d: number) => void;
24
+ export const udoc_pdf_extract_fonts: (a: number, b: number, c: number, d: number) => void;
25
+ export const udoc_pdf_extract_images: (a: number, b: number, c: number, d: number, e: number) => void;
26
+ export const udoc_pdf_split_by_outline: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
22
27
  export const udoc_remove_document: (a: number, b: number, c: number) => number;
23
28
  export const udoc_render_page_to_png: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
24
29
  export const udoc_render_page_to_rgba: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
@@ -2,10 +2,11 @@
2
2
  * Low-level client for communicating with the UDoc worker.
3
3
  *
4
4
  * Provides a Promise-based API for document operations.
5
+ * Also handles render queue, cache, and priority management.
5
6
  * This is an internal API - use UDocClient for the public SDK.
6
7
  */
7
- import type { Composition, ComposePick, LicenseResult } from "./worker.js";
8
- export type { Composition, ComposePick };
8
+ import type { Composition, ComposePick, ExtractedFont, ExtractedImage, LicenseResult, OutlineSection, SplitByOutlineResult } from "./worker.js";
9
+ export type { Composition, ComposePick, ExtractedFont, ExtractedImage, OutlineSection, SplitByOutlineResult };
9
10
  export type { LicenseResult };
10
11
  export interface PageInfo {
11
12
  width: number;
@@ -13,8 +14,15 @@ export interface PageInfo {
13
14
  /** Document rotation in degrees (0, 90, 180, or 270) */
14
15
  rotation: 0 | 90 | 180 | 270;
15
16
  }
16
- export interface RenderedPage {
17
- rgba: Uint8Array;
17
+ export type RenderType = "page" | "thumbnail";
18
+ export interface RenderRequest {
19
+ docId: string;
20
+ page: number;
21
+ type: RenderType;
22
+ scale: number;
23
+ }
24
+ export interface RenderResult {
25
+ bitmap: ImageBitmap;
18
26
  width: number;
19
27
  height: number;
20
28
  }
@@ -22,6 +30,12 @@ export declare class WorkerClient {
22
30
  private worker;
23
31
  private requestId;
24
32
  private pending;
33
+ private renderCache;
34
+ private renderQueue;
35
+ private renderInFlight;
36
+ private maxCacheSize;
37
+ private maxConcurrent;
38
+ private activeRenderCount;
25
39
  private constructor();
26
40
  /**
27
41
  * Create a WorkerClient using the bundled worker.
@@ -74,10 +88,6 @@ export declare class WorkerClient {
74
88
  * Get the page layout preference.
75
89
  */
76
90
  getPageLayout(id: string): Promise<string>;
77
- /**
78
- * Render a page to RGBA pixels.
79
- */
80
- renderPage(id: string, pageIndex: number, width: number, height: number): Promise<RenderedPage>;
81
91
  /**
82
92
  * Get the document outline.
83
93
  */
@@ -98,11 +108,85 @@ export declare class WorkerClient {
98
108
  * @param docIds - Array of document IDs to use as sources (order matters for doc indices)
99
109
  * @returns Array of new document IDs (one per composition)
100
110
  */
101
- composePdf(compositions: Composition[], docIds: string[]): Promise<string[]>;
111
+ pdfCompose(compositions: Composition[], docIds: string[]): Promise<string[]>;
112
+ /**
113
+ * Split a PDF document by its outline (bookmarks) structure.
114
+ *
115
+ * @param id - Document ID to split
116
+ * @param maxLevel - Maximum outline level to consider (1 = top level only)
117
+ * @param splitMidPage - When true, filters page content when sections share a page
118
+ * @returns Object with documentIds and sections
119
+ */
120
+ pdfSplitByOutline(id: string, maxLevel: number, splitMidPage?: boolean): Promise<SplitByOutlineResult>;
121
+ /**
122
+ * Extract all embedded images from a PDF document.
123
+ *
124
+ * @param id - Document ID to extract images from
125
+ * @param convertRawToPng - When true, converts raw pixel data to PNG format
126
+ * @returns Array of extracted images with metadata and data
127
+ */
128
+ pdfExtractImages(id: string, convertRawToPng?: boolean): Promise<ExtractedImage[]>;
129
+ /**
130
+ * Extract all embedded fonts from a PDF document.
131
+ *
132
+ * @param id - Document ID to extract fonts from
133
+ * @returns Array of extracted fonts with metadata and data
134
+ */
135
+ pdfExtractFonts(id: string): Promise<ExtractedFont[]>;
136
+ /**
137
+ * Compress a PDF document.
138
+ *
139
+ * Saves the document with full compression options enabled.
140
+ *
141
+ * @param id - Document ID to compress
142
+ * @returns Compressed PDF data
143
+ */
144
+ pdfCompress(id: string): Promise<Uint8Array>;
145
+ /**
146
+ * Decompress a PDF document.
147
+ *
148
+ * Removes all filter encodings from streams, resulting in raw,
149
+ * uncompressed stream data.
150
+ *
151
+ * @param id - Document ID to decompress
152
+ * @returns Decompressed PDF data
153
+ */
154
+ pdfDecompress(id: string): Promise<Uint8Array>;
102
155
  /**
103
156
  * Get the raw PDF bytes of a document.
104
157
  */
105
158
  getBytes(id: string): Promise<Uint8Array>;
159
+ /**
160
+ * Request a render. Returns cached result if available,
161
+ * otherwise queues the request.
162
+ */
163
+ requestRender(req: RenderRequest): Promise<RenderResult>;
164
+ /**
165
+ * Get a cached result without queuing a render.
166
+ */
167
+ getCachedRender(docId: string, page: number, type: RenderType, scale: number): RenderResult | null;
168
+ /**
169
+ * Cancel pending render requests matching criteria.
170
+ * Does not cancel in-flight requests.
171
+ */
172
+ cancelRenders(docId?: string, page?: number, type?: RenderType): void;
173
+ /**
174
+ * Invalidate cache entries. Call when document or zoom changes.
175
+ */
176
+ invalidateRenderCache(docId?: string): void;
177
+ /**
178
+ * Boost priority for the target page and nearby pages.
179
+ * Target page gets highest priority, nearby pages get slightly lower.
180
+ */
181
+ boostRenderPriority(docId: string, page: number): void;
182
+ /**
183
+ * Clean up render resources.
184
+ */
185
+ destroyRenderResources(): void;
186
+ private processRenderQueue;
187
+ private doRender;
188
+ private addToRenderCache;
189
+ private evictLRU;
106
190
  /**
107
191
  * Terminate the worker.
108
192
  */
@@ -1 +1 @@
1
- {"version":3,"file":"WorkerClient.d.ts","sourceRoot":"","sources":["../../../src/worker/WorkerClient.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAiC,MAAM,aAAa,CAAC;AAE1G,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC;AAEzC,YAAY,EAAE,aAAa,EAAE,C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