pdfjs-dist 2.0.943 → 2.4.456
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/README.md +4 -0
- package/bower.json +1 -1
- package/build/pdf.js +8286 -14230
- 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 +25500 -26628
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +22 -1
- package/es5/build/pdf.js +25473 -0
- package/es5/build/pdf.js.map +1 -0
- package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
- package/es5/build/pdf.worker.js +57878 -0
- package/es5/build/pdf.worker.js.map +1 -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/images/texture.png +0 -0
- package/es5/web/pdf_viewer.css +407 -0
- package/es5/web/pdf_viewer.js +7757 -0
- package/es5/web/pdf_viewer.js.map +1 -0
- package/image_decoders/pdf.image_decoders.js +2887 -4094
- 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 +855 -778
- package/lib/core/arithmetic_decoder.js +325 -311
- package/lib/core/bidi.js +117 -50
- package/lib/core/ccitt.js +251 -89
- package/lib/core/ccitt_stream.js +26 -16
- package/lib/core/cff_parser.js +525 -197
- package/lib/core/charsets.js +6 -5
- package/lib/core/chunked_stream.js +541 -406
- package/lib/core/cmap.js +368 -253
- package/lib/core/colorspace.js +781 -800
- package/lib/core/core_utils.js +152 -0
- package/lib/core/crypto.js +609 -422
- package/lib/core/document.js +649 -481
- package/lib/core/encodings.js +33 -24
- package/lib/core/evaluator.js +1471 -736
- package/lib/core/font_renderer.js +289 -149
- package/lib/core/fonts.js +1067 -413
- package/lib/core/function.js +517 -287
- package/lib/core/glyphlist.js +4529 -4527
- package/lib/core/image.js +232 -114
- package/lib/core/image_utils.js +94 -0
- package/lib/core/jbig2.js +711 -342
- package/lib/core/jbig2_stream.js +31 -19
- package/lib/core/jpeg_stream.js +151 -26
- package/lib/core/jpg.js +433 -181
- package/lib/core/jpx.js +551 -143
- package/lib/core/jpx_stream.js +40 -28
- package/lib/core/metrics.js +2931 -2931
- package/lib/core/murmurhash3.js +104 -97
- package/lib/core/obj.js +1561 -1053
- package/lib/core/operator_list.js +192 -64
- package/lib/core/parser.js +1162 -864
- package/lib/core/pattern.js +224 -75
- package/lib/core/pdf_manager.js +154 -285
- package/lib/core/primitives.js +145 -69
- package/lib/core/ps_parser.js +212 -162
- package/lib/core/standard_fonts.js +245 -244
- package/lib/core/stream.js +353 -81
- package/lib/core/type1_parser.js +218 -68
- package/lib/core/unicode.js +1682 -1655
- package/lib/core/worker.js +233 -302
- package/lib/core/worker_stream.js +168 -0
- package/lib/display/annotation_layer.js +808 -862
- package/lib/display/api.js +1778 -1462
- package/lib/display/api_compatibility.js +14 -9
- package/lib/display/canvas.js +463 -140
- package/lib/display/content_disposition.js +86 -58
- package/lib/display/display_utils.js +524 -0
- package/lib/display/fetch_stream.js +202 -274
- package/lib/display/font_loader.js +311 -333
- package/lib/display/metadata.js +98 -88
- package/lib/display/network.js +343 -347
- package/lib/display/network_utils.js +46 -26
- package/lib/display/node_stream.js +326 -404
- package/lib/display/pattern_helper.js +168 -69
- package/lib/display/svg.js +1296 -885
- package/lib/display/text_layer.js +229 -103
- package/lib/display/transport_stream.js +290 -250
- package/lib/display/webgl.js +116 -83
- package/lib/display/worker_options.js +6 -5
- package/lib/display/xml_parser.js +358 -337
- package/lib/examples/node/domstubs.js +95 -39
- package/lib/pdf.js +49 -31
- package/lib/pdf.worker.js +7 -5
- package/lib/shared/compatibility.js +3 -145
- package/lib/shared/is_node.js +8 -7
- package/lib/shared/message_handler.js +367 -314
- package/lib/shared/util.js +421 -415
- package/lib/test/unit/annotation_spec.js +1570 -690
- package/lib/test/unit/api_spec.js +855 -493
- package/lib/test/unit/bidi_spec.js +12 -12
- package/lib/test/unit/cff_parser_spec.js +88 -61
- package/lib/test/unit/clitests_helper.js +9 -12
- package/lib/test/unit/cmap_spec.js +140 -88
- package/lib/test/unit/colorspace_spec.js +204 -152
- package/lib/test/unit/core_utils_spec.js +211 -0
- package/lib/test/unit/crypto_spec.js +194 -182
- package/lib/test/unit/custom_spec.js +50 -64
- package/lib/test/unit/display_svg_spec.js +53 -38
- package/lib/test/unit/display_utils_spec.js +263 -0
- package/lib/test/unit/document_spec.js +17 -22
- package/lib/test/unit/encodings_spec.js +15 -57
- package/lib/test/unit/evaluator_spec.js +90 -83
- package/lib/test/unit/fetch_stream_spec.js +111 -0
- package/lib/test/unit/function_spec.js +219 -205
- package/lib/test/unit/jasmine-boot.js +68 -39
- package/lib/test/unit/message_handler_spec.js +187 -160
- package/lib/test/unit/metadata_spec.js +87 -34
- package/lib/test/unit/murmurhash3_spec.js +13 -13
- package/lib/test/unit/network_spec.js +26 -59
- package/lib/test/unit/network_utils_spec.js +187 -121
- package/lib/test/unit/node_stream_spec.js +98 -90
- package/lib/test/unit/parser_spec.js +173 -131
- package/lib/test/unit/pdf_find_controller_spec.js +148 -67
- package/lib/test/unit/pdf_find_utils_spec.js +35 -34
- package/lib/test/unit/pdf_history_spec.js +45 -33
- package/lib/test/unit/primitives_spec.js +161 -126
- package/lib/test/unit/stream_spec.js +22 -15
- package/lib/test/unit/test_utils.js +149 -98
- package/lib/test/unit/testreporter.js +36 -18
- package/lib/test/unit/type1_parser_spec.js +46 -44
- package/lib/test/unit/ui_utils_spec.js +388 -372
- package/lib/test/unit/unicode_spec.js +49 -46
- package/lib/test/unit/util_spec.js +144 -248
- package/lib/web/annotation_layer_builder.js +75 -95
- package/lib/web/app.js +1538 -1147
- package/lib/web/app_options.js +116 -104
- package/lib/web/base_viewer.js +950 -775
- package/lib/web/chromecom.js +217 -225
- package/lib/web/debugger.js +236 -148
- package/lib/web/download_manager.js +50 -50
- package/lib/web/firefox_print_service.js +51 -33
- package/lib/web/firefoxcom.js +225 -352
- package/lib/web/genericcom.js +30 -93
- package/lib/web/genericl10n.js +26 -143
- package/lib/web/grab_to_pan.js +57 -33
- package/lib/web/interfaces.js +105 -232
- package/lib/web/overlay_manager.js +73 -227
- package/lib/web/password_prompt.js +44 -62
- package/lib/web/pdf_attachment_viewer.js +118 -123
- package/lib/web/pdf_cursor_tools.js +89 -93
- package/lib/web/pdf_document_properties.js +242 -281
- package/lib/web/pdf_find_bar.js +157 -163
- package/lib/web/pdf_find_controller.js +598 -454
- package/lib/web/pdf_find_utils.js +32 -16
- package/lib/web/pdf_history.js +481 -355
- package/lib/web/pdf_link_service.js +355 -323
- package/lib/web/pdf_outline_viewer.js +167 -152
- package/lib/web/pdf_page_view.js +511 -457
- package/lib/web/pdf_presentation_mode.js +347 -335
- package/lib/web/pdf_print_service.js +133 -103
- package/lib/web/pdf_rendering_queue.js +98 -100
- package/lib/web/pdf_sidebar.js +323 -299
- package/lib/web/pdf_sidebar_resizer.js +107 -108
- package/lib/web/pdf_single_page_viewer.js +94 -146
- package/lib/web/pdf_thumbnail_view.js +319 -269
- package/lib/web/pdf_thumbnail_viewer.js +219 -199
- package/lib/web/pdf_viewer.component.js +111 -32
- package/lib/web/pdf_viewer.js +61 -101
- package/lib/web/preferences.js +87 -272
- package/lib/web/secondary_toolbar.js +207 -220
- package/lib/web/text_layer_builder.js +322 -322
- package/lib/web/toolbar.js +227 -180
- package/lib/web/ui_utils.js +476 -421
- package/lib/web/view_history.js +59 -208
- package/lib/web/viewer_compatibility.js +9 -6
- package/package.json +2 -9
- package/web/pdf_viewer.css +36 -22
- package/web/pdf_viewer.js +4407 -4516
- package/web/pdf_viewer.js.map +1 -1
- package/webpack.js +14 -5
- package/external/streams/streams-lib.js +0 -3962
- package/external/url/url-lib.js +0 -627
- package/lib/display/dom_utils.js +0 -441
- package/lib/shared/streams_polyfill.js +0 -39
- package/lib/shared/url_polyfill.js +0 -50
- package/lib/test/unit/dom_utils_spec.js +0 -89
- package/lib/web/dom_events.js +0 -140
@@ -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.
|
@@ -19,17 +19,19 @@
|
|
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.ChunkedStreamManager = exports.ChunkedStream =
|
27
|
+
exports.ChunkedStreamManager = exports.ChunkedStream = void 0;
|
28
28
|
|
29
|
-
var _util = require(
|
29
|
+
var _util = require("../shared/util.js");
|
30
30
|
|
31
|
-
var
|
32
|
-
|
31
|
+
var _core_utils = require("./core_utils.js");
|
32
|
+
|
33
|
+
class ChunkedStream {
|
34
|
+
constructor(length, chunkSize, manager) {
|
33
35
|
this.bytes = new Uint8Array(length);
|
34
36
|
this.start = 0;
|
35
37
|
this.pos = 0;
|
@@ -42,211 +44,297 @@ var ChunkedStream = function ChunkedStreamClosure() {
|
|
42
44
|
this.progressiveDataLength = 0;
|
43
45
|
this.lastSuccessfulEnsureByteChunk = -1;
|
44
46
|
}
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
chunks.push(chunk);
|
51
|
-
}
|
52
|
-
}
|
53
|
-
return chunks;
|
54
|
-
},
|
55
|
-
getBaseStreams: function ChunkedStream_getBaseStreams() {
|
56
|
-
return [this];
|
57
|
-
},
|
58
|
-
allChunksLoaded: function ChunkedStream_allChunksLoaded() {
|
59
|
-
return this.numChunksLoaded === this.numChunks;
|
60
|
-
},
|
61
|
-
onReceiveData: function ChunkedStream_onReceiveData(begin, chunk) {
|
62
|
-
var end = begin + chunk.byteLength;
|
63
|
-
if (begin % this.chunkSize !== 0) {
|
64
|
-
throw new Error('Bad begin offset: ' + begin);
|
65
|
-
}
|
66
|
-
var length = this.bytes.length;
|
67
|
-
if (end % this.chunkSize !== 0 && end !== length) {
|
68
|
-
throw new Error('Bad end offset: ' + end);
|
69
|
-
}
|
70
|
-
this.bytes.set(new Uint8Array(chunk), begin);
|
71
|
-
var chunkSize = this.chunkSize;
|
72
|
-
var beginChunk = Math.floor(begin / chunkSize);
|
73
|
-
var endChunk = Math.floor((end - 1) / chunkSize) + 1;
|
74
|
-
var curChunk;
|
75
|
-
for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
|
76
|
-
if (!this.loadedChunks[curChunk]) {
|
77
|
-
this.loadedChunks[curChunk] = true;
|
78
|
-
++this.numChunksLoaded;
|
79
|
-
}
|
80
|
-
}
|
81
|
-
},
|
82
|
-
onReceiveProgressiveData: function ChunkedStream_onReceiveProgressiveData(data) {
|
83
|
-
var position = this.progressiveDataLength;
|
84
|
-
var beginChunk = Math.floor(position / this.chunkSize);
|
85
|
-
this.bytes.set(new Uint8Array(data), position);
|
86
|
-
position += data.byteLength;
|
87
|
-
this.progressiveDataLength = position;
|
88
|
-
var endChunk = position >= this.end ? this.numChunks : Math.floor(position / this.chunkSize);
|
89
|
-
var curChunk;
|
90
|
-
for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
|
91
|
-
if (!this.loadedChunks[curChunk]) {
|
92
|
-
this.loadedChunks[curChunk] = true;
|
93
|
-
++this.numChunksLoaded;
|
94
|
-
}
|
95
|
-
}
|
96
|
-
},
|
97
|
-
ensureByte: function ChunkedStream_ensureByte(pos) {
|
98
|
-
var chunk = Math.floor(pos / this.chunkSize);
|
99
|
-
if (chunk === this.lastSuccessfulEnsureByteChunk) {
|
100
|
-
return;
|
101
|
-
}
|
47
|
+
|
48
|
+
getMissingChunks() {
|
49
|
+
const chunks = [];
|
50
|
+
|
51
|
+
for (let chunk = 0, n = this.numChunks; chunk < n; ++chunk) {
|
102
52
|
if (!this.loadedChunks[chunk]) {
|
103
|
-
|
104
|
-
}
|
105
|
-
this.lastSuccessfulEnsureByteChunk = chunk;
|
106
|
-
},
|
107
|
-
ensureRange: function ChunkedStream_ensureRange(begin, end) {
|
108
|
-
if (begin >= end) {
|
109
|
-
return;
|
53
|
+
chunks.push(chunk);
|
110
54
|
}
|
111
|
-
|
112
|
-
|
55
|
+
}
|
56
|
+
|
57
|
+
return chunks;
|
58
|
+
}
|
59
|
+
|
60
|
+
getBaseStreams() {
|
61
|
+
return [this];
|
62
|
+
}
|
63
|
+
|
64
|
+
allChunksLoaded() {
|
65
|
+
return this.numChunksLoaded === this.numChunks;
|
66
|
+
}
|
67
|
+
|
68
|
+
onReceiveData(begin, chunk) {
|
69
|
+
const chunkSize = this.chunkSize;
|
70
|
+
|
71
|
+
if (begin % chunkSize !== 0) {
|
72
|
+
throw new Error(`Bad begin offset: ${begin}`);
|
73
|
+
}
|
74
|
+
|
75
|
+
const end = begin + chunk.byteLength;
|
76
|
+
|
77
|
+
if (end % chunkSize !== 0 && end !== this.bytes.length) {
|
78
|
+
throw new Error(`Bad end offset: ${end}`);
|
79
|
+
}
|
80
|
+
|
81
|
+
this.bytes.set(new Uint8Array(chunk), begin);
|
82
|
+
const beginChunk = Math.floor(begin / chunkSize);
|
83
|
+
const endChunk = Math.floor((end - 1) / chunkSize) + 1;
|
84
|
+
|
85
|
+
for (let curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
|
86
|
+
if (!this.loadedChunks[curChunk]) {
|
87
|
+
this.loadedChunks[curChunk] = true;
|
88
|
+
++this.numChunksLoaded;
|
113
89
|
}
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
90
|
+
}
|
91
|
+
}
|
92
|
+
|
93
|
+
onReceiveProgressiveData(data) {
|
94
|
+
let position = this.progressiveDataLength;
|
95
|
+
const beginChunk = Math.floor(position / this.chunkSize);
|
96
|
+
this.bytes.set(new Uint8Array(data), position);
|
97
|
+
position += data.byteLength;
|
98
|
+
this.progressiveDataLength = position;
|
99
|
+
const endChunk = position >= this.end ? this.numChunks : Math.floor(position / this.chunkSize);
|
100
|
+
|
101
|
+
for (let curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
|
102
|
+
if (!this.loadedChunks[curChunk]) {
|
103
|
+
this.loadedChunks[curChunk] = true;
|
104
|
+
++this.numChunksLoaded;
|
121
105
|
}
|
122
|
-
}
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
109
|
+
ensureByte(pos) {
|
110
|
+
if (pos < this.progressiveDataLength) {
|
111
|
+
return;
|
112
|
+
}
|
113
|
+
|
114
|
+
const chunk = Math.floor(pos / this.chunkSize);
|
115
|
+
|
116
|
+
if (chunk === this.lastSuccessfulEnsureByteChunk) {
|
117
|
+
return;
|
118
|
+
}
|
119
|
+
|
120
|
+
if (!this.loadedChunks[chunk]) {
|
121
|
+
throw new _core_utils.MissingDataException(pos, pos + 1);
|
122
|
+
}
|
123
|
+
|
124
|
+
this.lastSuccessfulEnsureByteChunk = chunk;
|
125
|
+
}
|
126
|
+
|
127
|
+
ensureRange(begin, end) {
|
128
|
+
if (begin >= end) {
|
129
|
+
return;
|
130
|
+
}
|
131
|
+
|
132
|
+
if (end <= this.progressiveDataLength) {
|
133
|
+
return;
|
134
|
+
}
|
135
|
+
|
136
|
+
const chunkSize = this.chunkSize;
|
137
|
+
const beginChunk = Math.floor(begin / chunkSize);
|
138
|
+
const endChunk = Math.floor((end - 1) / chunkSize) + 1;
|
139
|
+
|
140
|
+
for (let chunk = beginChunk; chunk < endChunk; ++chunk) {
|
141
|
+
if (!this.loadedChunks[chunk]) {
|
142
|
+
throw new _core_utils.MissingDataException(begin, end);
|
131
143
|
}
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
getByte: function ChunkedStream_getByte() {
|
144
|
-
var pos = this.pos;
|
145
|
-
if (pos >= this.end) {
|
146
|
-
return -1;
|
144
|
+
}
|
145
|
+
}
|
146
|
+
|
147
|
+
nextEmptyChunk(beginChunk) {
|
148
|
+
const numChunks = this.numChunks;
|
149
|
+
|
150
|
+
for (let i = 0; i < numChunks; ++i) {
|
151
|
+
const chunk = (beginChunk + i) % numChunks;
|
152
|
+
|
153
|
+
if (!this.loadedChunks[chunk]) {
|
154
|
+
return chunk;
|
147
155
|
}
|
156
|
+
}
|
157
|
+
|
158
|
+
return null;
|
159
|
+
}
|
160
|
+
|
161
|
+
hasChunk(chunk) {
|
162
|
+
return !!this.loadedChunks[chunk];
|
163
|
+
}
|
164
|
+
|
165
|
+
get length() {
|
166
|
+
return this.end - this.start;
|
167
|
+
}
|
168
|
+
|
169
|
+
get isEmpty() {
|
170
|
+
return this.length === 0;
|
171
|
+
}
|
172
|
+
|
173
|
+
getByte() {
|
174
|
+
const pos = this.pos;
|
175
|
+
|
176
|
+
if (pos >= this.end) {
|
177
|
+
return -1;
|
178
|
+
}
|
179
|
+
|
180
|
+
if (pos >= this.progressiveDataLength) {
|
148
181
|
this.ensureByte(pos);
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
182
|
+
}
|
183
|
+
|
184
|
+
return this.bytes[this.pos++];
|
185
|
+
}
|
186
|
+
|
187
|
+
getUint16() {
|
188
|
+
const b0 = this.getByte();
|
189
|
+
const b1 = this.getByte();
|
190
|
+
|
191
|
+
if (b0 === -1 || b1 === -1) {
|
192
|
+
return -1;
|
193
|
+
}
|
194
|
+
|
195
|
+
return (b0 << 8) + b1;
|
196
|
+
}
|
197
|
+
|
198
|
+
getInt32() {
|
199
|
+
const b0 = this.getByte();
|
200
|
+
const b1 = this.getByte();
|
201
|
+
const b2 = this.getByte();
|
202
|
+
const b3 = this.getByte();
|
203
|
+
return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
|
204
|
+
}
|
205
|
+
|
206
|
+
getBytes(length, forceClamped = false) {
|
207
|
+
const bytes = this.bytes;
|
208
|
+
const pos = this.pos;
|
209
|
+
const strEnd = this.end;
|
210
|
+
|
211
|
+
if (!length) {
|
212
|
+
if (strEnd > this.progressiveDataLength) {
|
173
213
|
this.ensureRange(pos, strEnd);
|
174
|
-
var _subarray = bytes.subarray(pos, strEnd);
|
175
|
-
return forceClamped ? new Uint8ClampedArray(_subarray) : _subarray;
|
176
214
|
}
|
177
|
-
|
178
|
-
|
179
|
-
end = strEnd;
|
180
|
-
}
|
181
|
-
this.ensureRange(pos, end);
|
182
|
-
this.pos = end;
|
183
|
-
var subarray = bytes.subarray(pos, end);
|
215
|
+
|
216
|
+
const subarray = bytes.subarray(pos, strEnd);
|
184
217
|
return forceClamped ? new Uint8ClampedArray(subarray) : subarray;
|
185
|
-
}
|
218
|
+
}
|
219
|
+
|
220
|
+
let end = pos + length;
|
221
|
+
|
222
|
+
if (end > strEnd) {
|
223
|
+
end = strEnd;
|
224
|
+
}
|
225
|
+
|
226
|
+
if (end > this.progressiveDataLength) {
|
227
|
+
this.ensureRange(pos, end);
|
228
|
+
}
|
186
229
|
|
187
|
-
|
188
|
-
|
230
|
+
this.pos = end;
|
231
|
+
const subarray = bytes.subarray(pos, end);
|
232
|
+
return forceClamped ? new Uint8ClampedArray(subarray) : subarray;
|
233
|
+
}
|
234
|
+
|
235
|
+
peekByte() {
|
236
|
+
const peekedByte = this.getByte();
|
237
|
+
|
238
|
+
if (peekedByte !== -1) {
|
189
239
|
this.pos--;
|
190
|
-
|
191
|
-
},
|
192
|
-
peekBytes: function peekBytes(length) {
|
193
|
-
var forceClamped = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
240
|
+
}
|
194
241
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
242
|
+
return peekedByte;
|
243
|
+
}
|
244
|
+
|
245
|
+
peekBytes(length, forceClamped = false) {
|
246
|
+
const bytes = this.getBytes(length, forceClamped);
|
247
|
+
this.pos -= bytes.length;
|
248
|
+
return bytes;
|
249
|
+
}
|
250
|
+
|
251
|
+
getByteRange(begin, end) {
|
252
|
+
if (begin < 0) {
|
253
|
+
begin = 0;
|
254
|
+
}
|
199
255
|
|
200
|
-
|
256
|
+
if (end > this.end) {
|
257
|
+
end = this.end;
|
258
|
+
}
|
259
|
+
|
260
|
+
if (end > this.progressiveDataLength) {
|
201
261
|
this.ensureRange(begin, end);
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
262
|
+
}
|
263
|
+
|
264
|
+
return this.bytes.subarray(begin, end);
|
265
|
+
}
|
266
|
+
|
267
|
+
skip(n) {
|
268
|
+
if (!n) {
|
269
|
+
n = 1;
|
270
|
+
}
|
271
|
+
|
272
|
+
this.pos += n;
|
273
|
+
}
|
274
|
+
|
275
|
+
reset() {
|
276
|
+
this.pos = this.start;
|
277
|
+
}
|
278
|
+
|
279
|
+
moveStart() {
|
280
|
+
this.start = this.pos;
|
281
|
+
}
|
282
|
+
|
283
|
+
makeSubStream(start, length, dict) {
|
284
|
+
if (length) {
|
285
|
+
if (start + length > this.progressiveDataLength) {
|
286
|
+
this.ensureRange(start, start + length);
|
207
287
|
}
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
}
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
missingChunks.push(chunk);
|
228
|
-
}
|
288
|
+
} else {
|
289
|
+
if (start >= this.progressiveDataLength) {
|
290
|
+
this.ensureByte(start);
|
291
|
+
}
|
292
|
+
}
|
293
|
+
|
294
|
+
function ChunkedStreamSubstream() {}
|
295
|
+
|
296
|
+
ChunkedStreamSubstream.prototype = Object.create(this);
|
297
|
+
|
298
|
+
ChunkedStreamSubstream.prototype.getMissingChunks = function () {
|
299
|
+
const chunkSize = this.chunkSize;
|
300
|
+
const beginChunk = Math.floor(this.start / chunkSize);
|
301
|
+
const endChunk = Math.floor((this.end - 1) / chunkSize) + 1;
|
302
|
+
const missingChunks = [];
|
303
|
+
|
304
|
+
for (let chunk = beginChunk; chunk < endChunk; ++chunk) {
|
305
|
+
if (!this.loadedChunks[chunk]) {
|
306
|
+
missingChunks.push(chunk);
|
229
307
|
}
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
308
|
+
}
|
309
|
+
|
310
|
+
return missingChunks;
|
311
|
+
};
|
312
|
+
|
313
|
+
ChunkedStreamSubstream.prototype.allChunksLoaded = function () {
|
314
|
+
if (this.numChunksLoaded === this.numChunks) {
|
315
|
+
return true;
|
316
|
+
}
|
317
|
+
|
318
|
+
return this.getMissingChunks().length === 0;
|
319
|
+
};
|
320
|
+
|
321
|
+
const subStream = new ChunkedStreamSubstream();
|
322
|
+
subStream.pos = subStream.start = start;
|
323
|
+
subStream.end = start + length || this.end;
|
324
|
+
subStream.dict = dict;
|
325
|
+
return subStream;
|
326
|
+
}
|
327
|
+
|
328
|
+
}
|
329
|
+
|
330
|
+
exports.ChunkedStream = ChunkedStream;
|
331
|
+
|
332
|
+
class ChunkedStreamManager {
|
333
|
+
constructor(pdfNetworkStream, args) {
|
334
|
+
this.length = args.length;
|
335
|
+
this.chunkSize = args.rangeChunkSize;
|
336
|
+
this.stream = new ChunkedStream(this.length, this.chunkSize, this);
|
248
337
|
this.pdfNetworkStream = pdfNetworkStream;
|
249
|
-
this.url = args.url;
|
250
338
|
this.disableAutoFetch = args.disableAutoFetch;
|
251
339
|
this.msgHandler = args.msgHandler;
|
252
340
|
this.currRequestId = 0;
|
@@ -257,237 +345,284 @@ var ChunkedStreamManager = function ChunkedStreamManagerClosure() {
|
|
257
345
|
this.aborted = false;
|
258
346
|
this._loadedStreamCapability = (0, _util.createPromiseCapability)();
|
259
347
|
}
|
260
|
-
ChunkedStreamManager.prototype = {
|
261
|
-
onLoadedStream: function ChunkedStreamManager_getLoadedStream() {
|
262
|
-
return this._loadedStreamCapability.promise;
|
263
|
-
},
|
264
|
-
sendRequest: function ChunkedStreamManager_sendRequest(begin, end) {
|
265
|
-
var _this = this;
|
266
348
|
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
349
|
+
onLoadedStream() {
|
350
|
+
return this._loadedStreamCapability.promise;
|
351
|
+
}
|
352
|
+
|
353
|
+
sendRequest(begin, end) {
|
354
|
+
const rangeReader = this.pdfNetworkStream.getRangeReader(begin, end);
|
355
|
+
|
356
|
+
if (!rangeReader.isStreamingSupported) {
|
357
|
+
rangeReader.onProgress = this.onProgress.bind(this);
|
358
|
+
}
|
359
|
+
|
360
|
+
let chunks = [],
|
361
|
+
loaded = 0;
|
362
|
+
const promise = new Promise((resolve, reject) => {
|
363
|
+
const readChunk = chunk => {
|
364
|
+
try {
|
365
|
+
if (!chunk.done) {
|
366
|
+
const data = chunk.value;
|
367
|
+
chunks.push(data);
|
368
|
+
loaded += (0, _util.arrayByteLength)(data);
|
369
|
+
|
370
|
+
if (rangeReader.isStreamingSupported) {
|
371
|
+
this.onProgress({
|
372
|
+
loaded
|
373
|
+
});
|
286
374
|
}
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
} catch (e) {
|
291
|
-
reject(e);
|
375
|
+
|
376
|
+
rangeReader.read().then(readChunk, reject);
|
377
|
+
return;
|
292
378
|
}
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
379
|
+
|
380
|
+
const chunkData = (0, _util.arraysToBytes)(chunks);
|
381
|
+
chunks = null;
|
382
|
+
resolve(chunkData);
|
383
|
+
} catch (e) {
|
384
|
+
reject(e);
|
299
385
|
}
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
386
|
+
};
|
387
|
+
|
388
|
+
rangeReader.read().then(readChunk, reject);
|
389
|
+
});
|
390
|
+
promise.then(data => {
|
391
|
+
if (this.aborted) {
|
392
|
+
return;
|
393
|
+
}
|
394
|
+
|
395
|
+
this.onReceiveData({
|
396
|
+
chunk: data,
|
397
|
+
begin
|
304
398
|
});
|
305
|
-
}
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
_requestChunks
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
399
|
+
});
|
400
|
+
}
|
401
|
+
|
402
|
+
requestAllChunks() {
|
403
|
+
const missingChunks = this.stream.getMissingChunks();
|
404
|
+
|
405
|
+
this._requestChunks(missingChunks);
|
406
|
+
|
407
|
+
return this._loadedStreamCapability.promise;
|
408
|
+
}
|
409
|
+
|
410
|
+
_requestChunks(chunks) {
|
411
|
+
const requestId = this.currRequestId++;
|
412
|
+
const chunksNeeded = Object.create(null);
|
413
|
+
this.chunksNeededByRequest[requestId] = chunksNeeded;
|
414
|
+
|
415
|
+
for (const chunk of chunks) {
|
416
|
+
if (!this.stream.hasChunk(chunk)) {
|
417
|
+
chunksNeeded[chunk] = true;
|
320
418
|
}
|
321
|
-
|
322
|
-
|
419
|
+
}
|
420
|
+
|
421
|
+
if ((0, _util.isEmptyObj)(chunksNeeded)) {
|
422
|
+
return Promise.resolve();
|
423
|
+
}
|
424
|
+
|
425
|
+
const capability = (0, _util.createPromiseCapability)();
|
426
|
+
this.promisesByRequest[requestId] = capability;
|
427
|
+
const chunksToRequest = [];
|
428
|
+
|
429
|
+
for (let chunk in chunksNeeded) {
|
430
|
+
chunk = chunk | 0;
|
431
|
+
|
432
|
+
if (!(chunk in this.requestsByChunk)) {
|
433
|
+
this.requestsByChunk[chunk] = [];
|
434
|
+
chunksToRequest.push(chunk);
|
323
435
|
}
|
324
|
-
|
325
|
-
this.
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
436
|
+
|
437
|
+
this.requestsByChunk[chunk].push(requestId);
|
438
|
+
}
|
439
|
+
|
440
|
+
if (!chunksToRequest.length) {
|
441
|
+
return capability.promise;
|
442
|
+
}
|
443
|
+
|
444
|
+
const groupedChunksToRequest = this.groupChunks(chunksToRequest);
|
445
|
+
|
446
|
+
for (const groupedChunk of groupedChunksToRequest) {
|
447
|
+
const begin = groupedChunk.beginChunk * this.chunkSize;
|
448
|
+
const end = Math.min(groupedChunk.endChunk * this.chunkSize, this.length);
|
449
|
+
this.sendRequest(begin, end);
|
450
|
+
}
|
451
|
+
|
452
|
+
return capability.promise;
|
453
|
+
}
|
454
|
+
|
455
|
+
getStream() {
|
456
|
+
return this.stream;
|
457
|
+
}
|
458
|
+
|
459
|
+
requestRange(begin, end) {
|
460
|
+
end = Math.min(end, this.length);
|
461
|
+
const beginChunk = this.getBeginChunk(begin);
|
462
|
+
const endChunk = this.getEndChunk(end);
|
463
|
+
const chunks = [];
|
464
|
+
|
465
|
+
for (let chunk = beginChunk; chunk < endChunk; ++chunk) {
|
466
|
+
chunks.push(chunk);
|
467
|
+
}
|
468
|
+
|
469
|
+
return this._requestChunks(chunks);
|
470
|
+
}
|
471
|
+
|
472
|
+
requestRanges(ranges = []) {
|
473
|
+
const chunksToRequest = [];
|
474
|
+
|
475
|
+
for (const range of ranges) {
|
476
|
+
const beginChunk = this.getBeginChunk(range.begin);
|
477
|
+
const endChunk = this.getEndChunk(range.end);
|
478
|
+
|
479
|
+
for (let chunk = beginChunk; chunk < endChunk; ++chunk) {
|
480
|
+
if (!chunksToRequest.includes(chunk)) {
|
331
481
|
chunksToRequest.push(chunk);
|
332
482
|
}
|
333
|
-
this.requestsByChunk[chunk].push(requestId);
|
334
483
|
}
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
484
|
+
}
|
485
|
+
|
486
|
+
chunksToRequest.sort(function (a, b) {
|
487
|
+
return a - b;
|
488
|
+
});
|
489
|
+
return this._requestChunks(chunksToRequest);
|
490
|
+
}
|
491
|
+
|
492
|
+
groupChunks(chunks) {
|
493
|
+
const groupedChunks = [];
|
494
|
+
let beginChunk = -1;
|
495
|
+
let prevChunk = -1;
|
496
|
+
|
497
|
+
for (let i = 0, ii = chunks.length; i < ii; ++i) {
|
498
|
+
const chunk = chunks[i];
|
499
|
+
|
500
|
+
if (beginChunk < 0) {
|
501
|
+
beginChunk = chunk;
|
344
502
|
}
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
var beginChunk = this.getBeginChunk(begin);
|
353
|
-
var endChunk = this.getEndChunk(end);
|
354
|
-
var chunks = [];
|
355
|
-
for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
|
356
|
-
chunks.push(chunk);
|
503
|
+
|
504
|
+
if (prevChunk >= 0 && prevChunk + 1 !== chunk) {
|
505
|
+
groupedChunks.push({
|
506
|
+
beginChunk,
|
507
|
+
endChunk: prevChunk + 1
|
508
|
+
});
|
509
|
+
beginChunk = chunk;
|
357
510
|
}
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
var beginChunk = this.getBeginChunk(ranges[i].begin);
|
365
|
-
var endChunk = this.getEndChunk(ranges[i].end);
|
366
|
-
for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
|
367
|
-
if (!chunksToRequest.includes(chunk)) {
|
368
|
-
chunksToRequest.push(chunk);
|
369
|
-
}
|
370
|
-
}
|
511
|
+
|
512
|
+
if (i + 1 === chunks.length) {
|
513
|
+
groupedChunks.push({
|
514
|
+
beginChunk,
|
515
|
+
endChunk: chunk + 1
|
516
|
+
});
|
371
517
|
}
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
518
|
+
|
519
|
+
prevChunk = chunk;
|
520
|
+
}
|
521
|
+
|
522
|
+
return groupedChunks;
|
523
|
+
}
|
524
|
+
|
525
|
+
onProgress(args) {
|
526
|
+
this.msgHandler.send("DocProgress", {
|
527
|
+
loaded: this.stream.numChunksLoaded * this.chunkSize + args.loaded,
|
528
|
+
total: this.length
|
529
|
+
});
|
530
|
+
}
|
531
|
+
|
532
|
+
onReceiveData(args) {
|
533
|
+
const chunk = args.chunk;
|
534
|
+
const isProgressive = args.begin === undefined;
|
535
|
+
const begin = isProgressive ? this.progressiveDataLength : args.begin;
|
536
|
+
const end = begin + chunk.byteLength;
|
537
|
+
const beginChunk = Math.floor(begin / this.chunkSize);
|
538
|
+
const endChunk = end < this.length ? Math.floor(end / this.chunkSize) : Math.ceil(end / this.chunkSize);
|
539
|
+
|
540
|
+
if (isProgressive) {
|
541
|
+
this.stream.onReceiveProgressiveData(chunk);
|
542
|
+
this.progressiveDataLength = end;
|
543
|
+
} else {
|
544
|
+
this.stream.onReceiveData(begin, chunk);
|
545
|
+
}
|
546
|
+
|
547
|
+
if (this.stream.allChunksLoaded()) {
|
548
|
+
this._loadedStreamCapability.resolve(this.stream);
|
549
|
+
}
|
550
|
+
|
551
|
+
const loadedRequests = [];
|
552
|
+
|
553
|
+
for (let chunk = beginChunk; chunk < endChunk; ++chunk) {
|
554
|
+
const requestIds = this.requestsByChunk[chunk] || [];
|
555
|
+
delete this.requestsByChunk[chunk];
|
556
|
+
|
557
|
+
for (const requestId of requestIds) {
|
558
|
+
const chunksNeeded = this.chunksNeededByRequest[requestId];
|
559
|
+
|
560
|
+
if (chunk in chunksNeeded) {
|
561
|
+
delete chunksNeeded[chunk];
|
398
562
|
}
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
},
|
403
|
-
onProgress: function ChunkedStreamManager_onProgress(args) {
|
404
|
-
var bytesLoaded = this.stream.numChunksLoaded * this.chunkSize + args.loaded;
|
405
|
-
this.msgHandler.send('DocProgress', {
|
406
|
-
loaded: bytesLoaded,
|
407
|
-
total: this.length
|
408
|
-
});
|
409
|
-
},
|
410
|
-
onReceiveData: function ChunkedStreamManager_onReceiveData(args) {
|
411
|
-
var chunk = args.chunk;
|
412
|
-
var isProgressive = args.begin === undefined;
|
413
|
-
var begin = isProgressive ? this.progressiveDataLength : args.begin;
|
414
|
-
var end = begin + chunk.byteLength;
|
415
|
-
var beginChunk = Math.floor(begin / this.chunkSize);
|
416
|
-
var endChunk = end < this.length ? Math.floor(end / this.chunkSize) : Math.ceil(end / this.chunkSize);
|
417
|
-
if (isProgressive) {
|
418
|
-
this.stream.onReceiveProgressiveData(chunk);
|
419
|
-
this.progressiveDataLength = end;
|
420
|
-
} else {
|
421
|
-
this.stream.onReceiveData(begin, chunk);
|
422
|
-
}
|
423
|
-
if (this.stream.allChunksLoaded()) {
|
424
|
-
this._loadedStreamCapability.resolve(this.stream);
|
425
|
-
}
|
426
|
-
var loadedRequests = [];
|
427
|
-
var i, requestId;
|
428
|
-
for (chunk = beginChunk; chunk < endChunk; ++chunk) {
|
429
|
-
var requestIds = this.requestsByChunk[chunk] || [];
|
430
|
-
delete this.requestsByChunk[chunk];
|
431
|
-
for (i = 0; i < requestIds.length; ++i) {
|
432
|
-
requestId = requestIds[i];
|
433
|
-
var chunksNeeded = this.chunksNeededByRequest[requestId];
|
434
|
-
if (chunk in chunksNeeded) {
|
435
|
-
delete chunksNeeded[chunk];
|
436
|
-
}
|
437
|
-
if (!(0, _util.isEmptyObj)(chunksNeeded)) {
|
438
|
-
continue;
|
439
|
-
}
|
440
|
-
loadedRequests.push(requestId);
|
563
|
+
|
564
|
+
if (!(0, _util.isEmptyObj)(chunksNeeded)) {
|
565
|
+
continue;
|
441
566
|
}
|
567
|
+
|
568
|
+
loadedRequests.push(requestId);
|
442
569
|
}
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
if (Number.isInteger(nextEmptyChunk)) {
|
454
|
-
this._requestChunks([nextEmptyChunk]);
|
570
|
+
}
|
571
|
+
|
572
|
+
if (!this.disableAutoFetch && (0, _util.isEmptyObj)(this.requestsByChunk)) {
|
573
|
+
let nextEmptyChunk;
|
574
|
+
|
575
|
+
if (this.stream.numChunksLoaded === 1) {
|
576
|
+
const lastChunk = this.stream.numChunks - 1;
|
577
|
+
|
578
|
+
if (!this.stream.hasChunk(lastChunk)) {
|
579
|
+
nextEmptyChunk = lastChunk;
|
455
580
|
}
|
581
|
+
} else {
|
582
|
+
nextEmptyChunk = this.stream.nextEmptyChunk(endChunk);
|
456
583
|
}
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
delete this.promisesByRequest[requestId];
|
461
|
-
capability.resolve();
|
462
|
-
}
|
463
|
-
this.msgHandler.send('DocProgress', {
|
464
|
-
loaded: this.stream.numChunksLoaded * this.chunkSize,
|
465
|
-
total: this.length
|
466
|
-
});
|
467
|
-
},
|
468
|
-
onError: function ChunkedStreamManager_onError(err) {
|
469
|
-
this._loadedStreamCapability.reject(err);
|
470
|
-
},
|
471
|
-
getBeginChunk: function ChunkedStreamManager_getBeginChunk(begin) {
|
472
|
-
var chunk = Math.floor(begin / this.chunkSize);
|
473
|
-
return chunk;
|
474
|
-
},
|
475
|
-
getEndChunk: function ChunkedStreamManager_getEndChunk(end) {
|
476
|
-
var chunk = Math.floor((end - 1) / this.chunkSize) + 1;
|
477
|
-
return chunk;
|
478
|
-
},
|
479
|
-
abort: function ChunkedStreamManager_abort() {
|
480
|
-
this.aborted = true;
|
481
|
-
if (this.pdfNetworkStream) {
|
482
|
-
this.pdfNetworkStream.cancelAllRequests('abort');
|
483
|
-
}
|
484
|
-
for (var requestId in this.promisesByRequest) {
|
485
|
-
var capability = this.promisesByRequest[requestId];
|
486
|
-
capability.reject(new Error('Request was aborted'));
|
584
|
+
|
585
|
+
if (Number.isInteger(nextEmptyChunk)) {
|
586
|
+
this._requestChunks([nextEmptyChunk]);
|
487
587
|
}
|
488
588
|
}
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
589
|
+
|
590
|
+
for (const requestId of loadedRequests) {
|
591
|
+
const capability = this.promisesByRequest[requestId];
|
592
|
+
delete this.promisesByRequest[requestId];
|
593
|
+
capability.resolve();
|
594
|
+
}
|
595
|
+
|
596
|
+
this.msgHandler.send("DocProgress", {
|
597
|
+
loaded: this.stream.numChunksLoaded * this.chunkSize,
|
598
|
+
total: this.length
|
599
|
+
});
|
600
|
+
}
|
601
|
+
|
602
|
+
onError(err) {
|
603
|
+
this._loadedStreamCapability.reject(err);
|
604
|
+
}
|
605
|
+
|
606
|
+
getBeginChunk(begin) {
|
607
|
+
return Math.floor(begin / this.chunkSize);
|
608
|
+
}
|
609
|
+
|
610
|
+
getEndChunk(end) {
|
611
|
+
return Math.floor((end - 1) / this.chunkSize) + 1;
|
612
|
+
}
|
613
|
+
|
614
|
+
abort(reason) {
|
615
|
+
this.aborted = true;
|
616
|
+
|
617
|
+
if (this.pdfNetworkStream) {
|
618
|
+
this.pdfNetworkStream.cancelAllRequests(reason);
|
619
|
+
}
|
620
|
+
|
621
|
+
for (const requestId in this.promisesByRequest) {
|
622
|
+
this.promisesByRequest[requestId].reject(reason);
|
623
|
+
}
|
624
|
+
}
|
625
|
+
|
626
|
+
}
|
627
|
+
|
493
628
|
exports.ChunkedStreamManager = ChunkedStreamManager;
|