pdfjs-dist 2.0.943 → 2.1.266

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 (159) hide show
  1. package/bower.json +1 -1
  2. package/build/pdf.js +15329 -11095
  3. package/build/pdf.js.map +1 -1
  4. package/build/pdf.min.js +1 -1
  5. package/build/pdf.worker.js +12497 -4184
  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 +3438 -1209
  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 +335 -109
  12. package/lib/core/arithmetic_decoder.js +274 -244
  13. package/lib/core/bidi.js +64 -5
  14. package/lib/core/ccitt.js +172 -17
  15. package/lib/core/ccitt_stream.js +14 -5
  16. package/lib/core/cff_parser.js +304 -28
  17. package/lib/core/charsets.js +4 -3
  18. package/lib/core/chunked_stream.js +379 -149
  19. package/lib/core/cmap.js +210 -40
  20. package/lib/core/colorspace.js +332 -187
  21. package/lib/core/crypto.js +289 -44
  22. package/lib/core/document.js +508 -249
  23. package/lib/core/encodings.js +18 -9
  24. package/lib/core/evaluator.js +657 -119
  25. package/lib/core/font_renderer.js +217 -34
  26. package/lib/core/fonts.js +632 -41
  27. package/lib/core/function.js +252 -26
  28. package/lib/core/glyphlist.js +2 -1
  29. package/lib/core/image.js +124 -27
  30. package/lib/core/jbig2.js +425 -65
  31. package/lib/core/jbig2_stream.js +18 -7
  32. package/lib/core/jpeg_stream.js +24 -8
  33. package/lib/core/jpg.js +208 -16
  34. package/lib/core/jpx.js +395 -5
  35. package/lib/core/jpx_stream.js +17 -5
  36. package/lib/core/metrics.js +3 -3
  37. package/lib/core/murmurhash3.js +23 -5
  38. package/lib/core/obj.js +625 -132
  39. package/lib/core/operator_list.js +104 -3
  40. package/lib/core/parser.js +262 -25
  41. package/lib/core/pattern.js +144 -12
  42. package/lib/core/pdf_manager.js +104 -70
  43. package/lib/core/primitives.js +74 -21
  44. package/lib/core/ps_parser.js +133 -44
  45. package/lib/core/standard_fonts.js +9 -9
  46. package/lib/core/stream.js +283 -31
  47. package/lib/core/type1_parser.js +138 -6
  48. package/lib/core/unicode.js +28 -1
  49. package/lib/core/worker.js +192 -57
  50. package/lib/display/annotation_layer.js +303 -123
  51. package/lib/display/api.js +1073 -574
  52. package/lib/display/api_compatibility.js +4 -1
  53. package/lib/display/canvas.js +314 -18
  54. package/lib/display/content_disposition.js +70 -23
  55. package/lib/display/dom_utils.js +112 -59
  56. package/lib/display/fetch_stream.js +95 -50
  57. package/lib/display/font_loader.js +250 -132
  58. package/lib/display/metadata.js +37 -15
  59. package/lib/display/network.js +123 -34
  60. package/lib/display/network_utils.js +23 -10
  61. package/lib/display/node_stream.js +162 -65
  62. package/lib/display/pattern_helper.js +57 -6
  63. package/lib/display/svg.js +194 -18
  64. package/lib/display/text_layer.js +128 -14
  65. package/lib/display/transport_stream.js +83 -27
  66. package/lib/display/webgl.js +63 -17
  67. package/lib/display/worker_options.js +4 -3
  68. package/lib/display/xml_parser.js +162 -52
  69. package/lib/examples/node/domstubs.js +56 -3
  70. package/lib/pdf.js +15 -2
  71. package/lib/pdf.worker.js +4 -2
  72. package/lib/shared/compatibility.js +129 -26
  73. package/lib/shared/global_scope.js +1 -1
  74. package/lib/shared/is_node.js +3 -3
  75. package/lib/shared/message_handler.js +103 -45
  76. package/lib/shared/streams_polyfill.js +20 -16
  77. package/lib/shared/url_polyfill.js +8 -2
  78. package/lib/shared/util.js +246 -84
  79. package/lib/test/unit/annotation_spec.js +99 -73
  80. package/lib/test/unit/api_spec.js +347 -113
  81. package/lib/test/unit/bidi_spec.js +6 -6
  82. package/lib/test/unit/cff_parser_spec.js +17 -5
  83. package/lib/test/unit/clitests_helper.js +7 -8
  84. package/lib/test/unit/cmap_spec.js +79 -25
  85. package/lib/test/unit/colorspace_spec.js +65 -18
  86. package/lib/test/unit/crypto_spec.js +16 -4
  87. package/lib/test/unit/custom_spec.js +40 -52
  88. package/lib/test/unit/display_svg_spec.js +32 -16
  89. package/lib/test/unit/document_spec.js +2 -2
  90. package/lib/test/unit/dom_utils_spec.js +8 -8
  91. package/lib/test/unit/encodings_spec.js +24 -44
  92. package/lib/test/unit/evaluator_spec.js +15 -8
  93. package/lib/test/unit/function_spec.js +16 -4
  94. package/lib/test/unit/jasmine-boot.js +29 -16
  95. package/lib/test/unit/message_handler_spec.js +19 -6
  96. package/lib/test/unit/metadata_spec.js +64 -11
  97. package/lib/test/unit/murmurhash3_spec.js +2 -2
  98. package/lib/test/unit/network_spec.js +19 -4
  99. package/lib/test/unit/network_utils_spec.js +6 -4
  100. package/lib/test/unit/node_stream_spec.js +50 -26
  101. package/lib/test/unit/parser_spec.js +13 -29
  102. package/lib/test/unit/pdf_find_controller_spec.js +144 -32
  103. package/lib/test/unit/pdf_find_utils_spec.js +10 -9
  104. package/lib/test/unit/pdf_history_spec.js +20 -8
  105. package/lib/test/unit/primitives_spec.js +23 -3
  106. package/lib/test/unit/stream_spec.js +8 -3
  107. package/lib/test/unit/test_utils.js +89 -26
  108. package/lib/test/unit/testreporter.js +19 -1
  109. package/lib/test/unit/type1_parser_spec.js +7 -5
  110. package/lib/test/unit/ui_utils_spec.js +162 -38
  111. package/lib/test/unit/unicode_spec.js +13 -10
  112. package/lib/test/unit/util_spec.js +89 -9
  113. package/lib/web/annotation_layer_builder.js +38 -21
  114. package/lib/web/app.js +610 -245
  115. package/lib/web/app_options.js +54 -34
  116. package/lib/web/base_viewer.js +359 -162
  117. package/lib/web/chromecom.js +159 -80
  118. package/lib/web/debugger.js +161 -17
  119. package/lib/web/download_manager.js +29 -11
  120. package/lib/web/firefox_print_service.js +16 -8
  121. package/lib/web/firefoxcom.js +127 -91
  122. package/lib/web/genericcom.js +50 -31
  123. package/lib/web/genericl10n.js +46 -34
  124. package/lib/web/grab_to_pan.js +25 -3
  125. package/lib/web/interfaces.js +108 -61
  126. package/lib/web/overlay_manager.js +67 -45
  127. package/lib/web/password_prompt.js +20 -12
  128. package/lib/web/pdf_attachment_viewer.js +37 -17
  129. package/lib/web/pdf_cursor_tools.js +38 -15
  130. package/lib/web/pdf_document_properties.js +65 -24
  131. package/lib/web/pdf_find_bar.js +48 -20
  132. package/lib/web/pdf_find_controller.js +290 -89
  133. package/lib/web/pdf_find_utils.js +19 -3
  134. package/lib/web/pdf_history.js +186 -49
  135. package/lib/web/pdf_link_service.js +127 -52
  136. package/lib/web/pdf_outline_viewer.js +71 -21
  137. package/lib/web/pdf_page_view.js +188 -63
  138. package/lib/web/pdf_presentation_mode.js +98 -33
  139. package/lib/web/pdf_print_service.js +54 -10
  140. package/lib/web/pdf_rendering_queue.js +26 -4
  141. package/lib/web/pdf_sidebar.js +116 -62
  142. package/lib/web/pdf_sidebar_resizer.js +41 -15
  143. package/lib/web/pdf_single_page_viewer.js +65 -68
  144. package/lib/web/pdf_thumbnail_view.js +102 -31
  145. package/lib/web/pdf_thumbnail_viewer.js +62 -22
  146. package/lib/web/pdf_viewer.component.js +111 -31
  147. package/lib/web/pdf_viewer.js +80 -60
  148. package/lib/web/preferences.js +61 -39
  149. package/lib/web/secondary_toolbar.js +101 -82
  150. package/lib/web/text_layer_builder.js +124 -69
  151. package/lib/web/toolbar.js +67 -27
  152. package/lib/web/ui_utils.js +284 -128
  153. package/lib/web/view_history.js +75 -51
  154. package/lib/web/viewer_compatibility.js +2 -1
  155. package/package.json +1 -1
  156. package/web/pdf_viewer.css +1 -1
  157. package/web/pdf_viewer.js +2200 -973
  158. package/web/pdf_viewer.js.map +1 -1
  159. package/lib/web/dom_events.js +0 -140
@@ -19,54 +19,74 @@
19
19
  * @licend The above is the entire license notice for the
20
20
  * Javascript code in this page
21
21
  */
22
- 'use strict';
22
+ "use strict";
23
23
 
24
24
  Object.defineProperty(exports, "__esModule", {
25
25
  value: true
26
26
  });
27
- exports.PDFNodeStream = undefined;
27
+ exports.PDFNodeStream = void 0;
28
28
 
29
- var _regenerator = require('babel-runtime/regenerator');
29
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
30
30
 
31
- var _regenerator2 = _interopRequireDefault(_regenerator);
31
+ var _util = require("../shared/util");
32
32
 
33
- var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
33
+ var _network_utils = require("./network_utils");
34
34
 
35
- var _util = require('../shared/util');
35
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
36
36
 
37
- var _network_utils = require('./network_utils');
37
+ 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); }
38
38
 
39
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
39
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
40
+
41
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
40
42
 
41
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
43
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
42
44
 
43
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
45
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
44
46
 
45
- function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
47
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
48
+
49
+ 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); } }
50
+
51
+ 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); }); }; }
46
52
 
47
53
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
48
54
 
55
+ 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); } }
56
+
57
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
58
+
49
59
  var fs = require('fs');
60
+
50
61
  var http = require('http');
62
+
51
63
  var https = require('https');
64
+
52
65
  var url = require('url');
53
66
 
54
67
  var fileUriRegex = /^file:\/\/\/[a-zA-Z]:\//;
68
+
55
69
  function parseUrl(sourceUrl) {
56
70
  var parsedUrl = url.parse(sourceUrl);
71
+
57
72
  if (parsedUrl.protocol === 'file:' || parsedUrl.host) {
58
73
  return parsedUrl;
59
74
  }
75
+
60
76
  if (/^[a-z]:[/\\]/i.test(sourceUrl)) {
61
- return url.parse('file:///' + sourceUrl);
77
+ return url.parse("file:///".concat(sourceUrl));
62
78
  }
79
+
63
80
  if (!parsedUrl.host) {
64
81
  parsedUrl.protocol = 'file:';
65
82
  }
83
+
66
84
  return parsedUrl;
67
85
  }
68
86
 
69
- var PDFNodeStream = function () {
87
+ var PDFNodeStream =
88
+ /*#__PURE__*/
89
+ function () {
70
90
  function PDFNodeStream(source) {
71
91
  _classCallCheck(this, PDFNodeStream);
72
92
 
@@ -80,26 +100,30 @@ var PDFNodeStream = function () {
80
100
  }
81
101
 
82
102
  _createClass(PDFNodeStream, [{
83
- key: 'getFullReader',
103
+ key: "getFullReader",
84
104
  value: function getFullReader() {
85
105
  (0, _util.assert)(!this._fullRequest);
86
106
  this._fullRequest = this.isFsUrl ? new PDFNodeStreamFsFullReader(this) : new PDFNodeStreamFullReader(this);
87
107
  return this._fullRequest;
88
108
  }
89
109
  }, {
90
- key: 'getRangeReader',
110
+ key: "getRangeReader",
91
111
  value: function getRangeReader(start, end) {
92
112
  var rangeReader = this.isFsUrl ? new PDFNodeStreamFsRangeReader(this, start, end) : new PDFNodeStreamRangeReader(this, start, end);
113
+
93
114
  this._rangeRequestReaders.push(rangeReader);
115
+
94
116
  return rangeReader;
95
117
  }
96
118
  }, {
97
- key: 'cancelAllRequests',
119
+ key: "cancelAllRequests",
98
120
  value: function cancelAllRequests(reason) {
99
121
  if (this._fullRequest) {
100
122
  this._fullRequest.cancel(reason);
101
123
  }
124
+
102
125
  var readers = this._rangeRequestReaders.slice(0);
126
+
103
127
  readers.forEach(function (reader) {
104
128
  reader.cancel(reason);
105
129
  });
@@ -109,7 +133,11 @@ var PDFNodeStream = function () {
109
133
  return PDFNodeStream;
110
134
  }();
111
135
 
112
- var BaseFullReader = function () {
136
+ exports.PDFNodeStream = PDFNodeStream;
137
+
138
+ var BaseFullReader =
139
+ /*#__PURE__*/
140
+ function () {
113
141
  function BaseFullReader(stream) {
114
142
  _classCallCheck(this, BaseFullReader);
115
143
 
@@ -123,9 +151,11 @@ var BaseFullReader = function () {
123
151
  this._filename = null;
124
152
  this._disableRange = source.disableRange || false;
125
153
  this._rangeChunkSize = source.rangeChunkSize;
154
+
126
155
  if (!this._rangeChunkSize && !this._disableRange) {
127
156
  this._disableRange = true;
128
157
  }
158
+
129
159
  this._isStreamingSupported = !source.disableStream;
130
160
  this._isRangeSupported = !source.disableRange;
131
161
  this._readableStream = null;
@@ -134,11 +164,13 @@ var BaseFullReader = function () {
134
164
  }
135
165
 
136
166
  _createClass(BaseFullReader, [{
137
- key: 'read',
167
+ key: "read",
138
168
  value: function () {
139
- var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee() {
169
+ var _read = _asyncToGenerator(
170
+ /*#__PURE__*/
171
+ _regenerator.default.mark(function _callee() {
140
172
  var chunk, buffer;
141
- return _regenerator2.default.wrap(function _callee$(_context) {
173
+ return _regenerator.default.wrap(function _callee$(_context) {
142
174
  while (1) {
143
175
  switch (_context.prev = _context.next) {
144
176
  case 0:
@@ -151,7 +183,7 @@ var BaseFullReader = function () {
151
183
  break;
152
184
  }
153
185
 
154
- return _context.abrupt('return', {
186
+ return _context.abrupt("return", {
155
187
  value: undefined,
156
188
  done: true
157
189
  });
@@ -173,24 +205,26 @@ var BaseFullReader = function () {
173
205
  }
174
206
 
175
207
  this._readCapability = (0, _util.createPromiseCapability)();
176
- return _context.abrupt('return', this.read());
208
+ return _context.abrupt("return", this.read());
177
209
 
178
210
  case 10:
179
211
  this._loaded += chunk.length;
212
+
180
213
  if (this.onProgress) {
181
214
  this.onProgress({
182
215
  loaded: this._loaded,
183
216
  total: this._contentLength
184
217
  });
185
218
  }
219
+
186
220
  buffer = new Uint8Array(chunk).buffer;
187
- return _context.abrupt('return', {
221
+ return _context.abrupt("return", {
188
222
  value: buffer,
189
223
  done: false
190
224
  });
191
225
 
192
226
  case 14:
193
- case 'end':
227
+ case "end":
194
228
  return _context.stop();
195
229
  }
196
230
  }
@@ -198,28 +232,31 @@ var BaseFullReader = function () {
198
232
  }));
199
233
 
200
234
  function read() {
201
- return _ref.apply(this, arguments);
235
+ return _read.apply(this, arguments);
202
236
  }
203
237
 
204
238
  return read;
205
239
  }()
206
240
  }, {
207
- key: 'cancel',
241
+ key: "cancel",
208
242
  value: function cancel(reason) {
209
243
  if (!this._readableStream) {
210
244
  this._error(reason);
245
+
211
246
  return;
212
247
  }
248
+
213
249
  this._readableStream.destroy(reason);
214
250
  }
215
251
  }, {
216
- key: '_error',
252
+ key: "_error",
217
253
  value: function _error(reason) {
218
254
  this._storedError = reason;
255
+
219
256
  this._readCapability.resolve();
220
257
  }
221
258
  }, {
222
- key: '_setReadableStream',
259
+ key: "_setReadableStream",
223
260
  value: function _setReadableStream(readableStream) {
224
261
  var _this = this;
225
262
 
@@ -230,40 +267,43 @@ var BaseFullReader = function () {
230
267
  readableStream.on('end', function () {
231
268
  readableStream.destroy();
232
269
  _this._done = true;
270
+
233
271
  _this._readCapability.resolve();
234
272
  });
235
273
  readableStream.on('error', function (reason) {
236
274
  _this._error(reason);
237
275
  });
276
+
238
277
  if (!this._isStreamingSupported && this._isRangeSupported) {
239
278
  this._error(new _util.AbortException('streaming is disabled'));
240
279
  }
280
+
241
281
  if (this._storedError) {
242
282
  this._readableStream.destroy(this._storedError);
243
283
  }
244
284
  }
245
285
  }, {
246
- key: 'headersReady',
286
+ key: "headersReady",
247
287
  get: function get() {
248
288
  return this._headersCapability.promise;
249
289
  }
250
290
  }, {
251
- key: 'filename',
291
+ key: "filename",
252
292
  get: function get() {
253
293
  return this._filename;
254
294
  }
255
295
  }, {
256
- key: 'contentLength',
296
+ key: "contentLength",
257
297
  get: function get() {
258
298
  return this._contentLength;
259
299
  }
260
300
  }, {
261
- key: 'isRangeSupported',
301
+ key: "isRangeSupported",
262
302
  get: function get() {
263
303
  return this._isRangeSupported;
264
304
  }
265
305
  }, {
266
- key: 'isStreamingSupported',
306
+ key: "isStreamingSupported",
267
307
  get: function get() {
268
308
  return this._isStreamingSupported;
269
309
  }
@@ -272,7 +312,9 @@ var BaseFullReader = function () {
272
312
  return BaseFullReader;
273
313
  }();
274
314
 
275
- var BaseRangeReader = function () {
315
+ var BaseRangeReader =
316
+ /*#__PURE__*/
317
+ function () {
276
318
  function BaseRangeReader(stream) {
277
319
  _classCallCheck(this, BaseRangeReader);
278
320
 
@@ -288,11 +330,13 @@ var BaseRangeReader = function () {
288
330
  }
289
331
 
290
332
  _createClass(BaseRangeReader, [{
291
- key: 'read',
333
+ key: "read",
292
334
  value: function () {
293
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2() {
335
+ var _read2 = _asyncToGenerator(
336
+ /*#__PURE__*/
337
+ _regenerator.default.mark(function _callee2() {
294
338
  var chunk, buffer;
295
- return _regenerator2.default.wrap(function _callee2$(_context2) {
339
+ return _regenerator.default.wrap(function _callee2$(_context2) {
296
340
  while (1) {
297
341
  switch (_context2.prev = _context2.next) {
298
342
  case 0:
@@ -305,7 +349,7 @@ var BaseRangeReader = function () {
305
349
  break;
306
350
  }
307
351
 
308
- return _context2.abrupt('return', {
352
+ return _context2.abrupt("return", {
309
353
  value: undefined,
310
354
  done: true
311
355
  });
@@ -327,21 +371,25 @@ var BaseRangeReader = function () {
327
371
  }
328
372
 
329
373
  this._readCapability = (0, _util.createPromiseCapability)();
330
- return _context2.abrupt('return', this.read());
374
+ return _context2.abrupt("return", this.read());
331
375
 
332
376
  case 10:
333
377
  this._loaded += chunk.length;
378
+
334
379
  if (this.onProgress) {
335
- this.onProgress({ loaded: this._loaded });
380
+ this.onProgress({
381
+ loaded: this._loaded
382
+ });
336
383
  }
384
+
337
385
  buffer = new Uint8Array(chunk).buffer;
338
- return _context2.abrupt('return', {
386
+ return _context2.abrupt("return", {
339
387
  value: buffer,
340
388
  done: false
341
389
  });
342
390
 
343
391
  case 14:
344
- case 'end':
392
+ case "end":
345
393
  return _context2.stop();
346
394
  }
347
395
  }
@@ -349,28 +397,31 @@ var BaseRangeReader = function () {
349
397
  }));
350
398
 
351
399
  function read() {
352
- return _ref2.apply(this, arguments);
400
+ return _read2.apply(this, arguments);
353
401
  }
354
402
 
355
403
  return read;
356
404
  }()
357
405
  }, {
358
- key: 'cancel',
406
+ key: "cancel",
359
407
  value: function cancel(reason) {
360
408
  if (!this._readableStream) {
361
409
  this._error(reason);
410
+
362
411
  return;
363
412
  }
413
+
364
414
  this._readableStream.destroy(reason);
365
415
  }
366
416
  }, {
367
- key: '_error',
417
+ key: "_error",
368
418
  value: function _error(reason) {
369
419
  this._storedError = reason;
420
+
370
421
  this._readCapability.resolve();
371
422
  }
372
423
  }, {
373
- key: '_setReadableStream',
424
+ key: "_setReadableStream",
374
425
  value: function _setReadableStream(readableStream) {
375
426
  var _this2 = this;
376
427
 
@@ -381,17 +432,19 @@ var BaseRangeReader = function () {
381
432
  readableStream.on('end', function () {
382
433
  readableStream.destroy();
383
434
  _this2._done = true;
435
+
384
436
  _this2._readCapability.resolve();
385
437
  });
386
438
  readableStream.on('error', function (reason) {
387
439
  _this2._error(reason);
388
440
  });
441
+
389
442
  if (this._storedError) {
390
443
  this._readableStream.destroy(this._storedError);
391
444
  }
392
445
  }
393
446
  }, {
394
- key: 'isStreamingSupported',
447
+ key: "isStreamingSupported",
395
448
  get: function get() {
396
449
  return this._isStreamingSupported;
397
450
  }
@@ -412,23 +465,32 @@ function createRequestOptions(url, headers) {
412
465
  };
413
466
  }
414
467
 
415
- var PDFNodeStreamFullReader = function (_BaseFullReader) {
468
+ var PDFNodeStreamFullReader =
469
+ /*#__PURE__*/
470
+ function (_BaseFullReader) {
416
471
  _inherits(PDFNodeStreamFullReader, _BaseFullReader);
417
472
 
418
473
  function PDFNodeStreamFullReader(stream) {
474
+ var _this3;
475
+
419
476
  _classCallCheck(this, PDFNodeStreamFullReader);
420
477
 
421
- var _this3 = _possibleConstructorReturn(this, (PDFNodeStreamFullReader.__proto__ || Object.getPrototypeOf(PDFNodeStreamFullReader)).call(this, stream));
478
+ _this3 = _possibleConstructorReturn(this, _getPrototypeOf(PDFNodeStreamFullReader).call(this, stream));
422
479
 
423
480
  var handleResponse = function handleResponse(response) {
424
481
  if (response.statusCode === 404) {
425
- var error = new _util.MissingPDFException('Missing PDF "' + _this3._url + '".');
482
+ var error = new _util.MissingPDFException("Missing PDF \"".concat(_this3._url, "\"."));
426
483
  _this3._storedError = error;
484
+
427
485
  _this3._headersCapability.reject(error);
486
+
428
487
  return;
429
488
  }
489
+
430
490
  _this3._headersCapability.resolve();
491
+
431
492
  _this3._setReadableStream(response);
493
+
432
494
  var getResponseHeader = function getResponseHeader(name) {
433
495
  return _this3._readableStream.headers[name.toLowerCase()];
434
496
  };
@@ -446,87 +508,118 @@ var PDFNodeStreamFullReader = function (_BaseFullReader) {
446
508
  _this3._contentLength = suggestedLength || _this3._contentLength;
447
509
  _this3._filename = (0, _network_utils.extractFilenameFromHeader)(getResponseHeader);
448
510
  };
511
+
449
512
  _this3._request = null;
513
+
450
514
  if (_this3._url.protocol === 'http:') {
451
515
  _this3._request = http.request(createRequestOptions(_this3._url, stream.httpHeaders), handleResponse);
452
516
  } else {
453
517
  _this3._request = https.request(createRequestOptions(_this3._url, stream.httpHeaders), handleResponse);
454
518
  }
519
+
455
520
  _this3._request.on('error', function (reason) {
456
521
  _this3._storedError = reason;
522
+
457
523
  _this3._headersCapability.reject(reason);
458
524
  });
525
+
459
526
  _this3._request.end();
527
+
460
528
  return _this3;
461
529
  }
462
530
 
463
531
  return PDFNodeStreamFullReader;
464
532
  }(BaseFullReader);
465
533
 
466
- var PDFNodeStreamRangeReader = function (_BaseRangeReader) {
534
+ var PDFNodeStreamRangeReader =
535
+ /*#__PURE__*/
536
+ function (_BaseRangeReader) {
467
537
  _inherits(PDFNodeStreamRangeReader, _BaseRangeReader);
468
538
 
469
539
  function PDFNodeStreamRangeReader(stream, start, end) {
470
- _classCallCheck(this, PDFNodeStreamRangeReader);
540
+ var _this4;
471
541
 
472
- var _this4 = _possibleConstructorReturn(this, (PDFNodeStreamRangeReader.__proto__ || Object.getPrototypeOf(PDFNodeStreamRangeReader)).call(this, stream));
542
+ _classCallCheck(this, PDFNodeStreamRangeReader);
473
543
 
544
+ _this4 = _possibleConstructorReturn(this, _getPrototypeOf(PDFNodeStreamRangeReader).call(this, stream));
474
545
  _this4._httpHeaders = {};
546
+
475
547
  for (var property in stream.httpHeaders) {
476
548
  var value = stream.httpHeaders[property];
549
+
477
550
  if (typeof value === 'undefined') {
478
551
  continue;
479
552
  }
553
+
480
554
  _this4._httpHeaders[property] = value;
481
555
  }
482
- _this4._httpHeaders['Range'] = 'bytes=' + start + '-' + (end - 1);
556
+
557
+ _this4._httpHeaders['Range'] = "bytes=".concat(start, "-").concat(end - 1);
558
+
483
559
  var handleResponse = function handleResponse(response) {
484
560
  if (response.statusCode === 404) {
485
- var error = new _util.MissingPDFException('Missing PDF "' + _this4._url + '".');
561
+ var error = new _util.MissingPDFException("Missing PDF \"".concat(_this4._url, "\"."));
486
562
  _this4._storedError = error;
487
563
  return;
488
564
  }
565
+
489
566
  _this4._setReadableStream(response);
490
567
  };
568
+
491
569
  _this4._request = null;
570
+
492
571
  if (_this4._url.protocol === 'http:') {
493
572
  _this4._request = http.request(createRequestOptions(_this4._url, _this4._httpHeaders), handleResponse);
494
573
  } else {
495
574
  _this4._request = https.request(createRequestOptions(_this4._url, _this4._httpHeaders), handleResponse);
496
575
  }
576
+
497
577
  _this4._request.on('error', function (reason) {
498
578
  _this4._storedError = reason;
499
579
  });
580
+
500
581
  _this4._request.end();
582
+
501
583
  return _this4;
502
584
  }
503
585
 
504
586
  return PDFNodeStreamRangeReader;
505
587
  }(BaseRangeReader);
506
588
 
507
- var PDFNodeStreamFsFullReader = function (_BaseFullReader2) {
589
+ var PDFNodeStreamFsFullReader =
590
+ /*#__PURE__*/
591
+ function (_BaseFullReader2) {
508
592
  _inherits(PDFNodeStreamFsFullReader, _BaseFullReader2);
509
593
 
510
594
  function PDFNodeStreamFsFullReader(stream) {
511
- _classCallCheck(this, PDFNodeStreamFsFullReader);
595
+ var _this5;
512
596
 
513
- var _this5 = _possibleConstructorReturn(this, (PDFNodeStreamFsFullReader.__proto__ || Object.getPrototypeOf(PDFNodeStreamFsFullReader)).call(this, stream));
597
+ _classCallCheck(this, PDFNodeStreamFsFullReader);
514
598
 
599
+ _this5 = _possibleConstructorReturn(this, _getPrototypeOf(PDFNodeStreamFsFullReader).call(this, stream));
515
600
  var path = decodeURIComponent(_this5._url.path);
601
+
516
602
  if (fileUriRegex.test(_this5._url.href)) {
517
603
  path = path.replace(/^\//, '');
518
604
  }
605
+
519
606
  fs.lstat(path, function (error, stat) {
520
607
  if (error) {
521
608
  if (error.code === 'ENOENT') {
522
- error = new _util.MissingPDFException('Missing PDF "' + path + '".');
609
+ error = new _util.MissingPDFException("Missing PDF \"".concat(path, "\"."));
523
610
  }
611
+
524
612
  _this5._storedError = error;
613
+
525
614
  _this5._headersCapability.reject(error);
615
+
526
616
  return;
527
617
  }
618
+
528
619
  _this5._contentLength = stat.size;
620
+
529
621
  _this5._setReadableStream(fs.createReadStream(path));
622
+
530
623
  _this5._headersCapability.resolve();
531
624
  });
532
625
  return _this5;
@@ -535,26 +628,30 @@ var PDFNodeStreamFsFullReader = function (_BaseFullReader2) {
535
628
  return PDFNodeStreamFsFullReader;
536
629
  }(BaseFullReader);
537
630
 
538
- var PDFNodeStreamFsRangeReader = function (_BaseRangeReader2) {
631
+ var PDFNodeStreamFsRangeReader =
632
+ /*#__PURE__*/
633
+ function (_BaseRangeReader2) {
539
634
  _inherits(PDFNodeStreamFsRangeReader, _BaseRangeReader2);
540
635
 
541
636
  function PDFNodeStreamFsRangeReader(stream, start, end) {
542
- _classCallCheck(this, PDFNodeStreamFsRangeReader);
637
+ var _this6;
543
638
 
544
- var _this6 = _possibleConstructorReturn(this, (PDFNodeStreamFsRangeReader.__proto__ || Object.getPrototypeOf(PDFNodeStreamFsRangeReader)).call(this, stream));
639
+ _classCallCheck(this, PDFNodeStreamFsRangeReader);
545
640
 
641
+ _this6 = _possibleConstructorReturn(this, _getPrototypeOf(PDFNodeStreamFsRangeReader).call(this, stream));
546
642
  var path = decodeURIComponent(_this6._url.path);
643
+
547
644
  if (fileUriRegex.test(_this6._url.href)) {
548
645
  path = path.replace(/^\//, '');
549
646
  }
647
+
550
648
  _this6._setReadableStream(fs.createReadStream(path, {
551
649
  start: start,
552
650
  end: end - 1
553
651
  }));
652
+
554
653
  return _this6;
555
654
  }
556
655
 
557
656
  return PDFNodeStreamFsRangeReader;
558
- }(BaseRangeReader);
559
-
560
- exports.PDFNodeStream = PDFNodeStream;
657
+ }(BaseRangeReader);