Skip to content

Commit

Permalink
Fix types and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hyzyla committed Aug 31, 2024
1 parent cd6bb1b commit be183e5
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/index.cjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export * from "./index";
import { PDFiumLibrary as _PDFiumLibrary } from "./library";
import vendor from "./vendor/pdfium";

export class PDFiumLibrary {
export class PDFiumLibrary extends _PDFiumLibrary {
static async init(options?: {
wasmBinary?: ArrayBuffer;
wasmUrl?: string;
Expand Down
2 changes: 1 addition & 1 deletion src/index.esm.base64.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function base64ToUint8Array(base64: string) {
return bytes;
}

export class PDFiumLibrary {
export class PDFiumLibrary extends _PDFiumLibrary {
static async init() {
const base64 = await import("./vendor/pdfium.wasm.base64");
const wasmBinary = base64ToUint8Array(base64.PDFIUM_WASM_BASE64);
Expand Down
2 changes: 1 addition & 1 deletion src/index.esm.cdn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const CDN_WARNING = `
@hyzyla/pdfium: The PDFium WASM binary is loaded from a CDN. This may be slower than loading the binary from the local server. You can disable this warning by setting the 'disableCDNWarning' option to 'true' when calling PDFiumLibrary.init().
`;

export class PDFiumLibrary {
export class PDFiumLibrary extends _PDFiumLibrary {
static _cache: ArrayBuffer | null = null;

static async init(options?: { disableCDNWarning?: boolean }) {
Expand Down
2 changes: 1 addition & 1 deletion src/index.esm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export * from "./index";
import { PDFiumLibrary as _PDFiumLibrary } from "./library";
import vendor from "./vendor/pdfium.esm";

export class PDFiumLibrary {
export class PDFiumLibrary extends _PDFiumLibrary {
static async init(options?: {
wasmBinary?: ArrayBuffer;
wasmUrl?: string;
Expand Down
8 changes: 5 additions & 3 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import sharp from "sharp";
import { toMatchImageSnapshot } from "jest-image-snapshot";
import { test, describe, expect, beforeAll, afterAll } from "vitest";

import { type PDFiumDocument, PDFiumLibrary, PDFiumPage, PDFiumPageRenderOptions } from "../src/index";
import { type PDFiumDocument, PDFiumLibrary, PDFiumPage, PDFiumPageRenderOptions } from "../src/index.esm";
import type { PDFiumImageObject } from "../src/objects";


Expand Down Expand Up @@ -35,11 +35,13 @@ test("adds 1 + 2 to equal 3", () => {
describe("PDFium", () => {
let library: PDFiumLibrary;
beforeAll(async () => {
library = await PDFiumLibrary.init();
library = await PDFiumLibrary.init({
wasmBinary: await fs.readFile("./src/vendor/pdfium.wasm"),
});
});

afterAll(() => {
library.destroy();
library?.destroy();
});

async function loadDocument(
Expand Down

0 comments on commit be183e5

Please sign in to comment.