pdfmake 0.3.7 → 0.3.8

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/build/pdfmake.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! pdfmake v0.3.7, @license MIT, @link http://pdfmake.org */
1
+ /*! pdfmake v0.3.8, @license MIT, @link http://pdfmake.org */
2
2
  (function webpackUniversalModuleDefinition(root, factory) {
3
3
  if(typeof exports === 'object' && typeof module === 'object')
4
4
  module.exports = factory();
@@ -25,10 +25,62 @@ __webpack_require__.d(__webpack_exports__, {
25
25
  // EXTERNAL MODULE: ./node_modules/core-js/modules/es.array.includes.js
26
26
  var es_array_includes = __webpack_require__(187);
27
27
  // EXTERNAL MODULE: ./node_modules/pdfkit/js/pdfkit.es.js
28
- var pdfkit_es = __webpack_require__(5167);
28
+ var pdfkit_es = __webpack_require__(6649);
29
+ ;// ./src/helpers/variableType.js
30
+ /**
31
+ * @param {any} variable
32
+ * @returns {boolean}
33
+ */
34
+ function isString(variable) {
35
+ return typeof variable === 'string' || variable instanceof String;
36
+ }
37
+
38
+ /**
39
+ * @param {any} variable
40
+ * @returns {boolean}
41
+ */
42
+ function isNumber(variable) {
43
+ return (typeof variable === 'number' || variable instanceof Number) && !Number.isNaN(variable);
44
+ }
45
+
46
+ /**
47
+ * @param {any} variable
48
+ * @returns {boolean}
49
+ */
50
+ function isPositiveInteger(variable) {
51
+ if (!isNumber(variable) || !Number.isInteger(variable) || variable <= 0) {
52
+ return false;
53
+ }
54
+ return true;
55
+ }
56
+
57
+ /**
58
+ * @param {any} variable
59
+ * @returns {boolean}
60
+ */
61
+ function isObject(variable) {
62
+ return variable !== null && !Array.isArray(variable) && !isString(variable) && !isNumber(variable) && typeof variable === 'object';
63
+ }
64
+
65
+ /**
66
+ * @param {any} variable
67
+ * @returns {boolean}
68
+ */
69
+ function isEmptyObject(variable) {
70
+ return isObject(variable) && Object.keys(variable).length === 0;
71
+ }
72
+
73
+ /**
74
+ * @param {any} variable
75
+ * @returns {boolean}
76
+ */
77
+ function isValue(variable) {
78
+ return variable !== undefined && variable !== null;
79
+ }
29
80
  ;// ./src/PDFDocument.js
30
81
  /* provided dependency */ var Buffer = __webpack_require__(783)["Buffer"];
31
82
 
83
+
32
84
  const typeName = (bold, italics) => {
33
85
  let type = 'normal';
34
86
  if (bold && italics) {
@@ -41,7 +93,7 @@ const typeName = (bold, italics) => {
41
93
  return type;
42
94
  };
43
95
  class PDFDocument extends pdfkit_es/* default */.A {
44
- constructor(fonts, images, patterns, attachments, options, virtualfs) {
96
+ constructor(fonts, images, patterns, attachments, options, virtualfs, localAccessPolicy) {
45
97
  if (fonts === void 0) {
46
98
  fonts = {};
47
99
  }
@@ -60,6 +112,9 @@ class PDFDocument extends pdfkit_es/* default */.A {
60
112
  if (virtualfs === void 0) {
61
113
  virtualfs = null;
62
114
  }
115
+ if (localAccessPolicy === void 0) {
116
+ localAccessPolicy = undefined;
117
+ }
63
118
  super(options);
64
119
  this.fonts = {};
65
120
  this.fontCache = {};
@@ -84,6 +139,7 @@ class PDFDocument extends pdfkit_es/* default */.A {
84
139
  this.images = images;
85
140
  this.attachments = attachments;
86
141
  this.virtualfs = virtualfs;
142
+ this.localAccessPolicy = localAccessPolicy;
87
143
  }
88
144
  getFontType(bold, italics) {
89
145
  return typeName(bold, italics);
@@ -108,6 +164,8 @@ class PDFDocument extends pdfkit_es/* default */.A {
108
164
  }
109
165
  if (this.virtualfs && this.virtualfs.existsSync(def[0])) {
110
166
  def[0] = this.virtualfs.readFileSync(def[0]);
167
+ } else {
168
+ this.validateLocalFile(def[0]);
111
169
  }
112
170
  this.fontCache[familyName][type] = this.font(...def)._font;
113
171
  }
@@ -132,8 +190,10 @@ class PDFDocument extends pdfkit_es/* default */.A {
132
190
  return this._imageRegistry[src];
133
191
  }
134
192
  let image;
193
+ let imageSrc = realImageSrc(src);
194
+ this.validateLocalFile(imageSrc);
135
195
  try {
136
- image = this.openImage(realImageSrc(src));
196
+ image = this.openImage(imageSrc);
137
197
  if (!image) {
138
198
  throw new Error('No image');
139
199
  }
@@ -174,8 +234,19 @@ class PDFDocument extends pdfkit_es/* default */.A {
174
234
  if (this.virtualfs && this.virtualfs.existsSync(attachment.src)) {
175
235
  return this.virtualfs.readFileSync(attachment.src);
176
236
  }
237
+ this.validateLocalFile(attachment.src);
177
238
  return attachment;
178
239
  }
240
+ resolveColor(color, defaultColor) {
241
+ color = color || defaultColor;
242
+ if (typeof this._normalizeColor === 'function') {
243
+ if (isString(color) && this._normalizeColor(color) === null) {
244
+ // color is not valid
245
+ return defaultColor;
246
+ }
247
+ }
248
+ return color;
249
+ }
179
250
  setOpenActionAsPrint() {
180
251
  let printActionRef = this.ref({
181
252
  Type: 'Action',
@@ -185,59 +256,29 @@ class PDFDocument extends pdfkit_es/* default */.A {
185
256
  this._root.data.OpenAction = printActionRef;
186
257
  printActionRef.end();
187
258
  }
188
- }
189
- /* harmony default export */ const src_PDFDocument = (PDFDocument);
190
- ;// ./src/helpers/variableType.js
191
- /**
192
- * @param {any} variable
193
- * @returns {boolean}
194
- */
195
- function isString(variable) {
196
- return typeof variable === 'string' || variable instanceof String;
197
- }
198
-
199
- /**
200
- * @param {any} variable
201
- * @returns {boolean}
202
- */
203
- function isNumber(variable) {
204
- return (typeof variable === 'number' || variable instanceof Number) && !Number.isNaN(variable);
205
- }
206
-
207
- /**
208
- * @param {any} variable
209
- * @returns {boolean}
210
- */
211
- function isPositiveInteger(variable) {
212
- if (!isNumber(variable) || !Number.isInteger(variable) || variable <= 0) {
213
- return false;
259
+ file(src, options) {
260
+ if (options === void 0) {
261
+ options = {};
262
+ }
263
+ this.validateLocalFile(src);
264
+ return super.file(src, options);
265
+ }
266
+ validateLocalFile(path) {
267
+ if (typeof this.localAccessPolicy === 'undefined') {
268
+ return;
269
+ }
270
+ if (!isString(path)) {
271
+ return;
272
+ }
273
+ if (/^data:/.test(path)) {
274
+ return;
275
+ }
276
+ if (this.localAccessPolicy(path) !== true) {
277
+ throw new Error(`Access to local file denied by resource access policy: ${path}`);
278
+ }
214
279
  }
215
- return true;
216
- }
217
-
218
- /**
219
- * @param {any} variable
220
- * @returns {boolean}
221
- */
222
- function isObject(variable) {
223
- return variable !== null && !Array.isArray(variable) && !isString(variable) && !isNumber(variable) && typeof variable === 'object';
224
- }
225
-
226
- /**
227
- * @param {any} variable
228
- * @returns {boolean}
229
- */
230
- function isEmptyObject(variable) {
231
- return isObject(variable) && Object.keys(variable).length === 0;
232
- }
233
-
234
- /**
235
- * @param {any} variable
236
- * @returns {boolean}
237
- */
238
- function isValue(variable) {
239
- return variable !== undefined && variable !== null;
240
280
  }
281
+ /* harmony default export */ const src_PDFDocument = (PDFDocument);
241
282
  ;// ./src/helpers/node.js
242
283
 
243
284
  function fontStringify(key, val) {
@@ -4595,10 +4636,9 @@ class DocumentContext extends events.EventEmitter {
4595
4636
  initializePage() {
4596
4637
  this.y = this.pageMargins.top;
4597
4638
  this.availableHeight = this.getCurrentPage().pageSize.height - this.pageMargins.top - this.pageMargins.bottom;
4598
- const {
4599
- pageCtx,
4600
- isSnapshot
4601
- } = this.pageSnapshot();
4639
+ const _this$pageSnapshot = this.pageSnapshot(),
4640
+ pageCtx = _this$pageSnapshot.pageCtx,
4641
+ isSnapshot = _this$pageSnapshot.isSnapshot;
4602
4642
  pageCtx.availableWidth = this.getCurrentPage().pageSize.width - this.pageMargins.left - this.pageMargins.right;
4603
4643
  if (isSnapshot && this.marginXTopParent) {
4604
4644
  pageCtx.availableWidth -= this.marginXTopParent[0];
@@ -5549,9 +5589,17 @@ class PageElementWriter extends src_ElementWriter {
5549
5589
  ;// ./src/TableProcessor.js
5550
5590
 
5551
5591
 
5592
+ const PAGE_BREAK_VALUES = new Set(['before', 'beforeOdd', 'beforeEven', 'after', 'afterOdd', 'afterEven']);
5593
+ const hasExplicitPageBreak = cell => {
5594
+ if (!cell || typeof cell !== 'object') {
5595
+ return false;
5596
+ }
5597
+ return PAGE_BREAK_VALUES.has(cell.pageBreak);
5598
+ };
5552
5599
  class TableProcessor {
5553
5600
  constructor(tableNode) {
5554
5601
  this.tableNode = tableNode;
5602
+ this._isCurrentRowUnbreakable = false;
5555
5603
  }
5556
5604
  beginTable(writer) {
5557
5605
  const getTableInnerContentWidth = () => {
@@ -5690,7 +5738,10 @@ class TableProcessor {
5690
5738
  writer.context().moveDown(this.topLineWidth);
5691
5739
  }
5692
5740
  this.rowTopPageY = writer.context().y + this.rowPaddingTop;
5693
- if (this.dontBreakRows && rowIndex > 0) {
5741
+ const rowCells = this.tableNode.table.body[rowIndex] || [];
5742
+ const rowHasPageBreak = rowCells.some(hasExplicitPageBreak);
5743
+ this._isCurrentRowUnbreakable = this.dontBreakRows && rowIndex > 0 && !rowHasPageBreak;
5744
+ if (this._isCurrentRowUnbreakable) {
5694
5745
  writer.beginUnbreakableBlock();
5695
5746
  }
5696
5747
  this.rowTopY = writer.context().y;
@@ -6083,7 +6134,8 @@ class TableProcessor {
6083
6134
  if (this.headerRows && rowIndex === this.headerRows - 1) {
6084
6135
  this.headerRepeatable = writer.currentBlockToRepeatable();
6085
6136
  }
6086
- if (this.dontBreakRows) {
6137
+ const shouldCommitCurrentRowUnbreakable = this.dontBreakRows && (rowIndex === 0 || this._isCurrentRowUnbreakable);
6138
+ if (shouldCommitCurrentRowUnbreakable) {
6087
6139
  const pageChangedCallback = () => {
6088
6140
  if (rowIndex > 0 && !this.headerRows && this.layout.hLineWhenBroken !== false) {
6089
6141
  // Draw the top border of the row after a page break
@@ -6094,6 +6146,7 @@ class TableProcessor {
6094
6146
  writer.commitUnbreakableBlock();
6095
6147
  writer.removeListener('pageChanged', pageChangedCallback);
6096
6148
  }
6149
+ this._isCurrentRowUnbreakable = false;
6097
6150
  if (this.headerRepeatable && (rowIndex === this.rowsWithoutPageBreak - 1 || rowIndex === this.tableNode.table.body.length - 1)) {
6098
6151
  writer.commitUnbreakableBlock();
6099
6152
  writer.pushToRepeatables(this.headerRepeatable);
@@ -6983,19 +7036,21 @@ class LayoutBuilder {
6983
7036
  return null;
6984
7037
  }
6985
7038
  processRow(_ref) {
6986
- let {
6987
- marginX = [0, 0],
6988
- dontBreakRows = false,
6989
- rowsWithoutPageBreak = 0,
6990
- cells,
6991
- widths,
6992
- gaps,
6993
- tableNode,
6994
- tableBody,
6995
- rowIndex,
6996
- height,
6997
- snakingColumns = false
6998
- } = _ref;
7039
+ let _ref$marginX = _ref.marginX,
7040
+ marginX = _ref$marginX === void 0 ? [0, 0] : _ref$marginX,
7041
+ _ref$dontBreakRows = _ref.dontBreakRows,
7042
+ dontBreakRows = _ref$dontBreakRows === void 0 ? false : _ref$dontBreakRows,
7043
+ _ref$rowsWithoutPageB = _ref.rowsWithoutPageBreak,
7044
+ rowsWithoutPageBreak = _ref$rowsWithoutPageB === void 0 ? 0 : _ref$rowsWithoutPageB,
7045
+ cells = _ref.cells,
7046
+ widths = _ref.widths,
7047
+ gaps = _ref.gaps,
7048
+ tableNode = _ref.tableNode,
7049
+ tableBody = _ref.tableBody,
7050
+ rowIndex = _ref.rowIndex,
7051
+ height = _ref.height,
7052
+ _ref$snakingColumns = _ref.snakingColumns,
7053
+ snakingColumns = _ref$snakingColumns === void 0 ? false : _ref$snakingColumns;
6999
7054
  const isUnbreakableRow = dontBreakRows || rowIndex <= rowsWithoutPageBreak - 1;
7000
7055
  let pageBreaks = [];
7001
7056
  let pageBreaksByRowSpan = [];
@@ -7055,11 +7110,13 @@ class LayoutBuilder {
7055
7110
  // We store a reference of the ending cell in the first cell of the rowspan
7056
7111
  cell._endingCell = rowSpanRightEndingCell;
7057
7112
  cell._endingCell._startingRowSpanY = cell._startingRowSpanY;
7113
+ cell._endingCell._startingRowSpanPage = cell._startingRowSpanPage;
7058
7114
  }
7059
7115
  if (rowSpanLeftEndingCell) {
7060
7116
  // We store a reference of the left ending cell in the first cell of the rowspan
7061
7117
  cell._leftEndingCell = rowSpanLeftEndingCell;
7062
7118
  cell._leftEndingCell._startingRowSpanY = cell._startingRowSpanY;
7119
+ cell._leftEndingCell._startingRowSpanPage = cell._startingRowSpanPage;
7063
7120
  }
7064
7121
 
7065
7122
  // If we are after a cell that started a rowspan
@@ -7094,7 +7151,13 @@ class LayoutBuilder {
7094
7151
  if (dontBreakRows) {
7095
7152
  // Calculate how many points we have to discount to Y when dontBreakRows and rowSpan are combined
7096
7153
  const ctxBeforeRowSpanLastRow = this.writer.contextStack[this.writer.contextStack.length - 1];
7097
- discountY = ctxBeforeRowSpanLastRow.y - cell._startingRowSpanY;
7154
+ const startsOnCurrentPage = typeof cell._startingRowSpanPage === 'number' && cell._startingRowSpanPage === ctxBeforeRowSpanLastRow.page;
7155
+ if (startsOnCurrentPage && typeof cell._startingRowSpanY === 'number') {
7156
+ discountY = ctxBeforeRowSpanLastRow.y - cell._startingRowSpanY;
7157
+ }
7158
+
7159
+ // Do not increase Y by applying a negative discount.
7160
+ discountY = Math.max(0, discountY);
7098
7161
  }
7099
7162
  let originalXOffset = 0;
7100
7163
  // If context was saved from an unbreakable block and we are not in an unbreakable block anymore
@@ -7256,6 +7319,7 @@ class LayoutBuilder {
7256
7319
  tableNode.table.body[i].forEach(cell => {
7257
7320
  if (cell.rowSpan && cell.rowSpan > 1) {
7258
7321
  cell._startingRowSpanY = this.writer.context().y;
7322
+ cell._startingRowSpanPage = this.writer.context().page;
7259
7323
  }
7260
7324
  });
7261
7325
  }
@@ -7603,7 +7667,7 @@ class SVGMeasure {
7603
7667
  /* harmony default export */ const src_SVGMeasure = (SVGMeasure);
7604
7668
  ;// ./src/TextDecorator.js
7605
7669
 
7606
- const groupDecorations = line => {
7670
+ const groupDecorations = (line, pdfDocument) => {
7607
7671
  let groups = [];
7608
7672
  let currentGroup = null;
7609
7673
  for (let i = 0, l = line.inlines.length; i < l; i++) {
@@ -7616,7 +7680,7 @@ const groupDecorations = line => {
7616
7680
  if (!Array.isArray(decoration)) {
7617
7681
  decoration = [decoration];
7618
7682
  }
7619
- let color = inline.decorationColor || inline.color || 'black';
7683
+ let color = pdfDocument.resolveColor(pdfDocument.resolveColor(inline.decorationColor, inline.color), 'black');
7620
7684
  let style = inline.decorationStyle || 'solid';
7621
7685
  let thickness = isNumber(inline.decorationThickness) ? inline.decorationThickness : null;
7622
7686
  for (let ii = 0, ll = decoration.length; ii < ll; ii++) {
@@ -7646,10 +7710,10 @@ class TextDecorator {
7646
7710
  let height = line.getHeight();
7647
7711
  for (let i = 0, l = line.inlines.length; i < l; i++) {
7648
7712
  let inline = line.inlines[i];
7649
- if (!inline.background) {
7713
+ let color = this.pdfDocument.resolveColor(inline.background, undefined);
7714
+ if (!color) {
7650
7715
  continue;
7651
7716
  }
7652
- let color = inline.background;
7653
7717
  let patternColor = this.pdfDocument.providePattern(inline.background);
7654
7718
  if (patternColor !== null) {
7655
7719
  color = patternColor;
@@ -7659,7 +7723,7 @@ class TextDecorator {
7659
7723
  }
7660
7724
  }
7661
7725
  drawDecorations(line, x, y) {
7662
- let groups = groupDecorations(line);
7726
+ let groups = groupDecorations(line, this.pdfDocument);
7663
7727
  for (let i = 0, l = groups.length; i < l; i++) {
7664
7728
  this._drawDecoration(groups[i], x, y);
7665
7729
  }
@@ -7921,7 +7985,7 @@ class Renderer {
7921
7985
  }
7922
7986
  let opacity = isNumber(inline.opacity) ? inline.opacity : 1;
7923
7987
  this.pdfDocument.opacity(opacity);
7924
- this.pdfDocument.fill(inline.color || 'black');
7988
+ this.pdfDocument.fill(this.pdfDocument.resolveColor(inline.color, 'black'));
7925
7989
  this.pdfDocument._font = inline.font;
7926
7990
  this.pdfDocument.fontSize(inline.fontSize);
7927
7991
  let shiftedY = offsetText(y + shiftToBaseline, inline);
@@ -8014,14 +8078,14 @@ class Renderer {
8014
8078
  let fillOpacity = isNumber(vector.fillOpacity) ? vector.fillOpacity : 1;
8015
8079
  let strokeOpacity = isNumber(vector.strokeOpacity) ? vector.strokeOpacity : 1;
8016
8080
  if (vector.color && vector.lineColor) {
8017
- this.pdfDocument.fillColor(vector.color, fillOpacity);
8018
- this.pdfDocument.strokeColor(vector.lineColor, strokeOpacity);
8081
+ this.pdfDocument.fillColor(this.pdfDocument.resolveColor(vector.color, 'black'), fillOpacity);
8082
+ this.pdfDocument.strokeColor(this.pdfDocument.resolveColor(vector.lineColor, 'black'), strokeOpacity);
8019
8083
  this.pdfDocument.fillAndStroke();
8020
8084
  } else if (vector.color) {
8021
- this.pdfDocument.fillColor(vector.color, fillOpacity);
8085
+ this.pdfDocument.fillColor(this.pdfDocument.resolveColor(vector.color, 'black'), fillOpacity);
8022
8086
  this.pdfDocument.fill();
8023
8087
  } else {
8024
- this.pdfDocument.strokeColor(vector.lineColor || 'black', strokeOpacity);
8088
+ this.pdfDocument.strokeColor(this.pdfDocument.resolveColor(vector.lineColor, 'black'), strokeOpacity);
8025
8089
  this.pdfDocument.stroke();
8026
8090
  }
8027
8091
  }
@@ -8161,7 +8225,7 @@ class Renderer {
8161
8225
  }
8162
8226
  renderWatermark(page) {
8163
8227
  let watermark = page.watermark;
8164
- this.pdfDocument.fill(watermark.color);
8228
+ this.pdfDocument.fill(this.pdfDocument.resolveColor(watermark.color, 'black'));
8165
8229
  this.pdfDocument.opacity(watermark.opacity);
8166
8230
  this.pdfDocument.save();
8167
8231
  this.pdfDocument.rotate(watermark.angle, {
@@ -8193,11 +8257,13 @@ class PdfPrinter {
8193
8257
  * @param {object} fontDescriptors font definition dictionary
8194
8258
  * @param {object} virtualfs
8195
8259
  * @param {object} urlResolver
8260
+ * @param {(path: string) => boolean} localAccessPolicy
8196
8261
  */
8197
- constructor(fontDescriptors, virtualfs, urlResolver) {
8262
+ constructor(fontDescriptors, virtualfs, urlResolver, localAccessPolicy) {
8198
8263
  this.fontDescriptors = fontDescriptors;
8199
8264
  this.virtualfs = virtualfs;
8200
8265
  this.urlResolver = urlResolver;
8266
+ this.localAccessPolicy = localAccessPolicy;
8201
8267
  }
8202
8268
 
8203
8269
  /**
@@ -8246,7 +8312,7 @@ class PdfPrinter {
8246
8312
  info: createMetadata(docDefinition),
8247
8313
  font: null
8248
8314
  };
8249
- this.pdfKitDoc = new src_PDFDocument(this.fontDescriptors, docDefinition.images, docDefinition.patterns, docDefinition.attachments, pdfOptions, this.virtualfs);
8315
+ this.pdfKitDoc = new src_PDFDocument(this.fontDescriptors, docDefinition.images, docDefinition.patterns, docDefinition.attachments, pdfOptions, this.virtualfs, this.localAccessPolicy);
8250
8316
  embedFiles(docDefinition, this.pdfKitDoc);
8251
8317
  const builder = new src_LayoutBuilder(pageSize, normalizePageMargin(docDefinition.pageMargins), new src_SVGMeasure());
8252
8318
  builder.registerTableLayouts(tableLayouts);
@@ -8451,23 +8517,55 @@ function calculatePageHeight(page, margins) {
8451
8517
  // EXTERNAL MODULE: ./src/virtual-fs.js
8452
8518
  var virtual_fs = __webpack_require__(6811);
8453
8519
  ;// ./src/URLResolver.js
8454
- async function fetchUrl(url, headers) {
8520
+ const MAX_REDIRECTS = 30;
8521
+
8522
+ /**
8523
+ * @param {string} url
8524
+ * @param {object} headers
8525
+ * @param {(url: string) => boolean} urlAccessPolicy
8526
+ * @returns {Promise<Response>}
8527
+ */
8528
+ async function fetchUrl(url, headers, urlAccessPolicy) {
8455
8529
  if (headers === void 0) {
8456
8530
  headers = {};
8457
8531
  }
8458
- try {
8459
- const response = await fetch(url, {
8460
- headers
8461
- });
8462
- if (!response.ok) {
8463
- throw new Error(`Failed to fetch (status code: ${response.status}, url: "${url}")`);
8532
+ for (let i = 0; i <= MAX_REDIRECTS; i++) {
8533
+ if (typeof urlAccessPolicy !== 'undefined' && urlAccessPolicy(url) !== true) {
8534
+ throw new Error(`Access to URL denied by resource access policy: ${url}`);
8535
+ }
8536
+ try {
8537
+ let response = await fetch(url, {
8538
+ headers,
8539
+ redirect: 'manual'
8540
+ });
8541
+
8542
+ // redirect url
8543
+ if (response.status >= 300 && response.status < 400) {
8544
+ let location = response.headers.get('location');
8545
+ if (!location) {
8546
+ throw new Error('Redirect response missing Location header');
8547
+ }
8548
+ url = new URL(location, url).href;
8549
+ continue;
8550
+ }
8551
+
8552
+ // browsers do not support redirect: 'manual'
8553
+ if (response.type === 'opaqueredirect') {
8554
+ response = await fetch(url, {
8555
+ headers
8556
+ });
8557
+ }
8558
+ if (!response.ok) {
8559
+ throw new Error(`Failed to fetch (status code: ${response.status})`);
8560
+ }
8561
+ return response;
8562
+ } catch (error) {
8563
+ throw new Error(`Network request failed (url: "${url}", error: ${error.message})`, {
8564
+ cause: error
8565
+ });
8464
8566
  }
8465
- return await response.arrayBuffer();
8466
- } catch (error) {
8467
- throw new Error(`Network request failed (url: "${url}", error: ${error.message})`, {
8468
- cause: error
8469
- });
8470
8567
  }
8568
+ throw new Error(`Network request failed (url: "${url}", error: Too many redirects)`);
8471
8569
  }
8472
8570
  class URLResolver {
8473
8571
  constructor(fs) {
@@ -8491,10 +8589,15 @@ class URLResolver {
8491
8589
  if (this.fs.existsSync(url)) {
8492
8590
  return; // url was downloaded earlier
8493
8591
  }
8494
- if (typeof this.urlAccessPolicy !== 'undefined' && this.urlAccessPolicy(url) !== true) {
8495
- throw new Error(`Access to URL denied by resource access policy: ${url}`);
8592
+ const response = await fetchUrl(url, headers, this.urlAccessPolicy);
8593
+
8594
+ // validate access policy on redirected url (in browsers, only the final URL is validated)
8595
+ if (response.redirected) {
8596
+ if (typeof this.urlAccessPolicy !== 'undefined' && this.urlAccessPolicy(response.url) !== true) {
8597
+ throw new Error(`Access to URL denied by resource access policy: ${response.url}`);
8598
+ }
8496
8599
  }
8497
- const buffer = await fetchUrl(url, headers);
8600
+ const buffer = await response.arrayBuffer();
8498
8601
  this.fs.writeFileSync(url, buffer);
8499
8602
  }
8500
8603
  // else cannot be resolved
@@ -8520,6 +8623,7 @@ class pdfmake {
8520
8623
  constructor() {
8521
8624
  this.virtualfs = virtual_fs["default"];
8522
8625
  this.urlAccessPolicy = undefined;
8626
+ this.localAccessPolicy = undefined;
8523
8627
  }
8524
8628
 
8525
8629
  /**
@@ -8543,9 +8647,12 @@ class pdfmake {
8543
8647
  if (typeof this.urlAccessPolicy === 'undefined' && isServer) {
8544
8648
  console.warn('No URL access policy defined. Consider using setUrlAccessPolicy() to restrict external resource downloads.');
8545
8649
  }
8650
+ if (typeof this.localAccessPolicy === 'undefined' && isServer) {
8651
+ console.warn('No local access policy defined. Consider using setLocalAccessPolicy() to restrict local file system access.');
8652
+ }
8546
8653
  let urlResolver = new src_URLResolver(this.virtualfs);
8547
8654
  urlResolver.setUrlAccessPolicy(this.urlAccessPolicy);
8548
- let printer = new Printer(this.fonts, this.virtualfs, urlResolver);
8655
+ let printer = new Printer(this.fonts, this.virtualfs, urlResolver, this.localAccessPolicy);
8549
8656
  const pdfDocumentPromise = printer.createPdfKitDocument(docDefinition, options);
8550
8657
  return this._transformToDocument(pdfDocumentPromise);
8551
8658
  }
@@ -8648,7 +8755,7 @@ class OutputDocument {
8648
8755
  }
8649
8756
  /* harmony default export */ const src_OutputDocument = (OutputDocument);
8650
8757
  // EXTERNAL MODULE: ./node_modules/file-saver/dist/FileSaver.min.js
8651
- var FileSaver_min = __webpack_require__(6457);
8758
+ var FileSaver_min = __webpack_require__(6946);
8652
8759
  ;// ./src/browser-extensions/OutputDocumentBrowser.js
8653
8760
 
8654
8761
 
@@ -14553,7 +14660,10 @@ class StateMachine {
14553
14660
  */
14554
14661
 
14555
14662
  apply(str, actions) {
14556
- for (var [start, end, tags] of this.match(str)) {
14663
+ for (var _ref of this.match(str)) {
14664
+ var start = _ref[0];
14665
+ var end = _ref[1];
14666
+ var tags = _ref[2];
14557
14667
  for (var tag of tags) {
14558
14668
  if (typeof actions[tag] === 'function') {
14559
14669
  actions[tag](start, end, str.slice(start, end + 1));
@@ -14680,370 +14790,6 @@ var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
14680
14790
 
14681
14791
  /***/ },
14682
14792
 
14683
- /***/ 336
14684
- (module, __unused_webpack_exports, __webpack_require__) {
14685
-
14686
- "use strict";
14687
- /* provided dependency */ var Buffer = __webpack_require__(783)["Buffer"];
14688
-
14689
-
14690
- __webpack_require__(187);
14691
- /*
14692
- * MIT LICENSE
14693
- * Copyright (c) 2011 Devon Govett
14694
- *
14695
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this
14696
- * software and associated documentation files (the "Software"), to deal in the Software
14697
- * without restriction, including without limitation the rights to use, copy, modify, merge,
14698
- * publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
14699
- * to whom the Software is furnished to do so, subject to the following conditions:
14700
- *
14701
- * The above copyright notice and this permission notice shall be included in all copies or
14702
- * substantial portions of the Software.
14703
- *
14704
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
14705
- * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
14706
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
14707
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
14708
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14709
- */
14710
-
14711
- const fs = __webpack_require__(2416);
14712
- const zlib = __webpack_require__(6729);
14713
- module.exports = class PNG {
14714
- static decode(path, fn) {
14715
- return fs.readFile(path, function (err, file) {
14716
- const png = new PNG(file);
14717
- return png.decode(pixels => fn(pixels));
14718
- });
14719
- }
14720
- static load(path) {
14721
- const file = fs.readFileSync(path);
14722
- return new PNG(file);
14723
- }
14724
- constructor(data) {
14725
- let i;
14726
- this.data = data;
14727
- this.pos = 8; // Skip the default header
14728
-
14729
- this.palette = [];
14730
- this.imgData = [];
14731
- this.transparency = {};
14732
- this.text = {};
14733
- while (true) {
14734
- const chunkSize = this.readUInt32();
14735
- let section = '';
14736
- for (i = 0; i < 4; i++) {
14737
- section += String.fromCharCode(this.data[this.pos++]);
14738
- }
14739
- switch (section) {
14740
- case 'IHDR':
14741
- // we can grab interesting values from here (like width, height, etc)
14742
- this.width = this.readUInt32();
14743
- this.height = this.readUInt32();
14744
- this.bits = this.data[this.pos++];
14745
- this.colorType = this.data[this.pos++];
14746
- this.compressionMethod = this.data[this.pos++];
14747
- this.filterMethod = this.data[this.pos++];
14748
- this.interlaceMethod = this.data[this.pos++];
14749
- break;
14750
- case 'PLTE':
14751
- this.palette = this.read(chunkSize);
14752
- break;
14753
- case 'IDAT':
14754
- for (i = 0; i < chunkSize; i++) {
14755
- this.imgData.push(this.data[this.pos++]);
14756
- }
14757
- break;
14758
- case 'tRNS':
14759
- // This chunk can only occur once and it must occur after the
14760
- // PLTE chunk and before the IDAT chunk.
14761
- this.transparency = {};
14762
- switch (this.colorType) {
14763
- case 3:
14764
- // Indexed color, RGB. Each byte in this chunk is an alpha for
14765
- // the palette index in the PLTE ("palette") chunk up until the
14766
- // last non-opaque entry. Set up an array, stretching over all
14767
- // palette entries which will be 0 (opaque) or 1 (transparent).
14768
- this.transparency.indexed = this.read(chunkSize);
14769
- var short = 255 - this.transparency.indexed.length;
14770
- if (short > 0) {
14771
- for (i = 0; i < short; i++) {
14772
- this.transparency.indexed.push(255);
14773
- }
14774
- }
14775
- break;
14776
- case 0:
14777
- // Greyscale. Corresponding to entries in the PLTE chunk.
14778
- // Grey is two bytes, range 0 .. (2 ^ bit-depth) - 1
14779
- this.transparency.grayscale = this.read(chunkSize)[0];
14780
- break;
14781
- case 2:
14782
- // True color with proper alpha channel.
14783
- this.transparency.rgb = this.read(chunkSize);
14784
- break;
14785
- }
14786
- break;
14787
- case 'tEXt':
14788
- var text = this.read(chunkSize);
14789
- var index = text.indexOf(0);
14790
- var key = String.fromCharCode.apply(String, text.slice(0, index));
14791
- this.text[key] = String.fromCharCode.apply(String, text.slice(index + 1));
14792
- break;
14793
- case 'IEND':
14794
- // we've got everything we need!
14795
- switch (this.colorType) {
14796
- case 0:
14797
- case 3:
14798
- case 4:
14799
- this.colors = 1;
14800
- break;
14801
- case 2:
14802
- case 6:
14803
- this.colors = 3;
14804
- break;
14805
- }
14806
- this.hasAlphaChannel = [4, 6].includes(this.colorType);
14807
- var colors = this.colors + (this.hasAlphaChannel ? 1 : 0);
14808
- this.pixelBitlength = this.bits * colors;
14809
- switch (this.colors) {
14810
- case 1:
14811
- this.colorSpace = 'DeviceGray';
14812
- break;
14813
- case 3:
14814
- this.colorSpace = 'DeviceRGB';
14815
- break;
14816
- }
14817
- this.imgData = new Buffer(this.imgData);
14818
- return;
14819
- // removed by dead control flow
14820
-
14821
- default:
14822
- // unknown (or unimportant) section, skip it
14823
- this.pos += chunkSize;
14824
- }
14825
- this.pos += 4; // Skip the CRC
14826
-
14827
- if (this.pos > this.data.length) {
14828
- throw new Error('Incomplete or corrupt PNG file');
14829
- }
14830
- }
14831
- }
14832
- read(bytes) {
14833
- const result = new Array(bytes);
14834
- for (let i = 0; i < bytes; i++) {
14835
- result[i] = this.data[this.pos++];
14836
- }
14837
- return result;
14838
- }
14839
- readUInt32() {
14840
- const b1 = this.data[this.pos++] << 24;
14841
- const b2 = this.data[this.pos++] << 16;
14842
- const b3 = this.data[this.pos++] << 8;
14843
- const b4 = this.data[this.pos++];
14844
- return b1 | b2 | b3 | b4;
14845
- }
14846
- readUInt16() {
14847
- const b1 = this.data[this.pos++] << 8;
14848
- const b2 = this.data[this.pos++];
14849
- return b1 | b2;
14850
- }
14851
- decodePixels(fn) {
14852
- return zlib.inflate(this.imgData, (err, data) => {
14853
- if (err) {
14854
- throw err;
14855
- }
14856
- const {
14857
- width,
14858
- height
14859
- } = this;
14860
- const pixelBytes = this.pixelBitlength / 8;
14861
- const pixels = new Buffer(width * height * pixelBytes);
14862
- const {
14863
- length
14864
- } = data;
14865
- let pos = 0;
14866
- function pass(x0, y0, dx, dy, singlePass) {
14867
- if (singlePass === void 0) {
14868
- singlePass = false;
14869
- }
14870
- const w = Math.ceil((width - x0) / dx);
14871
- const h = Math.ceil((height - y0) / dy);
14872
- const scanlineLength = pixelBytes * w;
14873
- const buffer = singlePass ? pixels : new Buffer(scanlineLength * h);
14874
- let row = 0;
14875
- let c = 0;
14876
- while (row < h && pos < length) {
14877
- var byte, col, i, left, upper;
14878
- switch (data[pos++]) {
14879
- case 0:
14880
- // None
14881
- for (i = 0; i < scanlineLength; i++) {
14882
- buffer[c++] = data[pos++];
14883
- }
14884
- break;
14885
- case 1:
14886
- // Sub
14887
- for (i = 0; i < scanlineLength; i++) {
14888
- byte = data[pos++];
14889
- left = i < pixelBytes ? 0 : buffer[c - pixelBytes];
14890
- buffer[c++] = (byte + left) % 256;
14891
- }
14892
- break;
14893
- case 2:
14894
- // Up
14895
- for (i = 0; i < scanlineLength; i++) {
14896
- byte = data[pos++];
14897
- col = (i - i % pixelBytes) / pixelBytes;
14898
- upper = row && buffer[(row - 1) * scanlineLength + col * pixelBytes + i % pixelBytes];
14899
- buffer[c++] = (upper + byte) % 256;
14900
- }
14901
- break;
14902
- case 3:
14903
- // Average
14904
- for (i = 0; i < scanlineLength; i++) {
14905
- byte = data[pos++];
14906
- col = (i - i % pixelBytes) / pixelBytes;
14907
- left = i < pixelBytes ? 0 : buffer[c - pixelBytes];
14908
- upper = row && buffer[(row - 1) * scanlineLength + col * pixelBytes + i % pixelBytes];
14909
- buffer[c++] = (byte + Math.floor((left + upper) / 2)) % 256;
14910
- }
14911
- break;
14912
- case 4:
14913
- // Paeth
14914
- for (i = 0; i < scanlineLength; i++) {
14915
- var paeth, upperLeft;
14916
- byte = data[pos++];
14917
- col = (i - i % pixelBytes) / pixelBytes;
14918
- left = i < pixelBytes ? 0 : buffer[c - pixelBytes];
14919
- if (row === 0) {
14920
- upper = upperLeft = 0;
14921
- } else {
14922
- upper = buffer[(row - 1) * scanlineLength + col * pixelBytes + i % pixelBytes];
14923
- upperLeft = col && buffer[(row - 1) * scanlineLength + (col - 1) * pixelBytes + i % pixelBytes];
14924
- }
14925
- const p = left + upper - upperLeft;
14926
- const pa = Math.abs(p - left);
14927
- const pb = Math.abs(p - upper);
14928
- const pc = Math.abs(p - upperLeft);
14929
- if (pa <= pb && pa <= pc) {
14930
- paeth = left;
14931
- } else if (pb <= pc) {
14932
- paeth = upper;
14933
- } else {
14934
- paeth = upperLeft;
14935
- }
14936
- buffer[c++] = (byte + paeth) % 256;
14937
- }
14938
- break;
14939
- default:
14940
- throw new Error(`Invalid filter algorithm: ${data[pos - 1]}`);
14941
- }
14942
- if (!singlePass) {
14943
- let pixelsPos = ((y0 + row * dy) * width + x0) * pixelBytes;
14944
- let bufferPos = row * scanlineLength;
14945
- for (i = 0; i < w; i++) {
14946
- for (let j = 0; j < pixelBytes; j++) pixels[pixelsPos++] = buffer[bufferPos++];
14947
- pixelsPos += (dx - 1) * pixelBytes;
14948
- }
14949
- }
14950
- row++;
14951
- }
14952
- }
14953
- if (this.interlaceMethod === 1) {
14954
- /*
14955
- 1 6 4 6 2 6 4 6
14956
- 7 7 7 7 7 7 7 7
14957
- 5 6 5 6 5 6 5 6
14958
- 7 7 7 7 7 7 7 7
14959
- 3 6 4 6 3 6 4 6
14960
- 7 7 7 7 7 7 7 7
14961
- 5 6 5 6 5 6 5 6
14962
- 7 7 7 7 7 7 7 7
14963
- */
14964
- pass(0, 0, 8, 8); // 1
14965
- pass(4, 0, 8, 8); // 2
14966
- pass(0, 4, 4, 8); // 3
14967
- pass(2, 0, 4, 4); // 4
14968
- pass(0, 2, 2, 4); // 5
14969
- pass(1, 0, 2, 2); // 6
14970
- pass(0, 1, 1, 2); // 7
14971
- } else {
14972
- pass(0, 0, 1, 1, true);
14973
- }
14974
- return fn(pixels);
14975
- });
14976
- }
14977
- decodePalette() {
14978
- const {
14979
- palette
14980
- } = this;
14981
- const {
14982
- length
14983
- } = palette;
14984
- const transparency = this.transparency.indexed || [];
14985
- const ret = new Buffer(transparency.length + length);
14986
- let pos = 0;
14987
- let c = 0;
14988
- for (let i = 0; i < length; i += 3) {
14989
- var left;
14990
- ret[pos++] = palette[i];
14991
- ret[pos++] = palette[i + 1];
14992
- ret[pos++] = palette[i + 2];
14993
- ret[pos++] = (left = transparency[c++]) != null ? left : 255;
14994
- }
14995
- return ret;
14996
- }
14997
- copyToImageData(imageData, pixels) {
14998
- let j, k;
14999
- let {
15000
- colors
15001
- } = this;
15002
- let palette = null;
15003
- let alpha = this.hasAlphaChannel;
15004
- if (this.palette.length) {
15005
- palette = this._decodedPalette || (this._decodedPalette = this.decodePalette());
15006
- colors = 4;
15007
- alpha = true;
15008
- }
15009
- const data = imageData.data || imageData;
15010
- const {
15011
- length
15012
- } = data;
15013
- const input = palette || pixels;
15014
- let i = j = 0;
15015
- if (colors === 1) {
15016
- while (i < length) {
15017
- k = palette ? pixels[i / 4] * 4 : j;
15018
- const v = input[k++];
15019
- data[i++] = v;
15020
- data[i++] = v;
15021
- data[i++] = v;
15022
- data[i++] = alpha ? input[k++] : 255;
15023
- j = k;
15024
- }
15025
- } else {
15026
- while (i < length) {
15027
- k = palette ? pixels[i / 4] * 4 : j;
15028
- data[i++] = input[k++];
15029
- data[i++] = input[k++];
15030
- data[i++] = input[k++];
15031
- data[i++] = alpha ? input[k++] : 255;
15032
- j = k;
15033
- }
15034
- }
15035
- }
15036
- decode(fn) {
15037
- const ret = new Buffer(this.width * this.height * 4);
15038
- return this.decodePixels(pixels => {
15039
- this.copyToImageData(ret, pixels);
15040
- return fn(ret);
15041
- });
15042
- }
15043
- };
15044
-
15045
- /***/ },
15046
-
15047
14793
  /***/ 182
15048
14794
  (module, __unused_webpack_exports, __webpack_require__) {
15049
14795
 
@@ -15373,9 +15119,8 @@ __webpack_require__(8376);
15373
15119
  __webpack_require__(6401);
15374
15120
  __webpack_require__(2017);
15375
15121
  const inflate = __webpack_require__(3483);
15376
- const {
15377
- swap32LE
15378
- } = __webpack_require__(6016);
15122
+ const _require = __webpack_require__(6016),
15123
+ swap32LE = _require.swap32LE;
15379
15124
 
15380
15125
  // Shift size for getting the index-1 table offset.
15381
15126
  const SHIFT_1 = 6 + 5;
@@ -15466,11 +15211,10 @@ class UnicodeTrie {
15466
15211
  this.data = new Uint32Array(data.buffer);
15467
15212
  } else {
15468
15213
  // pre-parsed data
15469
- ({
15470
- data: this.data,
15471
- highStart: this.highStart,
15472
- errorValue: this.errorValue
15473
- } = data);
15214
+ var _data = data;
15215
+ this.data = _data.data;
15216
+ this.highStart = _data.highStart;
15217
+ this.errorValue = _data.errorValue;
15474
15218
  }
15475
15219
  }
15476
15220
  get(codePoint) {
@@ -15540,7 +15284,7 @@ module.exports = {
15540
15284
 
15541
15285
  /***/ },
15542
15286
 
15543
- /***/ 5167
15287
+ /***/ 6649
15544
15288
  (__unused_webpack_module, exports, __webpack_require__) {
15545
15289
 
15546
15290
  "use strict";
@@ -15566,7 +15310,7 @@ var _aes = __webpack_require__(2651);
15566
15310
  var fontkit = _interopRequireWildcard(__webpack_require__(1715));
15567
15311
  var _events = __webpack_require__(4785);
15568
15312
  var _linebreak = _interopRequireDefault(__webpack_require__(2532));
15569
- var _pngJs = _interopRequireDefault(__webpack_require__(336));
15313
+ var _pngJs = _interopRequireDefault(__webpack_require__(381));
15570
15314
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
15571
15315
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15572
15316
  var fs = __webpack_require__(2416);
@@ -16035,13 +15779,17 @@ function rc4(data, key) {
16035
15779
  let j = 0;
16036
15780
  for (let i = 0; i < 256; i++) {
16037
15781
  j = j + s[i] + key[i % key.length] & 0xff;
16038
- [s[i], s[j]] = [s[j], s[i]];
15782
+ var _ref3 = [s[j], s[i]];
15783
+ s[i] = _ref3[0];
15784
+ s[j] = _ref3[1];
16039
15785
  }
16040
15786
  const output = new Uint8Array(data.length);
16041
15787
  for (let i = 0, j = 0, k = 0; k < data.length; k++) {
16042
15788
  i = i + 1 & 0xff;
16043
15789
  j = j + s[i] & 0xff;
16044
- [s[i], s[j]] = [s[j], s[i]];
15790
+ var _ref4 = [s[j], s[i]];
15791
+ s[i] = _ref4[0];
15792
+ s[j] = _ref4[1];
16045
15793
  output[k] = data[k] ^ s[s[i] + s[j] & 0xff];
16046
15794
  }
16047
15795
  return output;
@@ -16480,9 +16228,7 @@ function processPasswordR5() {
16480
16228
  return out;
16481
16229
  }
16482
16230
  const PASSWORD_PADDING = [0x28, 0xbf, 0x4e, 0x5e, 0x4e, 0x75, 0x8a, 0x41, 0x64, 0x00, 0x4e, 0x56, 0xff, 0xfa, 0x01, 0x08, 0x2e, 0x2e, 0x00, 0xb6, 0xd0, 0x68, 0x3e, 0x80, 0x2f, 0x0c, 0xa9, 0xfe, 0x64, 0x53, 0x69, 0x7a];
16483
- const {
16484
- number: number$2
16485
- } = PDFObject;
16231
+ const number$2 = PDFObject.number;
16486
16232
  class PDFGradient$1 {
16487
16233
  constructor(doc) {
16488
16234
  this.doc = doc;
@@ -16631,8 +16377,20 @@ class PDFGradient$1 {
16631
16377
  return pattern;
16632
16378
  }
16633
16379
  apply(stroke) {
16634
- const [m0, m1, m2, m3, m4, m5] = this.doc._ctm;
16635
- const [m11, m12, m21, m22, dx, dy] = this.transform;
16380
+ const _this$doc$_ctm = this.doc._ctm,
16381
+ m0 = _this$doc$_ctm[0],
16382
+ m1 = _this$doc$_ctm[1],
16383
+ m2 = _this$doc$_ctm[2],
16384
+ m3 = _this$doc$_ctm[3],
16385
+ m4 = _this$doc$_ctm[4],
16386
+ m5 = _this$doc$_ctm[5];
16387
+ const _this$transform = this.transform,
16388
+ m11 = _this$transform[0],
16389
+ m12 = _this$transform[1],
16390
+ m21 = _this$transform[2],
16391
+ m22 = _this$transform[3],
16392
+ dx = _this$transform[4],
16393
+ dy = _this$transform[5];
16636
16394
  const m = [m0 * m11 + m2 * m12, m1 * m11 + m3 * m12, m0 * m21 + m2 * m22, m1 * m21 + m3 * m22, m0 * dx + m2 * dy + m4, m1 * dx + m3 * dy + m5];
16637
16395
  if (!this.embedded || m.join(' ') !== this.matrix.join(' ')) {
16638
16396
  this.embed(m);
@@ -16704,8 +16462,19 @@ class PDFTilingPattern$1 {
16704
16462
  createPattern() {
16705
16463
  const resources = this.doc.ref();
16706
16464
  resources.end();
16707
- const [m0, m1, m2, m3, m4, m5] = this.doc._ctm;
16708
- const [m11, m12, m21, m22, dx, dy] = [1, 0, 0, 1, 0, 0];
16465
+ const _this$doc$_ctm2 = this.doc._ctm,
16466
+ m0 = _this$doc$_ctm2[0],
16467
+ m1 = _this$doc$_ctm2[1],
16468
+ m2 = _this$doc$_ctm2[2],
16469
+ m3 = _this$doc$_ctm2[3],
16470
+ m4 = _this$doc$_ctm2[4],
16471
+ m5 = _this$doc$_ctm2[5];
16472
+ const m11 = 1,
16473
+ m12 = 0,
16474
+ m21 = 0,
16475
+ m22 = 1,
16476
+ dx = 0,
16477
+ dy = 0;
16709
16478
  const m = [m0 * m11 + m2 * m12, m1 * m11 + m3 * m12, m0 * m21 + m2 * m22, m1 * m21 + m3 * m22, m0 * dx + m2 * dy + m4, m1 * dx + m3 * dy + m5];
16710
16479
  const pattern = this.doc.ref({
16711
16480
  Type: 'Pattern',
@@ -16757,14 +16526,10 @@ class PDFTilingPattern$1 {
16757
16526
  var pattern = {
16758
16527
  PDFTilingPattern: PDFTilingPattern$1
16759
16528
  };
16760
- const {
16761
- PDFGradient,
16762
- PDFLinearGradient,
16763
- PDFRadialGradient
16764
- } = Gradient;
16765
- const {
16766
- PDFTilingPattern
16767
- } = pattern;
16529
+ const PDFGradient = Gradient.PDFGradient,
16530
+ PDFLinearGradient = Gradient.PDFLinearGradient,
16531
+ PDFRadialGradient = Gradient.PDFRadialGradient;
16532
+ const PDFTilingPattern = pattern.PDFTilingPattern;
16768
16533
  var ColorMixin = {
16769
16534
  initColor() {
16770
16535
  this.spotColors = {};
@@ -16873,7 +16638,9 @@ var ColorMixin = {
16873
16638
  }
16874
16639
  const key = `${fillOpacity}_${strokeOpacity}`;
16875
16640
  if (this._opacityRegistry[key]) {
16876
- [dictionary, name] = this._opacityRegistry[key];
16641
+ var _this$_opacityRegistr = this._opacityRegistry[key];
16642
+ dictionary = _this$_opacityRegistr[0];
16643
+ name = _this$_opacityRegistr[1];
16877
16644
  } else {
16878
16645
  dictionary = {
16879
16646
  Type: 'ExtGState'
@@ -17205,11 +16972,15 @@ const parse = function (path) {
17205
16972
  const position = args.length;
17206
16973
  if (position === 0 || position === 1) {
17207
16974
  if (c !== '+' && c !== '-') {
17208
- [newCursor, number] = readNumber(path, i);
16975
+ var _readNumber = readNumber(path, i);
16976
+ newCursor = _readNumber[0];
16977
+ number = _readNumber[1];
17209
16978
  }
17210
16979
  }
17211
16980
  if (position === 2 || position === 5 || position === 6) {
17212
- [newCursor, number] = readNumber(path, i);
16981
+ var _readNumber2 = readNumber(path, i);
16982
+ newCursor = _readNumber2[0];
16983
+ number = _readNumber2[1];
17213
16984
  }
17214
16985
  if (position === 3 || position === 4) {
17215
16986
  if (c === '0') {
@@ -17220,7 +16991,9 @@ const parse = function (path) {
17220
16991
  }
17221
16992
  }
17222
16993
  } else {
17223
- [newCursor, number] = readNumber(path, i);
16994
+ var _readNumber3 = readNumber(path, i);
16995
+ newCursor = _readNumber3[0];
16996
+ number = _readNumber3[1];
17224
16997
  }
17225
16998
  if (number == null) {
17226
16999
  return pathData;
@@ -17403,7 +17176,13 @@ const runners = {
17403
17176
  }
17404
17177
  };
17405
17178
  const solveArc = function (doc, x, y, coords) {
17406
- const [rx, ry, rot, large, sweep, ex, ey] = coords;
17179
+ const rx = coords[0],
17180
+ ry = coords[1],
17181
+ rot = coords[2],
17182
+ large = coords[3],
17183
+ sweep = coords[4],
17184
+ ex = coords[5],
17185
+ ey = coords[6];
17407
17186
  const segs = arcToSegments(ex, ey, rx, ry, large, sweep, rot, x, y);
17408
17187
  for (let seg of segs) {
17409
17188
  const bez = segmentToBezier(...seg);
@@ -17481,9 +17260,7 @@ class SVGPath {
17481
17260
  apply(commands, doc);
17482
17261
  }
17483
17262
  }
17484
- const {
17485
- number: number$1
17486
- } = PDFObject;
17263
+ const number$1 = PDFObject.number;
17487
17264
  const KAPPA = 4.0 * ((Math.sqrt(2) - 1.0) / 3.0);
17488
17265
  var VectorMixin = {
17489
17266
  initVector() {
@@ -17698,7 +17475,12 @@ var VectorMixin = {
17698
17475
  return this;
17699
17476
  }
17700
17477
  const m = this._ctm;
17701
- const [m0, m1, m2, m3, m4, m5] = m;
17478
+ const m0 = m[0],
17479
+ m1 = m[1],
17480
+ m2 = m[2],
17481
+ m3 = m[3],
17482
+ m4 = m[4],
17483
+ m5 = m[5];
17702
17484
  m[0] = m0 * m11 + m2 * m12;
17703
17485
  m[1] = m1 * m11 + m3 * m12;
17704
17486
  m[2] = m0 * m21 + m2 * m22;
@@ -17719,7 +17501,9 @@ var VectorMixin = {
17719
17501
  const sin = Math.sin(rad);
17720
17502
  let x = y = 0;
17721
17503
  if (options.origin != null) {
17722
- [x, y] = options.origin;
17504
+ var _options$origin = options.origin;
17505
+ x = _options$origin[0];
17506
+ y = _options$origin[1];
17723
17507
  const x1 = x * cos - y * sin;
17724
17508
  const y1 = x * sin + y * cos;
17725
17509
  x -= x1;
@@ -17739,7 +17523,9 @@ var VectorMixin = {
17739
17523
  }
17740
17524
  let x = y = 0;
17741
17525
  if (options.origin != null) {
17742
- [x, y] = options.origin;
17526
+ var _options$origin2 = options.origin;
17527
+ x = _options$origin2[0];
17528
+ y = _options$origin2[1];
17743
17529
  x -= xFactor * x;
17744
17530
  y -= yFactor * y;
17745
17531
  }
@@ -18018,14 +17804,13 @@ class StandardFont extends PDFFont {
18018
17804
  this.name = name;
18019
17805
  this.id = id;
18020
17806
  this.font = new AFMFont(STANDARD_FONTS[this.name]());
18021
- ({
18022
- ascender: this.ascender,
18023
- descender: this.descender,
18024
- bbox: this.bbox,
18025
- lineGap: this.lineGap,
18026
- xHeight: this.xHeight,
18027
- capHeight: this.capHeight
18028
- } = this.font);
17807
+ var _this$font = this.font;
17808
+ this.ascender = _this$font.ascender;
17809
+ this.descender = _this$font.descender;
17810
+ this.bbox = _this$font.bbox;
17811
+ this.lineGap = _this$font.lineGap;
17812
+ this.xHeight = _this$font.xHeight;
17813
+ this.capHeight = _this$font.capHeight;
18029
17814
  }
18030
17815
  embed() {
18031
17816
  this.dictionary.data = {
@@ -18144,10 +17929,9 @@ class EmbeddedFont extends PDFFont {
18144
17929
  };
18145
17930
  }
18146
17931
  encode(text, features) {
18147
- const {
18148
- glyphs,
18149
- positions
18150
- } = this.layout(text, features);
17932
+ const _this$layout = this.layout(text, features),
17933
+ glyphs = _this$layout.glyphs,
17934
+ positions = _this$layout.positions;
18151
17935
  const res = [];
18152
17936
  for (let i = 0; i < glyphs.length; i++) {
18153
17937
  const glyph = glyphs[i];
@@ -18191,9 +17975,7 @@ class EmbeddedFont extends PDFFont {
18191
17975
  }
18192
17976
  const tag = [1, 2, 3, 4, 5, 6].map(i => String.fromCharCode((this.id.charCodeAt(i) || 73) + 17)).join('');
18193
17977
  const name = tag + '+' + this.font.postscriptName?.replaceAll(' ', '_');
18194
- const {
18195
- bbox
18196
- } = this.font;
17978
+ const bbox = this.font.bbox;
18197
17979
  const descriptor = this.document.ref({
18198
17980
  Type: 'FontDescriptor',
18199
17981
  FontName: name,
@@ -18349,10 +18131,9 @@ var FontsMixin = {
18349
18131
  }
18350
18132
  if (typeof src === 'string' && this._registeredFonts[src]) {
18351
18133
  cacheKey = src;
18352
- ({
18353
- src,
18354
- family
18355
- } = this._registeredFonts[src]);
18134
+ var _this$_registeredFont = this._registeredFonts[src];
18135
+ src = _this$_registeredFont.src;
18136
+ family = _this$_registeredFont.family;
18356
18137
  } else {
18357
18138
  cacheKey = family || src;
18358
18139
  if (typeof cacheKey !== 'string') {
@@ -18504,9 +18285,7 @@ class LineWrapper extends _events.EventEmitter {
18504
18285
  });
18505
18286
  });
18506
18287
  this.on('lastLine', options => {
18507
- const {
18508
- align
18509
- } = options;
18288
+ const align = options.align;
18510
18289
  if (align === 'justify') {
18511
18290
  options.align = 'left';
18512
18291
  }
@@ -18604,16 +18383,12 @@ class LineWrapper extends _events.EventEmitter {
18604
18383
  let textWidth = 0;
18605
18384
  let wc = 0;
18606
18385
  let lc = 0;
18607
- let {
18608
- y
18609
- } = this.document;
18386
+ let y = this.document.y;
18610
18387
  const emitLine = () => {
18611
18388
  options.textWidth = textWidth + this.wordSpacing * (wc - 1);
18612
18389
  options.wordCount = wc;
18613
18390
  options.lineWidth = this.lineWidth;
18614
- ({
18615
- y
18616
- } = this.document);
18391
+ y = this.document.y;
18617
18392
  this.emit('line', buffer, options, this);
18618
18393
  return lc++;
18619
18394
  };
@@ -18727,9 +18502,7 @@ class LineWrapper extends _events.EventEmitter {
18727
18502
  return true;
18728
18503
  }
18729
18504
  }
18730
- const {
18731
- number
18732
- } = PDFObject;
18505
+ const number = PDFObject.number;
18733
18506
  function formatListLabel(n, listType) {
18734
18507
  if (listType === 'numbered') {
18735
18508
  return `${n}.`;
@@ -18810,10 +18583,8 @@ var TextMixin = {
18810
18583
  },
18811
18584
  boundsOfString(string, x, y, options) {
18812
18585
  options = this._initOptions(x, y, options);
18813
- ({
18814
- x,
18815
- y
18816
- } = this);
18586
+ x = this.x;
18587
+ y = this.y;
18817
18588
  const lineGap = options.lineGap ?? this._lineGap ?? 0;
18818
18589
  const lineHeight = this.currentLineHeight(true) + lineGap;
18819
18590
  let contentWidth = 0;
@@ -18901,10 +18672,8 @@ var TextMixin = {
18901
18672
  };
18902
18673
  },
18903
18674
  heightOfString(text, options) {
18904
- const {
18905
- x,
18906
- y
18907
- } = this;
18675
+ const x = this.x,
18676
+ y = this.y;
18908
18677
  options = this._initOptions(options);
18909
18678
  options.height = Infinity;
18910
18679
  const lineGap = options.lineGap || this._lineGap || 0;
@@ -18954,9 +18723,14 @@ var TextMixin = {
18954
18723
  let item, itemType, labelType, bodyType;
18955
18724
  if (options.structParent) {
18956
18725
  if (options.structTypes) {
18957
- [itemType, labelType, bodyType] = options.structTypes;
18726
+ var _options$structTypes = options.structTypes;
18727
+ itemType = _options$structTypes[0];
18728
+ labelType = _options$structTypes[1];
18729
+ bodyType = _options$structTypes[2];
18958
18730
  } else {
18959
- [itemType, labelType, bodyType] = ['LI', 'Lbl', 'LBody'];
18731
+ itemType = 'LI';
18732
+ labelType = 'Lbl';
18733
+ bodyType = 'LBody';
18960
18734
  }
18961
18735
  }
18962
18736
  if (itemType) {
@@ -19198,7 +18972,9 @@ var TextMixin = {
19198
18972
  encoded = [];
19199
18973
  positions = [];
19200
18974
  for (let word of words) {
19201
- const [encodedWord, positionsWord] = this._font.encode(word, options.features);
18975
+ const _this$_font$encode = this._font.encode(word, options.features),
18976
+ encodedWord = _this$_font$encode[0],
18977
+ positionsWord = _this$_font$encode[1];
19202
18978
  encoded = encoded.concat(encodedWord);
19203
18979
  positions = positions.concat(positionsWord);
19204
18980
  const space = {};
@@ -19211,7 +18987,9 @@ var TextMixin = {
19211
18987
  positions[positions.length - 1] = space;
19212
18988
  }
19213
18989
  } else {
19214
- [encoded, positions] = this._font.encode(text, options.features);
18990
+ var _this$_font$encode2 = this._font.encode(text, options.features);
18991
+ encoded = _this$_font$encode2[0];
18992
+ positions = _this$_font$encode2[1];
19215
18993
  }
19216
18994
  const scale = this._fontSize / 1000;
19217
18995
  const commands = [];
@@ -19401,9 +19179,7 @@ class PNGImage {
19401
19179
  const val = this.image.transparency.grayscale;
19402
19180
  this.obj.data['Mask'] = [val, val];
19403
19181
  } else if (this.image.transparency.rgb) {
19404
- const {
19405
- rgb
19406
- } = this.image.transparency;
19182
+ const rgb = this.image.transparency.rgb;
19407
19183
  const mask = [];
19408
19184
  for (let x of rgb) {
19409
19185
  mask.push(x, x);
@@ -19545,12 +19321,13 @@ var ImagesMixin = {
19545
19321
  if (this.page.xobjects[image.label] == null) {
19546
19322
  this.page.xobjects[image.label] = image.obj;
19547
19323
  }
19548
- let {
19549
- width,
19550
- height
19551
- } = image;
19324
+ let _image = image,
19325
+ width = _image.width,
19326
+ height = _image.height;
19552
19327
  if (!ignoreOrientation && image.orientation > 4) {
19553
- [width, height] = [height, width];
19328
+ var _ref5 = [height, width];
19329
+ width = _ref5[0];
19330
+ height = _ref5[1];
19554
19331
  }
19555
19332
  let w = options.width || width;
19556
19333
  let h = options.height || height;
@@ -19566,7 +19343,9 @@ var ImagesMixin = {
19566
19343
  w = width * options.scale;
19567
19344
  h = height * options.scale;
19568
19345
  } else if (options.fit) {
19569
- [bw, bh] = options.fit;
19346
+ var _options$fit = options.fit;
19347
+ bw = _options$fit[0];
19348
+ bh = _options$fit[1];
19570
19349
  bp = bw / bh;
19571
19350
  ip = width / height;
19572
19351
  if (ip > bp) {
@@ -19577,7 +19356,9 @@ var ImagesMixin = {
19577
19356
  w = bh * ip;
19578
19357
  }
19579
19358
  } else if (options.cover) {
19580
- [bw, bh] = options.cover;
19359
+ var _options$cover = options.cover;
19360
+ bw = _options$cover[0];
19361
+ bh = _options$cover[1];
19581
19362
  bp = bw / bh;
19582
19363
  ip = width / height;
19583
19364
  if (ip > bp) {
@@ -19788,7 +19569,11 @@ var AnnotationsMixin = {
19788
19569
  },
19789
19570
  _markup(x, y, w, h) {
19790
19571
  let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
19791
- const [x1, y1, x2, y2] = this._convertRect(x, y, w, h);
19572
+ const _this$_convertRect = this._convertRect(x, y, w, h),
19573
+ x1 = _this$_convertRect[0],
19574
+ y1 = _this$_convertRect[1],
19575
+ x2 = _this$_convertRect[2],
19576
+ y2 = _this$_convertRect[3];
19792
19577
  options.QuadPoints = [x1, y2, x2, y2, x1, y1, x2, y1];
19793
19578
  options.Contents = new String();
19794
19579
  return this.annotate(x, y, w, h, options);
@@ -19856,7 +19641,13 @@ var AnnotationsMixin = {
19856
19641
  let y2 = y1;
19857
19642
  y1 += h;
19858
19643
  let x2 = x1 + w;
19859
- const [m0, m1, m2, m3, m4, m5] = this._ctm;
19644
+ const _this$_ctm = this._ctm,
19645
+ m0 = _this$_ctm[0],
19646
+ m1 = _this$_ctm[1],
19647
+ m2 = _this$_ctm[2],
19648
+ m3 = _this$_ctm[3],
19649
+ m4 = _this$_ctm[4],
19650
+ m5 = _this$_ctm[5];
19860
19651
  x1 = m0 * x1 + m2 * y1 + m4;
19861
19652
  y1 = m1 * x1 + m3 * y1 + m5;
19862
19653
  x2 = m0 * x2 + m2 * y2 + m4;
@@ -20016,10 +19807,8 @@ class PDFStructureElement {
20016
19807
  }
20017
19808
  _addContentToParentTree(content) {
20018
19809
  content.refs.forEach(_ref => {
20019
- let {
20020
- pageRef,
20021
- mcid
20022
- } = _ref;
19810
+ let pageRef = _ref.pageRef,
19811
+ mcid = _ref.mcid;
20023
19812
  const pageStructParents = this.document.getStructParentTree().get(pageRef.data.StructParents);
20024
19813
  pageStructParents[mcid] = this.dictionary;
20025
19814
  });
@@ -20107,10 +19896,8 @@ class PDFStructureElement {
20107
19896
  }
20108
19897
  if (child instanceof PDFStructureContent) {
20109
19898
  child.refs.forEach(_ref2 => {
20110
- let {
20111
- pageRef,
20112
- mcid
20113
- } = _ref2;
19899
+ let pageRef = _ref2.pageRef,
19900
+ mcid = _ref2.mcid;
20114
19901
  if (!this.dictionary.data.Pg) {
20115
19902
  this.dictionary.data.Pg = pageRef;
20116
19903
  }
@@ -20673,10 +20460,9 @@ var AttachmentsMixin = {
20673
20460
  if (!data) {
20674
20461
  throw new Error(`Could not read contents of file at filepath ${src}`);
20675
20462
  }
20676
- const {
20677
- birthtime,
20678
- ctime
20679
- } = fs.statSync(src);
20463
+ const _fs$statSync = fs.statSync(src),
20464
+ birthtime = _fs$statSync.birthtime,
20465
+ ctime = _fs$statSync.ctime;
20680
20466
  refBody.Params.CreationDate = birthtime;
20681
20467
  refBody.Params.ModDate = ctime;
20682
20468
  }
@@ -20872,11 +20658,11 @@ function normalizedDefaultStyle(defaultStyleInternal) {
20872
20658
  text: defaultStyle
20873
20659
  };
20874
20660
  const defaultRowStyle = Object.fromEntries(Object.entries(defaultStyle).filter(_ref => {
20875
- let [k] = _ref;
20661
+ let k = _ref[0];
20876
20662
  return ROW_FIELDS.includes(k);
20877
20663
  }));
20878
20664
  const defaultColStyle = Object.fromEntries(Object.entries(defaultStyle).filter(_ref2 => {
20879
- let [k] = _ref2;
20665
+ let k = _ref2[0];
20880
20666
  return COLUMN_FIELDS.includes(k);
20881
20667
  }));
20882
20668
  defaultStyle.padding = normalizeSides(defaultStyle.padding);
@@ -20950,11 +20736,10 @@ function normalizeTable() {
20950
20736
  y: doc.sizeToPoint(opts.position?.y, doc.y)
20951
20737
  };
20952
20738
  this._maxWidth = doc.sizeToPoint(opts.maxWidth, doc.page.width - doc.page.margins.right - this._position.x);
20953
- const {
20954
- defaultStyle,
20955
- defaultColStyle,
20956
- defaultRowStyle
20957
- } = normalizedDefaultStyle(opts.defaultStyle);
20739
+ const _normalizedDefaultSty = normalizedDefaultStyle(opts.defaultStyle),
20740
+ defaultStyle = _normalizedDefaultSty.defaultStyle,
20741
+ defaultColStyle = _normalizedDefaultSty.defaultColStyle,
20742
+ defaultRowStyle = _normalizedDefaultSty.defaultRowStyle;
20958
20743
  this._defaultStyle = defaultStyle;
20959
20744
  let colStyle;
20960
20745
  if (opts.columnStyles) {
@@ -21151,10 +20936,9 @@ function measureCell(cell, rowHeight) {
21151
20936
  const textAllocatedWidth = cellWidth - cell.padding.left - cell.padding.right;
21152
20937
  const textAllocatedHeight = cellHeight - cell.padding.top - cell.padding.bottom;
21153
20938
  const rotation = cell.textOptions.rotation ?? 0;
21154
- const {
21155
- width: textMaxWidth,
21156
- height: textMaxHeight
21157
- } = computeBounds(rotation, textAllocatedWidth, textAllocatedHeight);
20939
+ const _computeBounds = computeBounds(rotation, textAllocatedWidth, textAllocatedHeight),
20940
+ textMaxWidth = _computeBounds.width,
20941
+ textMaxHeight = _computeBounds.height;
21158
20942
  const textOptions = {
21159
20943
  align: cell.align.x,
21160
20944
  ellipsis: true,
@@ -21392,7 +21176,8 @@ function renderCellText(cell) {
21392
21176
  }
21393
21177
  function renderBorder(border, borderColor, x, y, width, height, mask) {
21394
21178
  border = Object.fromEntries(Object.entries(border).map(_ref => {
21395
- let [k, v] = _ref;
21179
+ let k = _ref[0],
21180
+ v = _ref[1];
21396
21181
  return [k, mask && !mask[k] ? 0 : v];
21397
21182
  }));
21398
21183
  const doc = this.document;
@@ -21437,10 +21222,9 @@ class PDFTable {
21437
21222
  row = Array.from(row);
21438
21223
  row = normalizeRow.call(this, row, this._currRowIndex);
21439
21224
  if (this._currRowIndex === 0) ensure.call(this, row);
21440
- const {
21441
- newPage,
21442
- toRender
21443
- } = measure.call(this, row, this._currRowIndex);
21225
+ const _measure$call = measure.call(this, row, this._currRowIndex),
21226
+ newPage = _measure$call.newPage,
21227
+ toRender = _measure$call.toRender;
21444
21228
  if (newPage) this.document.continueOnNewPage();
21445
21229
  const yPos = renderRow.call(this, toRender, this._currRowIndex);
21446
21230
  this.document.x = this._position.x;
@@ -21659,9 +21443,7 @@ class PDFDocument extends _stream.default.Readable {
21659
21443
  }
21660
21444
  addPage(options) {
21661
21445
  if (options == null) {
21662
- ({
21663
- options
21664
- } = this);
21446
+ options = this.options;
21665
21447
  }
21666
21448
  if (!this.options.bufferPages) {
21667
21449
  this.flushPages();
@@ -29452,17 +29234,17 @@ module.exports = function callBoundIntrinsic(name, allowMissing) {
29452
29234
 
29453
29235
  var setFunctionLength = __webpack_require__(6255);
29454
29236
 
29455
- var $defineProperty = __webpack_require__(6649);
29237
+ var $defineProperty = __webpack_require__(9030);
29456
29238
 
29457
29239
  var callBindBasic = __webpack_require__(6688);
29458
29240
  var applyBind = __webpack_require__(8619);
29459
29241
 
29460
29242
  module.exports = function callBind(originalFunction) {
29461
29243
  var func = callBindBasic(arguments);
29462
- var adjustedLength = originalFunction.length - (arguments.length - 1);
29244
+ var adjustedLength = 1 + originalFunction.length - (arguments.length - 1);
29463
29245
  return setFunctionLength(
29464
29246
  func,
29465
- 1 + (adjustedLength > 0 ? adjustedLength : 0),
29247
+ adjustedLength > 0 ? adjustedLength : 0,
29466
29248
  true
29467
29249
  );
29468
29250
  };
@@ -29774,7 +29556,7 @@ if ( true && module.exports) {
29774
29556
  "use strict";
29775
29557
 
29776
29558
 
29777
- var $defineProperty = __webpack_require__(6649);
29559
+ var $defineProperty = __webpack_require__(9030);
29778
29560
 
29779
29561
  var $SyntaxError = __webpack_require__(7770);
29780
29562
  var $TypeError = __webpack_require__(6785);
@@ -29925,7 +29707,7 @@ module.exports = desc && typeof desc.get === 'function'
29925
29707
 
29926
29708
  /***/ },
29927
29709
 
29928
- /***/ 6649
29710
+ /***/ 9030
29929
29711
  (module) {
29930
29712
 
29931
29713
  "use strict";
@@ -30873,7 +30655,7 @@ var getEvalledConstructor = function (expressionSyntax) {
30873
30655
  };
30874
30656
 
30875
30657
  var $gOPD = __webpack_require__(8109);
30876
- var $defineProperty = __webpack_require__(6649);
30658
+ var $defineProperty = __webpack_require__(9030);
30877
30659
 
30878
30660
  var throwTypeError = function () {
30879
30661
  throw new $TypeError();
@@ -31325,7 +31107,7 @@ module.exports = $gOPD;
31325
31107
  "use strict";
31326
31108
 
31327
31109
 
31328
- var $defineProperty = __webpack_require__(6649);
31110
+ var $defineProperty = __webpack_require__(9030);
31329
31111
 
31330
31112
  var hasPropertyDescriptors = function hasPropertyDescriptors() {
31331
31113
  return !!$defineProperty;
@@ -46110,7 +45892,7 @@ module.exports = function whichTypedArray(value) {
46110
45892
 
46111
45893
  /***/ },
46112
45894
 
46113
- /***/ 6457
45895
+ /***/ 6946
46114
45896
  (module, exports, __webpack_require__) {
46115
45897
 
46116
45898
  var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function(a,b){if(true)!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (b),
@@ -63467,6 +63249,403 @@ module.exports = $f898ea50f3b38ab8$var$LineBreaker;
63467
63249
 
63468
63250
 
63469
63251
 
63252
+ /***/ },
63253
+
63254
+ /***/ 381
63255
+ (module, __unused_webpack_exports, __webpack_require__) {
63256
+
63257
+ "use strict";
63258
+ /* provided dependency */ var Buffer = __webpack_require__(783)["Buffer"];
63259
+
63260
+
63261
+ var zlib = __webpack_require__(6729);
63262
+
63263
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
63264
+
63265
+ var zlib__default = /*#__PURE__*/_interopDefaultCompat(zlib);
63266
+
63267
+ class PNG {
63268
+ static decode(path, fn) {
63269
+ {
63270
+ throw new Error('PNG.decode not available in browser build');
63271
+ }
63272
+ }
63273
+
63274
+ static load(path) {
63275
+ {
63276
+ throw new Error('PNG.load not available in browser build');
63277
+ }
63278
+ }
63279
+
63280
+ constructor(data) {
63281
+ let i;
63282
+ this.data = data;
63283
+ this.pos = 8; // Skip the default header
63284
+
63285
+ this.palette = [];
63286
+ this.imgData = [];
63287
+ this.transparency = {};
63288
+ this.text = {};
63289
+
63290
+ while (true) {
63291
+ const chunkSize = this.readUInt32();
63292
+ let section = '';
63293
+ for (i = 0; i < 4; i++) {
63294
+ section += String.fromCharCode(this.data[this.pos++]);
63295
+ }
63296
+
63297
+ switch (section) {
63298
+ case 'IHDR':
63299
+ // we can grab interesting values from here (like width, height, etc)
63300
+ this.width = this.readUInt32();
63301
+ this.height = this.readUInt32();
63302
+ this.bits = this.data[this.pos++];
63303
+ this.colorType = this.data[this.pos++];
63304
+ this.compressionMethod = this.data[this.pos++];
63305
+ this.filterMethod = this.data[this.pos++];
63306
+ this.interlaceMethod = this.data[this.pos++];
63307
+ break;
63308
+
63309
+ case 'PLTE':
63310
+ this.palette = this.read(chunkSize);
63311
+ break;
63312
+
63313
+ case 'IDAT':
63314
+ for (i = 0; i < chunkSize; i++) {
63315
+ this.imgData.push(this.data[this.pos++]);
63316
+ }
63317
+ break;
63318
+
63319
+ case 'tRNS':
63320
+ // This chunk can only occur once and it must occur after the
63321
+ // PLTE chunk and before the IDAT chunk.
63322
+ this.transparency = {};
63323
+ switch (this.colorType) {
63324
+ case 3:
63325
+ // Indexed color, RGB. Each byte in this chunk is an alpha for
63326
+ // the palette index in the PLTE ("palette") chunk up until the
63327
+ // last non-opaque entry. Set up an array, stretching over all
63328
+ // palette entries which will be 0 (opaque) or 1 (transparent).
63329
+ this.transparency.indexed = this.read(chunkSize);
63330
+ var short = 255 - this.transparency.indexed.length;
63331
+ if (short > 0) {
63332
+ for (i = 0; i < short; i++) {
63333
+ this.transparency.indexed.push(255);
63334
+ }
63335
+ }
63336
+ break;
63337
+ case 0:
63338
+ // Greyscale. Corresponding to entries in the PLTE chunk.
63339
+ // Grey is two bytes, range 0 .. (2 ^ bit-depth) - 1
63340
+ this.transparency.grayscale = this.read(chunkSize)[0];
63341
+ break;
63342
+ case 2:
63343
+ // True color with proper alpha channel.
63344
+ this.transparency.rgb = this.read(chunkSize);
63345
+ break;
63346
+ }
63347
+ break;
63348
+
63349
+ case 'tEXt':
63350
+ var text = this.read(chunkSize);
63351
+ var index = text.indexOf(0);
63352
+ var key = String.fromCharCode.apply(String, text.slice(0, index));
63353
+ this.text[key] = String.fromCharCode.apply(
63354
+ String,
63355
+ text.slice(index + 1)
63356
+ );
63357
+ break;
63358
+
63359
+ case 'IEND':
63360
+ // we've got everything we need!
63361
+ switch (this.colorType) {
63362
+ case 0:
63363
+ case 3:
63364
+ case 4:
63365
+ this.colors = 1;
63366
+ break;
63367
+ case 2:
63368
+ case 6:
63369
+ this.colors = 3;
63370
+ break;
63371
+ }
63372
+
63373
+ this.hasAlphaChannel = [4, 6].includes(this.colorType);
63374
+ var colors = this.colors + (this.hasAlphaChannel ? 1 : 0);
63375
+ this.pixelBitlength = this.bits * colors;
63376
+
63377
+ switch (this.colors) {
63378
+ case 1:
63379
+ this.colorSpace = 'DeviceGray';
63380
+ break;
63381
+ case 3:
63382
+ this.colorSpace = 'DeviceRGB';
63383
+ break;
63384
+ }
63385
+
63386
+ this.imgData = Buffer.from(this.imgData);
63387
+ return;
63388
+
63389
+ default:
63390
+ // unknown (or unimportant) section, skip it
63391
+ this.pos += chunkSize;
63392
+ }
63393
+
63394
+ this.pos += 4; // Skip the CRC
63395
+
63396
+ if (this.pos > this.data.length) {
63397
+ throw new Error('Incomplete or corrupt PNG file');
63398
+ }
63399
+ }
63400
+ }
63401
+
63402
+ read(bytes) {
63403
+ const result = new Array(bytes);
63404
+ for (let i = 0; i < bytes; i++) {
63405
+ result[i] = this.data[this.pos++];
63406
+ }
63407
+ return result;
63408
+ }
63409
+
63410
+ readUInt32() {
63411
+ const b1 = this.data[this.pos++] << 24;
63412
+ const b2 = this.data[this.pos++] << 16;
63413
+ const b3 = this.data[this.pos++] << 8;
63414
+ const b4 = this.data[this.pos++];
63415
+ return b1 | b2 | b3 | b4;
63416
+ }
63417
+
63418
+ readUInt16() {
63419
+ const b1 = this.data[this.pos++] << 8;
63420
+ const b2 = this.data[this.pos++];
63421
+ return b1 | b2;
63422
+ }
63423
+
63424
+ decodePixels(fn) {
63425
+ return zlib__default.default.inflate(this.imgData, (err, data) => {
63426
+ if (err) {
63427
+ throw err;
63428
+ }
63429
+
63430
+ const { width, height } = this;
63431
+ const pixelBytes = this.pixelBitlength / 8;
63432
+
63433
+ const pixels = Buffer.alloc(width * height * pixelBytes);
63434
+ const { length } = data;
63435
+ let pos = 0;
63436
+
63437
+ function pass(x0, y0, dx, dy, singlePass = false) {
63438
+ const w = Math.ceil((width - x0) / dx);
63439
+ const h = Math.ceil((height - y0) / dy);
63440
+ const scanlineLength = pixelBytes * w;
63441
+ const buffer = singlePass ? pixels : Buffer.alloc(scanlineLength * h);
63442
+ let row = 0;
63443
+ let c = 0;
63444
+ while (row < h && pos < length) {
63445
+ var byte, col, i, left, upper;
63446
+ switch (data[pos++]) {
63447
+ case 0: // None
63448
+ for (i = 0; i < scanlineLength; i++) {
63449
+ buffer[c++] = data[pos++];
63450
+ }
63451
+ break;
63452
+
63453
+ case 1: // Sub
63454
+ for (i = 0; i < scanlineLength; i++) {
63455
+ byte = data[pos++];
63456
+ left = i < pixelBytes ? 0 : buffer[c - pixelBytes];
63457
+ buffer[c++] = (byte + left) % 256;
63458
+ }
63459
+ break;
63460
+
63461
+ case 2: // Up
63462
+ for (i = 0; i < scanlineLength; i++) {
63463
+ byte = data[pos++];
63464
+ col = (i - (i % pixelBytes)) / pixelBytes;
63465
+ upper =
63466
+ row &&
63467
+ buffer[
63468
+ (row - 1) * scanlineLength +
63469
+ col * pixelBytes +
63470
+ (i % pixelBytes)
63471
+ ];
63472
+ buffer[c++] = (upper + byte) % 256;
63473
+ }
63474
+ break;
63475
+
63476
+ case 3: // Average
63477
+ for (i = 0; i < scanlineLength; i++) {
63478
+ byte = data[pos++];
63479
+ col = (i - (i % pixelBytes)) / pixelBytes;
63480
+ left = i < pixelBytes ? 0 : buffer[c - pixelBytes];
63481
+ upper =
63482
+ row &&
63483
+ buffer[
63484
+ (row - 1) * scanlineLength +
63485
+ col * pixelBytes +
63486
+ (i % pixelBytes)
63487
+ ];
63488
+ buffer[c++] = (byte + Math.floor((left + upper) / 2)) % 256;
63489
+ }
63490
+ break;
63491
+
63492
+ case 4: // Paeth
63493
+ for (i = 0; i < scanlineLength; i++) {
63494
+ var paeth, upperLeft;
63495
+ byte = data[pos++];
63496
+ col = (i - (i % pixelBytes)) / pixelBytes;
63497
+ left = i < pixelBytes ? 0 : buffer[c - pixelBytes];
63498
+
63499
+ if (row === 0) {
63500
+ upper = upperLeft = 0;
63501
+ } else {
63502
+ upper =
63503
+ buffer[
63504
+ (row - 1) * scanlineLength +
63505
+ col * pixelBytes +
63506
+ (i % pixelBytes)
63507
+ ];
63508
+ upperLeft =
63509
+ col &&
63510
+ buffer[
63511
+ (row - 1) * scanlineLength +
63512
+ (col - 1) * pixelBytes +
63513
+ (i % pixelBytes)
63514
+ ];
63515
+ }
63516
+
63517
+ const p = left + upper - upperLeft;
63518
+ const pa = Math.abs(p - left);
63519
+ const pb = Math.abs(p - upper);
63520
+ const pc = Math.abs(p - upperLeft);
63521
+
63522
+ if (pa <= pb && pa <= pc) {
63523
+ paeth = left;
63524
+ } else if (pb <= pc) {
63525
+ paeth = upper;
63526
+ } else {
63527
+ paeth = upperLeft;
63528
+ }
63529
+
63530
+ buffer[c++] = (byte + paeth) % 256;
63531
+ }
63532
+ break;
63533
+
63534
+ default:
63535
+ throw new Error(`Invalid filter algorithm: ${data[pos - 1]}`);
63536
+ }
63537
+
63538
+ if (!singlePass) {
63539
+ let pixelsPos = ((y0 + row * dy) * width + x0) * pixelBytes;
63540
+ let bufferPos = row * scanlineLength;
63541
+ for (i = 0; i < w; i++) {
63542
+ for (let j = 0; j < pixelBytes; j++)
63543
+ pixels[pixelsPos++] = buffer[bufferPos++];
63544
+ pixelsPos += (dx - 1) * pixelBytes;
63545
+ }
63546
+ }
63547
+
63548
+ row++;
63549
+ }
63550
+ }
63551
+
63552
+ if (this.interlaceMethod === 1) {
63553
+ /*
63554
+ 1 6 4 6 2 6 4 6
63555
+ 7 7 7 7 7 7 7 7
63556
+ 5 6 5 6 5 6 5 6
63557
+ 7 7 7 7 7 7 7 7
63558
+ 3 6 4 6 3 6 4 6
63559
+ 7 7 7 7 7 7 7 7
63560
+ 5 6 5 6 5 6 5 6
63561
+ 7 7 7 7 7 7 7 7
63562
+ */
63563
+ pass(0, 0, 8, 8); // 1
63564
+ pass(4, 0, 8, 8); // 2
63565
+ pass(0, 4, 4, 8); // 3
63566
+ pass(2, 0, 4, 4); // 4
63567
+ pass(0, 2, 2, 4); // 5
63568
+ pass(1, 0, 2, 2); // 6
63569
+ pass(0, 1, 1, 2); // 7
63570
+ } else {
63571
+ pass(0, 0, 1, 1, true);
63572
+ }
63573
+
63574
+ return fn(pixels);
63575
+ });
63576
+ }
63577
+
63578
+ decodePalette() {
63579
+ const { palette } = this;
63580
+ const { length } = palette;
63581
+ const transparency = this.transparency.indexed || [];
63582
+ const ret = Buffer.alloc(transparency.length + length);
63583
+ let pos = 0;
63584
+ let c = 0;
63585
+
63586
+ for (let i = 0; i < length; i += 3) {
63587
+ var left;
63588
+ ret[pos++] = palette[i];
63589
+ ret[pos++] = palette[i + 1];
63590
+ ret[pos++] = palette[i + 2];
63591
+ ret[pos++] = (left = transparency[c++]) != null ? left : 255;
63592
+ }
63593
+
63594
+ return ret;
63595
+ }
63596
+
63597
+ copyToImageData(imageData, pixels) {
63598
+ let j, k;
63599
+ let { colors } = this;
63600
+ let palette = null;
63601
+ let alpha = this.hasAlphaChannel;
63602
+
63603
+ if (this.palette.length) {
63604
+ palette =
63605
+ this._decodedPalette || (this._decodedPalette = this.decodePalette());
63606
+ colors = 4;
63607
+ alpha = true;
63608
+ }
63609
+
63610
+ const data = imageData.data || imageData;
63611
+ const { length } = data;
63612
+ const input = palette || pixels;
63613
+ let i = (j = 0);
63614
+
63615
+ if (colors === 1) {
63616
+ while (i < length) {
63617
+ k = palette ? pixels[i / 4] * 4 : j;
63618
+ const v = input[k++];
63619
+ data[i++] = v;
63620
+ data[i++] = v;
63621
+ data[i++] = v;
63622
+ data[i++] = alpha ? input[k++] : 255;
63623
+ j = k;
63624
+ }
63625
+ } else {
63626
+ while (i < length) {
63627
+ k = palette ? pixels[i / 4] * 4 : j;
63628
+ data[i++] = input[k++];
63629
+ data[i++] = input[k++];
63630
+ data[i++] = input[k++];
63631
+ data[i++] = alpha ? input[k++] : 255;
63632
+ j = k;
63633
+ }
63634
+ }
63635
+ }
63636
+
63637
+ decode(fn) {
63638
+ const ret = Buffer.alloc(this.width * this.height * 4);
63639
+ return this.decodePixels(pixels => {
63640
+ this.copyToImageData(ret, pixels);
63641
+ return fn(ret);
63642
+ });
63643
+ }
63644
+ }
63645
+
63646
+ module.exports = PNG;
63647
+
63648
+
63470
63649
  /***/ },
63471
63650
 
63472
63651
  /***/ 5233