@vertesia/converters 0.24.0-dev.202601221707
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/LICENSE +13 -0
- package/README.md +139 -0
- package/lib/esm/image.js +57 -0
- package/lib/esm/image.js.map +1 -0
- package/lib/esm/index.js +5 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/mutool.js +39 -0
- package/lib/esm/mutool.js.map +1 -0
- package/lib/esm/pandoc.js +40 -0
- package/lib/esm/pandoc.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/types/image.d.ts +16 -0
- package/lib/types/image.d.ts.map +1 -0
- package/lib/types/index.d.ts +4 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/mutool.d.ts +3 -0
- package/lib/types/mutool.d.ts.map +1 -0
- package/lib/types/pandoc.d.ts +6 -0
- package/lib/types/pandoc.d.ts.map +1 -0
- package/package.json +51 -0
- package/src/image.test.ts +25 -0
- package/src/image.ts +78 -0
- package/src/index.ts +12 -0
- package/src/mutool.test.ts +14 -0
- package/src/mutool.ts +45 -0
- package/src/pandoc.test.ts +14 -0
- package/src/pandoc.ts +46 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2024 Composable
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# @vertesia/converters
|
|
2
|
+
|
|
3
|
+
Image and document conversion utilities for Node.js. Provides functions for image transformation, PDF to text extraction, and document to Markdown conversion.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Image Transformation**: Resize and convert images using Sharp
|
|
8
|
+
- **PDF to Text**: Extract text from PDF files using MuTool
|
|
9
|
+
- **Document to Markdown**: Convert various document formats to Markdown using Pandoc
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @vertesia/converters
|
|
15
|
+
# or
|
|
16
|
+
pnpm add @vertesia/converters
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### System Dependencies
|
|
20
|
+
|
|
21
|
+
Some converters require external tools to be installed:
|
|
22
|
+
|
|
23
|
+
- **Image conversion**: No external dependencies (uses Sharp)
|
|
24
|
+
- **PDF to text**: Requires [MuTool](https://mupdf.com/docs/mutool.html) (`mutool` command)
|
|
25
|
+
- **Document to Markdown**: Requires [Pandoc](https://pandoc.org/) (`pandoc` command)
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
### Image Transformation
|
|
30
|
+
|
|
31
|
+
Transform images with resizing and format conversion:
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import {
|
|
35
|
+
transformImage,
|
|
36
|
+
transformImageToBuffer,
|
|
37
|
+
transformImageToFile
|
|
38
|
+
} from '@vertesia/converters';
|
|
39
|
+
|
|
40
|
+
// Transform image to a stream
|
|
41
|
+
import { createReadStream, createWriteStream } from 'fs';
|
|
42
|
+
|
|
43
|
+
const input = createReadStream('input.jpg');
|
|
44
|
+
const output = createWriteStream('output.webp');
|
|
45
|
+
|
|
46
|
+
await transformImage(input, output, {
|
|
47
|
+
max_hw: 1024, // Max width/height (maintains aspect ratio)
|
|
48
|
+
format: 'webp' // Output format
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// Transform image to buffer
|
|
52
|
+
const buffer = await transformImageToBuffer(inputBuffer, {
|
|
53
|
+
max_hw: 800,
|
|
54
|
+
format: 'png'
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// Transform image to file
|
|
58
|
+
await transformImageToFile(inputBuffer, 'output.jpg', {
|
|
59
|
+
max_hw: 1200,
|
|
60
|
+
format: 'jpeg'
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### PDF to Text
|
|
65
|
+
|
|
66
|
+
Extract text content from PDF files:
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
import { pdfToText, pdfToTextBuffer, pdfFileToText } from '@vertesia/converters';
|
|
70
|
+
|
|
71
|
+
// From buffer to string
|
|
72
|
+
const text = await pdfToText(pdfBuffer);
|
|
73
|
+
|
|
74
|
+
// From buffer to buffer
|
|
75
|
+
const textBuffer = await pdfToTextBuffer(pdfBuffer);
|
|
76
|
+
|
|
77
|
+
// From file to file
|
|
78
|
+
await pdfFileToText('input.pdf', 'output.txt');
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Document to Markdown
|
|
82
|
+
|
|
83
|
+
Convert documents to Markdown format using Pandoc:
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
import { manyToMarkdown } from '@vertesia/converters';
|
|
87
|
+
import { createReadStream } from 'fs';
|
|
88
|
+
|
|
89
|
+
// Convert DOCX to Markdown
|
|
90
|
+
const stream = createReadStream('document.docx');
|
|
91
|
+
const markdown = await manyToMarkdown(stream, 'docx');
|
|
92
|
+
|
|
93
|
+
// Convert HTML to Markdown
|
|
94
|
+
const htmlStream = createReadStream('page.html');
|
|
95
|
+
const md = await manyToMarkdown(htmlStream, 'html');
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Supported input formats include all formats supported by Pandoc: `docx`, `html`, `latex`, `rst`, `textile`, `org`, `mediawiki`, and many more.
|
|
99
|
+
|
|
100
|
+
## API Reference
|
|
101
|
+
|
|
102
|
+
### Image Functions
|
|
103
|
+
|
|
104
|
+
| Function | Description |
|
|
105
|
+
|----------|-------------|
|
|
106
|
+
| `transformImage(input, output, opts)` | Transform image from stream to stream |
|
|
107
|
+
| `transformImageToBuffer(input, opts)` | Transform image to buffer |
|
|
108
|
+
| `transformImageToFile(input, output, opts)` | Transform image to file |
|
|
109
|
+
|
|
110
|
+
#### TransformOptions
|
|
111
|
+
|
|
112
|
+
| Option | Type | Description |
|
|
113
|
+
|--------|------|-------------|
|
|
114
|
+
| `max_hw` | `number` | Maximum width/height (maintains aspect ratio, no upscaling) |
|
|
115
|
+
| `format` | `string` | Output format (`jpeg`, `png`, `webp`, `avif`, etc.) |
|
|
116
|
+
|
|
117
|
+
### PDF Functions
|
|
118
|
+
|
|
119
|
+
| Function | Description |
|
|
120
|
+
|----------|-------------|
|
|
121
|
+
| `pdfToText(buffer)` | Convert PDF buffer to text string |
|
|
122
|
+
| `pdfToTextBuffer(buffer)` | Convert PDF buffer to text buffer |
|
|
123
|
+
| `pdfFileToText(input, output)` | Convert PDF file to text file |
|
|
124
|
+
|
|
125
|
+
### Document Functions
|
|
126
|
+
|
|
127
|
+
| Function | Description |
|
|
128
|
+
|----------|-------------|
|
|
129
|
+
| `manyToMarkdown(stream, format)` | Convert document stream to Markdown |
|
|
130
|
+
|
|
131
|
+
## Requirements
|
|
132
|
+
|
|
133
|
+
- Node.js 18+
|
|
134
|
+
- MuTool (for PDF conversion)
|
|
135
|
+
- Pandoc (for document conversion)
|
|
136
|
+
|
|
137
|
+
## License
|
|
138
|
+
|
|
139
|
+
Apache-2.0
|
package/lib/esm/image.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import sharp from "sharp";
|
|
2
|
+
export function createImageTransformer(input, opts) {
|
|
3
|
+
const isInputStream = !!input.pipe;
|
|
4
|
+
let sh = isInputStream ? input.pipe(sharp()) : sharp(input);
|
|
5
|
+
if (opts.max_hw) {
|
|
6
|
+
sh = sh.resize({
|
|
7
|
+
width: opts.max_hw,
|
|
8
|
+
height: opts.max_hw,
|
|
9
|
+
fit: sharp.fit.inside,
|
|
10
|
+
withoutEnlargement: true,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
if (opts.format) {
|
|
14
|
+
sh = sh.toFormat(opts.format);
|
|
15
|
+
}
|
|
16
|
+
return sh;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* @param max_hw
|
|
20
|
+
* @param format
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
23
|
+
export async function transformImage(input, output, opts) {
|
|
24
|
+
const sh = createImageTransformer(input, opts);
|
|
25
|
+
sh.pipe(output);
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
const handleError = (err) => {
|
|
28
|
+
console.error('Failed to transform', err);
|
|
29
|
+
try {
|
|
30
|
+
if (input.pipe && input.destroy) {
|
|
31
|
+
input.destroy();
|
|
32
|
+
}
|
|
33
|
+
if (output.destroy) {
|
|
34
|
+
output.destroy();
|
|
35
|
+
}
|
|
36
|
+
sh.destroy();
|
|
37
|
+
}
|
|
38
|
+
finally {
|
|
39
|
+
reject(err);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
output.on('error', handleError);
|
|
43
|
+
input.pipe && input.on && input.on('error', handleError);
|
|
44
|
+
output.on("finish", () => {
|
|
45
|
+
resolve(sh);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
export function transformImageToBuffer(input, opts) {
|
|
50
|
+
const sh = createImageTransformer(input, opts);
|
|
51
|
+
return sh.toBuffer();
|
|
52
|
+
}
|
|
53
|
+
export async function transformImageToFile(input, output, opts) {
|
|
54
|
+
const sh = createImageTransformer(input, opts);
|
|
55
|
+
await sh.toFile(output);
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.js","sourceRoot":"","sources":["../../src/image.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAoB1B,MAAM,UAAU,sBAAsB,CAAC,KAAqB,EAAE,IAAsB;IAChF,MAAM,aAAa,GAAG,CAAC,CAAE,KAA+B,CAAC,IAAI,CAAC;IAC9D,IAAI,EAAE,GAAG,aAAa,CAAC,CAAC,CAAE,KAA+B,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAY,CAAC,CAAC;IAC9F,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC;YACX,KAAK,EAAE,IAAI,CAAC,MAAM;YAClB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,MAAM;YACrB,kBAAkB,EAAE,IAAI;SAC3B,CAAC,CAAC;IACP,CAAC;IACD,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,EAAE,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,KAAqB,EAAE,MAA6B,EAAE,IAAsB;IAC7G,MAAM,EAAE,GAAG,sBAAsB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC/C,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAEhB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACnC,MAAM,WAAW,GAAG,CAAC,GAAQ,EAAE,EAAE;YAC7B,OAAO,CAAC,KAAK,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAC;YAC1C,IAAI,CAAC;gBACD,IAAK,KAAa,CAAC,IAAI,IAAK,KAAa,CAAC,OAAO,EAAE,CAAC;oBAC/C,KAAa,CAAC,OAAO,EAAE,CAAC;gBAC7B,CAAC;gBACD,IAAK,MAAc,CAAC,OAAO,EAAE,CAAC;oBACzB,MAAc,CAAC,OAAO,EAAE,CAAC;gBAC9B,CAAC;gBACD,EAAE,CAAC,OAAO,EAAE,CAAC;YACjB,CAAC;oBAAS,CAAC;gBACP,MAAM,CAAC,GAAG,CAAC,CAAC;YAChB,CAAC;QACL,CAAC,CAAA;QACD,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QAC/B,KAAa,CAAC,IAAI,IAAK,KAAa,CAAC,EAAE,IAAK,KAAa,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QACpF,MAAM,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;YACrB,OAAO,CAAC,EAAE,CAAC,CAAC;QAChB,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,KAAqB,EAAE,IAAsB;IAChF,MAAM,EAAE,GAAG,sBAAsB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC/C,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC;AACzB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,KAAqB,EAAE,MAAc,EAAE,IAAsB;IACpG,MAAM,EAAE,GAAG,sBAAsB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC/C,MAAM,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC5B,CAAC"}
|
package/lib/esm/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { transformImage, transformImageToBuffer, transformImageToFile } from './image.js';
|
|
2
|
+
import { pdfFileToText, pdfToText, pdfToTextBuffer } from './mutool.js';
|
|
3
|
+
import { manyToMarkdown } from './pandoc.js';
|
|
4
|
+
export { manyToMarkdown, pdfFileToText, pdfToText, pdfToTextBuffer, transformImage, transformImageToBuffer, transformImageToFile };
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAC1F,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,EACH,cAAc,EACd,aAAa,EAAE,SAAS,EACxB,eAAe,EACf,cAAc,EACd,sBAAsB,EACtB,oBAAoB,EACvB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { spawn } from 'child_process';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import { readFile } from "fs/promises";
|
|
4
|
+
import tmp from 'tmp';
|
|
5
|
+
tmp.setGracefulCleanup();
|
|
6
|
+
export function pdfFileToText(input, output) {
|
|
7
|
+
return new Promise((resolve, reject) => {
|
|
8
|
+
const command = spawn("mutool", ["convert", "-o", output, input]);
|
|
9
|
+
command.on('exit', function (code) {
|
|
10
|
+
if (code) {
|
|
11
|
+
reject(new Error(`mutool exited with code ${code}`));
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
command.on('close', function (code) {
|
|
15
|
+
if (code) {
|
|
16
|
+
reject(new Error(`mutool exited with code ${code}`));
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
return resolve(output);
|
|
20
|
+
}
|
|
21
|
+
;
|
|
22
|
+
});
|
|
23
|
+
command.on('error', (err) => {
|
|
24
|
+
reject(err);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
export function pdfToText(buffer) {
|
|
29
|
+
return pdfToTextBuffer(buffer).then((buffer) => buffer.toString('utf-8'));
|
|
30
|
+
}
|
|
31
|
+
export function pdfToTextBuffer(buffer) {
|
|
32
|
+
const inputFile = tmp.fileSync({ postfix: '.pdf' });
|
|
33
|
+
const targetFileName = tmp.tmpNameSync({ postfix: '.txt' });
|
|
34
|
+
fs.writeSync(inputFile.fd, buffer);
|
|
35
|
+
return pdfFileToText(inputFile.name, targetFileName).then(() => {
|
|
36
|
+
return readFile(targetFileName);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=mutool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutool.js","sourceRoot":"","sources":["../../src/mutool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,GAAG,CAAC,kBAAkB,EAAE,CAAC;AAEzB,MAAM,UAAU,aAAa,CAAC,KAAa,EAAE,MAAc;IACvD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAEnC,MAAM,OAAO,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;QAElE,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,IAAI;YAC7B,IAAI,IAAI,EAAE,CAAC;gBACP,MAAM,CAAC,IAAI,KAAK,CAAC,2BAA2B,IAAI,EAAE,CAAC,CAAC,CAAC;YACzD,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,IAAI;YAC9B,IAAI,IAAI,EAAE,CAAC;gBACP,MAAM,CAAC,IAAI,KAAK,CAAC,2BAA2B,IAAI,EAAE,CAAC,CAAC,CAAC;YACzD,CAAC;iBAAM,CAAC;gBACJ,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC;YAC3B,CAAC;YAAA,CAAC;QACN,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YACxB,MAAM,CAAC,GAAG,CAAC,CAAC;QAChB,CAAC,CAAC,CAAC;IAEP,CAAC,CAAC,CAAC;AAEP,CAAC;AACD,MAAM,UAAU,SAAS,CAAC,MAAc;IACpC,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;AAC9E,CAAC;AACD,MAAM,UAAU,eAAe,CAAC,MAAc;IAC1C,MAAM,SAAS,GAAG,GAAG,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;IACpD,MAAM,cAAc,GAAG,GAAG,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;IAE5D,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IAEnC,OAAO,aAAa,CAAC,SAAS,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;QAC3D,OAAO,QAAQ,CAAC,cAAc,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { spawn } from 'child_process';
|
|
2
|
+
import { PassThrough } from 'stream';
|
|
3
|
+
export function manyToMarkdownFromBuffer(buffer, fromFormat) {
|
|
4
|
+
const input = new PassThrough();
|
|
5
|
+
input.end(buffer);
|
|
6
|
+
return manyToMarkdown(input, fromFormat);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Requires pandoc to be installed on the system.
|
|
10
|
+
* @param fromFormat is the format of the input buffer.
|
|
11
|
+
*/
|
|
12
|
+
export function manyToMarkdown(input, fromFormat) {
|
|
13
|
+
return new Promise((resolve, reject) => {
|
|
14
|
+
let result = [];
|
|
15
|
+
const command = spawn("pandoc", ["-t", "markdown", '-f', fromFormat], {
|
|
16
|
+
stdio: 'pipe',
|
|
17
|
+
});
|
|
18
|
+
input.pipe(command.stdin);
|
|
19
|
+
command.stdout.on('data', function (data) {
|
|
20
|
+
result.push(data.toString());
|
|
21
|
+
});
|
|
22
|
+
command.on('exit', function (code) {
|
|
23
|
+
if (code) {
|
|
24
|
+
reject(new Error(`pandoc exited with code ${code}`));
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
command.on('close', function (code) {
|
|
28
|
+
if (code) {
|
|
29
|
+
reject(new Error(`pandoc exited with code ${code}`));
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
resolve(result.join(''));
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
command.on('error', (err) => {
|
|
36
|
+
reject(err);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=pandoc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pandoc.js","sourceRoot":"","sources":["../../src/pandoc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,MAAM,UAAU,wBAAwB,CAAC,MAAc,EAAE,UAAkB;IACzE,MAAM,KAAK,GAAG,IAAI,WAAW,EAAE,CAAC;IAChC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAClB,OAAO,cAAc,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;AAE3C,CAAC;AACD;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,KAA4B,EAAE,UAAkB;IAE7E,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,IAAI,MAAM,GAAa,EAAE,CAAC;QAE1B,MAAM,OAAO,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,CAAC,EAAE;YACpE,KAAK,EAAE,MAAM;SACd,CAAC,CAAC;QACH,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAE1B,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,IAAY;YAC9C,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;QACH,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,IAAI;YAC/B,IAAI,IAAI,EAAE,CAAC;gBACT,MAAM,CAAC,IAAI,KAAK,CAAC,2BAA2B,IAAI,EAAE,CAAC,CAAC,CAAC;YACvD,CAAC;QACH,CAAC,CAAC,CAAC;QACH,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,IAAI;YAChC,IAAI,IAAI,EAAE,CAAC;gBACT,MAAM,CAAC,IAAI,KAAK,CAAC,2BAA2B,IAAI,EAAE,CAAC,CAAC,CAAC;YACvD,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAA;YAC1B,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YAC1B,MAAM,CAAC,GAAG,CAAC,CAAC;QACd,CAAC,CAAC,CAAC;IAEL,CAAC,CAAC,CAAC;AAEL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"fileNames":["../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2016.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2021.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.dom.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.core.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2016.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.date.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.object.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.string.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.array.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.object.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.string.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2019.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.date.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.string.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2020.number.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2021.promise.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2021.string.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2021.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.array.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.error.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.intl.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.object.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.string.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.regexp.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.decorators.d.ts","../../../node_modules/.pnpm/typescript@5.9.3/node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/compatibility/disposable.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/compatibility/indexable.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/compatibility/iterators.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/compatibility/index.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/globals.typedarray.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/buffer.buffer.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/globals.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/web-globals/abortcontroller.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/web-globals/domexception.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/web-globals/events.d.ts","../../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/header.d.ts","../../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/readable.d.ts","../../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/file.d.ts","../../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/fetch.d.ts","../../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/formdata.d.ts","../../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/connector.d.ts","../../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/client.d.ts","../../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/errors.d.ts","../../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/dispatcher.d.ts","../../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/global-dispatcher.d.ts","../../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/global-origin.d.ts","../../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/pool-stats.d.ts","../../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/pool.d.ts","../../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/handlers.d.ts","../../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/balanced-pool.d.ts","../../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/agent.d.ts","../../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/mock-interceptor.d.ts","../../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/mock-agent.d.ts","../../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/mock-client.d.ts","../../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/mock-pool.d.ts","../../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/mock-errors.d.ts","../../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/proxy-agent.d.ts","../../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/env-http-proxy-agent.d.ts","../../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/retry-handler.d.ts","../../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/retry-agent.d.ts","../../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/api.d.ts","../../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/interceptors.d.ts","../../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/util.d.ts","../../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/cookies.d.ts","../../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/patch.d.ts","../../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/websocket.d.ts","../../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/eventsource.d.ts","../../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/filereader.d.ts","../../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/diagnostics-channel.d.ts","../../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/content-type.d.ts","../../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/cache.d.ts","../../../node_modules/.pnpm/undici-types@6.21.0/node_modules/undici-types/index.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/web-globals/fetch.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/web-globals/navigator.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/web-globals/storage.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/assert.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/assert/strict.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/async_hooks.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/buffer.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/child_process.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/cluster.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/console.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/constants.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/crypto.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/dgram.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/diagnostics_channel.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/dns.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/dns/promises.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/domain.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/events.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/fs.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/fs/promises.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/http.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/http2.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/https.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/inspector.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/inspector.generated.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/module.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/net.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/os.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/path.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/perf_hooks.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/process.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/punycode.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/querystring.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/readline.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/readline/promises.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/repl.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/sea.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/sqlite.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/stream.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/stream/promises.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/stream/consumers.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/stream/web.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/string_decoder.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/test.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/timers.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/timers/promises.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/tls.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/trace_events.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/tty.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/url.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/util.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/v8.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/vm.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/wasi.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/worker_threads.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/zlib.d.ts","../../../node_modules/.pnpm/@types+node@22.19.3/node_modules/@types/node/index.d.ts","../../../node_modules/.pnpm/sharp@0.33.5/node_modules/sharp/lib/index.d.ts","../src/image.ts","../../../node_modules/.pnpm/@types+tmp@0.2.6/node_modules/@types/tmp/index.d.ts","../src/mutool.ts","../src/pandoc.ts","../src/index.ts"],"fileIdsList":[[64,109,110,112,129,130],[64,111,112,129,130],[112,129,130],[64,112,117,129,130,147],[64,112,113,118,123,129,130,132,144,155],[64,112,113,114,123,129,130,132],[64,112,129,130],[59,60,61,64,112,129,130],[64,112,115,129,130,156],[64,112,116,117,124,129,130,133],[64,112,117,129,130,144,152],[64,112,118,120,123,129,130,132],[64,111,112,119,129,130],[64,112,120,121,129,130],[64,112,122,123,129,130],[64,111,112,123,129,130],[64,112,123,124,125,129,130,144,155],[64,112,123,124,125,129,130,139,144,147],[64,105,112,120,123,126,129,130,132,144,155],[64,112,123,124,126,127,129,130,132,144,152,155],[64,112,126,128,129,130,144,152,155],[62,63,64,65,66,67,68,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161],[64,112,123,129,130],[64,112,129,130,131,155],[64,112,120,123,129,130,132,144],[64,112,129,130,133],[64,112,129,130,134],[64,111,112,129,130,135],[64,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161],[64,112,129,130,137],[64,112,129,130,138],[64,112,123,129,130,139,140],[64,112,129,130,139,141,156,158],[64,112,124,129,130],[64,112,123,129,130,144,145,147],[64,112,129,130,146,147],[64,112,129,130,144,145],[64,112,129,130,147],[64,112,129,130,148],[64,109,112,129,130,144,149],[64,112,123,129,130,150,151],[64,112,129,130,150,151],[64,112,117,129,130,132,144,152],[64,112,129,130,153],[64,112,129,130,132,154],[64,112,126,129,130,138,155],[64,112,117,129,130,156],[64,112,129,130,144,157],[64,112,129,130,131,158],[64,112,129,130,159],[64,105,112,129,130],[64,105,112,123,125,129,130,135,144,147,155,157,158,160],[64,112,129,130,144,161],[64,112,129,130,144,162],[64,77,81,112,129,130,155],[64,77,112,129,130,144,155],[64,72,112,129,130],[64,74,77,112,129,130,152,155],[64,112,129,130,132,152],[64,112,129,130,162],[64,72,112,129,130,162],[64,74,77,112,129,130,132,155],[64,69,70,73,76,112,123,129,130,144,155],[64,77,84,112,129,130],[64,69,75,112,129,130],[64,77,98,99,112,129,130],[64,73,77,112,129,130,147,155,162],[64,98,112,129,130,162],[64,71,72,112,129,130,162],[64,77,112,129,130],[64,71,72,73,74,75,76,77,78,79,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,99,100,101,102,103,104,112,129,130],[64,77,92,112,129,130],[64,77,84,85,112,129,130],[64,75,77,85,86,112,129,130],[64,76,112,129,130],[64,69,72,77,112,129,130],[64,77,81,85,86,112,129,130],[64,81,112,129,130],[64,75,77,80,112,129,130,155],[64,69,74,77,84,112,129,130],[64,112,129,130,144],[64,72,77,98,112,129,130,160,162],[64,112,129,130,163],[64,112,129,130,164,166,167],[64,112,113,124,125,129,130,165],[64,112,113,129,130,144]],"fileInfos":[{"version":"c430d44666289dae81f30fa7b2edebf186ecc91a2d4c71266ea6ae76388792e1","affectsGlobalScope":true,"impliedFormat":1},{"version":"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","impliedFormat":1},{"version":"3facaf05f0c5fc569c5649dd359892c98a85557e3e0c847964caeb67076f4d75","impliedFormat":1},{"version":"e44bb8bbac7f10ecc786703fe0a6a4b952189f908707980ba8f3c8975a760962","impliedFormat":1},{"version":"5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","impliedFormat":1},{"version":"68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","impliedFormat":1},{"version":"5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","impliedFormat":1},{"version":"feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","impliedFormat":1},{"version":"ee7bad0c15b58988daa84371e0b89d313b762ab83cb5b31b8a2d1162e8eb41c2","impliedFormat":1},{"version":"080941d9f9ff9307f7e27a83bcd888b7c8270716c39af943532438932ec1d0b9","affectsGlobalScope":true,"impliedFormat":1},{"version":"c57796738e7f83dbc4b8e65132f11a377649c00dd3eee333f672b8f0a6bea671","affectsGlobalScope":true,"impliedFormat":1},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true,"impliedFormat":1},{"version":"515d0b7b9bea2e31ea4ec968e9edd2c39d3eebf4a2d5cbd04e88639819ae3b71","affectsGlobalScope":true,"impliedFormat":1},{"version":"0559b1f683ac7505ae451f9a96ce4c3c92bdc71411651ca6ddb0e88baaaad6a3","affectsGlobalScope":true,"impliedFormat":1},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true,"impliedFormat":1},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true,"impliedFormat":1},{"version":"fb0f136d372979348d59b3f5020b4cdb81b5504192b1cacff5d1fbba29378aa1","affectsGlobalScope":true,"impliedFormat":1},{"version":"d15bea3d62cbbdb9797079416b8ac375ae99162a7fba5de2c6c505446486ac0a","affectsGlobalScope":true,"impliedFormat":1},{"version":"68d18b664c9d32a7336a70235958b8997ebc1c3b8505f4f1ae2b7e7753b87618","affectsGlobalScope":true,"impliedFormat":1},{"version":"eb3d66c8327153d8fa7dd03f9c58d351107fe824c79e9b56b462935176cdf12a","affectsGlobalScope":true,"impliedFormat":1},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true,"impliedFormat":1},{"version":"69ab18c3b76cd9b1be3d188eaf8bba06112ebbe2f47f6c322b5105a6fbc45a2e","affectsGlobalScope":true,"impliedFormat":1},{"version":"a680117f487a4d2f30ea46f1b4b7f58bef1480456e18ba53ee85c2746eeca012","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true,"impliedFormat":1},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true,"impliedFormat":1},{"version":"954296b30da6d508a104a3a0b5d96b76495c709785c1d11610908e63481ee667","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac9538681b19688c8eae65811b329d3744af679e0bdfa5d842d0e32524c73e1c","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a969edff4bd52585473d24995c5ef223f6652d6ef46193309b3921d65dd4376","affectsGlobalScope":true,"impliedFormat":1},{"version":"9e9fbd7030c440b33d021da145d3232984c8bb7916f277e8ffd3dc2e3eae2bdb","affectsGlobalScope":true,"impliedFormat":1},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true,"impliedFormat":1},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true,"impliedFormat":1},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true,"impliedFormat":1},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true,"impliedFormat":1},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true,"impliedFormat":1},{"version":"74f7fa2d027d5b33eb0471c8e82a6c87216223181ec31247c357a3e8e2fddc5b","affectsGlobalScope":true,"impliedFormat":1},{"version":"d6d7ae4d1f1f3772e2a3cde568ed08991a8ae34a080ff1151af28b7f798e22ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true,"impliedFormat":1},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true,"impliedFormat":1},{"version":"52ada8e0b6e0482b728070b7639ee42e83a9b1c22d205992756fe020fd9f4a47","affectsGlobalScope":true,"impliedFormat":1},{"version":"3bdefe1bfd4d6dee0e26f928f93ccc128f1b64d5d501ff4a8cf3c6371200e5e6","affectsGlobalScope":true,"impliedFormat":1},{"version":"59fb2c069260b4ba00b5643b907ef5d5341b167e7d1dbf58dfd895658bda2867","affectsGlobalScope":true,"impliedFormat":1},{"version":"639e512c0dfc3fad96a84caad71b8834d66329a1f28dc95e3946c9b58176c73a","affectsGlobalScope":true,"impliedFormat":1},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true,"impliedFormat":1},{"version":"af3dd424cf267428f30ccfc376f47a2c0114546b55c44d8c0f1d57d841e28d74","affectsGlobalScope":true,"impliedFormat":1},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true,"impliedFormat":1},{"version":"959d36cddf5e7d572a65045b876f2956c973a586da58e5d26cde519184fd9b8a","affectsGlobalScope":true,"impliedFormat":1},{"version":"965f36eae237dd74e6cca203a43e9ca801ce38824ead814728a2807b1910117d","affectsGlobalScope":true,"impliedFormat":1},{"version":"3925a6c820dcb1a06506c90b1577db1fdbf7705d65b62b99dce4be75c637e26b","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a3d63ef2b853447ec4f749d3f368ce642264246e02911fcb1590d8c161b8005","affectsGlobalScope":true,"impliedFormat":1},{"version":"8cdf8847677ac7d20486e54dd3fcf09eda95812ac8ace44b4418da1bbbab6eb8","affectsGlobalScope":true,"impliedFormat":1},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true,"impliedFormat":1},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true,"impliedFormat":1},{"version":"b4b67b1a91182421f5df999988c690f14d813b9850b40acd06ed44691f6727ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"8e7f8264d0fb4c5339605a15daadb037bf238c10b654bb3eee14208f860a32ea","affectsGlobalScope":true,"impliedFormat":1},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true,"impliedFormat":1},{"version":"6c7176368037af28cb72f2392010fa1cef295d6d6744bca8cfb54985f3a18c3e","affectsGlobalScope":true,"impliedFormat":1},{"version":"ab41ef1f2cdafb8df48be20cd969d875602483859dc194e9c97c8a576892c052","affectsGlobalScope":true,"impliedFormat":1},{"version":"437e20f2ba32abaeb7985e0afe0002de1917bc74e949ba585e49feba65da6ca1","affectsGlobalScope":true,"impliedFormat":1},{"version":"21d819c173c0cf7cc3ce57c3276e77fd9a8a01d35a06ad87158781515c9a438a","impliedFormat":1},{"version":"98cffbf06d6bab333473c70a893770dbe990783904002c4f1a960447b4b53dca","affectsGlobalScope":true,"impliedFormat":1},{"version":"3af97acf03cc97de58a3a4bc91f8f616408099bc4233f6d0852e72a8ffb91ac9","affectsGlobalScope":true,"impliedFormat":1},{"version":"808069bba06b6768b62fd22429b53362e7af342da4a236ed2d2e1c89fcca3b4a","affectsGlobalScope":true,"impliedFormat":1},{"version":"1db0b7dca579049ca4193d034d835f6bfe73096c73663e5ef9a0b5779939f3d0","affectsGlobalScope":true,"impliedFormat":1},{"version":"9798340ffb0d067d69b1ae5b32faa17ab31b82466a3fc00d8f2f2df0c8554aaa","affectsGlobalScope":true,"impliedFormat":1},{"version":"f26b11d8d8e4b8028f1c7d618b22274c892e4b0ef5b3678a8ccbad85419aef43","affectsGlobalScope":true,"impliedFormat":1},{"version":"5929864ce17fba74232584d90cb721a89b7ad277220627cc97054ba15a98ea8f","impliedFormat":1},{"version":"763fe0f42b3d79b440a9b6e51e9ba3f3f91352469c1e4b3b67bfa4ff6352f3f4","impliedFormat":1},{"version":"25c8056edf4314820382a5fdb4bb7816999acdcb929c8f75e3f39473b87e85bc","impliedFormat":1},{"version":"c464d66b20788266e5353b48dc4aa6bc0dc4a707276df1e7152ab0c9ae21fad8","impliedFormat":1},{"version":"78d0d27c130d35c60b5e5566c9f1e5be77caf39804636bc1a40133919a949f21","impliedFormat":1},{"version":"c6fd2c5a395f2432786c9cb8deb870b9b0e8ff7e22c029954fabdd692bff6195","impliedFormat":1},{"version":"1d6e127068ea8e104a912e42fc0a110e2aa5a66a356a917a163e8cf9a65e4a75","impliedFormat":1},{"version":"5ded6427296cdf3b9542de4471d2aa8d3983671d4cac0f4bf9c637208d1ced43","impliedFormat":1},{"version":"7f182617db458e98fc18dfb272d40aa2fff3a353c44a89b2c0ccb3937709bfb5","impliedFormat":1},{"version":"cadc8aced301244057c4e7e73fbcae534b0f5b12a37b150d80e5a45aa4bebcbd","impliedFormat":1},{"version":"385aab901643aa54e1c36f5ef3107913b10d1b5bb8cbcd933d4263b80a0d7f20","impliedFormat":1},{"version":"9670d44354bab9d9982eca21945686b5c24a3f893db73c0dae0fd74217a4c219","impliedFormat":1},{"version":"0b8a9268adaf4da35e7fa830c8981cfa22adbbe5b3f6f5ab91f6658899e657a7","impliedFormat":1},{"version":"11396ed8a44c02ab9798b7dca436009f866e8dae3c9c25e8c1fbc396880bf1bb","impliedFormat":1},{"version":"ba7bc87d01492633cb5a0e5da8a4a42a1c86270e7b3d2dea5d156828a84e4882","impliedFormat":1},{"version":"4893a895ea92c85345017a04ed427cbd6a1710453338df26881a6019432febdd","impliedFormat":1},{"version":"c21dc52e277bcfc75fac0436ccb75c204f9e1b3fa5e12729670910639f27343e","impliedFormat":1},{"version":"13f6f39e12b1518c6650bbb220c8985999020fe0f21d818e28f512b7771d00f9","impliedFormat":1},{"version":"9b5369969f6e7175740bf51223112ff209f94ba43ecd3bb09eefff9fd675624a","impliedFormat":1},{"version":"4fe9e626e7164748e8769bbf74b538e09607f07ed17c2f20af8d680ee49fc1da","impliedFormat":1},{"version":"24515859bc0b836719105bb6cc3d68255042a9f02a6022b3187948b204946bd2","impliedFormat":1},{"version":"ea0148f897b45a76544ae179784c95af1bd6721b8610af9ffa467a518a086a43","impliedFormat":1},{"version":"24c6a117721e606c9984335f71711877293a9651e44f59f3d21c1ea0856f9cc9","impliedFormat":1},{"version":"dd3273ead9fbde62a72949c97dbec2247ea08e0c6952e701a483d74ef92d6a17","impliedFormat":1},{"version":"405822be75ad3e4d162e07439bac80c6bcc6dbae1929e179cf467ec0b9ee4e2e","impliedFormat":1},{"version":"0db18c6e78ea846316c012478888f33c11ffadab9efd1cc8bcc12daded7a60b6","impliedFormat":1},{"version":"e61be3f894b41b7baa1fbd6a66893f2579bfad01d208b4ff61daef21493ef0a8","impliedFormat":1},{"version":"bd0532fd6556073727d28da0edfd1736417a3f9f394877b6d5ef6ad88fba1d1a","impliedFormat":1},{"version":"89167d696a849fce5ca508032aabfe901c0868f833a8625d5a9c6e861ef935d2","impliedFormat":1},{"version":"615ba88d0128ed16bf83ef8ccbb6aff05c3ee2db1cc0f89ab50a4939bfc1943f","impliedFormat":1},{"version":"a4d551dbf8746780194d550c88f26cf937caf8d56f102969a110cfaed4b06656","impliedFormat":1},{"version":"8bd86b8e8f6a6aa6c49b71e14c4ffe1211a0e97c80f08d2c8cc98838006e4b88","impliedFormat":1},{"version":"317e63deeb21ac07f3992f5b50cdca8338f10acd4fbb7257ebf56735bf52ab00","impliedFormat":1},{"version":"4732aec92b20fb28c5fe9ad99521fb59974289ed1e45aecb282616202184064f","impliedFormat":1},{"version":"2e85db9e6fd73cfa3d7f28e0ab6b55417ea18931423bd47b409a96e4a169e8e6","impliedFormat":1},{"version":"c46e079fe54c76f95c67fb89081b3e399da2c7d109e7dca8e4b58d83e332e605","impliedFormat":1},{"version":"bf67d53d168abc1298888693338cb82854bdb2e69ef83f8a0092093c2d562107","impliedFormat":1},{"version":"2cbe0621042e2a68c7cbce5dfed3906a1862a16a7d496010636cdbdb91341c0f","affectsGlobalScope":true,"impliedFormat":1},{"version":"f9501cc13ce624c72b61f12b3963e84fad210fbdf0ffbc4590e08460a3f04eba","affectsGlobalScope":true,"impliedFormat":1},{"version":"e7721c4f69f93c91360c26a0a84ee885997d748237ef78ef665b153e622b36c1","affectsGlobalScope":true,"impliedFormat":1},{"version":"0fa06ada475b910e2106c98c68b10483dc8811d0c14a8a8dd36efb2672485b29","impliedFormat":1},{"version":"33e5e9aba62c3193d10d1d33ae1fa75c46a1171cf76fef750777377d53b0303f","impliedFormat":1},{"version":"2b06b93fd01bcd49d1a6bd1f9b65ddcae6480b9a86e9061634d6f8e354c1468f","impliedFormat":1},{"version":"6a0cd27e5dc2cfbe039e731cf879d12b0e2dded06d1b1dedad07f7712de0d7f4","affectsGlobalScope":true,"impliedFormat":1},{"version":"13f5c844119c43e51ce777c509267f14d6aaf31eafb2c2b002ca35584cd13b29","impliedFormat":1},{"version":"e60477649d6ad21542bd2dc7e3d9ff6853d0797ba9f689ba2f6653818999c264","impliedFormat":1},{"version":"c2510f124c0293ab80b1777c44d80f812b75612f297b9857406468c0f4dafe29","affectsGlobalScope":true,"impliedFormat":1},{"version":"5524481e56c48ff486f42926778c0a3cce1cc85dc46683b92b1271865bcf015a","impliedFormat":1},{"version":"4c829ab315f57c5442c6667b53769975acbf92003a66aef19bce151987675bd1","affectsGlobalScope":true,"impliedFormat":1},{"version":"b2ade7657e2db96d18315694789eff2ddd3d8aea7215b181f8a0b303277cc579","impliedFormat":1},{"version":"9855e02d837744303391e5623a531734443a5f8e6e8755e018c41d63ad797db2","impliedFormat":1},{"version":"4d631b81fa2f07a0e63a9a143d6a82c25c5f051298651a9b69176ba28930756d","impliedFormat":1},{"version":"836a356aae992ff3c28a0212e3eabcb76dd4b0cc06bcb9607aeef560661b860d","impliedFormat":1},{"version":"1e0d1f8b0adfa0b0330e028c7941b5a98c08b600efe7f14d2d2a00854fb2f393","impliedFormat":1},{"version":"41670ee38943d9cbb4924e436f56fc19ee94232bc96108562de1a734af20dc2c","affectsGlobalScope":true,"impliedFormat":1},{"version":"c906fb15bd2aabc9ed1e3f44eb6a8661199d6c320b3aa196b826121552cb3695","impliedFormat":1},{"version":"22295e8103f1d6d8ea4b5d6211e43421fe4564e34d0dd8e09e520e452d89e659","impliedFormat":1},{"version":"bb45cd435da536500f1d9692a9b49d0c570b763ccbf00473248b777f5c1f353b","impliedFormat":1},{"version":"6b4e081d55ac24fc8a4631d5dd77fe249fa25900abd7d046abb87d90e3b45645","impliedFormat":1},{"version":"a10f0e1854f3316d7ee437b79649e5a6ae3ae14ffe6322b02d4987071a95362e","impliedFormat":1},{"version":"e208f73ef6a980104304b0d2ca5f6bf1b85de6009d2c7e404028b875020fa8f2","impliedFormat":1},{"version":"d163b6bc2372b4f07260747cbc6c0a6405ab3fbcea3852305e98ac43ca59f5bc","impliedFormat":1},{"version":"e6fa9ad47c5f71ff733744a029d1dc472c618de53804eae08ffc243b936f87ff","affectsGlobalScope":true,"impliedFormat":1},{"version":"83e63d6ccf8ec004a3bb6d58b9bb0104f60e002754b1e968024b320730cc5311","impliedFormat":1},{"version":"24826ed94a78d5c64bd857570fdbd96229ad41b5cb654c08d75a9845e3ab7dde","impliedFormat":1},{"version":"8b479a130ccb62e98f11f136d3ac80f2984fdc07616516d29881f3061f2dd472","impliedFormat":1},{"version":"928af3d90454bf656a52a48679f199f64c1435247d6189d1caf4c68f2eaf921f","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac39df6dfb9e284bb0c205b15f4d9a2b260f5bab5c85bf2fb97d0cdd509c06ea","affectsGlobalScope":true,"impliedFormat":1},{"version":"3f16a7e4deafa527ed9995a772bb380eb7d3c2c0fd4ae178c5263ed18394db2c","impliedFormat":1},{"version":"933921f0bb0ec12ef45d1062a1fc0f27635318f4d294e4d99de9a5493e618ca2","impliedFormat":1},{"version":"71a0f3ad612c123b57239a7749770017ecfe6b66411488000aba83e4546fde25","impliedFormat":1},{"version":"77fbe5eecb6fac4b6242bbf6eebfc43e98ce5ccba8fa44e0ef6a95c945ff4d98","impliedFormat":1},{"version":"4f9d8ca0c417b67b69eeb54c7ca1bedd7b56034bb9bfd27c5d4f3bc4692daca7","impliedFormat":1},{"version":"814118df420c4e38fe5ae1b9a3bafb6e9c2aa40838e528cde908381867be6466","impliedFormat":1},{"version":"a3fc63c0d7b031693f665f5494412ba4b551fe644ededccc0ab5922401079c95","impliedFormat":1},{"version":"f27524f4bef4b6519c604bdb23bf4465bddcccbf3f003abb901acbd0d7404d99","impliedFormat":1},{"version":"37ba7b45141a45ce6e80e66f2a96c8a5ab1bcef0fc2d0f56bb58df96ec67e972","impliedFormat":1},{"version":"45650f47bfb376c8a8ed39d4bcda5902ab899a3150029684ee4c10676d9fbaee","impliedFormat":1},{"version":"dba28a419aec76ed864ef43e5f577a5c99a010c32e5949fe4e17a4d57c58dd11","affectsGlobalScope":true,"impliedFormat":1},{"version":"18fd40412d102c5564136f29735e5d1c3b455b8a37f920da79561f1fde068208","impliedFormat":1},{"version":"c959a391a75be9789b43c8468f71e3fa06488b4d691d5729dde1416dcd38225b","impliedFormat":1},{"version":"f0be1b8078cd549d91f37c30c222c2a187ac1cf981d994fb476a1adc61387b14","affectsGlobalScope":true,"impliedFormat":1},{"version":"0aaed1d72199b01234152f7a60046bc947f1f37d78d182e9ae09c4289e06a592","impliedFormat":1},{"version":"5ebe6f4cc3b803cbfc962bae0d954f9c80e5078ca41eb3f1de41d92e7193ef37","impliedFormat":1},{"version":"66ba1b2c3e3a3644a1011cd530fb444a96b1b2dfe2f5e837a002d41a1a799e60","impliedFormat":1},{"version":"7e514f5b852fdbc166b539fdd1f4e9114f29911592a5eb10a94bb3a13ccac3c4","impliedFormat":1},{"version":"5b7aa3c4c1a5d81b411e8cb302b45507fea9358d3569196b27eb1a27ae3a90ef","affectsGlobalScope":true,"impliedFormat":1},{"version":"5987a903da92c7462e0b35704ce7da94d7fdc4b89a984871c0e2b87a8aae9e69","affectsGlobalScope":true,"impliedFormat":1},{"version":"ea08a0345023ade2b47fbff5a76d0d0ed8bff10bc9d22b83f40858a8e941501c","impliedFormat":1},{"version":"47613031a5a31510831304405af561b0ffaedb734437c595256bb61a90f9311b","impliedFormat":1},{"version":"ae062ce7d9510060c5d7e7952ae379224fb3f8f2dd74e88959878af2057c143b","impliedFormat":1},{"version":"8a1a0d0a4a06a8d278947fcb66bf684f117bf147f89b06e50662d79a53be3e9f","affectsGlobalScope":true,"impliedFormat":1},{"version":"9f663c2f91127ef7024e8ca4b3b4383ff2770e5f826696005de382282794b127","impliedFormat":1},{"version":"9f55299850d4f0921e79b6bf344b47c420ce0f507b9dcf593e532b09ea7eeea1","impliedFormat":1},{"version":"e749bbd37dadf82c9833278780527c717226e1e2c9bc7b2576c8ec1c40ec5647","impliedFormat":1},{"version":"2da3f3b797fac7937f6ce7b538470ed7b57ee5ea661dc1b4e251c50af14b3095","signature":"90b68fc4af20144deca7fe3b375151ef95567d9b7ea97ccd974ef557c91e4324"},{"version":"4eb2548d412c794edbe7213ecf9c370cabc154e4086f6d65693be9ad23510902","impliedFormat":1},{"version":"6a1a036c5eb712b18238de9f993a0ca85f69fecc29dd77618e507721a1fa2d1b","signature":"7629cf8961345004859b6acef2cb31d2e807c340d1539d1bc60e211fdc8486ae"},{"version":"64e0ecf07fac36829b166df8cd558676a44c0856ab052c00882c4be78f629b40","signature":"ec471abce8afd7e3ced5bdd4a6049efac7bf3826bcefe028470f1348b0f35bf4"},{"version":"1adfe2957629a55f96fbe6c512a3397db7faf6dd1b04d360e1412a28b2a2b8ef","signature":"bc5a96acbc6b66acd709597f7aaeb42484ae5e9da1b8067c424d8d885c0eacd5"}],"root":[164,[166,168]],"options":{"allowSyntheticDefaultImports":true,"composite":true,"declarationDir":"./types","esModuleInterop":true,"experimentalDecorators":true,"module":99,"noFallthroughCasesInSwitch":true,"noPropertyAccessFromIndexSignature":false,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./esm","rootDir":"../src","skipLibCheck":true,"sourceMap":true,"strict":true,"target":9,"useDefineForClassFields":true,"useUnknownInCatchVariables":true},"referencedMap":[[109,1],[110,1],[111,2],[64,3],[112,4],[113,5],[114,6],[59,7],[62,8],[60,7],[61,7],[115,9],[116,10],[117,11],[118,12],[119,13],[120,14],[121,14],[122,15],[123,16],[124,17],[125,18],[65,7],[63,7],[126,19],[127,20],[128,21],[162,22],[129,23],[130,7],[131,24],[132,25],[133,26],[134,27],[135,28],[136,29],[137,30],[138,31],[139,32],[140,32],[141,33],[142,7],[143,34],[144,35],[146,36],[145,37],[147,38],[148,39],[149,40],[150,41],[151,42],[152,43],[153,44],[154,45],[155,46],[156,47],[157,48],[158,49],[159,50],[66,7],[67,7],[68,7],[106,51],[107,7],[108,7],[160,52],[161,53],[165,7],[163,54],[57,7],[58,7],[10,7],[12,7],[11,7],[2,7],[13,7],[14,7],[15,7],[16,7],[17,7],[18,7],[19,7],[20,7],[3,7],[21,7],[22,7],[4,7],[23,7],[27,7],[24,7],[25,7],[26,7],[28,7],[29,7],[30,7],[5,7],[31,7],[32,7],[33,7],[34,7],[6,7],[38,7],[35,7],[36,7],[37,7],[39,7],[7,7],[40,7],[45,7],[46,7],[41,7],[42,7],[43,7],[44,7],[8,7],[50,7],[47,7],[48,7],[49,7],[51,7],[9,7],[52,7],[53,7],[54,7],[56,7],[55,7],[1,7],[84,55],[94,56],[83,55],[104,57],[75,58],[74,59],[103,60],[97,61],[102,62],[77,63],[91,64],[76,65],[100,66],[72,67],[71,60],[101,68],[73,69],[78,70],[79,7],[82,70],[69,7],[105,71],[95,72],[86,73],[87,74],[89,75],[85,76],[88,77],[98,60],[80,78],[81,79],[90,80],[70,81],[93,72],[92,70],[96,7],[99,82],[164,83],[168,84],[166,85],[167,86]],"latestChangedDtsFile":"./types/index.d.ts","version":"5.9.3"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import sharp from "sharp";
|
|
2
|
+
export interface TransformOptions {
|
|
3
|
+
max_hw?: number;
|
|
4
|
+
format?: keyof sharp.FormatEnum;
|
|
5
|
+
}
|
|
6
|
+
type SharpInputType = Buffer | ArrayBuffer | Uint8Array | Uint8ClampedArray | Int8Array | Uint16Array | Int16Array | Uint32Array | Int32Array | Float32Array | Float64Array | string | NodeJS.ReadableStream;
|
|
7
|
+
export declare function createImageTransformer(input: SharpInputType, opts: TransformOptions): sharp.Sharp;
|
|
8
|
+
/**
|
|
9
|
+
* @param max_hw
|
|
10
|
+
* @param format
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
export declare function transformImage(input: SharpInputType, output: NodeJS.WritableStream, opts: TransformOptions): Promise<sharp.Sharp>;
|
|
14
|
+
export declare function transformImageToBuffer(input: SharpInputType, opts: TransformOptions): Promise<Buffer>;
|
|
15
|
+
export declare function transformImageToFile(input: SharpInputType, output: string, opts: TransformOptions): Promise<void>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/image.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,WAAW,gBAAgB;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,KAAK,CAAC,UAAU,CAAA;CAClC;AAED,KAAK,cAAc,GAAG,MAAM,GACtB,WAAW,GACX,UAAU,GACV,iBAAiB,GACjB,SAAS,GACT,WAAW,GACX,UAAU,GACV,WAAW,GACX,UAAU,GACV,YAAY,GACZ,YAAY,GACZ,MAAM,GACN,MAAM,CAAC,cAAc,CAAA;AAC3B,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,gBAAgB,eAenF;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,CAAC,cAAc,EAAE,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAyBvI;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CAGrG;AAED,wBAAsB,oBAAoB,CAAC,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAGvH"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { transformImage, transformImageToBuffer, transformImageToFile } from './image.js';
|
|
2
|
+
import { pdfFileToText, pdfToText, pdfToTextBuffer } from './mutool.js';
|
|
3
|
+
import { manyToMarkdown } from './pandoc.js';
|
|
4
|
+
export { manyToMarkdown, pdfFileToText, pdfToText, pdfToTextBuffer, transformImage, transformImageToBuffer, transformImageToFile };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAC1F,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,EACH,cAAc,EACd,aAAa,EAAE,SAAS,EACxB,eAAe,EACf,cAAc,EACd,sBAAsB,EACtB,oBAAoB,EACvB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutool.d.ts","sourceRoot":"","sources":["../../src/mutool.ts"],"names":[],"mappings":"AAMA,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,oBAyB1D;AACD,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAEzD;AACD,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAS/D"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function manyToMarkdownFromBuffer(buffer: Buffer, fromFormat: string): Promise<string>;
|
|
2
|
+
/**
|
|
3
|
+
* Requires pandoc to be installed on the system.
|
|
4
|
+
* @param fromFormat is the format of the input buffer.
|
|
5
|
+
*/
|
|
6
|
+
export declare function manyToMarkdown(input: NodeJS.ReadableStream, fromFormat: string): Promise<string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pandoc.d.ts","sourceRoot":"","sources":["../../src/pandoc.ts"],"names":[],"mappings":"AAGA,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAK5F;AACD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,cAAc,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAgChG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vertesia/converters",
|
|
3
|
+
"version": "0.24.0-dev.202601221707",
|
|
4
|
+
"description": "Image and content converters",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"types": "./lib/types/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"lib",
|
|
9
|
+
"src"
|
|
10
|
+
],
|
|
11
|
+
"license": "Apache-2.0",
|
|
12
|
+
"exports": {
|
|
13
|
+
"types": "./lib/types/index.d.ts",
|
|
14
|
+
"import": "./lib/esm/index.js",
|
|
15
|
+
"require": "./lib/cjs/index.js"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/tmp": "^0.2.6",
|
|
19
|
+
"ts-dual-module": "^0.6.3",
|
|
20
|
+
"typescript": "^5.9.3",
|
|
21
|
+
"vitest": "^4.0.16"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"sharp": "^0.33.5",
|
|
25
|
+
"tmp": "^0.2.5"
|
|
26
|
+
},
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "https://github.com/vertesia/composableai.git",
|
|
30
|
+
"directory": "packages/converters"
|
|
31
|
+
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"vertesia",
|
|
34
|
+
"converters",
|
|
35
|
+
"image",
|
|
36
|
+
"pdf",
|
|
37
|
+
"markdown",
|
|
38
|
+
"sharp",
|
|
39
|
+
"pandoc",
|
|
40
|
+
"mutool",
|
|
41
|
+
"typescript"
|
|
42
|
+
],
|
|
43
|
+
"ts_dual_module": {
|
|
44
|
+
"outDir": "lib"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"test": "vitest run",
|
|
48
|
+
"build": "pnpm exec tsmod build --esm",
|
|
49
|
+
"clean": "rimraf ./node_modules ./lib ./tsconfig.tsbuildinfo"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import sharp from 'sharp';
|
|
4
|
+
import { expect, test } from 'vitest';
|
|
5
|
+
import { createImageTransformer } from './image';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
test('should resize an image to a maximum height or width', async () => {
|
|
9
|
+
const max_hw = 1596;
|
|
10
|
+
const format: keyof sharp.FormatEnum = 'jpeg';
|
|
11
|
+
const imageFile = fs.readFileSync(path.join(__dirname, '../fixtures', 'cat-picture.jpg'));
|
|
12
|
+
|
|
13
|
+
const sh = createImageTransformer(imageFile, { max_hw, format });
|
|
14
|
+
|
|
15
|
+
const buffer = await sh.toBuffer();
|
|
16
|
+
const metadata = await sharp(buffer).metadata();
|
|
17
|
+
|
|
18
|
+
console.log(metadata);
|
|
19
|
+
//await sh.toFile('./cat-picture.jpg');
|
|
20
|
+
|
|
21
|
+
expect(metadata.width).to.be.lessThanOrEqual(max_hw);
|
|
22
|
+
expect(metadata.height).to.be.lessThanOrEqual(max_hw);
|
|
23
|
+
expect(metadata.format).to.equal(format);
|
|
24
|
+
|
|
25
|
+
});
|
package/src/image.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import sharp from "sharp";
|
|
2
|
+
|
|
3
|
+
export interface TransformOptions {
|
|
4
|
+
max_hw?: number,
|
|
5
|
+
format?: keyof sharp.FormatEnum
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
type SharpInputType = Buffer
|
|
9
|
+
| ArrayBuffer
|
|
10
|
+
| Uint8Array
|
|
11
|
+
| Uint8ClampedArray
|
|
12
|
+
| Int8Array
|
|
13
|
+
| Uint16Array
|
|
14
|
+
| Int16Array
|
|
15
|
+
| Uint32Array
|
|
16
|
+
| Int32Array
|
|
17
|
+
| Float32Array
|
|
18
|
+
| Float64Array
|
|
19
|
+
| string
|
|
20
|
+
| NodeJS.ReadableStream
|
|
21
|
+
export function createImageTransformer(input: SharpInputType, opts: TransformOptions) {
|
|
22
|
+
const isInputStream = !!(input as NodeJS.ReadableStream).pipe;
|
|
23
|
+
let sh = isInputStream ? (input as NodeJS.ReadableStream).pipe(sharp()) : sharp(input as any);
|
|
24
|
+
if (opts.max_hw) {
|
|
25
|
+
sh = sh.resize({
|
|
26
|
+
width: opts.max_hw,
|
|
27
|
+
height: opts.max_hw,
|
|
28
|
+
fit: sharp.fit.inside,
|
|
29
|
+
withoutEnlargement: true,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
if (opts.format) {
|
|
33
|
+
sh = sh.toFormat(opts.format);
|
|
34
|
+
}
|
|
35
|
+
return sh;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @param max_hw
|
|
40
|
+
* @param format
|
|
41
|
+
* @returns
|
|
42
|
+
*/
|
|
43
|
+
export async function transformImage(input: SharpInputType, output: NodeJS.WritableStream, opts: TransformOptions): Promise<sharp.Sharp> {
|
|
44
|
+
const sh = createImageTransformer(input, opts);
|
|
45
|
+
sh.pipe(output);
|
|
46
|
+
|
|
47
|
+
return new Promise((resolve, reject) => {
|
|
48
|
+
const handleError = (err: any) => {
|
|
49
|
+
console.error('Failed to transform', err);
|
|
50
|
+
try {
|
|
51
|
+
if ((input as any).pipe && (input as any).destroy) {
|
|
52
|
+
(input as any).destroy();
|
|
53
|
+
}
|
|
54
|
+
if ((output as any).destroy) {
|
|
55
|
+
(output as any).destroy();
|
|
56
|
+
}
|
|
57
|
+
sh.destroy();
|
|
58
|
+
} finally {
|
|
59
|
+
reject(err);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
output.on('error', handleError);
|
|
63
|
+
(input as any).pipe && (input as any).on && (input as any).on('error', handleError);
|
|
64
|
+
output.on("finish", () => {
|
|
65
|
+
resolve(sh);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function transformImageToBuffer(input: SharpInputType, opts: TransformOptions): Promise<Buffer> {
|
|
71
|
+
const sh = createImageTransformer(input, opts);
|
|
72
|
+
return sh.toBuffer();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export async function transformImageToFile(input: SharpInputType, output: string, opts: TransformOptions): Promise<void> {
|
|
76
|
+
const sh = createImageTransformer(input, opts);
|
|
77
|
+
await sh.toFile(output);
|
|
78
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { transformImage, transformImageToBuffer, transformImageToFile } from './image.js';
|
|
2
|
+
import { pdfFileToText, pdfToText, pdfToTextBuffer } from './mutool.js';
|
|
3
|
+
import { manyToMarkdown } from './pandoc.js';
|
|
4
|
+
|
|
5
|
+
export {
|
|
6
|
+
manyToMarkdown,
|
|
7
|
+
pdfFileToText, pdfToText,
|
|
8
|
+
pdfToTextBuffer,
|
|
9
|
+
transformImage,
|
|
10
|
+
transformImageToBuffer,
|
|
11
|
+
transformImageToFile
|
|
12
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { expect, test } from 'vitest';
|
|
4
|
+
import { pdfToText } from './mutool.js';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
test('[mutool] should convert pdf to text', async () => {
|
|
8
|
+
const pdf = fs.readFileSync(path.join(__dirname, '../fixtures', 'test-pdf2.pdf'));
|
|
9
|
+
const buf = Buffer.from(pdf);
|
|
10
|
+
console.log("Running mutoolPdfToText")
|
|
11
|
+
const result: string = await pdfToText(buf);
|
|
12
|
+
expect(result).toContain('its attentive Ambassadors');
|
|
13
|
+
|
|
14
|
+
});
|
package/src/mutool.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { spawn } from 'child_process';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import { readFile } from "fs/promises";
|
|
4
|
+
import tmp from 'tmp';
|
|
5
|
+
tmp.setGracefulCleanup();
|
|
6
|
+
|
|
7
|
+
export function pdfFileToText(input: string, output: string) {
|
|
8
|
+
return new Promise((resolve, reject) => {
|
|
9
|
+
|
|
10
|
+
const command = spawn("mutool", ["convert", "-o", output, input]);
|
|
11
|
+
|
|
12
|
+
command.on('exit', function (code) {
|
|
13
|
+
if (code) {
|
|
14
|
+
reject(new Error(`mutool exited with code ${code}`));
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
command.on('close', function (code) {
|
|
19
|
+
if (code) {
|
|
20
|
+
reject(new Error(`mutool exited with code ${code}`));
|
|
21
|
+
} else {
|
|
22
|
+
return resolve(output);
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
command.on('error', (err) => {
|
|
27
|
+
reject(err);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
export function pdfToText(buffer: Buffer): Promise<string> {
|
|
34
|
+
return pdfToTextBuffer(buffer).then((buffer) => buffer.toString('utf-8'));
|
|
35
|
+
}
|
|
36
|
+
export function pdfToTextBuffer(buffer: Buffer): Promise<Buffer> {
|
|
37
|
+
const inputFile = tmp.fileSync({ postfix: '.pdf' });
|
|
38
|
+
const targetFileName = tmp.tmpNameSync({ postfix: '.txt' });
|
|
39
|
+
|
|
40
|
+
fs.writeSync(inputFile.fd, buffer);
|
|
41
|
+
|
|
42
|
+
return pdfFileToText(inputFile.name, targetFileName).then(() => {
|
|
43
|
+
return readFile(targetFileName);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { Readable } from 'stream';
|
|
4
|
+
import { expect, test } from 'vitest';
|
|
5
|
+
import { manyToMarkdown } from './pandoc';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
// Add more test cases for other file types (ODT, DOCX) if needed
|
|
10
|
+
test('should convert docx to markdown', async () => {
|
|
11
|
+
const docx: Buffer = fs.readFileSync(path.join(__dirname, '../fixtures', 'us-ciia.docx'));
|
|
12
|
+
const result = await manyToMarkdown(Readable.from(docx), 'docx');
|
|
13
|
+
expect(result).to.include('confidential');
|
|
14
|
+
});
|
package/src/pandoc.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { spawn } from 'child_process';
|
|
2
|
+
import { PassThrough } from 'stream';
|
|
3
|
+
|
|
4
|
+
export function manyToMarkdownFromBuffer(buffer: Buffer, fromFormat: string): Promise<string> {
|
|
5
|
+
const input = new PassThrough();
|
|
6
|
+
input.end(buffer);
|
|
7
|
+
return manyToMarkdown(input, fromFormat);
|
|
8
|
+
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Requires pandoc to be installed on the system.
|
|
12
|
+
* @param fromFormat is the format of the input buffer.
|
|
13
|
+
*/
|
|
14
|
+
export function manyToMarkdown(input: NodeJS.ReadableStream, fromFormat: string): Promise<string> {
|
|
15
|
+
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
let result: string[] = [];
|
|
18
|
+
|
|
19
|
+
const command = spawn("pandoc", ["-t", "markdown", '-f', fromFormat], {
|
|
20
|
+
stdio: 'pipe',
|
|
21
|
+
});
|
|
22
|
+
input.pipe(command.stdin);
|
|
23
|
+
|
|
24
|
+
command.stdout.on('data', function (data: string) {
|
|
25
|
+
result.push(data.toString());
|
|
26
|
+
});
|
|
27
|
+
command.on('exit', function (code) {
|
|
28
|
+
if (code) {
|
|
29
|
+
reject(new Error(`pandoc exited with code ${code}`));
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
command.on('close', function (code) {
|
|
33
|
+
if (code) {
|
|
34
|
+
reject(new Error(`pandoc exited with code ${code}`));
|
|
35
|
+
} else {
|
|
36
|
+
resolve(result.join(''))
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
command.on('error', (err) => {
|
|
41
|
+
reject(err);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
}
|