pdfjs-dist 2.2.228 → 2.3.200

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 (84) hide show
  1. package/bower.json +1 -1
  2. package/build/pdf.js +8851 -8582
  3. package/build/pdf.js.map +1 -1
  4. package/build/pdf.min.js +1 -1
  5. package/build/pdf.worker.js +8717 -8394
  6. package/build/pdf.worker.js.map +1 -1
  7. package/build/pdf.worker.min.js +1 -1
  8. package/image_decoders/pdf.image_decoders.js +3014 -2864
  9. package/image_decoders/pdf.image_decoders.js.map +1 -1
  10. package/image_decoders/pdf.image_decoders.min.js +1 -1
  11. package/lib/core/annotation.js +203 -39
  12. package/lib/core/chunked_stream.js +32 -9
  13. package/lib/core/core_utils.js +48 -22
  14. package/lib/core/document.js +44 -33
  15. package/lib/core/evaluator.js +68 -32
  16. package/lib/core/fonts.js +2 -2
  17. package/lib/core/glyphlist.js +1 -0
  18. package/lib/core/image.js +1 -1
  19. package/lib/core/jbig2.js +23 -6
  20. package/lib/core/jpg.js +54 -23
  21. package/lib/core/jpx.js +23 -6
  22. package/lib/core/obj.js +18 -16
  23. package/lib/core/operator_list.js +17 -14
  24. package/lib/core/parser.js +9 -12
  25. package/lib/core/pattern.js +22 -7
  26. package/lib/core/pdf_manager.js +4 -4
  27. package/lib/core/primitives.js +63 -42
  28. package/lib/core/stream.js +14 -0
  29. package/lib/core/type1_parser.js +9 -1
  30. package/lib/core/worker.js +17 -56
  31. package/lib/display/annotation_layer.js +194 -85
  32. package/lib/display/api.js +331 -213
  33. package/lib/display/canvas.js +6 -1
  34. package/lib/display/content_disposition.js +1 -1
  35. package/lib/display/display_utils.js +48 -18
  36. package/lib/display/network_utils.js +6 -0
  37. package/lib/display/pattern_helper.js +22 -5
  38. package/lib/display/svg.js +1 -1
  39. package/lib/display/text_layer.js +62 -53
  40. package/lib/display/xml_parser.js +1 -1
  41. package/lib/pdf.js +2 -3
  42. package/lib/pdf.worker.js +2 -2
  43. package/lib/shared/compatibility.js +23 -19
  44. package/lib/shared/message_handler.js +163 -196
  45. package/lib/shared/streams_polyfill.js +1 -1
  46. package/lib/shared/util.js +288 -196
  47. package/lib/test/unit/annotation_spec.js +687 -93
  48. package/lib/test/unit/api_spec.js +72 -27
  49. package/lib/test/unit/display_utils_spec.js +1 -1
  50. package/lib/test/unit/evaluator_spec.js +21 -5
  51. package/lib/test/unit/fetch_stream_spec.js +3 -1
  52. package/lib/test/unit/message_handler_spec.js +10 -6
  53. package/lib/test/unit/network_spec.js +3 -1
  54. package/lib/test/unit/network_utils_spec.js +14 -0
  55. package/lib/test/unit/node_stream_spec.js +3 -3
  56. package/lib/test/unit/primitives_spec.js +2 -2
  57. package/lib/test/unit/type1_parser_spec.js +1 -1
  58. package/lib/test/unit/ui_utils_spec.js +1 -1
  59. package/lib/test/unit/util_spec.js +10 -10
  60. package/lib/web/app.js +47 -35
  61. package/lib/web/app_options.js +4 -4
  62. package/lib/web/base_viewer.js +36 -12
  63. package/lib/web/chromecom.js +1 -3
  64. package/lib/web/download_manager.js +1 -1
  65. package/lib/web/firefox_print_service.js +7 -4
  66. package/lib/web/firefoxcom.js +10 -5
  67. package/lib/web/interfaces.js +4 -0
  68. package/lib/web/pdf_document_properties.js +1 -1
  69. package/lib/web/pdf_history.js +1 -1
  70. package/lib/web/pdf_link_service.js +7 -3
  71. package/lib/web/pdf_outline_viewer.js +2 -1
  72. package/lib/web/pdf_page_view.js +12 -16
  73. package/lib/web/pdf_print_service.js +3 -5
  74. package/lib/web/pdf_sidebar.js +3 -0
  75. package/lib/web/pdf_viewer.component.js +2 -2
  76. package/lib/web/toolbar.js +2 -0
  77. package/lib/web/ui_utils.js +1 -1
  78. package/package.json +1 -1
  79. package/web/pdf_viewer.css +5 -9
  80. package/web/pdf_viewer.js +60 -45
  81. package/web/pdf_viewer.js.map +1 -1
  82. package/external/streams/streams-lib.js +0 -3962
  83. package/external/url/url-lib.js +0 -627
  84. package/lib/shared/url_polyfill.js +0 -56
package/lib/core/obj.js CHANGED
@@ -62,7 +62,7 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArra
62
62
 
63
63
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
64
64
 
65
- function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
65
+ function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
66
66
 
67
67
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
68
68
 
@@ -1229,10 +1229,10 @@ var XRef = function XRefClosure() {
1229
1229
  this.pdfManager = pdfManager;
1230
1230
  this.entries = [];
1231
1231
  this.xrefstms = Object.create(null);
1232
- this.cache = [];
1232
+ this._cacheMap = new Map();
1233
1233
  this.stats = {
1234
- streamTypes: [],
1235
- fontTypes: []
1234
+ streamTypes: Object.create(null),
1235
+ fontTypes: Object.create(null)
1236
1236
  };
1237
1237
  }
1238
1238
 
@@ -1792,21 +1792,21 @@ var XRef = function XRefClosure() {
1792
1792
  return null;
1793
1793
  },
1794
1794
  fetchIfRef: function XRef_fetchIfRef(obj, suppressEncryption) {
1795
- if (!(0, _primitives.isRef)(obj)) {
1796
- return obj;
1795
+ if (obj instanceof _primitives.Ref) {
1796
+ return this.fetch(obj, suppressEncryption);
1797
1797
  }
1798
1798
 
1799
- return this.fetch(obj, suppressEncryption);
1799
+ return obj;
1800
1800
  },
1801
1801
  fetch: function XRef_fetch(ref, suppressEncryption) {
1802
- if (!(0, _primitives.isRef)(ref)) {
1802
+ if (!(ref instanceof _primitives.Ref)) {
1803
1803
  throw new Error('ref object is not a reference');
1804
1804
  }
1805
1805
 
1806
1806
  var num = ref.num;
1807
1807
 
1808
- if (num in this.cache) {
1809
- var cacheEntry = this.cache[num];
1808
+ if (this._cacheMap.has(num)) {
1809
+ var cacheEntry = this._cacheMap.get(num);
1810
1810
 
1811
1811
  if (cacheEntry instanceof _primitives.Dict && !cacheEntry.objId) {
1812
1812
  cacheEntry.objId = ref.toString();
@@ -1818,7 +1818,9 @@ var XRef = function XRefClosure() {
1818
1818
  var xrefEntry = this.getEntry(num);
1819
1819
 
1820
1820
  if (xrefEntry === null) {
1821
- return this.cache[num] = null;
1821
+ this._cacheMap.set(num, xrefEntry);
1822
+
1823
+ return xrefEntry;
1822
1824
  }
1823
1825
 
1824
1826
  if (xrefEntry.uncompressed) {
@@ -1885,7 +1887,7 @@ var XRef = function XRefClosure() {
1885
1887
  }
1886
1888
 
1887
1889
  if (!(0, _primitives.isStream)(xrefEntry)) {
1888
- this.cache[num] = xrefEntry;
1890
+ this._cacheMap.set(num, xrefEntry);
1889
1891
  }
1890
1892
 
1891
1893
  return xrefEntry;
@@ -1942,7 +1944,7 @@ var XRef = function XRefClosure() {
1942
1944
  var entry = this.entries[num];
1943
1945
 
1944
1946
  if (entry && entry.offset === tableOffset && entry.gen === i) {
1945
- this.cache[num] = entries[i];
1947
+ this._cacheMap.set(num, entries[i]);
1946
1948
  }
1947
1949
  }
1948
1950
 
@@ -1962,15 +1964,15 @@ var XRef = function XRefClosure() {
1962
1964
  while (1) {
1963
1965
  switch (_context.prev = _context.next) {
1964
1966
  case 0:
1965
- if ((0, _primitives.isRef)(obj)) {
1967
+ if (!(obj instanceof _primitives.Ref)) {
1966
1968
  _context.next = 2;
1967
1969
  break;
1968
1970
  }
1969
1971
 
1970
- return _context.abrupt("return", obj);
1972
+ return _context.abrupt("return", this.fetchAsync(obj, suppressEncryption));
1971
1973
 
1972
1974
  case 2:
1973
- return _context.abrupt("return", this.fetchAsync(obj, suppressEncryption));
1975
+ return _context.abrupt("return", obj);
1974
1976
 
1975
1977
  case 3:
1976
1978
  case "end":
@@ -536,12 +536,12 @@ var OperatorList = function OperatorListClosure() {
536
536
  var CHUNK_SIZE = 1000;
537
537
  var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5;
538
538
 
539
- function OperatorList(intent, messageHandler, pageIndex) {
540
- this.messageHandler = messageHandler;
539
+ function OperatorList(intent, streamSink, pageIndex) {
540
+ this._streamSink = streamSink;
541
541
  this.fnArray = [];
542
542
  this.argsArray = [];
543
543
 
544
- if (messageHandler && intent !== 'oplist') {
544
+ if (streamSink && intent !== 'oplist') {
545
545
  this.optimizer = new QueueOptimizer(this);
546
546
  } else {
547
547
  this.optimizer = new NullOptimizer(this);
@@ -552,6 +552,7 @@ var OperatorList = function OperatorListClosure() {
552
552
  this.pageIndex = pageIndex;
553
553
  this.intent = intent;
554
554
  this.weight = 0;
555
+ this._resolved = streamSink ? null : Promise.resolve();
555
556
  }
556
557
 
557
558
  OperatorList.prototype = {
@@ -559,6 +560,10 @@ var OperatorList = function OperatorListClosure() {
559
560
  return this.argsArray.length;
560
561
  },
561
562
 
563
+ get ready() {
564
+ return this._resolved || this._streamSink.ready;
565
+ },
566
+
562
567
  get totalLength() {
563
568
  return this._totalLength + this.length;
564
569
  },
@@ -567,7 +572,7 @@ var OperatorList = function OperatorListClosure() {
567
572
  this.optimizer.push(fn, args);
568
573
  this.weight++;
569
574
 
570
- if (this.messageHandler) {
575
+ if (this._streamSink) {
571
576
  if (this.weight >= CHUNK_SIZE) {
572
577
  this.flush();
573
578
  } else if (this.weight >= CHUNK_SIZE_ABOUT && (fn === _util.OPS.restore || fn === _util.OPS.endText)) {
@@ -633,16 +638,14 @@ var OperatorList = function OperatorListClosure() {
633
638
  this.optimizer.flush();
634
639
  var length = this.length;
635
640
  this._totalLength += length;
636
- this.messageHandler.send('RenderPageChunk', {
637
- operatorList: {
638
- fnArray: this.fnArray,
639
- argsArray: this.argsArray,
640
- lastChunk: lastChunk,
641
- length: length
642
- },
643
- pageIndex: this.pageIndex,
644
- intent: this.intent
645
- }, this._transfers);
641
+
642
+ this._streamSink.enqueue({
643
+ fnArray: this.fnArray,
644
+ argsArray: this.argsArray,
645
+ lastChunk: lastChunk,
646
+ length: length
647
+ }, 1, this._transfers);
648
+
646
649
  this.dependencies = Object.create(null);
647
650
  this.fnArray.length = 0;
648
651
  this.argsArray.length = 0;
@@ -94,7 +94,7 @@ function () {
94
94
  }, {
95
95
  key: "shift",
96
96
  value: function shift() {
97
- if ((0, _primitives.isCmd)(this.buf2, 'ID')) {
97
+ if (this.buf2 instanceof _primitives.Cmd && this.buf2.cmd === 'ID') {
98
98
  this.buf1 = this.buf2;
99
99
  this.buf2 = null;
100
100
  } else {
@@ -118,7 +118,8 @@ function () {
118
118
  }
119
119
  }, {
120
120
  key: "getObj",
121
- value: function getObj(cipherTransform) {
121
+ value: function getObj() {
122
+ var cipherTransform = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
122
123
  var buf1 = this.buf1;
123
124
  this.shift();
124
125
 
@@ -186,27 +187,23 @@ function () {
186
187
  }
187
188
 
188
189
  if (Number.isInteger(buf1)) {
189
- var num = buf1;
190
-
191
190
  if (Number.isInteger(this.buf1) && (0, _primitives.isCmd)(this.buf2, 'R')) {
192
- var ref = _primitives.Ref.get(num, this.buf1);
191
+ var ref = _primitives.Ref.get(buf1, this.buf1);
193
192
 
194
193
  this.shift();
195
194
  this.shift();
196
195
  return ref;
197
196
  }
198
197
 
199
- return num;
198
+ return buf1;
200
199
  }
201
200
 
202
- if ((0, _util.isString)(buf1)) {
203
- var str = buf1;
204
-
201
+ if (typeof buf1 === 'string') {
205
202
  if (cipherTransform) {
206
- str = cipherTransform.decryptString(str);
203
+ return cipherTransform.decryptString(buf1);
207
204
  }
208
205
 
209
- return str;
206
+ return buf1;
210
207
  }
211
208
 
212
209
  return buf1;
@@ -748,7 +745,7 @@ function () {
748
745
  }
749
746
 
750
747
  if (name === 'RunLengthDecode' || name === 'RL') {
751
- xrefStreamStats[_util.StreamType.RL] = true;
748
+ xrefStreamStats[_util.StreamType.RLX] = true;
752
749
  return new _stream.RunLengthStream(stream, maybeLength);
753
750
  }
754
751
 
@@ -104,6 +104,14 @@ Shadings.RadialAxial = function RadialAxialClosure() {
104
104
  var cs = dict.get('ColorSpace', 'CS');
105
105
  cs = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
106
106
  this.cs = cs;
107
+ var bbox = dict.getArray('BBox');
108
+
109
+ if (Array.isArray(bbox) && bbox.length === 4) {
110
+ this.bbox = _util.Util.normalizeRect(bbox);
111
+ } else {
112
+ this.bbox = null;
113
+ }
114
+
107
115
  var t0 = 0.0,
108
116
  t1 = 1.0;
109
117
 
@@ -140,8 +148,8 @@ Shadings.RadialAxial = function RadialAxialClosure() {
140
148
  this.extendEnd = extendEnd;
141
149
  var fnObj = dict.get('Function');
142
150
  var fn = pdfFunctionFactory.createFromArray(fnObj);
143
- var diff = t1 - t0;
144
- var step = diff / 10;
151
+ var NUMBER_OF_SAMPLES = 10;
152
+ var step = (t1 - t0) / NUMBER_OF_SAMPLES;
145
153
  var colorStops = this.colorStops = [];
146
154
 
147
155
  if (t0 >= t1 || step <= 0) {
@@ -153,14 +161,14 @@ Shadings.RadialAxial = function RadialAxialClosure() {
153
161
  ratio = new Float32Array(1);
154
162
  var rgbColor;
155
163
 
156
- for (var i = t0; i <= t1; i += step) {
157
- ratio[0] = i;
164
+ for (var i = 0; i <= NUMBER_OF_SAMPLES; i++) {
165
+ ratio[0] = t0 + i * step;
158
166
  fn(ratio, 0, color, 0);
159
167
  rgbColor = cs.getRgb(color, 0);
160
168
 
161
169
  var cssColor = _util.Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
162
170
 
163
- colorStops.push([(i - t0) / diff, cssColor]);
171
+ colorStops.push([i / NUMBER_OF_SAMPLES, cssColor]);
164
172
  }
165
173
 
166
174
  var background = 'transparent';
@@ -219,7 +227,7 @@ Shadings.RadialAxial = function RadialAxialClosure() {
219
227
  }
220
228
  }
221
229
 
222
- return ['RadialAxial', type, this.colorStops, p0, p1, r0, r1];
230
+ return ['RadialAxial', type, this.bbox, this.colorStops, p0, p1, r0, r1];
223
231
  }
224
232
  };
225
233
  return RadialAxial;
@@ -836,7 +844,14 @@ Shadings.Mesh = function MeshClosure() {
836
844
  this.matrix = matrix;
837
845
  this.shadingType = dict.get('ShadingType');
838
846
  this.type = 'Pattern';
839
- this.bbox = dict.getArray('BBox');
847
+ var bbox = dict.getArray('BBox');
848
+
849
+ if (Array.isArray(bbox) && bbox.length === 4) {
850
+ this.bbox = _util.Util.normalizeRect(bbox);
851
+ } else {
852
+ this.bbox = null;
853
+ }
854
+
840
855
  var cs = dict.get('ColorSpace', 'CS');
841
856
  cs = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
842
857
  this.cs = cs;
@@ -156,7 +156,7 @@ function () {
156
156
  }
157
157
  }, {
158
158
  key: "terminate",
159
- value: function terminate() {
159
+ value: function terminate(reason) {
160
160
  (0, _util.unreachable)('Abstract method `terminate` called');
161
161
  }
162
162
  }, {
@@ -264,7 +264,7 @@ function (_BasePdfManager) {
264
264
  }
265
265
  }, {
266
266
  key: "terminate",
267
- value: function terminate() {}
267
+ value: function terminate(reason) {}
268
268
  }]);
269
269
 
270
270
  return LocalPdfManager;
@@ -378,8 +378,8 @@ function (_BasePdfManager2) {
378
378
  }
379
379
  }, {
380
380
  key: "terminate",
381
- value: function terminate() {
382
- this.streamManager.abort();
381
+ value: function terminate(reason) {
382
+ this.streamManager.abort(reason);
383
383
  }
384
384
  }]);
385
385
 
@@ -34,10 +34,18 @@ exports.isRefsEqual = isRefsEqual;
34
34
  exports.isStream = isStream;
35
35
  exports.RefSetCache = exports.RefSet = exports.Ref = exports.Name = exports.Dict = exports.Cmd = exports.EOF = void 0;
36
36
 
37
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
38
+
37
39
  var _util = require("../shared/util");
38
40
 
41
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
42
+
39
43
  function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
40
44
 
45
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
46
+
47
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
48
+
41
49
  var EOF = {};
42
50
  exports.EOF = EOF;
43
51
 
@@ -104,68 +112,81 @@ var Dict = function DictClosure() {
104
112
  assignXref: function Dict_assignXref(newXref) {
105
113
  this.xref = newXref;
106
114
  },
107
- get: function Dict_get(key1, key2, key3) {
108
- var value;
109
- var xref = this.xref,
110
- suppressEncryption = this.suppressEncryption;
115
+ get: function get(key1, key2, key3) {
116
+ var value = this._map[key1];
111
117
 
112
- if (typeof (value = this._map[key1]) !== 'undefined' || key1 in this._map || typeof key2 === 'undefined') {
113
- return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
114
- }
115
-
116
- if (typeof (value = this._map[key2]) !== 'undefined' || key2 in this._map || typeof key3 === 'undefined') {
117
- return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
118
- }
118
+ if (value === undefined && !(key1 in this._map) && key2 !== undefined) {
119
+ value = this._map[key2];
119
120
 
120
- value = this._map[key3] || null;
121
- return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
122
- },
123
- getAsync: function Dict_getAsync(key1, key2, key3) {
124
- var value;
125
- var xref = this.xref,
126
- suppressEncryption = this.suppressEncryption;
127
-
128
- if (typeof (value = this._map[key1]) !== 'undefined' || key1 in this._map || typeof key2 === 'undefined') {
129
- if (xref) {
130
- return xref.fetchIfRefAsync(value, suppressEncryption);
121
+ if (value === undefined && !(key2 in this._map) && key3 !== undefined) {
122
+ value = this._map[key3];
131
123
  }
132
-
133
- return Promise.resolve(value);
134
124
  }
135
125
 
136
- if (typeof (value = this._map[key2]) !== 'undefined' || key2 in this._map || typeof key3 === 'undefined') {
137
- if (xref) {
138
- return xref.fetchIfRefAsync(value, suppressEncryption);
139
- }
140
-
141
- return Promise.resolve(value);
126
+ if (value instanceof Ref && this.xref) {
127
+ return this.xref.fetch(value, this.suppressEncryption);
142
128
  }
143
129
 
144
- value = this._map[key3] || null;
145
-
146
- if (xref) {
147
- return xref.fetchIfRefAsync(value, suppressEncryption);
130
+ return value;
131
+ },
132
+ getAsync: function () {
133
+ var _getAsync = _asyncToGenerator(
134
+ /*#__PURE__*/
135
+ _regenerator["default"].mark(function _callee(key1, key2, key3) {
136
+ var value;
137
+ return _regenerator["default"].wrap(function _callee$(_context) {
138
+ while (1) {
139
+ switch (_context.prev = _context.next) {
140
+ case 0:
141
+ value = this._map[key1];
142
+
143
+ if (value === undefined && !(key1 in this._map) && key2 !== undefined) {
144
+ value = this._map[key2];
145
+
146
+ if (value === undefined && !(key2 in this._map) && key3 !== undefined) {
147
+ value = this._map[key3];
148
+ }
149
+ }
150
+
151
+ if (!(value instanceof Ref && this.xref)) {
152
+ _context.next = 4;
153
+ break;
154
+ }
155
+
156
+ return _context.abrupt("return", this.xref.fetchAsync(value, this.suppressEncryption));
157
+
158
+ case 4:
159
+ return _context.abrupt("return", value);
160
+
161
+ case 5:
162
+ case "end":
163
+ return _context.stop();
164
+ }
165
+ }
166
+ }, _callee, this);
167
+ }));
168
+
169
+ function getAsync(_x, _x2, _x3) {
170
+ return _getAsync.apply(this, arguments);
148
171
  }
149
172
 
150
- return Promise.resolve(value);
151
- },
152
- getArray: function Dict_getArray(key1, key2, key3) {
173
+ return getAsync;
174
+ }(),
175
+ getArray: function getArray(key1, key2, key3) {
153
176
  var value = this.get(key1, key2, key3);
154
- var xref = this.xref,
155
- suppressEncryption = this.suppressEncryption;
156
177
 
157
- if (!Array.isArray(value) || !xref) {
178
+ if (!Array.isArray(value) || !this.xref) {
158
179
  return value;
159
180
  }
160
181
 
161
182
  value = value.slice();
162
183
 
163
184
  for (var i = 0, ii = value.length; i < ii; i++) {
164
- if (!isRef(value[i])) {
185
+ if (!(value[i] instanceof Ref)) {
165
186
  continue;
166
187
  }
167
188
 
168
- value[i] = xref.fetch(value[i], suppressEncryption);
189
+ value[i] = this.xref.fetch(value[i], this.suppressEncryption);
169
190
  }
170
191
 
171
192
  return value;
@@ -113,6 +113,17 @@ var Stream = function StreamClosure() {
113
113
  this.pos -= bytes.length;
114
114
  return bytes;
115
115
  },
116
+ getByteRange: function getByteRange(begin, end) {
117
+ if (begin < 0) {
118
+ begin = 0;
119
+ }
120
+
121
+ if (end > this.end) {
122
+ end = this.end;
123
+ }
124
+
125
+ return this.bytes.subarray(begin, end);
126
+ },
116
127
  skip: function Stream_skip(n) {
117
128
  if (!n) {
118
129
  n = 1;
@@ -271,6 +282,9 @@ var DecodeStream = function DecodeStreamClosure() {
271
282
 
272
283
  return new Stream(this.buffer, start, length, dict);
273
284
  },
285
+ getByteRange: function getByteRange(begin, end) {
286
+ (0, _util.unreachable)('Should not call DecodeStream.getByteRange');
287
+ },
274
288
  skip: function DecodeStream_skip(n) {
275
289
  if (!n) {
276
290
  n = 1;
@@ -496,7 +496,7 @@ var Type1Parser = function Type1ParserClosure() {
496
496
 
497
497
  return decrypt(bytes, CHAR_STRS_ENCRYPT_KEY, lenIV);
498
498
  },
499
- extractFontProgram: function Type1Parser_extractFontProgram() {
499
+ extractFontProgram: function Type1Parser_extractFontProgram(properties) {
500
500
  var stream = this.stream;
501
501
  var subrs = [],
502
502
  charstrings = [];
@@ -635,6 +635,14 @@ var Type1Parser = function Type1ParserClosure() {
635
635
  lsb: charString.lsb,
636
636
  seac: charString.seac
637
637
  });
638
+
639
+ if (properties.builtInEncoding) {
640
+ var _index = properties.builtInEncoding.indexOf(glyph);
641
+
642
+ if (_index > -1 && properties.widths[_index] === undefined && _index >= properties.firstChar && _index <= properties.lastChar) {
643
+ properties.widths[_index] = charString.width;
644
+ }
645
+ }
638
646
  }
639
647
 
640
648
  return program;
@@ -44,13 +44,11 @@ var _core_utils = require("./core_utils");
44
44
 
45
45
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
46
46
 
47
- function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
48
-
49
47
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
50
48
 
51
49
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
52
50
 
53
- function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
51
+ function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
54
52
 
55
53
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
56
54
 
@@ -97,28 +95,13 @@ var WorkerMessageHandler = {
97
95
  testMessageProcessed = true;
98
96
 
99
97
  if (!(data instanceof Uint8Array)) {
100
- handler.send('test', false);
98
+ handler.send('test', null);
101
99
  return;
102
100
  }
103
101
 
104
102
  var supportTransfers = data[0] === 255;
105
103
  handler.postMessageTransfers = supportTransfers;
106
- var xhr = new XMLHttpRequest();
107
- var responseExists = 'response' in xhr;
108
-
109
- try {
110
- xhr.responseType;
111
- } catch (e) {
112
- responseExists = false;
113
- }
114
-
115
- if (!responseExists) {
116
- handler.send('test', false);
117
- return;
118
- }
119
-
120
104
  handler.send('test', {
121
- supportTypedArray: true,
122
105
  supportTransfers: supportTransfers
123
106
  });
124
107
  });
@@ -136,7 +119,7 @@ var WorkerMessageHandler = {
136
119
  var WorkerTasks = [];
137
120
  var verbosity = (0, _util.getVerbosityLevel)();
138
121
  var apiVersion = docParams.apiVersion;
139
- var workerVersion = '2.2.228';
122
+ var workerVersion = '2.3.200';
140
123
 
141
124
  if (apiVersion !== workerVersion) {
142
125
  throw new Error("The API version \"".concat(apiVersion, "\" does not match ") + "the Worker version \"".concat(workerVersion, "\"."));
@@ -336,8 +319,8 @@ var WorkerMessageHandler = {
336
319
  cancelXHRs = null;
337
320
  });
338
321
 
339
- cancelXHRs = function cancelXHRs() {
340
- pdfStream.cancelAllRequests('abort');
322
+ cancelXHRs = function cancelXHRs(reason) {
323
+ pdfStream.cancelAllRequests(reason);
341
324
  };
342
325
 
343
326
  return pdfManagerCapability.promise;
@@ -405,7 +388,7 @@ var WorkerMessageHandler = {
405
388
  };
406
389
  getPdfManager(data, evaluatorOptions).then(function (newPdfManager) {
407
390
  if (terminated) {
408
- newPdfManager.terminate();
391
+ newPdfManager.terminate(new _util.AbortException('Worker was terminated.'));
409
392
  throw new Error('Worker was terminated');
410
393
  }
411
394
 
@@ -494,24 +477,27 @@ var WorkerMessageHandler = {
494
477
  return page.getAnnotationsData(intent);
495
478
  });
496
479
  });
497
- handler.on('RenderPageRequest', function wphSetupRenderPage(data) {
480
+ handler.on('GetOperatorList', function wphSetupRenderPage(data, sink) {
498
481
  var pageIndex = data.pageIndex;
499
482
  pdfManager.getPage(pageIndex).then(function (page) {
500
- var task = new WorkerTask('RenderPageRequest: page ' + pageIndex);
483
+ var task = new WorkerTask("GetOperatorList: page ".concat(pageIndex));
501
484
  startWorkerTask(task);
502
485
  var start = verbosity >= _util.VerbosityLevel.INFOS ? Date.now() : 0;
503
486
  page.getOperatorList({
504
487
  handler: handler,
488
+ sink: sink,
505
489
  task: task,
506
490
  intent: data.intent,
507
491
  renderInteractiveForms: data.renderInteractiveForms
508
- }).then(function (operatorList) {
492
+ }).then(function (operatorListInfo) {
509
493
  finishWorkerTask(task);
510
494
 
511
495
  if (start) {
512
- (0, _util.info)("page=".concat(pageIndex + 1, " - getOperatorList: time=") + "".concat(Date.now() - start, "ms, len=").concat(operatorList.totalLength));
496
+ (0, _util.info)("page=".concat(pageIndex + 1, " - getOperatorList: time=") + "".concat(Date.now() - start, "ms, len=").concat(operatorListInfo.length));
513
497
  }
514
- }, function (e) {
498
+
499
+ sink.close();
500
+ }, function (reason) {
515
501
  finishWorkerTask(task);
516
502
 
517
503
  if (task.terminated) {
@@ -521,31 +507,7 @@ var WorkerMessageHandler = {
521
507
  handler.send('UnsupportedFeature', {
522
508
  featureId: _util.UNSUPPORTED_FEATURES.unknown
523
509
  });
524
- var minimumStackMessage = 'worker.js: while trying to getPage() and getOperatorList()';
525
- var wrappedException;
526
-
527
- if (typeof e === 'string') {
528
- wrappedException = {
529
- message: e,
530
- stack: minimumStackMessage
531
- };
532
- } else if (_typeof(e) === 'object') {
533
- wrappedException = {
534
- message: e.message || e.toString(),
535
- stack: e.stack || minimumStackMessage
536
- };
537
- } else {
538
- wrappedException = {
539
- message: 'Unknown exception type: ' + _typeof(e),
540
- stack: minimumStackMessage
541
- };
542
- }
543
-
544
- handler.send('PageError', {
545
- pageIndex: pageIndex,
546
- error: wrappedException,
547
- intent: data.intent
548
- });
510
+ sink.error(reason);
549
511
  });
550
512
  });
551
513
  }, this);
@@ -582,7 +544,6 @@ var WorkerMessageHandler = {
582
544
  }
583
545
 
584
546
  sink.error(reason);
585
- throw reason;
586
547
  });
587
548
  });
588
549
  });
@@ -596,12 +557,12 @@ var WorkerMessageHandler = {
596
557
  terminated = true;
597
558
 
598
559
  if (pdfManager) {
599
- pdfManager.terminate();
560
+ pdfManager.terminate(new _util.AbortException('Worker was terminated.'));
600
561
  pdfManager = null;
601
562
  }
602
563
 
603
564
  if (cancelXHRs) {
604
- cancelXHRs();
565
+ cancelXHRs(new _util.AbortException('Worker was terminated.'));
605
566
  }
606
567
 
607
568
  (0, _primitives.clearPrimitiveCaches)();