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.
- package/CODE_OF_CONDUCT.md +15 -0
- package/bower.json +1 -1
- package/build/pdf.js +3349 -2324
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +1 -1
- package/build/pdf.worker.js +2804 -1975
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +1 -1
- package/image_decoders/pdf.image_decoders.js +431 -511
- package/image_decoders/pdf.image_decoders.js.map +1 -1
- package/image_decoders/pdf.image_decoders.min.js +1 -1
- package/lib/core/annotation.js +294 -224
- package/lib/core/arithmetic_decoder.js +1 -1
- package/lib/core/bidi.js +1 -1
- package/lib/core/ccitt.js +1 -1
- package/lib/core/ccitt_stream.js +1 -1
- package/lib/core/cff_parser.js +61 -12
- package/lib/core/charsets.js +1 -1
- package/lib/core/chunked_stream.js +24 -14
- package/lib/core/cmap.js +17 -13
- package/lib/core/colorspace.js +1 -1
- package/lib/core/core_utils.js +147 -0
- package/lib/core/crypto.js +1 -1
- package/lib/core/document.js +47 -40
- package/lib/core/encodings.js +1 -1
- package/lib/core/evaluator.js +346 -279
- package/lib/core/font_renderer.js +1 -1
- package/lib/core/fonts.js +23 -11
- package/lib/core/function.js +1 -1
- package/lib/core/glyphlist.js +2 -2
- package/lib/core/image.js +2 -2
- package/lib/core/image_utils.js +111 -0
- package/lib/core/jbig2.js +1 -1
- package/lib/core/jbig2_stream.js +1 -1
- package/lib/core/jpeg_stream.js +1 -1
- package/lib/core/jpg.js +2 -1
- package/lib/core/jpx.js +1 -1
- package/lib/core/jpx_stream.js +1 -1
- package/lib/core/metrics.js +13 -13
- package/lib/core/murmurhash3.js +37 -33
- package/lib/core/obj.js +245 -41
- package/lib/core/operator_list.js +43 -32
- package/lib/core/parser.js +228 -133
- package/lib/core/pattern.js +4 -2
- package/lib/core/pdf_manager.js +17 -15
- package/lib/core/primitives.js +40 -6
- package/lib/core/ps_parser.js +1 -1
- package/lib/core/standard_fonts.js +9 -9
- package/lib/core/stream.js +1 -1
- package/lib/core/type1_parser.js +1 -1
- package/lib/core/unicode.js +2 -2
- package/lib/core/worker.js +54 -171
- package/lib/core/worker_stream.js +277 -0
- package/lib/display/annotation_layer.js +112 -33
- package/lib/display/api.js +211 -123
- package/lib/display/api_compatibility.js +1 -1
- package/lib/display/canvas.js +40 -19
- package/lib/display/content_disposition.js +1 -1
- package/lib/display/display_utils.js +747 -0
- package/lib/display/fetch_stream.js +19 -12
- package/lib/display/font_loader.js +11 -8
- package/lib/display/metadata.js +1 -1
- package/lib/display/network.js +563 -521
- package/lib/display/network_utils.js +1 -1
- package/lib/display/node_stream.js +21 -12
- package/lib/display/pattern_helper.js +24 -25
- package/lib/display/svg.js +1068 -565
- package/lib/display/text_layer.js +24 -14
- package/lib/display/transport_stream.js +192 -70
- package/lib/display/webgl.js +1 -1
- package/lib/display/worker_options.js +1 -1
- package/lib/display/xml_parser.js +1 -1
- package/lib/examples/node/domstubs.js +4 -1
- package/lib/pdf.js +20 -15
- package/lib/pdf.worker.js +3 -3
- package/lib/shared/compatibility.js +6 -6
- package/lib/shared/global_scope.js +1 -1
- package/lib/shared/is_node.js +2 -2
- package/lib/shared/message_handler.js +7 -7
- package/lib/shared/streams_polyfill.js +1 -1
- package/lib/shared/url_polyfill.js +1 -1
- package/lib/shared/util.js +13 -125
- package/lib/test/unit/annotation_spec.js +278 -93
- package/lib/test/unit/api_spec.js +198 -188
- package/lib/test/unit/bidi_spec.js +1 -1
- package/lib/test/unit/cff_parser_spec.js +15 -1
- package/lib/test/unit/clitests_helper.js +3 -3
- package/lib/test/unit/cmap_spec.js +20 -20
- package/lib/test/unit/colorspace_spec.js +17 -12
- package/lib/test/unit/core_utils_spec.js +191 -0
- package/lib/test/unit/crypto_spec.js +1 -1
- package/lib/test/unit/custom_spec.js +8 -8
- package/lib/test/unit/display_svg_spec.js +8 -8
- package/lib/test/unit/display_utils_spec.js +273 -0
- package/lib/test/unit/document_spec.js +7 -12
- package/lib/test/unit/encodings_spec.js +5 -5
- package/lib/test/unit/evaluator_spec.js +8 -10
- package/lib/test/unit/fetch_stream_spec.js +109 -0
- package/lib/test/unit/function_spec.js +1 -1
- package/lib/test/unit/jasmine-boot.js +4 -4
- package/lib/test/unit/message_handler_spec.js +1 -1
- package/lib/test/unit/metadata_spec.js +1 -1
- package/lib/test/unit/murmurhash3_spec.js +1 -1
- package/lib/test/unit/network_spec.js +5 -55
- package/lib/test/unit/network_utils_spec.js +51 -1
- package/lib/test/unit/node_stream_spec.js +8 -8
- package/lib/test/unit/parser_spec.js +150 -86
- package/lib/test/unit/pdf_find_controller_spec.js +1 -1
- package/lib/test/unit/pdf_find_utils_spec.js +1 -1
- package/lib/test/unit/pdf_history_spec.js +1 -1
- package/lib/test/unit/primitives_spec.js +30 -17
- package/lib/test/unit/stream_spec.js +1 -1
- package/lib/test/unit/test_utils.js +197 -43
- package/lib/test/unit/testreporter.js +1 -1
- package/lib/test/unit/type1_parser_spec.js +1 -1
- package/lib/test/unit/ui_utils_spec.js +20 -20
- package/lib/test/unit/unicode_spec.js +5 -5
- package/lib/test/unit/util_spec.js +1 -164
- package/lib/web/annotation_layer_builder.js +1 -1
- package/lib/web/app.js +104 -60
- package/lib/web/app_options.js +45 -37
- package/lib/web/base_viewer.js +7 -7
- package/lib/web/chromecom.js +8 -8
- package/lib/web/debugger.js +7 -7
- package/lib/web/download_manager.js +3 -2
- package/lib/web/firefox_print_service.js +4 -2
- package/lib/web/firefoxcom.js +50 -19
- package/lib/web/genericcom.js +8 -8
- package/lib/web/genericl10n.js +10 -10
- package/lib/web/grab_to_pan.js +3 -1
- package/lib/web/interfaces.js +13 -13
- package/lib/web/overlay_manager.js +10 -10
- package/lib/web/password_prompt.js +2 -2
- package/lib/web/pdf_attachment_viewer.js +1 -1
- package/lib/web/pdf_cursor_tools.js +1 -1
- package/lib/web/pdf_document_properties.js +188 -119
- package/lib/web/pdf_find_bar.js +1 -1
- package/lib/web/pdf_find_controller.js +3 -3
- package/lib/web/pdf_find_utils.js +1 -1
- package/lib/web/pdf_history.js +1 -1
- package/lib/web/pdf_link_service.js +2 -2
- package/lib/web/pdf_outline_viewer.js +53 -28
- package/lib/web/pdf_page_view.js +9 -18
- package/lib/web/pdf_presentation_mode.js +1 -1
- package/lib/web/pdf_print_service.js +5 -3
- package/lib/web/pdf_rendering_queue.js +4 -7
- package/lib/web/pdf_sidebar.js +24 -17
- package/lib/web/pdf_sidebar_resizer.js +1 -1
- package/lib/web/pdf_single_page_viewer.js +1 -1
- package/lib/web/pdf_thumbnail_view.js +2 -2
- package/lib/web/pdf_thumbnail_viewer.js +3 -3
- package/lib/web/pdf_viewer.component.js +3 -3
- package/lib/web/pdf_viewer.js +3 -3
- package/lib/web/preferences.js +30 -30
- package/lib/web/secondary_toolbar.js +1 -1
- package/lib/web/text_layer_builder.js +23 -45
- package/lib/web/toolbar.js +1 -1
- package/lib/web/ui_utils.js +14 -14
- package/lib/web/view_history.js +15 -15
- package/lib/web/viewer_compatibility.js +1 -1
- package/package.json +1 -1
- package/web/pdf_viewer.css +21 -10
- package/web/pdf_viewer.js +126 -194
- package/web/pdf_viewer.js.map +1 -1
- package/lib/display/dom_utils.js +0 -494
- package/lib/test/unit/dom_utils_spec.js +0 -89
package/lib/display/network.js
CHANGED
@@ -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
|
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 =
|
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
|
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
|
-
|
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
|
-
|
60
|
-
|
61
|
-
|
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
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
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
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
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
|
-
|
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
|
-
|
112
|
-
|
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
|
-
|
115
|
-
|
90
|
+
for (var prop in listeners) {
|
91
|
+
args[prop] = listeners[prop];
|
116
92
|
}
|
117
93
|
|
118
|
-
|
94
|
+
return this.request(args);
|
119
95
|
}
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
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
|
-
|
112
|
+
for (var property in this.httpHeaders) {
|
113
|
+
var value = this.httpHeaders[property];
|
130
114
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
pendingRequest.mozChunked = true;
|
135
|
-
} else {
|
136
|
-
xhr.responseType = 'arraybuffer';
|
137
|
-
}
|
115
|
+
if (typeof value === 'undefined') {
|
116
|
+
continue;
|
117
|
+
}
|
138
118
|
|
139
|
-
|
140
|
-
|
141
|
-
args.onError(xhr.status);
|
142
|
-
};
|
143
|
-
}
|
119
|
+
xhr.setRequestHeader(property, value);
|
120
|
+
}
|
144
121
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
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
|
-
|
162
|
-
var chunk = getArrayBuffer(pendingRequest.xhr);
|
163
|
-
pendingRequest.onProgressiveData(chunk);
|
164
|
-
}
|
129
|
+
xhr.responseType = 'arraybuffer';
|
165
130
|
|
166
|
-
|
131
|
+
if (args.onError) {
|
132
|
+
xhr.onerror = function (evt) {
|
133
|
+
args.onError(xhr.status);
|
134
|
+
};
|
135
|
+
}
|
167
136
|
|
168
|
-
|
169
|
-
onProgress(
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
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
|
-
|
176
|
-
|
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
|
-
|
164
|
+
if (!pendingRequest) {
|
165
|
+
return;
|
166
|
+
}
|
180
167
|
|
181
|
-
|
182
|
-
pendingRequest.onHeadersReceived();
|
183
|
-
delete pendingRequest.onHeadersReceived;
|
184
|
-
}
|
168
|
+
var xhr = pendingRequest.xhr;
|
185
169
|
|
186
|
-
|
187
|
-
|
188
|
-
|
170
|
+
if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
|
171
|
+
pendingRequest.onHeadersReceived();
|
172
|
+
delete pendingRequest.onHeadersReceived;
|
173
|
+
}
|
189
174
|
|
190
|
-
|
191
|
-
|
192
|
-
|
175
|
+
if (xhr.readyState !== 4) {
|
176
|
+
return;
|
177
|
+
}
|
178
|
+
|
179
|
+
if (!(xhrId in this.pendingRequests)) {
|
180
|
+
return;
|
181
|
+
}
|
193
182
|
|
194
|
-
|
183
|
+
delete this.pendingRequests[xhrId];
|
195
184
|
|
196
|
-
|
197
|
-
|
198
|
-
|
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
|
-
|
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
|
-
|
205
|
-
|
196
|
+
if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
|
197
|
+
if (pendingRequest.onError) {
|
198
|
+
pendingRequest.onError(xhr.status);
|
199
|
+
}
|
206
200
|
|
207
|
-
|
208
|
-
if (pendingRequest.onError) {
|
209
|
-
pendingRequest.onError(xhr.status);
|
201
|
+
return;
|
210
202
|
}
|
211
203
|
|
212
|
-
|
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
|
-
|
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
|
-
|
238
|
-
|
239
|
-
return
|
231
|
+
}, {
|
232
|
+
key: "getRequestXhr",
|
233
|
+
value: function getRequestXhr(xhrId) {
|
234
|
+
return this.pendingRequests[xhrId].xhr;
|
240
235
|
}
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
},
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
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
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
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
|
280
|
-
|
281
|
-
|
276
|
+
_createClass(PDFNetworkStream, [{
|
277
|
+
key: "_onRangeRequestReaderClosed",
|
278
|
+
value: function _onRangeRequestReaderClosed(reader) {
|
279
|
+
var i = this._rangeRequestReaders.indexOf(reader);
|
282
280
|
|
283
|
-
|
284
|
-
|
281
|
+
if (i >= 0) {
|
282
|
+
this._rangeRequestReaders.splice(i, 1);
|
283
|
+
}
|
285
284
|
}
|
286
|
-
},
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
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
|
-
|
298
|
+
this._rangeRequestReaders.push(reader);
|
306
299
|
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
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
|
-
|
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
|
-
|
344
|
-
|
345
|
-
|
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
|
-
|
322
|
+
var PDFNetworkStreamFullRequestReader =
|
323
|
+
/*#__PURE__*/
|
324
|
+
function () {
|
325
|
+
function PDFNetworkStreamFullRequestReader(manager, source) {
|
326
|
+
_classCallCheck(this, PDFNetworkStreamFullRequestReader);
|
348
327
|
|
349
|
-
|
350
|
-
|
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
|
-
|
354
|
-
|
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.
|
367
|
-
this.
|
368
|
-
|
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
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
}
|
356
|
+
_createClass(PDFNetworkStreamFullRequestReader, [{
|
357
|
+
key: "_onHeadersReceived",
|
358
|
+
value: function _onHeadersReceived() {
|
359
|
+
var fullRequestXhrId = this._fullRequestId;
|
375
360
|
|
376
|
-
|
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
|
-
|
383
|
-
|
384
|
-
|
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
|
-
|
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
|
-
|
398
|
-
|
399
|
-
}
|
380
|
+
this._contentLength = suggestedLength || this._contentLength;
|
381
|
+
this._filename = (0, _network_utils.extractFilenameFromHeader)(getResponseHeader);
|
400
382
|
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
done: true
|
405
|
-
});
|
406
|
-
});
|
383
|
+
if (this._isRangeSupported) {
|
384
|
+
this._manager.abortRequest(fullRequestXhrId);
|
385
|
+
}
|
407
386
|
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
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
|
-
|
405
|
+
this._done = true;
|
416
406
|
|
417
|
-
|
418
|
-
|
419
|
-
|
407
|
+
if (this._cachedChunks.length > 0) {
|
408
|
+
return;
|
409
|
+
}
|
420
410
|
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
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
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
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
|
-
}
|
505
|
-
}));
|
499
|
+
}, _callee, this);
|
500
|
+
}));
|
506
501
|
|
507
|
-
|
508
|
-
|
509
|
-
|
502
|
+
function read() {
|
503
|
+
return _read.apply(this, arguments);
|
504
|
+
}
|
510
505
|
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
506
|
+
return read;
|
507
|
+
}()
|
508
|
+
}, {
|
509
|
+
key: "cancel",
|
510
|
+
value: function cancel(reason) {
|
511
|
+
this._done = true;
|
515
512
|
|
516
|
-
|
513
|
+
this._headersReceivedCapability.reject(reason);
|
517
514
|
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
515
|
+
this._requests.forEach(function (requestCapability) {
|
516
|
+
requestCapability.resolve({
|
517
|
+
value: undefined,
|
518
|
+
done: true
|
519
|
+
});
|
522
520
|
});
|
523
|
-
});
|
524
521
|
|
525
|
-
|
522
|
+
this._requests = [];
|
526
523
|
|
527
|
-
|
528
|
-
|
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
|
-
|
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
|
550
|
-
|
551
|
-
|
552
|
-
this.onClosed
|
579
|
+
_createClass(PDFNetworkStreamRangeRequestReader, [{
|
580
|
+
key: "_close",
|
581
|
+
value: function _close() {
|
582
|
+
if (this.onClosed) {
|
583
|
+
this.onClosed(this);
|
584
|
+
}
|
553
585
|
}
|
554
|
-
},
|
555
|
-
|
556
|
-
|
586
|
+
}, {
|
587
|
+
key: "_onDone",
|
588
|
+
value: function _onDone(data) {
|
589
|
+
var chunk = data.chunk;
|
557
590
|
|
558
|
-
|
559
|
-
|
591
|
+
if (this._requests.length > 0) {
|
592
|
+
var requestCapability = this._requests.shift();
|
560
593
|
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
594
|
+
requestCapability.resolve({
|
595
|
+
value: chunk,
|
596
|
+
done: false
|
597
|
+
});
|
598
|
+
} else {
|
599
|
+
this._queuedChunk = chunk;
|
600
|
+
}
|
568
601
|
|
569
|
-
|
602
|
+
this._done = true;
|
570
603
|
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
604
|
+
this._requests.forEach(function (requestCapability) {
|
605
|
+
requestCapability.resolve({
|
606
|
+
value: undefined,
|
607
|
+
done: true
|
608
|
+
});
|
575
609
|
});
|
576
|
-
});
|
577
610
|
|
578
|
-
|
611
|
+
this._requests = [];
|
579
612
|
|
580
|
-
|
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
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
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
|
-
|
646
|
-
|
647
|
-
|
648
|
-
this._done = true;
|
673
|
+
function read() {
|
674
|
+
return _read2.apply(this, arguments);
|
675
|
+
}
|
649
676
|
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
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
|
-
|
691
|
+
this._requests = [];
|
658
692
|
|
659
|
-
|
660
|
-
|
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
|
-
|
664
|
-
|
665
|
-
};
|
706
|
+
return PDFNetworkStreamRangeRequestReader;
|
707
|
+
}();
|