Skip to content

Commit

Permalink
Update types 🚁
Browse files Browse the repository at this point in the history
  • Loading branch information
hyzyla committed Sep 1, 2023
1 parent af5d0b0 commit 7aff75d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
15 changes: 8 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sharp from 'sharp';

import pdfium from './vendor/pdfium';
import vendor from './vendor/pdfium';
import type * as t from './vendor/pdfium';

const BYTES_PER_PIXEL = 4;

Expand Down Expand Up @@ -73,9 +74,9 @@ export type PDFiumPageRender = {
};

export class PDFiumLibrary {
module: any;
module: t.PDFium;
static async init() {
const module = await pdfium();
const module = await vendor();
module._FPDF_InitLibraryWithConfig({
version: 2,
m_pIsolate: null,
Expand All @@ -87,7 +88,7 @@ export class PDFiumLibrary {
return new PDFiumLibrary(module);
}

constructor(module: any) {
constructor(module: t.PDFium) {
this.module = module;
}

Expand All @@ -112,10 +113,10 @@ export class PDFiumLibrary {
}

export class PDFiumDocument {
module: any;
documentPointer: any;
module: t.PDFium;
documentPointer: number;
documentHandle: any;
constructor(module: any, documentPointer: any, documentHandle: any) {
constructor(module: t.PDFium, documentPointer: number, documentHandle: any) {
this.module = module;
this.documentPointer = documentPointer;
this.documentHandle = documentHandle;
Expand Down
5 changes: 3 additions & 2 deletions src/vendor/pdfium.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
declare type PDFium = {
export declare type PDFium = {
_FPDF_InitLibraryWithConfig: (config: any) => void;
_FPDF_LoadMemDocument: (ptr: number, size: number, password: string) => any;
_FPDF_GetLastError: () => number;
Expand All @@ -21,13 +21,14 @@ declare type PDFium = {
flags: number
) => void;
_FPDFBitmap_Destroy: (bitmap: any) => void;
_FPDF_CloseDocument(document: any): void;
asm: {
malloc: (size: number) => number;
free: (ptr: number) => void;
};
HEAPU8: Uint8Array;
};

declare function loadPdfium(): Promise<PDFium>;
export declare function loadPdfium(): Promise<PDFium>;

export default loadPdfium;

0 comments on commit 7aff75d

Please sign in to comment.