Skip to content

Commit

Permalink
feat!: deprecate defineUnPDFConfig for configureUnPDF
Browse files Browse the repository at this point in the history
  • Loading branch information
johannschopplich committed Nov 9, 2023
1 parent 02afd71 commit 014a6ea
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,11 @@ for (let i = 1; i <= doc.numPages; i++) {
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.

```ts
// Before using any other methods, define the PDF.js module
import { defineUnPDFConfig } from "unpdf";
// Before using any other method, define the PDF.js module
// if you need another PDF.js build
import { configureUnPDF } from "unpdf";

defineUnPDFConfig({
configureUnPDF({
// Use the official PDF.js build (make sure to install it first)
pdfjs: () => import("pdfjs-dist"),
});
Expand Down Expand Up @@ -118,12 +119,12 @@ interface UnPDFConfiguration {

## Methods

### `defineUnPDFConfig`
### `configureUnPDF`

Define a custom PDF.js module, like the legacy build. Make sure to call this method before using any other methods.

```ts
function defineUnPDFConfig(config: UnPDFConfiguration): Promise<void>;
function configureUnPDF(config: UnPDFConfiguration): Promise<void>;
```

### `getResolvedPDFJS`
Expand Down Expand Up @@ -172,9 +173,9 @@ In order to use this method, you have to meet the following requirements:
**Example**

```ts
import { defineUnPDFConfig, renderPageAsImage } from "unpdf";
import { configureUnPDF, renderPageAsImage } from "unpdf";

defineUnPDFConfig({
configureUnPDF({
// Use the official PDF.js build
pdfjs: () => import("pdfjs-dist"),
});
Expand Down
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { resolvePDFJSImports } from "./utils";
import type { UnPDFConfiguration } from "./types";

export async function defineUnPDFConfig(options: UnPDFConfiguration) {
export async function configureUnPDF(options: UnPDFConfiguration) {
const { pdfjs } = { ...options };

if (pdfjs) {
Expand Down
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@ import {
renderPageAsImage as _renderPageAsImage,
} from "./image";
import { resolvePDFJSImports } from "./utils";
import { configureUnPDF } from "./config";

export { defineUnPDFConfig } from "./config";
export {
getDocumentProxy,
getResolvedPDFJS,
resolvePDFJSImports,
} from "./utils";

export { configureUnPDF } from "./config";
/** @deprecated Use `configureUnPDF` instead */
const defineUnPDFConfig = configureUnPDF;
export { defineUnPDFConfig };

export const getMeta: typeof _getMeta = async (...args) => {
await resolvePDFJSImports();
return await _getMeta(...args);
Expand Down

0 comments on commit 014a6ea

Please sign in to comment.