@kittl/pdfkit 0.13.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.
@@ -0,0 +1,68 @@
1
+ 'use strict';
2
+
3
+ var VirtualFileSystem = /*#__PURE__*/function () {
4
+ function VirtualFileSystem() {
5
+ this.fileData = {};
6
+ }
7
+
8
+ var _proto = VirtualFileSystem.prototype;
9
+
10
+ _proto.readFileSync = function readFileSync(fileName, options) {
11
+ if (options === void 0) {
12
+ options = {};
13
+ }
14
+
15
+ var encoding = typeof options === 'string' ? options : options.encoding;
16
+ var virtualFileName = normalizeFilename(fileName);
17
+ var data = this.fileData[virtualFileName];
18
+
19
+ if (data == null) {
20
+ throw new Error("File '" + virtualFileName + "' not found in virtual file system");
21
+ }
22
+
23
+ if (encoding) {
24
+ // return a string
25
+ return typeof data === 'string' ? data : data.toString(encoding);
26
+ }
27
+
28
+ return Buffer.from(data, typeof data === 'string' ? 'base64' : undefined);
29
+ };
30
+
31
+ _proto.writeFileSync = function writeFileSync(fileName, content) {
32
+ this.fileData[normalizeFilename(fileName)] = content;
33
+ };
34
+
35
+ _proto.bindFileData = function bindFileData(data, options) {
36
+ if (data === void 0) {
37
+ data = {};
38
+ }
39
+
40
+ if (options === void 0) {
41
+ options = {};
42
+ }
43
+
44
+ if (options.reset) {
45
+ this.fileData = data;
46
+ } else {
47
+ Object.assign(this.fileData, data);
48
+ }
49
+ };
50
+
51
+ return VirtualFileSystem;
52
+ }();
53
+
54
+ function normalizeFilename(fileName) {
55
+ if (fileName.indexOf(__dirname) === 0) {
56
+ fileName = fileName.substring(__dirname.length);
57
+ }
58
+
59
+ if (fileName.indexOf('/') === 0) {
60
+ fileName = fileName.substring(1);
61
+ }
62
+
63
+ return fileName;
64
+ }
65
+
66
+ var virtualFs = new VirtualFileSystem();
67
+
68
+ module.exports = virtualFs;
package/package.json ADDED
@@ -0,0 +1,95 @@
1
+ {
2
+ "name": "@kittl/pdfkit",
3
+ "private": false,
4
+ "public": true,
5
+ "description": "A PDF generation library for Node.js",
6
+ "keywords": [
7
+ "pdf",
8
+ "pdf writer",
9
+ "pdf generator",
10
+ "graphics",
11
+ "document",
12
+ "vector"
13
+ ],
14
+ "version": "0.13.0",
15
+ "homepage": "http://pdfkit.org/",
16
+ "author": {
17
+ "name": "Devon Govett",
18
+ "email": "devongovett@gmail.com",
19
+ "url": "http://badassjs.com/"
20
+ },
21
+ "license": "MIT",
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "https://github.com/foliojs/pdfkit.git"
25
+ },
26
+ "bugs": "https://github.com/foliojs/pdfkit/issues",
27
+ "devDependencies": {
28
+ "@babel/core": "^7.11.6",
29
+ "@babel/plugin-external-helpers": "^7.10.4",
30
+ "@babel/preset-env": "^7.11.5",
31
+ "babel-jest": "^26.3.0",
32
+ "blob-stream": "^0.1.2",
33
+ "brace": "^0.11.1",
34
+ "brfs": "~2.0.2",
35
+ "browserify": "^16.5.0",
36
+ "canvas": "^2.9.1",
37
+ "codemirror": "~5.49.2",
38
+ "eslint": "^7.8.1",
39
+ "gh-pages": "^3.1.0",
40
+ "jest": "^28.1.1",
41
+ "jest-screenshot": "^0.3.5",
42
+ "markdown": "~0.5.0",
43
+ "pdfjs-dist": "^2.14.305",
44
+ "prettier": "1.19.1",
45
+ "pug": "^2.0.4",
46
+ "rollup": "^1.27.0",
47
+ "rollup-plugin-babel": "^4.3.3",
48
+ "rollup-plugin-cpy": "^2.0.1"
49
+ },
50
+ "dependencies": {
51
+ "crypto-js": "^4.0.0",
52
+ "fontkit": "^2.0.2",
53
+ "linebreak": "^1.1.0",
54
+ "png-js": "^1.0.0"
55
+ },
56
+ "scripts": {
57
+ "prepublishOnly": "npm run build",
58
+ "build": "rollup -c && browserify --standalone PDFDocument --ignore crypto js/pdfkit.js > js/pdfkit.standalone.js",
59
+ "browserify-example": "browserify examples/browserify/browser.js > examples/browserify/bundle.js",
60
+ "pdf-guide": "node docs/generate.js",
61
+ "website": "node docs/generate_website.js",
62
+ "publish-website": "node docs/publish_website.js",
63
+ "docs": "npm run pdf-guide && npm run website && npm run browserify-example",
64
+ "lint": "eslint {lib,tests}/**/*.js",
65
+ "prettier": "prettier {lib,tests,examples,docs}/**/*.js",
66
+ "test": "jest -i",
67
+ "test:visual": "jest visual/ -i",
68
+ "test:unit": "jest unit/"
69
+ },
70
+ "main": "js/pdfkit.js",
71
+ "module": "js/pdfkit.es5.js",
72
+ "esnext": "js/pdfkit.esnext.js",
73
+ "browserify": {
74
+ "transform": [
75
+ "brfs"
76
+ ]
77
+ },
78
+ "engine": [
79
+ "node >= v6.0.0"
80
+ ],
81
+ "jest": {
82
+ "testPathIgnorePatterns": [
83
+ "/node_modules/",
84
+ "<rootDir>/examples/"
85
+ ],
86
+ "testURL": "http://localhost/",
87
+ "setupFilesAfterEnv": [
88
+ "<rootDir>/tests/unit/setupTests.js"
89
+ ],
90
+ "reporters": [
91
+ "default",
92
+ "jest-screenshot/reporter"
93
+ ]
94
+ }
95
+ }