@kittl/pdfkit 0.13.0 → 0.17.3
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 +65 -0
- package/README.md +3 -3
- package/js/data/sRGB_IEC61966_2_1.icc +0 -0
- package/js/pdfkit.es.js +6086 -0
- package/js/pdfkit.es.js.map +1 -0
- package/js/pdfkit.es5.js +746 -1780
- package/js/pdfkit.es5.js.map +1 -1
- package/js/pdfkit.esnext.js +431 -1464
- package/js/pdfkit.esnext.js.map +1 -1
- package/js/pdfkit.js +1653 -2092
- package/js/pdfkit.js.map +1 -1
- package/js/pdfkit.standalone.js +33633 -29709
- package/js/virtual-fs.js +13 -30
- package/jsconfig.json +13 -0
- package/package.json +32 -35
- package/types/jest.custom-matchers.d.ts +28 -0
package/js/virtual-fs.js
CHANGED
|
@@ -1,68 +1,51 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
class VirtualFileSystem {
|
|
4
|
+
constructor() {
|
|
5
5
|
this.fileData = {};
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
var _proto = VirtualFileSystem.prototype;
|
|
9
|
-
|
|
10
|
-
_proto.readFileSync = function readFileSync(fileName, options) {
|
|
7
|
+
readFileSync(fileName, options) {
|
|
11
8
|
if (options === void 0) {
|
|
12
9
|
options = {};
|
|
13
10
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
var data = this.fileData[virtualFileName];
|
|
18
|
-
|
|
11
|
+
const encoding = typeof options === 'string' ? options : options.encoding;
|
|
12
|
+
const virtualFileName = normalizeFilename(fileName);
|
|
13
|
+
const data = this.fileData[virtualFileName];
|
|
19
14
|
if (data == null) {
|
|
20
|
-
throw new Error(
|
|
15
|
+
throw new Error(`File '${virtualFileName}' not found in virtual file system`);
|
|
21
16
|
}
|
|
22
|
-
|
|
23
17
|
if (encoding) {
|
|
24
18
|
// return a string
|
|
25
19
|
return typeof data === 'string' ? data : data.toString(encoding);
|
|
26
20
|
}
|
|
27
|
-
|
|
28
21
|
return Buffer.from(data, typeof data === 'string' ? 'base64' : undefined);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
_proto.writeFileSync = function writeFileSync(fileName, content) {
|
|
22
|
+
}
|
|
23
|
+
writeFileSync(fileName, content) {
|
|
32
24
|
this.fileData[normalizeFilename(fileName)] = content;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
_proto.bindFileData = function bindFileData(data, options) {
|
|
25
|
+
}
|
|
26
|
+
bindFileData(data, options) {
|
|
36
27
|
if (data === void 0) {
|
|
37
28
|
data = {};
|
|
38
29
|
}
|
|
39
|
-
|
|
40
30
|
if (options === void 0) {
|
|
41
31
|
options = {};
|
|
42
32
|
}
|
|
43
|
-
|
|
44
33
|
if (options.reset) {
|
|
45
34
|
this.fileData = data;
|
|
46
35
|
} else {
|
|
47
36
|
Object.assign(this.fileData, data);
|
|
48
37
|
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return VirtualFileSystem;
|
|
52
|
-
}();
|
|
53
|
-
|
|
38
|
+
}
|
|
39
|
+
}
|
|
54
40
|
function normalizeFilename(fileName) {
|
|
55
41
|
if (fileName.indexOf(__dirname) === 0) {
|
|
56
42
|
fileName = fileName.substring(__dirname.length);
|
|
57
43
|
}
|
|
58
|
-
|
|
59
44
|
if (fileName.indexOf('/') === 0) {
|
|
60
45
|
fileName = fileName.substring(1);
|
|
61
46
|
}
|
|
62
|
-
|
|
63
47
|
return fileName;
|
|
64
48
|
}
|
|
65
|
-
|
|
66
49
|
var virtualFs = new VirtualFileSystem();
|
|
67
50
|
|
|
68
51
|
module.exports = virtualFs;
|
package/jsconfig.json
ADDED
package/package.json
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kittl/pdfkit",
|
|
3
|
-
"private": false,
|
|
4
|
-
"public": true,
|
|
5
3
|
"description": "A PDF generation library for Node.js",
|
|
6
4
|
"keywords": [
|
|
7
5
|
"pdf",
|
|
@@ -11,7 +9,7 @@
|
|
|
11
9
|
"document",
|
|
12
10
|
"vector"
|
|
13
11
|
],
|
|
14
|
-
"version": "0.
|
|
12
|
+
"version": "0.17.3",
|
|
15
13
|
"homepage": "http://pdfkit.org/",
|
|
16
14
|
"author": {
|
|
17
15
|
"name": "Devon Govett",
|
|
@@ -25,71 +23,70 @@
|
|
|
25
23
|
},
|
|
26
24
|
"bugs": "https://github.com/foliojs/pdfkit/issues",
|
|
27
25
|
"devDependencies": {
|
|
28
|
-
"@babel/core": "^7.
|
|
29
|
-
"@babel/plugin-external-helpers": "^7.
|
|
30
|
-
"@babel/preset-env": "^7.
|
|
31
|
-
"
|
|
32
|
-
"
|
|
26
|
+
"@babel/core": "^7.26.0",
|
|
27
|
+
"@babel/plugin-external-helpers": "^7.25.9",
|
|
28
|
+
"@babel/preset-env": "^7.26.0",
|
|
29
|
+
"@eslint/js": "^9.17.0",
|
|
30
|
+
"@rollup/plugin-babel": "^6.0.4",
|
|
31
|
+
"babel-jest": "^29.7.0",
|
|
32
|
+
"blob-stream": "^0.1.3",
|
|
33
33
|
"brace": "^0.11.1",
|
|
34
34
|
"brfs": "~2.0.2",
|
|
35
|
-
"browserify": "^
|
|
36
|
-
"canvas": "^
|
|
37
|
-
"codemirror": "~5.
|
|
38
|
-
"eslint": "^
|
|
39
|
-
"gh-pages": "^
|
|
40
|
-
"
|
|
41
|
-
"jest
|
|
35
|
+
"browserify": "^17.0.1",
|
|
36
|
+
"canvas": "^3.1.0",
|
|
37
|
+
"codemirror": "~5.65.18",
|
|
38
|
+
"eslint": "^9.17.0",
|
|
39
|
+
"gh-pages": "^6.2.0",
|
|
40
|
+
"globals": "^15.14.0",
|
|
41
|
+
"jest": "^29.7.0",
|
|
42
|
+
"jest-image-snapshot": "^6.4.0",
|
|
42
43
|
"markdown": "~0.5.0",
|
|
43
44
|
"pdfjs-dist": "^2.14.305",
|
|
44
|
-
"prettier": "
|
|
45
|
-
"pug": "^
|
|
46
|
-
"rollup": "^
|
|
47
|
-
"rollup-plugin-
|
|
48
|
-
"rollup-plugin-cpy": "^2.0.1"
|
|
45
|
+
"prettier": "3.4.2",
|
|
46
|
+
"pug": "^3.0.3",
|
|
47
|
+
"rollup": "^2.79.2",
|
|
48
|
+
"rollup-plugin-copy": "^3.5.0"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"crypto-js": "^4.
|
|
52
|
-
"fontkit": "^2.0.
|
|
51
|
+
"crypto-js": "^4.2.0",
|
|
52
|
+
"fontkit": "^2.0.4",
|
|
53
|
+
"jpeg-exif": "^1.1.4",
|
|
53
54
|
"linebreak": "^1.1.0",
|
|
54
55
|
"png-js": "^1.0.0"
|
|
55
56
|
},
|
|
56
57
|
"scripts": {
|
|
57
58
|
"prepublishOnly": "npm run build",
|
|
58
|
-
"build": "rollup -c &&
|
|
59
|
+
"build": "rollup -c && npm run build-standalone",
|
|
60
|
+
"build-standalone": "browserify --standalone PDFDocument --ignore crypto js/pdfkit.js > js/pdfkit.standalone.js",
|
|
59
61
|
"browserify-example": "browserify examples/browserify/browser.js > examples/browserify/bundle.js",
|
|
60
62
|
"pdf-guide": "node docs/generate.js",
|
|
61
63
|
"website": "node docs/generate_website.js",
|
|
62
64
|
"publish-website": "node docs/publish_website.js",
|
|
63
65
|
"docs": "npm run pdf-guide && npm run website && npm run browserify-example",
|
|
64
66
|
"lint": "eslint {lib,tests}/**/*.js",
|
|
65
|
-
"prettier": "prettier
|
|
66
|
-
"test": "jest
|
|
67
|
-
"test:visual": "jest visual/
|
|
67
|
+
"prettier": "prettier lib tests docs",
|
|
68
|
+
"test": "jest",
|
|
69
|
+
"test:visual": "jest visual/",
|
|
68
70
|
"test:unit": "jest unit/"
|
|
69
71
|
},
|
|
70
72
|
"main": "js/pdfkit.js",
|
|
71
|
-
"module": "js/pdfkit.
|
|
72
|
-
"esnext": "js/pdfkit.esnext.js",
|
|
73
|
+
"module": "js/pdfkit.es.js",
|
|
73
74
|
"browserify": {
|
|
74
75
|
"transform": [
|
|
75
76
|
"brfs"
|
|
76
77
|
]
|
|
77
78
|
},
|
|
78
79
|
"engine": [
|
|
79
|
-
"node >=
|
|
80
|
+
"node >= v18.0.0"
|
|
80
81
|
],
|
|
81
82
|
"jest": {
|
|
83
|
+
"testEnvironment": "node",
|
|
82
84
|
"testPathIgnorePatterns": [
|
|
83
85
|
"/node_modules/",
|
|
84
86
|
"<rootDir>/examples/"
|
|
85
87
|
],
|
|
86
|
-
"testURL": "http://localhost/",
|
|
87
88
|
"setupFilesAfterEnv": [
|
|
88
89
|
"<rootDir>/tests/unit/setupTests.js"
|
|
89
|
-
],
|
|
90
|
-
"reporters": [
|
|
91
|
-
"default",
|
|
92
|
-
"jest-screenshot/reporter"
|
|
93
90
|
]
|
|
94
91
|
}
|
|
95
|
-
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Ambient typings to make custom Jest matchers available to the TS language server in tests.
|
|
2
|
+
// No external @types packages required.
|
|
3
|
+
|
|
4
|
+
type PartialExceptTheseRequired<T, K extends keyof T> = Partial<T> &
|
|
5
|
+
Pick<Required<T>, K>;
|
|
6
|
+
|
|
7
|
+
declare global {
|
|
8
|
+
// Minimal shape of a TextStream used by tests' helpers
|
|
9
|
+
interface TextStream {
|
|
10
|
+
text: string;
|
|
11
|
+
font: string;
|
|
12
|
+
fontSize: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
type TextStreamMatcher = PartialExceptTheseRequired<TextStream, 'text'>;
|
|
16
|
+
|
|
17
|
+
namespace jest {
|
|
18
|
+
interface Matchers<R> {
|
|
19
|
+
// Expect the PDF data array to contain a specific chunk sequence
|
|
20
|
+
toContainChunk(chunk: Array<string | RegExp>): R;
|
|
21
|
+
|
|
22
|
+
// Expect the PDF data array to contain a text stream matching the TextStream
|
|
23
|
+
toContainText(textStream: TextStreamMatcher): R;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export {};
|