@digicole/pdfmake-rtl 2.1.0 → 2.1.2

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 (65) hide show
  1. package/CHANGELOG.md +118 -83
  2. package/README.md +11 -10
  3. package/build/pdfmake.js +71 -42
  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 +11 -11
  8. package/js/3rd-party/svg-to-pdfkit/source.js +3823 -0
  9. package/js/3rd-party/svg-to-pdfkit.js +7 -0
  10. package/js/DocMeasure.js +713 -0
  11. package/js/DocPreprocessor.js +275 -0
  12. package/js/DocumentContext.js +310 -0
  13. package/js/ElementWriter.js +687 -0
  14. package/js/LayoutBuilder.js +1240 -0
  15. package/js/Line.js +113 -0
  16. package/js/OutputDocument.js +64 -0
  17. package/js/OutputDocumentServer.js +29 -0
  18. package/js/PDFDocument.js +144 -0
  19. package/js/PageElementWriter.js +161 -0
  20. package/js/PageSize.js +74 -0
  21. package/js/Printer.js +351 -0
  22. package/js/Renderer.js +417 -0
  23. package/js/SVGMeasure.js +92 -0
  24. package/js/StyleContextStack.js +191 -0
  25. package/js/TableProcessor.js +575 -0
  26. package/js/TextBreaker.js +166 -0
  27. package/js/TextDecorator.js +152 -0
  28. package/js/TextInlines.js +244 -0
  29. package/js/URLResolver.js +43 -0
  30. package/js/base.js +59 -0
  31. package/js/browser-extensions/OutputDocumentBrowser.js +82 -0
  32. package/js/browser-extensions/fonts/Cairo.js +38 -0
  33. package/js/browser-extensions/fonts/Roboto.js +38 -0
  34. package/js/browser-extensions/index.js +59 -0
  35. package/js/browser-extensions/pdfMake.js +3 -0
  36. package/js/browser-extensions/standard-fonts/Courier.js +38 -0
  37. package/js/browser-extensions/standard-fonts/Helvetica.js +38 -0
  38. package/js/browser-extensions/standard-fonts/Symbol.js +23 -0
  39. package/js/browser-extensions/standard-fonts/Times.js +38 -0
  40. package/js/browser-extensions/standard-fonts/ZapfDingbats.js +23 -0
  41. package/js/browser-extensions/virtual-fs-cjs.js +3 -0
  42. package/js/columnCalculator.js +148 -0
  43. package/js/helpers/node.js +123 -0
  44. package/js/helpers/tools.js +46 -0
  45. package/js/helpers/variableType.js +59 -0
  46. package/js/index.js +15 -0
  47. package/js/qrEnc.js +721 -0
  48. package/js/rtlUtils.js +519 -0
  49. package/js/standardPageSizes.js +56 -0
  50. package/js/tableLayouts.js +98 -0
  51. package/js/virtual-fs.js +60 -0
  52. package/package.json +1 -1
  53. package/src/{docMeasure.js → DocMeasure.js} +8 -8
  54. package/src/{elementWriter.js → ElementWriter.js} +3 -3
  55. package/src/{layoutBuilder.js → LayoutBuilder.js} +1406 -1393
  56. package/src/{tableProcessor.js → TableProcessor.js} +633 -620
  57. package/src/rtlUtils.js +503 -500
  58. /package/src/{docPreprocessor.js → DocPreprocessor.js} +0 -0
  59. /package/src/{documentContext.js → DocumentContext.js} +0 -0
  60. /package/src/{line.js → Line.js} +0 -0
  61. /package/src/{pageElementWriter.js → PageElementWriter.js} +0 -0
  62. /package/src/{printer.js → Printer.js} +0 -0
  63. /package/src/{svgMeasure.js → SVGMeasure.js} +0 -0
  64. /package/src/{styleContextStack.js → StyleContextStack.js} +0 -0
  65. /package/src/{textDecorator.js → TextDecorator.js} +0 -0
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.default = void 0;
5
+ const normalizeFilename = filename => {
6
+ if (filename.indexOf(__dirname) === 0) {
7
+ filename = filename.substring(__dirname.length);
8
+ }
9
+ if (filename.indexOf('/') === 0) {
10
+ filename = filename.substring(1);
11
+ }
12
+ return filename;
13
+ };
14
+ class VirtualFileSystem {
15
+ constructor() {
16
+ this.storage = {};
17
+ }
18
+
19
+ /**
20
+ * @param {string} filename
21
+ * @returns {boolean}
22
+ */
23
+ existsSync(filename) {
24
+ const normalizedFilename = normalizeFilename(filename);
25
+ return typeof this.storage[normalizedFilename] !== 'undefined';
26
+ }
27
+
28
+ /**
29
+ * @param {string} filename
30
+ * @param {?string|?object} options
31
+ * @returns {string|Buffer}
32
+ */
33
+ readFileSync(filename, options) {
34
+ const normalizedFilename = normalizeFilename(filename);
35
+ const encoding = typeof options === 'object' ? options.encoding : options;
36
+ if (!this.existsSync(normalizedFilename)) {
37
+ throw new Error(`File '${normalizedFilename}' not found in virtual file system`);
38
+ }
39
+ const buffer = this.storage[normalizedFilename];
40
+ if (encoding) {
41
+ return buffer.toString(encoding);
42
+ }
43
+ return buffer;
44
+ }
45
+
46
+ /**
47
+ * @param {string} filename
48
+ * @param {string|Buffer} content
49
+ * @param {?string|?object} options
50
+ */
51
+ writeFileSync(filename, content, options) {
52
+ const normalizedFilename = normalizeFilename(filename);
53
+ const encoding = typeof options === 'object' ? options.encoding : options;
54
+ if (!content && !options) {
55
+ throw new Error('No content');
56
+ }
57
+ this.storage[normalizedFilename] = encoding || typeof content === 'string' ? new Buffer(content, encoding) : content;
58
+ }
59
+ }
60
+ var _default = exports.default = new VirtualFileSystem();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digicole/pdfmake-rtl",
3
- "version": "2.1.0",
3
+ "version": "2.1.2",
4
4
  "description": "Enhanced PDFMake with comprehensive RTL (Arabic/Persian/Urdu) support - Production ready package",
5
5
  "main": "js/index.js",
6
6
  "esnext": "src/index.js",
@@ -1,12 +1,12 @@
1
- import TextInlines from './TextInlines';
2
- import StyleContextStack from './StyleContextStack';
3
- import ColumnCalculator from './columnCalculator';
4
- import { defaultTableLayout } from './tableLayouts';
5
- import { isString, isNumber, isObject } from './helpers/variableType';
6
- import { stringifyNode, getNodeId, getNodeMargin } from './helpers/node';
7
- import { pack } from './helpers/tools';
1
+ import TextInlines from './TextInlines.js';
2
+ import StyleContextStack from './StyleContextStack.js';
3
+ import ColumnCalculator from './columnCalculator.js';
4
+ import { defaultTableLayout } from './tableLayouts.js';
5
+ import { isString, isNumber, isObject } from './helpers/variableType.js';
6
+ import { stringifyNode, getNodeId, getNodeMargin } from './helpers/node.js';
7
+ import { pack } from './helpers/tools.js';
8
8
  import qrEncoder from './qrEnc.js';
9
- import { containsRTL } from './rtlUtils';
9
+ import { containsRTL } from './rtlUtils.js';
10
10
 
11
11
  class DocMeasure {
12
12
  constructor(
@@ -132,7 +132,7 @@ class ElementWriter extends EventEmitter {
132
132
  const LTR_REGEX = /[A-Za-z\u00C0-\u024F\u1E00-\u1EFF]/;
133
133
  const NUMBER_PUNCTUATION_REGEX = /^(\d+)([.:/\-)(]+)(\s*)$/;
134
134
  // Characters that are "boundary neutral" — separators/punctuation between scripts
135
- const BOUNDARY_NEUTRAL = /[\/\\\-()[\]{}<>:;.,!?@#$%^&*_=+|~`'"،؛؟\s]/;
135
+ const BOUNDARY_NEUTRAL = /[/\\\-()[\]{}<>:;.,!?@#$%^&*_=+|~`'"،؛؟\s]/;
136
136
 
137
137
  // --- Step 0: Pre-split inlines at RTL↔neutral and LTR↔neutral boundaries ---
138
138
  // e.g. "العربية/" → ["العربية", "/"] and "hello-" → ["hello", "-"]
@@ -242,8 +242,8 @@ class ElementWriter extends EventEmitter {
242
242
  // Find matching bracket pairs across runs. If the content between
243
243
  // a "(" neutral run and a ")" neutral run is predominantly one direction,
244
244
  // merge the opening bracket, content, and closing bracket into that direction.
245
- const OPEN_BRACKETS = /[(\[{<]/;
246
- const CLOSE_BRACKETS = /[)\]}>]/;
245
+ const OPEN_BRACKETS = /[(\\[{<]/;
246
+ // const CLOSE_BRACKETS = /[)\]}>]/;
247
247
  const BRACKET_MATCH = { '(': ')', '[': ']', '{': '}', '<': '>' };
248
248
 
249
249
  for (let i = 0; i < runs.length; i++) {