pdfmake 0.1.53 → 0.1.57
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/README.md +1 -5
- package/build/pdfmake.js +5768 -5582
- package/build/pdfmake.js.map +1 -1
- package/build/pdfmake.min.js +15 -7
- package/build/pdfmake.min.js.map +1 -1
- package/package.json +15 -11
- package/src/browser-extensions/pdfMake.js +23 -2
- package/src/browser-extensions/virtual-fs.js +5 -1
- package/src/docMeasure.js +4 -2
- package/src/docPreprocessor.js +7 -1
- package/src/documentContext.js +9 -0
- package/src/elementWriter.js +3 -0
- package/src/helpers.js +20 -1
- package/src/imageMeasure.js +4 -4
- package/src/layoutBuilder.js +12 -1
- package/src/printer.js +28 -10
- package/src/tableProcessor.js +115 -23
- package/src/textTools.js +2 -0
- package/webpack.config.js +45 -60
package/webpack.config.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
var path = require('path');
|
|
2
|
+
var UglifyJsPlugin = require('uglifyjs-webpack-plugin');
|
|
2
3
|
var StringReplacePlugin = require("string-replace-webpack-plugin");
|
|
3
4
|
var webpack = require('webpack');
|
|
4
5
|
var pkg = require('./package.json');
|
|
@@ -6,6 +7,7 @@ var pkg = require('./package.json');
|
|
|
6
7
|
var banner = '/*! ' + pkg.name + ' v' + pkg.version + ', @license ' + pkg.license + ', @link ' + pkg.homepage + ' */';
|
|
7
8
|
|
|
8
9
|
module.exports = {
|
|
10
|
+
mode: 'production',
|
|
9
11
|
entry: {
|
|
10
12
|
'pdfmake': './src/browser-extensions/pdfMake.js',
|
|
11
13
|
'pdfmake.min': './src/browser-extensions/pdfMake.js'
|
|
@@ -13,7 +15,9 @@ module.exports = {
|
|
|
13
15
|
output: {
|
|
14
16
|
path: path.join(__dirname, './build'),
|
|
15
17
|
filename: '[name].js',
|
|
16
|
-
libraryTarget: 'umd'
|
|
18
|
+
libraryTarget: 'umd',
|
|
19
|
+
// Workaround https://github.com/webpack/webpack/issues/6642 until https://github.com/webpack/webpack/issues/6525 lands.
|
|
20
|
+
globalObject: `typeof self !== 'undefined' ? self : this`
|
|
17
21
|
},
|
|
18
22
|
resolve: {
|
|
19
23
|
alias: {
|
|
@@ -26,8 +30,21 @@ module.exports = {
|
|
|
26
30
|
},
|
|
27
31
|
module: {
|
|
28
32
|
rules: [
|
|
33
|
+
// for fs don't use babel _interopDefault command
|
|
29
34
|
{
|
|
30
35
|
enforce: 'pre',
|
|
36
|
+
test: /pdfkit[/\\]js[/\\]/,
|
|
37
|
+
loader: StringReplacePlugin.replace({
|
|
38
|
+
replacements: [
|
|
39
|
+
{
|
|
40
|
+
pattern: "import fs from 'fs';",
|
|
41
|
+
replacement: function () {
|
|
42
|
+
return "var fs = require('fs');";
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
]})
|
|
46
|
+
},
|
|
47
|
+
{
|
|
31
48
|
test: /\.js$/,
|
|
32
49
|
include: /(pdfkit|saslprep)/,
|
|
33
50
|
use: {
|
|
@@ -45,91 +62,59 @@ module.exports = {
|
|
|
45
62
|
loose: true
|
|
46
63
|
}
|
|
47
64
|
]
|
|
48
|
-
]
|
|
65
|
+
],
|
|
66
|
+
plugins: ["@babel/plugin-transform-modules-commonjs"]
|
|
49
67
|
}
|
|
50
68
|
}
|
|
51
69
|
},
|
|
52
|
-
// Workaround for @babel/preset-env bug in useBuiltIns: 'usage' (always use import instead of require)
|
|
53
|
-
{
|
|
54
|
-
test: /\.js$/,
|
|
55
|
-
include: /saslprep/,
|
|
56
|
-
loader: StringReplacePlugin.replace({
|
|
57
|
-
replacements: [
|
|
58
|
-
{
|
|
59
|
-
pattern: /import "([\S]*)";/g,
|
|
60
|
-
replacement: function (match, p1) {
|
|
61
|
-
return 'require("' + p1 + '");';
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
]})
|
|
65
|
-
},
|
|
66
70
|
{test: /pdfMake.js$/, loader: 'expose-loader?pdfMake', include: [path.join(__dirname, './src/browser-extensions')]},
|
|
67
|
-
{test: /
|
|
71
|
+
{test: /fontkit[/\\]index.js$/, loader: StringReplacePlugin.replace({
|
|
68
72
|
replacements: [
|
|
69
73
|
{
|
|
70
|
-
pattern:
|
|
74
|
+
pattern: /fs\./g,
|
|
71
75
|
replacement: function () {
|
|
72
|
-
return '';
|
|
76
|
+
return 'require(\'fs\').';
|
|
73
77
|
}
|
|
74
78
|
}
|
|
75
79
|
]})
|
|
76
80
|
},
|
|
77
|
-
|
|
81
|
+
|
|
82
|
+
/* temporary bugfix for FileSaver: added hack for mobile device support, see https://github.com/bpampuch/pdfmake/issues/1664 */
|
|
83
|
+
/* waiting to merge and release PR https://github.com/eligrey/FileSaver.js/pull/533 */
|
|
84
|
+
{test: /FileSaver.min.js$/, loader: StringReplacePlugin.replace({
|
|
78
85
|
replacements: [
|
|
79
86
|
{
|
|
80
|
-
pattern:
|
|
87
|
+
pattern: '"download"in HTMLAnchorElement.prototype',
|
|
81
88
|
replacement: function () {
|
|
82
|
-
return '
|
|
89
|
+
return '(typeof HTMLAnchorElement !== "undefined" && "download" in HTMLAnchorElement.prototype)';
|
|
83
90
|
}
|
|
84
91
|
}
|
|
85
92
|
]})
|
|
86
93
|
},
|
|
87
94
|
|
|
88
|
-
/* temporary bugfix for pdfkit version 0.9.0 - issue https://github.com/foliojs/pdfkit/issues/923 */
|
|
89
|
-
/* waiting to release included PR https://github.com/foliojs/pdfkit/pull/925 */
|
|
90
|
-
{test: /pdfkit[/\\]js[/\\]/, loader: StringReplacePlugin.replace({
|
|
91
|
-
replacements: [
|
|
92
|
-
{
|
|
93
|
-
pattern: "stringBuffer = swapBytes(new Buffer(",
|
|
94
|
-
replacement: function () {
|
|
95
|
-
return "stringBuffer = swapBytes(Buffer.from(";
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
]})
|
|
99
|
-
},
|
|
100
|
-
{test: /pdfkit[/\\]js[/\\]/, loader: StringReplacePlugin.replace({
|
|
101
|
-
replacements: [
|
|
102
|
-
{
|
|
103
|
-
pattern: "stringBuffer = new Buffer(string, 'ascii');",
|
|
104
|
-
replacement: function () {
|
|
105
|
-
return "stringBuffer = Buffer.from(string.valueOf(), 'ascii');";
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
]})
|
|
109
|
-
},
|
|
110
|
-
/* *** */
|
|
111
|
-
|
|
112
95
|
{enforce: 'post', test: /fontkit[/\\]index.js$/, loader: "transform-loader?brfs"},
|
|
113
96
|
{enforce: 'post', test: /unicode-properties[/\\]index.js$/, loader: "transform-loader?brfs"},
|
|
114
97
|
{enforce: 'post', test: /linebreak[/\\]src[/\\]linebreaker.js/, loader: "transform-loader?brfs"}
|
|
115
98
|
]
|
|
116
99
|
},
|
|
100
|
+
optimization: {
|
|
101
|
+
minimizer: [
|
|
102
|
+
new UglifyJsPlugin({
|
|
103
|
+
include: /\.min\.js$/,
|
|
104
|
+
sourceMap: true,
|
|
105
|
+
uglifyOptions: {
|
|
106
|
+
compress: {
|
|
107
|
+
drop_console: true
|
|
108
|
+
},
|
|
109
|
+
mangle: {
|
|
110
|
+
reserved: ['HeadTable', 'NameTable', 'CmapTable', 'HheaTable', 'MaxpTable', 'HmtxTable', 'PostTable', 'OS2Table', 'LocaTable', 'GlyfTable']
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
})
|
|
114
|
+
]
|
|
115
|
+
},
|
|
117
116
|
plugins: [
|
|
118
117
|
new StringReplacePlugin(),
|
|
119
|
-
|
|
120
|
-
new webpack.optimize.UglifyJsPlugin({
|
|
121
|
-
include: /\.min\.js$/,
|
|
122
|
-
sourceMap: true,
|
|
123
|
-
uglifyOptions: {
|
|
124
|
-
compress: {
|
|
125
|
-
drop_console: true
|
|
126
|
-
},
|
|
127
|
-
mangle: {
|
|
128
|
-
reserved: ['HeadTable', 'NameTable', 'CmapTable', 'HheaTable', 'MaxpTable', 'HmtxTable', 'PostTable', 'OS2Table', 'LocaTable', 'GlyfTable']
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}),
|
|
132
|
-
|
|
133
118
|
new webpack.BannerPlugin({
|
|
134
119
|
banner: banner,
|
|
135
120
|
raw: true
|