@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,4 +1,26 @@
1
- /* Copyright 2012 Mozilla Foundation
1
+ /* Copyright 2018 Mozilla Foundation
2
+ *
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS,
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+
16
+ /* globals process */
17
+ // NW.js / Electron is a browser context, but copies some Node.js objects; see
18
+ // http://docs.nwjs.io/en/latest/For%20Users/Advanced/JavaScript%20Contexts%20in%20NW.js/#access-nodejs-and-nwjs-api-in-browser-context
19
+ // https://www.electronjs.org/docs/api/process#processversionselectron-readonly
20
+ // https://www.electronjs.org/docs/api/process#processtype-readonly
21
+ const isNodeJS = typeof process === "object" && process + "" === "[object process]" && !process.versions.nw && !(process.versions.electron && process.type && process.type !== "browser");
22
+
23
+ /* Copyright 2017 Mozilla Foundation
2
24
  *
3
25
  * Licensed under the Apache License, Version 2.0 (the "License");
4
26
  * you may not use this file except in compliance with the License.
@@ -13,12 +35,125 @@
13
35
  * limitations under the License.
14
36
  */
15
37
 
16
- import "./compatibility.js";
38
+ if ((typeof PDFJSDev === "undefined" || !PDFJSDev.test("SKIP_BABEL")) && (typeof globalThis === "undefined" || !globalThis._pdfjsCompatibilityChecked)) {
39
+ // Provides support for globalThis in legacy browsers.
40
+ // Support: Firefox<65, Chrome<71, Safari<12.1
41
+ if (typeof globalThis === "undefined" || globalThis.Math !== Math) {
42
+ // eslint-disable-next-line no-global-assign
43
+ globalThis = require("core-js/es/global-this");
44
+ }
45
+
46
+ globalThis._pdfjsCompatibilityChecked = true; // Support: Node.js
47
+
48
+ (function checkNodeBtoa() {
49
+ if (globalThis.btoa || !isNodeJS) {
50
+ return;
51
+ }
52
+
53
+ globalThis.btoa = function (chars) {
54
+ // eslint-disable-next-line no-undef
55
+ return Buffer.from(chars, "binary").toString("base64");
56
+ };
57
+ })(); // Support: Node.js
58
+
59
+
60
+ (function checkNodeAtob() {
61
+ if (globalThis.atob || !isNodeJS) {
62
+ return;
63
+ }
64
+
65
+ globalThis.atob = function (input) {
66
+ // eslint-disable-next-line no-undef
67
+ return Buffer.from(input, "base64").toString("binary");
68
+ };
69
+ })(); // Support: Node.js
70
+
17
71
 
72
+ (function checkDOMMatrix() {
73
+ if (globalThis.DOMMatrix || !isNodeJS) {
74
+ return;
75
+ }
76
+
77
+ globalThis.DOMMatrix = require("dommatrix/dist/dommatrix.js");
78
+ })(); // Provides support for Object.fromEntries in legacy browsers.
79
+ // Support: Firefox<63, Chrome<73, Safari<12.1, Node.js<12.0.0
80
+
81
+
82
+ (function checkObjectFromEntries() {
83
+ if (Object.fromEntries) {
84
+ return;
85
+ }
86
+
87
+ require("core-js/es/object/from-entries.js");
88
+ })(); // Provides support for *recent* additions to the Promise specification,
89
+ // however basic Promise support is assumed to be available natively.
90
+ // Support: Firefox<71, Chrome<76, Safari<13, Node.js<12.9.0
91
+
92
+
93
+ (function checkPromise() {
94
+ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("IMAGE_DECODERS")) {
95
+ // The current image decoders are synchronous, hence `Promise` shouldn't
96
+ // need to be polyfilled for the IMAGE_DECODERS build target.
97
+ return;
98
+ }
99
+
100
+ if (globalThis.Promise.allSettled) {
101
+ return;
102
+ }
103
+
104
+ globalThis.Promise = require("core-js/es/promise/index.js");
105
+ })(); // Support: Node.js
106
+
107
+
108
+ (function checkReadableStream() {
109
+ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("IMAGE_DECODERS")) {
110
+ // The current image decoders are synchronous, hence `ReadableStream`
111
+ // shouldn't need to be polyfilled for the IMAGE_DECODERS build target.
112
+ return;
113
+ }
114
+
115
+ let isReadableStreamSupported = false;
116
+
117
+ if (typeof ReadableStream !== "undefined") {
118
+ // MS Edge may say it has ReadableStream but they are not up to spec yet.
119
+ try {
120
+ // eslint-disable-next-line no-new
121
+ new ReadableStream({
122
+ start(controller) {
123
+ controller.close();
124
+ }
125
+
126
+ });
127
+ isReadableStreamSupported = true;
128
+ } catch (e) {// The ReadableStream constructor cannot be used.
129
+ }
130
+ }
131
+
132
+ if (isReadableStreamSupported) {
133
+ return;
134
+ }
135
+
136
+ globalThis.ReadableStream = require("web-streams-polyfill/dist/ponyfill.js").ReadableStream;
137
+ })();
138
+ }
139
+
140
+ /* Copyright 2012 Mozilla Foundation
141
+ *
142
+ * Licensed under the Apache License, Version 2.0 (the "License");
143
+ * you may not use this file except in compliance with the License.
144
+ * You may obtain a copy of the License at
145
+ *
146
+ * http://www.apache.org/licenses/LICENSE-2.0
147
+ *
148
+ * Unless required by applicable law or agreed to in writing, software
149
+ * distributed under the License is distributed on an "AS IS" BASIS,
150
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
151
+ * See the License for the specific language governing permissions and
152
+ * limitations under the License.
153
+ */
18
154
  const IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
19
- const FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];
155
+ const FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0]; // Permission flags from Table 22, Section 7.6.3.2 of the PDF specification.
20
156
 
21
- // Permission flags from Table 22, Section 7.6.3.2 of the PDF specification.
22
157
  const PermissionFlag = {
23
158
  PRINT: 0x04,
24
159
  MODIFY_CONTENTS: 0x08,
@@ -27,9 +162,8 @@ const PermissionFlag = {
27
162
  FILL_INTERACTIVE_FORMS: 0x100,
28
163
  COPY_FOR_ACCESSIBILITY: 0x200,
29
164
  ASSEMBLE: 0x400,
30
- PRINT_HIGH_QUALITY: 0x800,
165
+ PRINT_HIGH_QUALITY: 0x800
31
166
  };
32
-
33
167
  const TextRenderingMode = {
34
168
  FILL: 0,
35
169
  STROKE: 1,
@@ -40,15 +174,13 @@ const TextRenderingMode = {
40
174
  FILL_STROKE_ADD_TO_PATH: 6,
41
175
  ADD_TO_PATH: 7,
42
176
  FILL_STROKE_MASK: 3,
43
- ADD_TO_PATH_FLAG: 4,
177
+ ADD_TO_PATH_FLAG: 4
44
178
  };
45
-
46
179
  const ImageKind = {
47
180
  GRAYSCALE_1BPP: 1,
48
181
  RGB_24BPP: 2,
49
- RGBA_32BPP: 3,
182
+ RGBA_32BPP: 3
50
183
  };
51
-
52
184
  const AnnotationType = {
53
185
  TEXT: 1,
54
186
  LINK: 2,
@@ -75,32 +207,12 @@ const AnnotationType = {
75
207
  TRAPNET: 23,
76
208
  WATERMARK: 24,
77
209
  THREED: 25,
78
- REDACT: 26,
210
+ REDACT: 26
79
211
  };
80
-
81
- const AnnotationStateModelType = {
82
- MARKED: "Marked",
83
- REVIEW: "Review",
84
- };
85
-
86
- const AnnotationMarkedState = {
87
- MARKED: "Marked",
88
- UNMARKED: "Unmarked",
89
- };
90
-
91
- const AnnotationReviewState = {
92
- ACCEPTED: "Accepted",
93
- REJECTED: "Rejected",
94
- CANCELLED: "Cancelled",
95
- COMPLETED: "Completed",
96
- NONE: "None",
97
- };
98
-
99
212
  const AnnotationReplyType = {
100
213
  GROUP: "Group",
101
- REPLY: "R",
214
+ REPLY: "R"
102
215
  };
103
-
104
216
  const AnnotationFlag = {
105
217
  INVISIBLE: 0x01,
106
218
  HIDDEN: 0x02,
@@ -111,9 +223,8 @@ const AnnotationFlag = {
111
223
  READONLY: 0x40,
112
224
  LOCKED: 0x80,
113
225
  TOGGLENOVIEW: 0x100,
114
- LOCKEDCONTENTS: 0x200,
226
+ LOCKEDCONTENTS: 0x200
115
227
  };
116
-
117
228
  const AnnotationFieldFlag = {
118
229
  READONLY: 0x0000001,
119
230
  REQUIRED: 0x0000002,
@@ -133,17 +244,15 @@ const AnnotationFieldFlag = {
133
244
  COMB: 0x1000000,
134
245
  RICHTEXT: 0x2000000,
135
246
  RADIOSINUNISON: 0x2000000,
136
- COMMITONSELCHANGE: 0x4000000,
247
+ COMMITONSELCHANGE: 0x4000000
137
248
  };
138
-
139
249
  const AnnotationBorderStyleType = {
140
250
  SOLID: 1,
141
251
  DASHED: 2,
142
252
  BEVELED: 3,
143
253
  INSET: 4,
144
- UNDERLINE: 5,
254
+ UNDERLINE: 5
145
255
  };
146
-
147
256
  const AnnotationActionEventType = {
148
257
  E: "Mouse Enter",
149
258
  X: "Mouse Exit",
@@ -158,22 +267,19 @@ const AnnotationActionEventType = {
158
267
  K: "Keystroke",
159
268
  F: "Format",
160
269
  V: "Validate",
161
- C: "Calculate",
270
+ C: "Calculate"
162
271
  };
163
-
164
272
  const DocumentActionEventType = {
165
273
  WC: "WillClose",
166
274
  WS: "WillSave",
167
275
  DS: "DidSave",
168
276
  WP: "WillPrint",
169
- DP: "DidPrint",
277
+ DP: "DidPrint"
170
278
  };
171
-
172
279
  const PageActionEventType = {
173
280
  O: "PageOpen",
174
- C: "PageClose",
281
+ C: "PageClose"
175
282
  };
176
-
177
283
  const StreamType = {
178
284
  UNKNOWN: "UNKNOWN",
179
285
  FLATE: "FLATE",
@@ -184,9 +290,9 @@ const StreamType = {
184
290
  A85: "A85",
185
291
  AHX: "AHX",
186
292
  CCF: "CCF",
187
- RLX: "RLX", // PDF short name is 'RL', but telemetry requires three chars.
188
- };
293
+ RLX: "RLX" // PDF short name is 'RL', but telemetry requires three chars.
189
294
 
295
+ };
190
296
  const FontType = {
191
297
  UNKNOWN: "UNKNOWN",
192
298
  TYPE1: "TYPE1",
@@ -199,22 +305,19 @@ const FontType = {
199
305
  TYPE3: "TYPE3",
200
306
  OPENTYPE: "OPENTYPE",
201
307
  TYPE0: "TYPE0",
202
- MMTYPE1: "MMTYPE1",
308
+ MMTYPE1: "MMTYPE1"
203
309
  };
204
-
205
310
  const VerbosityLevel = {
206
311
  ERRORS: 0,
207
312
  WARNINGS: 1,
208
- INFOS: 5,
313
+ INFOS: 5
209
314
  };
210
-
211
315
  const CMapCompressionType = {
212
316
  NONE: 0,
213
317
  BINARY: 1,
214
- STREAM: 2,
215
- };
318
+ STREAM: 2
319
+ }; // All the possible operations for an operator list.
216
320
 
217
- // All the possible operations for an operator list.
218
321
  const OPS = {
219
322
  // Intentionally start from 1 so it is easy to spot bad operators that will be
220
323
  // 0's.
@@ -308,9 +411,8 @@ const OPS = {
308
411
  paintImageXObjectRepeat: 88,
309
412
  paintImageMaskXObjectRepeat: 89,
310
413
  paintSolidColorImageMask: 90,
311
- constructPath: 91,
414
+ constructPath: 91
312
415
  };
313
-
314
416
  const UNSUPPORTED_FEATURES = {
315
417
  /** @deprecated unused */
316
418
  unknown: "unknown",
@@ -319,6 +421,7 @@ const UNSUPPORTED_FEATURES = {
319
421
  signatures: "signatures",
320
422
  smask: "smask",
321
423
  shadingPattern: "shadingPattern",
424
+
322
425
  /** @deprecated unused */
323
426
  font: "font",
324
427
  errorTilingPattern: "errorTilingPattern",
@@ -334,14 +437,12 @@ const UNSUPPORTED_FEATURES = {
334
437
  errorFontLoadNative: "errorFontLoadNative",
335
438
  errorFontBuildPath: "errorFontBuildPath",
336
439
  errorFontGetPath: "errorFontGetPath",
337
- errorMarkedContent: "errorMarkedContent",
440
+ errorMarkedContent: "errorMarkedContent"
338
441
  };
339
-
340
442
  const PasswordResponses = {
341
443
  NEED_PASSWORD: 1,
342
- INCORRECT_PASSWORD: 2,
444
+ INCORRECT_PASSWORD: 2
343
445
  };
344
-
345
446
  let verbosity = VerbosityLevel.WARNINGS;
346
447
 
347
448
  function setVerbosityLevel(level) {
@@ -352,18 +453,18 @@ function setVerbosityLevel(level) {
352
453
 
353
454
  function getVerbosityLevel() {
354
455
  return verbosity;
355
- }
356
-
357
- // A notice for devs. These are good for things that are helpful to devs, such
456
+ } // A notice for devs. These are good for things that are helpful to devs, such
358
457
  // as warning that Workers were disabled, which is important to devs but not
359
458
  // end users.
459
+
460
+
360
461
  function info(msg) {
361
462
  if (verbosity >= VerbosityLevel.INFOS) {
362
463
  console.log(`Info: ${msg}`);
363
464
  }
364
- }
465
+ } // Non-fatal warnings.
466
+
365
467
 
366
- // Non-fatal warnings.
367
468
  function warn(msg) {
368
469
  if (verbosity >= VerbosityLevel.WARNINGS) {
369
470
  console.log(`Warning: ${msg}`);
@@ -378,13 +479,15 @@ function assert(cond, msg) {
378
479
  if (!cond) {
379
480
  unreachable(msg);
380
481
  }
381
- }
482
+ } // Checks if URLs have the same origin. For non-HTTP based URLs, returns false.
483
+
382
484
 
383
- // Checks if URLs have the same origin. For non-HTTP based URLs, returns false.
384
485
  function isSameOrigin(baseUrl, otherUrl) {
385
486
  let base;
487
+
386
488
  try {
387
489
  base = new URL(baseUrl);
490
+
388
491
  if (!base.origin || base.origin === "null") {
389
492
  return false; // non-HTTP url
390
493
  }
@@ -394,13 +497,14 @@ function isSameOrigin(baseUrl, otherUrl) {
394
497
 
395
498
  const other = new URL(otherUrl, base);
396
499
  return base.origin === other.origin;
397
- }
500
+ } // Checks if URLs use one of the allowed protocols, e.g. to avoid XSS.
501
+
398
502
 
399
- // Checks if URLs use one of the allowed protocols, e.g. to avoid XSS.
400
503
  function _isValidProtocol(url) {
401
504
  if (!url) {
402
505
  return false;
403
506
  }
507
+
404
508
  switch (url.protocol) {
405
509
  case "http:":
406
510
  case "https:":
@@ -408,11 +512,11 @@ function _isValidProtocol(url) {
408
512
  case "mailto:":
409
513
  case "tel:":
410
514
  return true;
515
+
411
516
  default:
412
517
  return false;
413
518
  }
414
519
  }
415
-
416
520
  /**
417
521
  * Attempts to create a valid absolute URL.
418
522
  *
@@ -420,18 +524,23 @@ function _isValidProtocol(url) {
420
524
  * @param {URL|string} baseUrl - An absolute URL.
421
525
  * @returns Either a valid {URL}, or `null` otherwise.
422
526
  */
527
+
528
+
423
529
  function createValidAbsoluteUrl(url, baseUrl) {
424
530
  if (!url) {
425
531
  return null;
426
532
  }
533
+
427
534
  try {
428
535
  const absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url);
536
+
429
537
  if (_isValidProtocol(absoluteUrl)) {
430
538
  return absoluteUrl;
431
539
  }
432
540
  } catch (ex) {
433
541
  /* `new URL()` will throw on incorrect data. */
434
542
  }
543
+
435
544
  return null;
436
545
  }
437
546
 
@@ -440,34 +549,37 @@ function shadow(obj, prop, value) {
440
549
  value,
441
550
  enumerable: true,
442
551
  configurable: true,
443
- writable: false,
552
+ writable: false
444
553
  });
445
554
  return value;
446
555
  }
447
-
448
556
  /**
449
557
  * @type {any}
450
558
  */
451
- const BaseException = (function BaseExceptionClosure() {
559
+
560
+
561
+ const BaseException = function BaseExceptionClosure() {
452
562
  // eslint-disable-next-line no-shadow
453
563
  function BaseException(message) {
454
564
  if (this.constructor === BaseException) {
455
565
  unreachable("Cannot initialize BaseException.");
456
566
  }
567
+
457
568
  this.message = message;
458
569
  this.name = this.constructor.name;
459
570
  }
571
+
460
572
  BaseException.prototype = new Error();
461
573
  BaseException.constructor = BaseException;
462
-
463
574
  return BaseException;
464
- })();
575
+ }();
465
576
 
466
577
  class PasswordException extends BaseException {
467
578
  constructor(msg, code) {
468
579
  super(msg);
469
580
  this.code = code;
470
581
  }
582
+
471
583
  }
472
584
 
473
585
  class UnknownErrorException extends BaseException {
@@ -475,6 +587,7 @@ class UnknownErrorException extends BaseException {
475
587
  super(msg);
476
588
  this.details = details;
477
589
  }
590
+
478
591
  }
479
592
 
480
593
  class InvalidPDFException extends BaseException {}
@@ -486,47 +599,52 @@ class UnexpectedResponseException extends BaseException {
486
599
  super(msg);
487
600
  this.status = status;
488
601
  }
489
- }
490
602
 
603
+ }
491
604
  /**
492
605
  * Error caused during parsing PDF data.
493
606
  */
494
- class FormatError extends BaseException {}
495
607
 
608
+
609
+ class FormatError extends BaseException {}
496
610
  /**
497
611
  * Error used to indicate task cancellation.
498
612
  */
613
+
614
+
499
615
  class AbortException extends BaseException {}
500
616
 
501
617
  const NullCharactersRegExp = /\x00/g;
502
-
503
618
  /**
504
619
  * @param {string} str
505
620
  */
621
+
506
622
  function removeNullCharacters(str) {
507
623
  if (typeof str !== "string") {
508
624
  warn("The argument for removeNullCharacters must be a string.");
509
625
  return str;
510
626
  }
627
+
511
628
  return str.replace(NullCharactersRegExp, "");
512
629
  }
513
630
 
514
631
  function bytesToString(bytes) {
515
- assert(
516
- bytes !== null && typeof bytes === "object" && bytes.length !== undefined,
517
- "Invalid argument for bytesToString"
518
- );
632
+ assert(bytes !== null && typeof bytes === "object" && bytes.length !== undefined, "Invalid argument for bytesToString");
519
633
  const length = bytes.length;
520
634
  const MAX_ARGUMENT_COUNT = 8192;
635
+
521
636
  if (length < MAX_ARGUMENT_COUNT) {
522
637
  return String.fromCharCode.apply(null, bytes);
523
638
  }
639
+
524
640
  const strBuf = [];
641
+
525
642
  for (let i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
526
643
  const chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
527
644
  const chunk = bytes.subarray(i, chunkEnd);
528
645
  strBuf.push(String.fromCharCode.apply(null, chunk));
529
646
  }
647
+
530
648
  return strBuf.join("");
531
649
  }
532
650
 
@@ -534,45 +652,55 @@ function stringToBytes(str) {
534
652
  assert(typeof str === "string", "Invalid argument for stringToBytes");
535
653
  const length = str.length;
536
654
  const bytes = new Uint8Array(length);
655
+
537
656
  for (let i = 0; i < length; ++i) {
538
657
  bytes[i] = str.charCodeAt(i) & 0xff;
539
658
  }
659
+
540
660
  return bytes;
541
661
  }
542
-
543
662
  /**
544
663
  * Gets length of the array (Array, Uint8Array, or string) in bytes.
545
664
  * @param {Array<any>|Uint8Array|string} arr
546
665
  * @returns {number}
547
666
  */
667
+
668
+
548
669
  function arrayByteLength(arr) {
549
670
  if (arr.length !== undefined) {
550
671
  return arr.length;
551
672
  }
673
+
552
674
  assert(arr.byteLength !== undefined, "arrayByteLength - invalid argument.");
553
675
  return arr.byteLength;
554
676
  }
555
-
556
677
  /**
557
678
  * Combines array items (arrays) into single Uint8Array object.
558
679
  * @param {Array<Array<any>|Uint8Array|string>} arr - the array of the arrays
559
680
  * (Array, Uint8Array, or string).
560
681
  * @returns {Uint8Array}
561
682
  */
683
+
684
+
562
685
  function arraysToBytes(arr) {
563
- const length = arr.length;
564
- // Shortcut: if first and only item is Uint8Array, return it.
686
+ const length = arr.length; // Shortcut: if first and only item is Uint8Array, return it.
687
+
565
688
  if (length === 1 && arr[0] instanceof Uint8Array) {
566
689
  return arr[0];
567
690
  }
691
+
568
692
  let resultLength = 0;
693
+
569
694
  for (let i = 0; i < length; i++) {
570
695
  resultLength += arrayByteLength(arr[i]);
571
696
  }
697
+
572
698
  let pos = 0;
573
699
  const data = new Uint8Array(resultLength);
700
+
574
701
  for (let i = 0; i < length; i++) {
575
702
  let item = arr[i];
703
+
576
704
  if (!(item instanceof Uint8Array)) {
577
705
  if (typeof item === "string") {
578
706
  item = stringToBytes(item);
@@ -580,95 +708,83 @@ function arraysToBytes(arr) {
580
708
  item = new Uint8Array(item);
581
709
  }
582
710
  }
711
+
583
712
  const itemLength = item.byteLength;
584
713
  data.set(item, pos);
585
714
  pos += itemLength;
586
715
  }
716
+
587
717
  return data;
588
718
  }
589
719
 
590
720
  function string32(value) {
591
- if (
592
- typeof PDFJSDev === "undefined" ||
593
- PDFJSDev.test("!PRODUCTION || TESTING")
594
- ) {
595
- assert(
596
- typeof value === "number" && Math.abs(value) < 2 ** 32,
597
- `string32: Unexpected input "${value}".`
598
- );
721
+ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("!PRODUCTION || TESTING")) {
722
+ assert(typeof value === "number" && Math.abs(value) < 2 ** 32, `string32: Unexpected input "${value}".`);
599
723
  }
600
- return String.fromCharCode(
601
- (value >> 24) & 0xff,
602
- (value >> 16) & 0xff,
603
- (value >> 8) & 0xff,
604
- value & 0xff
605
- );
724
+
725
+ return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
606
726
  }
607
727
 
608
728
  function objectSize(obj) {
609
729
  return Object.keys(obj).length;
610
- }
611
-
612
- // Ensure that the returned Object has a `null` prototype; hence why
730
+ } // Ensure that the returned Object has a `null` prototype; hence why
613
731
  // `Object.fromEntries(...)` is not used.
732
+
733
+
614
734
  function objectFromMap(map) {
615
735
  const obj = Object.create(null);
736
+
616
737
  for (const [key, value] of map) {
617
738
  obj[key] = value;
618
739
  }
740
+
619
741
  return obj;
620
- }
742
+ } // Checks the endianness of the platform.
743
+
621
744
 
622
- // Checks the endianness of the platform.
623
745
  function isLittleEndian() {
624
746
  const buffer8 = new Uint8Array(4);
625
747
  buffer8[0] = 1;
626
748
  const view32 = new Uint32Array(buffer8.buffer, 0, 1);
627
749
  return view32[0] === 1;
628
750
  }
751
+
629
752
  const IsLittleEndianCached = {
630
753
  get value() {
631
754
  return shadow(this, "value", isLittleEndian());
632
- },
633
- };
755
+ }
756
+
757
+ }; // Checks if it's possible to eval JS expressions.
634
758
 
635
- // Checks if it's possible to eval JS expressions.
636
759
  function isEvalSupported() {
637
760
  try {
638
761
  new Function(""); // eslint-disable-line no-new, no-new-func
762
+
639
763
  return true;
640
764
  } catch (e) {
641
765
  return false;
642
766
  }
643
767
  }
768
+
644
769
  const IsEvalSupportedCached = {
645
770
  get value() {
646
771
  return shadow(this, "value", isEvalSupported());
647
- },
648
- };
772
+ }
649
773
 
650
- const hexNumbers = [...Array(256).keys()].map(n =>
651
- n.toString(16).padStart(2, "0")
652
- );
774
+ };
775
+ const hexNumbers = [...Array(256).keys()].map(n => n.toString(16).padStart(2, "0"));
653
776
 
654
777
  class Util {
655
778
  static makeHexColor(r, g, b) {
656
779
  return `#${hexNumbers[r]}${hexNumbers[g]}${hexNumbers[b]}`;
657
- }
780
+ } // Concatenates two transformation matrices together and returns the result.
781
+
658
782
 
659
- // Concatenates two transformation matrices together and returns the result.
660
783
  static transform(m1, m2) {
661
- return [
662
- m1[0] * m2[0] + m1[2] * m2[1],
663
- m1[1] * m2[0] + m1[3] * m2[1],
664
- m1[0] * m2[2] + m1[2] * m2[3],
665
- m1[1] * m2[2] + m1[3] * m2[3],
666
- m1[0] * m2[4] + m1[2] * m2[5] + m1[4],
667
- m1[1] * m2[4] + m1[3] * m2[5] + m1[5],
668
- ];
669
- }
784
+ return [m1[0] * m2[0] + m1[2] * m2[1], m1[1] * m2[0] + m1[3] * m2[1], m1[0] * m2[2] + m1[2] * m2[3], m1[1] * m2[2] + m1[3] * m2[3], m1[0] * m2[4] + m1[2] * m2[5] + m1[4], m1[1] * m2[4] + m1[3] * m2[5] + m1[5]];
785
+ } // For 2d affine transforms
786
+
670
787
 
671
- // For 2d affine transforms
672
788
  static applyTransform(p, m) {
673
789
  const xt = p[0] * m[0] + p[1] * m[2] + m[4];
674
790
  const yt = p[0] * m[1] + p[1] * m[3] + m[5];
@@ -680,121 +796,97 @@ class Util {
680
796
  const xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
681
797
  const yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
682
798
  return [xt, yt];
683
- }
684
-
685
- // Applies the transform to the rectangle and finds the minimum axially
799
+ } // Applies the transform to the rectangle and finds the minimum axially
686
800
  // aligned bounding box.
801
+
802
+
687
803
  static getAxialAlignedBoundingBox(r, m) {
688
804
  const p1 = Util.applyTransform(r, m);
689
805
  const p2 = Util.applyTransform(r.slice(2, 4), m);
690
806
  const p3 = Util.applyTransform([r[0], r[3]], m);
691
807
  const p4 = Util.applyTransform([r[2], r[1]], m);
692
- return [
693
- Math.min(p1[0], p2[0], p3[0], p4[0]),
694
- Math.min(p1[1], p2[1], p3[1], p4[1]),
695
- Math.max(p1[0], p2[0], p3[0], p4[0]),
696
- Math.max(p1[1], p2[1], p3[1], p4[1]),
697
- ];
808
+ return [Math.min(p1[0], p2[0], p3[0], p4[0]), Math.min(p1[1], p2[1], p3[1], p4[1]), Math.max(p1[0], p2[0], p3[0], p4[0]), Math.max(p1[1], p2[1], p3[1], p4[1])];
698
809
  }
699
810
 
700
811
  static inverseTransform(m) {
701
812
  const d = m[0] * m[3] - m[1] * m[2];
702
- return [
703
- m[3] / d,
704
- -m[1] / d,
705
- -m[2] / d,
706
- m[0] / d,
707
- (m[2] * m[5] - m[4] * m[3]) / d,
708
- (m[4] * m[1] - m[5] * m[0]) / d,
709
- ];
710
- }
711
-
712
- // Apply a generic 3d matrix M on a 3-vector v:
813
+ return [m[3] / d, -m[1] / d, -m[2] / d, m[0] / d, (m[2] * m[5] - m[4] * m[3]) / d, (m[4] * m[1] - m[5] * m[0]) / d];
814
+ } // Apply a generic 3d matrix M on a 3-vector v:
713
815
  // | a b c | | X |
714
816
  // | d e f | x | Y |
715
817
  // | g h i | | Z |
716
818
  // M is assumed to be serialized as [a,b,c,d,e,f,g,h,i],
717
819
  // with v as [X,Y,Z]
718
- static apply3dTransform(m, v) {
719
- return [
720
- m[0] * v[0] + m[1] * v[1] + m[2] * v[2],
721
- m[3] * v[0] + m[4] * v[1] + m[5] * v[2],
722
- m[6] * v[0] + m[7] * v[1] + m[8] * v[2],
723
- ];
724
- }
725
820
 
726
- // This calculation uses Singular Value Decomposition.
821
+
822
+ static apply3dTransform(m, v) {
823
+ return [m[0] * v[0] + m[1] * v[1] + m[2] * v[2], m[3] * v[0] + m[4] * v[1] + m[5] * v[2], m[6] * v[0] + m[7] * v[1] + m[8] * v[2]];
824
+ } // This calculation uses Singular Value Decomposition.
727
825
  // The SVD can be represented with formula A = USV. We are interested in the
728
826
  // matrix S here because it represents the scale values.
827
+
828
+
729
829
  static singularValueDecompose2dScale(m) {
730
- const transpose = [m[0], m[2], m[1], m[3]];
830
+ const transpose = [m[0], m[2], m[1], m[3]]; // Multiply matrix m with its transpose.
731
831
 
732
- // Multiply matrix m with its transpose.
733
832
  const a = m[0] * transpose[0] + m[1] * transpose[2];
734
833
  const b = m[0] * transpose[1] + m[1] * transpose[3];
735
834
  const c = m[2] * transpose[0] + m[3] * transpose[2];
736
- const d = m[2] * transpose[1] + m[3] * transpose[3];
835
+ const d = m[2] * transpose[1] + m[3] * transpose[3]; // Solve the second degree polynomial to get roots.
737
836
 
738
- // Solve the second degree polynomial to get roots.
739
837
  const first = (a + d) / 2;
740
838
  const second = Math.sqrt((a + d) ** 2 - 4 * (a * d - c * b)) / 2;
741
839
  const sx = first + second || 1;
742
- const sy = first - second || 1;
840
+ const sy = first - second || 1; // Scale values are the square roots of the eigenvalues.
743
841
 
744
- // Scale values are the square roots of the eigenvalues.
745
842
  return [Math.sqrt(sx), Math.sqrt(sy)];
746
- }
747
-
748
- // Normalize rectangle rect=[x1, y1, x2, y2] so that (x1,y1) < (x2,y2)
843
+ } // Normalize rectangle rect=[x1, y1, x2, y2] so that (x1,y1) < (x2,y2)
749
844
  // For coordinate systems whose origin lies in the bottom-left, this
750
845
  // means normalization to (BL,TR) ordering. For systems with origin in the
751
846
  // top-left, this means (TL,BR) ordering.
847
+
848
+
752
849
  static normalizeRect(rect) {
753
850
  const r = rect.slice(0); // clone rect
851
+
754
852
  if (rect[0] > rect[2]) {
755
853
  r[0] = rect[2];
756
854
  r[2] = rect[0];
757
855
  }
856
+
758
857
  if (rect[1] > rect[3]) {
759
858
  r[1] = rect[3];
760
859
  r[3] = rect[1];
761
860
  }
762
- return r;
763
- }
764
861
 
765
- // Returns a rectangle [x1, y1, x2, y2] corresponding to the
862
+ return r;
863
+ } // Returns a rectangle [x1, y1, x2, y2] corresponding to the
766
864
  // intersection of rect1 and rect2. If no intersection, returns 'false'
767
865
  // The rectangle coordinates of rect1, rect2 should be [x1, y1, x2, y2]
866
+
867
+
768
868
  static intersect(rect1, rect2) {
769
869
  function compare(a, b) {
770
870
  return a - b;
771
- }
871
+ } // Order points along the axes
872
+
772
873
 
773
- // Order points along the axes
774
874
  const orderedX = [rect1[0], rect1[2], rect2[0], rect2[2]].sort(compare);
775
875
  const orderedY = [rect1[1], rect1[3], rect2[1], rect2[3]].sort(compare);
776
876
  const result = [];
777
-
778
877
  rect1 = Util.normalizeRect(rect1);
779
- rect2 = Util.normalizeRect(rect2);
878
+ rect2 = Util.normalizeRect(rect2); // X: first and second points belong to different rectangles?
780
879
 
781
- // X: first and second points belong to different rectangles?
782
- if (
783
- (orderedX[0] === rect1[0] && orderedX[1] === rect2[0]) ||
784
- (orderedX[0] === rect2[0] && orderedX[1] === rect1[0])
785
- ) {
880
+ if (orderedX[0] === rect1[0] && orderedX[1] === rect2[0] || orderedX[0] === rect2[0] && orderedX[1] === rect1[0]) {
786
881
  // Intersection must be between second and third points
787
882
  result[0] = orderedX[1];
788
883
  result[2] = orderedX[2];
789
884
  } else {
790
885
  return null;
791
- }
886
+ } // Y: first and second points belong to different rectangles?
887
+
792
888
 
793
- // Y: first and second points belong to different rectangles?
794
- if (
795
- (orderedY[0] === rect1[1] && orderedY[1] === rect2[1]) ||
796
- (orderedY[0] === rect2[1] && orderedY[1] === rect1[1])
797
- ) {
889
+ if (orderedY[0] === rect1[1] && orderedY[1] === rect2[1] || orderedY[0] === rect2[1] && orderedY[1] === rect1[1]) {
798
890
  // Intersection must be between second and third points
799
891
  result[1] = orderedY[1];
800
892
  result[3] = orderedY[2];
@@ -804,36 +896,24 @@ class Util {
804
896
 
805
897
  return result;
806
898
  }
899
+
807
900
  }
808
901
 
809
- const PDFStringTranslateTable = [
810
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2d8,
811
- 0x2c7, 0x2c6, 0x2d9, 0x2dd, 0x2db, 0x2da, 0x2dc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
812
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
813
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
814
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
815
- 0, 0, 0, 0, 0, 0, 0, 0, 0x2022, 0x2020, 0x2021, 0x2026, 0x2014, 0x2013, 0x192,
816
- 0x2044, 0x2039, 0x203a, 0x2212, 0x2030, 0x201e, 0x201c, 0x201d, 0x2018,
817
- 0x2019, 0x201a, 0x2122, 0xfb01, 0xfb02, 0x141, 0x152, 0x160, 0x178, 0x17d,
818
- 0x131, 0x142, 0x153, 0x161, 0x17e, 0, 0x20ac,
819
- ];
902
+ const PDFStringTranslateTable = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2d8, 0x2c7, 0x2c6, 0x2d9, 0x2dd, 0x2db, 0x2da, 0x2dc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2022, 0x2020, 0x2021, 0x2026, 0x2014, 0x2013, 0x192, 0x2044, 0x2039, 0x203a, 0x2212, 0x2030, 0x201e, 0x201c, 0x201d, 0x2018, 0x2019, 0x201a, 0x2122, 0xfb01, 0xfb02, 0x141, 0x152, 0x160, 0x178, 0x17d, 0x131, 0x142, 0x153, 0x161, 0x17e, 0, 0x20ac];
820
903
 
821
904
  function stringToPDFString(str) {
822
905
  const length = str.length,
823
- strBuf = [];
906
+ strBuf = [];
907
+
824
908
  if (str[0] === "\xFE" && str[1] === "\xFF") {
825
909
  // UTF16BE BOM
826
910
  for (let i = 2; i < length; i += 2) {
827
- strBuf.push(
828
- String.fromCharCode((str.charCodeAt(i) << 8) | str.charCodeAt(i + 1))
829
- );
911
+ strBuf.push(String.fromCharCode(str.charCodeAt(i) << 8 | str.charCodeAt(i + 1)));
830
912
  }
831
913
  } else if (str[0] === "\xFF" && str[1] === "\xFE") {
832
914
  // UTF16LE BOM
833
915
  for (let i = 2; i < length; i += 2) {
834
- strBuf.push(
835
- String.fromCharCode((str.charCodeAt(i + 1) << 8) | str.charCodeAt(i))
836
- );
916
+ strBuf.push(String.fromCharCode(str.charCodeAt(i + 1) << 8 | str.charCodeAt(i)));
837
917
  }
838
918
  } else {
839
919
  for (let i = 0; i < length; ++i) {
@@ -841,6 +921,7 @@ function stringToPDFString(str) {
841
921
  strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
842
922
  }
843
923
  }
924
+
844
925
  return strBuf.join("");
845
926
  }
846
927
 
@@ -854,6 +935,7 @@ function escapeString(str) {
854
935
  } else if (match === "\r") {
855
936
  return "\\r";
856
937
  }
938
+
857
939
  return `\\${match}`;
858
940
  });
859
941
  }
@@ -864,13 +946,12 @@ function isAscii(str) {
864
946
 
865
947
  function stringToUTF16BEString(str) {
866
948
  const buf = ["\xFE\xFF"];
949
+
867
950
  for (let i = 0, ii = str.length; i < ii; i++) {
868
951
  const char = str.charCodeAt(i);
869
- buf.push(
870
- String.fromCharCode((char >> 8) & 0xff),
871
- String.fromCharCode(char & 0xff)
872
- );
952
+ buf.push(String.fromCharCode(char >> 8 & 0xff), String.fromCharCode(char & 0xff));
873
953
  }
954
+
874
955
  return buf.join("");
875
956
  }
876
957
 
@@ -902,27 +983,20 @@ function isArrayEqual(arr1, arr2) {
902
983
  if (arr1.length !== arr2.length) {
903
984
  return false;
904
985
  }
986
+
905
987
  for (let i = 0, ii = arr1.length; i < ii; i++) {
906
988
  if (arr1[i] !== arr2[i]) {
907
989
  return false;
908
990
  }
909
991
  }
992
+
910
993
  return true;
911
994
  }
912
995
 
913
996
  function getModificationDate(date = new Date()) {
914
- const buffer = [
915
- date.getUTCFullYear().toString(),
916
- (date.getUTCMonth() + 1).toString().padStart(2, "0"),
917
- date.getUTCDate().toString().padStart(2, "0"),
918
- date.getUTCHours().toString().padStart(2, "0"),
919
- date.getUTCMinutes().toString().padStart(2, "0"),
920
- date.getUTCSeconds().toString().padStart(2, "0"),
921
- ];
922
-
997
+ const buffer = [date.getUTCFullYear().toString(), (date.getUTCMonth() + 1).toString().padStart(2, "0"), date.getUTCDate().toString().padStart(2, "0"), date.getUTCHours().toString().padStart(2, "0"), date.getUTCMinutes().toString().padStart(2, "0"), date.getUTCSeconds().toString().padStart(2, "0")];
923
998
  return buffer.join("");
924
999
  }
925
-
926
1000
  /**
927
1001
  * Promise Capability object.
928
1002
  *
@@ -939,20 +1013,23 @@ function getModificationDate(date = new Date()) {
939
1013
  *
940
1014
  * @returns {PromiseCapability}
941
1015
  */
1016
+
1017
+
942
1018
  function createPromiseCapability() {
943
1019
  const capability = Object.create(null);
944
1020
  let isSettled = false;
945
-
946
1021
  Object.defineProperty(capability, "settled", {
947
1022
  get() {
948
1023
  return isSettled;
949
- },
1024
+ }
1025
+
950
1026
  });
951
1027
  capability.promise = new Promise(function (resolve, reject) {
952
1028
  capability.resolve = function (data) {
953
1029
  isSettled = true;
954
1030
  resolve(data);
955
1031
  };
1032
+
956
1033
  capability.reject = function (reason) {
957
1034
  isSettled = true;
958
1035
  reject(reason);
@@ -963,90 +1040,27 @@ function createPromiseCapability() {
963
1040
 
964
1041
  function createObjectURL(data, contentType = "", forceDataSchema = false) {
965
1042
  if (URL.createObjectURL && !forceDataSchema) {
966
- return URL.createObjectURL(new Blob([data], { type: contentType }));
967
- }
968
- // Blob/createObjectURL is not available, falling back to data schema.
969
- const digits =
970
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
1043
+ return URL.createObjectURL(new Blob([data], {
1044
+ type: contentType
1045
+ }));
1046
+ } // Blob/createObjectURL is not available, falling back to data schema.
1047
+
971
1048
 
1049
+ const digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
972
1050
  let buffer = `data:${contentType};base64,`;
1051
+
973
1052
  for (let i = 0, ii = data.length; i < ii; i += 3) {
974
1053
  const b1 = data[i] & 0xff;
975
1054
  const b2 = data[i + 1] & 0xff;
976
1055
  const b3 = data[i + 2] & 0xff;
977
1056
  const d1 = b1 >> 2,
978
- d2 = ((b1 & 3) << 4) | (b2 >> 4);
979
- const d3 = i + 1 < ii ? ((b2 & 0xf) << 2) | (b3 >> 6) : 64;
1057
+ d2 = (b1 & 3) << 4 | b2 >> 4;
1058
+ const d3 = i + 1 < ii ? (b2 & 0xf) << 2 | b3 >> 6 : 64;
980
1059
  const d4 = i + 2 < ii ? b3 & 0x3f : 64;
981
1060
  buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
982
1061
  }
1062
+
983
1063
  return buffer;
984
1064
  }
985
1065
 
986
- export {
987
- AbortException,
988
- AnnotationActionEventType,
989
- AnnotationBorderStyleType,
990
- AnnotationFieldFlag,
991
- AnnotationFlag,
992
- AnnotationMarkedState,
993
- AnnotationReplyType,
994
- AnnotationReviewState,
995
- AnnotationStateModelType,
996
- AnnotationType,
997
- arrayByteLength,
998
- arraysToBytes,
999
- assert,
1000
- BaseException,
1001
- bytesToString,
1002
- CMapCompressionType,
1003
- createObjectURL,
1004
- createPromiseCapability,
1005
- createValidAbsoluteUrl,
1006
- DocumentActionEventType,
1007
- escapeString,
1008
- FONT_IDENTITY_MATRIX,
1009
- FontType,
1010
- FormatError,
1011
- getModificationDate,
1012
- getVerbosityLevel,
1013
- IDENTITY_MATRIX,
1014
- ImageKind,
1015
- info,
1016
- InvalidPDFException,
1017
- isArrayBuffer,
1018
- isArrayEqual,
1019
- isAscii,
1020
- isBool,
1021
- IsEvalSupportedCached,
1022
- IsLittleEndianCached,
1023
- isNum,
1024
- isSameOrigin,
1025
- isString,
1026
- MissingPDFException,
1027
- objectFromMap,
1028
- objectSize,
1029
- OPS,
1030
- PageActionEventType,
1031
- PasswordException,
1032
- PasswordResponses,
1033
- PermissionFlag,
1034
- removeNullCharacters,
1035
- setVerbosityLevel,
1036
- shadow,
1037
- StreamType,
1038
- string32,
1039
- stringToBytes,
1040
- stringToPDFString,
1041
- stringToUTF16BEString,
1042
- stringToUTF8String,
1043
- TextRenderingMode,
1044
- UnexpectedResponseException,
1045
- UnknownErrorException,
1046
- unreachable,
1047
- UNSUPPORTED_FEATURES,
1048
- utf8StringToString,
1049
- Util,
1050
- VerbosityLevel,
1051
- warn,
1052
- };
1066
+ export { utf8StringToString as $, AbortException as A, stringToPDFString as B, createObjectURL as C, CMapCompressionType as D, createValidAbsoluteUrl as E, FormatError as F, PasswordResponses as G, PermissionFlag as H, IsEvalSupportedCached as I, removeNullCharacters as J, BaseException as K, isString as L, MissingPDFException as M, objectSize as N, OPS as O, PasswordException as P, arrayByteLength as Q, arraysToBytes as R, StreamType as S, TextRenderingMode as T, UNSUPPORTED_FEATURES as U, VerbosityLevel as V, FontType as W, isBool as X, isArrayEqual as Y, stringToUTF8String as Z, DocumentActionEventType as _, string32 as a, escapeString as a0, AnnotationFlag as a1, AnnotationFieldFlag as a2, isAscii as a3, stringToUTF16BEString as a4, getModificationDate as a5, AnnotationReplyType as a6, AnnotationActionEventType as a7, PageActionEventType as a8, bytesToString as b, assert as c, info as d, Util as e, IDENTITY_MATRIX as f, FONT_IDENTITY_MATRIX as g, isNum as h, isNodeJS as i, ImageKind as j, IsLittleEndianCached as k, createPromiseCapability as l, isArrayBuffer as m, stringToBytes as n, objectFromMap as o, setVerbosityLevel as p, getVerbosityLevel as q, isSameOrigin as r, shadow as s, UnknownErrorException as t, unreachable as u, UnexpectedResponseException as v, warn as w, InvalidPDFException as x, AnnotationType as y, AnnotationBorderStyleType as z };