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