pdfjs-dist 2.2.228 → 2.6.347
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/README.md +4 -0
- package/bower.json +1 -1
- package/build/pdf.js +8816 -19300
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +22 -1
- package/build/pdf.worker.entry.js +5 -3
- package/build/pdf.worker.js +27185 -35746
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +22 -1
- package/es5/build/pdf.js +26665 -0
- package/es5/build/pdf.js.map +1 -0
- package/es5/build/pdf.min.js +22 -0
- package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
- package/es5/build/pdf.worker.js +61231 -0
- package/es5/build/pdf.worker.js.map +1 -0
- package/es5/build/pdf.worker.min.js +22 -0
- package/es5/image_decoders/pdf.image_decoders.js +12529 -0
- package/es5/image_decoders/pdf.image_decoders.js.map +1 -0
- package/es5/image_decoders/pdf.image_decoders.min.js +22 -0
- package/es5/web/images/annotation-check.svg +11 -0
- package/es5/web/images/annotation-comment.svg +16 -0
- package/es5/web/images/annotation-help.svg +26 -0
- package/es5/web/images/annotation-insert.svg +10 -0
- package/es5/web/images/annotation-key.svg +11 -0
- package/es5/web/images/annotation-newparagraph.svg +11 -0
- package/es5/web/images/annotation-noicon.svg +7 -0
- package/es5/web/images/annotation-note.svg +42 -0
- package/es5/web/images/annotation-paragraph.svg +16 -0
- package/es5/web/images/loading-icon.gif +0 -0
- package/es5/web/images/shadow.png +0 -0
- package/es5/web/pdf_viewer.css +406 -0
- package/es5/web/pdf_viewer.js +7886 -0
- package/es5/web/pdf_viewer.js.map +1 -0
- package/image_decoders/pdf.image_decoders.js +1498 -4832
- package/image_decoders/pdf.image_decoders.js.map +1 -1
- package/image_decoders/pdf.image_decoders.min.js +22 -1
- package/lib/README.md +7 -0
- package/lib/core/annotation.js +1144 -927
- package/lib/core/arithmetic_decoder.js +81 -97
- package/lib/core/bidi.js +54 -46
- package/lib/core/ccitt.js +88 -81
- package/lib/core/ccitt_stream.js +15 -14
- package/lib/core/cff_parser.js +747 -716
- package/lib/core/charsets.js +4 -4
- package/lib/core/chunked_stream.js +462 -553
- package/lib/core/cmap.js +231 -277
- package/lib/core/colorspace.js +715 -857
- package/lib/core/core_utils.js +57 -52
- package/lib/core/crypto.js +416 -437
- package/lib/core/document.js +629 -670
- package/lib/core/encodings.js +15 -15
- package/lib/core/evaluator.js +3229 -2800
- package/lib/core/font_renderer.js +135 -178
- package/lib/core/fonts.js +602 -534
- package/lib/core/function.js +355 -279
- package/lib/core/glyphlist.js +4527 -4526
- package/lib/core/image.js +442 -439
- package/lib/core/image_utils.js +221 -61
- package/lib/core/jbig2.js +325 -316
- package/lib/core/jbig2_stream.js +18 -17
- package/lib/core/jpeg_stream.js +21 -26
- package/lib/core/jpg.js +289 -233
- package/lib/core/jpx.js +161 -143
- package/lib/core/jpx_stream.js +28 -28
- package/lib/core/metrics.js +2928 -2928
- package/lib/core/murmurhash3.js +87 -102
- package/lib/core/obj.js +1343 -1300
- package/lib/core/operator_list.js +90 -67
- package/lib/core/parser.js +990 -987
- package/lib/core/pattern.js +105 -77
- package/lib/core/pdf_manager.js +149 -316
- package/lib/core/primitives.js +156 -104
- package/lib/core/ps_parser.js +175 -214
- package/lib/core/standard_fonts.js +237 -236
- package/lib/core/stream.js +94 -74
- package/lib/core/type1_parser.js +89 -69
- package/lib/core/unicode.js +1654 -1654
- package/lib/core/worker.js +275 -290
- package/lib/core/worker_stream.js +101 -210
- package/lib/core/writer.js +242 -0
- package/lib/display/annotation_layer.js +772 -1041
- package/lib/display/annotation_storage.js +89 -0
- package/lib/display/api.js +1575 -1868
- package/lib/display/api_compatibility.js +12 -17
- package/lib/display/canvas.js +370 -222
- package/lib/display/content_disposition.js +40 -59
- package/lib/display/display_utils.js +341 -536
- package/lib/display/fetch_stream.js +188 -304
- package/lib/display/font_loader.js +282 -414
- package/lib/display/metadata.js +81 -99
- package/lib/display/network.js +362 -511
- package/lib/display/network_utils.js +25 -18
- package/lib/display/node_stream.js +283 -465
- package/lib/display/node_utils.js +87 -0
- package/lib/display/optional_content_config.js +184 -0
- package/lib/display/pattern_helper.js +93 -44
- package/lib/display/svg.js +1163 -1401
- package/lib/display/text_layer.js +154 -137
- package/lib/display/transport_stream.js +237 -375
- package/lib/display/webgl.js +70 -83
- package/lib/display/worker_options.js +3 -3
- package/lib/display/xml_parser.js +303 -392
- package/lib/examples/node/domstubs.js +37 -37
- package/lib/pdf.js +220 -58
- package/lib/pdf.worker.js +14 -6
- package/lib/shared/compatibility.js +3 -246
- package/lib/shared/is_node.js +7 -6
- package/lib/shared/message_handler.js +327 -332
- package/lib/shared/util.js +271 -306
- package/lib/test/unit/annotation_spec.js +1902 -763
- package/lib/test/unit/annotation_storage_spec.js +83 -0
- package/lib/test/unit/api_spec.js +790 -592
- package/lib/test/unit/bidi_spec.js +7 -7
- package/lib/test/unit/cff_parser_spec.js +73 -72
- package/lib/test/unit/clitests_helper.js +7 -9
- package/lib/test/unit/cmap_spec.js +86 -88
- package/lib/test/unit/colorspace_spec.js +346 -154
- package/lib/test/unit/core_utils_spec.js +125 -105
- package/lib/test/unit/crypto_spec.js +232 -185
- package/lib/test/unit/custom_spec.js +150 -24
- package/lib/test/unit/display_svg_spec.js +34 -39
- package/lib/test/unit/display_utils_spec.js +139 -149
- package/lib/test/unit/document_spec.js +128 -17
- package/lib/test/unit/encodings_spec.js +12 -34
- package/lib/test/unit/evaluator_spec.js +112 -91
- package/lib/test/unit/fetch_stream_spec.js +31 -29
- package/lib/test/unit/function_spec.js +206 -204
- package/lib/test/unit/jasmine-boot.js +48 -32
- package/lib/test/unit/message_handler_spec.js +173 -159
- package/lib/test/unit/metadata_spec.js +71 -71
- package/lib/test/unit/murmurhash3_spec.js +12 -12
- package/lib/test/unit/network_spec.js +13 -11
- package/lib/test/unit/network_utils_spec.js +158 -144
- package/lib/test/unit/node_stream_spec.js +76 -90
- package/lib/test/unit/parser_spec.js +108 -114
- package/lib/test/unit/pdf_find_controller_spec.js +55 -86
- package/lib/test/unit/pdf_find_utils_spec.js +32 -32
- package/lib/test/unit/pdf_history_spec.js +32 -32
- package/lib/test/unit/primitives_spec.js +337 -156
- package/lib/test/unit/stream_spec.js +16 -14
- package/lib/test/unit/test_utils.js +91 -304
- package/lib/test/unit/testreporter.js +33 -22
- package/lib/test/unit/type1_parser_spec.js +42 -42
- package/lib/test/unit/ui_utils_spec.js +299 -461
- package/lib/test/unit/unicode_spec.js +42 -42
- package/lib/test/unit/util_spec.js +129 -149
- package/lib/test/unit/writer_spec.js +84 -0
- package/lib/web/annotation_layer_builder.js +78 -111
- package/lib/web/app.js +1542 -1267
- package/lib/web/app_options.js +76 -91
- package/lib/web/base_tree_viewer.js +100 -0
- package/lib/web/base_viewer.js +869 -834
- package/lib/web/chromecom.js +165 -252
- package/lib/web/debugger.js +149 -205
- package/lib/web/download_manager.js +34 -58
- package/lib/web/firefox_print_service.js +62 -34
- package/lib/web/firefoxcom.js +206 -374
- package/lib/web/genericcom.js +26 -108
- package/lib/web/genericl10n.js +24 -153
- package/lib/web/grab_to_pan.js +30 -30
- package/lib/web/interfaces.js +80 -254
- package/lib/web/overlay_manager.js +70 -246
- package/lib/web/password_prompt.js +38 -64
- package/lib/web/pdf_attachment_viewer.js +150 -126
- package/lib/web/pdf_cursor_tools.js +75 -102
- package/lib/web/pdf_document_properties.js +229 -383
- package/lib/web/pdf_find_bar.js +136 -170
- package/lib/web/pdf_find_controller.js +492 -548
- package/lib/web/pdf_find_utils.js +13 -13
- package/lib/web/pdf_history.js +397 -406
- package/lib/web/pdf_layer_viewer.js +208 -0
- package/lib/web/pdf_link_service.js +304 -348
- package/lib/web/pdf_outline_viewer.js +119 -212
- package/lib/web/pdf_page_view.js +474 -513
- package/lib/web/pdf_presentation_mode.js +308 -357
- package/lib/web/pdf_print_service.js +96 -110
- package/lib/web/pdf_rendering_queue.js +87 -108
- package/lib/web/pdf_sidebar.js +286 -302
- package/lib/web/pdf_sidebar_resizer.js +92 -119
- package/lib/web/pdf_single_page_viewer.js +77 -126
- package/lib/web/pdf_thumbnail_view.js +289 -297
- package/lib/web/pdf_thumbnail_viewer.js +202 -206
- package/lib/web/pdf_viewer.component.js +20 -21
- package/lib/web/pdf_viewer.js +55 -115
- package/lib/web/preferences.js +69 -273
- package/lib/web/secondary_toolbar.js +164 -196
- package/lib/web/text_layer_builder.js +284 -319
- package/lib/web/toolbar.js +217 -210
- package/lib/web/ui_utils.js +274 -421
- package/lib/web/view_history.js +52 -226
- package/lib/web/viewer_compatibility.js +21 -6
- package/package.json +4 -9
- package/types/display/annotation_layer.d.ts +61 -0
- package/types/display/annotation_storage.d.ts +36 -0
- package/types/display/api.d.ts +1107 -0
- package/types/display/api_compatibility.d.ts +1 -0
- package/types/display/canvas.d.ts +4 -0
- package/types/display/content_disposition.d.ts +7 -0
- package/types/display/display_utils.d.ts +243 -0
- package/types/display/fetch_stream.d.ts +67 -0
- package/types/display/font_loader.d.ts +19 -0
- package/types/display/metadata.d.ts +9 -0
- package/types/display/network.d.ts +80 -0
- package/types/display/network_utils.d.ts +14 -0
- package/types/display/node_stream.d.ts +72 -0
- package/types/display/node_utils.d.ts +6 -0
- package/types/display/optional_content_config.d.ts +12 -0
- package/types/display/pattern_helper.d.ts +5 -0
- package/types/display/svg.d.ts +2 -0
- package/types/display/text_layer.d.ts +83 -0
- package/types/display/transport_stream.d.ts +57 -0
- package/types/display/webgl.d.ts +20 -0
- package/types/display/worker_options.d.ts +27 -0
- package/types/display/xml_parser.d.ts +35 -0
- package/types/pdf.d.ts +33 -0
- package/types/shared/compatibility.d.ts +1 -0
- package/types/shared/is_node.d.ts +1 -0
- package/types/shared/message_handler.d.ts +62 -0
- package/types/shared/util.d.ts +421 -0
- package/web/images/shadow.png +0 -0
- package/web/pdf_viewer.css +29 -27
- package/web/pdf_viewer.js +3524 -4746
- package/web/pdf_viewer.js.map +1 -1
- package/webpack.js +6 -5
- package/external/streams/streams-lib.js +0 -3962
- package/external/url/url-lib.js +0 -627
- package/lib/shared/streams_polyfill.js +0 -43
- package/lib/shared/url_polyfill.js +0 -56
- package/web/images/texture.png +0 -0
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 2020 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.
|
@@ -26,45 +26,27 @@ Object.defineProperty(exports, "__esModule", {
|
|
26
26
|
});
|
27
27
|
exports.PDFNetworkStream = void 0;
|
28
28
|
|
29
|
-
var
|
29
|
+
var _util = require("../shared/util.js");
|
30
30
|
|
31
|
-
var
|
32
|
-
|
33
|
-
var _network_utils = require("./network_utils");
|
34
|
-
|
35
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
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; }
|
31
|
+
var _network_utils = require("./network_utils.js");
|
46
32
|
|
47
33
|
;
|
48
|
-
|
49
|
-
|
34
|
+
const OK_RESPONSE = 200;
|
35
|
+
const PARTIAL_CONTENT_RESPONSE = 206;
|
50
36
|
|
51
37
|
function getArrayBuffer(xhr) {
|
52
|
-
|
38
|
+
const data = xhr.response;
|
53
39
|
|
54
|
-
if (typeof data !==
|
40
|
+
if (typeof data !== "string") {
|
55
41
|
return data;
|
56
42
|
}
|
57
43
|
|
58
|
-
|
44
|
+
const array = (0, _util.stringToBytes)(data);
|
59
45
|
return array.buffer;
|
60
46
|
}
|
61
47
|
|
62
|
-
|
63
|
-
|
64
|
-
function () {
|
65
|
-
function NetworkManager(url, args) {
|
66
|
-
_classCallCheck(this, NetworkManager);
|
67
|
-
|
48
|
+
class NetworkManager {
|
49
|
+
constructor(url, args) {
|
68
50
|
this.url = url;
|
69
51
|
args = args || {};
|
70
52
|
this.isHttp = /^https?:/i.test(url);
|
@@ -79,190 +61,159 @@ function () {
|
|
79
61
|
this.pendingRequests = Object.create(null);
|
80
62
|
}
|
81
63
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
end: end
|
88
|
-
};
|
89
|
-
|
90
|
-
for (var prop in listeners) {
|
91
|
-
args[prop] = listeners[prop];
|
92
|
-
}
|
64
|
+
requestRange(begin, end, listeners) {
|
65
|
+
const args = {
|
66
|
+
begin,
|
67
|
+
end
|
68
|
+
};
|
93
69
|
|
94
|
-
|
70
|
+
for (const prop in listeners) {
|
71
|
+
args[prop] = listeners[prop];
|
95
72
|
}
|
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
|
108
|
-
};
|
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
73
|
|
115
|
-
|
116
|
-
|
117
|
-
}
|
74
|
+
return this.request(args);
|
75
|
+
}
|
118
76
|
|
119
|
-
|
120
|
-
|
77
|
+
requestFull(listeners) {
|
78
|
+
return this.request(listeners);
|
79
|
+
}
|
121
80
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
81
|
+
request(args) {
|
82
|
+
const xhr = this.getXhr();
|
83
|
+
const xhrId = this.currXhrId++;
|
84
|
+
const pendingRequest = this.pendingRequests[xhrId] = {
|
85
|
+
xhr
|
86
|
+
};
|
87
|
+
xhr.open("GET", this.url);
|
88
|
+
xhr.withCredentials = this.withCredentials;
|
128
89
|
|
129
|
-
|
90
|
+
for (const property in this.httpHeaders) {
|
91
|
+
const value = this.httpHeaders[property];
|
130
92
|
|
131
|
-
if (
|
132
|
-
|
133
|
-
args.onError(xhr.status);
|
134
|
-
};
|
93
|
+
if (typeof value === "undefined") {
|
94
|
+
continue;
|
135
95
|
}
|
136
96
|
|
137
|
-
xhr.
|
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;
|
97
|
+
xhr.setRequestHeader(property, value);
|
145
98
|
}
|
146
|
-
}, {
|
147
|
-
key: "onProgress",
|
148
|
-
value: function onProgress(xhrId, evt) {
|
149
|
-
var pendingRequest = this.pendingRequests[xhrId];
|
150
99
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
pendingRequest.onProgress(evt);
|
157
|
-
}
|
100
|
+
if (this.isHttp && "begin" in args && "end" in args) {
|
101
|
+
xhr.setRequestHeader("Range", `bytes=${args.begin}-${args.end - 1}`);
|
102
|
+
pendingRequest.expectedStatus = PARTIAL_CONTENT_RESPONSE;
|
103
|
+
} else {
|
104
|
+
pendingRequest.expectedStatus = OK_RESPONSE;
|
158
105
|
}
|
159
|
-
}, {
|
160
|
-
key: "onStateChange",
|
161
|
-
value: function onStateChange(xhrId, evt) {
|
162
|
-
var pendingRequest = this.pendingRequests[xhrId];
|
163
106
|
|
164
|
-
|
165
|
-
return;
|
166
|
-
}
|
107
|
+
xhr.responseType = "arraybuffer";
|
167
108
|
|
168
|
-
|
109
|
+
if (args.onError) {
|
110
|
+
xhr.onerror = function (evt) {
|
111
|
+
args.onError(xhr.status);
|
112
|
+
};
|
113
|
+
}
|
169
114
|
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
115
|
+
xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
|
116
|
+
xhr.onprogress = this.onProgress.bind(this, xhrId);
|
117
|
+
pendingRequest.onHeadersReceived = args.onHeadersReceived;
|
118
|
+
pendingRequest.onDone = args.onDone;
|
119
|
+
pendingRequest.onError = args.onError;
|
120
|
+
pendingRequest.onProgress = args.onProgress;
|
121
|
+
xhr.send(null);
|
122
|
+
return xhrId;
|
123
|
+
}
|
174
124
|
|
175
|
-
|
176
|
-
|
177
|
-
}
|
125
|
+
onProgress(xhrId, evt) {
|
126
|
+
const pendingRequest = this.pendingRequests[xhrId];
|
178
127
|
|
179
|
-
|
180
|
-
|
181
|
-
|
128
|
+
if (!pendingRequest) {
|
129
|
+
return;
|
130
|
+
}
|
182
131
|
|
183
|
-
|
132
|
+
if (pendingRequest.onProgress) {
|
133
|
+
pendingRequest.onProgress(evt);
|
134
|
+
}
|
135
|
+
}
|
184
136
|
|
185
|
-
|
186
|
-
|
187
|
-
pendingRequest.onError(xhr.status);
|
188
|
-
}
|
137
|
+
onStateChange(xhrId, evt) {
|
138
|
+
const pendingRequest = this.pendingRequests[xhrId];
|
189
139
|
|
190
|
-
|
191
|
-
|
140
|
+
if (!pendingRequest) {
|
141
|
+
return;
|
142
|
+
}
|
192
143
|
|
193
|
-
|
194
|
-
var ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
|
144
|
+
const xhr = pendingRequest.xhr;
|
195
145
|
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
146
|
+
if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
|
147
|
+
pendingRequest.onHeadersReceived();
|
148
|
+
delete pendingRequest.onHeadersReceived;
|
149
|
+
}
|
200
150
|
|
201
|
-
|
202
|
-
|
151
|
+
if (xhr.readyState !== 4) {
|
152
|
+
return;
|
153
|
+
}
|
203
154
|
|
204
|
-
|
155
|
+
if (!(xhrId in this.pendingRequests)) {
|
156
|
+
return;
|
157
|
+
}
|
205
158
|
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
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) {
|
159
|
+
delete this.pendingRequests[xhrId];
|
160
|
+
|
161
|
+
if (xhr.status === 0 && this.isHttp) {
|
162
|
+
if (pendingRequest.onError) {
|
219
163
|
pendingRequest.onError(xhr.status);
|
220
164
|
}
|
221
|
-
}
|
222
|
-
}, {
|
223
|
-
key: "hasPendingRequests",
|
224
|
-
value: function hasPendingRequests() {
|
225
|
-
for (var xhrId in this.pendingRequests) {
|
226
|
-
return true;
|
227
|
-
}
|
228
165
|
|
229
|
-
return
|
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;
|
166
|
+
return;
|
240
167
|
}
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
168
|
+
|
169
|
+
const xhrStatus = xhr.status || OK_RESPONSE;
|
170
|
+
const ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
|
171
|
+
|
172
|
+
if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
|
173
|
+
if (pendingRequest.onError) {
|
174
|
+
pendingRequest.onError(xhr.status);
|
246
175
|
}
|
176
|
+
|
177
|
+
return;
|
247
178
|
}
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
179
|
+
|
180
|
+
const chunk = getArrayBuffer(xhr);
|
181
|
+
|
182
|
+
if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
|
183
|
+
const rangeHeader = xhr.getResponseHeader("Content-Range");
|
184
|
+
const matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
|
185
|
+
pendingRequest.onDone({
|
186
|
+
begin: parseInt(matches[1], 10),
|
187
|
+
chunk
|
188
|
+
});
|
189
|
+
} else if (chunk) {
|
190
|
+
pendingRequest.onDone({
|
191
|
+
begin: 0,
|
192
|
+
chunk
|
193
|
+
});
|
194
|
+
} else if (pendingRequest.onError) {
|
195
|
+
pendingRequest.onError(xhr.status);
|
254
196
|
}
|
255
|
-
}
|
197
|
+
}
|
256
198
|
|
257
|
-
|
258
|
-
|
199
|
+
getRequestXhr(xhrId) {
|
200
|
+
return this.pendingRequests[xhrId].xhr;
|
201
|
+
}
|
259
202
|
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
function PDFNetworkStream(source) {
|
264
|
-
_classCallCheck(this, PDFNetworkStream);
|
203
|
+
isPendingRequest(xhrId) {
|
204
|
+
return xhrId in this.pendingRequests;
|
205
|
+
}
|
265
206
|
|
207
|
+
abortRequest(xhrId) {
|
208
|
+
const xhr = this.pendingRequests[xhrId].xhr;
|
209
|
+
delete this.pendingRequests[xhrId];
|
210
|
+
xhr.abort();
|
211
|
+
}
|
212
|
+
|
213
|
+
}
|
214
|
+
|
215
|
+
class PDFNetworkStream {
|
216
|
+
constructor(source) {
|
266
217
|
this._source = source;
|
267
218
|
this._manager = new NetworkManager(source.url, {
|
268
219
|
httpHeaders: source.httpHeaders,
|
@@ -273,60 +224,49 @@ function () {
|
|
273
224
|
this._rangeRequestReaders = [];
|
274
225
|
}
|
275
226
|
|
276
|
-
|
277
|
-
|
278
|
-
value: function _onRangeRequestReaderClosed(reader) {
|
279
|
-
var i = this._rangeRequestReaders.indexOf(reader);
|
227
|
+
_onRangeRequestReaderClosed(reader) {
|
228
|
+
const i = this._rangeRequestReaders.indexOf(reader);
|
280
229
|
|
281
|
-
|
282
|
-
|
283
|
-
}
|
284
|
-
}
|
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;
|
230
|
+
if (i >= 0) {
|
231
|
+
this._rangeRequestReaders.splice(i, 1);
|
291
232
|
}
|
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);
|
233
|
+
}
|
297
234
|
|
298
|
-
|
235
|
+
getFullReader() {
|
236
|
+
(0, _util.assert)(!this._fullRequestReader, "PDFNetworkStream.getFullReader can only be called once.");
|
237
|
+
this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._source);
|
238
|
+
return this._fullRequestReader;
|
239
|
+
}
|
299
240
|
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
key: "cancelAllRequests",
|
304
|
-
value: function cancelAllRequests(reason) {
|
305
|
-
if (this._fullRequestReader) {
|
306
|
-
this._fullRequestReader.cancel(reason);
|
307
|
-
}
|
241
|
+
getRangeReader(begin, end) {
|
242
|
+
const reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end);
|
243
|
+
reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
|
308
244
|
|
309
|
-
|
245
|
+
this._rangeRequestReaders.push(reader);
|
310
246
|
|
311
|
-
|
312
|
-
|
313
|
-
|
247
|
+
return reader;
|
248
|
+
}
|
249
|
+
|
250
|
+
cancelAllRequests(reason) {
|
251
|
+
if (this._fullRequestReader) {
|
252
|
+
this._fullRequestReader.cancel(reason);
|
314
253
|
}
|
315
|
-
}]);
|
316
254
|
|
317
|
-
|
318
|
-
}();
|
255
|
+
const readers = this._rangeRequestReaders.slice(0);
|
319
256
|
|
320
|
-
|
257
|
+
readers.forEach(function (reader) {
|
258
|
+
reader.cancel(reason);
|
259
|
+
});
|
260
|
+
}
|
261
|
+
|
262
|
+
}
|
321
263
|
|
322
|
-
|
323
|
-
/*#__PURE__*/
|
324
|
-
function () {
|
325
|
-
function PDFNetworkStreamFullRequestReader(manager, source) {
|
326
|
-
_classCallCheck(this, PDFNetworkStreamFullRequestReader);
|
264
|
+
exports.PDFNetworkStream = PDFNetworkStream;
|
327
265
|
|
266
|
+
class PDFNetworkStreamFullRequestReader {
|
267
|
+
constructor(manager, source) {
|
328
268
|
this._manager = manager;
|
329
|
-
|
269
|
+
const args = {
|
330
270
|
onHeadersReceived: this._onHeadersReceived.bind(this),
|
331
271
|
onDone: this._onDone.bind(this),
|
332
272
|
onError: this._onError.bind(this),
|
@@ -353,218 +293,168 @@ function () {
|
|
353
293
|
this.onProgress = null;
|
354
294
|
}
|
355
295
|
|
356
|
-
|
357
|
-
|
358
|
-
value: function _onHeadersReceived() {
|
359
|
-
var fullRequestXhrId = this._fullRequestId;
|
296
|
+
_onHeadersReceived() {
|
297
|
+
const fullRequestXhrId = this._fullRequestId;
|
360
298
|
|
361
|
-
|
299
|
+
const fullRequestXhr = this._manager.getRequestXhr(fullRequestXhrId);
|
362
300
|
|
363
|
-
|
364
|
-
|
365
|
-
|
301
|
+
const getResponseHeader = name => {
|
302
|
+
return fullRequestXhr.getResponseHeader(name);
|
303
|
+
};
|
366
304
|
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
if (allowRangeRequests) {
|
377
|
-
this._isRangeSupported = true;
|
378
|
-
}
|
305
|
+
const {
|
306
|
+
allowRangeRequests,
|
307
|
+
suggestedLength
|
308
|
+
} = (0, _network_utils.validateRangeRequestCapabilities)({
|
309
|
+
getResponseHeader,
|
310
|
+
isHttp: this._manager.isHttp,
|
311
|
+
rangeChunkSize: this._rangeChunkSize,
|
312
|
+
disableRange: this._disableRange
|
313
|
+
});
|
379
314
|
|
380
|
-
|
381
|
-
this.
|
315
|
+
if (allowRangeRequests) {
|
316
|
+
this._isRangeSupported = true;
|
317
|
+
}
|
382
318
|
|
383
|
-
|
384
|
-
|
385
|
-
}
|
319
|
+
this._contentLength = suggestedLength || this._contentLength;
|
320
|
+
this._filename = (0, _network_utils.extractFilenameFromHeader)(getResponseHeader);
|
386
321
|
|
387
|
-
|
322
|
+
if (this._isRangeSupported) {
|
323
|
+
this._manager.abortRequest(fullRequestXhrId);
|
388
324
|
}
|
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
325
|
|
405
|
-
|
326
|
+
this._headersReceivedCapability.resolve();
|
327
|
+
}
|
406
328
|
|
407
|
-
|
408
|
-
|
409
|
-
|
329
|
+
_onDone(args) {
|
330
|
+
if (args) {
|
331
|
+
if (this._requests.length > 0) {
|
332
|
+
const requestCapability = this._requests.shift();
|
410
333
|
|
411
|
-
this._requests.forEach(function (requestCapability) {
|
412
334
|
requestCapability.resolve({
|
413
|
-
value:
|
414
|
-
done:
|
335
|
+
value: args.chunk,
|
336
|
+
done: false
|
415
337
|
});
|
416
|
-
}
|
417
|
-
|
418
|
-
|
338
|
+
} else {
|
339
|
+
this._cachedChunks.push(args.chunk);
|
340
|
+
}
|
419
341
|
}
|
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
342
|
|
427
|
-
|
343
|
+
this._done = true;
|
428
344
|
|
429
|
-
|
430
|
-
|
345
|
+
if (this._cachedChunks.length > 0) {
|
346
|
+
return;
|
347
|
+
}
|
348
|
+
|
349
|
+
this._requests.forEach(function (requestCapability) {
|
350
|
+
requestCapability.resolve({
|
351
|
+
value: undefined,
|
352
|
+
done: true
|
431
353
|
});
|
354
|
+
});
|
432
355
|
|
433
|
-
|
434
|
-
|
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
|
-
}
|
445
|
-
}
|
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
|
-
}
|
356
|
+
this._requests = [];
|
357
|
+
}
|
505
358
|
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
value: function cancel(reason) {
|
511
|
-
this._done = true;
|
359
|
+
_onError(status) {
|
360
|
+
const url = this._url;
|
361
|
+
const exception = (0, _network_utils.createResponseStatusError)(status, url);
|
362
|
+
this._storedError = exception;
|
512
363
|
|
513
|
-
|
364
|
+
this._headersReceivedCapability.reject(exception);
|
514
365
|
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
366
|
+
this._requests.forEach(function (requestCapability) {
|
367
|
+
requestCapability.reject(exception);
|
368
|
+
});
|
369
|
+
|
370
|
+
this._requests = [];
|
371
|
+
this._cachedChunks = [];
|
372
|
+
}
|
373
|
+
|
374
|
+
_onProgress(data) {
|
375
|
+
if (this.onProgress) {
|
376
|
+
this.onProgress({
|
377
|
+
loaded: data.loaded,
|
378
|
+
total: data.lengthComputable ? data.total : this._contentLength
|
520
379
|
});
|
380
|
+
}
|
381
|
+
}
|
521
382
|
|
522
|
-
|
383
|
+
get filename() {
|
384
|
+
return this._filename;
|
385
|
+
}
|
523
386
|
|
524
|
-
|
525
|
-
|
526
|
-
|
387
|
+
get isRangeSupported() {
|
388
|
+
return this._isRangeSupported;
|
389
|
+
}
|
527
390
|
|
528
|
-
|
529
|
-
|
530
|
-
}
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
391
|
+
get isStreamingSupported() {
|
392
|
+
return this._isStreamingSupported;
|
393
|
+
}
|
394
|
+
|
395
|
+
get contentLength() {
|
396
|
+
return this._contentLength;
|
397
|
+
}
|
398
|
+
|
399
|
+
get headersReady() {
|
400
|
+
return this._headersReceivedCapability.promise;
|
401
|
+
}
|
402
|
+
|
403
|
+
async read() {
|
404
|
+
if (this._storedError) {
|
405
|
+
throw this._storedError;
|
539
406
|
}
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
407
|
+
|
408
|
+
if (this._cachedChunks.length > 0) {
|
409
|
+
const chunk = this._cachedChunks.shift();
|
410
|
+
|
411
|
+
return {
|
412
|
+
value: chunk,
|
413
|
+
done: false
|
414
|
+
};
|
544
415
|
}
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
416
|
+
|
417
|
+
if (this._done) {
|
418
|
+
return {
|
419
|
+
value: undefined,
|
420
|
+
done: true
|
421
|
+
};
|
549
422
|
}
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
423
|
+
|
424
|
+
const requestCapability = (0, _util.createPromiseCapability)();
|
425
|
+
|
426
|
+
this._requests.push(requestCapability);
|
427
|
+
|
428
|
+
return requestCapability.promise;
|
429
|
+
}
|
430
|
+
|
431
|
+
cancel(reason) {
|
432
|
+
this._done = true;
|
433
|
+
|
434
|
+
this._headersReceivedCapability.reject(reason);
|
435
|
+
|
436
|
+
this._requests.forEach(function (requestCapability) {
|
437
|
+
requestCapability.resolve({
|
438
|
+
value: undefined,
|
439
|
+
done: true
|
440
|
+
});
|
441
|
+
});
|
442
|
+
|
443
|
+
this._requests = [];
|
444
|
+
|
445
|
+
if (this._manager.isPendingRequest(this._fullRequestId)) {
|
446
|
+
this._manager.abortRequest(this._fullRequestId);
|
554
447
|
}
|
555
|
-
}]);
|
556
448
|
|
557
|
-
|
558
|
-
}
|
449
|
+
this._fullRequestReader = null;
|
450
|
+
}
|
559
451
|
|
560
|
-
|
561
|
-
/*#__PURE__*/
|
562
|
-
function () {
|
563
|
-
function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
|
564
|
-
_classCallCheck(this, PDFNetworkStreamRangeRequestReader);
|
452
|
+
}
|
565
453
|
|
454
|
+
class PDFNetworkStreamRangeRequestReader {
|
455
|
+
constructor(manager, begin, end) {
|
566
456
|
this._manager = manager;
|
567
|
-
|
457
|
+
const args = {
|
568
458
|
onDone: this._onDone.bind(this),
|
569
459
|
onProgress: this._onProgress.bind(this)
|
570
460
|
};
|
@@ -576,132 +466,93 @@ function () {
|
|
576
466
|
this.onClosed = null;
|
577
467
|
}
|
578
468
|
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
if (this.onClosed) {
|
583
|
-
this.onClosed(this);
|
584
|
-
}
|
469
|
+
_close() {
|
470
|
+
if (this.onClosed) {
|
471
|
+
this.onClosed(this);
|
585
472
|
}
|
586
|
-
}
|
587
|
-
key: "_onDone",
|
588
|
-
value: function _onDone(data) {
|
589
|
-
var chunk = data.chunk;
|
473
|
+
}
|
590
474
|
|
591
|
-
|
592
|
-
|
475
|
+
_onDone(data) {
|
476
|
+
const chunk = data.chunk;
|
593
477
|
|
594
|
-
|
595
|
-
|
596
|
-
done: false
|
597
|
-
});
|
598
|
-
} else {
|
599
|
-
this._queuedChunk = chunk;
|
600
|
-
}
|
478
|
+
if (this._requests.length > 0) {
|
479
|
+
const requestCapability = this._requests.shift();
|
601
480
|
|
602
|
-
|
481
|
+
requestCapability.resolve({
|
482
|
+
value: chunk,
|
483
|
+
done: false
|
484
|
+
});
|
485
|
+
} else {
|
486
|
+
this._queuedChunk = chunk;
|
487
|
+
}
|
603
488
|
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
489
|
+
this._done = true;
|
490
|
+
|
491
|
+
this._requests.forEach(function (requestCapability) {
|
492
|
+
requestCapability.resolve({
|
493
|
+
value: undefined,
|
494
|
+
done: true
|
609
495
|
});
|
496
|
+
});
|
610
497
|
|
611
|
-
|
498
|
+
this._requests = [];
|
499
|
+
|
500
|
+
this._close();
|
501
|
+
}
|
612
502
|
|
613
|
-
|
503
|
+
_onProgress(evt) {
|
504
|
+
if (!this.isStreamingSupported && this.onProgress) {
|
505
|
+
this.onProgress({
|
506
|
+
loaded: evt.loaded
|
507
|
+
});
|
614
508
|
}
|
615
|
-
}
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
509
|
+
}
|
510
|
+
|
511
|
+
get isStreamingSupported() {
|
512
|
+
return false;
|
513
|
+
}
|
514
|
+
|
515
|
+
async read() {
|
516
|
+
if (this._queuedChunk !== null) {
|
517
|
+
const chunk = this._queuedChunk;
|
518
|
+
this._queuedChunk = null;
|
519
|
+
return {
|
520
|
+
value: chunk,
|
521
|
+
done: false
|
522
|
+
};
|
623
523
|
}
|
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
524
|
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
525
|
+
if (this._done) {
|
526
|
+
return {
|
527
|
+
value: undefined,
|
528
|
+
done: true
|
529
|
+
};
|
530
|
+
}
|
683
531
|
|
684
|
-
|
685
|
-
requestCapability.resolve({
|
686
|
-
value: undefined,
|
687
|
-
done: true
|
688
|
-
});
|
689
|
-
});
|
532
|
+
const requestCapability = (0, _util.createPromiseCapability)();
|
690
533
|
|
691
|
-
|
534
|
+
this._requests.push(requestCapability);
|
692
535
|
|
693
|
-
|
694
|
-
|
695
|
-
}
|
536
|
+
return requestCapability.promise;
|
537
|
+
}
|
696
538
|
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
539
|
+
cancel(reason) {
|
540
|
+
this._done = true;
|
541
|
+
|
542
|
+
this._requests.forEach(function (requestCapability) {
|
543
|
+
requestCapability.resolve({
|
544
|
+
value: undefined,
|
545
|
+
done: true
|
546
|
+
});
|
547
|
+
});
|
548
|
+
|
549
|
+
this._requests = [];
|
550
|
+
|
551
|
+
if (this._manager.isPendingRequest(this._requestId)) {
|
552
|
+
this._manager.abortRequest(this._requestId);
|
703
553
|
}
|
704
|
-
}]);
|
705
554
|
|
706
|
-
|
707
|
-
}
|
555
|
+
this._close();
|
556
|
+
}
|
557
|
+
|
558
|
+
}
|