unpdf 1.0.0 → 1.0.2

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.
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # unpdf
2
2
 
3
- A collection of utilities for working with PDF files. Designed specifically for Bun, Deno, and serverless environments. However, it also works in Node.js and the browser.
3
+ A collection of utilities for PDF extraction and rendering. Designed specifically for Bun, Deno, and serverless environments. However, it also works in Node.js and the browser.
4
4
 
5
- `unpdf` ships with a serverless build/redistribution of Mozilla's [PDF.js](https://github.com/mozilla/pdf.js) for serverless environments. Apart from some string replacements and mocks, [`unenv`](https://github.com/unjs/unenv) does the heavy lifting by converting Node.js specific code to be platform-agnostic. See [`pdfjs.rollup.config.ts`](./pdfjs.rollup.config.ts) for all the details.
5
+ `unpdf` ships with a serverless build/redistribution of Mozilla's [PDF.js](https://github.com/mozilla/pdf.js) for serverless environments. Some string replacements and inlining the PDF.js worker allow the browser code to become platform agnostic. See [`pdfjs.rollup.config.ts`](./pdfjs.rollup.config.ts) for all the details.
6
6
 
7
7
  This library is also intended as a modern alternative to the unmaintained but still popular [`pdf-parse`](https://www.npmjs.com/package/pdf-parse).
8
8
 
package/dist/index.cjs CHANGED
@@ -29,16 +29,13 @@ async function resolvePDFJSImport(pdfjsResolver, { reload = false } = {}) {
29
29
  resolvedModule = await interopDefault(pdfjsResolver());
30
30
  return;
31
31
  } catch (error) {
32
- console.error(error);
33
- throw new Error("PDF.js could not be resolved. Please check the resolver function.");
32
+ throw new Error(`PDF.js could not be resolved: ${error}`);
34
33
  }
35
34
  }
36
35
  try {
37
- const { resolvePDFJS } = await import('unpdf/pdfjs');
38
- resolvedModule = await resolvePDFJS();
36
+ resolvedModule = await import('unpdf/pdfjs');
39
37
  } catch (error) {
40
- console.error(error);
41
- throw new Error("PDF.js package not available. Please install it first.");
38
+ throw new Error(`Built-in PDF.js module could not be resolved: ${error}`);
42
39
  }
43
40
  }
44
41
  function isPDFDocumentProxy(data) {
@@ -208,7 +205,7 @@ async function getMeta$1(data) {
208
205
  const meta = await pdf.getMetadata();
209
206
  return {
210
207
  info: meta?.info ?? {},
211
- metadata: meta?.metadata?.getAll() ?? {}
208
+ metadata: { ...meta?.metadata }
212
209
  };
213
210
  }
214
211
 
package/dist/index.mjs CHANGED
@@ -27,16 +27,13 @@ async function resolvePDFJSImport(pdfjsResolver, { reload = false } = {}) {
27
27
  resolvedModule = await interopDefault(pdfjsResolver());
28
28
  return;
29
29
  } catch (error) {
30
- console.error(error);
31
- throw new Error("PDF.js could not be resolved. Please check the resolver function.");
30
+ throw new Error(`PDF.js could not be resolved: ${error}`);
32
31
  }
33
32
  }
34
33
  try {
35
- const { resolvePDFJS } = await import('unpdf/pdfjs');
36
- resolvedModule = await resolvePDFJS();
34
+ resolvedModule = await import('unpdf/pdfjs');
37
35
  } catch (error) {
38
- console.error(error);
39
- throw new Error("PDF.js package not available. Please install it first.");
36
+ throw new Error(`Built-in PDF.js module could not be resolved: ${error}`);
40
37
  }
41
38
  }
42
39
  function isPDFDocumentProxy(data) {
@@ -206,7 +203,7 @@ async function getMeta$1(data) {
206
203
  const meta = await pdf.getMetadata();
207
204
  return {
208
205
  info: meta?.info ?? {},
209
- metadata: meta?.metadata?.getAll() ?? {}
206
+ metadata: { ...meta?.metadata }
210
207
  };
211
208
  }
212
209
 
package/dist/pdfjs.d.mts CHANGED
@@ -1,4 +1 @@
1
- import * as PDFJS from './types/src/pdf'
2
- declare function resolvePDFJS(): Promise<typeof PDFJS>
3
- export { resolvePDFJS }
4
1
  export * from './types/src/pdf'
package/dist/pdfjs.d.ts CHANGED
@@ -1,4 +1 @@
1
- import * as PDFJS from './types/src/pdf'
2
- declare function resolvePDFJS(): Promise<typeof PDFJS>
3
- export { resolvePDFJS }
4
1
  export * from './types/src/pdf'