convertit 1.0.0 → 1.0.1
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/CHANGELOG.md +7 -0
- package/README.md +98 -82
- package/dist/converters/excel-styles.d.ts.map +1 -1
- package/dist/converters/excel.d.ts.map +1 -1
- package/dist/converters/image.d.ts.map +1 -1
- package/dist/converters/pdf.d.ts.map +1 -1
- package/dist/converters/text.d.ts +4 -4
- package/dist/converters/text.d.ts.map +1 -1
- package/dist/index.js +21 -22
- package/dist/transformers/index.d.ts +3 -3
- package/dist/transformers/index.d.ts.map +1 -1
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -8,12 +8,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
8
8
|
### Added
|
|
9
9
|
|
|
10
10
|
#### Core Features
|
|
11
|
+
|
|
11
12
|
- **File Conversion**: Support for PDF, Word (DOCX), Excel (XLSX), CSV, HTML, JSON, XML, Markdown, and image formats
|
|
12
13
|
- **Builder Pattern**: Fluent API for chaining conversion operations
|
|
13
14
|
- **Batch Processing**: Convert multiple files with configurable concurrency
|
|
14
15
|
- **Progress Tracking**: Monitor conversion progress with callbacks
|
|
15
16
|
|
|
16
17
|
#### Excel Conditional Formatting (NEW)
|
|
18
|
+
|
|
17
19
|
- **Row Styles**: Color entire rows based on conditions
|
|
18
20
|
- Even/odd row styling (zebra stripes)
|
|
19
21
|
- Column value conditions (equal, greater than, less than, etc.)
|
|
@@ -34,6 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
34
36
|
- Icon sets
|
|
35
37
|
|
|
36
38
|
#### Template Engine (NEW)
|
|
39
|
+
|
|
37
40
|
- Simple yet powerful template processing
|
|
38
41
|
- Variable substitution with dot notation
|
|
39
42
|
- Conditionals (`#if`, `#unless`, `#else`)
|
|
@@ -48,6 +51,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
48
51
|
- `json`, `join`, `length`, `default`
|
|
49
52
|
|
|
50
53
|
#### Transformers
|
|
54
|
+
|
|
51
55
|
- **Watermark**: Add text watermarks to PDFs
|
|
52
56
|
- **Encryption**: Password protect PDF files
|
|
53
57
|
- **Compression**: Reduce file sizes
|
|
@@ -58,6 +62,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
58
62
|
- **Rotation**: Rotate PDF pages
|
|
59
63
|
|
|
60
64
|
#### Developer Experience
|
|
65
|
+
|
|
61
66
|
- **ESLint**: Code linting with TypeScript support
|
|
62
67
|
- **Husky**: Git hooks for pre-commit and pre-push
|
|
63
68
|
- **lint-staged**: Run linters on staged files
|
|
@@ -65,6 +70,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
65
70
|
- **TypeScript**: Full type definitions for all APIs
|
|
66
71
|
|
|
67
72
|
#### Utilities
|
|
73
|
+
|
|
68
74
|
- File format detection and validation
|
|
69
75
|
- MIME type utilities
|
|
70
76
|
- Color parsing and conversion
|
|
@@ -73,6 +79,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
73
79
|
- Async utilities (delay, retry, timeout)
|
|
74
80
|
|
|
75
81
|
### Technical Details
|
|
82
|
+
|
|
76
83
|
- Built with Bun for fast development
|
|
77
84
|
- ESM and CJS dual module support
|
|
78
85
|
- Comprehensive test coverage
|
package/README.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# convertit
|
|
2
2
|
|
|
3
|
+
<p align="center">
|
|
4
|
+
<a href="https://www.npmjs.com/package/convertit"><img src="https://img.shields.io/npm/v/convertit.svg" alt="npm version"></a>
|
|
5
|
+
<a href="https://www.npmjs.com/package/convertit"><img src="https://img.shields.io/npm/dm/convertit.svg" alt="npm downloads"></a>
|
|
6
|
+
<a href="https://github.com/suraj-9849/convertit"><img src="https://img.shields.io/github/stars/suraj-9849/convertit.svg?style=social" alt="GitHub stars"></a>
|
|
7
|
+
<a href="https://github.com/suraj-9849/convertit/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/convertit.svg" alt="license"></a>
|
|
8
|
+
</p>
|
|
9
|
+
|
|
3
10
|
<p align="center">
|
|
4
11
|
<strong>A powerful, type-safe file conversion library for Node.js and Bun</strong>
|
|
5
12
|
</p>
|
|
@@ -71,7 +78,8 @@ const base64 = await convertit.from(data).toPdf().toBase64();
|
|
|
71
78
|
import convertit from 'convertit';
|
|
72
79
|
|
|
73
80
|
// Convert JSON to PDF with options
|
|
74
|
-
const buffer = await convertit
|
|
81
|
+
const buffer = await convertit
|
|
82
|
+
.from(jsonData)
|
|
75
83
|
.toPdf({ pageSize: 'A4', orientation: 'landscape' })
|
|
76
84
|
.withWatermark({ text: 'DRAFT', opacity: 0.3 })
|
|
77
85
|
.withCompression({ level: 'medium' })
|
|
@@ -94,7 +102,8 @@ const salesData = [
|
|
|
94
102
|
];
|
|
95
103
|
|
|
96
104
|
// Create Excel with conditional row colors
|
|
97
|
-
const excel = await convertit
|
|
105
|
+
const excel = await convertit
|
|
106
|
+
.from(salesData)
|
|
98
107
|
.toExcel({
|
|
99
108
|
sheetName: 'Sales Report',
|
|
100
109
|
rowStyles: [
|
|
@@ -130,7 +139,7 @@ const excel = await convertit.from(salesData)
|
|
|
130
139
|
{
|
|
131
140
|
condition: {
|
|
132
141
|
type: 'expression',
|
|
133
|
-
expression:
|
|
142
|
+
expression: row => row.status === 'Deficit',
|
|
134
143
|
},
|
|
135
144
|
style: StylePresets.negativeHighlight,
|
|
136
145
|
},
|
|
@@ -141,46 +150,49 @@ const excel = await convertit.from(salesData)
|
|
|
141
150
|
|
|
142
151
|
### Row Style Conditions
|
|
143
152
|
|
|
144
|
-
| Condition Type | Description
|
|
145
|
-
|
|
146
|
-
| `even`
|
|
147
|
-
| `odd`
|
|
148
|
-
| `columnValue`
|
|
149
|
-
| `expression`
|
|
153
|
+
| Condition Type | Description | Example |
|
|
154
|
+
| -------------- | ------------------------ | ------------------------------------------------------------------------ |
|
|
155
|
+
| `even` | Style even-numbered rows | `{ type: 'even' }` |
|
|
156
|
+
| `odd` | Style odd-numbered rows | `{ type: 'odd' }` |
|
|
157
|
+
| `columnValue` | Based on column value | `{ type: 'columnValue', column: 'amount', operator: 'equal', value: 0 }` |
|
|
158
|
+
| `expression` | Custom JavaScript logic | `{ type: 'expression', expression: (row) => row.amount < 0 }` |
|
|
150
159
|
|
|
151
160
|
### Cell Styles
|
|
152
161
|
|
|
153
162
|
Style specific cells, columns, or ranges:
|
|
154
163
|
|
|
155
164
|
```typescript
|
|
156
|
-
await convertit
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
165
|
+
await convertit
|
|
166
|
+
.from(data)
|
|
167
|
+
.toExcel({
|
|
168
|
+
cellStyles: [
|
|
169
|
+
// Style entire column
|
|
170
|
+
{
|
|
171
|
+
target: 'D', // Column D (amount)
|
|
172
|
+
style: {
|
|
173
|
+
numFmt: '$#,##0.00',
|
|
174
|
+
alignment: { horizontal: 'right' },
|
|
175
|
+
},
|
|
164
176
|
},
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
177
|
+
// Style header row
|
|
178
|
+
{
|
|
179
|
+
target: 'A1:F1',
|
|
180
|
+
style: {
|
|
181
|
+
font: { bold: true, color: '#FFFFFF' },
|
|
182
|
+
fill: { color: '#1976D2' },
|
|
183
|
+
},
|
|
172
184
|
},
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
185
|
+
// Style specific cell
|
|
186
|
+
{
|
|
187
|
+
target: 'A10',
|
|
188
|
+
style: {
|
|
189
|
+
font: { bold: true, size: 14 },
|
|
190
|
+
border: { bottom: { style: 'thick' } },
|
|
191
|
+
},
|
|
180
192
|
},
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
193
|
+
],
|
|
194
|
+
})
|
|
195
|
+
.toFile('styled-cells.xlsx');
|
|
184
196
|
```
|
|
185
197
|
|
|
186
198
|
### Style Presets
|
|
@@ -191,13 +203,13 @@ Use built-in presets for common styling scenarios:
|
|
|
191
203
|
import { StylePresets } from 'convertit';
|
|
192
204
|
|
|
193
205
|
// Available presets:
|
|
194
|
-
StylePresets.positiveHighlight
|
|
195
|
-
StylePresets.negativeHighlight
|
|
196
|
-
StylePresets.warningHighlight
|
|
197
|
-
StylePresets.headerStyle
|
|
198
|
-
StylePresets.totalRow
|
|
199
|
-
StylePresets.currencyFormat
|
|
200
|
-
StylePresets.percentFormat
|
|
206
|
+
StylePresets.positiveHighlight; // Green background
|
|
207
|
+
StylePresets.negativeHighlight; // Red background
|
|
208
|
+
StylePresets.warningHighlight; // Yellow/amber background
|
|
209
|
+
StylePresets.headerStyle; // Bold white text on blue
|
|
210
|
+
StylePresets.totalRow; // Bold with top border
|
|
211
|
+
StylePresets.currencyFormat; // Currency number format
|
|
212
|
+
StylePresets.percentFormat; // Percentage format
|
|
201
213
|
```
|
|
202
214
|
|
|
203
215
|
### Native Excel Conditional Formatting
|
|
@@ -205,33 +217,37 @@ StylePresets.percentFormat // Percentage format
|
|
|
205
217
|
Apply Excel's built-in conditional formatting rules:
|
|
206
218
|
|
|
207
219
|
```typescript
|
|
208
|
-
await convertit
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
}
|
|
220
|
+
await convertit
|
|
221
|
+
.from(data)
|
|
222
|
+
.toExcel({
|
|
223
|
+
conditionalFormatting: [
|
|
224
|
+
// Data bars
|
|
225
|
+
{
|
|
226
|
+
type: 'dataBar',
|
|
227
|
+
ref: 'D2:D100',
|
|
228
|
+
rules: { color: '4CAF50' },
|
|
229
|
+
},
|
|
230
|
+
// Color scale (heat map)
|
|
231
|
+
{
|
|
232
|
+
type: 'colorScale',
|
|
233
|
+
ref: 'E2:E100',
|
|
234
|
+
rules: { color: 'F44336' },
|
|
235
|
+
},
|
|
236
|
+
// Icon sets
|
|
237
|
+
{
|
|
238
|
+
type: 'iconSet',
|
|
239
|
+
ref: 'F2:F100',
|
|
240
|
+
rules: { iconSet: '3TrafficLights' },
|
|
241
|
+
},
|
|
242
|
+
],
|
|
243
|
+
})
|
|
244
|
+
.toFile('conditional-formatting.xlsx');
|
|
230
245
|
```
|
|
231
246
|
|
|
232
247
|
## Supported Conversions
|
|
233
248
|
|
|
234
249
|
### Documents
|
|
250
|
+
|
|
235
251
|
- **PDF**: Create PDFs from text, JSON, arrays, or other data
|
|
236
252
|
- **Word (DOCX)**: Generate Word documents with formatting
|
|
237
253
|
- **HTML**: Convert to HTML with templates and styling
|
|
@@ -239,14 +255,17 @@ await convertit.from(data).toExcel({
|
|
|
239
255
|
- **Plain Text**: Extract or convert to plain text
|
|
240
256
|
|
|
241
257
|
### Spreadsheets
|
|
258
|
+
|
|
242
259
|
- **Excel (XLSX)**: Create spreadsheets with multiple sheets, formulas, conditional formatting, and styling
|
|
243
260
|
- **CSV**: Generate CSV with custom delimiters
|
|
244
261
|
|
|
245
262
|
### Data Formats
|
|
263
|
+
|
|
246
264
|
- **JSON**: Convert to/from JSON
|
|
247
265
|
- **XML**: Generate XML from data
|
|
248
266
|
|
|
249
267
|
### Images
|
|
268
|
+
|
|
250
269
|
- **PNG, JPG, JPEG, WebP, GIF, BMP, TIFF**: Convert between image formats
|
|
251
270
|
- **Resize, crop, rotate, and apply filters**
|
|
252
271
|
|
|
@@ -305,23 +324,22 @@ toFile(path: string): Promise<string>
|
|
|
305
324
|
|
|
306
325
|
```typescript
|
|
307
326
|
const data = [
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
327
|
+
{ name: 'Suraj', email: 'surajlohit42@example.com', salary: 85000 },
|
|
328
|
+
{ name: 'Sathya', email: 'sathya@example.com', salary: 95000 },
|
|
329
|
+
{ name: 'Karthik', email: 'karthik@example.com', salary: 79000 },
|
|
330
|
+
{ name: 'Charan', email: 'charan@example.com', salary: 91000 },
|
|
331
|
+
{ name: 'Sid', email: 'sid@example.com', salary: 75000 },
|
|
332
|
+
{ name: 'pruthvi', email: 'pruthvi@example.com', salary: 95000 },
|
|
314
333
|
];
|
|
315
334
|
|
|
316
|
-
const buffer = await convertit
|
|
335
|
+
const buffer = await convertit
|
|
336
|
+
.from(data)
|
|
317
337
|
.toExcel({
|
|
318
338
|
sheetName: 'Employees',
|
|
319
339
|
autoFilter: true,
|
|
320
340
|
freezePane: { row: 1 },
|
|
321
341
|
autoWidth: true,
|
|
322
|
-
rowStyles: [
|
|
323
|
-
{ condition: { type: 'even' }, style: { fill: { color: '#F5F5F5' } } },
|
|
324
|
-
],
|
|
342
|
+
rowStyles: [{ condition: { type: 'even' }, style: { fill: { color: '#F5F5F5' } } }],
|
|
325
343
|
cellStyles: [
|
|
326
344
|
{
|
|
327
345
|
target: 'C', // Salary column
|
|
@@ -335,7 +353,8 @@ const buffer = await convertit.from(data)
|
|
|
335
353
|
### Create PDF with Headers and Footers
|
|
336
354
|
|
|
337
355
|
```typescript
|
|
338
|
-
const buffer = await convertit
|
|
356
|
+
const buffer = await convertit
|
|
357
|
+
.from(content)
|
|
339
358
|
.toPdf({
|
|
340
359
|
pageSize: 'A4',
|
|
341
360
|
margins: { top: 72, bottom: 72, left: 72, right: 72 },
|
|
@@ -355,7 +374,8 @@ const buffer = await convertit.from(content)
|
|
|
355
374
|
### Add Watermark to PDF
|
|
356
375
|
|
|
357
376
|
```typescript
|
|
358
|
-
const watermarkedPdf = await convertit
|
|
377
|
+
const watermarkedPdf = await convertit
|
|
378
|
+
.from(pdfBuffer)
|
|
359
379
|
.toPdf()
|
|
360
380
|
.withWatermark({
|
|
361
381
|
text: 'CONFIDENTIAL',
|
|
@@ -384,12 +404,7 @@ console.log(`Converted ${result.successCount}/${result.totalFiles} files`);
|
|
|
384
404
|
For advanced use cases, use converters directly:
|
|
385
405
|
|
|
386
406
|
```typescript
|
|
387
|
-
import {
|
|
388
|
-
PDFManipulator,
|
|
389
|
-
ExcelUtils,
|
|
390
|
-
ExcelStyleEngine,
|
|
391
|
-
ImageUtils
|
|
392
|
-
} from 'convertit';
|
|
407
|
+
import { PDFManipulator, ExcelUtils, ExcelStyleEngine, ImageUtils } from 'convertit';
|
|
393
408
|
|
|
394
409
|
// PDF manipulation
|
|
395
410
|
const pageCount = await PDFManipulator.getPageCount(pdfBuffer);
|
|
@@ -495,9 +510,10 @@ bun run typecheck
|
|
|
495
510
|
## Contributing
|
|
496
511
|
|
|
497
512
|
Contributions are welcome! This project uses:
|
|
513
|
+
|
|
498
514
|
- ESLint for linting
|
|
499
515
|
- Husky for git hooks
|
|
500
516
|
- lint-staged for pre-commit checks
|
|
501
517
|
- GitHub Actions for CI/CD
|
|
502
518
|
|
|
503
|
-
Please ensure your PR passes all checks before submitting.
|
|
519
|
+
Please ensure your PR passes all checks before submitting.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"excel-styles.d.ts","sourceRoot":"","sources":["../../src/converters/excel-styles.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,EACV,YAAY,EAEZ,YAAY,EAEZ,SAAS,EACT,kBAAkB,EACnB,MAAM,eAAe,CAAC;AAEvB,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,SAAS,CAAoB;IACrC,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,IAAI,CAAQ;gBAER,SAAS,EAAE,OAAO,CAAC,SAAS,EA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eAAe,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"excel.d.ts","sourceRoot":"","sources":["../../src/converters/excel.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,UAAU,EAAgB,MAAM,eAAe,CAAC;AAIjG,qBAAa,cAAe,SAAQ,aAAa;;IAK/C,wBAAwB,IAAI,UAAU,EAAE;IAIlC,OAAO,CAAC,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC;YAwBlE,eAAe;YAgCf,gBAAgB;YA2BhB,gBAAgB;YAmChB,WAAW;IAqGzB,OAAO,CAAC,cAAc;IA8BtB,OAAO,CAAC,YAAY;IAiCpB,OAAO,CAAC,eAAe;CAgBxB;AAED;;GAEG;AACH,qBAAa,UAAU;IACrB;;OAEG;WACU,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC;IAkBjD;;OAEG;WACU,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;IAmBrE;;OAEG;WACU,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAM3D;;OAEG;WACU,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CA4B/E;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/converters/image.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OA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AEG;WACU,eAAe,CAC1B,KAAK,EAAE,MAAM,EACb,KAAK,GAAE,MAAY,EACnB,MAAM,GAAE,MAAY,GACnB,OAAO,CAAC,MAAM,CAAC;IAIlB;;OAEG;WACU,KAAK,CAChB,MAAM,EAAE,MAAM,EAAE,EAChB,SAAS,GAAE,YAAY,GAAG,UAAyB,GAClD,OAAO,CAAC,MAAM,CAAC;CAgEnB;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pdf.d.ts","sourceRoot":"","sources":["../../src/converters/pdf.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,EACV,aAAa,EACb,kBAAkB,EAClB,UAAU,EAGX,MAAM,eAAe,CAAC;AAIvB,qBAAa,YAAa,SAAQ,aAAa;;IAK7C,wBAAwB,IAAI,UAAU,EAAE;IAIlC,OAAO,CAAC,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC;IA6BhF,OAAO,CAAC,WAAW;
|
|
1
|
+
{"version":3,"file":"pdf.d.ts","sourceRoot":"","sources":["../../src/converters/pdf.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,EACV,aAAa,EACb,kBAAkB,EAClB,UAAU,EAGX,MAAM,eAAe,CAAC;AAIvB,qBAAa,YAAa,SAAQ,aAAa;;IAK7C,wBAAwB,IAAI,UAAU,EAAE;IAIlC,OAAO,CAAC,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC;IA6BhF,OAAO,CAAC,WAAW;YAOL,cAAc;YAwFd,eAAe;YAoBf,gBAAgB;YAUhB,mBAAmB;YAkDnB,gBAAgB;IAU9B,OAAO,CAAC,SAAS;IAmDjB,OAAO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M,CAAC;CAiBhF;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -6,19 +6,19 @@ import type { InputDataType, ConvertFileOptions, FileFormat } from '../core/type
|
|
|
6
6
|
export declare class TextConverter extends BaseConverter {
|
|
7
7
|
constructor();
|
|
8
8
|
getSupportedInputFormats(): FileFormat[];
|
|
9
|
-
convert(data: InputDataType,
|
|
9
|
+
convert(data: InputDataType, _options: ConvertFileOptions): Promise<Buffer>;
|
|
10
10
|
private arrayToText;
|
|
11
11
|
private objectToText;
|
|
12
12
|
}
|
|
13
13
|
export declare class JSONConverter extends BaseConverter {
|
|
14
14
|
constructor();
|
|
15
15
|
getSupportedInputFormats(): FileFormat[];
|
|
16
|
-
convert(data: InputDataType,
|
|
16
|
+
convert(data: InputDataType, _options: ConvertFileOptions): Promise<Buffer>;
|
|
17
17
|
}
|
|
18
18
|
export declare class XMLConverter extends BaseConverter {
|
|
19
19
|
constructor();
|
|
20
20
|
getSupportedInputFormats(): FileFormat[];
|
|
21
|
-
convert(data: InputDataType,
|
|
21
|
+
convert(data: InputDataType, _options: ConvertFileOptions): Promise<Buffer>;
|
|
22
22
|
private objectToXml;
|
|
23
23
|
private escapeXml;
|
|
24
24
|
private sanitizeTagName;
|
|
@@ -26,7 +26,7 @@ export declare class XMLConverter extends BaseConverter {
|
|
|
26
26
|
export declare class MarkdownConverter extends BaseConverter {
|
|
27
27
|
constructor();
|
|
28
28
|
getSupportedInputFormats(): FileFormat[];
|
|
29
|
-
convert(data: InputDataType,
|
|
29
|
+
convert(data: InputDataType, _options: ConvertFileOptions): Promise<Buffer>;
|
|
30
30
|
private convertToMarkdown;
|
|
31
31
|
private htmlToMarkdown;
|
|
32
32
|
private arrayToMarkdown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/converters/text.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO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;IAQzB,OAAO,CAAC,cAAc;IAkEtB,OAAO,CAAC,eAAe;IAYvB,OAAO,CAAC,mBAAmB;IAoB3B,OAAO,CAAC,gBAAgB;CAwBzB"}
|
package/dist/index.js
CHANGED
|
@@ -247737,7 +247737,7 @@ class PDFConverter extends BaseConverter {
|
|
|
247737
247737
|
const invalidChars = text.match(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g);
|
|
247738
247738
|
return !invalidChars || invalidChars.length < text.length * 0.1;
|
|
247739
247739
|
}
|
|
247740
|
-
async createFromText(text, pdfOptions,
|
|
247740
|
+
async createFromText(text, pdfOptions, _options) {
|
|
247741
247741
|
return new Promise((resolve, reject) => {
|
|
247742
247742
|
try {
|
|
247743
247743
|
const pageSize = getPageSize(pdfOptions.pageSize || "A4");
|
|
@@ -247815,7 +247815,7 @@ class PDFConverter extends BaseConverter {
|
|
|
247815
247815
|
const text = JSON.stringify(data, null, 2);
|
|
247816
247816
|
return this.createFromText(text, pdfOptions, options);
|
|
247817
247817
|
}
|
|
247818
|
-
async createFromTableData(data, pdfOptions,
|
|
247818
|
+
async createFromTableData(data, pdfOptions, _options) {
|
|
247819
247819
|
return new Promise((resolve, reject) => {
|
|
247820
247820
|
try {
|
|
247821
247821
|
const pageSize = getPageSize(pdfOptions.pageSize || "A4");
|
|
@@ -265375,14 +265375,16 @@ class ExcelStyleEngine {
|
|
|
265375
265375
|
return rowIndex % 2 === 0;
|
|
265376
265376
|
case "odd":
|
|
265377
265377
|
return rowIndex % 2 === 1;
|
|
265378
|
-
case "every":
|
|
265378
|
+
case "every": {
|
|
265379
265379
|
const offset = condition.offset || 0;
|
|
265380
265380
|
return (rowIndex - offset) % condition.n === 0;
|
|
265381
|
+
}
|
|
265381
265382
|
case "range":
|
|
265382
265383
|
return rowIndex >= condition.start && rowIndex <= condition.end;
|
|
265383
|
-
case "custom":
|
|
265384
|
+
case "custom": {
|
|
265384
265385
|
const dataArray = Array.isArray(rowData) ? rowData : Object.values(rowData || {});
|
|
265385
265386
|
return condition.predicate(dataArray, rowIndex);
|
|
265387
|
+
}
|
|
265386
265388
|
case "columnValue":
|
|
265387
265389
|
return this.evaluateColumnCondition(rowData, condition);
|
|
265388
265390
|
default:
|
|
@@ -265943,8 +265945,6 @@ class ExcelUtils {
|
|
|
265943
265945
|
static async merge(files, outputSheetName) {
|
|
265944
265946
|
const workbook = new import_exceljs.default.Workbook;
|
|
265945
265947
|
const mergedSheet = workbook.addWorksheet(outputSheetName || "Merged");
|
|
265946
|
-
let currentRow = 1;
|
|
265947
|
-
let headers = [];
|
|
265948
265948
|
let headersAdded = false;
|
|
265949
265949
|
for (const file of files) {
|
|
265950
265950
|
const sourceWorkbook = new import_exceljs.default.Workbook;
|
|
@@ -265955,14 +265955,11 @@ class ExcelUtils {
|
|
|
265955
265955
|
sourceSheet.eachRow((row, rowNumber) => {
|
|
265956
265956
|
if (rowNumber === 1) {
|
|
265957
265957
|
if (!headersAdded) {
|
|
265958
|
-
|
|
265959
|
-
const headerRow = mergedSheet.addRow(row.values);
|
|
265960
|
-
currentRow++;
|
|
265958
|
+
mergedSheet.addRow(row.values);
|
|
265961
265959
|
headersAdded = true;
|
|
265962
265960
|
}
|
|
265963
265961
|
} else {
|
|
265964
265962
|
mergedSheet.addRow(row.values);
|
|
265965
|
-
currentRow++;
|
|
265966
265963
|
}
|
|
265967
265964
|
});
|
|
265968
265965
|
}
|
|
@@ -268060,7 +268057,7 @@ class HTMLConverter extends BaseConverter {
|
|
|
268060
268057
|
html = html.replace(/`([^`]+)`/g, "<code>$1</code>");
|
|
268061
268058
|
html = html.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<a href="$2">$1</a>');
|
|
268062
268059
|
html = html.replace(/!\[([^\]]*)\]\(([^)]+)\)/g, '<img src="$2" alt="$1">');
|
|
268063
|
-
html = html.replace(/^[
|
|
268060
|
+
html = html.replace(/^[*-] (.+)$/gm, "<li>$1</li>");
|
|
268064
268061
|
html = html.replace(/(<li>.*<\/li>\n?)+/g, "<ul>$&</ul>");
|
|
268065
268062
|
html = html.replace(/^\d+\. (.+)$/gm, "<li>$1</li>");
|
|
268066
268063
|
html = html.replace(/^> (.+)$/gm, "<blockquote>$1</blockquote>");
|
|
@@ -268315,7 +268312,6 @@ class ImageConverter extends BaseConverter {
|
|
|
268315
268312
|
async processImage(input, format2, options2) {
|
|
268316
268313
|
try {
|
|
268317
268314
|
let image = import_sharp.default(input);
|
|
268318
|
-
const metadata = await image.metadata();
|
|
268319
268315
|
if (options2.width || options2.height) {
|
|
268320
268316
|
image = image.resize({
|
|
268321
268317
|
width: options2.width,
|
|
@@ -268508,7 +268504,7 @@ class ImageUtils {
|
|
|
268508
268504
|
case "webp":
|
|
268509
268505
|
image = image.webp({ quality });
|
|
268510
268506
|
break;
|
|
268511
|
-
default:
|
|
268507
|
+
default: {
|
|
268512
268508
|
const metadata = await import_sharp.default(input).metadata();
|
|
268513
268509
|
if (metadata.format === "jpeg" || metadata.format === "jpg") {
|
|
268514
268510
|
image = image.jpeg({ quality });
|
|
@@ -268517,6 +268513,7 @@ class ImageUtils {
|
|
|
268517
268513
|
} else {
|
|
268518
268514
|
image = image.webp({ quality });
|
|
268519
268515
|
}
|
|
268516
|
+
}
|
|
268520
268517
|
}
|
|
268521
268518
|
return image.toBuffer();
|
|
268522
268519
|
}
|
|
@@ -268588,7 +268585,7 @@ class TextConverter extends BaseConverter {
|
|
|
268588
268585
|
getSupportedInputFormats() {
|
|
268589
268586
|
return ["json", "csv", "html", "xml", "markdown", "md"];
|
|
268590
268587
|
}
|
|
268591
|
-
async convert(data,
|
|
268588
|
+
async convert(data, _options) {
|
|
268592
268589
|
let text;
|
|
268593
268590
|
if (typeof data === "string") {
|
|
268594
268591
|
text = data;
|
|
@@ -268649,7 +268646,7 @@ class JSONConverter extends BaseConverter {
|
|
|
268649
268646
|
getSupportedInputFormats() {
|
|
268650
268647
|
return ["csv", "xml", "txt", "excel", "xlsx"];
|
|
268651
268648
|
}
|
|
268652
|
-
async convert(data,
|
|
268649
|
+
async convert(data, _options) {
|
|
268653
268650
|
let jsonData;
|
|
268654
268651
|
if (typeof data === "string") {
|
|
268655
268652
|
try {
|
|
@@ -268679,7 +268676,7 @@ class XMLConverter extends BaseConverter {
|
|
|
268679
268676
|
getSupportedInputFormats() {
|
|
268680
268677
|
return ["json", "csv", "txt"];
|
|
268681
268678
|
}
|
|
268682
|
-
async convert(data,
|
|
268679
|
+
async convert(data, _options) {
|
|
268683
268680
|
let obj2;
|
|
268684
268681
|
if (typeof data === "string") {
|
|
268685
268682
|
try {
|
|
@@ -268746,7 +268743,7 @@ class MarkdownConverter extends BaseConverter {
|
|
|
268746
268743
|
getSupportedInputFormats() {
|
|
268747
268744
|
return ["json", "csv", "txt", "html"];
|
|
268748
268745
|
}
|
|
268749
|
-
async convert(data,
|
|
268746
|
+
async convert(data, _options) {
|
|
268750
268747
|
let markdown;
|
|
268751
268748
|
if (typeof data === "string") {
|
|
268752
268749
|
markdown = this.convertToMarkdown(data);
|
|
@@ -268934,7 +268931,7 @@ class CompressionTransformer {
|
|
|
268934
268931
|
}
|
|
268935
268932
|
|
|
268936
268933
|
class MergeTransformer {
|
|
268937
|
-
static async merge(files, format2,
|
|
268934
|
+
static async merge(files, format2, _config) {
|
|
268938
268935
|
if (files.length === 0) {
|
|
268939
268936
|
throw new ConvertFileError("INVALID_INPUT" /* INVALID_INPUT */, "No files to merge");
|
|
268940
268937
|
}
|
|
@@ -268947,9 +268944,10 @@ class MergeTransformer {
|
|
|
268947
268944
|
case "xlsx":
|
|
268948
268945
|
case "excel":
|
|
268949
268946
|
return ExcelUtils.merge(files);
|
|
268950
|
-
case "csv":
|
|
268947
|
+
case "csv": {
|
|
268951
268948
|
const merged = CSVUtils.merge(files.map((f) => f.toString("utf-8")));
|
|
268952
268949
|
return Buffer.from(merged, "utf-8");
|
|
268950
|
+
}
|
|
268953
268951
|
case "png":
|
|
268954
268952
|
case "jpg":
|
|
268955
268953
|
case "jpeg":
|
|
@@ -269079,9 +269077,10 @@ class WatermarkTransformer {
|
|
|
269079
269077
|
class RotationTransformer {
|
|
269080
269078
|
static async rotate(data, format2, config) {
|
|
269081
269079
|
switch (format2) {
|
|
269082
|
-
case "pdf":
|
|
269080
|
+
case "pdf": {
|
|
269083
269081
|
const pages = config.pages === "all" ? undefined : config.pages === "odd" ? Array.from({ length: 100 }, (_2, i2) => i2 * 2 + 1) : config.pages === "even" ? Array.from({ length: 100 }, (_2, i2) => (i2 + 1) * 2) : config.pages;
|
|
269084
269082
|
return PDFManipulator.rotatePages(data, config.angle, pages);
|
|
269083
|
+
}
|
|
269085
269084
|
case "png":
|
|
269086
269085
|
case "jpg":
|
|
269087
269086
|
case "jpeg":
|
|
@@ -269094,7 +269093,7 @@ class RotationTransformer {
|
|
|
269094
269093
|
}
|
|
269095
269094
|
|
|
269096
269095
|
class EncryptionTransformer {
|
|
269097
|
-
static async encrypt(data, format2,
|
|
269096
|
+
static async encrypt(data, format2, _config) {
|
|
269098
269097
|
switch (format2) {
|
|
269099
269098
|
case "pdf":
|
|
269100
269099
|
console.warn("PDF encryption is not fully implemented");
|
|
@@ -269110,7 +269109,7 @@ class EncryptionTransformer {
|
|
|
269110
269109
|
}
|
|
269111
269110
|
|
|
269112
269111
|
class PageNumberTransformer {
|
|
269113
|
-
static async addPageNumbers(data, format2,
|
|
269112
|
+
static async addPageNumbers(data, format2, _config) {
|
|
269114
269113
|
switch (format2) {
|
|
269115
269114
|
case "pdf":
|
|
269116
269115
|
console.warn("PDF page numbering should be set during creation");
|
|
@@ -19,7 +19,7 @@ export declare class CompressionTransformer {
|
|
|
19
19
|
* Combines multiple files into one
|
|
20
20
|
*/
|
|
21
21
|
export declare class MergeTransformer {
|
|
22
|
-
static merge(files: Buffer[], format: string,
|
|
22
|
+
static merge(files: Buffer[], format: string, _config?: MergeConfig): Promise<Buffer>;
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* Split Transformer
|
|
@@ -49,13 +49,13 @@ export declare class RotationTransformer {
|
|
|
49
49
|
* Password protects files
|
|
50
50
|
*/
|
|
51
51
|
export declare class EncryptionTransformer {
|
|
52
|
-
static encrypt(data: Buffer, format: string,
|
|
52
|
+
static encrypt(data: Buffer, format: string, _config: EncryptionConfig): Promise<Buffer>;
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
55
|
* Page Number Transformer
|
|
56
56
|
* Adds page numbers to documents
|
|
57
57
|
*/
|
|
58
58
|
export declare class PageNumberTransformer {
|
|
59
|
-
static addPageNumbers(data: Buffer, format: string,
|
|
59
|
+
static addPageNumbers(data: Buffer, format: string, _config: any): Promise<Buffer>;
|
|
60
60
|
}
|
|
61
61
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transformers/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,YAAY,EACb,MAAM,eAAe,CAAC;AAQvB;;;GAGG;AACH,qBAAa,sBAAsB;WACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;IAgC/F;;OAEG;IACH,MAAM,CAAC,mBAAmB,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,CAAC,OAAO,CAAC,GAAG,MAAM;CAS5F;AAED;;;GAGG;AACH,qBAAa,gBAAgB;WACd,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transformers/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,YAAY,EACb,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AAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;CAezF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "convertit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"description": "Convert it! The ultimate file conversion toolkit. Create PDFs, Word docs, Excel spreadsheets, and more with a simple, chainable API.",
|
|
5
6
|
"main": "dist/index.js",
|
|
6
7
|
"module": "dist/index.mjs",
|