pdfjs-dist 2.3.200 → 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.

Files changed (185) hide show
  1. package/README.md +4 -0
  2. package/bower.json +1 -1
  3. package/build/pdf.js +6499 -17971
  4. package/build/pdf.js.map +1 -1
  5. package/build/pdf.min.js +22 -1
  6. package/build/pdf.worker.entry.js +5 -3
  7. package/build/pdf.worker.js +19303 -29896
  8. package/build/pdf.worker.js.map +1 -1
  9. package/build/pdf.worker.min.js +22 -1
  10. package/es5/build/pdf.js +25473 -0
  11. package/es5/build/pdf.js.map +1 -0
  12. package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
  13. package/es5/build/pdf.worker.js +57878 -0
  14. package/es5/build/pdf.worker.js.map +1 -0
  15. package/es5/web/images/annotation-check.svg +11 -0
  16. package/es5/web/images/annotation-comment.svg +16 -0
  17. package/es5/web/images/annotation-help.svg +26 -0
  18. package/es5/web/images/annotation-insert.svg +10 -0
  19. package/es5/web/images/annotation-key.svg +11 -0
  20. package/es5/web/images/annotation-newparagraph.svg +11 -0
  21. package/es5/web/images/annotation-noicon.svg +7 -0
  22. package/es5/web/images/annotation-note.svg +42 -0
  23. package/es5/web/images/annotation-paragraph.svg +16 -0
  24. package/es5/web/images/loading-icon.gif +0 -0
  25. package/es5/web/images/shadow.png +0 -0
  26. package/es5/web/images/texture.png +0 -0
  27. package/es5/web/pdf_viewer.css +407 -0
  28. package/es5/web/pdf_viewer.js +7757 -0
  29. package/es5/web/pdf_viewer.js.map +1 -0
  30. package/image_decoders/pdf.image_decoders.js +1333 -4839
  31. package/image_decoders/pdf.image_decoders.js.map +1 -1
  32. package/image_decoders/pdf.image_decoders.min.js +22 -1
  33. package/lib/README.md +7 -0
  34. package/lib/core/annotation.js +683 -1066
  35. package/lib/core/arithmetic_decoder.js +81 -97
  36. package/lib/core/bidi.js +54 -46
  37. package/lib/core/ccitt.js +88 -81
  38. package/lib/core/ccitt_stream.js +15 -14
  39. package/lib/core/cff_parser.js +196 -193
  40. package/lib/core/charsets.js +4 -4
  41. package/lib/core/chunked_stream.js +441 -569
  42. package/lib/core/cmap.js +220 -279
  43. package/lib/core/colorspace.js +699 -863
  44. package/lib/core/core_utils.js +59 -80
  45. package/lib/core/crypto.js +379 -437
  46. package/lib/core/document.js +564 -673
  47. package/lib/core/encodings.js +15 -15
  48. package/lib/core/evaluator.js +983 -889
  49. package/lib/core/font_renderer.js +128 -171
  50. package/lib/core/fonts.js +451 -400
  51. package/lib/core/function.js +289 -285
  52. package/lib/core/glyphlist.js +4527 -4527
  53. package/lib/core/image.js +138 -117
  54. package/lib/core/image_utils.js +46 -63
  55. package/lib/core/jbig2.js +324 -332
  56. package/lib/core/jbig2_stream.js +18 -17
  57. package/lib/core/jpeg_stream.js +133 -24
  58. package/lib/core/jpg.js +238 -210
  59. package/lib/core/jpx.js +158 -157
  60. package/lib/core/jpx_stream.js +28 -28
  61. package/lib/core/metrics.js +2928 -2928
  62. package/lib/core/murmurhash3.js +87 -102
  63. package/lib/core/obj.js +1111 -1302
  64. package/lib/core/operator_list.js +55 -42
  65. package/lib/core/parser.js +956 -987
  66. package/lib/core/pattern.js +69 -69
  67. package/lib/core/pdf_manager.js +149 -316
  68. package/lib/core/primitives.js +45 -77
  69. package/lib/core/ps_parser.js +175 -214
  70. package/lib/core/standard_fonts.js +237 -236
  71. package/lib/core/stream.js +83 -77
  72. package/lib/core/type1_parser.js +78 -68
  73. package/lib/core/unicode.js +1654 -1654
  74. package/lib/core/worker.js +148 -196
  75. package/lib/core/worker_stream.js +101 -210
  76. package/lib/display/annotation_layer.js +733 -1155
  77. package/lib/display/api.js +1539 -1928
  78. package/lib/display/api_compatibility.js +10 -8
  79. package/lib/display/canvas.js +159 -158
  80. package/lib/display/content_disposition.js +36 -55
  81. package/lib/display/display_utils.js +298 -551
  82. package/lib/display/fetch_stream.js +181 -305
  83. package/lib/display/font_loader.js +273 -416
  84. package/lib/display/metadata.js +86 -98
  85. package/lib/display/network.js +376 -511
  86. package/lib/display/network_utils.js +20 -19
  87. package/lib/display/node_stream.js +276 -460
  88. package/lib/display/pattern_helper.js +76 -44
  89. package/lib/display/svg.js +1137 -1405
  90. package/lib/display/text_layer.js +75 -82
  91. package/lib/display/transport_stream.js +236 -374
  92. package/lib/display/webgl.js +70 -83
  93. package/lib/display/worker_options.js +3 -3
  94. package/lib/display/xml_parser.js +303 -392
  95. package/lib/examples/node/domstubs.js +37 -37
  96. package/lib/pdf.js +22 -21
  97. package/lib/pdf.worker.js +5 -5
  98. package/lib/shared/compatibility.js +2 -251
  99. package/lib/shared/is_node.js +7 -6
  100. package/lib/shared/message_handler.js +222 -194
  101. package/lib/shared/util.js +269 -405
  102. package/lib/test/unit/annotation_spec.js +1089 -1014
  103. package/lib/test/unit/api_spec.js +617 -544
  104. package/lib/test/unit/bidi_spec.js +7 -7
  105. package/lib/test/unit/cff_parser_spec.js +63 -62
  106. package/lib/test/unit/clitests_helper.js +7 -9
  107. package/lib/test/unit/cmap_spec.js +84 -86
  108. package/lib/test/unit/colorspace_spec.js +154 -154
  109. package/lib/test/unit/core_utils_spec.js +125 -105
  110. package/lib/test/unit/crypto_spec.js +181 -181
  111. package/lib/test/unit/custom_spec.js +22 -24
  112. package/lib/test/unit/display_svg_spec.js +35 -36
  113. package/lib/test/unit/display_utils_spec.js +139 -149
  114. package/lib/test/unit/document_spec.js +16 -16
  115. package/lib/test/unit/encodings_spec.js +12 -34
  116. package/lib/test/unit/evaluator_spec.js +81 -95
  117. package/lib/test/unit/fetch_stream_spec.js +30 -30
  118. package/lib/test/unit/function_spec.js +206 -204
  119. package/lib/test/unit/jasmine-boot.js +48 -32
  120. package/lib/test/unit/message_handler_spec.js +172 -162
  121. package/lib/test/unit/metadata_spec.js +69 -69
  122. package/lib/test/unit/murmurhash3_spec.js +12 -12
  123. package/lib/test/unit/network_spec.js +12 -12
  124. package/lib/test/unit/network_utils_spec.js +152 -152
  125. package/lib/test/unit/node_stream_spec.js +74 -90
  126. package/lib/test/unit/parser_spec.js +107 -113
  127. package/lib/test/unit/pdf_find_controller_spec.js +55 -86
  128. package/lib/test/unit/pdf_find_utils_spec.js +32 -32
  129. package/lib/test/unit/pdf_history_spec.js +32 -32
  130. package/lib/test/unit/primitives_spec.js +117 -115
  131. package/lib/test/unit/stream_spec.js +16 -14
  132. package/lib/test/unit/test_utils.js +119 -285
  133. package/lib/test/unit/testreporter.js +19 -19
  134. package/lib/test/unit/type1_parser_spec.js +41 -41
  135. package/lib/test/unit/ui_utils_spec.js +318 -426
  136. package/lib/test/unit/unicode_spec.js +42 -42
  137. package/lib/test/unit/util_spec.js +122 -143
  138. package/lib/web/annotation_layer_builder.js +66 -103
  139. package/lib/web/app.js +1166 -1196
  140. package/lib/web/app_options.js +61 -77
  141. package/lib/web/base_viewer.js +804 -850
  142. package/lib/web/chromecom.js +164 -249
  143. package/lib/web/debugger.js +149 -205
  144. package/lib/web/download_manager.js +38 -57
  145. package/lib/web/firefox_print_service.js +35 -30
  146. package/lib/web/firefoxcom.js +175 -374
  147. package/lib/web/genericcom.js +26 -108
  148. package/lib/web/genericl10n.js +24 -153
  149. package/lib/web/grab_to_pan.js +30 -30
  150. package/lib/web/interfaces.js +80 -258
  151. package/lib/web/overlay_manager.js +70 -246
  152. package/lib/web/password_prompt.js +38 -64
  153. package/lib/web/pdf_attachment_viewer.js +105 -130
  154. package/lib/web/pdf_cursor_tools.js +75 -102
  155. package/lib/web/pdf_document_properties.js +227 -376
  156. package/lib/web/pdf_find_bar.js +137 -171
  157. package/lib/web/pdf_find_controller.js +492 -549
  158. package/lib/web/pdf_find_utils.js +13 -13
  159. package/lib/web/pdf_history.js +395 -406
  160. package/lib/web/pdf_link_service.js +302 -349
  161. package/lib/web/pdf_outline_viewer.js +148 -209
  162. package/lib/web/pdf_page_view.js +449 -507
  163. package/lib/web/pdf_presentation_mode.js +304 -357
  164. package/lib/web/pdf_print_service.js +90 -104
  165. package/lib/web/pdf_rendering_queue.js +87 -108
  166. package/lib/web/pdf_sidebar.js +264 -304
  167. package/lib/web/pdf_sidebar_resizer.js +92 -119
  168. package/lib/web/pdf_single_page_viewer.js +77 -126
  169. package/lib/web/pdf_thumbnail_view.js +276 -297
  170. package/lib/web/pdf_thumbnail_viewer.js +186 -206
  171. package/lib/web/pdf_viewer.component.js +20 -21
  172. package/lib/web/pdf_viewer.js +55 -115
  173. package/lib/web/preferences.js +66 -273
  174. package/lib/web/secondary_toolbar.js +164 -196
  175. package/lib/web/text_layer_builder.js +284 -317
  176. package/lib/web/toolbar.js +216 -211
  177. package/lib/web/ui_utils.js +303 -404
  178. package/lib/web/view_history.js +49 -222
  179. package/lib/web/viewer_compatibility.js +7 -5
  180. package/package.json +2 -9
  181. package/web/pdf_viewer.css +25 -18
  182. package/web/pdf_viewer.js +3481 -4764
  183. package/web/pdf_viewer.js.map +1 -1
  184. package/webpack.js +14 -5
  185. package/lib/shared/streams_polyfill.js +0 -43
package/lib/web/app.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * @licstart The following is the entire license notice for the
3
3
  * Javascript code in this page
4
4
  *
5
- * Copyright 2019 Mozilla Foundation
5
+ * Copyright 2020 Mozilla Foundation
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -26,102 +26,108 @@ Object.defineProperty(exports, "__esModule", {
26
26
  });
27
27
  exports.PDFPrintServiceFactory = exports.DefaultExternalServices = exports.PDFViewerApplication = void 0;
28
28
 
29
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
29
+ var _ui_utils = require("./ui_utils.js");
30
30
 
31
- var _ui_utils = require("./ui_utils");
32
-
33
- var _app_options = require("./app_options");
31
+ var _app_options = require("./app_options.js");
34
32
 
35
33
  var _pdf = require("../pdf");
36
34
 
37
- var _pdf_cursor_tools = require("./pdf_cursor_tools");
35
+ var _pdf_cursor_tools = require("./pdf_cursor_tools.js");
38
36
 
39
- var _pdf_rendering_queue = require("./pdf_rendering_queue");
37
+ var _pdf_rendering_queue = require("./pdf_rendering_queue.js");
40
38
 
41
- var _pdf_sidebar = require("./pdf_sidebar");
39
+ var _pdf_sidebar = require("./pdf_sidebar.js");
42
40
 
43
- var _overlay_manager = require("./overlay_manager");
41
+ var _overlay_manager = require("./overlay_manager.js");
44
42
 
45
- var _password_prompt = require("./password_prompt");
43
+ var _password_prompt = require("./password_prompt.js");
46
44
 
47
- var _pdf_attachment_viewer = require("./pdf_attachment_viewer");
45
+ var _pdf_attachment_viewer = require("./pdf_attachment_viewer.js");
48
46
 
49
- var _pdf_document_properties = require("./pdf_document_properties");
47
+ var _pdf_document_properties = require("./pdf_document_properties.js");
50
48
 
51
- var _pdf_find_bar = require("./pdf_find_bar");
49
+ var _pdf_find_bar = require("./pdf_find_bar.js");
52
50
 
53
- var _pdf_find_controller = require("./pdf_find_controller");
51
+ var _pdf_find_controller = require("./pdf_find_controller.js");
54
52
 
55
- var _pdf_history = require("./pdf_history");
53
+ var _pdf_history = require("./pdf_history.js");
56
54
 
57
- var _pdf_link_service = require("./pdf_link_service");
55
+ var _pdf_link_service = require("./pdf_link_service.js");
58
56
 
59
- var _pdf_outline_viewer = require("./pdf_outline_viewer");
57
+ var _pdf_outline_viewer = require("./pdf_outline_viewer.js");
60
58
 
61
- var _pdf_presentation_mode = require("./pdf_presentation_mode");
59
+ var _pdf_presentation_mode = require("./pdf_presentation_mode.js");
62
60
 
63
- var _pdf_sidebar_resizer = require("./pdf_sidebar_resizer");
61
+ var _pdf_sidebar_resizer = require("./pdf_sidebar_resizer.js");
64
62
 
65
- var _pdf_thumbnail_viewer = require("./pdf_thumbnail_viewer");
63
+ var _pdf_thumbnail_viewer = require("./pdf_thumbnail_viewer.js");
66
64
 
67
- var _pdf_viewer = require("./pdf_viewer");
65
+ var _pdf_viewer = require("./pdf_viewer.js");
68
66
 
69
- var _secondary_toolbar = require("./secondary_toolbar");
67
+ var _secondary_toolbar = require("./secondary_toolbar.js");
70
68
 
71
- var _toolbar = require("./toolbar");
69
+ var _toolbar = require("./toolbar.js");
72
70
 
73
- var _view_history = require("./view_history");
71
+ var _view_history = require("./view_history.js");
74
72
 
75
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
73
+ const DEFAULT_SCALE_DELTA = 1.1;
74
+ const DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
75
+ const FORCE_PAGES_LOADED_TIMEOUT = 10000;
76
+ const WHEEL_ZOOM_DISABLED_TIMEOUT = 1000;
77
+ const ViewOnLoad = {
78
+ UNKNOWN: -1,
79
+ PREVIOUS: 0,
80
+ INITIAL: 1
81
+ };
76
82
 
77
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
83
+ class DefaultExternalServices {
84
+ constructor() {
85
+ throw new Error("Cannot initialize DefaultExternalServices.");
86
+ }
78
87
 
79
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
88
+ static updateFindControlState(data) {}
80
89
 
81
- function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
90
+ static updateFindMatchesCount(data) {}
82
91
 
83
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
92
+ static initPassiveLoading(callbacks) {}
84
93
 
85
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
94
+ static fallback(data, callback) {}
86
95
 
87
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
96
+ static reportTelemetry(data) {}
88
97
 
89
- var DEFAULT_SCALE_DELTA = 1.1;
90
- var DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
91
- var FORCE_PAGES_LOADED_TIMEOUT = 10000;
92
- var WHEEL_ZOOM_DISABLED_TIMEOUT = 1000;
93
- var ViewOnLoad = {
94
- UNKNOWN: -1,
95
- PREVIOUS: 0,
96
- INITIAL: 1
97
- };
98
- var DefaultExternalServices = {
99
- updateFindControlState: function updateFindControlState(data) {},
100
- updateFindMatchesCount: function updateFindMatchesCount(data) {},
101
- initPassiveLoading: function initPassiveLoading(callbacks) {},
102
- fallback: function fallback(data, callback) {},
103
- reportTelemetry: function reportTelemetry(data) {},
104
- createDownloadManager: function createDownloadManager(options) {
105
- throw new Error('Not implemented: createDownloadManager');
106
- },
107
- createPreferences: function createPreferences() {
108
- throw new Error('Not implemented: createPreferences');
109
- },
110
- createL10n: function createL10n(options) {
111
- throw new Error('Not implemented: createL10n');
112
- },
113
- supportsIntegratedFind: false,
114
- supportsDocumentFonts: true,
115
- supportsDocumentColors: true,
116
- supportedMouseWheelZoomModifierKeys: {
117
- ctrlKey: true,
118
- metaKey: true
98
+ static createDownloadManager(options) {
99
+ throw new Error("Not implemented: createDownloadManager");
119
100
  }
120
- };
101
+
102
+ static createPreferences() {
103
+ throw new Error("Not implemented: createPreferences");
104
+ }
105
+
106
+ static createL10n(options) {
107
+ throw new Error("Not implemented: createL10n");
108
+ }
109
+
110
+ static get supportsIntegratedFind() {
111
+ return (0, _pdf.shadow)(this, "supportsIntegratedFind", false);
112
+ }
113
+
114
+ static get supportsDocumentFonts() {
115
+ return (0, _pdf.shadow)(this, "supportsDocumentFonts", true);
116
+ }
117
+
118
+ static get supportedMouseWheelZoomModifierKeys() {
119
+ return (0, _pdf.shadow)(this, "supportedMouseWheelZoomModifierKeys", {
120
+ ctrlKey: true,
121
+ metaKey: true
122
+ });
123
+ }
124
+
125
+ }
126
+
121
127
  exports.DefaultExternalServices = DefaultExternalServices;
122
- var PDFViewerApplication = {
128
+ const PDFViewerApplication = {
123
129
  initialBookmark: document.location.hash.substring(1),
124
- initialized: false,
130
+ _initializedCapability: (0, _pdf.createPromiseCapability)(),
125
131
  fellback: false,
126
132
  appConfig: null,
127
133
  pdfDocument: null,
@@ -150,390 +156,261 @@ var PDFViewerApplication = {
150
156
  isInitialViewSet: false,
151
157
  downloadComplete: false,
152
158
  isViewerEmbedded: window.parent !== window,
153
- url: '',
154
- baseUrl: '',
159
+ url: "",
160
+ baseUrl: "",
155
161
  externalServices: DefaultExternalServices,
156
162
  _boundEvents: {},
157
163
  contentDispositionFilename: null,
158
- initialize: function () {
159
- var _initialize = _asyncToGenerator(
160
- /*#__PURE__*/
161
- _regenerator["default"].mark(function _callee(appConfig) {
162
- var _this = this;
163
-
164
- var appContainer;
165
- return _regenerator["default"].wrap(function _callee$(_context) {
166
- while (1) {
167
- switch (_context.prev = _context.next) {
168
- case 0:
169
- this.preferences = this.externalServices.createPreferences();
170
- this.appConfig = appConfig;
171
- _context.next = 4;
172
- return this._readPreferences();
173
-
174
- case 4:
175
- _context.next = 6;
176
- return this._parseHashParameters();
177
-
178
- case 6:
179
- _context.next = 8;
180
- return this._initializeL10n();
181
-
182
- case 8:
183
- if (this.isViewerEmbedded && _app_options.AppOptions.get('externalLinkTarget') === _pdf.LinkTarget.NONE) {
184
- _app_options.AppOptions.set('externalLinkTarget', _pdf.LinkTarget.TOP);
185
- }
186
-
187
- _context.next = 11;
188
- return this._initializeViewerComponents();
189
-
190
- case 11:
191
- this.bindEvents();
192
- this.bindWindowEvents();
193
- appContainer = appConfig.appContainer || document.documentElement;
194
- this.l10n.translate(appContainer).then(function () {
195
- _this.eventBus.dispatch('localized', {
196
- source: _this
197
- });
198
- });
199
- this.initialized = true;
200
-
201
- case 16:
202
- case "end":
203
- return _context.stop();
204
- }
205
- }
206
- }, _callee, this);
207
- }));
208
-
209
- function initialize(_x) {
210
- return _initialize.apply(this, arguments);
211
- }
212
-
213
- return initialize;
214
- }(),
215
- _readPreferences: function () {
216
- var _readPreferences2 = _asyncToGenerator(
217
- /*#__PURE__*/
218
- _regenerator["default"].mark(function _callee2() {
219
- var prefs, name;
220
- return _regenerator["default"].wrap(function _callee2$(_context2) {
221
- while (1) {
222
- switch (_context2.prev = _context2.next) {
223
- case 0:
224
- if (!(_app_options.AppOptions.get('disablePreferences') === true)) {
225
- _context2.next = 2;
226
- break;
227
- }
228
-
229
- return _context2.abrupt("return");
230
-
231
- case 2:
232
- _context2.prev = 2;
233
- _context2.next = 5;
234
- return this.preferences.getAll();
235
-
236
- case 5:
237
- prefs = _context2.sent;
238
-
239
- for (name in prefs) {
240
- _app_options.AppOptions.set(name, prefs[name]);
241
- }
242
-
243
- _context2.next = 12;
244
- break;
245
164
 
246
- case 9:
247
- _context2.prev = 9;
248
- _context2.t0 = _context2["catch"](2);
249
- console.error("_readPreferences: \"".concat(_context2.t0.message, "\"."));
165
+ async initialize(appConfig) {
166
+ this.preferences = this.externalServices.createPreferences();
167
+ this.appConfig = appConfig;
168
+ await this._readPreferences();
169
+ await this._parseHashParameters();
170
+ await this._initializeL10n();
250
171
 
251
- case 12:
252
- case "end":
253
- return _context2.stop();
254
- }
255
- }
256
- }, _callee2, this, [[2, 9]]);
257
- }));
258
-
259
- function _readPreferences() {
260
- return _readPreferences2.apply(this, arguments);
261
- }
262
-
263
- return _readPreferences;
264
- }(),
265
- _parseHashParameters: function () {
266
- var _parseHashParameters2 = _asyncToGenerator(
267
- /*#__PURE__*/
268
- _regenerator["default"].mark(function _callee3() {
269
- var waitOn, hash, hashParams, viewer, enabled;
270
- return _regenerator["default"].wrap(function _callee3$(_context3) {
271
- while (1) {
272
- switch (_context3.prev = _context3.next) {
273
- case 0:
274
- if (_app_options.AppOptions.get('pdfBugEnabled')) {
275
- _context3.next = 2;
276
- break;
277
- }
278
-
279
- return _context3.abrupt("return", undefined);
280
-
281
- case 2:
282
- waitOn = [];
283
- hash = document.location.hash.substring(1);
284
- hashParams = (0, _ui_utils.parseQueryString)(hash);
285
-
286
- if ('disableworker' in hashParams && hashParams['disableworker'] === 'true') {
287
- waitOn.push(loadFakeWorker());
288
- }
289
-
290
- if ('disablerange' in hashParams) {
291
- _app_options.AppOptions.set('disableRange', hashParams['disablerange'] === 'true');
292
- }
293
-
294
- if ('disablestream' in hashParams) {
295
- _app_options.AppOptions.set('disableStream', hashParams['disablestream'] === 'true');
296
- }
297
-
298
- if ('disableautofetch' in hashParams) {
299
- _app_options.AppOptions.set('disableAutoFetch', hashParams['disableautofetch'] === 'true');
300
- }
301
-
302
- if ('disablefontface' in hashParams) {
303
- _app_options.AppOptions.set('disableFontFace', hashParams['disablefontface'] === 'true');
304
- }
305
-
306
- if ('disablehistory' in hashParams) {
307
- _app_options.AppOptions.set('disableHistory', hashParams['disablehistory'] === 'true');
308
- }
309
-
310
- if ('webgl' in hashParams) {
311
- _app_options.AppOptions.set('enableWebGL', hashParams['webgl'] === 'true');
312
- }
313
-
314
- if ('useonlycsszoom' in hashParams) {
315
- _app_options.AppOptions.set('useOnlyCssZoom', hashParams['useonlycsszoom'] === 'true');
316
- }
317
-
318
- if ('verbosity' in hashParams) {
319
- _app_options.AppOptions.set('verbosity', hashParams['verbosity'] | 0);
320
- }
321
-
322
- if (!('textlayer' in hashParams)) {
323
- _context3.next = 23;
324
- break;
325
- }
326
-
327
- _context3.t0 = hashParams['textlayer'];
328
- _context3.next = _context3.t0 === 'off' ? 18 : _context3.t0 === 'visible' ? 20 : _context3.t0 === 'shadow' ? 20 : _context3.t0 === 'hover' ? 20 : 23;
329
- break;
172
+ if (this.isViewerEmbedded && _app_options.AppOptions.get("externalLinkTarget") === _pdf.LinkTarget.NONE) {
173
+ _app_options.AppOptions.set("externalLinkTarget", _pdf.LinkTarget.TOP);
174
+ }
175
+
176
+ await this._initializeViewerComponents();
177
+ this.bindEvents();
178
+ this.bindWindowEvents();
179
+ const appContainer = appConfig.appContainer || document.documentElement;
180
+ this.l10n.translate(appContainer).then(() => {
181
+ this.eventBus.dispatch("localized", {
182
+ source: this
183
+ });
184
+ });
185
+
186
+ this._initializedCapability.resolve();
187
+ },
188
+
189
+ async _readPreferences() {
190
+ if (_app_options.AppOptions.get("disablePreferences") === true) {
191
+ return;
192
+ }
193
+
194
+ try {
195
+ const prefs = await this.preferences.getAll();
330
196
 
331
- case 18:
332
- _app_options.AppOptions.set('textLayerMode', _ui_utils.TextLayerMode.DISABLE);
197
+ for (const name in prefs) {
198
+ _app_options.AppOptions.set(name, prefs[name]);
199
+ }
200
+ } catch (reason) {
201
+ console.error(`_readPreferences: "${reason.message}".`);
202
+ }
203
+ },
333
204
 
334
- return _context3.abrupt("break", 23);
205
+ async _parseHashParameters() {
206
+ if (!_app_options.AppOptions.get("pdfBugEnabled")) {
207
+ return undefined;
208
+ }
335
209
 
336
- case 20:
337
- viewer = this.appConfig.viewerContainer;
338
- viewer.classList.add('textLayer-' + hashParams['textlayer']);
339
- return _context3.abrupt("break", 23);
210
+ const hash = document.location.hash.substring(1);
340
211
 
341
- case 23:
342
- if ('pdfbug' in hashParams) {
343
- _app_options.AppOptions.set('pdfBug', true);
212
+ if (!hash) {
213
+ return undefined;
214
+ }
344
215
 
345
- enabled = hashParams['pdfbug'].split(',');
346
- waitOn.push(loadAndEnablePDFBug(enabled));
347
- }
216
+ const hashParams = (0, _ui_utils.parseQueryString)(hash),
217
+ waitOn = [];
348
218
 
349
- if ('locale' in hashParams) {
350
- _app_options.AppOptions.set('locale', hashParams['locale']);
351
- }
219
+ if ("disableworker" in hashParams && hashParams["disableworker"] === "true") {
220
+ waitOn.push(loadFakeWorker());
221
+ }
352
222
 
353
- return _context3.abrupt("return", Promise.all(waitOn)["catch"](function (reason) {
354
- console.error("_parseHashParameters: \"".concat(reason.message, "\"."));
355
- }));
223
+ if ("disablerange" in hashParams) {
224
+ _app_options.AppOptions.set("disableRange", hashParams["disablerange"] === "true");
225
+ }
356
226
 
357
- case 26:
358
- case "end":
359
- return _context3.stop();
360
- }
361
- }
362
- }, _callee3, this);
363
- }));
364
-
365
- function _parseHashParameters() {
366
- return _parseHashParameters2.apply(this, arguments);
367
- }
368
-
369
- return _parseHashParameters;
370
- }(),
371
- _initializeL10n: function () {
372
- var _initializeL10n2 = _asyncToGenerator(
373
- /*#__PURE__*/
374
- _regenerator["default"].mark(function _callee4() {
375
- var dir;
376
- return _regenerator["default"].wrap(function _callee4$(_context4) {
377
- while (1) {
378
- switch (_context4.prev = _context4.next) {
379
- case 0:
380
- this.l10n = this.externalServices.createL10n({
381
- locale: _app_options.AppOptions.get('locale')
382
- });
383
- _context4.next = 3;
384
- return this.l10n.getDirection();
385
-
386
- case 3:
387
- dir = _context4.sent;
388
- document.getElementsByTagName('html')[0].dir = dir;
389
-
390
- case 5:
391
- case "end":
392
- return _context4.stop();
393
- }
394
- }
395
- }, _callee4, this);
396
- }));
397
-
398
- function _initializeL10n() {
399
- return _initializeL10n2.apply(this, arguments);
400
- }
401
-
402
- return _initializeL10n;
403
- }(),
404
- _initializeViewerComponents: function () {
405
- var _initializeViewerComponents2 = _asyncToGenerator(
406
- /*#__PURE__*/
407
- _regenerator["default"].mark(function _callee5() {
408
- var appConfig, eventBus, pdfRenderingQueue, pdfLinkService, downloadManager, findController, container, viewer;
409
- return _regenerator["default"].wrap(function _callee5$(_context5) {
410
- while (1) {
411
- switch (_context5.prev = _context5.next) {
412
- case 0:
413
- appConfig = this.appConfig;
414
- this.overlayManager = new _overlay_manager.OverlayManager();
415
- eventBus = appConfig.eventBus || (0, _ui_utils.getGlobalEventBus)(_app_options.AppOptions.get('eventBusDispatchToDOM'));
416
- this.eventBus = eventBus;
417
- pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
418
- pdfRenderingQueue.onIdle = this.cleanup.bind(this);
419
- this.pdfRenderingQueue = pdfRenderingQueue;
420
- pdfLinkService = new _pdf_link_service.PDFLinkService({
421
- eventBus: eventBus,
422
- externalLinkTarget: _app_options.AppOptions.get('externalLinkTarget'),
423
- externalLinkRel: _app_options.AppOptions.get('externalLinkRel')
424
- });
425
- this.pdfLinkService = pdfLinkService;
426
- downloadManager = this.externalServices.createDownloadManager({
427
- disableCreateObjectURL: _app_options.AppOptions.get('disableCreateObjectURL')
428
- });
429
- this.downloadManager = downloadManager;
430
- findController = new _pdf_find_controller.PDFFindController({
431
- linkService: pdfLinkService,
432
- eventBus: eventBus
433
- });
434
- this.findController = findController;
435
- container = appConfig.mainContainer;
436
- viewer = appConfig.viewerContainer;
437
- this.pdfViewer = new _pdf_viewer.PDFViewer({
438
- container: container,
439
- viewer: viewer,
440
- eventBus: eventBus,
441
- renderingQueue: pdfRenderingQueue,
442
- linkService: pdfLinkService,
443
- downloadManager: downloadManager,
444
- findController: findController,
445
- renderer: _app_options.AppOptions.get('renderer'),
446
- enableWebGL: _app_options.AppOptions.get('enableWebGL'),
447
- l10n: this.l10n,
448
- textLayerMode: _app_options.AppOptions.get('textLayerMode'),
449
- imageResourcesPath: _app_options.AppOptions.get('imageResourcesPath'),
450
- renderInteractiveForms: _app_options.AppOptions.get('renderInteractiveForms'),
451
- enablePrintAutoRotate: _app_options.AppOptions.get('enablePrintAutoRotate'),
452
- useOnlyCssZoom: _app_options.AppOptions.get('useOnlyCssZoom'),
453
- maxCanvasPixels: _app_options.AppOptions.get('maxCanvasPixels')
454
- });
455
- pdfRenderingQueue.setViewer(this.pdfViewer);
456
- pdfLinkService.setViewer(this.pdfViewer);
457
- this.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({
458
- container: appConfig.sidebar.thumbnailView,
459
- renderingQueue: pdfRenderingQueue,
460
- linkService: pdfLinkService,
461
- l10n: this.l10n
462
- });
463
- pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer);
464
- this.pdfHistory = new _pdf_history.PDFHistory({
465
- linkService: pdfLinkService,
466
- eventBus: eventBus
467
- });
468
- pdfLinkService.setHistory(this.pdfHistory);
469
-
470
- if (!this.supportsIntegratedFind) {
471
- this.findBar = new _pdf_find_bar.PDFFindBar(appConfig.findBar, eventBus, this.l10n);
472
- }
473
-
474
- this.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties, this.overlayManager, eventBus, this.l10n);
475
- this.pdfCursorTools = new _pdf_cursor_tools.PDFCursorTools({
476
- container: container,
477
- eventBus: eventBus,
478
- cursorToolOnLoad: _app_options.AppOptions.get('cursorToolOnLoad')
479
- });
480
- this.toolbar = new _toolbar.Toolbar(appConfig.toolbar, eventBus, this.l10n);
481
- this.secondaryToolbar = new _secondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus);
482
-
483
- if (this.supportsFullscreen) {
484
- this.pdfPresentationMode = new _pdf_presentation_mode.PDFPresentationMode({
485
- container: container,
486
- viewer: viewer,
487
- pdfViewer: this.pdfViewer,
488
- eventBus: eventBus,
489
- contextMenuItems: appConfig.fullscreen
490
- });
491
- }
492
-
493
- this.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay, this.overlayManager, this.l10n);
494
- this.pdfOutlineViewer = new _pdf_outline_viewer.PDFOutlineViewer({
495
- container: appConfig.sidebar.outlineView,
496
- eventBus: eventBus,
497
- linkService: pdfLinkService
498
- });
499
- this.pdfAttachmentViewer = new _pdf_attachment_viewer.PDFAttachmentViewer({
500
- container: appConfig.sidebar.attachmentsView,
501
- eventBus: eventBus,
502
- downloadManager: downloadManager
503
- });
504
- this.pdfSidebar = new _pdf_sidebar.PDFSidebar({
505
- elements: appConfig.sidebar,
506
- pdfViewer: this.pdfViewer,
507
- pdfThumbnailViewer: this.pdfThumbnailViewer,
508
- eventBus: eventBus,
509
- l10n: this.l10n
510
- });
511
- this.pdfSidebar.onToggled = this.forceRendering.bind(this);
512
- this.pdfSidebarResizer = new _pdf_sidebar_resizer.PDFSidebarResizer(appConfig.sidebarResizer, eventBus, this.l10n);
513
-
514
- case 34:
515
- case "end":
516
- return _context5.stop();
517
- }
518
- }
519
- }, _callee5, this);
520
- }));
227
+ if ("disablestream" in hashParams) {
228
+ _app_options.AppOptions.set("disableStream", hashParams["disablestream"] === "true");
229
+ }
230
+
231
+ if ("disableautofetch" in hashParams) {
232
+ _app_options.AppOptions.set("disableAutoFetch", hashParams["disableautofetch"] === "true");
233
+ }
234
+
235
+ if ("disablefontface" in hashParams) {
236
+ _app_options.AppOptions.set("disableFontFace", hashParams["disablefontface"] === "true");
237
+ }
238
+
239
+ if ("disablehistory" in hashParams) {
240
+ _app_options.AppOptions.set("disableHistory", hashParams["disablehistory"] === "true");
241
+ }
242
+
243
+ if ("webgl" in hashParams) {
244
+ _app_options.AppOptions.set("enableWebGL", hashParams["webgl"] === "true");
245
+ }
246
+
247
+ if ("verbosity" in hashParams) {
248
+ _app_options.AppOptions.set("verbosity", hashParams["verbosity"] | 0);
249
+ }
250
+
251
+ if ("textlayer" in hashParams) {
252
+ switch (hashParams["textlayer"]) {
253
+ case "off":
254
+ _app_options.AppOptions.set("textLayerMode", _ui_utils.TextLayerMode.DISABLE);
255
+
256
+ break;
257
+
258
+ case "visible":
259
+ case "shadow":
260
+ case "hover":
261
+ const viewer = this.appConfig.viewerContainer;
262
+ viewer.classList.add("textLayer-" + hashParams["textlayer"]);
263
+ break;
264
+ }
265
+ }
266
+
267
+ if ("pdfbug" in hashParams) {
268
+ _app_options.AppOptions.set("pdfBug", true);
269
+
270
+ const enabled = hashParams["pdfbug"].split(",");
271
+ waitOn.push(loadAndEnablePDFBug(enabled));
272
+ }
273
+
274
+ if ("locale" in hashParams) {
275
+ _app_options.AppOptions.set("locale", hashParams["locale"]);
276
+ }
277
+
278
+ return Promise.all(waitOn).catch(reason => {
279
+ console.error(`_parseHashParameters: "${reason.message}".`);
280
+ });
281
+ },
282
+
283
+ async _initializeL10n() {
284
+ this.l10n = this.externalServices.createL10n({
285
+ locale: _app_options.AppOptions.get("locale")
286
+ });
287
+ const dir = await this.l10n.getDirection();
288
+ document.getElementsByTagName("html")[0].dir = dir;
289
+ },
290
+
291
+ async _initializeViewerComponents() {
292
+ const appConfig = this.appConfig;
293
+ this.overlayManager = new _overlay_manager.OverlayManager();
294
+ const eventBus = appConfig.eventBus || new _ui_utils.EventBus({
295
+ dispatchToDOM: _app_options.AppOptions.get("eventBusDispatchToDOM")
296
+ });
297
+ this.eventBus = eventBus;
298
+ const pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
299
+ pdfRenderingQueue.onIdle = this.cleanup.bind(this);
300
+ this.pdfRenderingQueue = pdfRenderingQueue;
301
+ const pdfLinkService = new _pdf_link_service.PDFLinkService({
302
+ eventBus,
303
+ externalLinkTarget: _app_options.AppOptions.get("externalLinkTarget"),
304
+ externalLinkRel: _app_options.AppOptions.get("externalLinkRel"),
305
+ ignoreDestinationZoom: _app_options.AppOptions.get("ignoreDestinationZoom")
306
+ });
307
+ this.pdfLinkService = pdfLinkService;
308
+ const downloadManager = this.externalServices.createDownloadManager({
309
+ disableCreateObjectURL: _app_options.AppOptions.get("disableCreateObjectURL")
310
+ });
311
+ this.downloadManager = downloadManager;
312
+ const findController = new _pdf_find_controller.PDFFindController({
313
+ linkService: pdfLinkService,
314
+ eventBus
315
+ });
316
+ this.findController = findController;
317
+ const container = appConfig.mainContainer;
318
+ const viewer = appConfig.viewerContainer;
319
+ this.pdfViewer = new _pdf_viewer.PDFViewer({
320
+ container,
321
+ viewer,
322
+ eventBus,
323
+ renderingQueue: pdfRenderingQueue,
324
+ linkService: pdfLinkService,
325
+ downloadManager,
326
+ findController,
327
+ renderer: _app_options.AppOptions.get("renderer"),
328
+ enableWebGL: _app_options.AppOptions.get("enableWebGL"),
329
+ l10n: this.l10n,
330
+ textLayerMode: _app_options.AppOptions.get("textLayerMode"),
331
+ imageResourcesPath: _app_options.AppOptions.get("imageResourcesPath"),
332
+ renderInteractiveForms: _app_options.AppOptions.get("renderInteractiveForms"),
333
+ enablePrintAutoRotate: _app_options.AppOptions.get("enablePrintAutoRotate"),
334
+ useOnlyCssZoom: _app_options.AppOptions.get("useOnlyCssZoom"),
335
+ maxCanvasPixels: _app_options.AppOptions.get("maxCanvasPixels")
336
+ });
337
+ pdfRenderingQueue.setViewer(this.pdfViewer);
338
+ pdfLinkService.setViewer(this.pdfViewer);
339
+ this.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({
340
+ container: appConfig.sidebar.thumbnailView,
341
+ renderingQueue: pdfRenderingQueue,
342
+ linkService: pdfLinkService,
343
+ l10n: this.l10n
344
+ });
345
+ pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer);
346
+ this.pdfHistory = new _pdf_history.PDFHistory({
347
+ linkService: pdfLinkService,
348
+ eventBus
349
+ });
350
+ pdfLinkService.setHistory(this.pdfHistory);
521
351
 
522
- function _initializeViewerComponents() {
523
- return _initializeViewerComponents2.apply(this, arguments);
352
+ if (!this.supportsIntegratedFind) {
353
+ this.findBar = new _pdf_find_bar.PDFFindBar(appConfig.findBar, eventBus, this.l10n);
524
354
  }
525
355
 
526
- return _initializeViewerComponents;
527
- }(),
528
- run: function run(config) {
356
+ this.pdfDocumentProperties = new _pdf_document_properties.PDFDocumentProperties(appConfig.documentProperties, this.overlayManager, eventBus, this.l10n);
357
+ this.pdfCursorTools = new _pdf_cursor_tools.PDFCursorTools({
358
+ container,
359
+ eventBus,
360
+ cursorToolOnLoad: _app_options.AppOptions.get("cursorToolOnLoad")
361
+ });
362
+ this.toolbar = new _toolbar.Toolbar(appConfig.toolbar, eventBus, this.l10n);
363
+ this.secondaryToolbar = new _secondary_toolbar.SecondaryToolbar(appConfig.secondaryToolbar, container, eventBus);
364
+
365
+ if (this.supportsFullscreen) {
366
+ this.pdfPresentationMode = new _pdf_presentation_mode.PDFPresentationMode({
367
+ container,
368
+ pdfViewer: this.pdfViewer,
369
+ eventBus,
370
+ contextMenuItems: appConfig.fullscreen
371
+ });
372
+ }
373
+
374
+ this.passwordPrompt = new _password_prompt.PasswordPrompt(appConfig.passwordOverlay, this.overlayManager, this.l10n);
375
+ this.pdfOutlineViewer = new _pdf_outline_viewer.PDFOutlineViewer({
376
+ container: appConfig.sidebar.outlineView,
377
+ eventBus,
378
+ linkService: pdfLinkService
379
+ });
380
+ this.pdfAttachmentViewer = new _pdf_attachment_viewer.PDFAttachmentViewer({
381
+ container: appConfig.sidebar.attachmentsView,
382
+ eventBus,
383
+ downloadManager
384
+ });
385
+ this.pdfSidebar = new _pdf_sidebar.PDFSidebar({
386
+ elements: appConfig.sidebar,
387
+ pdfViewer: this.pdfViewer,
388
+ pdfThumbnailViewer: this.pdfThumbnailViewer,
389
+ eventBus,
390
+ l10n: this.l10n
391
+ });
392
+ this.pdfSidebar.onToggled = this.forceRendering.bind(this);
393
+ this.pdfSidebarResizer = new _pdf_sidebar_resizer.PDFSidebarResizer(appConfig.sidebarResizer, eventBus, this.l10n);
394
+ },
395
+
396
+ run(config) {
529
397
  this.initialize(config).then(webViewerInitialized);
530
398
  },
531
- zoomIn: function zoomIn(ticks) {
399
+
400
+ get initialized() {
401
+ return this._initializedCapability.settled;
402
+ },
403
+
404
+ get initializedPromise() {
405
+ return this._initializedCapability.promise;
406
+ },
407
+
408
+ zoomIn(ticks) {
532
409
  if (this.pdfViewer.isInPresentationMode) {
533
410
  return;
534
411
  }
535
412
 
536
- var newScale = this.pdfViewer.currentScale;
413
+ let newScale = this.pdfViewer.currentScale;
537
414
 
538
415
  do {
539
416
  newScale = (newScale * DEFAULT_SCALE_DELTA).toFixed(2);
@@ -543,12 +420,13 @@ var PDFViewerApplication = {
543
420
 
544
421
  this.pdfViewer.currentScaleValue = newScale;
545
422
  },
546
- zoomOut: function zoomOut(ticks) {
423
+
424
+ zoomOut(ticks) {
547
425
  if (this.pdfViewer.isInPresentationMode) {
548
426
  return;
549
427
  }
550
428
 
551
- var newScale = this.pdfViewer.currentScale;
429
+ let newScale = this.pdfViewer.currentScale;
552
430
 
553
431
  do {
554
432
  newScale = (newScale / DEFAULT_SCALE_DELTA).toFixed(2);
@@ -558,7 +436,8 @@ var PDFViewerApplication = {
558
436
 
559
437
  this.pdfViewer.currentScaleValue = newScale;
560
438
  },
561
- zoomReset: function zoomReset() {
439
+
440
+ zoomReset() {
562
441
  if (this.pdfViewer.isInPresentationMode) {
563
442
  return;
564
443
  }
@@ -587,15 +466,15 @@ var PDFViewerApplication = {
587
466
  },
588
467
 
589
468
  get supportsFullscreen() {
590
- var support;
591
- var doc = document.documentElement;
469
+ let support;
470
+ const doc = document.documentElement;
592
471
  support = !!(doc.requestFullscreen || doc.mozRequestFullScreen || doc.webkitRequestFullScreen || doc.msRequestFullscreen);
593
472
 
594
473
  if (document.fullscreenEnabled === false || document.mozFullScreenEnabled === false || document.webkitFullscreenEnabled === false || document.msFullscreenEnabled === false) {
595
474
  support = false;
596
475
  }
597
476
 
598
- return (0, _pdf.shadow)(this, 'supportsFullscreen', support);
477
+ return (0, _pdf.shadow)(this, "supportsFullscreen", support);
599
478
  },
600
479
 
601
480
  get supportsIntegratedFind() {
@@ -606,27 +485,23 @@ var PDFViewerApplication = {
606
485
  return this.externalServices.supportsDocumentFonts;
607
486
  },
608
487
 
609
- get supportsDocumentColors() {
610
- return this.externalServices.supportsDocumentColors;
611
- },
612
-
613
488
  get loadingBar() {
614
- var bar = new _ui_utils.ProgressBar('#loadingBar');
615
- return (0, _pdf.shadow)(this, 'loadingBar', bar);
489
+ const bar = new _ui_utils.ProgressBar("#loadingBar");
490
+ return (0, _pdf.shadow)(this, "loadingBar", bar);
616
491
  },
617
492
 
618
493
  get supportedMouseWheelZoomModifierKeys() {
619
494
  return this.externalServices.supportedMouseWheelZoomModifierKeys;
620
495
  },
621
496
 
622
- initPassiveLoading: function initPassiveLoading() {
623
- throw new Error('Not implemented: initPassiveLoading');
497
+ initPassiveLoading() {
498
+ throw new Error("Not implemented: initPassiveLoading");
624
499
  },
625
- setTitleUsingUrl: function setTitleUsingUrl() {
626
- var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
500
+
501
+ setTitleUsingUrl(url = "") {
627
502
  this.url = url;
628
- this.baseUrl = url.split('#')[0];
629
- var title = (0, _ui_utils.getPDFFileNameFromURL)(url, '');
503
+ this.baseUrl = url.split("#")[0];
504
+ let title = (0, _ui_utils.getPDFFileNameFromURL)(url, "");
630
505
 
631
506
  if (!title) {
632
507
  try {
@@ -638,217 +513,164 @@ var PDFViewerApplication = {
638
513
 
639
514
  this.setTitle(title);
640
515
  },
641
- setTitle: function setTitle(title) {
516
+
517
+ setTitle(title) {
642
518
  if (this.isViewerEmbedded) {
643
519
  return;
644
520
  }
645
521
 
646
522
  document.title = title;
647
523
  },
648
- close: function () {
649
- var _close = _asyncToGenerator(
650
- /*#__PURE__*/
651
- _regenerator["default"].mark(function _callee6() {
652
- var errorWrapper, promise;
653
- return _regenerator["default"].wrap(function _callee6$(_context6) {
654
- while (1) {
655
- switch (_context6.prev = _context6.next) {
656
- case 0:
657
- errorWrapper = this.appConfig.errorWrapper.container;
658
- errorWrapper.setAttribute('hidden', 'true');
659
-
660
- if (this.pdfLoadingTask) {
661
- _context6.next = 4;
662
- break;
663
- }
664
-
665
- return _context6.abrupt("return", undefined);
666
-
667
- case 4:
668
- promise = this.pdfLoadingTask.destroy();
669
- this.pdfLoadingTask = null;
670
-
671
- if (this.pdfDocument) {
672
- this.pdfDocument = null;
673
- this.pdfThumbnailViewer.setDocument(null);
674
- this.pdfViewer.setDocument(null);
675
- this.pdfLinkService.setDocument(null);
676
- this.pdfDocumentProperties.setDocument(null);
677
- }
678
-
679
- this.store = null;
680
- this.isInitialViewSet = false;
681
- this.downloadComplete = false;
682
- this.url = '';
683
- this.baseUrl = '';
684
- this.contentDispositionFilename = null;
685
- this.pdfSidebar.reset();
686
- this.pdfOutlineViewer.reset();
687
- this.pdfAttachmentViewer.reset();
688
-
689
- if (this.findBar) {
690
- this.findBar.reset();
691
- }
692
-
693
- this.toolbar.reset();
694
- this.secondaryToolbar.reset();
695
-
696
- if (typeof PDFBug !== 'undefined') {
697
- PDFBug.cleanup();
698
- }
699
-
700
- return _context6.abrupt("return", promise);
701
-
702
- case 21:
703
- case "end":
704
- return _context6.stop();
705
- }
706
- }
707
- }, _callee6, this);
708
- }));
709
524
 
710
- function close() {
711
- return _close.apply(this, arguments);
525
+ async close() {
526
+ const errorWrapper = this.appConfig.errorWrapper.container;
527
+ errorWrapper.setAttribute("hidden", "true");
528
+
529
+ if (!this.pdfLoadingTask) {
530
+ return undefined;
712
531
  }
713
532
 
714
- return close;
715
- }(),
716
- open: function () {
717
- var _open = _asyncToGenerator(
718
- /*#__PURE__*/
719
- _regenerator["default"].mark(function _callee7(file, args) {
720
- var _this2 = this;
533
+ const promise = this.pdfLoadingTask.destroy();
534
+ this.pdfLoadingTask = null;
721
535
 
722
- var workerParameters, key, parameters, apiParameters, _key, value, _key2, _value, loadingTask;
723
-
724
- return _regenerator["default"].wrap(function _callee7$(_context7) {
725
- while (1) {
726
- switch (_context7.prev = _context7.next) {
727
- case 0:
728
- if (!this.pdfLoadingTask) {
729
- _context7.next = 3;
730
- break;
731
- }
732
-
733
- _context7.next = 3;
734
- return this.close();
735
-
736
- case 3:
737
- workerParameters = _app_options.AppOptions.getAll(_app_options.OptionKind.WORKER);
738
-
739
- for (key in workerParameters) {
740
- _pdf.GlobalWorkerOptions[key] = workerParameters[key];
741
- }
742
-
743
- parameters = Object.create(null);
744
-
745
- if (typeof file === 'string') {
746
- this.setTitleUsingUrl(file);
747
- parameters.url = file;
748
- } else if (file && 'byteLength' in file) {
749
- parameters.data = file;
750
- } else if (file.url && file.originalUrl) {
751
- this.setTitleUsingUrl(file.originalUrl);
752
- parameters.url = file.url;
753
- }
754
-
755
- apiParameters = _app_options.AppOptions.getAll(_app_options.OptionKind.API);
756
-
757
- for (_key in apiParameters) {
758
- value = apiParameters[_key];
759
-
760
- if (_key === 'docBaseUrl' && !value) {}
761
-
762
- parameters[_key] = value;
763
- }
764
-
765
- if (args) {
766
- for (_key2 in args) {
767
- _value = args[_key2];
768
-
769
- if (_key2 === 'length') {
770
- this.pdfDocumentProperties.setFileSize(_value);
771
- }
772
-
773
- parameters[_key2] = _value;
774
- }
775
- }
776
-
777
- loadingTask = (0, _pdf.getDocument)(parameters);
778
- this.pdfLoadingTask = loadingTask;
779
-
780
- loadingTask.onPassword = function (updateCallback, reason) {
781
- _this2.pdfLinkService.externalLinkEnabled = false;
782
-
783
- _this2.passwordPrompt.setUpdateCallback(updateCallback, reason);
784
-
785
- _this2.passwordPrompt.open();
786
- };
787
-
788
- loadingTask.onProgress = function (_ref) {
789
- var loaded = _ref.loaded,
790
- total = _ref.total;
791
-
792
- _this2.progress(loaded / total);
793
- };
794
-
795
- loadingTask.onUnsupportedFeature = this.fallback.bind(this);
796
- return _context7.abrupt("return", loadingTask.promise.then(function (pdfDocument) {
797
- _this2.load(pdfDocument);
798
- }, function (exception) {
799
- if (loadingTask !== _this2.pdfLoadingTask) {
800
- return undefined;
801
- }
802
-
803
- var message = exception && exception.message;
804
- var loadingErrorMessage;
805
-
806
- if (exception instanceof _pdf.InvalidPDFException) {
807
- loadingErrorMessage = _this2.l10n.get('invalid_file_error', null, 'Invalid or corrupted PDF file.');
808
- } else if (exception instanceof _pdf.MissingPDFException) {
809
- loadingErrorMessage = _this2.l10n.get('missing_file_error', null, 'Missing PDF file.');
810
- } else if (exception instanceof _pdf.UnexpectedResponseException) {
811
- loadingErrorMessage = _this2.l10n.get('unexpected_response_error', null, 'Unexpected server response.');
812
- } else {
813
- loadingErrorMessage = _this2.l10n.get('loading_error', null, 'An error occurred while loading the PDF.');
814
- }
815
-
816
- return loadingErrorMessage.then(function (msg) {
817
- _this2.error(msg, {
818
- message: message
819
- });
820
-
821
- throw new Error(msg);
822
- });
823
- }));
824
-
825
- case 16:
826
- case "end":
827
- return _context7.stop();
828
- }
536
+ if (this.pdfDocument) {
537
+ this.pdfDocument = null;
538
+ this.pdfThumbnailViewer.setDocument(null);
539
+ this.pdfViewer.setDocument(null);
540
+ this.pdfLinkService.setDocument(null);
541
+ this.pdfDocumentProperties.setDocument(null);
542
+ }
543
+
544
+ this.store = null;
545
+ this.isInitialViewSet = false;
546
+ this.downloadComplete = false;
547
+ this.url = "";
548
+ this.baseUrl = "";
549
+ this.contentDispositionFilename = null;
550
+ this.pdfSidebar.reset();
551
+ this.pdfOutlineViewer.reset();
552
+ this.pdfAttachmentViewer.reset();
553
+
554
+ if (this.pdfHistory) {
555
+ this.pdfHistory.reset();
556
+ }
557
+
558
+ if (this.findBar) {
559
+ this.findBar.reset();
560
+ }
561
+
562
+ this.toolbar.reset();
563
+ this.secondaryToolbar.reset();
564
+
565
+ if (typeof PDFBug !== "undefined") {
566
+ PDFBug.cleanup();
567
+ }
568
+
569
+ return promise;
570
+ },
571
+
572
+ async open(file, args) {
573
+ if (this.pdfLoadingTask) {
574
+ await this.close();
575
+ }
576
+
577
+ const workerParameters = _app_options.AppOptions.getAll(_app_options.OptionKind.WORKER);
578
+
579
+ for (const key in workerParameters) {
580
+ _pdf.GlobalWorkerOptions[key] = workerParameters[key];
581
+ }
582
+
583
+ const parameters = Object.create(null);
584
+
585
+ if (typeof file === "string") {
586
+ this.setTitleUsingUrl(file);
587
+ parameters.url = file;
588
+ } else if (file && "byteLength" in file) {
589
+ parameters.data = file;
590
+ } else if (file.url && file.originalUrl) {
591
+ this.setTitleUsingUrl(file.originalUrl);
592
+ parameters.url = file.url;
593
+ }
594
+
595
+ const apiParameters = _app_options.AppOptions.getAll(_app_options.OptionKind.API);
596
+
597
+ for (const key in apiParameters) {
598
+ let value = apiParameters[key];
599
+
600
+ if (key === "docBaseUrl" && !value) {}
601
+
602
+ parameters[key] = value;
603
+ }
604
+
605
+ if (args) {
606
+ for (const key in args) {
607
+ const value = args[key];
608
+
609
+ if (key === "length") {
610
+ this.pdfDocumentProperties.setFileSize(value);
829
611
  }
830
- }, _callee7, this);
831
- }));
832
612
 
833
- function open(_x2, _x3) {
834
- return _open.apply(this, arguments);
613
+ parameters[key] = value;
614
+ }
835
615
  }
836
616
 
837
- return open;
838
- }(),
839
- download: function download() {
840
- var _this3 = this;
617
+ const loadingTask = (0, _pdf.getDocument)(parameters);
618
+ this.pdfLoadingTask = loadingTask;
841
619
 
620
+ loadingTask.onPassword = (updateCallback, reason) => {
621
+ this.pdfLinkService.externalLinkEnabled = false;
622
+ this.passwordPrompt.setUpdateCallback(updateCallback, reason);
623
+ this.passwordPrompt.open();
624
+ };
625
+
626
+ loadingTask.onProgress = ({
627
+ loaded,
628
+ total
629
+ }) => {
630
+ this.progress(loaded / total);
631
+ };
632
+
633
+ loadingTask.onUnsupportedFeature = this.fallback.bind(this);
634
+ return loadingTask.promise.then(pdfDocument => {
635
+ this.load(pdfDocument);
636
+ }, exception => {
637
+ if (loadingTask !== this.pdfLoadingTask) {
638
+ return undefined;
639
+ }
640
+
641
+ const message = exception && exception.message;
642
+ let loadingErrorMessage;
643
+
644
+ if (exception instanceof _pdf.InvalidPDFException) {
645
+ loadingErrorMessage = this.l10n.get("invalid_file_error", null, "Invalid or corrupted PDF file.");
646
+ } else if (exception instanceof _pdf.MissingPDFException) {
647
+ loadingErrorMessage = this.l10n.get("missing_file_error", null, "Missing PDF file.");
648
+ } else if (exception instanceof _pdf.UnexpectedResponseException) {
649
+ loadingErrorMessage = this.l10n.get("unexpected_response_error", null, "Unexpected server response.");
650
+ } else {
651
+ loadingErrorMessage = this.l10n.get("loading_error", null, "An error occurred while loading the PDF.");
652
+ }
653
+
654
+ return loadingErrorMessage.then(msg => {
655
+ this.error(msg, {
656
+ message
657
+ });
658
+ throw new Error(msg);
659
+ });
660
+ });
661
+ },
662
+
663
+ download() {
842
664
  function downloadByUrl() {
843
665
  downloadManager.downloadUrl(url, filename);
844
666
  }
845
667
 
846
- var url = this.baseUrl;
847
- var filename = this.contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(this.url);
848
- var downloadManager = this.downloadManager;
668
+ const url = this.baseUrl;
669
+ const filename = this.contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(this.url);
670
+ const downloadManager = this.downloadManager;
849
671
 
850
- downloadManager.onerror = function (err) {
851
- _this3.error("PDF failed to download: ".concat(err));
672
+ downloadManager.onerror = err => {
673
+ this.error(`PDF failed to download: ${err}`);
852
674
  };
853
675
 
854
676
  if (!this.pdfDocument || !this.downloadComplete) {
@@ -857,92 +679,109 @@ var PDFViewerApplication = {
857
679
  }
858
680
 
859
681
  this.pdfDocument.getData().then(function (data) {
860
- var blob = new Blob([data], {
861
- type: 'application/pdf'
682
+ const blob = new Blob([data], {
683
+ type: "application/pdf"
862
684
  });
863
685
  downloadManager.download(blob, url, filename);
864
- })["catch"](downloadByUrl);
686
+ }).catch(downloadByUrl);
687
+ },
688
+
689
+ fallback(featureId) {
690
+ if (this.fellback) {
691
+ return;
692
+ }
693
+
694
+ this.fellback = true;
695
+ this.externalServices.fallback({
696
+ featureId,
697
+ url: this.baseUrl
698
+ }, function response(download) {
699
+ if (!download) {
700
+ return;
701
+ }
702
+
703
+ PDFViewerApplication.download();
704
+ });
865
705
  },
866
- fallback: function fallback(featureId) {},
867
- error: function error(message, moreInfo) {
868
- var moreInfoText = [this.l10n.get('error_version_info', {
869
- version: _pdf.version || '?',
870
- build: _pdf.build || '?'
871
- }, 'PDF.js v{{version}} (build: {{build}})')];
706
+
707
+ error(message, moreInfo) {
708
+ const moreInfoText = [this.l10n.get("error_version_info", {
709
+ version: _pdf.version || "?",
710
+ build: _pdf.build || "?"
711
+ }, "PDF.js v{{version}} (build: {{build}})")];
872
712
 
873
713
  if (moreInfo) {
874
- moreInfoText.push(this.l10n.get('error_message', {
714
+ moreInfoText.push(this.l10n.get("error_message", {
875
715
  message: moreInfo.message
876
- }, 'Message: {{message}}'));
716
+ }, "Message: {{message}}"));
877
717
 
878
718
  if (moreInfo.stack) {
879
- moreInfoText.push(this.l10n.get('error_stack', {
719
+ moreInfoText.push(this.l10n.get("error_stack", {
880
720
  stack: moreInfo.stack
881
- }, 'Stack: {{stack}}'));
721
+ }, "Stack: {{stack}}"));
882
722
  } else {
883
723
  if (moreInfo.filename) {
884
- moreInfoText.push(this.l10n.get('error_file', {
724
+ moreInfoText.push(this.l10n.get("error_file", {
885
725
  file: moreInfo.filename
886
- }, 'File: {{file}}'));
726
+ }, "File: {{file}}"));
887
727
  }
888
728
 
889
729
  if (moreInfo.lineNumber) {
890
- moreInfoText.push(this.l10n.get('error_line', {
730
+ moreInfoText.push(this.l10n.get("error_line", {
891
731
  line: moreInfo.lineNumber
892
- }, 'Line: {{line}}'));
732
+ }, "Line: {{line}}"));
893
733
  }
894
734
  }
895
735
  }
896
736
 
897
- var errorWrapperConfig = this.appConfig.errorWrapper;
898
- var errorWrapper = errorWrapperConfig.container;
899
- errorWrapper.removeAttribute('hidden');
900
- var errorMessage = errorWrapperConfig.errorMessage;
737
+ const errorWrapperConfig = this.appConfig.errorWrapper;
738
+ const errorWrapper = errorWrapperConfig.container;
739
+ errorWrapper.removeAttribute("hidden");
740
+ const errorMessage = errorWrapperConfig.errorMessage;
901
741
  errorMessage.textContent = message;
902
- var closeButton = errorWrapperConfig.closeButton;
742
+ const closeButton = errorWrapperConfig.closeButton;
903
743
 
904
744
  closeButton.onclick = function () {
905
- errorWrapper.setAttribute('hidden', 'true');
745
+ errorWrapper.setAttribute("hidden", "true");
906
746
  };
907
747
 
908
- var errorMoreInfo = errorWrapperConfig.errorMoreInfo;
909
- var moreInfoButton = errorWrapperConfig.moreInfoButton;
910
- var lessInfoButton = errorWrapperConfig.lessInfoButton;
748
+ const errorMoreInfo = errorWrapperConfig.errorMoreInfo;
749
+ const moreInfoButton = errorWrapperConfig.moreInfoButton;
750
+ const lessInfoButton = errorWrapperConfig.lessInfoButton;
911
751
 
912
752
  moreInfoButton.onclick = function () {
913
- errorMoreInfo.removeAttribute('hidden');
914
- moreInfoButton.setAttribute('hidden', 'true');
915
- lessInfoButton.removeAttribute('hidden');
916
- errorMoreInfo.style.height = errorMoreInfo.scrollHeight + 'px';
753
+ errorMoreInfo.removeAttribute("hidden");
754
+ moreInfoButton.setAttribute("hidden", "true");
755
+ lessInfoButton.removeAttribute("hidden");
756
+ errorMoreInfo.style.height = errorMoreInfo.scrollHeight + "px";
917
757
  };
918
758
 
919
759
  lessInfoButton.onclick = function () {
920
- errorMoreInfo.setAttribute('hidden', 'true');
921
- moreInfoButton.removeAttribute('hidden');
922
- lessInfoButton.setAttribute('hidden', 'true');
760
+ errorMoreInfo.setAttribute("hidden", "true");
761
+ moreInfoButton.removeAttribute("hidden");
762
+ lessInfoButton.setAttribute("hidden", "true");
923
763
  };
924
764
 
925
765
  moreInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
926
766
  lessInfoButton.oncontextmenu = _ui_utils.noContextMenuHandler;
927
767
  closeButton.oncontextmenu = _ui_utils.noContextMenuHandler;
928
- moreInfoButton.removeAttribute('hidden');
929
- lessInfoButton.setAttribute('hidden', 'true');
930
- Promise.all(moreInfoText).then(function (parts) {
931
- errorMoreInfo.value = parts.join('\n');
768
+ moreInfoButton.removeAttribute("hidden");
769
+ lessInfoButton.setAttribute("hidden", "true");
770
+ Promise.all(moreInfoText).then(parts => {
771
+ errorMoreInfo.value = parts.join("\n");
932
772
  });
933
773
  },
934
- progress: function progress(level) {
935
- var _this4 = this;
936
774
 
775
+ progress(level) {
937
776
  if (this.downloadComplete) {
938
777
  return;
939
778
  }
940
779
 
941
- var percent = Math.round(level * 100);
780
+ const percent = Math.round(level * 100);
942
781
 
943
782
  if (percent > this.loadingBar.percent || isNaN(percent)) {
944
783
  this.loadingBar.percent = percent;
945
- var disableAutoFetch = this.pdfDocument ? this.pdfDocument.loadingParams['disableAutoFetch'] : _app_options.AppOptions.get('disableAutoFetch');
784
+ const disableAutoFetch = this.pdfDocument ? this.pdfDocument.loadingParams["disableAutoFetch"] : _app_options.AppOptions.get("disableAutoFetch");
946
785
 
947
786
  if (disableAutoFetch && percent) {
948
787
  if (this.disableAutoFetchLoadingBarTimeout) {
@@ -951,185 +790,152 @@ var PDFViewerApplication = {
951
790
  }
952
791
 
953
792
  this.loadingBar.show();
954
- this.disableAutoFetchLoadingBarTimeout = setTimeout(function () {
955
- _this4.loadingBar.hide();
956
-
957
- _this4.disableAutoFetchLoadingBarTimeout = null;
793
+ this.disableAutoFetchLoadingBarTimeout = setTimeout(() => {
794
+ this.loadingBar.hide();
795
+ this.disableAutoFetchLoadingBarTimeout = null;
958
796
  }, DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT);
959
797
  }
960
798
  }
961
799
  },
962
- load: function load(pdfDocument) {
963
- var _this5 = this;
964
800
 
801
+ load(pdfDocument) {
965
802
  this.pdfDocument = pdfDocument;
966
- pdfDocument.getDownloadInfo().then(function () {
967
- _this5.downloadComplete = true;
968
-
969
- _this5.loadingBar.hide();
970
-
971
- firstPagePromise.then(function () {
972
- _this5.eventBus.dispatch('documentloaded', {
973
- source: _this5
803
+ pdfDocument.getDownloadInfo().then(() => {
804
+ this.downloadComplete = true;
805
+ this.loadingBar.hide();
806
+ firstPagePromise.then(() => {
807
+ this.eventBus.dispatch("documentloaded", {
808
+ source: this
974
809
  });
975
810
  });
976
811
  });
977
- var pageLayoutPromise = pdfDocument.getPageLayout()["catch"](function () {});
978
- var pageModePromise = pdfDocument.getPageMode()["catch"](function () {});
979
- var openActionDestPromise = pdfDocument.getOpenActionDestination()["catch"](function () {});
812
+ const pageLayoutPromise = pdfDocument.getPageLayout().catch(function () {});
813
+ const pageModePromise = pdfDocument.getPageMode().catch(function () {});
814
+ const openActionPromise = pdfDocument.getOpenAction().catch(function () {});
980
815
  this.toolbar.setPagesCount(pdfDocument.numPages, false);
981
816
  this.secondaryToolbar.setPagesCount(pdfDocument.numPages);
982
- var store = this.store = new _view_history.ViewHistory(pdfDocument.fingerprint);
983
- var baseDocumentUrl;
817
+ const store = this.store = new _view_history.ViewHistory(pdfDocument.fingerprint);
818
+ let baseDocumentUrl;
984
819
  baseDocumentUrl = null;
985
820
  this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
986
821
  this.pdfDocumentProperties.setDocument(pdfDocument, this.url);
987
- var pdfViewer = this.pdfViewer;
822
+ const pdfViewer = this.pdfViewer;
988
823
  pdfViewer.setDocument(pdfDocument);
989
- var firstPagePromise = pdfViewer.firstPagePromise;
990
- var pagesPromise = pdfViewer.pagesPromise;
991
- var onePageRendered = pdfViewer.onePageRendered;
992
- var pdfThumbnailViewer = this.pdfThumbnailViewer;
824
+ const {
825
+ firstPagePromise,
826
+ onePageRendered,
827
+ pagesPromise
828
+ } = pdfViewer;
829
+ const pdfThumbnailViewer = this.pdfThumbnailViewer;
993
830
  pdfThumbnailViewer.setDocument(pdfDocument);
994
- firstPagePromise.then(function (pdfPage) {
995
- _this5.loadingBar.setWidth(_this5.appConfig.viewerContainer);
996
-
997
- var storePromise = store.getMultiple({
831
+ firstPagePromise.then(pdfPage => {
832
+ this.loadingBar.setWidth(this.appConfig.viewerContainer);
833
+ const storePromise = store.getMultiple({
998
834
  page: null,
999
835
  zoom: _ui_utils.DEFAULT_SCALE_VALUE,
1000
- scrollLeft: '0',
1001
- scrollTop: '0',
836
+ scrollLeft: "0",
837
+ scrollTop: "0",
1002
838
  rotation: null,
1003
839
  sidebarView: _pdf_sidebar.SidebarView.UNKNOWN,
1004
840
  scrollMode: _ui_utils.ScrollMode.UNKNOWN,
1005
841
  spreadMode: _ui_utils.SpreadMode.UNKNOWN
1006
- })["catch"](function () {});
1007
- Promise.all([_ui_utils.animationStarted, storePromise, pageLayoutPromise, pageModePromise, openActionDestPromise]).then(
1008
- /*#__PURE__*/
1009
- function () {
1010
- var _ref3 = _asyncToGenerator(
1011
- /*#__PURE__*/
1012
- _regenerator["default"].mark(function _callee8(_ref2) {
1013
- var _ref4, timeStamp, _ref4$, values, pageLayout, pageMode, openActionDest, viewOnLoad, initialBookmark, zoom, hash, rotation, sidebarView, scrollMode, spreadMode;
1014
-
1015
- return _regenerator["default"].wrap(function _callee8$(_context8) {
1016
- while (1) {
1017
- switch (_context8.prev = _context8.next) {
1018
- case 0:
1019
- _ref4 = _slicedToArray(_ref2, 5), timeStamp = _ref4[0], _ref4$ = _ref4[1], values = _ref4$ === void 0 ? {} : _ref4$, pageLayout = _ref4[2], pageMode = _ref4[3], openActionDest = _ref4[4];
1020
- viewOnLoad = _app_options.AppOptions.get('viewOnLoad');
1021
-
1022
- _this5._initializePdfHistory({
1023
- fingerprint: pdfDocument.fingerprint,
1024
- viewOnLoad: viewOnLoad,
1025
- initialDest: openActionDest
1026
- });
1027
-
1028
- initialBookmark = _this5.initialBookmark;
1029
- zoom = _app_options.AppOptions.get('defaultZoomValue');
1030
- hash = zoom ? "zoom=".concat(zoom) : null;
1031
- rotation = null;
1032
- sidebarView = _app_options.AppOptions.get('sidebarViewOnLoad');
1033
- scrollMode = _app_options.AppOptions.get('scrollModeOnLoad');
1034
- spreadMode = _app_options.AppOptions.get('spreadModeOnLoad');
1035
-
1036
- if (values.page && viewOnLoad !== ViewOnLoad.INITIAL) {
1037
- hash = "page=".concat(values.page, "&zoom=").concat(zoom || values.zoom, ",") + "".concat(values.scrollLeft, ",").concat(values.scrollTop);
1038
- rotation = parseInt(values.rotation, 10);
1039
-
1040
- if (sidebarView === _pdf_sidebar.SidebarView.UNKNOWN) {
1041
- sidebarView = values.sidebarView | 0;
1042
- }
1043
-
1044
- if (scrollMode === _ui_utils.ScrollMode.UNKNOWN) {
1045
- scrollMode = values.scrollMode | 0;
1046
- }
1047
-
1048
- if (spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
1049
- spreadMode = values.spreadMode | 0;
1050
- }
1051
- }
1052
-
1053
- if (pageMode && sidebarView === _pdf_sidebar.SidebarView.UNKNOWN) {
1054
- sidebarView = apiPageModeToSidebarView(pageMode);
1055
- }
1056
-
1057
- if (pageLayout && spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
1058
- spreadMode = apiPageLayoutToSpreadMode(pageLayout);
1059
- }
1060
-
1061
- _this5.setInitialView(hash, {
1062
- rotation: rotation,
1063
- sidebarView: sidebarView,
1064
- scrollMode: scrollMode,
1065
- spreadMode: spreadMode
1066
- });
1067
-
1068
- _this5.eventBus.dispatch('documentinit', {
1069
- source: _this5
1070
- });
1071
-
1072
- if (!_this5.isViewerEmbedded) {
1073
- pdfViewer.focus();
1074
- }
1075
-
1076
- _context8.next = 18;
1077
- return Promise.race([pagesPromise, new Promise(function (resolve) {
1078
- setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT);
1079
- })]);
1080
-
1081
- case 18:
1082
- if (!(!initialBookmark && !hash)) {
1083
- _context8.next = 20;
1084
- break;
1085
- }
1086
-
1087
- return _context8.abrupt("return");
1088
-
1089
- case 20:
1090
- if (!pdfViewer.hasEqualPageSizes) {
1091
- _context8.next = 22;
1092
- break;
1093
- }
1094
-
1095
- return _context8.abrupt("return");
1096
-
1097
- case 22:
1098
- _this5.initialBookmark = initialBookmark;
1099
- pdfViewer.currentScaleValue = pdfViewer.currentScaleValue;
1100
-
1101
- _this5.setInitialView(hash);
1102
-
1103
- case 25:
1104
- case "end":
1105
- return _context8.stop();
1106
- }
1107
- }
1108
- }, _callee8);
1109
- }));
842
+ }).catch(() => {});
843
+ Promise.all([_ui_utils.animationStarted, storePromise, pageLayoutPromise, pageModePromise, openActionPromise]).then(async ([timeStamp, values = {}, pageLayout, pageMode, openAction]) => {
844
+ const viewOnLoad = _app_options.AppOptions.get("viewOnLoad");
845
+
846
+ this._initializePdfHistory({
847
+ fingerprint: pdfDocument.fingerprint,
848
+ viewOnLoad,
849
+ initialDest: openAction && openAction.dest
850
+ });
1110
851
 
1111
- return function (_x4) {
1112
- return _ref3.apply(this, arguments);
1113
- };
1114
- }())["catch"](function () {
1115
- _this5.setInitialView();
852
+ const initialBookmark = this.initialBookmark;
853
+
854
+ const zoom = _app_options.AppOptions.get("defaultZoomValue");
855
+
856
+ let hash = zoom ? `zoom=${zoom}` : null;
857
+ let rotation = null;
858
+
859
+ let sidebarView = _app_options.AppOptions.get("sidebarViewOnLoad");
860
+
861
+ let scrollMode = _app_options.AppOptions.get("scrollModeOnLoad");
862
+
863
+ let spreadMode = _app_options.AppOptions.get("spreadModeOnLoad");
864
+
865
+ if (values.page && viewOnLoad !== ViewOnLoad.INITIAL) {
866
+ hash = `page=${values.page}&zoom=${zoom || values.zoom},` + `${values.scrollLeft},${values.scrollTop}`;
867
+ rotation = parseInt(values.rotation, 10);
868
+
869
+ if (sidebarView === _pdf_sidebar.SidebarView.UNKNOWN) {
870
+ sidebarView = values.sidebarView | 0;
871
+ }
872
+
873
+ if (scrollMode === _ui_utils.ScrollMode.UNKNOWN) {
874
+ scrollMode = values.scrollMode | 0;
875
+ }
876
+
877
+ if (spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
878
+ spreadMode = values.spreadMode | 0;
879
+ }
880
+ }
881
+
882
+ if (pageMode && sidebarView === _pdf_sidebar.SidebarView.UNKNOWN) {
883
+ sidebarView = apiPageModeToSidebarView(pageMode);
884
+ }
885
+
886
+ if (pageLayout && spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
887
+ spreadMode = apiPageLayoutToSpreadMode(pageLayout);
888
+ }
889
+
890
+ this.setInitialView(hash, {
891
+ rotation,
892
+ sidebarView,
893
+ scrollMode,
894
+ spreadMode
895
+ });
896
+ this.eventBus.dispatch("documentinit", {
897
+ source: this
898
+ });
899
+
900
+ if (!this.isViewerEmbedded) {
901
+ pdfViewer.focus();
902
+ }
903
+
904
+ await Promise.race([pagesPromise, new Promise(resolve => {
905
+ setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT);
906
+ })]);
907
+
908
+ if (!initialBookmark && !hash) {
909
+ return;
910
+ }
911
+
912
+ if (pdfViewer.hasEqualPageSizes) {
913
+ return;
914
+ }
915
+
916
+ this.initialBookmark = initialBookmark;
917
+ pdfViewer.currentScaleValue = pdfViewer.currentScaleValue;
918
+ this.setInitialView(hash);
919
+ }).catch(() => {
920
+ this.setInitialView();
1116
921
  }).then(function () {
1117
922
  pdfViewer.update();
1118
923
  });
1119
924
  });
1120
- pdfDocument.getPageLabels().then(function (labels) {
1121
- if (!labels || _app_options.AppOptions.get('disablePageLabels')) {
925
+ pdfDocument.getPageLabels().then(labels => {
926
+ if (!labels || _app_options.AppOptions.get("disablePageLabels")) {
1122
927
  return;
1123
928
  }
1124
929
 
1125
- var i = 0,
1126
- numLabels = labels.length;
930
+ const numLabels = labels.length;
1127
931
 
1128
- if (numLabels !== _this5.pagesCount) {
1129
- console.error('The number of Page Labels does not match ' + 'the number of pages in the document.');
932
+ if (numLabels !== this.pagesCount) {
933
+ console.error("The number of Page Labels does not match " + "the number of pages in the document.");
1130
934
  return;
1131
935
  }
1132
936
 
937
+ let i = 0;
938
+
1133
939
  while (i < numLabels && labels[i] === (i + 1).toString()) {
1134
940
  i++;
1135
941
  }
@@ -1140,107 +946,145 @@ var PDFViewerApplication = {
1140
946
 
1141
947
  pdfViewer.setPageLabels(labels);
1142
948
  pdfThumbnailViewer.setPageLabels(labels);
1143
-
1144
- _this5.toolbar.setPagesCount(pdfDocument.numPages, true);
1145
-
1146
- _this5.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
949
+ this.toolbar.setPagesCount(pdfDocument.numPages, true);
950
+ this.toolbar.setPageNumber(pdfViewer.currentPageNumber, pdfViewer.currentPageLabel);
1147
951
  });
1148
- pagesPromise.then(function () {
1149
- if (!_this5.supportsPrinting) {
1150
- return;
1151
- }
952
+ pagesPromise.then(async () => {
953
+ const [openAction, javaScript] = await Promise.all([openActionPromise, pdfDocument.getJavaScript()]);
954
+ let triggerAutoPrint = false;
1152
955
 
1153
- pdfDocument.getJavaScript().then(function (javaScript) {
1154
- if (!javaScript) {
1155
- return;
1156
- }
956
+ if (openAction && openAction.action === "Print") {
957
+ triggerAutoPrint = true;
958
+ }
1157
959
 
1158
- javaScript.some(function (js) {
960
+ if (javaScript) {
961
+ javaScript.some(js => {
1159
962
  if (!js) {
1160
963
  return false;
1161
964
  }
1162
965
 
1163
- console.warn('Warning: JavaScript is not supported');
1164
-
1165
- _this5.fallback(_pdf.UNSUPPORTED_FEATURES.javaScript);
1166
-
966
+ console.warn("Warning: JavaScript is not supported");
967
+ this.fallback(_pdf.UNSUPPORTED_FEATURES.javaScript);
1167
968
  return true;
1168
969
  });
1169
- var regex = /\bprint\s*\(/;
1170
-
1171
- for (var i = 0, ii = javaScript.length; i < ii; i++) {
1172
- var js = javaScript[i];
1173
970
 
1174
- if (js && regex.test(js)) {
1175
- setTimeout(function () {
1176
- window.print();
1177
- });
1178
- return;
971
+ if (!triggerAutoPrint) {
972
+ for (const js of javaScript) {
973
+ if (js && _ui_utils.AutoPrintRegExp.test(js)) {
974
+ triggerAutoPrint = true;
975
+ break;
976
+ }
1179
977
  }
1180
978
  }
1181
- });
979
+ }
980
+
981
+ if (!this.supportsPrinting) {
982
+ return;
983
+ }
984
+
985
+ if (triggerAutoPrint) {
986
+ setTimeout(function () {
987
+ window.print();
988
+ });
989
+ }
1182
990
  });
1183
- onePageRendered.then(function () {
1184
- pdfDocument.getOutline().then(function (outline) {
1185
- _this5.pdfOutlineViewer.render({
1186
- outline: outline
991
+ onePageRendered.then(() => {
992
+ pdfDocument.getOutline().then(outline => {
993
+ this.pdfOutlineViewer.render({
994
+ outline
1187
995
  });
1188
996
  });
1189
- pdfDocument.getAttachments().then(function (attachments) {
1190
- _this5.pdfAttachmentViewer.render({
1191
- attachments: attachments
997
+ pdfDocument.getAttachments().then(attachments => {
998
+ this.pdfAttachmentViewer.render({
999
+ attachments
1192
1000
  });
1193
1001
  });
1194
1002
  });
1195
- pdfDocument.getMetadata().then(function (_ref5) {
1196
- var info = _ref5.info,
1197
- metadata = _ref5.metadata,
1198
- contentDispositionFilename = _ref5.contentDispositionFilename;
1199
- _this5.documentInfo = info;
1200
- _this5.metadata = metadata;
1201
- _this5.contentDispositionFilename = contentDispositionFilename;
1202
- console.log('PDF ' + pdfDocument.fingerprint + ' [' + info.PDFFormatVersion + ' ' + (info.Producer || '-').trim() + ' / ' + (info.Creator || '-').trim() + ']' + ' (PDF.js: ' + (_pdf.version || '-') + (_app_options.AppOptions.get('enableWebGL') ? ' [WebGL]' : '') + ')');
1203
- var pdfTitle;
1204
-
1205
- if (metadata && metadata.has('dc:title')) {
1206
- var title = metadata.get('dc:title');
1207
-
1208
- if (title !== 'Untitled') {
1209
- pdfTitle = title;
1210
- }
1003
+ pdfDocument.getMetadata().then(({
1004
+ info,
1005
+ metadata,
1006
+ contentDispositionFilename
1007
+ }) => {
1008
+ this.documentInfo = info;
1009
+ this.metadata = metadata;
1010
+ this.contentDispositionFilename = contentDispositionFilename;
1011
+ console.log("PDF " + pdfDocument.fingerprint + " [" + info.PDFFormatVersion + " " + (info.Producer || "-").trim() + " / " + (info.Creator || "-").trim() + "]" + " (PDF.js: " + (_pdf.version || "-") + (_app_options.AppOptions.get("enableWebGL") ? " [WebGL]" : "") + ")");
1012
+ let pdfTitle;
1013
+ const infoTitle = info && info["Title"];
1014
+
1015
+ if (infoTitle) {
1016
+ pdfTitle = infoTitle;
1211
1017
  }
1212
1018
 
1213
- if (!pdfTitle && info && info['Title']) {
1214
- pdfTitle = info['Title'];
1019
+ const metadataTitle = metadata && metadata.get("dc:title");
1020
+
1021
+ if (metadataTitle) {
1022
+ if (metadataTitle !== "Untitled" && !/[\uFFF0-\uFFFF]/g.test(metadataTitle)) {
1023
+ pdfTitle = metadataTitle;
1024
+ }
1215
1025
  }
1216
1026
 
1217
1027
  if (pdfTitle) {
1218
- _this5.setTitle("".concat(pdfTitle, " - ").concat(contentDispositionFilename || document.title));
1028
+ this.setTitle(`${pdfTitle} - ${contentDispositionFilename || document.title}`);
1219
1029
  } else if (contentDispositionFilename) {
1220
- _this5.setTitle(contentDispositionFilename);
1030
+ this.setTitle(contentDispositionFilename);
1221
1031
  }
1222
1032
 
1223
1033
  if (info.IsAcroFormPresent) {
1224
- console.warn('Warning: AcroForm/XFA is not supported');
1034
+ console.warn("Warning: AcroForm/XFA is not supported");
1035
+ this.fallback(_pdf.UNSUPPORTED_FEATURES.forms);
1036
+ }
1037
+
1038
+ let versionId = "other";
1039
+ const KNOWN_VERSIONS = ["1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "2.0", "2.1", "2.2", "2.3"];
1225
1040
 
1226
- _this5.fallback(_pdf.UNSUPPORTED_FEATURES.forms);
1041
+ if (KNOWN_VERSIONS.includes(info.PDFFormatVersion)) {
1042
+ versionId = `v${info.PDFFormatVersion.replace(".", "_")}`;
1043
+ }
1044
+
1045
+ let generatorId = "other";
1046
+ const KNOWN_GENERATORS = ["acrobat distiller", "acrobat pdfwriter", "adobe livecycle", "adobe pdf library", "adobe photoshop", "ghostscript", "tcpdf", "cairo", "dvipdfm", "dvips", "pdftex", "pdfkit", "itext", "prince", "quarkxpress", "mac os x", "microsoft", "openoffice", "oracle", "luradocument", "pdf-xchange", "antenna house", "aspose.cells", "fpdf"];
1047
+
1048
+ if (info.Producer) {
1049
+ const producer = info.Producer.toLowerCase();
1050
+ KNOWN_GENERATORS.some(function (generator) {
1051
+ if (!producer.includes(generator)) {
1052
+ return false;
1053
+ }
1054
+
1055
+ generatorId = generator.replace(/[ .\-]/g, "_");
1056
+ return true;
1057
+ });
1058
+ }
1059
+
1060
+ let formType = null;
1061
+
1062
+ if (info.IsAcroFormPresent) {
1063
+ formType = info.IsXFAPresent ? "xfa" : "acroform";
1227
1064
  }
1065
+
1066
+ this.externalServices.reportTelemetry({
1067
+ type: "documentInfo",
1068
+ version: versionId,
1069
+ generator: generatorId,
1070
+ formType
1071
+ });
1228
1072
  });
1229
1073
  },
1230
- _initializePdfHistory: function _initializePdfHistory(_ref6) {
1231
- var fingerprint = _ref6.fingerprint,
1232
- viewOnLoad = _ref6.viewOnLoad,
1233
- _ref6$initialDest = _ref6.initialDest,
1234
- initialDest = _ref6$initialDest === void 0 ? null : _ref6$initialDest;
1235
1074
 
1236
- if (_app_options.AppOptions.get('disableHistory') || this.isViewerEmbedded) {
1075
+ _initializePdfHistory({
1076
+ fingerprint,
1077
+ viewOnLoad,
1078
+ initialDest = null
1079
+ }) {
1080
+ if (_app_options.AppOptions.get("disableHistory") || this.isViewerEmbedded) {
1237
1081
  return;
1238
1082
  }
1239
1083
 
1240
1084
  this.pdfHistory.initialize({
1241
- fingerprint: fingerprint,
1085
+ fingerprint,
1242
1086
  resetHistory: viewOnLoad === ViewOnLoad.INITIAL,
1243
- updateUrl: _app_options.AppOptions.get('historyUpdateUrl')
1087
+ updateUrl: _app_options.AppOptions.get("historyUpdateUrl")
1244
1088
  });
1245
1089
 
1246
1090
  if (this.pdfHistory.initialBookmark) {
@@ -1256,28 +1100,26 @@ var PDFViewerApplication = {
1256
1100
  });
1257
1101
  }
1258
1102
  },
1259
- setInitialView: function setInitialView(storedHash) {
1260
- var _this6 = this;
1261
-
1262
- var _ref7 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
1263
- rotation = _ref7.rotation,
1264
- sidebarView = _ref7.sidebarView,
1265
- scrollMode = _ref7.scrollMode,
1266
- spreadMode = _ref7.spreadMode;
1267
1103
 
1268
- var setRotation = function setRotation(angle) {
1104
+ setInitialView(storedHash, {
1105
+ rotation,
1106
+ sidebarView,
1107
+ scrollMode,
1108
+ spreadMode
1109
+ } = {}) {
1110
+ const setRotation = angle => {
1269
1111
  if ((0, _ui_utils.isValidRotation)(angle)) {
1270
- _this6.pdfViewer.pagesRotation = angle;
1112
+ this.pdfViewer.pagesRotation = angle;
1271
1113
  }
1272
1114
  };
1273
1115
 
1274
- var setViewerModes = function setViewerModes(scroll, spread) {
1116
+ const setViewerModes = (scroll, spread) => {
1275
1117
  if ((0, _ui_utils.isValidScrollMode)(scroll)) {
1276
- _this6.pdfViewer.scrollMode = scroll;
1118
+ this.pdfViewer.scrollMode = scroll;
1277
1119
  }
1278
1120
 
1279
1121
  if ((0, _ui_utils.isValidSpreadMode)(spread)) {
1280
- _this6.pdfViewer.spreadMode = spread;
1122
+ this.pdfViewer.spreadMode = spread;
1281
1123
  }
1282
1124
  };
1283
1125
 
@@ -1302,7 +1144,8 @@ var PDFViewerApplication = {
1302
1144
  this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
1303
1145
  }
1304
1146
  },
1305
- cleanup: function cleanup() {
1147
+
1148
+ cleanup() {
1306
1149
  if (!this.pdfDocument) {
1307
1150
  return;
1308
1151
  }
@@ -1314,40 +1157,44 @@ var PDFViewerApplication = {
1314
1157
  this.pdfDocument.cleanup();
1315
1158
  }
1316
1159
  },
1317
- forceRendering: function forceRendering() {
1160
+
1161
+ forceRendering() {
1318
1162
  this.pdfRenderingQueue.printing = this.printing;
1319
1163
  this.pdfRenderingQueue.isThumbnailViewEnabled = this.pdfSidebar.isThumbnailViewVisible;
1320
1164
  this.pdfRenderingQueue.renderHighestPriority();
1321
1165
  },
1322
- beforePrint: function beforePrint() {
1323
- var _this7 = this;
1324
1166
 
1167
+ beforePrint() {
1325
1168
  if (this.printService) {
1326
1169
  return;
1327
1170
  }
1328
1171
 
1329
1172
  if (!this.supportsPrinting) {
1330
- this.l10n.get('printing_not_supported', null, 'Warning: Printing is not fully supported by ' + 'this browser.').then(function (printMessage) {
1331
- _this7.error(printMessage);
1173
+ this.l10n.get("printing_not_supported", null, "Warning: Printing is not fully supported by this browser.").then(printMessage => {
1174
+ this.error(printMessage);
1332
1175
  });
1333
1176
  return;
1334
1177
  }
1335
1178
 
1336
1179
  if (!this.pdfViewer.pageViewsReady) {
1337
- this.l10n.get('printing_not_ready', null, 'Warning: The PDF is not fully loaded for printing.').then(function (notReadyMessage) {
1180
+ this.l10n.get("printing_not_ready", null, "Warning: The PDF is not fully loaded for printing.").then(notReadyMessage => {
1338
1181
  window.alert(notReadyMessage);
1339
1182
  });
1340
1183
  return;
1341
1184
  }
1342
1185
 
1343
- var pagesOverview = this.pdfViewer.getPagesOverview();
1344
- var printContainer = this.appConfig.printContainer;
1345
- var printService = PDFPrintServiceFactory.instance.createPrintService(this.pdfDocument, pagesOverview, printContainer, this.l10n);
1186
+ const pagesOverview = this.pdfViewer.getPagesOverview();
1187
+ const printContainer = this.appConfig.printContainer;
1188
+ const printService = PDFPrintServiceFactory.instance.createPrintService(this.pdfDocument, pagesOverview, printContainer, this.l10n);
1346
1189
  this.printService = printService;
1347
1190
  this.forceRendering();
1348
1191
  printService.layout();
1192
+ this.externalServices.reportTelemetry({
1193
+ type: "print"
1194
+ });
1349
1195
  },
1350
- afterPrint: function afterPrint() {
1196
+
1197
+ afterPrint() {
1351
1198
  if (this.printService) {
1352
1199
  this.printService.destroy();
1353
1200
  this.printService = null;
@@ -1355,196 +1202,287 @@ var PDFViewerApplication = {
1355
1202
 
1356
1203
  this.forceRendering();
1357
1204
  },
1358
- rotatePages: function rotatePages(delta) {
1205
+
1206
+ rotatePages(delta) {
1359
1207
  if (!this.pdfDocument) {
1360
1208
  return;
1361
1209
  }
1362
1210
 
1363
- var newRotation = (this.pdfViewer.pagesRotation + 360 + delta) % 360;
1211
+ const newRotation = (this.pdfViewer.pagesRotation + 360 + delta) % 360;
1364
1212
  this.pdfViewer.pagesRotation = newRotation;
1365
1213
  },
1366
- requestPresentationMode: function requestPresentationMode() {
1214
+
1215
+ requestPresentationMode() {
1367
1216
  if (!this.pdfPresentationMode) {
1368
1217
  return;
1369
1218
  }
1370
1219
 
1371
1220
  this.pdfPresentationMode.request();
1372
1221
  },
1373
- bindEvents: function bindEvents() {
1374
- var eventBus = this.eventBus,
1375
- _boundEvents = this._boundEvents;
1222
+
1223
+ bindEvents() {
1224
+ const {
1225
+ eventBus,
1226
+ _boundEvents
1227
+ } = this;
1376
1228
  _boundEvents.beforePrint = this.beforePrint.bind(this);
1377
1229
  _boundEvents.afterPrint = this.afterPrint.bind(this);
1378
- eventBus.on('resize', webViewerResize);
1379
- eventBus.on('hashchange', webViewerHashchange);
1380
- eventBus.on('beforeprint', _boundEvents.beforePrint);
1381
- eventBus.on('afterprint', _boundEvents.afterPrint);
1382
- eventBus.on('pagerendered', webViewerPageRendered);
1383
- eventBus.on('textlayerrendered', webViewerTextLayerRendered);
1384
- eventBus.on('updateviewarea', webViewerUpdateViewarea);
1385
- eventBus.on('pagechanging', webViewerPageChanging);
1386
- eventBus.on('scalechanging', webViewerScaleChanging);
1387
- eventBus.on('rotationchanging', webViewerRotationChanging);
1388
- eventBus.on('sidebarviewchanged', webViewerSidebarViewChanged);
1389
- eventBus.on('pagemode', webViewerPageMode);
1390
- eventBus.on('namedaction', webViewerNamedAction);
1391
- eventBus.on('presentationmodechanged', webViewerPresentationModeChanged);
1392
- eventBus.on('presentationmode', webViewerPresentationMode);
1393
- eventBus.on('openfile', webViewerOpenFile);
1394
- eventBus.on('print', webViewerPrint);
1395
- eventBus.on('download', webViewerDownload);
1396
- eventBus.on('firstpage', webViewerFirstPage);
1397
- eventBus.on('lastpage', webViewerLastPage);
1398
- eventBus.on('nextpage', webViewerNextPage);
1399
- eventBus.on('previouspage', webViewerPreviousPage);
1400
- eventBus.on('zoomin', webViewerZoomIn);
1401
- eventBus.on('zoomout', webViewerZoomOut);
1402
- eventBus.on('zoomreset', webViewerZoomReset);
1403
- eventBus.on('pagenumberchanged', webViewerPageNumberChanged);
1404
- eventBus.on('scalechanged', webViewerScaleChanged);
1405
- eventBus.on('rotatecw', webViewerRotateCw);
1406
- eventBus.on('rotateccw', webViewerRotateCcw);
1407
- eventBus.on('switchscrollmode', webViewerSwitchScrollMode);
1408
- eventBus.on('scrollmodechanged', webViewerScrollModeChanged);
1409
- eventBus.on('switchspreadmode', webViewerSwitchSpreadMode);
1410
- eventBus.on('spreadmodechanged', webViewerSpreadModeChanged);
1411
- eventBus.on('documentproperties', webViewerDocumentProperties);
1412
- eventBus.on('find', webViewerFind);
1413
- eventBus.on('findfromurlhash', webViewerFindFromUrlHash);
1414
- eventBus.on('updatefindmatchescount', webViewerUpdateFindMatchesCount);
1415
- eventBus.on('updatefindcontrolstate', webViewerUpdateFindControlState);
1416
- eventBus.on('fileinputchange', webViewerFileInputChange);
1230
+
1231
+ eventBus._on("resize", webViewerResize);
1232
+
1233
+ eventBus._on("hashchange", webViewerHashchange);
1234
+
1235
+ eventBus._on("beforeprint", _boundEvents.beforePrint);
1236
+
1237
+ eventBus._on("afterprint", _boundEvents.afterPrint);
1238
+
1239
+ eventBus._on("pagerendered", webViewerPageRendered);
1240
+
1241
+ eventBus._on("updateviewarea", webViewerUpdateViewarea);
1242
+
1243
+ eventBus._on("pagechanging", webViewerPageChanging);
1244
+
1245
+ eventBus._on("scalechanging", webViewerScaleChanging);
1246
+
1247
+ eventBus._on("rotationchanging", webViewerRotationChanging);
1248
+
1249
+ eventBus._on("sidebarviewchanged", webViewerSidebarViewChanged);
1250
+
1251
+ eventBus._on("pagemode", webViewerPageMode);
1252
+
1253
+ eventBus._on("namedaction", webViewerNamedAction);
1254
+
1255
+ eventBus._on("presentationmodechanged", webViewerPresentationModeChanged);
1256
+
1257
+ eventBus._on("presentationmode", webViewerPresentationMode);
1258
+
1259
+ eventBus._on("print", webViewerPrint);
1260
+
1261
+ eventBus._on("download", webViewerDownload);
1262
+
1263
+ eventBus._on("firstpage", webViewerFirstPage);
1264
+
1265
+ eventBus._on("lastpage", webViewerLastPage);
1266
+
1267
+ eventBus._on("nextpage", webViewerNextPage);
1268
+
1269
+ eventBus._on("previouspage", webViewerPreviousPage);
1270
+
1271
+ eventBus._on("zoomin", webViewerZoomIn);
1272
+
1273
+ eventBus._on("zoomout", webViewerZoomOut);
1274
+
1275
+ eventBus._on("zoomreset", webViewerZoomReset);
1276
+
1277
+ eventBus._on("pagenumberchanged", webViewerPageNumberChanged);
1278
+
1279
+ eventBus._on("scalechanged", webViewerScaleChanged);
1280
+
1281
+ eventBus._on("rotatecw", webViewerRotateCw);
1282
+
1283
+ eventBus._on("rotateccw", webViewerRotateCcw);
1284
+
1285
+ eventBus._on("switchscrollmode", webViewerSwitchScrollMode);
1286
+
1287
+ eventBus._on("scrollmodechanged", webViewerScrollModeChanged);
1288
+
1289
+ eventBus._on("switchspreadmode", webViewerSwitchSpreadMode);
1290
+
1291
+ eventBus._on("spreadmodechanged", webViewerSpreadModeChanged);
1292
+
1293
+ eventBus._on("documentproperties", webViewerDocumentProperties);
1294
+
1295
+ eventBus._on("find", webViewerFind);
1296
+
1297
+ eventBus._on("findfromurlhash", webViewerFindFromUrlHash);
1298
+
1299
+ eventBus._on("updatefindmatchescount", webViewerUpdateFindMatchesCount);
1300
+
1301
+ eventBus._on("updatefindcontrolstate", webViewerUpdateFindControlState);
1302
+
1303
+ eventBus._on("fileinputchange", webViewerFileInputChange);
1304
+
1305
+ eventBus._on("openfile", webViewerOpenFile);
1417
1306
  },
1418
- bindWindowEvents: function bindWindowEvents() {
1419
- var eventBus = this.eventBus,
1420
- _boundEvents = this._boundEvents;
1421
1307
 
1422
- _boundEvents.windowResize = function () {
1423
- eventBus.dispatch('resize', {
1308
+ bindWindowEvents() {
1309
+ const {
1310
+ eventBus,
1311
+ _boundEvents
1312
+ } = this;
1313
+
1314
+ _boundEvents.windowResize = () => {
1315
+ eventBus.dispatch("resize", {
1424
1316
  source: window
1425
1317
  });
1426
1318
  };
1427
1319
 
1428
- _boundEvents.windowHashChange = function () {
1429
- eventBus.dispatch('hashchange', {
1320
+ _boundEvents.windowHashChange = () => {
1321
+ eventBus.dispatch("hashchange", {
1430
1322
  source: window,
1431
1323
  hash: document.location.hash.substring(1)
1432
1324
  });
1433
1325
  };
1434
1326
 
1435
- _boundEvents.windowBeforePrint = function () {
1436
- eventBus.dispatch('beforeprint', {
1327
+ _boundEvents.windowBeforePrint = () => {
1328
+ eventBus.dispatch("beforeprint", {
1437
1329
  source: window
1438
1330
  });
1439
1331
  };
1440
1332
 
1441
- _boundEvents.windowAfterPrint = function () {
1442
- eventBus.dispatch('afterprint', {
1333
+ _boundEvents.windowAfterPrint = () => {
1334
+ eventBus.dispatch("afterprint", {
1443
1335
  source: window
1444
1336
  });
1445
1337
  };
1446
1338
 
1447
- window.addEventListener('visibilitychange', webViewerVisibilityChange);
1448
- window.addEventListener('wheel', webViewerWheel, {
1339
+ window.addEventListener("visibilitychange", webViewerVisibilityChange);
1340
+ window.addEventListener("wheel", webViewerWheel, {
1449
1341
  passive: false
1450
1342
  });
1451
- window.addEventListener('click', webViewerClick);
1452
- window.addEventListener('keydown', webViewerKeyDown);
1453
- window.addEventListener('resize', _boundEvents.windowResize);
1454
- window.addEventListener('hashchange', _boundEvents.windowHashChange);
1455
- window.addEventListener('beforeprint', _boundEvents.windowBeforePrint);
1456
- window.addEventListener('afterprint', _boundEvents.windowAfterPrint);
1343
+ window.addEventListener("click", webViewerClick);
1344
+ window.addEventListener("keydown", webViewerKeyDown);
1345
+ window.addEventListener("resize", _boundEvents.windowResize);
1346
+ window.addEventListener("hashchange", _boundEvents.windowHashChange);
1347
+ window.addEventListener("beforeprint", _boundEvents.windowBeforePrint);
1348
+ window.addEventListener("afterprint", _boundEvents.windowAfterPrint);
1457
1349
  },
1458
- unbindEvents: function unbindEvents() {
1459
- var eventBus = this.eventBus,
1460
- _boundEvents = this._boundEvents;
1461
- eventBus.off('resize', webViewerResize);
1462
- eventBus.off('hashchange', webViewerHashchange);
1463
- eventBus.off('beforeprint', _boundEvents.beforePrint);
1464
- eventBus.off('afterprint', _boundEvents.afterPrint);
1465
- eventBus.off('pagerendered', webViewerPageRendered);
1466
- eventBus.off('textlayerrendered', webViewerTextLayerRendered);
1467
- eventBus.off('updateviewarea', webViewerUpdateViewarea);
1468
- eventBus.off('pagechanging', webViewerPageChanging);
1469
- eventBus.off('scalechanging', webViewerScaleChanging);
1470
- eventBus.off('rotationchanging', webViewerRotationChanging);
1471
- eventBus.off('sidebarviewchanged', webViewerSidebarViewChanged);
1472
- eventBus.off('pagemode', webViewerPageMode);
1473
- eventBus.off('namedaction', webViewerNamedAction);
1474
- eventBus.off('presentationmodechanged', webViewerPresentationModeChanged);
1475
- eventBus.off('presentationmode', webViewerPresentationMode);
1476
- eventBus.off('openfile', webViewerOpenFile);
1477
- eventBus.off('print', webViewerPrint);
1478
- eventBus.off('download', webViewerDownload);
1479
- eventBus.off('firstpage', webViewerFirstPage);
1480
- eventBus.off('lastpage', webViewerLastPage);
1481
- eventBus.off('nextpage', webViewerNextPage);
1482
- eventBus.off('previouspage', webViewerPreviousPage);
1483
- eventBus.off('zoomin', webViewerZoomIn);
1484
- eventBus.off('zoomout', webViewerZoomOut);
1485
- eventBus.off('zoomreset', webViewerZoomReset);
1486
- eventBus.off('pagenumberchanged', webViewerPageNumberChanged);
1487
- eventBus.off('scalechanged', webViewerScaleChanged);
1488
- eventBus.off('rotatecw', webViewerRotateCw);
1489
- eventBus.off('rotateccw', webViewerRotateCcw);
1490
- eventBus.off('switchscrollmode', webViewerSwitchScrollMode);
1491
- eventBus.off('scrollmodechanged', webViewerScrollModeChanged);
1492
- eventBus.off('switchspreadmode', webViewerSwitchSpreadMode);
1493
- eventBus.off('spreadmodechanged', webViewerSpreadModeChanged);
1494
- eventBus.off('documentproperties', webViewerDocumentProperties);
1495
- eventBus.off('find', webViewerFind);
1496
- eventBus.off('findfromurlhash', webViewerFindFromUrlHash);
1497
- eventBus.off('updatefindmatchescount', webViewerUpdateFindMatchesCount);
1498
- eventBus.off('updatefindcontrolstate', webViewerUpdateFindControlState);
1499
- eventBus.off('fileinputchange', webViewerFileInputChange);
1350
+
1351
+ unbindEvents() {
1352
+ const {
1353
+ eventBus,
1354
+ _boundEvents
1355
+ } = this;
1356
+
1357
+ eventBus._off("resize", webViewerResize);
1358
+
1359
+ eventBus._off("hashchange", webViewerHashchange);
1360
+
1361
+ eventBus._off("beforeprint", _boundEvents.beforePrint);
1362
+
1363
+ eventBus._off("afterprint", _boundEvents.afterPrint);
1364
+
1365
+ eventBus._off("pagerendered", webViewerPageRendered);
1366
+
1367
+ eventBus._off("updateviewarea", webViewerUpdateViewarea);
1368
+
1369
+ eventBus._off("pagechanging", webViewerPageChanging);
1370
+
1371
+ eventBus._off("scalechanging", webViewerScaleChanging);
1372
+
1373
+ eventBus._off("rotationchanging", webViewerRotationChanging);
1374
+
1375
+ eventBus._off("sidebarviewchanged", webViewerSidebarViewChanged);
1376
+
1377
+ eventBus._off("pagemode", webViewerPageMode);
1378
+
1379
+ eventBus._off("namedaction", webViewerNamedAction);
1380
+
1381
+ eventBus._off("presentationmodechanged", webViewerPresentationModeChanged);
1382
+
1383
+ eventBus._off("presentationmode", webViewerPresentationMode);
1384
+
1385
+ eventBus._off("print", webViewerPrint);
1386
+
1387
+ eventBus._off("download", webViewerDownload);
1388
+
1389
+ eventBus._off("firstpage", webViewerFirstPage);
1390
+
1391
+ eventBus._off("lastpage", webViewerLastPage);
1392
+
1393
+ eventBus._off("nextpage", webViewerNextPage);
1394
+
1395
+ eventBus._off("previouspage", webViewerPreviousPage);
1396
+
1397
+ eventBus._off("zoomin", webViewerZoomIn);
1398
+
1399
+ eventBus._off("zoomout", webViewerZoomOut);
1400
+
1401
+ eventBus._off("zoomreset", webViewerZoomReset);
1402
+
1403
+ eventBus._off("pagenumberchanged", webViewerPageNumberChanged);
1404
+
1405
+ eventBus._off("scalechanged", webViewerScaleChanged);
1406
+
1407
+ eventBus._off("rotatecw", webViewerRotateCw);
1408
+
1409
+ eventBus._off("rotateccw", webViewerRotateCcw);
1410
+
1411
+ eventBus._off("switchscrollmode", webViewerSwitchScrollMode);
1412
+
1413
+ eventBus._off("scrollmodechanged", webViewerScrollModeChanged);
1414
+
1415
+ eventBus._off("switchspreadmode", webViewerSwitchSpreadMode);
1416
+
1417
+ eventBus._off("spreadmodechanged", webViewerSpreadModeChanged);
1418
+
1419
+ eventBus._off("documentproperties", webViewerDocumentProperties);
1420
+
1421
+ eventBus._off("find", webViewerFind);
1422
+
1423
+ eventBus._off("findfromurlhash", webViewerFindFromUrlHash);
1424
+
1425
+ eventBus._off("updatefindmatchescount", webViewerUpdateFindMatchesCount);
1426
+
1427
+ eventBus._off("updatefindcontrolstate", webViewerUpdateFindControlState);
1428
+
1429
+ eventBus._off("fileinputchange", webViewerFileInputChange);
1430
+
1431
+ eventBus._off("openfile", webViewerOpenFile);
1432
+
1500
1433
  _boundEvents.beforePrint = null;
1501
1434
  _boundEvents.afterPrint = null;
1502
1435
  },
1503
- unbindWindowEvents: function unbindWindowEvents() {
1504
- var _boundEvents = this._boundEvents;
1505
- window.removeEventListener('visibilitychange', webViewerVisibilityChange);
1506
- window.removeEventListener('wheel', webViewerWheel);
1507
- window.removeEventListener('click', webViewerClick);
1508
- window.removeEventListener('keydown', webViewerKeyDown);
1509
- window.removeEventListener('resize', _boundEvents.windowResize);
1510
- window.removeEventListener('hashchange', _boundEvents.windowHashChange);
1511
- window.removeEventListener('beforeprint', _boundEvents.windowBeforePrint);
1512
- window.removeEventListener('afterprint', _boundEvents.windowAfterPrint);
1436
+
1437
+ unbindWindowEvents() {
1438
+ const {
1439
+ _boundEvents
1440
+ } = this;
1441
+ window.removeEventListener("visibilitychange", webViewerVisibilityChange);
1442
+ window.removeEventListener("wheel", webViewerWheel);
1443
+ window.removeEventListener("click", webViewerClick);
1444
+ window.removeEventListener("keydown", webViewerKeyDown);
1445
+ window.removeEventListener("resize", _boundEvents.windowResize);
1446
+ window.removeEventListener("hashchange", _boundEvents.windowHashChange);
1447
+ window.removeEventListener("beforeprint", _boundEvents.windowBeforePrint);
1448
+ window.removeEventListener("afterprint", _boundEvents.windowAfterPrint);
1513
1449
  _boundEvents.windowResize = null;
1514
1450
  _boundEvents.windowHashChange = null;
1515
1451
  _boundEvents.windowBeforePrint = null;
1516
1452
  _boundEvents.windowAfterPrint = null;
1517
1453
  }
1454
+
1518
1455
  };
1519
1456
  exports.PDFViewerApplication = PDFViewerApplication;
1520
- var validateFileURL;
1457
+ let validateFileURL;
1521
1458
  {
1522
- var HOSTED_VIEWER_ORIGINS = ['null', 'http://mozilla.github.io', 'https://mozilla.github.io'];
1459
+ const HOSTED_VIEWER_ORIGINS = ["null", "http://mozilla.github.io", "https://mozilla.github.io"];
1523
1460
 
1524
- validateFileURL = function validateFileURL(file) {
1461
+ validateFileURL = function (file) {
1525
1462
  if (file === undefined) {
1526
1463
  return;
1527
1464
  }
1528
1465
 
1529
1466
  try {
1530
- var viewerOrigin = new URL(window.location.href).origin || 'null';
1467
+ const viewerOrigin = new URL(window.location.href).origin || "null";
1531
1468
 
1532
1469
  if (HOSTED_VIEWER_ORIGINS.includes(viewerOrigin)) {
1533
1470
  return;
1534
1471
  }
1535
1472
 
1536
- var _ref8 = new URL(file, window.location.href),
1537
- origin = _ref8.origin,
1538
- protocol = _ref8.protocol;
1473
+ const {
1474
+ origin,
1475
+ protocol
1476
+ } = new URL(file, window.location.href);
1539
1477
 
1540
- if (origin !== viewerOrigin && protocol !== 'blob:') {
1541
- throw new Error('file origin does not match viewer\'s');
1478
+ if (origin !== viewerOrigin && protocol !== "blob:") {
1479
+ throw new Error("file origin does not match viewer's");
1542
1480
  }
1543
1481
  } catch (ex) {
1544
- var message = ex && ex.message;
1545
- PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while loading the PDF.').then(function (loadingErrorMessage) {
1482
+ const message = ex && ex.message;
1483
+ PDFViewerApplication.l10n.get("loading_error", null, "An error occurred while loading the PDF.").then(loadingErrorMessage => {
1546
1484
  PDFViewerApplication.error(loadingErrorMessage, {
1547
- message: message
1485
+ message
1548
1486
  });
1549
1487
  });
1550
1488
  throw ex;
@@ -1552,93 +1490,100 @@ var validateFileURL;
1552
1490
  };
1553
1491
  }
1554
1492
 
1555
- function loadFakeWorker() {
1493
+ async function loadFakeWorker() {
1556
1494
  if (!_pdf.GlobalWorkerOptions.workerSrc) {
1557
- _pdf.GlobalWorkerOptions.workerSrc = _app_options.AppOptions.get('workerSrc');
1495
+ _pdf.GlobalWorkerOptions.workerSrc = _app_options.AppOptions.get("workerSrc");
1558
1496
  }
1559
1497
 
1560
1498
  return (0, _pdf.loadScript)(_pdf.PDFWorker.getWorkerSrc());
1561
1499
  }
1562
1500
 
1563
1501
  function loadAndEnablePDFBug(enabledTabs) {
1564
- var appConfig = PDFViewerApplication.appConfig;
1502
+ const appConfig = PDFViewerApplication.appConfig;
1565
1503
  return (0, _pdf.loadScript)(appConfig.debuggerScriptPath).then(function () {
1566
1504
  PDFBug.enable(enabledTabs);
1567
1505
  PDFBug.init({
1568
- OPS: _pdf.OPS,
1569
- createObjectURL: _pdf.createObjectURL
1506
+ OPS: _pdf.OPS
1570
1507
  }, appConfig.mainContainer);
1571
1508
  });
1572
1509
  }
1573
1510
 
1574
1511
  function webViewerInitialized() {
1575
- var appConfig = PDFViewerApplication.appConfig;
1576
- var file;
1577
- var queryString = document.location.search.substring(1);
1578
- var params = (0, _ui_utils.parseQueryString)(queryString);
1579
- file = 'file' in params ? params.file : _app_options.AppOptions.get('defaultUrl');
1512
+ const appConfig = PDFViewerApplication.appConfig;
1513
+ let file;
1514
+ const queryString = document.location.search.substring(1);
1515
+ const params = (0, _ui_utils.parseQueryString)(queryString);
1516
+ file = "file" in params ? params.file : _app_options.AppOptions.get("defaultUrl");
1580
1517
  validateFileURL(file);
1581
- var fileInput = document.createElement('input');
1518
+ const fileInput = document.createElement("input");
1582
1519
  fileInput.id = appConfig.openFileInputName;
1583
- fileInput.className = 'fileInput';
1584
- fileInput.setAttribute('type', 'file');
1520
+ fileInput.className = "fileInput";
1521
+ fileInput.setAttribute("type", "file");
1585
1522
  fileInput.oncontextmenu = _ui_utils.noContextMenuHandler;
1586
1523
  document.body.appendChild(fileInput);
1587
1524
 
1588
1525
  if (!window.File || !window.FileReader || !window.FileList || !window.Blob) {
1589
- appConfig.toolbar.openFile.setAttribute('hidden', 'true');
1590
- appConfig.secondaryToolbar.openFileButton.setAttribute('hidden', 'true');
1526
+ appConfig.toolbar.openFile.setAttribute("hidden", "true");
1527
+ appConfig.secondaryToolbar.openFileButton.setAttribute("hidden", "true");
1591
1528
  } else {
1592
1529
  fileInput.value = null;
1593
1530
  }
1594
1531
 
1595
- fileInput.addEventListener('change', function (evt) {
1596
- var files = evt.target.files;
1532
+ fileInput.addEventListener("change", function (evt) {
1533
+ const files = evt.target.files;
1597
1534
 
1598
1535
  if (!files || files.length === 0) {
1599
1536
  return;
1600
1537
  }
1601
1538
 
1602
- PDFViewerApplication.eventBus.dispatch('fileinputchange', {
1539
+ PDFViewerApplication.eventBus.dispatch("fileinputchange", {
1603
1540
  source: this,
1604
1541
  fileInput: evt.target
1605
1542
  });
1606
1543
  });
1607
- appConfig.mainContainer.addEventListener('dragover', function (evt) {
1544
+ appConfig.mainContainer.addEventListener("dragover", function (evt) {
1608
1545
  evt.preventDefault();
1609
- evt.dataTransfer.dropEffect = 'move';
1546
+ evt.dataTransfer.dropEffect = "move";
1610
1547
  });
1611
- appConfig.mainContainer.addEventListener('drop', function (evt) {
1548
+ appConfig.mainContainer.addEventListener("drop", function (evt) {
1612
1549
  evt.preventDefault();
1613
- var files = evt.dataTransfer.files;
1550
+ const files = evt.dataTransfer.files;
1614
1551
 
1615
1552
  if (!files || files.length === 0) {
1616
1553
  return;
1617
1554
  }
1618
1555
 
1619
- PDFViewerApplication.eventBus.dispatch('fileinputchange', {
1556
+ PDFViewerApplication.eventBus.dispatch("fileinputchange", {
1620
1557
  source: this,
1621
1558
  fileInput: evt.dataTransfer
1622
1559
  });
1623
1560
  });
1624
1561
 
1562
+ if (!PDFViewerApplication.supportsDocumentFonts) {
1563
+ _app_options.AppOptions.set("disableFontFace", true);
1564
+
1565
+ PDFViewerApplication.l10n.get("web_fonts_disabled", null, "Web fonts are disabled: unable to use embedded PDF fonts.").then(msg => {
1566
+ console.warn(msg);
1567
+ });
1568
+ }
1569
+
1625
1570
  if (!PDFViewerApplication.supportsPrinting) {
1626
- appConfig.toolbar.print.classList.add('hidden');
1627
- appConfig.secondaryToolbar.printButton.classList.add('hidden');
1571
+ appConfig.toolbar.print.classList.add("hidden");
1572
+ appConfig.secondaryToolbar.printButton.classList.add("hidden");
1628
1573
  }
1629
1574
 
1630
1575
  if (!PDFViewerApplication.supportsFullscreen) {
1631
- appConfig.toolbar.presentationModeButton.classList.add('hidden');
1632
- appConfig.secondaryToolbar.presentationModeButton.classList.add('hidden');
1576
+ appConfig.toolbar.presentationModeButton.classList.add("hidden");
1577
+ appConfig.secondaryToolbar.presentationModeButton.classList.add("hidden");
1633
1578
  }
1634
1579
 
1635
1580
  if (PDFViewerApplication.supportsIntegratedFind) {
1636
- appConfig.toolbar.viewFind.classList.add('hidden');
1581
+ appConfig.toolbar.viewFind.classList.add("hidden");
1637
1582
  }
1638
1583
 
1639
- appConfig.mainContainer.addEventListener('transitionend', function (evt) {
1584
+ appConfig.mainContainer.addEventListener("transitionend", function (evt) {
1640
1585
  if (evt.target === this) {
1641
- PDFViewerApplication.eventBus.dispatch('resize', {
1586
+ PDFViewerApplication.eventBus.dispatch("resize", {
1642
1587
  source: this
1643
1588
  });
1644
1589
  }
@@ -1647,25 +1592,25 @@ function webViewerInitialized() {
1647
1592
  try {
1648
1593
  webViewerOpenFileViaURL(file);
1649
1594
  } catch (reason) {
1650
- PDFViewerApplication.l10n.get('loading_error', null, 'An error occurred while loading the PDF.').then(function (msg) {
1595
+ PDFViewerApplication.l10n.get("loading_error", null, "An error occurred while loading the PDF.").then(msg => {
1651
1596
  PDFViewerApplication.error(msg, reason);
1652
1597
  });
1653
1598
  }
1654
1599
  }
1655
1600
 
1656
- var webViewerOpenFileViaURL;
1601
+ let webViewerOpenFileViaURL;
1657
1602
  {
1658
- webViewerOpenFileViaURL = function webViewerOpenFileViaURL(file) {
1659
- if (file && file.lastIndexOf('file:', 0) === 0) {
1603
+ webViewerOpenFileViaURL = function (file) {
1604
+ if (file && file.lastIndexOf("file:", 0) === 0) {
1660
1605
  PDFViewerApplication.setTitleUsingUrl(file);
1661
- var xhr = new XMLHttpRequest();
1606
+ const xhr = new XMLHttpRequest();
1662
1607
 
1663
1608
  xhr.onload = function () {
1664
1609
  PDFViewerApplication.open(new Uint8Array(xhr.response));
1665
1610
  };
1666
1611
 
1667
- xhr.open('GET', file);
1668
- xhr.responseType = 'arraybuffer';
1612
+ xhr.open("GET", file);
1613
+ xhr.responseType = "arraybuffer";
1669
1614
  xhr.send();
1670
1615
  return;
1671
1616
  }
@@ -1677,9 +1622,9 @@ var webViewerOpenFileViaURL;
1677
1622
  }
1678
1623
 
1679
1624
  function webViewerPageRendered(evt) {
1680
- var pageNumber = evt.pageNumber;
1681
- var pageIndex = pageNumber - 1;
1682
- var pageView = PDFViewerApplication.pdfViewer.getPageView(pageIndex);
1625
+ const pageNumber = evt.pageNumber;
1626
+ const pageIndex = pageNumber - 1;
1627
+ const pageView = PDFViewerApplication.pdfViewer.getPageView(pageIndex);
1683
1628
 
1684
1629
  if (pageNumber === PDFViewerApplication.page) {
1685
1630
  PDFViewerApplication.toolbar.updateLoadingIndicatorState(false);
@@ -1690,42 +1635,52 @@ function webViewerPageRendered(evt) {
1690
1635
  }
1691
1636
 
1692
1637
  if (PDFViewerApplication.pdfSidebar.isThumbnailViewVisible) {
1693
- var thumbnailView = PDFViewerApplication.pdfThumbnailViewer.getThumbnail(pageIndex);
1638
+ const thumbnailView = PDFViewerApplication.pdfThumbnailViewer.getThumbnail(pageIndex);
1694
1639
  thumbnailView.setImage(pageView);
1695
1640
  }
1696
1641
 
1697
- if (typeof Stats !== 'undefined' && Stats.enabled && pageView.stats) {
1642
+ if (typeof Stats !== "undefined" && Stats.enabled && pageView.stats) {
1698
1643
  Stats.add(pageNumber, pageView.stats);
1699
1644
  }
1700
1645
 
1701
1646
  if (pageView.error) {
1702
- PDFViewerApplication.l10n.get('rendering_error', null, 'An error occurred while rendering the page.').then(function (msg) {
1647
+ PDFViewerApplication.l10n.get("rendering_error", null, "An error occurred while rendering the page.").then(msg => {
1703
1648
  PDFViewerApplication.error(msg, pageView.error);
1704
1649
  });
1705
1650
  }
1706
- }
1707
1651
 
1708
- function webViewerTextLayerRendered(evt) {}
1652
+ PDFViewerApplication.externalServices.reportTelemetry({
1653
+ type: "pageInfo",
1654
+ timestamp: evt.timestamp
1655
+ });
1656
+ PDFViewerApplication.pdfDocument.getStats().then(function (stats) {
1657
+ PDFViewerApplication.externalServices.reportTelemetry({
1658
+ type: "documentStats",
1659
+ stats
1660
+ });
1661
+ });
1662
+ }
1709
1663
 
1710
- function webViewerPageMode(evt) {
1711
- var mode = evt.mode,
1712
- view;
1664
+ function webViewerPageMode({
1665
+ mode
1666
+ }) {
1667
+ let view;
1713
1668
 
1714
1669
  switch (mode) {
1715
- case 'thumbs':
1670
+ case "thumbs":
1716
1671
  view = _pdf_sidebar.SidebarView.THUMBS;
1717
1672
  break;
1718
1673
 
1719
- case 'bookmarks':
1720
- case 'outline':
1674
+ case "bookmarks":
1675
+ case "outline":
1721
1676
  view = _pdf_sidebar.SidebarView.OUTLINE;
1722
1677
  break;
1723
1678
 
1724
- case 'attachments':
1679
+ case "attachments":
1725
1680
  view = _pdf_sidebar.SidebarView.ATTACHMENTS;
1726
1681
  break;
1727
1682
 
1728
- case 'none':
1683
+ case "none":
1729
1684
  view = _pdf_sidebar.SidebarView.NONE;
1730
1685
  break;
1731
1686
 
@@ -1738,14 +1693,14 @@ function webViewerPageMode(evt) {
1738
1693
  }
1739
1694
 
1740
1695
  function webViewerNamedAction(evt) {
1741
- var action = evt.action;
1696
+ const action = evt.action;
1742
1697
 
1743
1698
  switch (action) {
1744
- case 'GoToPage':
1699
+ case "GoToPage":
1745
1700
  PDFViewerApplication.appConfig.toolbar.pageNumber.select();
1746
1701
  break;
1747
1702
 
1748
- case 'Find':
1703
+ case "Find":
1749
1704
  if (!PDFViewerApplication.supportsIntegratedFind) {
1750
1705
  PDFViewerApplication.findBar.toggle();
1751
1706
  }
@@ -1754,70 +1709,81 @@ function webViewerNamedAction(evt) {
1754
1709
  }
1755
1710
  }
1756
1711
 
1757
- function webViewerPresentationModeChanged(evt) {
1758
- var active = evt.active,
1759
- switchInProgress = evt.switchInProgress;
1760
- PDFViewerApplication.pdfViewer.presentationModeState = switchInProgress ? _ui_utils.PresentationModeState.CHANGING : active ? _ui_utils.PresentationModeState.FULLSCREEN : _ui_utils.PresentationModeState.NORMAL;
1712
+ function webViewerPresentationModeChanged({
1713
+ active,
1714
+ switchInProgress
1715
+ }) {
1716
+ let state = _ui_utils.PresentationModeState.NORMAL;
1717
+
1718
+ if (switchInProgress) {
1719
+ state = _ui_utils.PresentationModeState.CHANGING;
1720
+ } else if (active) {
1721
+ state = _ui_utils.PresentationModeState.FULLSCREEN;
1722
+ }
1723
+
1724
+ PDFViewerApplication.pdfViewer.presentationModeState = state;
1761
1725
  }
1762
1726
 
1763
1727
  function webViewerSidebarViewChanged(evt) {
1764
1728
  PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = PDFViewerApplication.pdfSidebar.isThumbnailViewVisible;
1765
- var store = PDFViewerApplication.store;
1729
+ const store = PDFViewerApplication.store;
1766
1730
 
1767
1731
  if (store && PDFViewerApplication.isInitialViewSet) {
1768
- store.set('sidebarView', evt.view)["catch"](function () {});
1732
+ store.set("sidebarView", evt.view).catch(function () {});
1769
1733
  }
1770
1734
  }
1771
1735
 
1772
1736
  function webViewerUpdateViewarea(evt) {
1773
- var location = evt.location,
1774
- store = PDFViewerApplication.store;
1737
+ const location = evt.location,
1738
+ store = PDFViewerApplication.store;
1775
1739
 
1776
1740
  if (store && PDFViewerApplication.isInitialViewSet) {
1777
1741
  store.setMultiple({
1778
- 'page': location.pageNumber,
1779
- 'zoom': location.scale,
1780
- 'scrollLeft': location.left,
1781
- 'scrollTop': location.top,
1782
- 'rotation': location.rotation
1783
- })["catch"](function () {});
1742
+ page: location.pageNumber,
1743
+ zoom: location.scale,
1744
+ scrollLeft: location.left,
1745
+ scrollTop: location.top,
1746
+ rotation: location.rotation
1747
+ }).catch(function () {});
1784
1748
  }
1785
1749
 
1786
- var href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
1750
+ const href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
1787
1751
  PDFViewerApplication.appConfig.toolbar.viewBookmark.href = href;
1788
1752
  PDFViewerApplication.appConfig.secondaryToolbar.viewBookmarkButton.href = href;
1789
- var currentPage = PDFViewerApplication.pdfViewer.getPageView(PDFViewerApplication.page - 1);
1790
- var loading = currentPage.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED;
1753
+ const currentPage = PDFViewerApplication.pdfViewer.getPageView(PDFViewerApplication.page - 1);
1754
+ const loading = currentPage.renderingState !== _pdf_rendering_queue.RenderingStates.FINISHED;
1791
1755
  PDFViewerApplication.toolbar.updateLoadingIndicatorState(loading);
1792
1756
  }
1793
1757
 
1794
1758
  function webViewerScrollModeChanged(evt) {
1795
- var store = PDFViewerApplication.store;
1759
+ const store = PDFViewerApplication.store;
1796
1760
 
1797
1761
  if (store && PDFViewerApplication.isInitialViewSet) {
1798
- store.set('scrollMode', evt.mode)["catch"](function () {});
1762
+ store.set("scrollMode", evt.mode).catch(function () {});
1799
1763
  }
1800
1764
  }
1801
1765
 
1802
1766
  function webViewerSpreadModeChanged(evt) {
1803
- var store = PDFViewerApplication.store;
1767
+ const store = PDFViewerApplication.store;
1804
1768
 
1805
1769
  if (store && PDFViewerApplication.isInitialViewSet) {
1806
- store.set('spreadMode', evt.mode)["catch"](function () {});
1770
+ store.set("spreadMode", evt.mode).catch(function () {});
1807
1771
  }
1808
1772
  }
1809
1773
 
1810
1774
  function webViewerResize() {
1811
- var pdfDocument = PDFViewerApplication.pdfDocument,
1812
- pdfViewer = PDFViewerApplication.pdfViewer;
1775
+ const {
1776
+ pdfDocument,
1777
+ pdfViewer
1778
+ } = PDFViewerApplication;
1813
1779
 
1814
1780
  if (!pdfDocument) {
1815
1781
  return;
1816
1782
  }
1817
1783
 
1818
- var currentScaleValue = pdfViewer.currentScaleValue;
1784
+ const currentScaleValue = pdfViewer.currentScaleValue;
1819
1785
 
1820
- if (currentScaleValue === 'auto' || currentScaleValue === 'page-fit' || currentScaleValue === 'page-width') {
1786
+ if (currentScaleValue === "auto" || currentScaleValue === "page-fit" || currentScaleValue === "page-width") {
1821
1787
  pdfViewer.currentScaleValue = currentScaleValue;
1822
1788
  }
1823
1789
 
@@ -1825,7 +1791,7 @@ function webViewerResize() {
1825
1791
  }
1826
1792
 
1827
1793
  function webViewerHashchange(evt) {
1828
- var hash = evt.hash;
1794
+ const hash = evt.hash;
1829
1795
 
1830
1796
  if (!hash) {
1831
1797
  return;
@@ -1838,21 +1804,21 @@ function webViewerHashchange(evt) {
1838
1804
  }
1839
1805
  }
1840
1806
 
1841
- var webViewerFileInputChange;
1807
+ let webViewerFileInputChange, webViewerOpenFile;
1842
1808
  {
1843
- webViewerFileInputChange = function webViewerFileInputChange(evt) {
1809
+ webViewerFileInputChange = function (evt) {
1844
1810
  if (PDFViewerApplication.pdfViewer && PDFViewerApplication.pdfViewer.isInPresentationMode) {
1845
1811
  return;
1846
1812
  }
1847
1813
 
1848
- var file = evt.fileInput.files[0];
1814
+ const file = evt.fileInput.files[0];
1849
1815
 
1850
- if (URL.createObjectURL && !_app_options.AppOptions.get('disableCreateObjectURL')) {
1851
- var url = URL.createObjectURL(file);
1816
+ if (URL.createObjectURL && !_app_options.AppOptions.get("disableCreateObjectURL")) {
1817
+ let url = URL.createObjectURL(file);
1852
1818
 
1853
1819
  if (file.name) {
1854
1820
  url = {
1855
- url: url,
1821
+ url,
1856
1822
  originalUrl: file.name
1857
1823
  };
1858
1824
  }
@@ -1860,21 +1826,26 @@ var webViewerFileInputChange;
1860
1826
  PDFViewerApplication.open(url);
1861
1827
  } else {
1862
1828
  PDFViewerApplication.setTitleUsingUrl(file.name);
1863
- var fileReader = new FileReader();
1829
+ const fileReader = new FileReader();
1864
1830
 
1865
- fileReader.onload = function webViewerChangeFileReaderOnload(evt) {
1866
- var buffer = evt.target.result;
1831
+ fileReader.onload = function webViewerChangeFileReaderOnload(event) {
1832
+ const buffer = event.target.result;
1867
1833
  PDFViewerApplication.open(new Uint8Array(buffer));
1868
1834
  };
1869
1835
 
1870
1836
  fileReader.readAsArrayBuffer(file);
1871
1837
  }
1872
1838
 
1873
- var appConfig = PDFViewerApplication.appConfig;
1874
- appConfig.toolbar.viewBookmark.setAttribute('hidden', 'true');
1875
- appConfig.secondaryToolbar.viewBookmarkButton.setAttribute('hidden', 'true');
1876
- appConfig.toolbar.download.setAttribute('hidden', 'true');
1877
- appConfig.secondaryToolbar.downloadButton.setAttribute('hidden', 'true');
1839
+ const appConfig = PDFViewerApplication.appConfig;
1840
+ appConfig.toolbar.viewBookmark.setAttribute("hidden", "true");
1841
+ appConfig.secondaryToolbar.viewBookmarkButton.setAttribute("hidden", "true");
1842
+ appConfig.toolbar.download.setAttribute("hidden", "true");
1843
+ appConfig.secondaryToolbar.downloadButton.setAttribute("hidden", "true");
1844
+ };
1845
+
1846
+ webViewerOpenFile = function (evt) {
1847
+ const openFileInputName = PDFViewerApplication.appConfig.openFileInputName;
1848
+ document.getElementById(openFileInputName).click();
1878
1849
  };
1879
1850
  }
1880
1851
 
@@ -1882,11 +1853,6 @@ function webViewerPresentationMode() {
1882
1853
  PDFViewerApplication.requestPresentationMode();
1883
1854
  }
1884
1855
 
1885
- function webViewerOpenFile() {
1886
- var openFileInputName = PDFViewerApplication.appConfig.openFileInputName;
1887
- document.getElementById(openFileInputName).click();
1888
- }
1889
-
1890
1856
  function webViewerPrint() {
1891
1857
  window.print();
1892
1858
  }
@@ -1928,9 +1894,9 @@ function webViewerZoomReset() {
1928
1894
  }
1929
1895
 
1930
1896
  function webViewerPageNumberChanged(evt) {
1931
- var pdfViewer = PDFViewerApplication.pdfViewer;
1897
+ const pdfViewer = PDFViewerApplication.pdfViewer;
1932
1898
 
1933
- if (evt.value !== '') {
1899
+ if (evt.value !== "") {
1934
1900
  pdfViewer.currentPageLabel = evt.value;
1935
1901
  }
1936
1902
 
@@ -1964,7 +1930,7 @@ function webViewerDocumentProperties() {
1964
1930
  }
1965
1931
 
1966
1932
  function webViewerFind(evt) {
1967
- PDFViewerApplication.findController.executeCommand('find' + evt.type, {
1933
+ PDFViewerApplication.findController.executeCommand("find" + evt.type, {
1968
1934
  query: evt.query,
1969
1935
  phraseSearch: evt.phraseSearch,
1970
1936
  caseSensitive: evt.caseSensitive,
@@ -1975,7 +1941,7 @@ function webViewerFind(evt) {
1975
1941
  }
1976
1942
 
1977
1943
  function webViewerFindFromUrlHash(evt) {
1978
- PDFViewerApplication.findController.executeCommand('find', {
1944
+ PDFViewerApplication.findController.executeCommand("find", {
1979
1945
  query: evt.query,
1980
1946
  phraseSearch: evt.phraseSearch,
1981
1947
  caseSensitive: false,
@@ -1985,9 +1951,9 @@ function webViewerFindFromUrlHash(evt) {
1985
1951
  });
1986
1952
  }
1987
1953
 
1988
- function webViewerUpdateFindMatchesCount(_ref9) {
1989
- var matchesCount = _ref9.matchesCount;
1990
-
1954
+ function webViewerUpdateFindMatchesCount({
1955
+ matchesCount
1956
+ }) {
1991
1957
  if (PDFViewerApplication.supportsIntegratedFind) {
1992
1958
  PDFViewerApplication.externalServices.updateFindMatchesCount(matchesCount);
1993
1959
  } else {
@@ -1995,16 +1961,16 @@ function webViewerUpdateFindMatchesCount(_ref9) {
1995
1961
  }
1996
1962
  }
1997
1963
 
1998
- function webViewerUpdateFindControlState(_ref10) {
1999
- var state = _ref10.state,
2000
- previous = _ref10.previous,
2001
- matchesCount = _ref10.matchesCount;
2002
-
1964
+ function webViewerUpdateFindControlState({
1965
+ state,
1966
+ previous,
1967
+ matchesCount
1968
+ }) {
2003
1969
  if (PDFViewerApplication.supportsIntegratedFind) {
2004
1970
  PDFViewerApplication.externalServices.updateFindControlState({
2005
1971
  result: state,
2006
1972
  findPrevious: previous,
2007
- matchesCount: matchesCount
1973
+ matchesCount
2008
1974
  });
2009
1975
  } else {
2010
1976
  PDFViewerApplication.findBar.updateUIState(state, previous, matchesCount);
@@ -2023,7 +1989,7 @@ function webViewerRotationChanging(evt) {
2023
1989
  }
2024
1990
 
2025
1991
  function webViewerPageChanging(evt) {
2026
- var page = evt.pageNumber;
1992
+ const page = evt.pageNumber;
2027
1993
  PDFViewerApplication.toolbar.setPageNumber(page, evt.pageLabel || null);
2028
1994
  PDFViewerApplication.secondaryToolbar.setPageNumber(page);
2029
1995
 
@@ -2031,8 +1997,8 @@ function webViewerPageChanging(evt) {
2031
1997
  PDFViewerApplication.pdfThumbnailViewer.scrollThumbnailIntoView(page);
2032
1998
  }
2033
1999
 
2034
- if (typeof Stats !== 'undefined' && Stats.enabled) {
2035
- var pageView = PDFViewerApplication.pdfViewer.getPageView(page - 1);
2000
+ if (typeof Stats !== "undefined" && Stats.enabled) {
2001
+ const pageView = PDFViewerApplication.pdfViewer.getPageView(page - 1);
2036
2002
 
2037
2003
  if (pageView && pageView.stats) {
2038
2004
  Stats.add(page, pageView.stats);
@@ -2041,12 +2007,12 @@ function webViewerPageChanging(evt) {
2041
2007
  }
2042
2008
 
2043
2009
  function webViewerVisibilityChange(evt) {
2044
- if (document.visibilityState === 'visible') {
2010
+ if (document.visibilityState === "visible") {
2045
2011
  setZoomDisabledTimeout();
2046
2012
  }
2047
2013
  }
2048
2014
 
2049
- var zoomDisabledTimeout = null;
2015
+ let zoomDisabledTimeout = null;
2050
2016
 
2051
2017
  function setZoomDisabledTimeout() {
2052
2018
  if (zoomDisabledTimeout) {
@@ -2059,8 +2025,10 @@ function setZoomDisabledTimeout() {
2059
2025
  }
2060
2026
 
2061
2027
  function webViewerWheel(evt) {
2062
- var pdfViewer = PDFViewerApplication.pdfViewer,
2063
- supportedMouseWheelZoomModifierKeys = PDFViewerApplication.supportedMouseWheelZoomModifierKeys;
2028
+ const {
2029
+ pdfViewer,
2030
+ supportedMouseWheelZoomModifierKeys
2031
+ } = PDFViewerApplication;
2064
2032
 
2065
2033
  if (pdfViewer.isInPresentationMode) {
2066
2034
  return;
@@ -2069,14 +2037,14 @@ function webViewerWheel(evt) {
2069
2037
  if (evt.ctrlKey && supportedMouseWheelZoomModifierKeys.ctrlKey || evt.metaKey && supportedMouseWheelZoomModifierKeys.metaKey) {
2070
2038
  evt.preventDefault();
2071
2039
 
2072
- if (zoomDisabledTimeout || document.visibilityState === 'hidden') {
2040
+ if (zoomDisabledTimeout || document.visibilityState === "hidden") {
2073
2041
  return;
2074
2042
  }
2075
2043
 
2076
- var previousScale = pdfViewer.currentScale;
2077
- var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
2078
- var MOUSE_WHEEL_DELTA_PER_PAGE_SCALE = 3.0;
2079
- var ticks = delta * MOUSE_WHEEL_DELTA_PER_PAGE_SCALE;
2044
+ const previousScale = pdfViewer.currentScale;
2045
+ const delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
2046
+ const MOUSE_WHEEL_DELTA_PER_PAGE_SCALE = 3.0;
2047
+ const ticks = delta * MOUSE_WHEEL_DELTA_PER_PAGE_SCALE;
2080
2048
 
2081
2049
  if (ticks < 0) {
2082
2050
  PDFViewerApplication.zoomOut(-ticks);
@@ -2084,13 +2052,13 @@ function webViewerWheel(evt) {
2084
2052
  PDFViewerApplication.zoomIn(ticks);
2085
2053
  }
2086
2054
 
2087
- var currentScale = pdfViewer.currentScale;
2055
+ const currentScale = pdfViewer.currentScale;
2088
2056
 
2089
2057
  if (previousScale !== currentScale) {
2090
- var scaleCorrectionFactor = currentScale / previousScale - 1;
2091
- var rect = pdfViewer.container.getBoundingClientRect();
2092
- var dx = evt.clientX - rect.left;
2093
- var dy = evt.clientY - rect.top;
2058
+ const scaleCorrectionFactor = currentScale / previousScale - 1;
2059
+ const rect = pdfViewer.container.getBoundingClientRect();
2060
+ const dx = evt.clientX - rect.left;
2061
+ const dy = evt.clientY - rect.top;
2094
2062
  pdfViewer.container.scrollLeft += dx * scaleCorrectionFactor;
2095
2063
  pdfViewer.container.scrollTop += dy * scaleCorrectionFactor;
2096
2064
  }
@@ -2104,7 +2072,7 @@ function webViewerClick(evt) {
2104
2072
  return;
2105
2073
  }
2106
2074
 
2107
- var appConfig = PDFViewerApplication.appConfig;
2075
+ const appConfig = PDFViewerApplication.appConfig;
2108
2076
 
2109
2077
  if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || appConfig.toolbar.container.contains(evt.target) && evt.target !== appConfig.secondaryToolbar.toggleButton) {
2110
2078
  PDFViewerApplication.secondaryToolbar.close();
@@ -2116,11 +2084,11 @@ function webViewerKeyDown(evt) {
2116
2084
  return;
2117
2085
  }
2118
2086
 
2119
- var handled = false,
2087
+ let handled = false,
2120
2088
  ensureViewerFocused = false;
2121
- var cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 : 0);
2122
- var pdfViewer = PDFViewerApplication.pdfViewer;
2123
- var isViewerInPresentationMode = pdfViewer && pdfViewer.isInPresentationMode;
2089
+ const cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 : 0);
2090
+ const pdfViewer = PDFViewerApplication.pdfViewer;
2091
+ const isViewerInPresentationMode = pdfViewer && pdfViewer.isInPresentationMode;
2124
2092
 
2125
2093
  if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
2126
2094
  switch (evt.keyCode) {
@@ -2134,10 +2102,10 @@ function webViewerKeyDown(evt) {
2134
2102
 
2135
2103
  case 71:
2136
2104
  if (!PDFViewerApplication.supportsIntegratedFind) {
2137
- var findState = PDFViewerApplication.findController.state;
2105
+ const findState = PDFViewerApplication.findController.state;
2138
2106
 
2139
2107
  if (findState) {
2140
- PDFViewerApplication.findController.executeCommand('findagain', {
2108
+ PDFViewerApplication.findController.executeCommand("findagain", {
2141
2109
  query: findState.query,
2142
2110
  phraseSearch: findState.phraseSearch,
2143
2111
  caseSensitive: findState.caseSensitive,
@@ -2236,17 +2204,17 @@ function webViewerKeyDown(evt) {
2236
2204
  return;
2237
2205
  }
2238
2206
 
2239
- var curElement = document.activeElement || document.querySelector(':focus');
2240
- var curElementTagName = curElement && curElement.tagName.toUpperCase();
2207
+ const curElement = document.activeElement || document.querySelector(":focus");
2208
+ const curElementTagName = curElement && curElement.tagName.toUpperCase();
2241
2209
 
2242
- if (curElementTagName === 'INPUT' || curElementTagName === 'TEXTAREA' || curElementTagName === 'SELECT') {
2210
+ if (curElementTagName === "INPUT" || curElementTagName === "TEXTAREA" || curElementTagName === "SELECT" || curElement && curElement.isContentEditable) {
2243
2211
  if (evt.keyCode !== 27) {
2244
2212
  return;
2245
2213
  }
2246
2214
  }
2247
2215
 
2248
2216
  if (cmd === 0) {
2249
- var turnPage = 0,
2217
+ let turnPage = 0,
2250
2218
  turnOnlyIfPageFit = false;
2251
2219
 
2252
2220
  switch (evt.keyCode) {
@@ -2353,7 +2321,7 @@ function webViewerKeyDown(evt) {
2353
2321
  break;
2354
2322
  }
2355
2323
 
2356
- if (turnPage !== 0 && (!turnOnlyIfPageFit || pdfViewer.currentScaleValue === 'page-fit')) {
2324
+ if (turnPage !== 0 && (!turnOnlyIfPageFit || pdfViewer.currentScaleValue === "page-fit")) {
2357
2325
  if (turnPage > 0) {
2358
2326
  if (PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
2359
2327
  PDFViewerApplication.page++;
@@ -2372,7 +2340,7 @@ function webViewerKeyDown(evt) {
2372
2340
  switch (evt.keyCode) {
2373
2341
  case 13:
2374
2342
  case 32:
2375
- if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== 'page-fit') {
2343
+ if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== "page-fit") {
2376
2344
  break;
2377
2345
  }
2378
2346
 
@@ -2390,7 +2358,7 @@ function webViewerKeyDown(evt) {
2390
2358
  }
2391
2359
 
2392
2360
  if (!handled && !isViewerInPresentationMode) {
2393
- if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 && curElementTagName !== 'BUTTON') {
2361
+ if (evt.keyCode >= 33 && evt.keyCode <= 40 || evt.keyCode === 32 && curElementTagName !== "BUTTON") {
2394
2362
  ensureViewerFocused = true;
2395
2363
  }
2396
2364
  }
@@ -2406,16 +2374,16 @@ function webViewerKeyDown(evt) {
2406
2374
 
2407
2375
  function apiPageLayoutToSpreadMode(layout) {
2408
2376
  switch (layout) {
2409
- case 'SinglePage':
2410
- case 'OneColumn':
2377
+ case "SinglePage":
2378
+ case "OneColumn":
2411
2379
  return _ui_utils.SpreadMode.NONE;
2412
2380
 
2413
- case 'TwoColumnLeft':
2414
- case 'TwoPageLeft':
2381
+ case "TwoColumnLeft":
2382
+ case "TwoPageLeft":
2415
2383
  return _ui_utils.SpreadMode.ODD;
2416
2384
 
2417
- case 'TwoColumnRight':
2418
- case 'TwoPageRight':
2385
+ case "TwoColumnRight":
2386
+ case "TwoPageRight":
2419
2387
  return _ui_utils.SpreadMode.EVEN;
2420
2388
  }
2421
2389
 
@@ -2424,30 +2392,32 @@ function apiPageLayoutToSpreadMode(layout) {
2424
2392
 
2425
2393
  function apiPageModeToSidebarView(mode) {
2426
2394
  switch (mode) {
2427
- case 'UseNone':
2395
+ case "UseNone":
2428
2396
  return _pdf_sidebar.SidebarView.NONE;
2429
2397
 
2430
- case 'UseThumbs':
2398
+ case "UseThumbs":
2431
2399
  return _pdf_sidebar.SidebarView.THUMBS;
2432
2400
 
2433
- case 'UseOutlines':
2401
+ case "UseOutlines":
2434
2402
  return _pdf_sidebar.SidebarView.OUTLINE;
2435
2403
 
2436
- case 'UseAttachments':
2404
+ case "UseAttachments":
2437
2405
  return _pdf_sidebar.SidebarView.ATTACHMENTS;
2438
2406
 
2439
- case 'UseOC':
2407
+ case "UseOC":
2440
2408
  }
2441
2409
 
2442
2410
  return _pdf_sidebar.SidebarView.NONE;
2443
2411
  }
2444
2412
 
2445
- var PDFPrintServiceFactory = {
2413
+ const PDFPrintServiceFactory = {
2446
2414
  instance: {
2447
2415
  supportsPrinting: false,
2448
- createPrintService: function createPrintService() {
2449
- throw new Error('Not implemented: createPrintService');
2416
+
2417
+ createPrintService() {
2418
+ throw new Error("Not implemented: createPrintService");
2450
2419
  }
2420
+
2451
2421
  }
2452
2422
  };
2453
2423
  exports.PDFPrintServiceFactory = PDFPrintServiceFactory;