pdfkit 0.18.0 → 0.19.0
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/.yarn/install-state.gz +0 -0
- package/CHANGELOG.md +15 -2
- package/js/pdfkit.es.js +270 -263
- package/js/pdfkit.es.js.map +1 -1
- package/js/pdfkit.js +194 -99
- package/js/pdfkit.js.map +1 -1
- package/js/pdfkit.standalone.js +351 -294
- package/js/virtual-fs.js +1 -3
- package/package.json +24 -34
- package/rollup.config.mjs +124 -0
- package/types/jest.custom-matchers.d.ts +8 -8
- package/vitest.config.js +11 -0
package/js/virtual-fs.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
1
|
class VirtualFileSystem {
|
|
4
2
|
constructor() {
|
|
5
3
|
this.fileData = {};
|
|
@@ -48,4 +46,4 @@ function normalizeFilename(fileName) {
|
|
|
48
46
|
}
|
|
49
47
|
var virtualFs = new VirtualFileSystem();
|
|
50
48
|
|
|
51
|
-
|
|
49
|
+
export { virtualFs as default };
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"document",
|
|
10
10
|
"vector"
|
|
11
11
|
],
|
|
12
|
-
"version": "0.
|
|
12
|
+
"version": "0.19.0",
|
|
13
13
|
"homepage": "http://pdfkit.org/",
|
|
14
14
|
"author": {
|
|
15
15
|
"name": "Devon Govett",
|
|
@@ -23,29 +23,29 @@
|
|
|
23
23
|
},
|
|
24
24
|
"bugs": "https://github.com/foliojs/pdfkit/issues",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@babel/core": "^7.
|
|
27
|
-
"@babel/plugin-external-helpers": "^7.
|
|
28
|
-
"@babel/preset-env": "^7.
|
|
29
|
-
"@eslint/js": "^
|
|
30
|
-
"@rollup/plugin-babel": "^
|
|
31
|
-
"babel-jest": "^29.7.0",
|
|
26
|
+
"@babel/core": "^7.29.7",
|
|
27
|
+
"@babel/plugin-external-helpers": "^7.29.7",
|
|
28
|
+
"@babel/preset-env": "^7.29.7",
|
|
29
|
+
"@eslint/js": "^10.0.1",
|
|
30
|
+
"@rollup/plugin-babel": "^7.1.0",
|
|
32
31
|
"blob-stream": "^0.1.3",
|
|
33
32
|
"brace": "^0.11.1",
|
|
34
33
|
"brfs": "~2.0.2",
|
|
35
34
|
"browserify": "^17.0.1",
|
|
36
|
-
"canvas": "^3.2.
|
|
37
|
-
"codemirror": "~5.65.
|
|
38
|
-
"eslint": "^
|
|
39
|
-
"gh-pages": "^6.
|
|
40
|
-
"globals": "^
|
|
41
|
-
"jest": "^
|
|
42
|
-
"jest-image-snapshot": "^6.
|
|
35
|
+
"canvas": "^3.2.3",
|
|
36
|
+
"codemirror": "~5.65.21",
|
|
37
|
+
"eslint": "^10.4.1",
|
|
38
|
+
"gh-pages": "^6.3.0",
|
|
39
|
+
"globals": "^17.6.0",
|
|
40
|
+
"jest-diff": "^30.4.1",
|
|
41
|
+
"jest-image-snapshot": "^6.5.2",
|
|
43
42
|
"markdown": "~0.5.0",
|
|
44
|
-
"pdfjs-dist": "^
|
|
43
|
+
"pdfjs-dist": "^5.7.284",
|
|
45
44
|
"prettier": "3.4.2",
|
|
46
|
-
"pug": "^3.0.
|
|
47
|
-
"rollup": "^
|
|
48
|
-
"rollup-plugin-copy": "^3.5.0"
|
|
45
|
+
"pug": "^3.0.4",
|
|
46
|
+
"rollup": "^4.61.1",
|
|
47
|
+
"rollup-plugin-copy": "^3.5.0",
|
|
48
|
+
"vitest": "^4.1.8"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@noble/ciphers": "^1.0.0",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"fontkit": "^2.0.4",
|
|
54
54
|
"js-md5": "^0.8.3",
|
|
55
55
|
"linebreak": "^1.1.0",
|
|
56
|
-
"png-js": "^1.
|
|
56
|
+
"png-js": "^1.1.0"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"prepublishOnly": "npm run build",
|
|
@@ -65,10 +65,10 @@
|
|
|
65
65
|
"publish-website": "node docs/publish_website.js",
|
|
66
66
|
"docs": "npm run pdf-guide && npm run website && npm run browserify-example",
|
|
67
67
|
"lint": "eslint {lib,tests}/**/*.js",
|
|
68
|
-
"prettier": "prettier lib tests docs",
|
|
69
|
-
"test": "
|
|
70
|
-
"test:visual": "
|
|
71
|
-
"test:unit": "
|
|
68
|
+
"prettier": "prettier --check lib tests docs",
|
|
69
|
+
"test": "vitest --testTimeout 8000 run",
|
|
70
|
+
"test:visual": "vitest --testTimeout 8000 run tests/visual",
|
|
71
|
+
"test:unit": "vitest run tests/unit"
|
|
72
72
|
},
|
|
73
73
|
"main": "js/pdfkit.js",
|
|
74
74
|
"module": "js/pdfkit.es.js",
|
|
@@ -78,17 +78,7 @@
|
|
|
78
78
|
]
|
|
79
79
|
},
|
|
80
80
|
"engine": [
|
|
81
|
-
"node >=
|
|
81
|
+
"node >= v20.0.0"
|
|
82
82
|
],
|
|
83
|
-
"jest": {
|
|
84
|
-
"testEnvironment": "node",
|
|
85
|
-
"testPathIgnorePatterns": [
|
|
86
|
-
"/node_modules/",
|
|
87
|
-
"<rootDir>/examples/"
|
|
88
|
-
],
|
|
89
|
-
"setupFilesAfterEnv": [
|
|
90
|
-
"<rootDir>/tests/unit/setupTests.js"
|
|
91
|
-
]
|
|
92
|
-
},
|
|
93
83
|
"packageManager": "yarn@4.10.3"
|
|
94
84
|
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import pkg from './package.json' with { type: 'json' };
|
|
2
|
+
import { babel } from '@rollup/plugin-babel';
|
|
3
|
+
import copy from 'rollup-plugin-copy';
|
|
4
|
+
|
|
5
|
+
const external = [
|
|
6
|
+
'stream',
|
|
7
|
+
'fs',
|
|
8
|
+
'zlib',
|
|
9
|
+
'fontkit',
|
|
10
|
+
'events',
|
|
11
|
+
'linebreak',
|
|
12
|
+
'png-js',
|
|
13
|
+
'js-md5',
|
|
14
|
+
'@noble/hashes/utils',
|
|
15
|
+
'@noble/hashes/sha256',
|
|
16
|
+
'@noble/ciphers/aes',
|
|
17
|
+
'crypto',
|
|
18
|
+
'saslprep',
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
const supportedBrowsers = [
|
|
22
|
+
'Firefox 115', // ESR from 2023
|
|
23
|
+
'iOS 16', // from 2022
|
|
24
|
+
'Safari 16', // from 2022
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
export default [
|
|
28
|
+
// CommonJS build for Node
|
|
29
|
+
{
|
|
30
|
+
input: 'lib/document.js',
|
|
31
|
+
external,
|
|
32
|
+
output: {
|
|
33
|
+
name: 'pdfkit',
|
|
34
|
+
file: pkg.main,
|
|
35
|
+
format: 'cjs',
|
|
36
|
+
sourcemap: true,
|
|
37
|
+
interop: 'default',
|
|
38
|
+
},
|
|
39
|
+
plugins: [
|
|
40
|
+
babel({
|
|
41
|
+
babelHelpers: 'bundled',
|
|
42
|
+
babelrc: false,
|
|
43
|
+
presets: [
|
|
44
|
+
[
|
|
45
|
+
'@babel/preset-env',
|
|
46
|
+
{
|
|
47
|
+
modules: false,
|
|
48
|
+
targets: {
|
|
49
|
+
node: '20',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
],
|
|
54
|
+
comments: false,
|
|
55
|
+
}),
|
|
56
|
+
copy({
|
|
57
|
+
targets: [
|
|
58
|
+
{
|
|
59
|
+
src: ['lib/font/data/*.afm', 'lib/mixins/data/*.icc'],
|
|
60
|
+
dest: 'js/data',
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
}),
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
|
+
// ES for green browsers
|
|
67
|
+
{
|
|
68
|
+
input: 'lib/document.js',
|
|
69
|
+
external,
|
|
70
|
+
output: {
|
|
71
|
+
name: 'pdfkit.es',
|
|
72
|
+
file: pkg.module,
|
|
73
|
+
format: 'es',
|
|
74
|
+
sourcemap: true,
|
|
75
|
+
},
|
|
76
|
+
plugins: [
|
|
77
|
+
babel({
|
|
78
|
+
babelHelpers: 'bundled',
|
|
79
|
+
babelrc: false,
|
|
80
|
+
presets: [
|
|
81
|
+
[
|
|
82
|
+
'@babel/preset-env',
|
|
83
|
+
{
|
|
84
|
+
modules: false,
|
|
85
|
+
bugfixes: true,
|
|
86
|
+
targets: {
|
|
87
|
+
browsers: supportedBrowsers,
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
],
|
|
92
|
+
comments: false,
|
|
93
|
+
}),
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
input: 'lib/virtual-fs.js',
|
|
98
|
+
external,
|
|
99
|
+
output: {
|
|
100
|
+
name: 'virtual-fs',
|
|
101
|
+
file: 'js/virtual-fs.js',
|
|
102
|
+
format: 'es',
|
|
103
|
+
sourcemap: false,
|
|
104
|
+
},
|
|
105
|
+
plugins: [
|
|
106
|
+
babel({
|
|
107
|
+
babelHelpers: 'bundled',
|
|
108
|
+
babelrc: false,
|
|
109
|
+
presets: [
|
|
110
|
+
[
|
|
111
|
+
'@babel/preset-env',
|
|
112
|
+
{
|
|
113
|
+
loose: true,
|
|
114
|
+
modules: false,
|
|
115
|
+
targets: {
|
|
116
|
+
browsers: supportedBrowsers,
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
],
|
|
120
|
+
],
|
|
121
|
+
}),
|
|
122
|
+
],
|
|
123
|
+
},
|
|
124
|
+
];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Ambient typings to make custom
|
|
1
|
+
// Ambient typings to make custom Vitest matchers available to the TS language server in tests.
|
|
2
2
|
// No external @types packages required.
|
|
3
3
|
|
|
4
4
|
type PartialExceptTheseRequired<T, K extends keyof T> = Partial<T> &
|
|
@@ -13,15 +13,15 @@ declare global {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
type TextStreamMatcher = PartialExceptTheseRequired<TextStream, 'text'>;
|
|
16
|
+
}
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
declare module 'vitest' {
|
|
19
|
+
interface Matchers<R> {
|
|
20
|
+
// Expect the PDF data array to contain a specific chunk sequence
|
|
21
|
+
toContainChunk(chunk: Array<string | RegExp>): R;
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
23
|
+
// Expect the PDF data array to contain a text stream matching the TextStream
|
|
24
|
+
toContainText(textStream: TextStreamMatcher): R;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
package/vitest.config.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { defineConfig } from 'vitest/config';
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
test: {
|
|
5
|
+
globals: true,
|
|
6
|
+
environment: 'node',
|
|
7
|
+
include: ['tests/**/*.spec.js'],
|
|
8
|
+
exclude: ['**/node_modules/**', 'examples/**'],
|
|
9
|
+
setupFiles: ['./tests/unit/setupTests.js'],
|
|
10
|
+
},
|
|
11
|
+
});
|