unpdf 0.11.0 → 0.12.0

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 (43) hide show
  1. package/README.md +4 -2
  2. package/dist/index.cjs +9 -3
  3. package/dist/index.mjs +9 -3
  4. package/dist/pdfjs.mjs +1 -1
  5. package/dist/types/src/display/annotation_layer.d.ts +3 -3
  6. package/dist/types/src/display/annotation_storage.d.ts +9 -0
  7. package/dist/types/src/display/api.d.ts +48 -26
  8. package/dist/types/src/display/base_factory.d.ts +4 -0
  9. package/dist/types/src/display/canvas.d.ts +2 -0
  10. package/dist/types/src/display/display_utils.d.ts +2 -1
  11. package/dist/types/src/display/draw_layer.d.ts +1 -1
  12. package/dist/types/src/display/editor/alt_text.d.ts +14 -3
  13. package/dist/types/src/display/editor/annotation_editor_layer.d.ts +3 -1
  14. package/dist/types/src/display/editor/editor.d.ts +11 -2
  15. package/dist/types/src/display/editor/freetext.d.ts +2 -2
  16. package/dist/types/src/display/editor/highlight.d.ts +4 -4
  17. package/dist/types/src/display/editor/ink.d.ts +4 -3
  18. package/dist/types/src/display/editor/outliner.d.ts +3 -3
  19. package/dist/types/src/display/editor/stamp.d.ts +21 -0
  20. package/dist/types/src/display/editor/toolbar.d.ts +3 -2
  21. package/dist/types/src/display/editor/tools.d.ts +20 -5
  22. package/dist/types/src/display/node_stream.d.ts +1 -1
  23. package/dist/types/src/display/text_layer.d.ts +10 -11
  24. package/dist/types/src/display/worker_options.d.ts +2 -2
  25. package/dist/types/src/pdf.d.ts +1 -4
  26. package/dist/types/src/shared/util.d.ts +3 -0
  27. package/dist/types/web/annotation_layer_builder.d.ts +1 -0
  28. package/dist/types/web/app_options.d.ts +4 -2
  29. package/dist/types/web/download_manager.d.ts +1 -2
  30. package/dist/types/web/event_utils.d.ts +8 -6
  31. package/dist/types/web/genericl10n.d.ts +5 -5
  32. package/dist/types/web/interfaces.d.ts +2 -9
  33. package/dist/types/web/l10n.d.ts +6 -2
  34. package/dist/types/web/pdf_find_controller.d.ts +24 -0
  35. package/dist/types/web/pdf_link_service.d.ts +1 -1
  36. package/dist/types/web/pdf_page_view.d.ts +12 -6
  37. package/dist/types/web/pdf_thumbnail_view.d.ts +11 -3
  38. package/dist/types/web/pdf_thumbnail_viewer.d.ts +16 -1
  39. package/dist/types/web/pdf_viewer.d.ts +22 -6
  40. package/dist/types/web/text_accessibility.d.ts +1 -1
  41. package/dist/types/web/text_layer_builder.d.ts +4 -4
  42. package/dist/types/web/ui_utils.d.ts +7 -2
  43. package/package.json +21 -21
package/README.md CHANGED
@@ -16,8 +16,7 @@ This library is also intended as a modern alternative to the unmaintained but st
16
16
 
17
17
  ## PDF.js Compatibility
18
18
 
19
- > [!NOTE]
20
- > This package is currently using PDF.js v4.3.136.
19
+ The serverless build of PDF.js provided by `unpdf` is based on PDF.js v4.6.82. If you need a different version, you can [use another PDF.js build](#use-official-or-legacy-pdfjs-build).
21
20
 
22
21
  ## Installation
23
22
 
@@ -86,6 +85,9 @@ for (let i = 1; i <= doc.numPages; i++) {
86
85
 
87
86
  Generally speaking, you don't need to worry about the PDF.js build. `unpdf` ships with a serverless build of the latest PDF.js version. However, if you want to use the official PDF.js version or the legacy build, you can define a custom PDF.js module.
88
87
 
88
+ > [!WARNING]
89
+ > The latest PDF.js v4.6.82 uses `Promise.withResolvers`, which may not be supported in all environments, such as Node < 22. Consider to use the bundled serverless build, which includes a polyfill, or use an older version of PDF.js.
90
+
89
91
  ```ts
90
92
  // Before using any other method, define the PDF.js module
91
93
  // if you need another PDF.js build
package/dist/index.cjs CHANGED
@@ -31,16 +31,18 @@ async function resolvePDFJSImports(pdfjsResolver, { force = false } = {}) {
31
31
  resolvedModule = await resolvedModule.resolvePDFJS();
32
32
  }
33
33
  return;
34
- } catch {
34
+ } catch (error) {
35
+ console.error(error);
35
36
  throw new Error(
36
37
  "Resolving failed. Please check the provided configuration."
37
38
  );
38
39
  }
39
40
  }
40
41
  try {
41
- const { resolvePDFJS } = await import('unpdf/pdfjs');
42
+ const { resolvePDFJS } = await Promise.resolve().then(function () { return pdfjs; });
42
43
  resolvedModule = await resolvePDFJS();
43
- } catch {
44
+ } catch (error) {
45
+ console.error(error);
44
46
  throw new Error(
45
47
  "PDF.js is not available. Please add the package as a dependency."
46
48
  );
@@ -199,6 +201,10 @@ const renderPageAsImage = async (...args) => {
199
201
  return await renderPageAsImage$1(...args);
200
202
  };
201
203
 
204
+ const pdfjs = {
205
+ __proto__: null
206
+ };
207
+
202
208
  exports.configureUnPDF = configureUnPDF;
203
209
  exports.createIsomorphicCanvasFactory = createIsomorphicCanvasFactory;
204
210
  exports.extractImages = extractImages;
package/dist/index.mjs CHANGED
@@ -29,16 +29,18 @@ async function resolvePDFJSImports(pdfjsResolver, { force = false } = {}) {
29
29
  resolvedModule = await resolvedModule.resolvePDFJS();
30
30
  }
31
31
  return;
32
- } catch {
32
+ } catch (error) {
33
+ console.error(error);
33
34
  throw new Error(
34
35
  "Resolving failed. Please check the provided configuration."
35
36
  );
36
37
  }
37
38
  }
38
39
  try {
39
- const { resolvePDFJS } = await import('unpdf/pdfjs');
40
+ const { resolvePDFJS } = await Promise.resolve().then(function () { return pdfjs; });
40
41
  resolvedModule = await resolvePDFJS();
41
- } catch {
42
+ } catch (error) {
43
+ console.error(error);
42
44
  throw new Error(
43
45
  "PDF.js is not available. Please add the package as a dependency."
44
46
  );
@@ -197,4 +199,8 @@ const renderPageAsImage = async (...args) => {
197
199
  return await renderPageAsImage$1(...args);
198
200
  };
199
201
 
202
+ const pdfjs = {
203
+ __proto__: null
204
+ };
205
+
200
206
  export { configureUnPDF, createIsomorphicCanvasFactory, extractImages, extractText, getDocumentProxy, getMeta, getResolvedPDFJS, renderPageAsImage, resolvePDFJSImports };