@vaadin-component-factory/vcf-pdf-viewer 0.9.0 → 0.9.4

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.
Files changed (174) hide show
  1. package/README.md +1 -1
  2. package/package.json +33 -18
  3. package/{src/display → pdfjs/dist}/display_utils.js +344 -139
  4. package/{src/display → pdfjs/dist}/fetch_stream.js +115 -97
  5. package/pdfjs/dist/get.js +1857 -0
  6. package/pdfjs/dist/index.js +767 -0
  7. package/pdfjs/dist/l10n_utils.js +140 -0
  8. package/{src/shared → pdfjs/dist}/message_handler.js +243 -259
  9. package/{src/display → pdfjs/dist}/network.js +149 -87
  10. package/{src/display/content_disposition.js → pdfjs/dist/network_utils.js} +167 -55
  11. package/{src/display → pdfjs/dist}/node_stream.js +133 -98
  12. package/pdfjs/dist/pdf.js +12778 -0
  13. package/pdfjs/dist/pdf_link_service.js +638 -0
  14. package/pdfjs/dist/pdf_rendering_queue.js +199 -0
  15. package/pdfjs/dist/pdf_thumbnail_viewer.js +819 -0
  16. package/pdfjs/dist/pdf_viewer.js +3598 -0
  17. package/pdfjs/dist/typeof.js +100 -0
  18. package/pdfjs/dist/ui_utils.js +1033 -0
  19. package/{src/shared → pdfjs/dist}/util.js +301 -287
  20. package/pdfjs/dist/worker.js +62813 -0
  21. package/src/vcf-pdf-viewer.js +77 -27
  22. package/theme/lumo/vcf-pdf-viewer-styles.js +1 -1
  23. package/theme/material/vcf-pdf-viewer.js +2 -2
  24. package/src/core/.eslintrc +0 -13
  25. package/src/core/annotation.js +0 -2948
  26. package/src/core/arithmetic_decoder.js +0 -182
  27. package/src/core/ascii_85_stream.js +0 -98
  28. package/src/core/ascii_hex_stream.js +0 -79
  29. package/src/core/base_stream.js +0 -110
  30. package/src/core/bidi.js +0 -438
  31. package/src/core/calibri_factors.js +0 -308
  32. package/src/core/catalog.js +0 -1459
  33. package/src/core/ccitt.js +0 -1062
  34. package/src/core/ccitt_stream.js +0 -60
  35. package/src/core/cff_font.js +0 -116
  36. package/src/core/cff_parser.js +0 -1949
  37. package/src/core/charsets.js +0 -119
  38. package/src/core/chunked_stream.js +0 -557
  39. package/src/core/cmap.js +0 -1039
  40. package/src/core/colorspace.js +0 -1533
  41. package/src/core/core_utils.js +0 -464
  42. package/src/core/crypto.js +0 -1900
  43. package/src/core/decode_stream.js +0 -170
  44. package/src/core/decrypt_stream.js +0 -59
  45. package/src/core/default_appearance.js +0 -99
  46. package/src/core/document.js +0 -1456
  47. package/src/core/encodings.js +0 -301
  48. package/src/core/evaluator.js +0 -4601
  49. package/src/core/file_spec.js +0 -108
  50. package/src/core/flate_stream.js +0 -402
  51. package/src/core/font_renderer.js +0 -882
  52. package/src/core/fonts.js +0 -3260
  53. package/src/core/fonts_utils.js +0 -221
  54. package/src/core/function.js +0 -1257
  55. package/src/core/glyf.js +0 -706
  56. package/src/core/glyphlist.js +0 -4558
  57. package/src/core/helvetica_factors.js +0 -353
  58. package/src/core/image.js +0 -802
  59. package/src/core/image_utils.js +0 -291
  60. package/src/core/jbig2.js +0 -2572
  61. package/src/core/jbig2_stream.js +0 -73
  62. package/src/core/jpeg_stream.js +0 -105
  63. package/src/core/jpg.js +0 -1416
  64. package/src/core/jpx.js +0 -2343
  65. package/src/core/jpx_stream.js +0 -87
  66. package/src/core/liberationsans_widths.js +0 -221
  67. package/src/core/lzw_stream.js +0 -150
  68. package/src/core/metadata_parser.js +0 -146
  69. package/src/core/metrics.js +0 -2970
  70. package/src/core/murmurhash3.js +0 -139
  71. package/src/core/myriadpro_factors.js +0 -290
  72. package/src/core/name_number_tree.js +0 -153
  73. package/src/core/object_loader.js +0 -149
  74. package/src/core/opentype_file_builder.js +0 -154
  75. package/src/core/operator_list.js +0 -734
  76. package/src/core/parser.js +0 -1416
  77. package/src/core/pattern.js +0 -985
  78. package/src/core/pdf_manager.js +0 -217
  79. package/src/core/predictor_stream.js +0 -238
  80. package/src/core/primitives.js +0 -402
  81. package/src/core/ps_parser.js +0 -272
  82. package/src/core/run_length_stream.js +0 -61
  83. package/src/core/segoeui_factors.js +0 -308
  84. package/src/core/standard_fonts.js +0 -817
  85. package/src/core/stream.js +0 -103
  86. package/src/core/struct_tree.js +0 -335
  87. package/src/core/to_unicode_map.js +0 -103
  88. package/src/core/type1_font.js +0 -421
  89. package/src/core/type1_parser.js +0 -776
  90. package/src/core/unicode.js +0 -1649
  91. package/src/core/worker.js +0 -848
  92. package/src/core/worker_stream.js +0 -135
  93. package/src/core/writer.js +0 -278
  94. package/src/core/xfa/bind.js +0 -652
  95. package/src/core/xfa/builder.js +0 -207
  96. package/src/core/xfa/config.js +0 -1926
  97. package/src/core/xfa/connection_set.js +0 -202
  98. package/src/core/xfa/data.js +0 -82
  99. package/src/core/xfa/datasets.js +0 -76
  100. package/src/core/xfa/factory.js +0 -111
  101. package/src/core/xfa/fonts.js +0 -181
  102. package/src/core/xfa/formcalc_lexer.js +0 -385
  103. package/src/core/xfa/formcalc_parser.js +0 -1340
  104. package/src/core/xfa/html_utils.js +0 -639
  105. package/src/core/xfa/layout.js +0 -383
  106. package/src/core/xfa/locale_set.js +0 -345
  107. package/src/core/xfa/namespaces.js +0 -81
  108. package/src/core/xfa/parser.js +0 -184
  109. package/src/core/xfa/setup.js +0 -38
  110. package/src/core/xfa/signature.js +0 -40
  111. package/src/core/xfa/som.js +0 -338
  112. package/src/core/xfa/stylesheet.js +0 -40
  113. package/src/core/xfa/template.js +0 -6260
  114. package/src/core/xfa/text.js +0 -290
  115. package/src/core/xfa/unknown.js +0 -29
  116. package/src/core/xfa/utils.js +0 -217
  117. package/src/core/xfa/xdp.js +0 -59
  118. package/src/core/xfa/xfa_object.js +0 -1130
  119. package/src/core/xfa/xhtml.js +0 -543
  120. package/src/core/xfa_fonts.js +0 -208
  121. package/src/core/xml_parser.js +0 -507
  122. package/src/core/xref.js +0 -899
  123. package/src/display/annotation_layer.js +0 -2107
  124. package/src/display/annotation_storage.js +0 -113
  125. package/src/display/api.js +0 -3292
  126. package/src/display/base_factory.js +0 -180
  127. package/src/display/canvas.js +0 -2828
  128. package/src/display/font_loader.js +0 -484
  129. package/src/display/metadata.js +0 -41
  130. package/src/display/network_utils.js +0 -100
  131. package/src/display/node_utils.js +0 -83
  132. package/src/display/optional_content_config.js +0 -189
  133. package/src/display/pattern_helper.js +0 -659
  134. package/src/display/svg.js +0 -1709
  135. package/src/display/text_layer.js +0 -847
  136. package/src/display/transport_stream.js +0 -303
  137. package/src/display/worker_options.js +0 -40
  138. package/src/display/xfa_layer.js +0 -204
  139. package/src/doc_helper.js +0 -25
  140. package/src/images/logo.svg +0 -41
  141. package/src/interfaces.js +0 -169
  142. package/src/license_header.js +0 -14
  143. package/src/license_header_libre.js +0 -21
  144. package/src/pdf.image_decoders.js +0 -46
  145. package/src/pdf.js +0 -146
  146. package/src/pdf.sandbox.external.js +0 -181
  147. package/src/pdf.sandbox.js +0 -151
  148. package/src/pdf.scripting.js +0 -25
  149. package/src/pdf.worker.entry.js +0 -19
  150. package/src/pdf.worker.js +0 -23
  151. package/src/scripting_api/aform.js +0 -608
  152. package/src/scripting_api/app.js +0 -621
  153. package/src/scripting_api/color.js +0 -129
  154. package/src/scripting_api/common.js +0 -58
  155. package/src/scripting_api/console.js +0 -38
  156. package/src/scripting_api/constants.js +0 -208
  157. package/src/scripting_api/doc.js +0 -1195
  158. package/src/scripting_api/error.js +0 -23
  159. package/src/scripting_api/event.js +0 -232
  160. package/src/scripting_api/field.js +0 -620
  161. package/src/scripting_api/fullscreen.js +0 -145
  162. package/src/scripting_api/initialization.js +0 -223
  163. package/src/scripting_api/pdf_object.js +0 -24
  164. package/src/scripting_api/print_params.js +0 -146
  165. package/src/scripting_api/proxy.js +0 -139
  166. package/src/scripting_api/thermometer.js +0 -69
  167. package/src/scripting_api/util.js +0 -581
  168. package/src/shared/.eslintrc +0 -13
  169. package/src/shared/cffStandardStrings.js +0 -311
  170. package/src/shared/compatibility.js +0 -114
  171. package/src/shared/fonts_utils.js +0 -429
  172. package/src/shared/is_node.js +0 -27
  173. package/src/shared/scripting_utils.js +0 -85
  174. package/src/worker_loader.js +0 -32
@@ -1,3 +1,7 @@
1
+ import { c as assert, l 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
+
1
5
  /* Copyright 2012 Mozilla Foundation
2
6
  *
3
7
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,67 +17,56 @@
13
17
  * limitations under the License.
14
18
  */
15
19
 
16
- import {
17
- AbortException,
18
- assert,
19
- createPromiseCapability,
20
- } from "../shared/util.js";
21
- import {
22
- createResponseStatusError,
23
- extractFilenameFromHeader,
24
- validateRangeRequestCapabilities,
25
- validateResponseStatus,
26
- } from "./network_utils.js";
27
-
28
20
  if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
29
- throw new Error(
30
- 'Module "./fetch_stream.js" shall not be used with MOZCENTRAL builds.'
31
- );
21
+ throw new Error('Module "./fetch_stream.js" shall not be used with MOZCENTRAL builds.');
32
22
  }
33
23
 
34
24
  function createFetchOptions(headers, withCredentials, abortController) {
35
25
  return {
36
26
  method: "GET",
37
27
  headers,
38
- signal: abortController?.signal,
28
+ signal: abortController === null || abortController === void 0 ? void 0 : abortController.signal,
39
29
  mode: "cors",
40
30
  credentials: withCredentials ? "include" : "same-origin",
41
- redirect: "follow",
31
+ redirect: "follow"
42
32
  };
43
33
  }
44
34
 
45
35
  function createHeaders(httpHeaders) {
46
36
  const headers = new Headers();
37
+
47
38
  for (const property in httpHeaders) {
48
39
  const value = httpHeaders[property];
40
+
49
41
  if (typeof value === "undefined") {
50
42
  continue;
51
43
  }
44
+
52
45
  headers.append(property, value);
53
46
  }
47
+
54
48
  return headers;
55
49
  }
56
-
57
50
  /** @implements {IPDFStream} */
51
+
52
+
58
53
  class PDFFetchStream {
59
54
  constructor(source) {
60
55
  this.source = source;
61
56
  this.isHttp = /^https?:/i.test(source.url);
62
- this.httpHeaders = (this.isHttp && source.httpHeaders) || {};
63
-
57
+ this.httpHeaders = this.isHttp && source.httpHeaders || {};
64
58
  this._fullRequestReader = null;
65
59
  this._rangeRequestReaders = [];
66
60
  }
67
61
 
68
62
  get _progressiveDataLength() {
69
- return this._fullRequestReader?._loaded ?? 0;
63
+ var _this$_fullRequestRea, _this$_fullRequestRea2;
64
+
65
+ 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;
70
66
  }
71
67
 
72
68
  getFullReader() {
73
- assert(
74
- !this._fullRequestReader,
75
- "PDFFetchStream.getFullReader can only be called once."
76
- );
69
+ assert(!this._fullRequestReader, "PDFFetchStream.getFullReader can only be called once.");
77
70
  this._fullRequestReader = new PDFFetchStreamReader(this);
78
71
  return this._fullRequestReader;
79
72
  }
@@ -82,8 +75,11 @@ class PDFFetchStream {
82
75
  if (end <= this._progressiveDataLength) {
83
76
  return null;
84
77
  }
78
+
85
79
  const reader = new PDFFetchStreamRangeReader(this, begin, end);
80
+
86
81
  this._rangeRequestReaders.push(reader);
82
+
87
83
  return reader;
88
84
  }
89
85
 
@@ -91,13 +87,16 @@ class PDFFetchStream {
91
87
  if (this._fullRequestReader) {
92
88
  this._fullRequestReader.cancel(reason);
93
89
  }
90
+
94
91
  for (const reader of this._rangeRequestReaders.slice(0)) {
95
92
  reader.cancel(reason);
96
93
  }
97
94
  }
98
- }
99
95
 
96
+ }
100
97
  /** @implements {IPDFStreamReader} */
98
+
99
+
101
100
  class PDFFetchStreamReader {
102
101
  constructor(stream) {
103
102
  this._stream = stream;
@@ -110,6 +109,7 @@ class PDFFetchStreamReader {
110
109
  this._headersCapability = createPromiseCapability();
111
110
  this._disableRange = source.disableRange || false;
112
111
  this._rangeChunkSize = source.rangeChunkSize;
112
+
113
113
  if (!this._rangeChunkSize && !this._disableRange) {
114
114
  this._disableRange = true;
115
115
  }
@@ -117,52 +117,43 @@ class PDFFetchStreamReader {
117
117
  if (typeof AbortController !== "undefined") {
118
118
  this._abortController = new AbortController();
119
119
  }
120
+
120
121
  this._isStreamingSupported = !source.disableStream;
121
122
  this._isRangeSupported = !source.disableRange;
122
-
123
123
  this._headers = createHeaders(this._stream.httpHeaders);
124
-
125
124
  const url = source.url;
126
- fetch(
127
- url,
128
- createFetchOptions(
129
- this._headers,
130
- this._withCredentials,
131
- this._abortController
132
- )
133
- )
134
- .then(response => {
135
- if (!validateResponseStatus(response.status)) {
136
- throw createResponseStatusError(response.status, url);
137
- }
138
- this._reader = response.body.getReader();
139
- this._headersCapability.resolve();
140
-
141
- const getResponseHeader = name => {
142
- return response.headers.get(name);
143
- };
144
- const { allowRangeRequests, suggestedLength } =
145
- validateRangeRequestCapabilities({
146
- getResponseHeader,
147
- isHttp: this._stream.isHttp,
148
- rangeChunkSize: this._rangeChunkSize,
149
- disableRange: this._disableRange,
150
- });
151
-
152
- this._isRangeSupported = allowRangeRequests;
153
- // Setting right content length.
154
- this._contentLength = suggestedLength || this._contentLength;
155
-
156
- this._filename = extractFilenameFromHeader(getResponseHeader);
157
-
158
- // We need to stop reading when range is supported and streaming is
159
- // disabled.
160
- if (!this._isStreamingSupported && this._isRangeSupported) {
161
- this.cancel(new AbortException("Streaming is disabled."));
162
- }
163
- })
164
- .catch(this._headersCapability.reject);
125
+ fetch(url, createFetchOptions(this._headers, this._withCredentials, this._abortController)).then(response => {
126
+ if (!validateResponseStatus(response.status)) {
127
+ throw createResponseStatusError(response.status, url);
128
+ }
129
+
130
+ this._reader = response.body.getReader();
131
+
132
+ this._headersCapability.resolve();
133
+
134
+ const getResponseHeader = name => {
135
+ return response.headers.get(name);
136
+ };
137
+
138
+ const {
139
+ allowRangeRequests,
140
+ suggestedLength
141
+ } = validateRangeRequestCapabilities({
142
+ getResponseHeader,
143
+ isHttp: this._stream.isHttp,
144
+ rangeChunkSize: this._rangeChunkSize,
145
+ disableRange: this._disableRange
146
+ });
147
+ this._isRangeSupported = allowRangeRequests; // Setting right content length.
148
+
149
+ this._contentLength = suggestedLength || this._contentLength;
150
+ this._filename = extractFilenameFromHeader(getResponseHeader); // We need to stop reading when range is supported and streaming is
151
+ // disabled.
165
152
 
153
+ if (!this._isStreamingSupported && this._isRangeSupported) {
154
+ this.cancel(new AbortException("Streaming is disabled."));
155
+ }
156
+ }).catch(this._headersCapability.reject);
166
157
  this.onProgress = null;
167
158
  }
168
159
 
@@ -188,32 +179,48 @@ class PDFFetchStreamReader {
188
179
 
189
180
  async read() {
190
181
  await this._headersCapability.promise;
191
- const { value, done } = await this._reader.read();
182
+ const {
183
+ value,
184
+ done
185
+ } = await this._reader.read();
186
+
192
187
  if (done) {
193
- return { value, done };
188
+ return {
189
+ value,
190
+ done
191
+ };
194
192
  }
193
+
195
194
  this._loaded += value.byteLength;
195
+
196
196
  if (this.onProgress) {
197
197
  this.onProgress({
198
198
  loaded: this._loaded,
199
- total: this._contentLength,
199
+ total: this._contentLength
200
200
  });
201
201
  }
202
+
202
203
  const buffer = new Uint8Array(value).buffer;
203
- return { value: buffer, done: false };
204
+ return {
205
+ value: buffer,
206
+ done: false
207
+ };
204
208
  }
205
209
 
206
210
  cancel(reason) {
207
211
  if (this._reader) {
208
212
  this._reader.cancel(reason);
209
213
  }
214
+
210
215
  if (this._abortController) {
211
216
  this._abortController.abort();
212
217
  }
213
218
  }
214
- }
215
219
 
220
+ }
216
221
  /** @implements {IPDFStreamRangeReader} */
222
+
223
+
217
224
  class PDFFetchStreamRangeReader {
218
225
  constructor(stream, begin, end) {
219
226
  this._stream = stream;
@@ -229,31 +236,25 @@ class PDFFetchStreamRangeReader {
229
236
  }
230
237
 
231
238
  this._headers = createHeaders(this._stream.httpHeaders);
239
+
232
240
  this._headers.append("Range", `bytes=${begin}-${end - 1}`);
233
241
 
234
242
  const url = source.url;
235
- fetch(
236
- url,
237
- createFetchOptions(
238
- this._headers,
239
- this._withCredentials,
240
- this._abortController
241
- )
242
- )
243
- .then(response => {
244
- if (!validateResponseStatus(response.status)) {
245
- throw createResponseStatusError(response.status, url);
246
- }
247
- this._readCapability.resolve();
248
- this._reader = response.body.getReader();
249
- })
250
- .catch(reason => {
251
- if (reason?.name === "AbortError") {
252
- return;
253
- }
254
- throw reason;
255
- });
243
+ fetch(url, createFetchOptions(this._headers, this._withCredentials, this._abortController)).then(response => {
244
+ if (!validateResponseStatus(response.status)) {
245
+ throw createResponseStatusError(response.status, url);
246
+ }
247
+
248
+ this._readCapability.resolve();
249
+
250
+ this._reader = response.body.getReader();
251
+ }).catch(reason => {
252
+ if ((reason === null || reason === void 0 ? void 0 : reason.name) === "AbortError") {
253
+ return;
254
+ }
256
255
 
256
+ throw reason;
257
+ });
257
258
  this.onProgress = null;
258
259
  }
259
260
 
@@ -263,26 +264,43 @@ class PDFFetchStreamRangeReader {
263
264
 
264
265
  async read() {
265
266
  await this._readCapability.promise;
266
- const { value, done } = await this._reader.read();
267
+ const {
268
+ value,
269
+ done
270
+ } = await this._reader.read();
271
+
267
272
  if (done) {
268
- return { value, done };
273
+ return {
274
+ value,
275
+ done
276
+ };
269
277
  }
278
+
270
279
  this._loaded += value.byteLength;
280
+
271
281
  if (this.onProgress) {
272
- this.onProgress({ loaded: this._loaded });
282
+ this.onProgress({
283
+ loaded: this._loaded
284
+ });
273
285
  }
286
+
274
287
  const buffer = new Uint8Array(value).buffer;
275
- return { value: buffer, done: false };
288
+ return {
289
+ value: buffer,
290
+ done: false
291
+ };
276
292
  }
277
293
 
278
294
  cancel(reason) {
279
295
  if (this._reader) {
280
296
  this._reader.cancel(reason);
281
297
  }
298
+
282
299
  if (this._abortController) {
283
300
  this._abortController.abort();
284
301
  }
285
302
  }
303
+
286
304
  }
287
305
 
288
306
  export { PDFFetchStream };