pdfmake 0.3.0-beta.17 → 0.3.0-beta.19

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.
Files changed (40) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +2 -7
  3. package/build/pdfmake.js +33324 -33106
  4. package/build/pdfmake.js.map +1 -1
  5. package/build/pdfmake.min.js +2 -2
  6. package/build/pdfmake.min.js.map +1 -1
  7. package/build/vfs_fonts.js +4 -4
  8. package/fonts/Roboto/Roboto-Italic.ttf +0 -0
  9. package/fonts/Roboto/Roboto-Medium.ttf +0 -0
  10. package/fonts/Roboto/Roboto-MediumItalic.ttf +0 -0
  11. package/fonts/Roboto/Roboto-Regular.ttf +0 -0
  12. package/js/DocMeasure.js +12 -1
  13. package/js/DocPreprocessor.js +21 -6
  14. package/js/DocumentContext.js +5 -4
  15. package/js/LayoutBuilder.js +137 -34
  16. package/js/OutputDocument.js +22 -34
  17. package/js/OutputDocumentServer.js +6 -11
  18. package/js/PageElementWriter.js +2 -2
  19. package/js/Printer.js +132 -145
  20. package/js/StyleContextStack.js +4 -0
  21. package/js/TextBreaker.js +30 -3
  22. package/js/URLResolver.js +23 -62
  23. package/js/browser-extensions/OutputDocumentBrowser.js +35 -72
  24. package/js/browser-extensions/index.js +2 -2
  25. package/package.json +18 -18
  26. package/src/DocMeasure.js +15 -1
  27. package/src/DocPreprocessor.js +25 -6
  28. package/src/DocumentContext.js +4 -4
  29. package/src/LayoutBuilder.js +169 -39
  30. package/src/OutputDocument.js +23 -37
  31. package/src/OutputDocumentServer.js +6 -11
  32. package/src/PageElementWriter.js +2 -2
  33. package/src/Printer.js +131 -143
  34. package/src/StyleContextStack.js +4 -0
  35. package/src/TextBreaker.js +23 -4
  36. package/src/URLResolver.js +23 -68
  37. package/src/browser-extensions/OutputDocumentBrowser.js +33 -71
  38. package/src/browser-extensions/index.js +2 -2
  39. package/js/browser-extensions/URLBrowserResolver.js +0 -81
  40. package/src/browser-extensions/URLBrowserResolver.js +0 -89
@@ -1,81 +0,0 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- exports.default = void 0;
5
- const fetchUrl = (url, headers = {}) => {
6
- return new Promise((resolve, reject) => {
7
- const xhr = new XMLHttpRequest();
8
- xhr.open('GET', url, true);
9
- for (let headerName in headers) {
10
- xhr.setRequestHeader(headerName, headers[headerName]);
11
- }
12
- xhr.responseType = 'arraybuffer';
13
- xhr.onreadystatechange = () => {
14
- if (xhr.readyState !== 4) {
15
- return;
16
- }
17
- const ok = xhr.status >= 200 && xhr.status < 300;
18
- if (!ok) {
19
- setTimeout(() => {
20
- reject(new TypeError(`Failed to fetch (url: "${url}")`));
21
- }, 0);
22
- }
23
- };
24
- xhr.onload = () => {
25
- const ok = xhr.status >= 200 && xhr.status < 300;
26
- if (ok) {
27
- resolve(xhr.response);
28
- }
29
- };
30
- xhr.onerror = () => {
31
- setTimeout(() => {
32
- reject(new TypeError(`Network request failed (url: "${url}")`));
33
- }, 0);
34
- };
35
- xhr.ontimeout = () => {
36
- setTimeout(() => {
37
- reject(new TypeError(`Network request failed (url: "${url}")`));
38
- }, 0);
39
- };
40
- xhr.send();
41
- });
42
- };
43
- class URLBrowserResolver {
44
- constructor(fs) {
45
- this.fs = fs;
46
- this.resolving = {};
47
- }
48
- resolve(url, headers = {}) {
49
- if (!this.resolving[url]) {
50
- this.resolving[url] = new Promise((resolve, reject) => {
51
- if (url.toLowerCase().indexOf('https://') === 0 || url.toLowerCase().indexOf('http://') === 0) {
52
- if (this.fs.existsSync(url)) {
53
- // url was downloaded earlier
54
- resolve();
55
- } else {
56
- fetchUrl(url, headers).then(buffer => {
57
- this.fs.writeFileSync(url, buffer);
58
- resolve();
59
- }, result => {
60
- reject(result);
61
- });
62
- }
63
- } else {
64
- // cannot be resolved
65
- resolve();
66
- }
67
- });
68
- }
69
- return this.resolving[url];
70
- }
71
- resolved() {
72
- return new Promise((resolve, reject) => {
73
- Promise.all(Object.values(this.resolving)).then(() => {
74
- resolve();
75
- }, result => {
76
- reject(result);
77
- });
78
- });
79
- }
80
- }
81
- var _default = exports.default = URLBrowserResolver;
@@ -1,89 +0,0 @@
1
- const fetchUrl = (url, headers = {}) => {
2
- return new Promise((resolve, reject) => {
3
- const xhr = new XMLHttpRequest();
4
- xhr.open('GET', url, true);
5
- for (let headerName in headers) {
6
- xhr.setRequestHeader(headerName, headers[headerName]);
7
- }
8
- xhr.responseType = 'arraybuffer';
9
-
10
- xhr.onreadystatechange = () => {
11
- if (xhr.readyState !== 4) {
12
- return;
13
- }
14
-
15
- const ok = xhr.status >= 200 && xhr.status < 300;
16
- if (!ok) {
17
- setTimeout(() => {
18
- reject(new TypeError(`Failed to fetch (url: "${url}")`));
19
- }, 0);
20
- }
21
- };
22
-
23
- xhr.onload = () => {
24
- const ok = xhr.status >= 200 && xhr.status < 300;
25
- if (ok) {
26
- resolve(xhr.response);
27
- }
28
- };
29
-
30
- xhr.onerror = () => {
31
- setTimeout(() => {
32
- reject(new TypeError(`Network request failed (url: "${url}")`));
33
- }, 0);
34
- };
35
-
36
- xhr.ontimeout = () => {
37
- setTimeout(() => {
38
- reject(new TypeError(`Network request failed (url: "${url}")`));
39
- }, 0);
40
- };
41
-
42
- xhr.send();
43
- });
44
- };
45
-
46
- class URLBrowserResolver {
47
- constructor(fs) {
48
- this.fs = fs;
49
- this.resolving = {};
50
- }
51
-
52
- resolve(url, headers = {}) {
53
- if (!this.resolving[url]) {
54
- this.resolving[url] = new Promise((resolve, reject) => {
55
- if (url.toLowerCase().indexOf('https://') === 0 || url.toLowerCase().indexOf('http://') === 0) {
56
- if (this.fs.existsSync(url)) {
57
- // url was downloaded earlier
58
- resolve();
59
- } else {
60
- fetchUrl(url, headers).then(buffer => {
61
- this.fs.writeFileSync(url, buffer);
62
- resolve();
63
- }, result => {
64
- reject(result);
65
- });
66
- }
67
- } else {
68
- // cannot be resolved
69
- resolve();
70
- }
71
- });
72
- }
73
-
74
- return this.resolving[url];
75
- }
76
-
77
- resolved() {
78
- return new Promise((resolve, reject) => {
79
- Promise.all(Object.values(this.resolving)).then(() => {
80
- resolve();
81
- }, result => {
82
- reject(result);
83
- });
84
- });
85
- }
86
-
87
- }
88
-
89
- export default URLBrowserResolver;