pdfjs-dist 2.1.266 → 2.2.228

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.

Potentially problematic release.


This version of pdfjs-dist might be problematic. Click here for more details.

Files changed (166) hide show
  1. package/CODE_OF_CONDUCT.md +15 -0
  2. package/bower.json +1 -1
  3. package/build/pdf.js +3349 -2324
  4. package/build/pdf.js.map +1 -1
  5. package/build/pdf.min.js +1 -1
  6. package/build/pdf.worker.js +2804 -1975
  7. package/build/pdf.worker.js.map +1 -1
  8. package/build/pdf.worker.min.js +1 -1
  9. package/image_decoders/pdf.image_decoders.js +431 -511
  10. package/image_decoders/pdf.image_decoders.js.map +1 -1
  11. package/image_decoders/pdf.image_decoders.min.js +1 -1
  12. package/lib/core/annotation.js +294 -224
  13. package/lib/core/arithmetic_decoder.js +1 -1
  14. package/lib/core/bidi.js +1 -1
  15. package/lib/core/ccitt.js +1 -1
  16. package/lib/core/ccitt_stream.js +1 -1
  17. package/lib/core/cff_parser.js +61 -12
  18. package/lib/core/charsets.js +1 -1
  19. package/lib/core/chunked_stream.js +24 -14
  20. package/lib/core/cmap.js +17 -13
  21. package/lib/core/colorspace.js +1 -1
  22. package/lib/core/core_utils.js +147 -0
  23. package/lib/core/crypto.js +1 -1
  24. package/lib/core/document.js +47 -40
  25. package/lib/core/encodings.js +1 -1
  26. package/lib/core/evaluator.js +346 -279
  27. package/lib/core/font_renderer.js +1 -1
  28. package/lib/core/fonts.js +23 -11
  29. package/lib/core/function.js +1 -1
  30. package/lib/core/glyphlist.js +2 -2
  31. package/lib/core/image.js +2 -2
  32. package/lib/core/image_utils.js +111 -0
  33. package/lib/core/jbig2.js +1 -1
  34. package/lib/core/jbig2_stream.js +1 -1
  35. package/lib/core/jpeg_stream.js +1 -1
  36. package/lib/core/jpg.js +2 -1
  37. package/lib/core/jpx.js +1 -1
  38. package/lib/core/jpx_stream.js +1 -1
  39. package/lib/core/metrics.js +13 -13
  40. package/lib/core/murmurhash3.js +37 -33
  41. package/lib/core/obj.js +245 -41
  42. package/lib/core/operator_list.js +43 -32
  43. package/lib/core/parser.js +228 -133
  44. package/lib/core/pattern.js +4 -2
  45. package/lib/core/pdf_manager.js +17 -15
  46. package/lib/core/primitives.js +40 -6
  47. package/lib/core/ps_parser.js +1 -1
  48. package/lib/core/standard_fonts.js +9 -9
  49. package/lib/core/stream.js +1 -1
  50. package/lib/core/type1_parser.js +1 -1
  51. package/lib/core/unicode.js +2 -2
  52. package/lib/core/worker.js +54 -171
  53. package/lib/core/worker_stream.js +277 -0
  54. package/lib/display/annotation_layer.js +112 -33
  55. package/lib/display/api.js +211 -123
  56. package/lib/display/api_compatibility.js +1 -1
  57. package/lib/display/canvas.js +40 -19
  58. package/lib/display/content_disposition.js +1 -1
  59. package/lib/display/display_utils.js +747 -0
  60. package/lib/display/fetch_stream.js +19 -12
  61. package/lib/display/font_loader.js +11 -8
  62. package/lib/display/metadata.js +1 -1
  63. package/lib/display/network.js +563 -521
  64. package/lib/display/network_utils.js +1 -1
  65. package/lib/display/node_stream.js +21 -12
  66. package/lib/display/pattern_helper.js +24 -25
  67. package/lib/display/svg.js +1068 -565
  68. package/lib/display/text_layer.js +24 -14
  69. package/lib/display/transport_stream.js +192 -70
  70. package/lib/display/webgl.js +1 -1
  71. package/lib/display/worker_options.js +1 -1
  72. package/lib/display/xml_parser.js +1 -1
  73. package/lib/examples/node/domstubs.js +4 -1
  74. package/lib/pdf.js +20 -15
  75. package/lib/pdf.worker.js +3 -3
  76. package/lib/shared/compatibility.js +6 -6
  77. package/lib/shared/global_scope.js +1 -1
  78. package/lib/shared/is_node.js +2 -2
  79. package/lib/shared/message_handler.js +7 -7
  80. package/lib/shared/streams_polyfill.js +1 -1
  81. package/lib/shared/url_polyfill.js +1 -1
  82. package/lib/shared/util.js +13 -125
  83. package/lib/test/unit/annotation_spec.js +278 -93
  84. package/lib/test/unit/api_spec.js +198 -188
  85. package/lib/test/unit/bidi_spec.js +1 -1
  86. package/lib/test/unit/cff_parser_spec.js +15 -1
  87. package/lib/test/unit/clitests_helper.js +3 -3
  88. package/lib/test/unit/cmap_spec.js +20 -20
  89. package/lib/test/unit/colorspace_spec.js +17 -12
  90. package/lib/test/unit/core_utils_spec.js +191 -0
  91. package/lib/test/unit/crypto_spec.js +1 -1
  92. package/lib/test/unit/custom_spec.js +8 -8
  93. package/lib/test/unit/display_svg_spec.js +8 -8
  94. package/lib/test/unit/display_utils_spec.js +273 -0
  95. package/lib/test/unit/document_spec.js +7 -12
  96. package/lib/test/unit/encodings_spec.js +5 -5
  97. package/lib/test/unit/evaluator_spec.js +8 -10
  98. package/lib/test/unit/fetch_stream_spec.js +109 -0
  99. package/lib/test/unit/function_spec.js +1 -1
  100. package/lib/test/unit/jasmine-boot.js +4 -4
  101. package/lib/test/unit/message_handler_spec.js +1 -1
  102. package/lib/test/unit/metadata_spec.js +1 -1
  103. package/lib/test/unit/murmurhash3_spec.js +1 -1
  104. package/lib/test/unit/network_spec.js +5 -55
  105. package/lib/test/unit/network_utils_spec.js +51 -1
  106. package/lib/test/unit/node_stream_spec.js +8 -8
  107. package/lib/test/unit/parser_spec.js +150 -86
  108. package/lib/test/unit/pdf_find_controller_spec.js +1 -1
  109. package/lib/test/unit/pdf_find_utils_spec.js +1 -1
  110. package/lib/test/unit/pdf_history_spec.js +1 -1
  111. package/lib/test/unit/primitives_spec.js +30 -17
  112. package/lib/test/unit/stream_spec.js +1 -1
  113. package/lib/test/unit/test_utils.js +197 -43
  114. package/lib/test/unit/testreporter.js +1 -1
  115. package/lib/test/unit/type1_parser_spec.js +1 -1
  116. package/lib/test/unit/ui_utils_spec.js +20 -20
  117. package/lib/test/unit/unicode_spec.js +5 -5
  118. package/lib/test/unit/util_spec.js +1 -164
  119. package/lib/web/annotation_layer_builder.js +1 -1
  120. package/lib/web/app.js +104 -60
  121. package/lib/web/app_options.js +45 -37
  122. package/lib/web/base_viewer.js +7 -7
  123. package/lib/web/chromecom.js +8 -8
  124. package/lib/web/debugger.js +7 -7
  125. package/lib/web/download_manager.js +3 -2
  126. package/lib/web/firefox_print_service.js +4 -2
  127. package/lib/web/firefoxcom.js +50 -19
  128. package/lib/web/genericcom.js +8 -8
  129. package/lib/web/genericl10n.js +10 -10
  130. package/lib/web/grab_to_pan.js +3 -1
  131. package/lib/web/interfaces.js +13 -13
  132. package/lib/web/overlay_manager.js +10 -10
  133. package/lib/web/password_prompt.js +2 -2
  134. package/lib/web/pdf_attachment_viewer.js +1 -1
  135. package/lib/web/pdf_cursor_tools.js +1 -1
  136. package/lib/web/pdf_document_properties.js +188 -119
  137. package/lib/web/pdf_find_bar.js +1 -1
  138. package/lib/web/pdf_find_controller.js +3 -3
  139. package/lib/web/pdf_find_utils.js +1 -1
  140. package/lib/web/pdf_history.js +1 -1
  141. package/lib/web/pdf_link_service.js +2 -2
  142. package/lib/web/pdf_outline_viewer.js +53 -28
  143. package/lib/web/pdf_page_view.js +9 -18
  144. package/lib/web/pdf_presentation_mode.js +1 -1
  145. package/lib/web/pdf_print_service.js +5 -3
  146. package/lib/web/pdf_rendering_queue.js +4 -7
  147. package/lib/web/pdf_sidebar.js +24 -17
  148. package/lib/web/pdf_sidebar_resizer.js +1 -1
  149. package/lib/web/pdf_single_page_viewer.js +1 -1
  150. package/lib/web/pdf_thumbnail_view.js +2 -2
  151. package/lib/web/pdf_thumbnail_viewer.js +3 -3
  152. package/lib/web/pdf_viewer.component.js +3 -3
  153. package/lib/web/pdf_viewer.js +3 -3
  154. package/lib/web/preferences.js +30 -30
  155. package/lib/web/secondary_toolbar.js +1 -1
  156. package/lib/web/text_layer_builder.js +23 -45
  157. package/lib/web/toolbar.js +1 -1
  158. package/lib/web/ui_utils.js +14 -14
  159. package/lib/web/view_history.js +15 -15
  160. package/lib/web/viewer_compatibility.js +1 -1
  161. package/package.json +1 -1
  162. package/web/pdf_viewer.css +21 -10
  163. package/web/pdf_viewer.js +126 -194
  164. package/web/pdf_viewer.js.map +1 -1
  165. package/lib/display/dom_utils.js +0 -494
  166. package/lib/test/unit/dom_utils_spec.js +0 -89
@@ -2,7 +2,7 @@
2
2
  * @licstart The following is the entire license notice for the
3
3
  * Javascript code in this page
4
4
  *
5
- * Copyright 2018 Mozilla Foundation
5
+ * Copyright 2019 Mozilla Foundation
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -40,6 +40,14 @@ var _jpeg_stream = require("./jpeg_stream");
40
40
 
41
41
  var _jpx_stream = require("./jpx_stream");
42
42
 
43
+ var _core_utils = require("./core_utils");
44
+
45
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
46
+
47
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
48
+
49
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
50
+
43
51
  var MAX_LENGTH_TO_CACHE = 1000;
44
52
  var MAX_ADLER32_LENGTH = 5552;
45
53
 
@@ -56,22 +64,36 @@ function computeAdler32(bytes) {
56
64
  return b % 65521 << 16 | a % 65521;
57
65
  }
58
66
 
59
- var Parser = function ParserClosure() {
60
- function Parser(lexer, allowStreams, xref, recoveryMode) {
67
+ var Parser =
68
+ /*#__PURE__*/
69
+ function () {
70
+ function Parser(_ref) {
71
+ var lexer = _ref.lexer,
72
+ xref = _ref.xref,
73
+ _ref$allowStreams = _ref.allowStreams,
74
+ allowStreams = _ref$allowStreams === void 0 ? false : _ref$allowStreams,
75
+ _ref$recoveryMode = _ref.recoveryMode,
76
+ recoveryMode = _ref$recoveryMode === void 0 ? false : _ref$recoveryMode;
77
+
78
+ _classCallCheck(this, Parser);
79
+
61
80
  this.lexer = lexer;
62
- this.allowStreams = allowStreams;
63
81
  this.xref = xref;
64
- this.recoveryMode = recoveryMode || false;
82
+ this.allowStreams = allowStreams;
83
+ this.recoveryMode = recoveryMode;
65
84
  this.imageCache = Object.create(null);
66
85
  this.refill();
67
86
  }
68
87
 
69
- Parser.prototype = {
70
- refill: function Parser_refill() {
88
+ _createClass(Parser, [{
89
+ key: "refill",
90
+ value: function refill() {
71
91
  this.buf1 = this.lexer.getObj();
72
92
  this.buf2 = this.lexer.getObj();
73
- },
74
- shift: function Parser_shift() {
93
+ }
94
+ }, {
95
+ key: "shift",
96
+ value: function shift() {
75
97
  if ((0, _primitives.isCmd)(this.buf2, 'ID')) {
76
98
  this.buf1 = this.buf2;
77
99
  this.buf2 = null;
@@ -79,20 +101,24 @@ var Parser = function ParserClosure() {
79
101
  this.buf1 = this.buf2;
80
102
  this.buf2 = this.lexer.getObj();
81
103
  }
82
- },
83
- tryShift: function Parser_tryShift() {
104
+ }
105
+ }, {
106
+ key: "tryShift",
107
+ value: function tryShift() {
84
108
  try {
85
109
  this.shift();
86
110
  return true;
87
111
  } catch (e) {
88
- if (e instanceof _util.MissingDataException) {
112
+ if (e instanceof _core_utils.MissingDataException) {
89
113
  throw e;
90
114
  }
91
115
 
92
116
  return false;
93
117
  }
94
- },
95
- getObj: function Parser_getObj(cipherTransform) {
118
+ }
119
+ }, {
120
+ key: "getObj",
121
+ value: function getObj(cipherTransform) {
96
122
  var buf1 = this.buf1;
97
123
  this.shift();
98
124
 
@@ -163,7 +189,8 @@ var Parser = function ParserClosure() {
163
189
  var num = buf1;
164
190
 
165
191
  if (Number.isInteger(this.buf1) && (0, _primitives.isCmd)(this.buf2, 'R')) {
166
- var ref = new _primitives.Ref(num, this.buf1);
192
+ var ref = _primitives.Ref.get(num, this.buf1);
193
+
167
194
  this.shift();
168
195
  this.shift();
169
196
  return ref;
@@ -183,8 +210,10 @@ var Parser = function ParserClosure() {
183
210
  }
184
211
 
185
212
  return buf1;
186
- },
187
- findDefaultInlineStreamEnd: function findDefaultInlineStreamEnd(stream) {
213
+ }
214
+ }, {
215
+ key: "findDefaultInlineStreamEnd",
216
+ value: function findDefaultInlineStreamEnd(stream) {
188
217
  var E = 0x45,
189
218
  I = 0x49,
190
219
  SPACE = 0x20,
@@ -250,8 +279,10 @@ var Parser = function ParserClosure() {
250
279
  }
251
280
 
252
281
  return stream.pos - endOffset - startPos;
253
- },
254
- findDCTDecodeInlineStreamEnd: function Parser_findDCTDecodeInlineStreamEnd(stream) {
282
+ }
283
+ }, {
284
+ key: "findDCTDecodeInlineStreamEnd",
285
+ value: function findDCTDecodeInlineStreamEnd(stream) {
255
286
  var startPos = stream.pos,
256
287
  foundEOI = false,
257
288
  b,
@@ -339,8 +370,10 @@ var Parser = function ParserClosure() {
339
370
 
340
371
  this.inlineStreamSkipEI(stream);
341
372
  return length;
342
- },
343
- findASCII85DecodeInlineStreamEnd: function Parser_findASCII85DecodeInlineStreamEnd(stream) {
373
+ }
374
+ }, {
375
+ key: "findASCII85DecodeInlineStreamEnd",
376
+ value: function findASCII85DecodeInlineStreamEnd(stream) {
344
377
  var TILDE = 0x7E,
345
378
  GT = 0x3E;
346
379
  var startPos = stream.pos,
@@ -348,9 +381,18 @@ var Parser = function ParserClosure() {
348
381
  length;
349
382
 
350
383
  while ((ch = stream.getByte()) !== -1) {
351
- if (ch === TILDE && stream.peekByte() === GT) {
352
- stream.skip();
353
- break;
384
+ if (ch === TILDE) {
385
+ ch = stream.peekByte();
386
+
387
+ while ((0, _util.isSpace)(ch)) {
388
+ stream.skip();
389
+ ch = stream.peekByte();
390
+ }
391
+
392
+ if (ch === GT) {
393
+ stream.skip();
394
+ break;
395
+ }
354
396
  }
355
397
  }
356
398
 
@@ -364,8 +406,10 @@ var Parser = function ParserClosure() {
364
406
 
365
407
  this.inlineStreamSkipEI(stream);
366
408
  return length;
367
- },
368
- findASCIIHexDecodeInlineStreamEnd: function Parser_findASCIIHexDecodeInlineStreamEnd(stream) {
409
+ }
410
+ }, {
411
+ key: "findASCIIHexDecodeInlineStreamEnd",
412
+ value: function findASCIIHexDecodeInlineStreamEnd(stream) {
369
413
  var GT = 0x3E;
370
414
  var startPos = stream.pos,
371
415
  ch,
@@ -387,8 +431,10 @@ var Parser = function ParserClosure() {
387
431
 
388
432
  this.inlineStreamSkipEI(stream);
389
433
  return length;
390
- },
391
- inlineStreamSkipEI: function Parser_inlineStreamSkipEI(stream) {
434
+ }
435
+ }, {
436
+ key: "inlineStreamSkipEI",
437
+ value: function inlineStreamSkipEI(stream) {
392
438
  var E = 0x45,
393
439
  I = 0x49;
394
440
  var state = 0,
@@ -403,12 +449,14 @@ var Parser = function ParserClosure() {
403
449
  break;
404
450
  }
405
451
  }
406
- },
407
- makeInlineImage: function Parser_makeInlineImage(cipherTransform) {
452
+ }
453
+ }, {
454
+ key: "makeInlineImage",
455
+ value: function makeInlineImage(cipherTransform) {
408
456
  var lexer = this.lexer;
409
457
  var stream = lexer.stream;
410
- var dict = new _primitives.Dict(this.xref),
411
- dictLength;
458
+ var dict = new _primitives.Dict(this.xref);
459
+ var dictLength;
412
460
 
413
461
  while (!(0, _primitives.isCmd)(this.buf1, 'ID') && !(0, _primitives.isEOF)(this.buf1)) {
414
462
  if (!(0, _primitives.isName)(this.buf1)) {
@@ -429,8 +477,8 @@ var Parser = function ParserClosure() {
429
477
  dictLength = stream.pos - lexer.beginInlineImagePos;
430
478
  }
431
479
 
432
- var filter = dict.get('Filter', 'F'),
433
- filterName;
480
+ var filter = dict.get('Filter', 'F');
481
+ var filterName;
434
482
 
435
483
  if ((0, _primitives.isName)(filter)) {
436
484
  filterName = filter.name;
@@ -442,8 +490,8 @@ var Parser = function ParserClosure() {
442
490
  }
443
491
  }
444
492
 
445
- var startPos = stream.pos,
446
- length;
493
+ var startPos = stream.pos;
494
+ var length;
447
495
 
448
496
  if (filterName === 'DCTDecode' || filterName === 'DCT') {
449
497
  length = this.findDCTDecodeInlineStreamEnd(stream);
@@ -484,15 +532,17 @@ var Parser = function ParserClosure() {
484
532
  imageStream.dict = dict;
485
533
 
486
534
  if (cacheKey !== undefined) {
487
- imageStream.cacheKey = 'inline_' + length + '_' + cacheKey;
535
+ imageStream.cacheKey = "inline_".concat(length, "_").concat(cacheKey);
488
536
  this.imageCache[cacheKey] = imageStream;
489
537
  }
490
538
 
491
539
  this.buf2 = _primitives.Cmd.get('EI');
492
540
  this.shift();
493
541
  return imageStream;
494
- },
495
- _findStreamLength: function _findStreamLength(startPos, signature) {
542
+ }
543
+ }, {
544
+ key: "_findStreamLength",
545
+ value: function _findStreamLength(startPos, signature) {
496
546
  var stream = this.lexer.stream;
497
547
  stream.pos = startPos;
498
548
  var SCAN_BLOCK_LENGTH = 2048;
@@ -527,8 +577,10 @@ var Parser = function ParserClosure() {
527
577
  }
528
578
 
529
579
  return -1;
530
- },
531
- makeStream: function Parser_makeStream(dict, cipherTransform) {
580
+ }
581
+ }, {
582
+ key: "makeStream",
583
+ value: function makeStream(dict, cipherTransform) {
532
584
  var lexer = this.lexer;
533
585
  var stream = lexer.stream;
534
586
  lexer.skipToNextLine();
@@ -536,7 +588,7 @@ var Parser = function ParserClosure() {
536
588
  var length = dict.get('Length');
537
589
 
538
590
  if (!Number.isInteger(length)) {
539
- (0, _util.info)('Bad ' + length + ' attribute in stream');
591
+ (0, _util.info)("Bad length \"".concat(length, "\" in stream"));
540
592
  length = 0;
541
593
  }
542
594
 
@@ -593,8 +645,10 @@ var Parser = function ParserClosure() {
593
645
  stream = this.filter(stream, dict, length);
594
646
  stream.dict = dict;
595
647
  return stream;
596
- },
597
- filter: function Parser_filter(stream, dict, length) {
648
+ }
649
+ }, {
650
+ key: "filter",
651
+ value: function filter(stream, dict, length) {
598
652
  var filter = dict.get('Filter', 'F');
599
653
  var params = dict.get('DecodeParms', 'DP');
600
654
 
@@ -616,7 +670,7 @@ var Parser = function ParserClosure() {
616
670
  filter = this.xref.fetchIfRef(filterArray[i]);
617
671
 
618
672
  if (!(0, _primitives.isName)(filter)) {
619
- throw new _util.FormatError('Bad filter name: ' + filter);
673
+ throw new _util.FormatError("Bad filter name \"".concat(filter, "\""));
620
674
  }
621
675
 
622
676
  params = null;
@@ -631,10 +685,12 @@ var Parser = function ParserClosure() {
631
685
  }
632
686
 
633
687
  return stream;
634
- },
635
- makeFilter: function Parser_makeFilter(stream, name, maybeLength, params) {
688
+ }
689
+ }, {
690
+ key: "makeFilter",
691
+ value: function makeFilter(stream, name, maybeLength, params) {
636
692
  if (maybeLength === 0) {
637
- (0, _util.warn)('Empty "' + name + '" stream.');
693
+ (0, _util.warn)("Empty \"".concat(name, "\" stream."));
638
694
  return new _stream.NullStream();
639
695
  }
640
696
 
@@ -701,54 +757,65 @@ var Parser = function ParserClosure() {
701
757
  return new _jbig2_stream.Jbig2Stream(stream, maybeLength, stream.dict, params);
702
758
  }
703
759
 
704
- (0, _util.warn)('filter "' + name + '" not supported yet');
760
+ (0, _util.warn)("Filter \"".concat(name, "\" is not supported."));
705
761
  return stream;
706
762
  } catch (ex) {
707
- if (ex instanceof _util.MissingDataException) {
763
+ if (ex instanceof _core_utils.MissingDataException) {
708
764
  throw ex;
709
765
  }
710
766
 
711
- (0, _util.warn)('Invalid stream: \"' + ex + '\"');
767
+ (0, _util.warn)("Invalid stream: \"".concat(ex, "\""));
712
768
  return new _stream.NullStream();
713
769
  }
714
770
  }
715
- };
771
+ }]);
772
+
716
773
  return Parser;
717
774
  }();
718
775
 
719
776
  exports.Parser = Parser;
777
+ var specialChars = [1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2, 0, 0, 2, 2, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
720
778
 
721
- var Lexer = function LexerClosure() {
722
- function Lexer(stream, knownCommands) {
723
- this.stream = stream;
724
- this.nextChar();
725
- this.strBuf = [];
726
- this.knownCommands = knownCommands;
727
- this.beginInlineImagePos = -1;
779
+ function toHexDigit(ch) {
780
+ if (ch >= 0x30 && ch <= 0x39) {
781
+ return ch & 0x0F;
728
782
  }
729
783
 
730
- var specialChars = [1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2, 0, 0, 2, 2, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
784
+ if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
785
+ return (ch & 0x0F) + 9;
786
+ }
731
787
 
732
- function toHexDigit(ch) {
733
- if (ch >= 0x30 && ch <= 0x39) {
734
- return ch & 0x0F;
735
- }
788
+ return -1;
789
+ }
736
790
 
737
- if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
738
- return (ch & 0x0F) + 9;
739
- }
791
+ var Lexer =
792
+ /*#__PURE__*/
793
+ function () {
794
+ function Lexer(stream) {
795
+ var knownCommands = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
796
+
797
+ _classCallCheck(this, Lexer);
740
798
 
741
- return -1;
799
+ this.stream = stream;
800
+ this.nextChar();
801
+ this.strBuf = [];
802
+ this.knownCommands = knownCommands;
803
+ this.beginInlineImagePos = -1;
742
804
  }
743
805
 
744
- Lexer.prototype = {
745
- nextChar: function Lexer_nextChar() {
806
+ _createClass(Lexer, [{
807
+ key: "nextChar",
808
+ value: function nextChar() {
746
809
  return this.currentChar = this.stream.getByte();
747
- },
748
- peekChar: function Lexer_peekChar() {
810
+ }
811
+ }, {
812
+ key: "peekChar",
813
+ value: function peekChar() {
749
814
  return this.stream.peekByte();
750
- },
751
- getNumber: function Lexer_getNumber() {
815
+ }
816
+ }, {
817
+ key: "getNumber",
818
+ value: function getNumber() {
752
819
  var ch = this.currentChar;
753
820
  var eNotation = false;
754
821
  var divideBy = 0;
@@ -811,7 +878,7 @@ var Lexer = function LexerClosure() {
811
878
  break;
812
879
  }
813
880
  } else if (ch === 0x2D) {
814
- (0, _util.warn)('Badly formatted number');
881
+ (0, _util.warn)('Badly formatted number: minus sign in the middle');
815
882
  } else if (ch === 0x45 || ch === 0x65) {
816
883
  ch = this.peekChar();
817
884
 
@@ -837,8 +904,10 @@ var Lexer = function LexerClosure() {
837
904
  }
838
905
 
839
906
  return sign * baseValue;
840
- },
841
- getString: function Lexer_getString() {
907
+ }
908
+ }, {
909
+ key: "getString",
910
+ value: function getString() {
842
911
  var numParen = 1;
843
912
  var done = false;
844
913
  var strBuf = this.strBuf;
@@ -961,8 +1030,10 @@ var Lexer = function LexerClosure() {
961
1030
  }
962
1031
 
963
1032
  return strBuf.join('');
964
- },
965
- getName: function Lexer_getName() {
1033
+ }
1034
+ }, {
1035
+ key: "getName",
1036
+ value: function getName() {
966
1037
  var ch, previousCh;
967
1038
  var strBuf = this.strBuf;
968
1039
  strBuf.length = 0;
@@ -985,7 +1056,7 @@ var Lexer = function LexerClosure() {
985
1056
  var x2 = toHexDigit(ch);
986
1057
 
987
1058
  if (x2 === -1) {
988
- (0, _util.warn)('Lexer_getName: Illegal digit (' + String.fromCharCode(ch) + ') in hexadecimal number.');
1059
+ (0, _util.warn)("Lexer_getName: Illegal digit (".concat(String.fromCharCode(ch), ") ") + 'in hexadecimal number.');
989
1060
  strBuf.push('#', String.fromCharCode(previousCh));
990
1061
 
991
1062
  if (specialChars[ch]) {
@@ -1006,18 +1077,19 @@ var Lexer = function LexerClosure() {
1006
1077
  }
1007
1078
 
1008
1079
  if (strBuf.length > 127) {
1009
- (0, _util.warn)('name token is longer than allowed by the spec: ' + strBuf.length);
1080
+ (0, _util.warn)("Name token is longer than allowed by the spec: ".concat(strBuf.length));
1010
1081
  }
1011
1082
 
1012
1083
  return _primitives.Name.get(strBuf.join(''));
1013
- },
1014
- getHexString: function Lexer_getHexString() {
1084
+ }
1085
+ }, {
1086
+ key: "getHexString",
1087
+ value: function getHexString() {
1015
1088
  var strBuf = this.strBuf;
1016
1089
  strBuf.length = 0;
1017
1090
  var ch = this.currentChar;
1018
1091
  var isFirstHex = true;
1019
- var firstDigit;
1020
- var secondDigit;
1092
+ var firstDigit, secondDigit;
1021
1093
 
1022
1094
  while (true) {
1023
1095
  if (ch < 0) {
@@ -1034,7 +1106,7 @@ var Lexer = function LexerClosure() {
1034
1106
  firstDigit = toHexDigit(ch);
1035
1107
 
1036
1108
  if (firstDigit === -1) {
1037
- (0, _util.warn)('Ignoring invalid character "' + ch + '" in hex string');
1109
+ (0, _util.warn)("Ignoring invalid character \"".concat(ch, "\" in hex string"));
1038
1110
  ch = this.nextChar();
1039
1111
  continue;
1040
1112
  }
@@ -1042,7 +1114,7 @@ var Lexer = function LexerClosure() {
1042
1114
  secondDigit = toHexDigit(ch);
1043
1115
 
1044
1116
  if (secondDigit === -1) {
1045
- (0, _util.warn)('Ignoring invalid character "' + ch + '" in hex string');
1117
+ (0, _util.warn)("Ignoring invalid character \"".concat(ch, "\" in hex string"));
1046
1118
  ch = this.nextChar();
1047
1119
  continue;
1048
1120
  }
@@ -1056,8 +1128,10 @@ var Lexer = function LexerClosure() {
1056
1128
  }
1057
1129
 
1058
1130
  return strBuf.join('');
1059
- },
1060
- getObj: function Lexer_getObj() {
1131
+ }
1132
+ }, {
1133
+ key: "getObj",
1134
+ value: function getObj() {
1061
1135
  var comment = false;
1062
1136
  var ch = this.currentChar;
1063
1137
 
@@ -1178,8 +1252,10 @@ var Lexer = function LexerClosure() {
1178
1252
  }
1179
1253
 
1180
1254
  return _primitives.Cmd.get(str);
1181
- },
1182
- skipToNextLine: function Lexer_skipToNextLine() {
1255
+ }
1256
+ }, {
1257
+ key: "skipToNextLine",
1258
+ value: function skipToNextLine() {
1183
1259
  var ch = this.currentChar;
1184
1260
 
1185
1261
  while (ch >= 0) {
@@ -1199,63 +1275,82 @@ var Lexer = function LexerClosure() {
1199
1275
  ch = this.nextChar();
1200
1276
  }
1201
1277
  }
1202
- };
1278
+ }]);
1279
+
1203
1280
  return Lexer;
1204
1281
  }();
1205
1282
 
1206
1283
  exports.Lexer = Lexer;
1207
- var Linearization = {
1208
- create: function LinearizationCreate(stream) {
1209
- function getInt(name, allowZeroValue) {
1210
- var obj = linDict.get(name);
1211
1284
 
1212
- if (Number.isInteger(obj) && (allowZeroValue ? obj >= 0 : obj > 0)) {
1213
- return obj;
1285
+ var Linearization =
1286
+ /*#__PURE__*/
1287
+ function () {
1288
+ function Linearization() {
1289
+ _classCallCheck(this, Linearization);
1290
+ }
1291
+
1292
+ _createClass(Linearization, null, [{
1293
+ key: "create",
1294
+ value: function create(stream) {
1295
+ function getInt(linDict, name) {
1296
+ var allowZeroValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
1297
+ var obj = linDict.get(name);
1298
+
1299
+ if (Number.isInteger(obj) && (allowZeroValue ? obj >= 0 : obj > 0)) {
1300
+ return obj;
1301
+ }
1302
+
1303
+ throw new Error("The \"".concat(name, "\" parameter in the linearization ") + 'dictionary is invalid.');
1214
1304
  }
1215
1305
 
1216
- throw new Error('The "' + name + '" parameter in the linearization ' + 'dictionary is invalid.');
1217
- }
1306
+ function getHints(linDict) {
1307
+ var hints = linDict.get('H');
1308
+ var hintsLength;
1218
1309
 
1219
- function getHints() {
1220
- var hints = linDict.get('H'),
1221
- hintsLength,
1222
- item;
1310
+ if (Array.isArray(hints) && ((hintsLength = hints.length) === 2 || hintsLength === 4)) {
1311
+ for (var index = 0; index < hintsLength; index++) {
1312
+ var hint = hints[index];
1223
1313
 
1224
- if (Array.isArray(hints) && ((hintsLength = hints.length) === 2 || hintsLength === 4)) {
1225
- for (var index = 0; index < hintsLength; index++) {
1226
- if (!(Number.isInteger(item = hints[index]) && item > 0)) {
1227
- throw new Error('Hint (' + index + ') in the linearization dictionary is invalid.');
1314
+ if (!(Number.isInteger(hint) && hint > 0)) {
1315
+ throw new Error("Hint (".concat(index, ") in the linearization dictionary ") + 'is invalid.');
1316
+ }
1228
1317
  }
1318
+
1319
+ return hints;
1229
1320
  }
1230
1321
 
1231
- return hints;
1322
+ throw new Error('Hint array in the linearization dictionary is invalid.');
1232
1323
  }
1233
1324
 
1234
- throw new Error('Hint array in the linearization dictionary is invalid.');
1235
- }
1325
+ var parser = new Parser({
1326
+ lexer: new Lexer(stream),
1327
+ xref: null
1328
+ });
1329
+ var obj1 = parser.getObj();
1330
+ var obj2 = parser.getObj();
1331
+ var obj3 = parser.getObj();
1332
+ var linDict = parser.getObj();
1333
+ var obj, length;
1334
+
1335
+ if (!(Number.isInteger(obj1) && Number.isInteger(obj2) && (0, _primitives.isCmd)(obj3, 'obj') && (0, _primitives.isDict)(linDict) && (0, _util.isNum)(obj = linDict.get('Linearized')) && obj > 0)) {
1336
+ return null;
1337
+ } else if ((length = getInt(linDict, 'L')) !== stream.length) {
1338
+ throw new Error('The "L" parameter in the linearization dictionary ' + 'does not equal the stream length.');
1339
+ }
1236
1340
 
1237
- var parser = new Parser(new Lexer(stream), false, null);
1238
- var obj1 = parser.getObj();
1239
- var obj2 = parser.getObj();
1240
- var obj3 = parser.getObj();
1241
- var linDict = parser.getObj();
1242
- var obj, length;
1243
-
1244
- if (!(Number.isInteger(obj1) && Number.isInteger(obj2) && (0, _primitives.isCmd)(obj3, 'obj') && (0, _primitives.isDict)(linDict) && (0, _util.isNum)(obj = linDict.get('Linearized')) && obj > 0)) {
1245
- return null;
1246
- } else if ((length = getInt('L')) !== stream.length) {
1247
- throw new Error('The "L" parameter in the linearization dictionary ' + 'does not equal the stream length.');
1341
+ return {
1342
+ length: length,
1343
+ hints: getHints(linDict),
1344
+ objectNumberFirst: getInt(linDict, 'O'),
1345
+ endFirst: getInt(linDict, 'E'),
1346
+ numPages: getInt(linDict, 'N'),
1347
+ mainXRefEntriesOffset: getInt(linDict, 'T'),
1348
+ pageFirst: linDict.has('P') ? getInt(linDict, 'P', true) : 0
1349
+ };
1248
1350
  }
1351
+ }]);
1352
+
1353
+ return Linearization;
1354
+ }();
1249
1355
 
1250
- return {
1251
- length: length,
1252
- hints: getHints(),
1253
- objectNumberFirst: getInt('O'),
1254
- endFirst: getInt('E'),
1255
- numPages: getInt('N'),
1256
- mainXRefEntriesOffset: getInt('T'),
1257
- pageFirst: linDict.has('P') ? getInt('P', true) : 0
1258
- };
1259
- }
1260
- };
1261
1356
  exports.Linearization = Linearization;
@@ -2,7 +2,7 @@
2
2
  * @licstart The following is the entire license notice for the
3
3
  * Javascript code in this page
4
4
  *
5
- * Copyright 2018 Mozilla Foundation
5
+ * Copyright 2019 Mozilla Foundation
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -33,6 +33,8 @@ var _colorspace = require("./colorspace");
33
33
 
34
34
  var _primitives = require("./primitives");
35
35
 
36
+ var _core_utils = require("./core_utils");
37
+
36
38
  var ShadingType = {
37
39
  FUNCTION_BASED: 1,
38
40
  AXIAL: 2,
@@ -74,7 +76,7 @@ var Pattern = function PatternClosure() {
74
76
  throw new _util.FormatError('Unsupported ShadingType: ' + type);
75
77
  }
76
78
  } catch (ex) {
77
- if (ex instanceof _util.MissingDataException) {
79
+ if (ex instanceof _core_utils.MissingDataException) {
78
80
  throw ex;
79
81
  }
80
82