@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.
- package/CHANGELOG.md +118 -83
- package/README.md +11 -10
- package/build/pdfmake.js +71 -42
- package/build/pdfmake.js.map +1 -1
- package/build/pdfmake.min.js +2 -2
- package/build/pdfmake.min.js.map +1 -1
- package/build/vfs_fonts.js +11 -11
- package/js/3rd-party/svg-to-pdfkit/source.js +3823 -0
- package/js/3rd-party/svg-to-pdfkit.js +7 -0
- package/js/DocMeasure.js +713 -0
- package/js/DocPreprocessor.js +275 -0
- package/js/DocumentContext.js +310 -0
- package/js/ElementWriter.js +687 -0
- package/js/LayoutBuilder.js +1240 -0
- package/js/Line.js +113 -0
- package/js/OutputDocument.js +64 -0
- package/js/OutputDocumentServer.js +29 -0
- package/js/PDFDocument.js +144 -0
- package/js/PageElementWriter.js +161 -0
- package/js/PageSize.js +74 -0
- package/js/Printer.js +351 -0
- package/js/Renderer.js +417 -0
- package/js/SVGMeasure.js +92 -0
- package/js/StyleContextStack.js +191 -0
- package/js/TableProcessor.js +575 -0
- package/js/TextBreaker.js +166 -0
- package/js/TextDecorator.js +152 -0
- package/js/TextInlines.js +244 -0
- package/js/URLResolver.js +43 -0
- package/js/base.js +59 -0
- package/js/browser-extensions/OutputDocumentBrowser.js +82 -0
- package/js/browser-extensions/fonts/Cairo.js +38 -0
- package/js/browser-extensions/fonts/Roboto.js +38 -0
- package/js/browser-extensions/index.js +59 -0
- package/js/browser-extensions/pdfMake.js +3 -0
- package/js/browser-extensions/standard-fonts/Courier.js +38 -0
- package/js/browser-extensions/standard-fonts/Helvetica.js +38 -0
- package/js/browser-extensions/standard-fonts/Symbol.js +23 -0
- package/js/browser-extensions/standard-fonts/Times.js +38 -0
- package/js/browser-extensions/standard-fonts/ZapfDingbats.js +23 -0
- package/js/browser-extensions/virtual-fs-cjs.js +3 -0
- package/js/columnCalculator.js +148 -0
- package/js/helpers/node.js +123 -0
- package/js/helpers/tools.js +46 -0
- package/js/helpers/variableType.js +59 -0
- package/js/index.js +15 -0
- package/js/qrEnc.js +721 -0
- package/js/rtlUtils.js +519 -0
- package/js/standardPageSizes.js +56 -0
- package/js/tableLayouts.js +98 -0
- package/js/virtual-fs.js +60 -0
- package/package.json +1 -1
- package/src/{docMeasure.js → DocMeasure.js} +8 -8
- package/src/{elementWriter.js → ElementWriter.js} +3 -3
- package/src/{layoutBuilder.js → LayoutBuilder.js} +1406 -1393
- package/src/{tableProcessor.js → TableProcessor.js} +633 -620
- package/src/rtlUtils.js +503 -500
- /package/src/{docPreprocessor.js → DocPreprocessor.js} +0 -0
- /package/src/{documentContext.js → DocumentContext.js} +0 -0
- /package/src/{line.js → Line.js} +0 -0
- /package/src/{pageElementWriter.js → PageElementWriter.js} +0 -0
- /package/src/{printer.js → Printer.js} +0 -0
- /package/src/{svgMeasure.js → SVGMeasure.js} +0 -0
- /package/src/{styleContextStack.js → StyleContextStack.js} +0 -0
- /package/src/{textDecorator.js → TextDecorator.js} +0 -0
package/js/virtual-fs.js
ADDED
|
@@ -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,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 = /[
|
|
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
|
-
|
|
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++) {
|