diff options
Diffstat (limited to 'lib/index.d.ts')
| -rw-r--r-- | lib/index.d.ts | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/lib/index.d.ts b/lib/index.d.ts new file mode 100644 index 0000000..0950b54 --- /dev/null +++ b/lib/index.d.ts @@ -0,0 +1,78 @@ +interface Mammoth { + convertToHtml: (input: Input, options?: Options) => Promise<Result>; + extractRawText: (input: Input) => Promise<Result>; + embedStyleMap: (input: Input, styleMap: string) => Promise<{toBuffer: () => Buffer}>; + images: Images; +} + +type Input = NodeJsInput | BrowserInput; + +type NodeJsInput = PathInput | BufferInput; + +interface PathInput { + path: string; +} + +interface BufferInput { + buffer: Buffer; +} + +type BrowserInput = ArrayBufferInput; + +interface ArrayBufferInput { + arrayBuffer: ArrayBuffer; +} + +interface Options { + styleMap?: string | Array<string>; + includeEmbeddedStyleMap?: boolean; + includeDefaultStyleMap?: boolean; + convertImage?: ImageConverter; + ignoreEmptyParagraphs?: boolean; + idPrefix?: string; +} + +interface ImageConverter { + __mammothBrand: "ImageConverter"; +} + +interface Image { + contentType: string; + read: ImageRead; +} + +interface ImageRead { + (): Promise<Buffer>; + (encoding: string): Promise<string>; +} + +interface ImageAttributes { + src: string; +} + +interface Images { + dataUri: ImageConverter; + imgElement: (f: (image: Image) => Promise<ImageAttributes>) => ImageConverter; +} + +interface Result { + value: string; + messages: Array<Message>; +} + +type Message = Warning | Error; + +interface Warning { + type: "warning"; + message: string; +} + +interface Error { + type: "error"; + message: string; + error: unknown; +} + +declare const mammoth: Mammoth; + +export = mammoth; |
