pdfjs-dist 2.1.266 → 2.2.228

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


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

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