pdfjs-dist 2.0.487 → 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 (161) hide show
  1. package/bower.json +1 -1
  2. package/build/pdf.js +15564 -9476
  3. package/build/pdf.js.map +1 -1
  4. package/build/pdf.min.js +1 -1
  5. package/build/pdf.worker.js +46644 -36309
  6. package/build/pdf.worker.js.map +1 -1
  7. package/build/pdf.worker.min.js +1 -1
  8. package/external/url/url-lib.js +627 -0
  9. package/image_decoders/pdf.image_decoders.js +11430 -0
  10. package/image_decoders/pdf.image_decoders.js.map +1 -0
  11. package/image_decoders/pdf.image_decoders.min.js +1 -0
  12. package/lib/core/annotation.js +406 -131
  13. package/lib/core/arithmetic_decoder.js +275 -245
  14. package/lib/core/bidi.js +65 -6
  15. package/lib/core/ccitt.js +173 -18
  16. package/lib/core/ccitt_stream.js +15 -6
  17. package/lib/core/cff_parser.js +376 -53
  18. package/lib/core/charsets.js +5 -4
  19. package/lib/core/chunked_stream.js +387 -149
  20. package/lib/core/cmap.js +310 -75
  21. package/lib/core/colorspace.js +874 -594
  22. package/lib/core/crypto.js +290 -45
  23. package/lib/core/document.js +545 -260
  24. package/lib/core/encodings.js +19 -10
  25. package/lib/core/evaluator.js +725 -147
  26. package/lib/core/font_renderer.js +360 -91
  27. package/lib/core/fonts.js +791 -186
  28. package/lib/core/function.js +284 -71
  29. package/lib/core/glyphlist.js +3 -2
  30. package/lib/core/image.js +168 -61
  31. package/lib/core/jbig2.js +479 -66
  32. package/lib/core/jbig2_stream.js +19 -8
  33. package/lib/core/jpeg_stream.js +38 -13
  34. package/lib/core/jpg.js +252 -29
  35. package/lib/core/jpx.js +396 -6
  36. package/lib/core/jpx_stream.js +18 -6
  37. package/lib/core/metrics.js +4 -4
  38. package/lib/core/murmurhash3.js +24 -6
  39. package/lib/core/obj.js +1137 -475
  40. package/lib/core/operator_list.js +108 -6
  41. package/lib/core/parser.js +321 -68
  42. package/lib/core/pattern.js +145 -13
  43. package/lib/core/pdf_manager.js +321 -133
  44. package/lib/core/primitives.js +75 -22
  45. package/lib/core/ps_parser.js +134 -45
  46. package/lib/core/standard_fonts.js +10 -10
  47. package/lib/core/stream.js +313 -34
  48. package/lib/core/type1_parser.js +143 -13
  49. package/lib/core/unicode.js +31 -4
  50. package/lib/core/worker.js +210 -66
  51. package/lib/display/annotation_layer.js +361 -123
  52. package/lib/display/api.js +1454 -729
  53. package/lib/display/api_compatibility.js +11 -13
  54. package/lib/display/canvas.js +324 -29
  55. package/lib/display/content_disposition.js +83 -32
  56. package/lib/display/dom_utils.js +226 -41
  57. package/lib/display/fetch_stream.js +208 -84
  58. package/lib/display/font_loader.js +465 -236
  59. package/lib/display/metadata.js +38 -16
  60. package/lib/display/network.js +216 -51
  61. package/lib/display/network_utils.js +32 -19
  62. package/lib/display/node_stream.js +352 -169
  63. package/lib/display/pattern_helper.js +58 -7
  64. package/lib/display/svg.js +242 -29
  65. package/lib/display/text_layer.js +132 -18
  66. package/lib/display/transport_stream.js +171 -42
  67. package/lib/display/webgl.js +64 -18
  68. package/lib/display/worker_options.js +5 -4
  69. package/lib/display/xml_parser.js +166 -53
  70. package/lib/examples/node/domstubs.js +57 -4
  71. package/lib/pdf.js +21 -4
  72. package/lib/pdf.worker.js +5 -3
  73. package/lib/shared/compatibility.js +158 -564
  74. package/lib/shared/global_scope.js +2 -2
  75. package/lib/shared/is_node.js +4 -4
  76. package/lib/shared/message_handler.js +521 -0
  77. package/lib/shared/streams_polyfill.js +21 -17
  78. package/lib/shared/url_polyfill.js +56 -0
  79. package/lib/shared/util.js +295 -650
  80. package/lib/test/unit/annotation_spec.js +629 -345
  81. package/lib/test/unit/api_spec.js +555 -253
  82. package/lib/test/unit/bidi_spec.js +7 -7
  83. package/lib/test/unit/cff_parser_spec.js +40 -11
  84. package/lib/test/unit/clitests_helper.js +9 -7
  85. package/lib/test/unit/cmap_spec.js +80 -26
  86. package/lib/test/unit/colorspace_spec.js +99 -52
  87. package/lib/test/unit/crypto_spec.js +17 -5
  88. package/lib/test/unit/custom_spec.js +41 -53
  89. package/lib/test/unit/display_svg_spec.js +33 -17
  90. package/lib/test/unit/document_spec.js +3 -3
  91. package/lib/test/unit/dom_utils_spec.js +9 -9
  92. package/lib/test/unit/encodings_spec.js +25 -45
  93. package/lib/test/unit/evaluator_spec.js +34 -9
  94. package/lib/test/unit/function_spec.js +17 -5
  95. package/lib/test/unit/jasmine-boot.js +31 -18
  96. package/lib/test/unit/{util_stream_spec.js → message_handler_spec.js} +41 -69
  97. package/lib/test/unit/metadata_spec.js +71 -11
  98. package/lib/test/unit/murmurhash3_spec.js +3 -3
  99. package/lib/test/unit/network_spec.js +20 -5
  100. package/lib/test/unit/network_utils_spec.js +41 -14
  101. package/lib/test/unit/node_stream_spec.js +51 -27
  102. package/lib/test/unit/parser_spec.js +35 -8
  103. package/lib/test/unit/pdf_find_controller_spec.js +230 -0
  104. package/lib/test/unit/pdf_find_utils_spec.js +63 -0
  105. package/lib/test/unit/pdf_history_spec.js +21 -9
  106. package/lib/test/unit/primitives_spec.js +24 -4
  107. package/lib/test/unit/stream_spec.js +12 -4
  108. package/lib/test/unit/test_utils.js +90 -27
  109. package/lib/test/unit/testreporter.js +21 -3
  110. package/lib/test/unit/type1_parser_spec.js +8 -6
  111. package/lib/test/unit/ui_utils_spec.js +452 -14
  112. package/lib/test/unit/unicode_spec.js +14 -11
  113. package/lib/test/unit/util_spec.js +131 -9
  114. package/lib/web/annotation_layer_builder.js +39 -22
  115. package/lib/web/app.js +1240 -582
  116. package/lib/web/app_options.js +71 -41
  117. package/lib/web/base_viewer.js +508 -179
  118. package/lib/web/chromecom.js +261 -117
  119. package/lib/web/debugger.js +166 -22
  120. package/lib/web/download_manager.js +31 -13
  121. package/lib/web/firefox_print_service.js +17 -9
  122. package/lib/web/firefoxcom.js +283 -79
  123. package/lib/web/genericcom.js +89 -30
  124. package/lib/web/genericl10n.js +142 -30
  125. package/lib/web/grab_to_pan.js +26 -4
  126. package/lib/web/interfaces.js +170 -47
  127. package/lib/web/overlay_manager.js +235 -85
  128. package/lib/web/password_prompt.js +21 -13
  129. package/lib/web/pdf_attachment_viewer.js +38 -18
  130. package/lib/web/pdf_cursor_tools.js +39 -16
  131. package/lib/web/pdf_document_properties.js +80 -30
  132. package/lib/web/pdf_find_bar.js +84 -40
  133. package/lib/web/pdf_find_controller.js +495 -184
  134. package/lib/web/pdf_find_utils.js +111 -0
  135. package/lib/web/pdf_history.js +190 -53
  136. package/lib/web/pdf_link_service.js +137 -76
  137. package/lib/web/pdf_outline_viewer.js +73 -22
  138. package/lib/web/pdf_page_view.js +196 -63
  139. package/lib/web/pdf_presentation_mode.js +99 -34
  140. package/lib/web/pdf_print_service.js +57 -11
  141. package/lib/web/pdf_rendering_queue.js +27 -5
  142. package/lib/web/pdf_sidebar.js +120 -67
  143. package/lib/web/pdf_sidebar_resizer.js +42 -16
  144. package/lib/web/pdf_single_page_viewer.js +74 -66
  145. package/lib/web/pdf_thumbnail_view.js +103 -32
  146. package/lib/web/pdf_thumbnail_viewer.js +64 -24
  147. package/lib/web/pdf_viewer.component.js +112 -32
  148. package/lib/web/pdf_viewer.js +91 -52
  149. package/lib/web/preferences.js +275 -80
  150. package/lib/web/secondary_toolbar.js +165 -40
  151. package/lib/web/text_layer_builder.js +162 -65
  152. package/lib/web/toolbar.js +78 -43
  153. package/lib/web/ui_utils.js +462 -136
  154. package/lib/web/view_history.js +215 -67
  155. package/lib/web/viewer_compatibility.js +4 -13
  156. package/package.json +5 -4
  157. package/web/pdf_viewer.css +58 -1
  158. package/web/pdf_viewer.js +6346 -3919
  159. package/web/pdf_viewer.js.map +1 -1
  160. package/lib/test/unit/fonts_spec.js +0 -81
  161. package/lib/web/dom_events.js +0 -137
@@ -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 2017 Mozilla Foundation
5
+ * Copyright 2018 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.
@@ -19,66 +19,81 @@
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.NetworkManager = exports.PDFNetworkStream = undefined;
27
+ exports.PDFNetworkStream = PDFNetworkStream;
28
+ exports.NetworkManager = NetworkManager;
28
29
 
29
- var _util = require('../shared/util');
30
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
30
31
 
31
- var _network_utils = require('./network_utils');
32
+ var _util = require("../shared/util");
32
33
 
33
- var _global_scope = require('../shared/global_scope');
34
+ var _network_utils = require("./network_utils");
34
35
 
35
- var _global_scope2 = _interopRequireDefault(_global_scope);
36
+ var _global_scope = _interopRequireDefault(require("../shared/global_scope"));
36
37
 
37
38
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
38
39
 
40
+ 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); } }
41
+
42
+ 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); }); }; }
43
+
39
44
  ;
40
45
  var OK_RESPONSE = 200;
41
46
  var PARTIAL_CONTENT_RESPONSE = 206;
47
+
42
48
  function NetworkManager(url, args) {
43
49
  this.url = url;
44
50
  args = args || {};
45
51
  this.isHttp = /^https?:/i.test(url);
46
52
  this.httpHeaders = this.isHttp && args.httpHeaders || {};
47
53
  this.withCredentials = args.withCredentials || false;
54
+
48
55
  this.getXhr = args.getXhr || function NetworkManager_getXhr() {
49
56
  return new XMLHttpRequest();
50
57
  };
58
+
51
59
  this.currXhrId = 0;
52
60
  this.pendingRequests = Object.create(null);
53
61
  this.loadedRequests = Object.create(null);
54
62
  }
63
+
55
64
  function getArrayBuffer(xhr) {
56
65
  var data = xhr.response;
66
+
57
67
  if (typeof data !== 'string') {
58
68
  return data;
59
69
  }
70
+
60
71
  var array = (0, _util.stringToBytes)(data);
61
72
  return array.buffer;
62
73
  }
74
+
63
75
  var supportsMozChunked = function supportsMozChunkedClosure() {
64
76
  try {
65
77
  var x = new XMLHttpRequest();
66
- x.open('GET', _global_scope2.default.location.href);
78
+ x.open('GET', _global_scope.default.location.href);
67
79
  x.responseType = 'moz-chunked-arraybuffer';
68
80
  return x.responseType === 'moz-chunked-arraybuffer';
69
81
  } catch (e) {
70
82
  return false;
71
83
  }
72
84
  }();
85
+
73
86
  NetworkManager.prototype = {
74
87
  requestRange: function NetworkManager_requestRange(begin, end, listeners) {
75
88
  var args = {
76
89
  begin: begin,
77
90
  end: end
78
91
  };
92
+
79
93
  for (var prop in listeners) {
80
94
  args[prop] = listeners[prop];
81
95
  }
96
+
82
97
  return this.request(args);
83
98
  },
84
99
  requestFull: function NetworkManager_requestFull(listeners) {
@@ -87,16 +102,22 @@ NetworkManager.prototype = {
87
102
  request: function NetworkManager_request(args) {
88
103
  var xhr = this.getXhr();
89
104
  var xhrId = this.currXhrId++;
90
- var pendingRequest = this.pendingRequests[xhrId] = { xhr: xhr };
105
+ var pendingRequest = this.pendingRequests[xhrId] = {
106
+ xhr: xhr
107
+ };
91
108
  xhr.open('GET', this.url);
92
109
  xhr.withCredentials = this.withCredentials;
110
+
93
111
  for (var property in this.httpHeaders) {
94
112
  var value = this.httpHeaders[property];
113
+
95
114
  if (typeof value === 'undefined') {
96
115
  continue;
97
116
  }
117
+
98
118
  xhr.setRequestHeader(property, value);
99
119
  }
120
+
100
121
  if (this.isHttp && 'begin' in args && 'end' in args) {
101
122
  var rangeStr = args.begin + '-' + (args.end - 1);
102
123
  xhr.setRequestHeader('Range', 'bytes=' + rangeStr);
@@ -104,7 +125,9 @@ NetworkManager.prototype = {
104
125
  } else {
105
126
  pendingRequest.expectedStatus = 200;
106
127
  }
128
+
107
129
  var useMozChunkedLoading = supportsMozChunked && !!args.onProgressiveData;
130
+
108
131
  if (useMozChunkedLoading) {
109
132
  xhr.responseType = 'moz-chunked-arraybuffer';
110
133
  pendingRequest.onProgressiveData = args.onProgressiveData;
@@ -112,11 +135,13 @@ NetworkManager.prototype = {
112
135
  } else {
113
136
  xhr.responseType = 'arraybuffer';
114
137
  }
138
+
115
139
  if (args.onError) {
116
140
  xhr.onerror = function (evt) {
117
141
  args.onError(xhr.status);
118
142
  };
119
143
  }
144
+
120
145
  xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
121
146
  xhr.onprogress = this.onProgress.bind(this, xhrId);
122
147
  pendingRequest.onHeadersReceived = args.onHeadersReceived;
@@ -128,51 +153,68 @@ NetworkManager.prototype = {
128
153
  },
129
154
  onProgress: function NetworkManager_onProgress(xhrId, evt) {
130
155
  var pendingRequest = this.pendingRequests[xhrId];
156
+
131
157
  if (!pendingRequest) {
132
158
  return;
133
159
  }
160
+
134
161
  if (pendingRequest.mozChunked) {
135
162
  var chunk = getArrayBuffer(pendingRequest.xhr);
136
163
  pendingRequest.onProgressiveData(chunk);
137
164
  }
165
+
138
166
  var onProgress = pendingRequest.onProgress;
167
+
139
168
  if (onProgress) {
140
169
  onProgress(evt);
141
170
  }
142
171
  },
143
172
  onStateChange: function NetworkManager_onStateChange(xhrId, evt) {
144
173
  var pendingRequest = this.pendingRequests[xhrId];
174
+
145
175
  if (!pendingRequest) {
146
176
  return;
147
177
  }
178
+
148
179
  var xhr = pendingRequest.xhr;
180
+
149
181
  if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
150
182
  pendingRequest.onHeadersReceived();
151
183
  delete pendingRequest.onHeadersReceived;
152
184
  }
185
+
153
186
  if (xhr.readyState !== 4) {
154
187
  return;
155
188
  }
189
+
156
190
  if (!(xhrId in this.pendingRequests)) {
157
191
  return;
158
192
  }
193
+
159
194
  delete this.pendingRequests[xhrId];
195
+
160
196
  if (xhr.status === 0 && this.isHttp) {
161
197
  if (pendingRequest.onError) {
162
198
  pendingRequest.onError(xhr.status);
163
199
  }
200
+
164
201
  return;
165
202
  }
203
+
166
204
  var xhrStatus = xhr.status || OK_RESPONSE;
167
205
  var ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
206
+
168
207
  if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
169
208
  if (pendingRequest.onError) {
170
209
  pendingRequest.onError(xhr.status);
171
210
  }
211
+
172
212
  return;
173
213
  }
214
+
174
215
  this.loadedRequests[xhrId] = true;
175
216
  var chunk = getArrayBuffer(xhr);
217
+
176
218
  if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
177
219
  var rangeHeader = xhr.getResponseHeader('Content-Range');
178
220
  var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
@@ -196,6 +238,7 @@ NetworkManager.prototype = {
196
238
  for (var xhrId in this.pendingRequests) {
197
239
  return true;
198
240
  }
241
+
199
242
  return false;
200
243
  },
201
244
  getRequestXhr: function NetworkManager_getXhr(xhrId) {
@@ -221,6 +264,7 @@ NetworkManager.prototype = {
221
264
  xhr.abort();
222
265
  }
223
266
  };
267
+
224
268
  function PDFNetworkStream(source) {
225
269
  this._source = source;
226
270
  this._manager = new NetworkManager(source.url, {
@@ -231,9 +275,11 @@ function PDFNetworkStream(source) {
231
275
  this._fullRequestReader = null;
232
276
  this._rangeRequestReaders = [];
233
277
  }
278
+
234
279
  PDFNetworkStream.prototype = {
235
280
  _onRangeRequestReaderClosed: function PDFNetworkStream_onRangeRequestReaderClosed(reader) {
236
281
  var i = this._rangeRequestReaders.indexOf(reader);
282
+
237
283
  if (i >= 0) {
238
284
  this._rangeRequestReaders.splice(i, 1);
239
285
  }
@@ -246,19 +292,24 @@ PDFNetworkStream.prototype = {
246
292
  getRangeReader: function PDFNetworkStream_getRangeReader(begin, end) {
247
293
  var reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end);
248
294
  reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
295
+
249
296
  this._rangeRequestReaders.push(reader);
297
+
250
298
  return reader;
251
299
  },
252
300
  cancelAllRequests: function PDFNetworkStream_cancelAllRequests(reason) {
253
301
  if (this._fullRequestReader) {
254
302
  this._fullRequestReader.cancel(reason);
255
303
  }
304
+
256
305
  var readers = this._rangeRequestReaders.slice(0);
306
+
257
307
  readers.forEach(function (reader) {
258
308
  reader.cancel(reason);
259
309
  });
260
310
  }
261
311
  };
312
+
262
313
  function PDFNetworkStreamFullRequestReader(manager, source) {
263
314
  this._manager = manager;
264
315
  var args = {
@@ -274,9 +325,11 @@ function PDFNetworkStreamFullRequestReader(manager, source) {
274
325
  this._disableRange = source.disableRange || false;
275
326
  this._contentLength = source.length;
276
327
  this._rangeChunkSize = source.rangeChunkSize;
328
+
277
329
  if (!this._rangeChunkSize && !this._disableRange) {
278
330
  this._disableRange = true;
279
331
  }
332
+
280
333
  this._isStreamingSupported = false;
281
334
  this._isRangeSupported = false;
282
335
  this._cachedChunks = [];
@@ -286,10 +339,13 @@ function PDFNetworkStreamFullRequestReader(manager, source) {
286
339
  this._filename = null;
287
340
  this.onProgress = null;
288
341
  }
342
+
289
343
  PDFNetworkStreamFullRequestReader.prototype = {
290
344
  _onHeadersReceived: function PDFNetworkStreamFullRequestReader_onHeadersReceived() {
291
345
  var fullRequestXhrId = this._fullRequestId;
346
+
292
347
  var fullRequestXhr = this._manager.getRequestXhr(fullRequestXhrId);
348
+
293
349
  var getResponseHeader = function getResponseHeader(name) {
294
350
  return fullRequestXhr.getResponseHeader(name);
295
351
  };
@@ -306,19 +362,23 @@ PDFNetworkStreamFullRequestReader.prototype = {
306
362
  if (allowRangeRequests) {
307
363
  this._isRangeSupported = true;
308
364
  }
365
+
309
366
  this._contentLength = suggestedLength || this._contentLength;
310
367
  this._filename = (0, _network_utils.extractFilenameFromHeader)(getResponseHeader);
311
368
  var networkManager = this._manager;
369
+
312
370
  if (networkManager.isStreamingRequest(fullRequestXhrId)) {
313
371
  this._isStreamingSupported = true;
314
372
  } else if (this._isRangeSupported) {
315
373
  networkManager.abortRequest(fullRequestXhrId);
316
374
  }
375
+
317
376
  this._headersReceivedCapability.resolve();
318
377
  },
319
378
  _onProgressiveData: function PDFNetworkStreamFullRequestReader_onProgressiveData(chunk) {
320
379
  if (this._requests.length > 0) {
321
380
  var requestCapability = this._requests.shift();
381
+
322
382
  requestCapability.resolve({
323
383
  value: chunk,
324
384
  done: false
@@ -331,26 +391,33 @@ PDFNetworkStreamFullRequestReader.prototype = {
331
391
  if (args) {
332
392
  this._onProgressiveData(args.chunk);
333
393
  }
394
+
334
395
  this._done = true;
396
+
335
397
  if (this._cachedChunks.length > 0) {
336
398
  return;
337
399
  }
400
+
338
401
  this._requests.forEach(function (requestCapability) {
339
402
  requestCapability.resolve({
340
403
  value: undefined,
341
404
  done: true
342
405
  });
343
406
  });
407
+
344
408
  this._requests = [];
345
409
  },
346
410
  _onError: function PDFNetworkStreamFullRequestReader_onError(status) {
347
411
  var url = this._url;
348
412
  var exception = (0, _network_utils.createResponseStatusError)(status, url);
349
413
  this._storedError = exception;
414
+
350
415
  this._headersReceivedCapability.reject(exception);
416
+
351
417
  this._requests.forEach(function (requestCapability) {
352
418
  requestCapability.reject(exception);
353
419
  });
420
+
354
421
  this._requests = [];
355
422
  this._cachedChunks = [];
356
423
  },
@@ -362,58 +429,109 @@ PDFNetworkStreamFullRequestReader.prototype = {
362
429
  });
363
430
  }
364
431
  },
432
+
365
433
  get filename() {
366
434
  return this._filename;
367
435
  },
436
+
368
437
  get isRangeSupported() {
369
438
  return this._isRangeSupported;
370
439
  },
440
+
371
441
  get isStreamingSupported() {
372
442
  return this._isStreamingSupported;
373
443
  },
444
+
374
445
  get contentLength() {
375
446
  return this._contentLength;
376
447
  },
448
+
377
449
  get headersReady() {
378
450
  return this._headersReceivedCapability.promise;
379
451
  },
380
- read: function PDFNetworkStreamFullRequestReader_read() {
381
- if (this._storedError) {
382
- return Promise.reject(this._storedError);
383
- }
384
- if (this._cachedChunks.length > 0) {
385
- var chunk = this._cachedChunks.shift();
386
- return Promise.resolve({
387
- value: chunk,
388
- done: false
389
- });
390
- }
391
- if (this._done) {
392
- return Promise.resolve({
393
- value: undefined,
394
- done: true
395
- });
452
+
453
+ read: function () {
454
+ var _read = _asyncToGenerator(
455
+ /*#__PURE__*/
456
+ _regenerator.default.mark(function _callee() {
457
+ var chunk, requestCapability;
458
+ return _regenerator.default.wrap(function _callee$(_context) {
459
+ while (1) {
460
+ switch (_context.prev = _context.next) {
461
+ case 0:
462
+ if (!this._storedError) {
463
+ _context.next = 2;
464
+ break;
465
+ }
466
+
467
+ throw this._storedError;
468
+
469
+ case 2:
470
+ if (!(this._cachedChunks.length > 0)) {
471
+ _context.next = 5;
472
+ break;
473
+ }
474
+
475
+ chunk = this._cachedChunks.shift();
476
+ return _context.abrupt("return", {
477
+ value: chunk,
478
+ done: false
479
+ });
480
+
481
+ case 5:
482
+ if (!this._done) {
483
+ _context.next = 7;
484
+ break;
485
+ }
486
+
487
+ return _context.abrupt("return", {
488
+ value: undefined,
489
+ done: true
490
+ });
491
+
492
+ case 7:
493
+ requestCapability = (0, _util.createPromiseCapability)();
494
+
495
+ this._requests.push(requestCapability);
496
+
497
+ return _context.abrupt("return", requestCapability.promise);
498
+
499
+ case 10:
500
+ case "end":
501
+ return _context.stop();
502
+ }
503
+ }
504
+ }, _callee, this);
505
+ }));
506
+
507
+ function read() {
508
+ return _read.apply(this, arguments);
396
509
  }
397
- var requestCapability = (0, _util.createPromiseCapability)();
398
- this._requests.push(requestCapability);
399
- return requestCapability.promise;
400
- },
510
+
511
+ return read;
512
+ }(),
401
513
  cancel: function PDFNetworkStreamFullRequestReader_cancel(reason) {
402
514
  this._done = true;
515
+
403
516
  this._headersReceivedCapability.reject(reason);
517
+
404
518
  this._requests.forEach(function (requestCapability) {
405
519
  requestCapability.resolve({
406
520
  value: undefined,
407
521
  done: true
408
522
  });
409
523
  });
524
+
410
525
  this._requests = [];
526
+
411
527
  if (this._manager.isPendingRequest(this._fullRequestId)) {
412
528
  this._manager.abortRequest(this._fullRequestId);
413
529
  }
530
+
414
531
  this._fullRequestReader = null;
415
532
  }
416
533
  };
534
+
417
535
  function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
418
536
  this._manager = manager;
419
537
  var args = {
@@ -427,6 +545,7 @@ function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
427
545
  this.onProgress = null;
428
546
  this.onClosed = null;
429
547
  }
548
+
430
549
  PDFNetworkStreamRangeRequestReader.prototype = {
431
550
  _close: function PDFNetworkStreamRangeRequestReader_close() {
432
551
  if (this.onClosed) {
@@ -435,8 +554,10 @@ PDFNetworkStreamRangeRequestReader.prototype = {
435
554
  },
436
555
  _onDone: function PDFNetworkStreamRangeRequestReader_onDone(data) {
437
556
  var chunk = data.chunk;
557
+
438
558
  if (this._requests.length > 0) {
439
559
  var requestCapability = this._requests.shift();
560
+
440
561
  requestCapability.resolve({
441
562
  value: chunk,
442
563
  done: false
@@ -444,57 +565,101 @@ PDFNetworkStreamRangeRequestReader.prototype = {
444
565
  } else {
445
566
  this._queuedChunk = chunk;
446
567
  }
568
+
447
569
  this._done = true;
570
+
448
571
  this._requests.forEach(function (requestCapability) {
449
572
  requestCapability.resolve({
450
573
  value: undefined,
451
574
  done: true
452
575
  });
453
576
  });
577
+
454
578
  this._requests = [];
579
+
455
580
  this._close();
456
581
  },
457
582
  _onProgress: function PDFNetworkStreamRangeRequestReader_onProgress(evt) {
458
583
  if (!this.isStreamingSupported && this.onProgress) {
459
- this.onProgress({ loaded: evt.loaded });
584
+ this.onProgress({
585
+ loaded: evt.loaded
586
+ });
460
587
  }
461
588
  },
589
+
462
590
  get isStreamingSupported() {
463
591
  return false;
464
592
  },
465
- read: function PDFNetworkStreamRangeRequestReader_read() {
466
- if (this._queuedChunk !== null) {
467
- var chunk = this._queuedChunk;
468
- this._queuedChunk = null;
469
- return Promise.resolve({
470
- value: chunk,
471
- done: false
472
- });
473
- }
474
- if (this._done) {
475
- return Promise.resolve({
476
- value: undefined,
477
- done: true
478
- });
593
+
594
+ read: function () {
595
+ var _read2 = _asyncToGenerator(
596
+ /*#__PURE__*/
597
+ _regenerator.default.mark(function _callee2() {
598
+ var chunk, requestCapability;
599
+ return _regenerator.default.wrap(function _callee2$(_context2) {
600
+ while (1) {
601
+ switch (_context2.prev = _context2.next) {
602
+ case 0:
603
+ if (!(this._queuedChunk !== null)) {
604
+ _context2.next = 4;
605
+ break;
606
+ }
607
+
608
+ chunk = this._queuedChunk;
609
+ this._queuedChunk = null;
610
+ return _context2.abrupt("return", {
611
+ value: chunk,
612
+ done: false
613
+ });
614
+
615
+ case 4:
616
+ if (!this._done) {
617
+ _context2.next = 6;
618
+ break;
619
+ }
620
+
621
+ return _context2.abrupt("return", {
622
+ value: undefined,
623
+ done: true
624
+ });
625
+
626
+ case 6:
627
+ requestCapability = (0, _util.createPromiseCapability)();
628
+
629
+ this._requests.push(requestCapability);
630
+
631
+ return _context2.abrupt("return", requestCapability.promise);
632
+
633
+ case 9:
634
+ case "end":
635
+ return _context2.stop();
636
+ }
637
+ }
638
+ }, _callee2, this);
639
+ }));
640
+
641
+ function read() {
642
+ return _read2.apply(this, arguments);
479
643
  }
480
- var requestCapability = (0, _util.createPromiseCapability)();
481
- this._requests.push(requestCapability);
482
- return requestCapability.promise;
483
- },
644
+
645
+ return read;
646
+ }(),
484
647
  cancel: function PDFNetworkStreamRangeRequestReader_cancel(reason) {
485
648
  this._done = true;
649
+
486
650
  this._requests.forEach(function (requestCapability) {
487
651
  requestCapability.resolve({
488
652
  value: undefined,
489
653
  done: true
490
654
  });
491
655
  });
656
+
492
657
  this._requests = [];
658
+
493
659
  if (this._manager.isPendingRequest(this._requestId)) {
494
660
  this._manager.abortRequest(this._requestId);
495
661
  }
662
+
496
663
  this._close();
497
664
  }
498
- };
499
- exports.PDFNetworkStream = PDFNetworkStream;
500
- exports.NetworkManager = NetworkManager;
665
+ };