Skip to content

Commit 24c34c2

Browse files
Modernize export
1 parent 55a3403 commit 24c34c2

File tree

1 file changed

+6
-33
lines changed

1 file changed

+6
-33
lines changed

src/main.ts

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
import _applyPlugin from './applyPlugin'
44
import { UserOptions } from './config'
55
import { jsPDFConstructor, jsPDFDocument } from './documentHandler'
6+
import { CellHookData } from './HookData'
67
import { parseInput } from './inputParser'
7-
import { drawTable as _drawTable } from './tableDrawer'
8+
import { Cell, Column, Row, Table } from './models'
89
import { createTable as _createTable } from './tableCalculator'
9-
import { Table } from './models'
10-
import { CellHookData } from './HookData'
11-
import { Cell, Column, Row } from './models'
10+
import { drawTable as _drawTable } from './tableDrawer'
1211

1312
export type autoTable = (options: UserOptions) => void
1413

@@ -18,38 +17,12 @@ export function applyPlugin(jsPDF: jsPDFConstructor) {
1817
_applyPlugin(jsPDF)
1918
}
2019

21-
function autoTable(d: jsPDFDocument, options: UserOptions) {
20+
export function autoTable(d: jsPDFDocument, options: UserOptions) {
2221
const input = parseInput(d, options)
2322
const table = _createTable(d, input)
2423
_drawTable(d, table)
2524
}
2625

27-
// Experimental export
28-
export function __createTable(d: jsPDFDocument, options: UserOptions): Table {
29-
const input = parseInput(d, options)
30-
return _createTable(d, input)
31-
}
32-
33-
export function __drawTable(d: jsPDFDocument, table: Table) {
34-
_drawTable(d, table)
35-
}
36-
37-
try {
38-
// eslint-disable-next-line @typescript-eslint/no-var-requires
39-
let jsPDF = require('jspdf')
40-
// Webpack imported jspdf instead of jsPDF for some reason
41-
// while it seemed to work everywhere else.
42-
if (jsPDF.jsPDF) jsPDF = jsPDF.jsPDF
43-
applyPlugin(jsPDF)
44-
} catch (error) {
45-
// Importing jspdf in nodejs environments does not work as of jspdf
46-
// 1.5.3 so we need to silence potential errors to support using for example
47-
// the nodejs jspdf dist files with the exported applyPlugin
48-
}
49-
5026
export default autoTable
51-
export { CellHookData }
52-
export { Table }
53-
export { Row }
54-
export { Column }
55-
export { Cell }
27+
28+
export { Cell, CellHookData, Column, Row, Table }

0 commit comments

Comments
 (0)