@vaadin-component-factory/vcf-pdf-viewer 3.1.0 → 4.0.0
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.
- package/README.md +2 -1
- package/package.json +56 -52
- package/pdfjs/dist/display_utils.js +609 -714
- package/pdfjs/dist/fetch_stream.js +239 -293
- package/pdfjs/dist/l10n_utils.js +113 -122
- package/pdfjs/dist/message_handler.js +451 -524
- package/pdfjs/dist/network.js +441 -552
- package/pdfjs/dist/network_utils.js +262 -309
- package/pdfjs/dist/node_stream.js +383 -481
- package/pdfjs/dist/pdf.js +9883 -11687
- package/pdfjs/dist/pdf_link_service.js +440 -534
- package/pdfjs/dist/pdf_rendering_queue.js +134 -154
- package/pdfjs/dist/pdf_thumbnail_viewer.js +620 -738
- package/pdfjs/dist/pdf_viewer.js +2667 -3207
- package/pdfjs/dist/ui_utils.js +762 -881
- package/pdfjs/dist/util.js +867 -991
- package/pdfjs/dist/worker.js +51434 -60846
- package/src/vcf-pdf-viewer.js +999 -886
- package/theme/base/vcf-pdf-viewer-styles.js +144 -0
- package/theme/base/vcf-pdf-viewer-toolbar-icons-styles.js +39 -0
- package/theme/base/vcf-pdf-viewer.js +3 -0
- package/vcf-pdf-viewer.js +1 -1
- package/theme/lumo/vcf-pdf-viewer-styles.js +0 -153
- package/theme/lumo/vcf-pdf-viewer-toolbar-icons-styles.js +0 -35
- package/theme/lumo/vcf-pdf-viewer.js +0 -3
- package/theme/material/baseline-keyboard_arrow_down-24px.svg +0 -1
- package/theme/material/baseline-keyboard_arrow_up-24px.svg +0 -1
- package/theme/material/vcf-pdf-viewer-styles.js +0 -123
- package/theme/material/vcf-pdf-viewer.js +0 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as validateResponseStatus, c as createResponseStatusError, v as validateRangeRequestCapabilities, e as extractFilenameFromHeader } from './network_utils.js';
|
|
3
|
-
import './display_utils.js';
|
|
4
|
-
|
|
1
|
+
import { d as assert, c as createPromiseCapability, A as AbortException } from './util.js';
|
|
2
|
+
import { a as validateResponseStatus, c as createResponseStatusError, v as validateRangeRequestCapabilities, e as extractFilenameFromHeader } from './network_utils.js';
|
|
3
|
+
import './display_utils.js';
|
|
4
|
+
|
|
5
5
|
/* Copyright 2012 Mozilla Foundation
|
|
6
6
|
*
|
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -15,292 +15,238 @@ import './display_utils.js';
|
|
|
15
15
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
16
|
* See the License for the specific language governing permissions and
|
|
17
17
|
* limitations under the License.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
|
21
|
-
throw new Error('Module "./fetch_stream.js" shall not be used with MOZCENTRAL builds.');
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
this.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
this.
|
|
103
|
-
|
|
104
|
-
this.
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
this.
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
this.
|
|
231
|
-
this.
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
throw reason;
|
|
257
|
-
});
|
|
258
|
-
this.onProgress = null;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
get isStreamingSupported() {
|
|
262
|
-
return this._isStreamingSupported;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
async read() {
|
|
266
|
-
await this._readCapability.promise;
|
|
267
|
-
const {
|
|
268
|
-
value,
|
|
269
|
-
done
|
|
270
|
-
} = await this._reader.read();
|
|
271
|
-
|
|
272
|
-
if (done) {
|
|
273
|
-
return {
|
|
274
|
-
value,
|
|
275
|
-
done
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
this._loaded += value.byteLength;
|
|
280
|
-
|
|
281
|
-
if (this.onProgress) {
|
|
282
|
-
this.onProgress({
|
|
283
|
-
loaded: this._loaded
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
const buffer = new Uint8Array(value).buffer;
|
|
288
|
-
return {
|
|
289
|
-
value: buffer,
|
|
290
|
-
done: false
|
|
291
|
-
};
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
cancel(reason) {
|
|
295
|
-
if (this._reader) {
|
|
296
|
-
this._reader.cancel(reason);
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
if (this._abortController) {
|
|
300
|
-
this._abortController.abort();
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
export { PDFFetchStream };
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
|
21
|
+
throw new Error('Module "./fetch_stream.js" shall not be used with MOZCENTRAL builds.');
|
|
22
|
+
}
|
|
23
|
+
function createFetchOptions(headers, withCredentials, abortController) {
|
|
24
|
+
return {
|
|
25
|
+
method: "GET",
|
|
26
|
+
headers,
|
|
27
|
+
signal: abortController === null || abortController === void 0 ? void 0 : abortController.signal,
|
|
28
|
+
mode: "cors",
|
|
29
|
+
credentials: withCredentials ? "include" : "same-origin",
|
|
30
|
+
redirect: "follow"
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function createHeaders(httpHeaders) {
|
|
34
|
+
const headers = new Headers();
|
|
35
|
+
for (const property in httpHeaders) {
|
|
36
|
+
const value = httpHeaders[property];
|
|
37
|
+
if (typeof value === "undefined") {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
headers.append(property, value);
|
|
41
|
+
}
|
|
42
|
+
return headers;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** @implements {IPDFStream} */
|
|
46
|
+
class PDFFetchStream {
|
|
47
|
+
constructor(source) {
|
|
48
|
+
this.source = source;
|
|
49
|
+
this.isHttp = /^https?:/i.test(source.url);
|
|
50
|
+
this.httpHeaders = this.isHttp && source.httpHeaders || {};
|
|
51
|
+
this._fullRequestReader = null;
|
|
52
|
+
this._rangeRequestReaders = [];
|
|
53
|
+
}
|
|
54
|
+
get _progressiveDataLength() {
|
|
55
|
+
var _this$_fullRequestRea, _this$_fullRequestRea2;
|
|
56
|
+
return (_this$_fullRequestRea = (_this$_fullRequestRea2 = this._fullRequestReader) === null || _this$_fullRequestRea2 === void 0 ? void 0 : _this$_fullRequestRea2._loaded) !== null && _this$_fullRequestRea !== void 0 ? _this$_fullRequestRea : 0;
|
|
57
|
+
}
|
|
58
|
+
getFullReader() {
|
|
59
|
+
assert(!this._fullRequestReader, "PDFFetchStream.getFullReader can only be called once.");
|
|
60
|
+
this._fullRequestReader = new PDFFetchStreamReader(this);
|
|
61
|
+
return this._fullRequestReader;
|
|
62
|
+
}
|
|
63
|
+
getRangeReader(begin, end) {
|
|
64
|
+
if (end <= this._progressiveDataLength) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
const reader = new PDFFetchStreamRangeReader(this, begin, end);
|
|
68
|
+
this._rangeRequestReaders.push(reader);
|
|
69
|
+
return reader;
|
|
70
|
+
}
|
|
71
|
+
cancelAllRequests(reason) {
|
|
72
|
+
if (this._fullRequestReader) {
|
|
73
|
+
this._fullRequestReader.cancel(reason);
|
|
74
|
+
}
|
|
75
|
+
for (const reader of this._rangeRequestReaders.slice(0)) {
|
|
76
|
+
reader.cancel(reason);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** @implements {IPDFStreamReader} */
|
|
82
|
+
class PDFFetchStreamReader {
|
|
83
|
+
constructor(stream) {
|
|
84
|
+
this._stream = stream;
|
|
85
|
+
this._reader = null;
|
|
86
|
+
this._loaded = 0;
|
|
87
|
+
this._filename = null;
|
|
88
|
+
const source = stream.source;
|
|
89
|
+
this._withCredentials = source.withCredentials || false;
|
|
90
|
+
this._contentLength = source.length;
|
|
91
|
+
this._headersCapability = createPromiseCapability();
|
|
92
|
+
this._disableRange = source.disableRange || false;
|
|
93
|
+
this._rangeChunkSize = source.rangeChunkSize;
|
|
94
|
+
if (!this._rangeChunkSize && !this._disableRange) {
|
|
95
|
+
this._disableRange = true;
|
|
96
|
+
}
|
|
97
|
+
if (typeof AbortController !== "undefined") {
|
|
98
|
+
this._abortController = new AbortController();
|
|
99
|
+
}
|
|
100
|
+
this._isStreamingSupported = !source.disableStream;
|
|
101
|
+
this._isRangeSupported = !source.disableRange;
|
|
102
|
+
this._headers = createHeaders(this._stream.httpHeaders);
|
|
103
|
+
const url = source.url;
|
|
104
|
+
fetch(url, createFetchOptions(this._headers, this._withCredentials, this._abortController)).then(response => {
|
|
105
|
+
if (!validateResponseStatus(response.status)) {
|
|
106
|
+
throw createResponseStatusError(response.status, url);
|
|
107
|
+
}
|
|
108
|
+
this._reader = response.body.getReader();
|
|
109
|
+
this._headersCapability.resolve();
|
|
110
|
+
const getResponseHeader = name => {
|
|
111
|
+
return response.headers.get(name);
|
|
112
|
+
};
|
|
113
|
+
const {
|
|
114
|
+
allowRangeRequests,
|
|
115
|
+
suggestedLength
|
|
116
|
+
} = validateRangeRequestCapabilities({
|
|
117
|
+
getResponseHeader,
|
|
118
|
+
isHttp: this._stream.isHttp,
|
|
119
|
+
rangeChunkSize: this._rangeChunkSize,
|
|
120
|
+
disableRange: this._disableRange
|
|
121
|
+
});
|
|
122
|
+
this._isRangeSupported = allowRangeRequests;
|
|
123
|
+
// Setting right content length.
|
|
124
|
+
this._contentLength = suggestedLength || this._contentLength;
|
|
125
|
+
this._filename = extractFilenameFromHeader(getResponseHeader);
|
|
126
|
+
|
|
127
|
+
// We need to stop reading when range is supported and streaming is
|
|
128
|
+
// disabled.
|
|
129
|
+
if (!this._isStreamingSupported && this._isRangeSupported) {
|
|
130
|
+
this.cancel(new AbortException("Streaming is disabled."));
|
|
131
|
+
}
|
|
132
|
+
}).catch(this._headersCapability.reject);
|
|
133
|
+
this.onProgress = null;
|
|
134
|
+
}
|
|
135
|
+
get headersReady() {
|
|
136
|
+
return this._headersCapability.promise;
|
|
137
|
+
}
|
|
138
|
+
get filename() {
|
|
139
|
+
return this._filename;
|
|
140
|
+
}
|
|
141
|
+
get contentLength() {
|
|
142
|
+
return this._contentLength;
|
|
143
|
+
}
|
|
144
|
+
get isRangeSupported() {
|
|
145
|
+
return this._isRangeSupported;
|
|
146
|
+
}
|
|
147
|
+
get isStreamingSupported() {
|
|
148
|
+
return this._isStreamingSupported;
|
|
149
|
+
}
|
|
150
|
+
async read() {
|
|
151
|
+
await this._headersCapability.promise;
|
|
152
|
+
const {
|
|
153
|
+
value,
|
|
154
|
+
done
|
|
155
|
+
} = await this._reader.read();
|
|
156
|
+
if (done) {
|
|
157
|
+
return {
|
|
158
|
+
value,
|
|
159
|
+
done
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
this._loaded += value.byteLength;
|
|
163
|
+
if (this.onProgress) {
|
|
164
|
+
this.onProgress({
|
|
165
|
+
loaded: this._loaded,
|
|
166
|
+
total: this._contentLength
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
const buffer = new Uint8Array(value).buffer;
|
|
170
|
+
return {
|
|
171
|
+
value: buffer,
|
|
172
|
+
done: false
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
cancel(reason) {
|
|
176
|
+
if (this._reader) {
|
|
177
|
+
this._reader.cancel(reason);
|
|
178
|
+
}
|
|
179
|
+
if (this._abortController) {
|
|
180
|
+
this._abortController.abort();
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** @implements {IPDFStreamRangeReader} */
|
|
186
|
+
class PDFFetchStreamRangeReader {
|
|
187
|
+
constructor(stream, begin, end) {
|
|
188
|
+
this._stream = stream;
|
|
189
|
+
this._reader = null;
|
|
190
|
+
this._loaded = 0;
|
|
191
|
+
const source = stream.source;
|
|
192
|
+
this._withCredentials = source.withCredentials || false;
|
|
193
|
+
this._readCapability = createPromiseCapability();
|
|
194
|
+
this._isStreamingSupported = !source.disableStream;
|
|
195
|
+
if (typeof AbortController !== "undefined") {
|
|
196
|
+
this._abortController = new AbortController();
|
|
197
|
+
}
|
|
198
|
+
this._headers = createHeaders(this._stream.httpHeaders);
|
|
199
|
+
this._headers.append("Range", `bytes=${begin}-${end - 1}`);
|
|
200
|
+
const url = source.url;
|
|
201
|
+
fetch(url, createFetchOptions(this._headers, this._withCredentials, this._abortController)).then(response => {
|
|
202
|
+
if (!validateResponseStatus(response.status)) {
|
|
203
|
+
throw createResponseStatusError(response.status, url);
|
|
204
|
+
}
|
|
205
|
+
this._readCapability.resolve();
|
|
206
|
+
this._reader = response.body.getReader();
|
|
207
|
+
}).catch(reason => {
|
|
208
|
+
if ((reason === null || reason === void 0 ? void 0 : reason.name) === "AbortError") {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
throw reason;
|
|
212
|
+
});
|
|
213
|
+
this.onProgress = null;
|
|
214
|
+
}
|
|
215
|
+
get isStreamingSupported() {
|
|
216
|
+
return this._isStreamingSupported;
|
|
217
|
+
}
|
|
218
|
+
async read() {
|
|
219
|
+
await this._readCapability.promise;
|
|
220
|
+
const {
|
|
221
|
+
value,
|
|
222
|
+
done
|
|
223
|
+
} = await this._reader.read();
|
|
224
|
+
if (done) {
|
|
225
|
+
return {
|
|
226
|
+
value,
|
|
227
|
+
done
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
this._loaded += value.byteLength;
|
|
231
|
+
if (this.onProgress) {
|
|
232
|
+
this.onProgress({
|
|
233
|
+
loaded: this._loaded
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
const buffer = new Uint8Array(value).buffer;
|
|
237
|
+
return {
|
|
238
|
+
value: buffer,
|
|
239
|
+
done: false
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
cancel(reason) {
|
|
243
|
+
if (this._reader) {
|
|
244
|
+
this._reader.cancel(reason);
|
|
245
|
+
}
|
|
246
|
+
if (this._abortController) {
|
|
247
|
+
this._abortController.abort();
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export { PDFFetchStream };
|