pdfkit 0.17.2 → 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/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
- module.exports = virtualFs;
49
+ export { virtualFs as default };
package/jsconfig.json CHANGED
@@ -1,13 +1,13 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "module": "CommonJS",
5
- "allowJs": true,
6
- // Don't force external @types; our ambient file is included below
7
- "baseUrl": "."
8
- },
9
- "include": [
10
- "tests/**/*.js",
11
- "types/**/*.d.ts"
12
- ]
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "CommonJS",
5
+ "allowJs": true,
6
+ // Don't force external @types; our ambient file is included below
7
+ "baseUrl": "."
8
+ },
9
+ "include": [
10
+ "tests/**/*.js",
11
+ "types/**/*.d.ts"
12
+ ]
13
13
  }
package/package.json CHANGED
@@ -1,93 +1,84 @@
1
- {
2
- "name": "pdfkit",
3
- "description": "A PDF generation library for Node.js",
4
- "keywords": [
5
- "pdf",
6
- "pdf writer",
7
- "pdf generator",
8
- "graphics",
9
- "document",
10
- "vector"
11
- ],
12
- "version": "0.17.2",
13
- "homepage": "http://pdfkit.org/",
14
- "author": {
15
- "name": "Devon Govett",
16
- "email": "devongovett@gmail.com",
17
- "url": "http://badassjs.com/"
18
- },
19
- "license": "MIT",
20
- "repository": {
21
- "type": "git",
22
- "url": "https://github.com/foliojs/pdfkit.git"
23
- },
24
- "bugs": "https://github.com/foliojs/pdfkit/issues",
25
- "devDependencies": {
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
- "brace": "^0.11.1",
34
- "brfs": "~2.0.2",
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-environment-jsdom": "^29.7.0",
43
- "jest-image-snapshot": "^6.4.0",
44
- "markdown": "~0.5.0",
45
- "pdfjs-dist": "^2.14.305",
46
- "prettier": "3.4.2",
47
- "pug": "^3.0.3",
48
- "rollup": "^2.79.2",
49
- "rollup-plugin-copy": "^3.5.0"
50
- },
51
- "dependencies": {
52
- "crypto-js": "^4.2.0",
53
- "fontkit": "^2.0.4",
54
- "jpeg-exif": "^1.1.4",
55
- "linebreak": "^1.1.0",
56
- "png-js": "^1.0.0"
57
- },
58
- "scripts": {
59
- "prepublishOnly": "npm run build",
60
- "build": "rollup -c && npm run build-standalone",
61
- "build-standalone": "browserify --standalone PDFDocument --ignore crypto js/pdfkit.js > js/pdfkit.standalone.js",
62
- "browserify-example": "browserify examples/browserify/browser.js > examples/browserify/bundle.js",
63
- "pdf-guide": "node docs/generate.js",
64
- "website": "node docs/generate_website.js",
65
- "publish-website": "node docs/publish_website.js",
66
- "docs": "npm run pdf-guide && npm run website && npm run browserify-example",
67
- "lint": "eslint {lib,tests}/**/*.js",
68
- "prettier": "prettier lib tests docs",
69
- "test": "jest -i --env=node",
70
- "test:visual": "jest visual/ -i --env=node",
71
- "test:unit": "jest unit/ --env=node"
72
- },
73
- "main": "js/pdfkit.js",
74
- "module": "js/pdfkit.es.js",
75
- "browserify": {
76
- "transform": [
77
- "brfs"
78
- ]
79
- },
80
- "engine": [
81
- "node >= v18.0.0"
82
- ],
83
- "jest": {
84
- "testEnvironment": "jest-environment-jsdom",
85
- "testPathIgnorePatterns": [
86
- "/node_modules/",
87
- "<rootDir>/examples/"
88
- ],
89
- "setupFilesAfterEnv": [
90
- "<rootDir>/tests/unit/setupTests.js"
91
- ]
92
- }
1
+ {
2
+ "name": "pdfkit",
3
+ "description": "A PDF generation library for Node.js",
4
+ "keywords": [
5
+ "pdf",
6
+ "pdf writer",
7
+ "pdf generator",
8
+ "graphics",
9
+ "document",
10
+ "vector"
11
+ ],
12
+ "version": "0.19.0",
13
+ "homepage": "http://pdfkit.org/",
14
+ "author": {
15
+ "name": "Devon Govett",
16
+ "email": "devongovett@gmail.com",
17
+ "url": "http://badassjs.com/"
18
+ },
19
+ "license": "MIT",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/foliojs/pdfkit.git"
23
+ },
24
+ "bugs": "https://github.com/foliojs/pdfkit/issues",
25
+ "devDependencies": {
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",
31
+ "blob-stream": "^0.1.3",
32
+ "brace": "^0.11.1",
33
+ "brfs": "~2.0.2",
34
+ "browserify": "^17.0.1",
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",
42
+ "markdown": "~0.5.0",
43
+ "pdfjs-dist": "^5.7.284",
44
+ "prettier": "3.4.2",
45
+ "pug": "^3.0.4",
46
+ "rollup": "^4.61.1",
47
+ "rollup-plugin-copy": "^3.5.0",
48
+ "vitest": "^4.1.8"
49
+ },
50
+ "dependencies": {
51
+ "@noble/ciphers": "^1.0.0",
52
+ "@noble/hashes": "^1.6.0",
53
+ "fontkit": "^2.0.4",
54
+ "js-md5": "^0.8.3",
55
+ "linebreak": "^1.1.0",
56
+ "png-js": "^1.1.0"
57
+ },
58
+ "scripts": {
59
+ "prepublishOnly": "npm run build",
60
+ "build": "rollup -c && npm run build-standalone",
61
+ "build-standalone": "browserify --standalone PDFDocument --ignore crypto js/pdfkit.js > js/pdfkit.standalone.js",
62
+ "browserify-example": "browserify examples/browserify/browser.js > examples/browserify/bundle.js",
63
+ "pdf-guide": "node docs/generate.js",
64
+ "website": "node docs/generate_website.js",
65
+ "publish-website": "node docs/publish_website.js",
66
+ "docs": "npm run pdf-guide && npm run website && npm run browserify-example",
67
+ "lint": "eslint {lib,tests}/**/*.js",
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
+ },
73
+ "main": "js/pdfkit.js",
74
+ "module": "js/pdfkit.es.js",
75
+ "browserify": {
76
+ "transform": [
77
+ "brfs"
78
+ ]
79
+ },
80
+ "engine": [
81
+ "node >= v20.0.0"
82
+ ],
83
+ "packageManager": "yarn@4.10.3"
93
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,28 +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 {};
1
+ // Ambient typings to make custom Vitest 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
+
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;
22
+
23
+ // Expect the PDF data array to contain a text stream matching the TextStream
24
+ toContainText(textStream: TextStreamMatcher): R;
25
+ }
26
+ }
27
+
28
+ export {};
@@ -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
+ });