pdfjs-dist 2.0.489 → 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 (169) hide show
  1. package/CODE_OF_CONDUCT.md +15 -0
  2. package/bower.json +1 -1
  3. package/build/pdf.js +18515 -11402
  4. package/build/pdf.js.map +1 -1
  5. package/build/pdf.min.js +1 -1
  6. package/build/pdf.worker.js +48266 -37137
  7. package/build/pdf.worker.js.map +1 -1
  8. package/build/pdf.worker.min.js +1 -1
  9. package/external/url/url-lib.js +627 -0
  10. package/image_decoders/pdf.image_decoders.js +11350 -0
  11. package/image_decoders/pdf.image_decoders.js.map +1 -0
  12. package/image_decoders/pdf.image_decoders.min.js +1 -0
  13. package/lib/core/annotation.js +587 -242
  14. package/lib/core/arithmetic_decoder.js +275 -245
  15. package/lib/core/bidi.js +65 -6
  16. package/lib/core/ccitt.js +173 -18
  17. package/lib/core/ccitt_stream.js +15 -6
  18. package/lib/core/cff_parser.js +433 -61
  19. package/lib/core/charsets.js +5 -4
  20. package/lib/core/chunked_stream.js +400 -152
  21. package/lib/core/cmap.js +326 -87
  22. package/lib/core/colorspace.js +874 -594
  23. package/lib/core/core_utils.js +147 -0
  24. package/lib/core/crypto.js +290 -45
  25. package/lib/core/document.js +560 -268
  26. package/lib/core/encodings.js +19 -10
  27. package/lib/core/evaluator.js +1005 -360
  28. package/lib/core/font_renderer.js +331 -97
  29. package/lib/core/fonts.js +812 -195
  30. package/lib/core/function.js +284 -71
  31. package/lib/core/glyphlist.js +4 -3
  32. package/lib/core/image.js +169 -62
  33. package/lib/core/image_utils.js +111 -0
  34. package/lib/core/jbig2.js +479 -66
  35. package/lib/core/jbig2_stream.js +19 -8
  36. package/lib/core/jpeg_stream.js +38 -13
  37. package/lib/core/jpg.js +253 -29
  38. package/lib/core/jpx.js +396 -6
  39. package/lib/core/jpx_stream.js +18 -6
  40. package/lib/core/metrics.js +15 -15
  41. package/lib/core/murmurhash3.js +56 -34
  42. package/lib/core/obj.js +1354 -488
  43. package/lib/core/operator_list.js +144 -31
  44. package/lib/core/parser.js +539 -191
  45. package/lib/core/pattern.js +148 -14
  46. package/lib/core/pdf_manager.js +323 -133
  47. package/lib/core/primitives.js +111 -24
  48. package/lib/core/ps_parser.js +134 -45
  49. package/lib/core/standard_fonts.js +17 -17
  50. package/lib/core/stream.js +313 -34
  51. package/lib/core/type1_parser.js +143 -13
  52. package/lib/core/unicode.js +32 -5
  53. package/lib/core/worker.js +217 -190
  54. package/lib/core/worker_stream.js +277 -0
  55. package/lib/display/annotation_layer.js +450 -133
  56. package/lib/display/api.js +1597 -784
  57. package/lib/display/api_compatibility.js +11 -13
  58. package/lib/display/canvas.js +360 -44
  59. package/lib/display/content_disposition.js +83 -32
  60. package/lib/display/display_utils.js +747 -0
  61. package/lib/display/fetch_stream.js +221 -90
  62. package/lib/display/font_loader.js +468 -236
  63. package/lib/display/metadata.js +38 -16
  64. package/lib/display/network.js +635 -428
  65. package/lib/display/network_utils.js +32 -19
  66. package/lib/display/node_stream.js +367 -175
  67. package/lib/display/pattern_helper.js +81 -31
  68. package/lib/display/svg.js +1235 -519
  69. package/lib/display/text_layer.js +153 -29
  70. package/lib/display/transport_stream.js +345 -94
  71. package/lib/display/webgl.js +64 -18
  72. package/lib/display/worker_options.js +5 -4
  73. package/lib/display/xml_parser.js +166 -53
  74. package/lib/examples/node/domstubs.js +60 -4
  75. package/lib/pdf.js +36 -14
  76. package/lib/pdf.worker.js +5 -3
  77. package/lib/shared/compatibility.js +158 -564
  78. package/lib/shared/global_scope.js +2 -2
  79. package/lib/shared/is_node.js +4 -4
  80. package/lib/shared/message_handler.js +521 -0
  81. package/lib/shared/streams_polyfill.js +21 -17
  82. package/lib/shared/url_polyfill.js +56 -0
  83. package/lib/shared/util.js +243 -710
  84. package/lib/test/unit/annotation_spec.js +870 -401
  85. package/lib/test/unit/api_spec.js +657 -345
  86. package/lib/test/unit/bidi_spec.js +7 -7
  87. package/lib/test/unit/cff_parser_spec.js +54 -11
  88. package/lib/test/unit/clitests_helper.js +10 -8
  89. package/lib/test/unit/cmap_spec.js +95 -41
  90. package/lib/test/unit/colorspace_spec.js +115 -63
  91. package/lib/test/unit/core_utils_spec.js +191 -0
  92. package/lib/test/unit/crypto_spec.js +17 -5
  93. package/lib/test/unit/custom_spec.js +43 -55
  94. package/lib/test/unit/display_svg_spec.js +34 -18
  95. package/lib/test/unit/display_utils_spec.js +273 -0
  96. package/lib/test/unit/document_spec.js +8 -13
  97. package/lib/test/unit/encodings_spec.js +25 -45
  98. package/lib/test/unit/evaluator_spec.js +38 -15
  99. package/lib/test/unit/fetch_stream_spec.js +109 -0
  100. package/lib/test/unit/function_spec.js +17 -5
  101. package/lib/test/unit/jasmine-boot.js +33 -20
  102. package/lib/test/unit/{util_stream_spec.js → message_handler_spec.js} +41 -69
  103. package/lib/test/unit/metadata_spec.js +71 -11
  104. package/lib/test/unit/murmurhash3_spec.js +3 -3
  105. package/lib/test/unit/network_spec.js +19 -54
  106. package/lib/test/unit/network_utils_spec.js +91 -14
  107. package/lib/test/unit/node_stream_spec.js +56 -32
  108. package/lib/test/unit/parser_spec.js +162 -71
  109. package/lib/test/unit/pdf_find_controller_spec.js +230 -0
  110. package/lib/test/unit/pdf_find_utils_spec.js +63 -0
  111. package/lib/test/unit/pdf_history_spec.js +21 -9
  112. package/lib/test/unit/primitives_spec.js +53 -20
  113. package/lib/test/unit/stream_spec.js +12 -4
  114. package/lib/test/unit/test_utils.js +273 -56
  115. package/lib/test/unit/testreporter.js +21 -3
  116. package/lib/test/unit/type1_parser_spec.js +8 -6
  117. package/lib/test/unit/ui_utils_spec.js +454 -16
  118. package/lib/test/unit/unicode_spec.js +18 -15
  119. package/lib/test/unit/util_spec.js +87 -128
  120. package/lib/web/annotation_layer_builder.js +39 -22
  121. package/lib/web/app.js +1290 -588
  122. package/lib/web/app_options.js +100 -62
  123. package/lib/web/base_viewer.js +511 -182
  124. package/lib/web/chromecom.js +261 -117
  125. package/lib/web/debugger.js +166 -22
  126. package/lib/web/download_manager.js +32 -13
  127. package/lib/web/firefox_print_service.js +20 -10
  128. package/lib/web/firefoxcom.js +315 -80
  129. package/lib/web/genericcom.js +89 -30
  130. package/lib/web/genericl10n.js +142 -30
  131. package/lib/web/grab_to_pan.js +28 -4
  132. package/lib/web/interfaces.js +170 -47
  133. package/lib/web/overlay_manager.js +235 -85
  134. package/lib/web/password_prompt.js +22 -14
  135. package/lib/web/pdf_attachment_viewer.js +38 -18
  136. package/lib/web/pdf_cursor_tools.js +39 -16
  137. package/lib/web/pdf_document_properties.js +255 -136
  138. package/lib/web/pdf_find_bar.js +84 -40
  139. package/lib/web/pdf_find_controller.js +495 -184
  140. package/lib/web/pdf_find_utils.js +111 -0
  141. package/lib/web/pdf_history.js +190 -53
  142. package/lib/web/pdf_link_service.js +138 -77
  143. package/lib/web/pdf_outline_viewer.js +122 -46
  144. package/lib/web/pdf_page_view.js +191 -67
  145. package/lib/web/pdf_presentation_mode.js +99 -34
  146. package/lib/web/pdf_print_service.js +61 -13
  147. package/lib/web/pdf_rendering_queue.js +28 -9
  148. package/lib/web/pdf_sidebar.js +141 -81
  149. package/lib/web/pdf_sidebar_resizer.js +42 -16
  150. package/lib/web/pdf_single_page_viewer.js +74 -66
  151. package/lib/web/pdf_thumbnail_view.js +104 -33
  152. package/lib/web/pdf_thumbnail_viewer.js +66 -26
  153. package/lib/web/pdf_viewer.component.js +112 -32
  154. package/lib/web/pdf_viewer.js +91 -52
  155. package/lib/web/preferences.js +284 -89
  156. package/lib/web/secondary_toolbar.js +165 -40
  157. package/lib/web/text_layer_builder.js +134 -59
  158. package/lib/web/toolbar.js +78 -43
  159. package/lib/web/ui_utils.js +462 -136
  160. package/lib/web/view_history.js +215 -67
  161. package/lib/web/viewer_compatibility.js +4 -13
  162. package/package.json +5 -4
  163. package/web/pdf_viewer.css +79 -11
  164. package/web/pdf_viewer.js +6107 -3748
  165. package/web/pdf_viewer.js.map +1 -1
  166. package/lib/display/dom_utils.js +0 -309
  167. package/lib/test/unit/dom_utils_spec.js +0 -89
  168. package/lib/test/unit/fonts_spec.js +0 -81
  169. 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 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.
@@ -19,49 +19,87 @@
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.PDFDataTransportStream = undefined;
27
+ exports.PDFDataTransportStream = void 0;
28
28
 
29
- var _util = require('../shared/util');
29
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
30
30
 
31
- var PDFDataTransportStream = function PDFDataTransportStreamClosure() {
31
+ var _util = require("../shared/util");
32
+
33
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
34
+
35
+ 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); } }
36
+
37
+ 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); }); }; }
38
+
39
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
40
+
41
+ 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); } }
42
+
43
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
44
+
45
+ var PDFDataTransportStream =
46
+ /*#__PURE__*/
47
+ function () {
32
48
  function PDFDataTransportStream(params, pdfDataRangeTransport) {
33
49
  var _this = this;
34
50
 
51
+ _classCallCheck(this, PDFDataTransportStream);
52
+
35
53
  (0, _util.assert)(pdfDataRangeTransport);
36
54
  this._queuedChunks = [];
55
+ this._progressiveDone = params.progressiveDone || false;
37
56
  var initialData = params.initialData;
57
+
38
58
  if (initialData && initialData.length > 0) {
39
59
  var buffer = new Uint8Array(initialData).buffer;
60
+
40
61
  this._queuedChunks.push(buffer);
41
62
  }
63
+
42
64
  this._pdfDataRangeTransport = pdfDataRangeTransport;
43
65
  this._isStreamingSupported = !params.disableStream;
44
66
  this._isRangeSupported = !params.disableRange;
45
67
  this._contentLength = params.length;
46
68
  this._fullRequestReader = null;
47
69
  this._rangeReaders = [];
70
+
48
71
  this._pdfDataRangeTransport.addRangeListener(function (begin, chunk) {
49
72
  _this._onReceiveData({
50
73
  begin: begin,
51
74
  chunk: chunk
52
75
  });
53
76
  });
54
- this._pdfDataRangeTransport.addProgressListener(function (loaded) {
55
- _this._onProgress({ loaded: loaded });
77
+
78
+ this._pdfDataRangeTransport.addProgressListener(function (loaded, total) {
79
+ _this._onProgress({
80
+ loaded: loaded,
81
+ total: total
82
+ });
56
83
  });
84
+
57
85
  this._pdfDataRangeTransport.addProgressiveReadListener(function (chunk) {
58
- _this._onReceiveData({ chunk: chunk });
86
+ _this._onReceiveData({
87
+ chunk: chunk
88
+ });
89
+ });
90
+
91
+ this._pdfDataRangeTransport.addProgressiveDoneListener(function () {
92
+ _this._onProgressiveDone();
59
93
  });
94
+
60
95
  this._pdfDataRangeTransport.transportReady();
61
96
  }
62
- PDFDataTransportStream.prototype = {
63
- _onReceiveData: function PDFDataTransportStream_onReceiveData(args) {
97
+
98
+ _createClass(PDFDataTransportStream, [{
99
+ key: "_onReceiveData",
100
+ value: function _onReceiveData(args) {
64
101
  var buffer = new Uint8Array(args.chunk).buffer;
102
+
65
103
  if (args.begin === undefined) {
66
104
  if (this._fullRequestReader) {
67
105
  this._fullRequestReader._enqueue(buffer);
@@ -73,119 +111,281 @@ var PDFDataTransportStream = function PDFDataTransportStreamClosure() {
73
111
  if (rangeReader._begin !== args.begin) {
74
112
  return false;
75
113
  }
114
+
76
115
  rangeReader._enqueue(buffer);
116
+
77
117
  return true;
78
118
  });
119
+
79
120
  (0, _util.assert)(found);
80
121
  }
81
- },
82
- _onProgress: function PDFDataTransportStream_onDataProgress(evt) {
83
- if (this._rangeReaders.length > 0) {
122
+ }
123
+ }, {
124
+ key: "_onProgress",
125
+ value: function _onProgress(evt) {
126
+ if (evt.total === undefined) {
84
127
  var firstReader = this._rangeReaders[0];
85
- if (firstReader.onProgress) {
86
- firstReader.onProgress({ loaded: evt.loaded });
128
+
129
+ if (firstReader && firstReader.onProgress) {
130
+ firstReader.onProgress({
131
+ loaded: evt.loaded
132
+ });
133
+ }
134
+ } else {
135
+ var fullReader = this._fullRequestReader;
136
+
137
+ if (fullReader && fullReader.onProgress) {
138
+ fullReader.onProgress({
139
+ loaded: evt.loaded,
140
+ total: evt.total
141
+ });
87
142
  }
88
143
  }
89
- },
90
- _removeRangeReader: function PDFDataTransportStream_removeRangeReader(reader) {
144
+ }
145
+ }, {
146
+ key: "_onProgressiveDone",
147
+ value: function _onProgressiveDone() {
148
+ if (this._fullRequestReader) {
149
+ this._fullRequestReader.progressiveDone();
150
+ }
151
+
152
+ this._progressiveDone = true;
153
+ }
154
+ }, {
155
+ key: "_removeRangeReader",
156
+ value: function _removeRangeReader(reader) {
91
157
  var i = this._rangeReaders.indexOf(reader);
158
+
92
159
  if (i >= 0) {
93
160
  this._rangeReaders.splice(i, 1);
94
161
  }
95
- },
96
- getFullReader: function PDFDataTransportStream_getFullReader() {
162
+ }
163
+ }, {
164
+ key: "getFullReader",
165
+ value: function getFullReader() {
97
166
  (0, _util.assert)(!this._fullRequestReader);
98
167
  var queuedChunks = this._queuedChunks;
99
168
  this._queuedChunks = null;
100
- return new PDFDataTransportStreamReader(this, queuedChunks);
101
- },
102
- getRangeReader: function PDFDataTransportStream_getRangeReader(begin, end) {
169
+ return new PDFDataTransportStreamReader(this, queuedChunks, this._progressiveDone);
170
+ }
171
+ }, {
172
+ key: "getRangeReader",
173
+ value: function getRangeReader(begin, end) {
174
+ if (end <= this._progressiveDataLength) {
175
+ return null;
176
+ }
177
+
103
178
  var reader = new PDFDataTransportStreamRangeReader(this, begin, end);
179
+
104
180
  this._pdfDataRangeTransport.requestDataRange(begin, end);
181
+
105
182
  this._rangeReaders.push(reader);
183
+
106
184
  return reader;
107
- },
108
- cancelAllRequests: function PDFDataTransportStream_cancelAllRequests(reason) {
185
+ }
186
+ }, {
187
+ key: "cancelAllRequests",
188
+ value: function cancelAllRequests(reason) {
109
189
  if (this._fullRequestReader) {
110
190
  this._fullRequestReader.cancel(reason);
111
191
  }
192
+
112
193
  var readers = this._rangeReaders.slice(0);
194
+
113
195
  readers.forEach(function (rangeReader) {
114
196
  rangeReader.cancel(reason);
115
197
  });
198
+
116
199
  this._pdfDataRangeTransport.abort();
117
200
  }
118
- };
201
+ }, {
202
+ key: "_progressiveDataLength",
203
+ get: function get() {
204
+ return this._fullRequestReader ? this._fullRequestReader._loaded : 0;
205
+ }
206
+ }]);
207
+
208
+ return PDFDataTransportStream;
209
+ }();
210
+
211
+ exports.PDFDataTransportStream = PDFDataTransportStream;
212
+
213
+ var PDFDataTransportStreamReader =
214
+ /*#__PURE__*/
215
+ function () {
119
216
  function PDFDataTransportStreamReader(stream, queuedChunks) {
217
+ var progressiveDone = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
218
+
219
+ _classCallCheck(this, PDFDataTransportStreamReader);
220
+
120
221
  this._stream = stream;
121
- this._done = false;
222
+ this._done = progressiveDone || false;
122
223
  this._filename = null;
123
224
  this._queuedChunks = queuedChunks || [];
225
+ this._loaded = 0;
226
+ var _iteratorNormalCompletion = true;
227
+ var _didIteratorError = false;
228
+ var _iteratorError = undefined;
229
+
230
+ try {
231
+ for (var _iterator = this._queuedChunks[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
232
+ var chunk = _step.value;
233
+ this._loaded += chunk.byteLength;
234
+ }
235
+ } catch (err) {
236
+ _didIteratorError = true;
237
+ _iteratorError = err;
238
+ } finally {
239
+ try {
240
+ if (!_iteratorNormalCompletion && _iterator["return"] != null) {
241
+ _iterator["return"]();
242
+ }
243
+ } finally {
244
+ if (_didIteratorError) {
245
+ throw _iteratorError;
246
+ }
247
+ }
248
+ }
249
+
124
250
  this._requests = [];
125
251
  this._headersReady = Promise.resolve();
126
252
  stream._fullRequestReader = this;
127
253
  this.onProgress = null;
128
254
  }
129
- PDFDataTransportStreamReader.prototype = {
130
- _enqueue: function PDFDataTransportStreamReader_enqueue(chunk) {
255
+
256
+ _createClass(PDFDataTransportStreamReader, [{
257
+ key: "_enqueue",
258
+ value: function _enqueue(chunk) {
131
259
  if (this._done) {
132
260
  return;
133
261
  }
262
+
134
263
  if (this._requests.length > 0) {
135
264
  var requestCapability = this._requests.shift();
265
+
136
266
  requestCapability.resolve({
137
267
  value: chunk,
138
268
  done: false
139
269
  });
140
- return;
141
- }
142
- this._queuedChunks.push(chunk);
143
- },
144
- get headersReady() {
145
- return this._headersReady;
146
- },
147
- get filename() {
148
- return this._filename;
149
- },
150
- get isRangeSupported() {
151
- return this._stream._isRangeSupported;
152
- },
153
- get isStreamingSupported() {
154
- return this._stream._isStreamingSupported;
155
- },
156
- get contentLength() {
157
- return this._stream._contentLength;
158
- },
159
- read: function PDFDataTransportStreamReader_read() {
160
- if (this._queuedChunks.length > 0) {
161
- var chunk = this._queuedChunks.shift();
162
- return Promise.resolve({
163
- value: chunk,
164
- done: false
165
- });
270
+ } else {
271
+ this._queuedChunks.push(chunk);
166
272
  }
167
- if (this._done) {
168
- return Promise.resolve({
169
- value: undefined,
170
- done: true
171
- });
273
+
274
+ this._loaded += chunk.byteLength;
275
+ }
276
+ }, {
277
+ key: "read",
278
+ value: function () {
279
+ var _read = _asyncToGenerator(
280
+ /*#__PURE__*/
281
+ _regenerator["default"].mark(function _callee() {
282
+ var chunk, requestCapability;
283
+ return _regenerator["default"].wrap(function _callee$(_context) {
284
+ while (1) {
285
+ switch (_context.prev = _context.next) {
286
+ case 0:
287
+ if (!(this._queuedChunks.length > 0)) {
288
+ _context.next = 3;
289
+ break;
290
+ }
291
+
292
+ chunk = this._queuedChunks.shift();
293
+ return _context.abrupt("return", {
294
+ value: chunk,
295
+ done: false
296
+ });
297
+
298
+ case 3:
299
+ if (!this._done) {
300
+ _context.next = 5;
301
+ break;
302
+ }
303
+
304
+ return _context.abrupt("return", {
305
+ value: undefined,
306
+ done: true
307
+ });
308
+
309
+ case 5:
310
+ requestCapability = (0, _util.createPromiseCapability)();
311
+
312
+ this._requests.push(requestCapability);
313
+
314
+ return _context.abrupt("return", requestCapability.promise);
315
+
316
+ case 8:
317
+ case "end":
318
+ return _context.stop();
319
+ }
320
+ }
321
+ }, _callee, this);
322
+ }));
323
+
324
+ function read() {
325
+ return _read.apply(this, arguments);
172
326
  }
173
- var requestCapability = (0, _util.createPromiseCapability)();
174
- this._requests.push(requestCapability);
175
- return requestCapability.promise;
176
- },
177
- cancel: function PDFDataTransportStreamReader_cancel(reason) {
327
+
328
+ return read;
329
+ }()
330
+ }, {
331
+ key: "cancel",
332
+ value: function cancel(reason) {
178
333
  this._done = true;
334
+
179
335
  this._requests.forEach(function (requestCapability) {
180
336
  requestCapability.resolve({
181
337
  value: undefined,
182
338
  done: true
183
339
  });
184
340
  });
341
+
185
342
  this._requests = [];
186
343
  }
187
- };
344
+ }, {
345
+ key: "progressiveDone",
346
+ value: function progressiveDone() {
347
+ if (this._done) {
348
+ return;
349
+ }
350
+
351
+ this._done = true;
352
+ }
353
+ }, {
354
+ key: "headersReady",
355
+ get: function get() {
356
+ return this._headersReady;
357
+ }
358
+ }, {
359
+ key: "filename",
360
+ get: function get() {
361
+ return this._filename;
362
+ }
363
+ }, {
364
+ key: "isRangeSupported",
365
+ get: function get() {
366
+ return this._stream._isRangeSupported;
367
+ }
368
+ }, {
369
+ key: "isStreamingSupported",
370
+ get: function get() {
371
+ return this._stream._isStreamingSupported;
372
+ }
373
+ }, {
374
+ key: "contentLength",
375
+ get: function get() {
376
+ return this._stream._contentLength;
377
+ }
378
+ }]);
379
+
380
+ return PDFDataTransportStreamReader;
381
+ }();
382
+
383
+ var PDFDataTransportStreamRangeReader =
384
+ /*#__PURE__*/
385
+ function () {
188
386
  function PDFDataTransportStreamRangeReader(stream, begin, end) {
387
+ _classCallCheck(this, PDFDataTransportStreamRangeReader);
388
+
189
389
  this._stream = stream;
190
390
  this._begin = begin;
191
391
  this._end = end;
@@ -194,64 +394,115 @@ var PDFDataTransportStream = function PDFDataTransportStreamClosure() {
194
394
  this._done = false;
195
395
  this.onProgress = null;
196
396
  }
197
- PDFDataTransportStreamRangeReader.prototype = {
198
- _enqueue: function PDFDataTransportStreamRangeReader_enqueue(chunk) {
397
+
398
+ _createClass(PDFDataTransportStreamRangeReader, [{
399
+ key: "_enqueue",
400
+ value: function _enqueue(chunk) {
199
401
  if (this._done) {
200
402
  return;
201
403
  }
404
+
202
405
  if (this._requests.length === 0) {
203
406
  this._queuedChunk = chunk;
204
407
  } else {
205
408
  var requestsCapability = this._requests.shift();
409
+
206
410
  requestsCapability.resolve({
207
411
  value: chunk,
208
412
  done: false
209
413
  });
414
+
210
415
  this._requests.forEach(function (requestCapability) {
211
416
  requestCapability.resolve({
212
417
  value: undefined,
213
418
  done: true
214
419
  });
215
420
  });
421
+
216
422
  this._requests = [];
217
423
  }
424
+
218
425
  this._done = true;
426
+
219
427
  this._stream._removeRangeReader(this);
220
- },
221
- get isStreamingSupported() {
222
- return false;
223
- },
224
- read: function PDFDataTransportStreamRangeReader_read() {
225
- if (this._queuedChunk) {
226
- var chunk = this._queuedChunk;
227
- this._queuedChunk = null;
228
- return Promise.resolve({
229
- value: chunk,
230
- done: false
231
- });
232
- }
233
- if (this._done) {
234
- return Promise.resolve({
235
- value: undefined,
236
- done: true
237
- });
428
+ }
429
+ }, {
430
+ key: "read",
431
+ value: function () {
432
+ var _read2 = _asyncToGenerator(
433
+ /*#__PURE__*/
434
+ _regenerator["default"].mark(function _callee2() {
435
+ var chunk, requestCapability;
436
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
437
+ while (1) {
438
+ switch (_context2.prev = _context2.next) {
439
+ case 0:
440
+ if (!this._queuedChunk) {
441
+ _context2.next = 4;
442
+ break;
443
+ }
444
+
445
+ chunk = this._queuedChunk;
446
+ this._queuedChunk = null;
447
+ return _context2.abrupt("return", {
448
+ value: chunk,
449
+ done: false
450
+ });
451
+
452
+ case 4:
453
+ if (!this._done) {
454
+ _context2.next = 6;
455
+ break;
456
+ }
457
+
458
+ return _context2.abrupt("return", {
459
+ value: undefined,
460
+ done: true
461
+ });
462
+
463
+ case 6:
464
+ requestCapability = (0, _util.createPromiseCapability)();
465
+
466
+ this._requests.push(requestCapability);
467
+
468
+ return _context2.abrupt("return", requestCapability.promise);
469
+
470
+ case 9:
471
+ case "end":
472
+ return _context2.stop();
473
+ }
474
+ }
475
+ }, _callee2, this);
476
+ }));
477
+
478
+ function read() {
479
+ return _read2.apply(this, arguments);
238
480
  }
239
- var requestCapability = (0, _util.createPromiseCapability)();
240
- this._requests.push(requestCapability);
241
- return requestCapability.promise;
242
- },
243
- cancel: function PDFDataTransportStreamRangeReader_cancel(reason) {
481
+
482
+ return read;
483
+ }()
484
+ }, {
485
+ key: "cancel",
486
+ value: function cancel(reason) {
244
487
  this._done = true;
488
+
245
489
  this._requests.forEach(function (requestCapability) {
246
490
  requestCapability.resolve({
247
491
  value: undefined,
248
492
  done: true
249
493
  });
250
494
  });
495
+
251
496
  this._requests = [];
497
+
252
498
  this._stream._removeRangeReader(this);
253
499
  }
254
- };
255
- return PDFDataTransportStream;
256
- }();
257
- exports.PDFDataTransportStream = PDFDataTransportStream;
500
+ }, {
501
+ key: "isStreamingSupported",
502
+ get: function get() {
503
+ return false;
504
+ }
505
+ }]);
506
+
507
+ return PDFDataTransportStreamRangeReader;
508
+ }();