ats-form-react-pdf-renderer 4.3.8 → 4.3.10
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/lib/react-pdf.browser.js +63 -46
- package/lib/react-pdf.browser.js.map +1 -1
- package/lib/react-pdf.browser.min.js +2 -2
- package/lib/react-pdf.js +65 -48
- package/lib/react-pdf.js.map +1 -1
- package/lib/react-pdf.min.js +2 -2
- package/package.json +7 -7
package/lib/react-pdf.browser.js
CHANGED
|
@@ -4054,7 +4054,7 @@ const fromFragments = fragments => {
|
|
|
4054
4054
|
runs
|
|
4055
4055
|
};
|
|
4056
4056
|
};
|
|
4057
|
-
|
|
4057
|
+
const SOFT_HYPHEN$1 = '\u00ad';
|
|
4058
4058
|
/**
|
|
4059
4059
|
* Default word hyphenation engine used when no one provided.
|
|
4060
4060
|
* Does not perform word hyphenation at all
|
|
@@ -4062,7 +4062,16 @@ const fromFragments = fragments => {
|
|
|
4062
4062
|
* @param word
|
|
4063
4063
|
* @returns Same word
|
|
4064
4064
|
*/
|
|
4065
|
-
const
|
|
4065
|
+
const defaultHyphenate = word => [word];
|
|
4066
|
+
/**
|
|
4067
|
+
* Remove soft hyphens from word
|
|
4068
|
+
*
|
|
4069
|
+
* @param word
|
|
4070
|
+
* @returns Word without soft hyphens
|
|
4071
|
+
*/
|
|
4072
|
+
const removeSoftHyphens = word => {
|
|
4073
|
+
return word.replaceAll(SOFT_HYPHEN$1, '');
|
|
4074
|
+
};
|
|
4066
4075
|
/**
|
|
4067
4076
|
* Wrap words of attribute string
|
|
4068
4077
|
*
|
|
@@ -4084,21 +4093,30 @@ const wrapWords = function (engines, options) {
|
|
|
4084
4093
|
var _engines$wordHyphenat, _engines;
|
|
4085
4094
|
const syllables = [];
|
|
4086
4095
|
const fragments = [];
|
|
4087
|
-
const
|
|
4096
|
+
const builtinHyphenate = ((_engines$wordHyphenat = (_engines = engines).wordHyphenation) === null || _engines$wordHyphenat === void 0 ? void 0 : _engines$wordHyphenat.call(_engines)) || defaultHyphenate;
|
|
4097
|
+
const hyphenate = options.hyphenationCallback || builtinHyphenate;
|
|
4098
|
+
let offset = 0;
|
|
4088
4099
|
for (let i = 0; i < attributedString.runs.length; i += 1) {
|
|
4089
4100
|
let string = '';
|
|
4090
4101
|
const run = attributedString.runs[i];
|
|
4091
4102
|
const words = attributedString.string.slice(run.start, run.end).split(/([ ]+)/g).filter(Boolean);
|
|
4092
4103
|
for (let j = 0; j < words.length; j += 1) {
|
|
4093
4104
|
const word = words[j];
|
|
4094
|
-
const parts =
|
|
4105
|
+
const parts = hyphenate(word, builtinHyphenate).map(removeSoftHyphens);
|
|
4095
4106
|
syllables.push(...parts);
|
|
4096
4107
|
string += parts.join('');
|
|
4097
4108
|
}
|
|
4109
|
+
// Modify run start and end based on removed soft hyphens.
|
|
4110
|
+
const runOffset = run.end - run.start - string.length;
|
|
4111
|
+
const start = run.start - offset;
|
|
4112
|
+
const end = run.end - offset - runOffset;
|
|
4098
4113
|
fragments.push({
|
|
4099
4114
|
...run,
|
|
4115
|
+
start,
|
|
4116
|
+
end,
|
|
4100
4117
|
string
|
|
4101
4118
|
});
|
|
4119
|
+
offset += runOffset;
|
|
4102
4120
|
}
|
|
4103
4121
|
const result = {
|
|
4104
4122
|
...fromFragments(fragments),
|
|
@@ -5776,7 +5794,7 @@ const layoutEngine = engines => {
|
|
|
5776
5794
|
if (options === void 0) {
|
|
5777
5795
|
options = {};
|
|
5778
5796
|
}
|
|
5779
|
-
const processParagraph = compose(resolveYOffset(), resolveAttachments(), verticalAlignment(), wrapWords(engines, options),
|
|
5797
|
+
const processParagraph = compose(resolveYOffset(), resolveAttachments(), verticalAlignment(), generateGlyphs(), wrapWords(engines, options), mirrorString(), preprocessRuns(engines));
|
|
5780
5798
|
const processParagraphs = paragraphs => paragraphs.map(processParagraph);
|
|
5781
5799
|
return compose(finalizeFragments(engines, options), bidiReordering(), typesetter(engines, options, container), processParagraphs, splitParagraphs(), applyDefaultStyles())(attributedString);
|
|
5782
5800
|
};
|
|
@@ -5834,6 +5852,15 @@ const bidiEngine = () => {
|
|
|
5834
5852
|
};
|
|
5835
5853
|
};
|
|
5836
5854
|
const INFINITY = 10000;
|
|
5855
|
+
const skipPastGlueAndPenalty = (nodes, start) => {
|
|
5856
|
+
let j = start + 1;
|
|
5857
|
+
for (; j < nodes.length; j++) {
|
|
5858
|
+
if (nodes[j].type !== 'glue' && nodes[j].type !== 'penalty') {
|
|
5859
|
+
break;
|
|
5860
|
+
}
|
|
5861
|
+
}
|
|
5862
|
+
return nodes[j - 1];
|
|
5863
|
+
};
|
|
5837
5864
|
const getNextBreakpoint = (subnodes, widths, lineNumber) => {
|
|
5838
5865
|
let position = null;
|
|
5839
5866
|
let minimumBadness = Infinity;
|
|
@@ -5856,6 +5883,7 @@ const getNextBreakpoint = (subnodes, widths, lineNumber) => {
|
|
|
5856
5883
|
}
|
|
5857
5884
|
return 0;
|
|
5858
5885
|
};
|
|
5886
|
+
let hyphenWidth = 0;
|
|
5859
5887
|
for (let i = 0; i < subnodes.length; i += 1) {
|
|
5860
5888
|
const node = subnodes[i];
|
|
5861
5889
|
if (node.type === 'box') {
|
|
@@ -5866,7 +5894,9 @@ const getNextBreakpoint = (subnodes, widths, lineNumber) => {
|
|
|
5866
5894
|
sum.stretch += node.stretch;
|
|
5867
5895
|
sum.shrink += node.shrink;
|
|
5868
5896
|
}
|
|
5869
|
-
|
|
5897
|
+
const potentialEndOfLine = skipPastGlueAndPenalty(subnodes, i);
|
|
5898
|
+
hyphenWidth = potentialEndOfLine.type === 'penalty' ? potentialEndOfLine.width : 0;
|
|
5899
|
+
if (sum.width - sum.shrink + hyphenWidth > lineLength) {
|
|
5870
5900
|
if (position === null) {
|
|
5871
5901
|
let j = i === 0 ? i + 1 : i;
|
|
5872
5902
|
while (j < subnodes.length && (subnodes[j].type === 'glue' || subnodes[j].type === 'penalty')) {
|
|
@@ -5886,7 +5916,7 @@ const getNextBreakpoint = (subnodes, widths, lineNumber) => {
|
|
|
5886
5916
|
}
|
|
5887
5917
|
}
|
|
5888
5918
|
}
|
|
5889
|
-
return sum.width - sum.shrink > lineLength ? position : null;
|
|
5919
|
+
return sum.width - sum.shrink + hyphenWidth > lineLength ? position : null;
|
|
5890
5920
|
};
|
|
5891
5921
|
const applyBestFit = (nodes, widths) => {
|
|
5892
5922
|
let count = 0;
|
|
@@ -6483,7 +6513,6 @@ const breakLines = (attributedString, nodes, breaks) => {
|
|
|
6483
6513
|
start = end;
|
|
6484
6514
|
return [...acc, line];
|
|
6485
6515
|
}, []);
|
|
6486
|
-
// Last line
|
|
6487
6516
|
lines.push(slice(start, attributedString.string.length, attributedString));
|
|
6488
6517
|
return lines;
|
|
6489
6518
|
};
|
|
@@ -6915,10 +6944,11 @@ const wordHyphenation = () => {
|
|
|
6915
6944
|
const IGNORED_CODE_POINTS = [173];
|
|
6916
6945
|
const getFontSize = run => run.attributes.fontSize || 12;
|
|
6917
6946
|
const pickFontFromFontStack = (codePoint, fontStack, lastFont) => {
|
|
6947
|
+
if (IGNORED_CODE_POINTS.includes(codePoint)) return lastFont;
|
|
6918
6948
|
const fontStackWithFallback = [...fontStack, lastFont];
|
|
6919
6949
|
for (let i = 0; i < fontStackWithFallback.length; i += 1) {
|
|
6920
6950
|
const font = fontStackWithFallback[i];
|
|
6921
|
-
if (
|
|
6951
|
+
if (font && font.hasGlyphForCodePoint && font.hasGlyphForCodePoint(codePoint)) {
|
|
6922
6952
|
return font;
|
|
6923
6953
|
}
|
|
6924
6954
|
}
|
|
@@ -23506,11 +23536,7 @@ class PNG {
|
|
|
23506
23536
|
this.format = 'png';
|
|
23507
23537
|
}
|
|
23508
23538
|
static isValid(data) {
|
|
23509
|
-
|
|
23510
|
-
return !!new PNG(data);
|
|
23511
|
-
} catch {
|
|
23512
|
-
return false;
|
|
23513
|
-
}
|
|
23539
|
+
return data && Buffer$1.isBuffer(data) && data[0] === 137 && data[1] === 80 && data[2] === 78 && data[3] === 71 && data[4] === 13 && data[5] === 10 && data[6] === 26 && data[7] === 10;
|
|
23514
23540
|
}
|
|
23515
23541
|
}
|
|
23516
23542
|
class JPEG {
|
|
@@ -23550,22 +23576,21 @@ const createCache = function (_temp) {
|
|
|
23550
23576
|
let {
|
|
23551
23577
|
limit = 100
|
|
23552
23578
|
} = _temp === void 0 ? {} : _temp;
|
|
23553
|
-
let cache =
|
|
23554
|
-
let keys = [];
|
|
23579
|
+
let cache = new Map();
|
|
23555
23580
|
return {
|
|
23556
|
-
get: key => key ? cache
|
|
23581
|
+
get: key => key ? cache.get(key) ?? undefined : null,
|
|
23557
23582
|
set: (key, value) => {
|
|
23558
|
-
|
|
23559
|
-
if (
|
|
23560
|
-
|
|
23583
|
+
cache.delete(key);
|
|
23584
|
+
if (cache.size >= limit) {
|
|
23585
|
+
const firstKey = cache.keys().next().value;
|
|
23586
|
+
cache.delete(firstKey);
|
|
23561
23587
|
}
|
|
23562
|
-
cache
|
|
23588
|
+
cache.set(key, value);
|
|
23563
23589
|
},
|
|
23564
23590
|
reset: () => {
|
|
23565
|
-
cache =
|
|
23566
|
-
keys = [];
|
|
23591
|
+
cache = new Map();
|
|
23567
23592
|
},
|
|
23568
|
-
length: () =>
|
|
23593
|
+
length: () => cache.size
|
|
23569
23594
|
};
|
|
23570
23595
|
};
|
|
23571
23596
|
const IMAGE_CACHE = createCache({
|
|
@@ -23578,7 +23603,7 @@ const isBlob = src => {
|
|
|
23578
23603
|
const isDataImageSrc = src => {
|
|
23579
23604
|
return 'data' in src;
|
|
23580
23605
|
};
|
|
23581
|
-
const
|
|
23606
|
+
const isDataUri = imageSrc => 'uri' in imageSrc && imageSrc.uri.startsWith('data:');
|
|
23582
23607
|
const fetchRemoteFile = async src => {
|
|
23583
23608
|
const {
|
|
23584
23609
|
method = 'GET',
|
|
@@ -23599,7 +23624,7 @@ const isValidFormat = format => {
|
|
|
23599
23624
|
const lower = format.toLowerCase();
|
|
23600
23625
|
return lower === 'jpg' || lower === 'jpeg' || lower === 'png';
|
|
23601
23626
|
};
|
|
23602
|
-
const
|
|
23627
|
+
const getImageFormat = buffer => {
|
|
23603
23628
|
let format;
|
|
23604
23629
|
if (JPEG.isValid(buffer)) {
|
|
23605
23630
|
format = 'jpg';
|
|
@@ -23637,7 +23662,7 @@ const resolveImageFromData = async src => {
|
|
|
23637
23662
|
throw new Error(`Invalid data given for local file: ${JSON.stringify(src)}`);
|
|
23638
23663
|
};
|
|
23639
23664
|
const resolveBufferImage = async buffer => {
|
|
23640
|
-
const format =
|
|
23665
|
+
const format = getImageFormat(buffer);
|
|
23641
23666
|
if (format) {
|
|
23642
23667
|
return getImage(buffer, format);
|
|
23643
23668
|
}
|
|
@@ -23662,27 +23687,18 @@ const resolveBlobImage = async blob => {
|
|
|
23662
23687
|
const buffer = await blob.arrayBuffer();
|
|
23663
23688
|
return getImage(Buffer$1.from(buffer), format);
|
|
23664
23689
|
};
|
|
23665
|
-
const getImageFormat = body => {
|
|
23666
|
-
const isPng = body[0] === 137 && body[1] === 80 && body[2] === 78 && body[3] === 71 && body[4] === 13 && body[5] === 10 && body[6] === 26 && body[7] === 10;
|
|
23667
|
-
const isJpg = body[0] === 255 && body[1] === 216 && body[2] === 255;
|
|
23668
|
-
let extension = '';
|
|
23669
|
-
if (isPng) {
|
|
23670
|
-
extension = 'png';
|
|
23671
|
-
} else if (isJpg) {
|
|
23672
|
-
extension = 'jpg';
|
|
23673
|
-
} else {
|
|
23674
|
-
throw new Error('Not valid image extension');
|
|
23675
|
-
}
|
|
23676
|
-
return extension;
|
|
23677
|
-
};
|
|
23678
23690
|
const resolveImageFromUrl = async src => {
|
|
23679
23691
|
const data = await fetchRemoteFile(src);
|
|
23680
23692
|
const format = getImageFormat(data);
|
|
23693
|
+
if (!format) {
|
|
23694
|
+
throw new Error('Not valid image extension');
|
|
23695
|
+
}
|
|
23681
23696
|
return getImage(data, format);
|
|
23682
23697
|
};
|
|
23683
23698
|
const getCacheKey = src => {
|
|
23699
|
+
var _src$data;
|
|
23684
23700
|
if (isBlob(src) || isBuffer(src)) return null;
|
|
23685
|
-
if (isDataImageSrc(src)) return src.data.toString();
|
|
23701
|
+
if (isDataImageSrc(src)) return ((_src$data = src.data) === null || _src$data === void 0 ? void 0 : _src$data.toString('base64')) ?? null;
|
|
23686
23702
|
return src.uri;
|
|
23687
23703
|
};
|
|
23688
23704
|
const resolveImage = function (src, _temp2) {
|
|
@@ -23697,16 +23713,13 @@ const resolveImage = function (src, _temp2) {
|
|
|
23697
23713
|
image = resolveBufferImage(src);
|
|
23698
23714
|
} else if (cache && IMAGE_CACHE.get(cacheKey)) {
|
|
23699
23715
|
return IMAGE_CACHE.get(cacheKey);
|
|
23700
|
-
} else if (
|
|
23716
|
+
} else if (isDataUri(src)) {
|
|
23701
23717
|
image = resolveBase64Image(src);
|
|
23702
23718
|
} else if (isDataImageSrc(src)) {
|
|
23703
23719
|
image = resolveImageFromData(src);
|
|
23704
23720
|
} else {
|
|
23705
23721
|
image = resolveImageFromUrl(src);
|
|
23706
23722
|
}
|
|
23707
|
-
if (!image) {
|
|
23708
|
-
throw new Error('Cannot resolve image');
|
|
23709
|
-
}
|
|
23710
23723
|
if (cache && cacheKey) {
|
|
23711
23724
|
IMAGE_CACHE.set(cacheKey, image);
|
|
23712
23725
|
}
|
|
@@ -24954,6 +24967,10 @@ const splitNode = (node, height) => {
|
|
|
24954
24967
|
borderTopWidth: 0,
|
|
24955
24968
|
borderTopLeftRadius: 0,
|
|
24956
24969
|
borderTopRightRadius: 0
|
|
24970
|
+
},
|
|
24971
|
+
props: {
|
|
24972
|
+
...node.props,
|
|
24973
|
+
bookmark: null
|
|
24957
24974
|
}
|
|
24958
24975
|
});
|
|
24959
24976
|
if (nextHeight) {
|
|
@@ -26893,7 +26910,7 @@ const createRenderer = _ref2 => {
|
|
|
26893
26910
|
});
|
|
26894
26911
|
};
|
|
26895
26912
|
|
|
26896
|
-
var version$1 = "4.3.
|
|
26913
|
+
var version$1 = "4.3.10";
|
|
26897
26914
|
var packageJson = {
|
|
26898
26915
|
version: version$1};
|
|
26899
26916
|
|