pdfjs-dist 2.1.266 → 2.2.228

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 (166) hide show
  1. package/CODE_OF_CONDUCT.md +15 -0
  2. package/bower.json +1 -1
  3. package/build/pdf.js +3349 -2324
  4. package/build/pdf.js.map +1 -1
  5. package/build/pdf.min.js +1 -1
  6. package/build/pdf.worker.js +2804 -1975
  7. package/build/pdf.worker.js.map +1 -1
  8. package/build/pdf.worker.min.js +1 -1
  9. package/image_decoders/pdf.image_decoders.js +431 -511
  10. package/image_decoders/pdf.image_decoders.js.map +1 -1
  11. package/image_decoders/pdf.image_decoders.min.js +1 -1
  12. package/lib/core/annotation.js +294 -224
  13. package/lib/core/arithmetic_decoder.js +1 -1
  14. package/lib/core/bidi.js +1 -1
  15. package/lib/core/ccitt.js +1 -1
  16. package/lib/core/ccitt_stream.js +1 -1
  17. package/lib/core/cff_parser.js +61 -12
  18. package/lib/core/charsets.js +1 -1
  19. package/lib/core/chunked_stream.js +24 -14
  20. package/lib/core/cmap.js +17 -13
  21. package/lib/core/colorspace.js +1 -1
  22. package/lib/core/core_utils.js +147 -0
  23. package/lib/core/crypto.js +1 -1
  24. package/lib/core/document.js +47 -40
  25. package/lib/core/encodings.js +1 -1
  26. package/lib/core/evaluator.js +346 -279
  27. package/lib/core/font_renderer.js +1 -1
  28. package/lib/core/fonts.js +23 -11
  29. package/lib/core/function.js +1 -1
  30. package/lib/core/glyphlist.js +2 -2
  31. package/lib/core/image.js +2 -2
  32. package/lib/core/image_utils.js +111 -0
  33. package/lib/core/jbig2.js +1 -1
  34. package/lib/core/jbig2_stream.js +1 -1
  35. package/lib/core/jpeg_stream.js +1 -1
  36. package/lib/core/jpg.js +2 -1
  37. package/lib/core/jpx.js +1 -1
  38. package/lib/core/jpx_stream.js +1 -1
  39. package/lib/core/metrics.js +13 -13
  40. package/lib/core/murmurhash3.js +37 -33
  41. package/lib/core/obj.js +245 -41
  42. package/lib/core/operator_list.js +43 -32
  43. package/lib/core/parser.js +228 -133
  44. package/lib/core/pattern.js +4 -2
  45. package/lib/core/pdf_manager.js +17 -15
  46. package/lib/core/primitives.js +40 -6
  47. package/lib/core/ps_parser.js +1 -1
  48. package/lib/core/standard_fonts.js +9 -9
  49. package/lib/core/stream.js +1 -1
  50. package/lib/core/type1_parser.js +1 -1
  51. package/lib/core/unicode.js +2 -2
  52. package/lib/core/worker.js +54 -171
  53. package/lib/core/worker_stream.js +277 -0
  54. package/lib/display/annotation_layer.js +112 -33
  55. package/lib/display/api.js +211 -123
  56. package/lib/display/api_compatibility.js +1 -1
  57. package/lib/display/canvas.js +40 -19
  58. package/lib/display/content_disposition.js +1 -1
  59. package/lib/display/display_utils.js +747 -0
  60. package/lib/display/fetch_stream.js +19 -12
  61. package/lib/display/font_loader.js +11 -8
  62. package/lib/display/metadata.js +1 -1
  63. package/lib/display/network.js +563 -521
  64. package/lib/display/network_utils.js +1 -1
  65. package/lib/display/node_stream.js +21 -12
  66. package/lib/display/pattern_helper.js +24 -25
  67. package/lib/display/svg.js +1068 -565
  68. package/lib/display/text_layer.js +24 -14
  69. package/lib/display/transport_stream.js +192 -70
  70. package/lib/display/webgl.js +1 -1
  71. package/lib/display/worker_options.js +1 -1
  72. package/lib/display/xml_parser.js +1 -1
  73. package/lib/examples/node/domstubs.js +4 -1
  74. package/lib/pdf.js +20 -15
  75. package/lib/pdf.worker.js +3 -3
  76. package/lib/shared/compatibility.js +6 -6
  77. package/lib/shared/global_scope.js +1 -1
  78. package/lib/shared/is_node.js +2 -2
  79. package/lib/shared/message_handler.js +7 -7
  80. package/lib/shared/streams_polyfill.js +1 -1
  81. package/lib/shared/url_polyfill.js +1 -1
  82. package/lib/shared/util.js +13 -125
  83. package/lib/test/unit/annotation_spec.js +278 -93
  84. package/lib/test/unit/api_spec.js +198 -188
  85. package/lib/test/unit/bidi_spec.js +1 -1
  86. package/lib/test/unit/cff_parser_spec.js +15 -1
  87. package/lib/test/unit/clitests_helper.js +3 -3
  88. package/lib/test/unit/cmap_spec.js +20 -20
  89. package/lib/test/unit/colorspace_spec.js +17 -12
  90. package/lib/test/unit/core_utils_spec.js +191 -0
  91. package/lib/test/unit/crypto_spec.js +1 -1
  92. package/lib/test/unit/custom_spec.js +8 -8
  93. package/lib/test/unit/display_svg_spec.js +8 -8
  94. package/lib/test/unit/display_utils_spec.js +273 -0
  95. package/lib/test/unit/document_spec.js +7 -12
  96. package/lib/test/unit/encodings_spec.js +5 -5
  97. package/lib/test/unit/evaluator_spec.js +8 -10
  98. package/lib/test/unit/fetch_stream_spec.js +109 -0
  99. package/lib/test/unit/function_spec.js +1 -1
  100. package/lib/test/unit/jasmine-boot.js +4 -4
  101. package/lib/test/unit/message_handler_spec.js +1 -1
  102. package/lib/test/unit/metadata_spec.js +1 -1
  103. package/lib/test/unit/murmurhash3_spec.js +1 -1
  104. package/lib/test/unit/network_spec.js +5 -55
  105. package/lib/test/unit/network_utils_spec.js +51 -1
  106. package/lib/test/unit/node_stream_spec.js +8 -8
  107. package/lib/test/unit/parser_spec.js +150 -86
  108. package/lib/test/unit/pdf_find_controller_spec.js +1 -1
  109. package/lib/test/unit/pdf_find_utils_spec.js +1 -1
  110. package/lib/test/unit/pdf_history_spec.js +1 -1
  111. package/lib/test/unit/primitives_spec.js +30 -17
  112. package/lib/test/unit/stream_spec.js +1 -1
  113. package/lib/test/unit/test_utils.js +197 -43
  114. package/lib/test/unit/testreporter.js +1 -1
  115. package/lib/test/unit/type1_parser_spec.js +1 -1
  116. package/lib/test/unit/ui_utils_spec.js +20 -20
  117. package/lib/test/unit/unicode_spec.js +5 -5
  118. package/lib/test/unit/util_spec.js +1 -164
  119. package/lib/web/annotation_layer_builder.js +1 -1
  120. package/lib/web/app.js +104 -60
  121. package/lib/web/app_options.js +45 -37
  122. package/lib/web/base_viewer.js +7 -7
  123. package/lib/web/chromecom.js +8 -8
  124. package/lib/web/debugger.js +7 -7
  125. package/lib/web/download_manager.js +3 -2
  126. package/lib/web/firefox_print_service.js +4 -2
  127. package/lib/web/firefoxcom.js +50 -19
  128. package/lib/web/genericcom.js +8 -8
  129. package/lib/web/genericl10n.js +10 -10
  130. package/lib/web/grab_to_pan.js +3 -1
  131. package/lib/web/interfaces.js +13 -13
  132. package/lib/web/overlay_manager.js +10 -10
  133. package/lib/web/password_prompt.js +2 -2
  134. package/lib/web/pdf_attachment_viewer.js +1 -1
  135. package/lib/web/pdf_cursor_tools.js +1 -1
  136. package/lib/web/pdf_document_properties.js +188 -119
  137. package/lib/web/pdf_find_bar.js +1 -1
  138. package/lib/web/pdf_find_controller.js +3 -3
  139. package/lib/web/pdf_find_utils.js +1 -1
  140. package/lib/web/pdf_history.js +1 -1
  141. package/lib/web/pdf_link_service.js +2 -2
  142. package/lib/web/pdf_outline_viewer.js +53 -28
  143. package/lib/web/pdf_page_view.js +9 -18
  144. package/lib/web/pdf_presentation_mode.js +1 -1
  145. package/lib/web/pdf_print_service.js +5 -3
  146. package/lib/web/pdf_rendering_queue.js +4 -7
  147. package/lib/web/pdf_sidebar.js +24 -17
  148. package/lib/web/pdf_sidebar_resizer.js +1 -1
  149. package/lib/web/pdf_single_page_viewer.js +1 -1
  150. package/lib/web/pdf_thumbnail_view.js +2 -2
  151. package/lib/web/pdf_thumbnail_viewer.js +3 -3
  152. package/lib/web/pdf_viewer.component.js +3 -3
  153. package/lib/web/pdf_viewer.js +3 -3
  154. package/lib/web/preferences.js +30 -30
  155. package/lib/web/secondary_toolbar.js +1 -1
  156. package/lib/web/text_layer_builder.js +23 -45
  157. package/lib/web/toolbar.js +1 -1
  158. package/lib/web/ui_utils.js +14 -14
  159. package/lib/web/view_history.js +15 -15
  160. package/lib/web/viewer_compatibility.js +1 -1
  161. package/package.json +1 -1
  162. package/web/pdf_viewer.css +21 -10
  163. package/web/pdf_viewer.js +126 -194
  164. package/web/pdf_viewer.js.map +1 -1
  165. package/lib/display/dom_utils.js +0 -494
  166. package/lib/test/unit/dom_utils_spec.js +0 -89
@@ -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 2018 Mozilla Foundation
5
+ * Copyright 2019 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.
@@ -23,10 +23,6 @@
23
23
 
24
24
  var _util = require("../../shared/util");
25
25
 
26
- var _primitives = require("../../core/primitives");
27
-
28
- var _test_utils = require("./test_utils");
29
-
30
26
  function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
31
27
 
32
28
  describe('util', function () {
@@ -52,125 +48,6 @@ describe('util', function () {
52
48
  expect((0, _util.bytesToString)(bytes)).toEqual(string);
53
49
  });
54
50
  });
55
- describe('getInheritableProperty', function () {
56
- it('handles non-dictionary arguments', function () {
57
- expect((0, _util.getInheritableProperty)({
58
- dict: null,
59
- key: 'foo'
60
- })).toEqual(undefined);
61
- expect((0, _util.getInheritableProperty)({
62
- dict: undefined,
63
- key: 'foo'
64
- })).toEqual(undefined);
65
- });
66
- it('handles dictionaries that do not contain the property', function () {
67
- var emptyDict = new _primitives.Dict();
68
- expect((0, _util.getInheritableProperty)({
69
- dict: emptyDict,
70
- key: 'foo'
71
- })).toEqual(undefined);
72
- var filledDict = new _primitives.Dict();
73
- filledDict.set('bar', 'baz');
74
- expect((0, _util.getInheritableProperty)({
75
- dict: filledDict,
76
- key: 'foo'
77
- })).toEqual(undefined);
78
- });
79
- it('fetches the property if it is not inherited', function () {
80
- var ref = new _primitives.Ref(10, 0);
81
- var xref = new _test_utils.XRefMock([{
82
- ref: ref,
83
- data: 'quux'
84
- }]);
85
- var dict = new _primitives.Dict(xref);
86
- dict.set('foo', 'bar');
87
- expect((0, _util.getInheritableProperty)({
88
- dict: dict,
89
- key: 'foo'
90
- })).toEqual('bar');
91
- dict.set('baz', ['qux', ref]);
92
- expect((0, _util.getInheritableProperty)({
93
- dict: dict,
94
- key: 'baz',
95
- getArray: true
96
- })).toEqual(['qux', 'quux']);
97
- });
98
- it('fetches the property if it is inherited and present on one level', function () {
99
- var ref = new _primitives.Ref(10, 0);
100
- var xref = new _test_utils.XRefMock([{
101
- ref: ref,
102
- data: 'quux'
103
- }]);
104
- var firstDict = new _primitives.Dict(xref);
105
- var secondDict = new _primitives.Dict(xref);
106
- firstDict.set('Parent', secondDict);
107
- secondDict.set('foo', 'bar');
108
- expect((0, _util.getInheritableProperty)({
109
- dict: firstDict,
110
- key: 'foo'
111
- })).toEqual('bar');
112
- secondDict.set('baz', ['qux', ref]);
113
- expect((0, _util.getInheritableProperty)({
114
- dict: firstDict,
115
- key: 'baz',
116
- getArray: true
117
- })).toEqual(['qux', 'quux']);
118
- });
119
- it('fetches the property if it is inherited and present on multiple levels', function () {
120
- var ref = new _primitives.Ref(10, 0);
121
- var xref = new _test_utils.XRefMock([{
122
- ref: ref,
123
- data: 'quux'
124
- }]);
125
- var firstDict = new _primitives.Dict(xref);
126
- var secondDict = new _primitives.Dict(xref);
127
- firstDict.set('Parent', secondDict);
128
- firstDict.set('foo', 'bar1');
129
- secondDict.set('foo', 'bar2');
130
- expect((0, _util.getInheritableProperty)({
131
- dict: firstDict,
132
- key: 'foo'
133
- })).toEqual('bar1');
134
- expect((0, _util.getInheritableProperty)({
135
- dict: firstDict,
136
- key: 'foo',
137
- getArray: false,
138
- stopWhenFound: false
139
- })).toEqual(['bar1', 'bar2']);
140
- firstDict.set('baz', ['qux1', ref]);
141
- secondDict.set('baz', ['qux2', ref]);
142
- expect((0, _util.getInheritableProperty)({
143
- dict: firstDict,
144
- key: 'baz',
145
- getArray: true,
146
- stopWhenFound: false
147
- })).toEqual([['qux1', 'quux'], ['qux2', 'quux']]);
148
- });
149
- it('stops searching when the loop limit is reached', function () {
150
- var dict = new _primitives.Dict();
151
- var currentDict = dict;
152
- var parentDict = null;
153
-
154
- for (var i = 0; i < 150; i++) {
155
- parentDict = new _primitives.Dict();
156
- currentDict.set('Parent', parentDict);
157
- currentDict = parentDict;
158
- }
159
-
160
- parentDict.set('foo', 'bar');
161
- expect((0, _util.getInheritableProperty)({
162
- dict: dict,
163
- key: 'foo'
164
- })).toEqual(undefined);
165
- dict.set('foo', 'baz');
166
- expect((0, _util.getInheritableProperty)({
167
- dict: dict,
168
- key: 'foo',
169
- getArray: false,
170
- stopWhenFound: false
171
- })).toEqual(['baz']);
172
- });
173
- });
174
51
  describe('isArrayBuffer', function () {
175
52
  it('handles array buffer values', function () {
176
53
  expect((0, _util.isArrayBuffer)(new ArrayBuffer(0))).toEqual(true);
@@ -313,46 +190,6 @@ describe('util', function () {
313
190
  expect(_typeof(readable.getReader)).toEqual('function');
314
191
  });
315
192
  });
316
- describe('toRomanNumerals', function () {
317
- it('handles invalid arguments', function () {
318
- var _arr = ['foo', -1, 0];
319
-
320
- var _loop = function _loop() {
321
- var input = _arr[_i];
322
- expect(function () {
323
- (0, _util.toRomanNumerals)(input);
324
- }).toThrow(new Error('The number should be a positive integer.'));
325
- };
326
-
327
- for (var _i = 0; _i < _arr.length; _i++) {
328
- _loop();
329
- }
330
- });
331
- it('converts numbers to uppercase Roman numerals', function () {
332
- expect((0, _util.toRomanNumerals)(1)).toEqual('I');
333
- expect((0, _util.toRomanNumerals)(6)).toEqual('VI');
334
- expect((0, _util.toRomanNumerals)(7)).toEqual('VII');
335
- expect((0, _util.toRomanNumerals)(8)).toEqual('VIII');
336
- expect((0, _util.toRomanNumerals)(10)).toEqual('X');
337
- expect((0, _util.toRomanNumerals)(40)).toEqual('XL');
338
- expect((0, _util.toRomanNumerals)(100)).toEqual('C');
339
- expect((0, _util.toRomanNumerals)(500)).toEqual('D');
340
- expect((0, _util.toRomanNumerals)(1000)).toEqual('M');
341
- expect((0, _util.toRomanNumerals)(2019)).toEqual('MMXIX');
342
- });
343
- it('converts numbers to lowercase Roman numerals', function () {
344
- expect((0, _util.toRomanNumerals)(1, true)).toEqual('i');
345
- expect((0, _util.toRomanNumerals)(6, true)).toEqual('vi');
346
- expect((0, _util.toRomanNumerals)(7, true)).toEqual('vii');
347
- expect((0, _util.toRomanNumerals)(8, true)).toEqual('viii');
348
- expect((0, _util.toRomanNumerals)(10, true)).toEqual('x');
349
- expect((0, _util.toRomanNumerals)(40, true)).toEqual('xl');
350
- expect((0, _util.toRomanNumerals)(100, true)).toEqual('c');
351
- expect((0, _util.toRomanNumerals)(500, true)).toEqual('d');
352
- expect((0, _util.toRomanNumerals)(1000, true)).toEqual('m');
353
- expect((0, _util.toRomanNumerals)(2019, true)).toEqual('mmxix');
354
- });
355
- });
356
193
  describe('URL', function () {
357
194
  it('should return an Object', function () {
358
195
  var url = new _util.URL('https://example.com');
@@ -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 2018 Mozilla Foundation
5
+ * Copyright 2019 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.
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 2018 Mozilla Foundation
5
+ * Copyright 2019 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.
@@ -30,6 +30,8 @@ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"))
30
30
 
31
31
  var _ui_utils = require("./ui_utils");
32
32
 
33
+ var _app_options = require("./app_options");
34
+
33
35
  var _pdf = require("../pdf");
34
36
 
35
37
  var _pdf_cursor_tools = require("./pdf_cursor_tools");
@@ -38,8 +40,6 @@ var _pdf_rendering_queue = require("./pdf_rendering_queue");
38
40
 
39
41
  var _pdf_sidebar = require("./pdf_sidebar");
40
42
 
41
- var _app_options = require("./app_options");
42
-
43
43
  var _overlay_manager = require("./overlay_manager");
44
44
 
45
45
  var _password_prompt = require("./password_prompt");
@@ -72,7 +72,7 @@ var _toolbar = require("./toolbar");
72
72
 
73
73
  var _view_history = require("./view_history");
74
74
 
75
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
75
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
76
76
 
77
77
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
78
78
 
@@ -158,11 +158,11 @@ var PDFViewerApplication = {
158
158
  initialize: function () {
159
159
  var _initialize = _asyncToGenerator(
160
160
  /*#__PURE__*/
161
- _regenerator.default.mark(function _callee(appConfig) {
161
+ _regenerator["default"].mark(function _callee(appConfig) {
162
162
  var _this = this;
163
163
 
164
164
  var appContainer;
165
- return _regenerator.default.wrap(function _callee$(_context) {
165
+ return _regenerator["default"].wrap(function _callee$(_context) {
166
166
  while (1) {
167
167
  switch (_context.prev = _context.next) {
168
168
  case 0:
@@ -215,9 +215,9 @@ var PDFViewerApplication = {
215
215
  _readPreferences: function () {
216
216
  var _readPreferences2 = _asyncToGenerator(
217
217
  /*#__PURE__*/
218
- _regenerator.default.mark(function _callee2() {
218
+ _regenerator["default"].mark(function _callee2() {
219
219
  var prefs, name;
220
- return _regenerator.default.wrap(function _callee2$(_context2) {
220
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
221
221
  while (1) {
222
222
  switch (_context2.prev = _context2.next) {
223
223
  case 0:
@@ -240,14 +240,15 @@ var PDFViewerApplication = {
240
240
  _app_options.AppOptions.set(name, prefs[name]);
241
241
  }
242
242
 
243
- _context2.next = 11;
243
+ _context2.next = 12;
244
244
  break;
245
245
 
246
246
  case 9:
247
247
  _context2.prev = 9;
248
248
  _context2.t0 = _context2["catch"](2);
249
+ console.error("_readPreferences: \"".concat(_context2.t0.message, "\"."));
249
250
 
250
- case 11:
251
+ case 12:
251
252
  case "end":
252
253
  return _context2.stop();
253
254
  }
@@ -264,9 +265,9 @@ var PDFViewerApplication = {
264
265
  _parseHashParameters: function () {
265
266
  var _parseHashParameters2 = _asyncToGenerator(
266
267
  /*#__PURE__*/
267
- _regenerator.default.mark(function _callee3() {
268
+ _regenerator["default"].mark(function _callee3() {
268
269
  var waitOn, hash, hashParams, viewer, enabled;
269
- return _regenerator.default.wrap(function _callee3$(_context3) {
270
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
270
271
  while (1) {
271
272
  switch (_context3.prev = _context3.next) {
272
273
  case 0:
@@ -275,7 +276,7 @@ var PDFViewerApplication = {
275
276
  break;
276
277
  }
277
278
 
278
- return _context3.abrupt("return");
279
+ return _context3.abrupt("return", undefined);
279
280
 
280
281
  case 2:
281
282
  waitOn = [];
@@ -349,7 +350,7 @@ var PDFViewerApplication = {
349
350
  _app_options.AppOptions.set('locale', hashParams['locale']);
350
351
  }
351
352
 
352
- return _context3.abrupt("return", Promise.all(waitOn).catch(function (reason) {
353
+ return _context3.abrupt("return", Promise.all(waitOn)["catch"](function (reason) {
353
354
  console.error("_parseHashParameters: \"".concat(reason.message, "\"."));
354
355
  }));
355
356
 
@@ -370,9 +371,9 @@ var PDFViewerApplication = {
370
371
  _initializeL10n: function () {
371
372
  var _initializeL10n2 = _asyncToGenerator(
372
373
  /*#__PURE__*/
373
- _regenerator.default.mark(function _callee4() {
374
+ _regenerator["default"].mark(function _callee4() {
374
375
  var dir;
375
- return _regenerator.default.wrap(function _callee4$(_context4) {
376
+ return _regenerator["default"].wrap(function _callee4$(_context4) {
376
377
  while (1) {
377
378
  switch (_context4.prev = _context4.next) {
378
379
  case 0:
@@ -403,16 +404,15 @@ var PDFViewerApplication = {
403
404
  _initializeViewerComponents: function () {
404
405
  var _initializeViewerComponents2 = _asyncToGenerator(
405
406
  /*#__PURE__*/
406
- _regenerator.default.mark(function _callee5() {
407
- var appConfig, dispatchToDOM, eventBus, pdfRenderingQueue, pdfLinkService, downloadManager, findController, container, viewer, thumbnailContainer, sidebarConfig;
408
- return _regenerator.default.wrap(function _callee5$(_context5) {
407
+ _regenerator["default"].mark(function _callee5() {
408
+ var appConfig, eventBus, pdfRenderingQueue, pdfLinkService, downloadManager, findController, container, viewer;
409
+ return _regenerator["default"].wrap(function _callee5$(_context5) {
409
410
  while (1) {
410
411
  switch (_context5.prev = _context5.next) {
411
412
  case 0:
412
413
  appConfig = this.appConfig;
413
414
  this.overlayManager = new _overlay_manager.OverlayManager();
414
- dispatchToDOM = _app_options.AppOptions.get('eventBusDispatchToDOM');
415
- eventBus = appConfig.eventBus || (0, _ui_utils.getGlobalEventBus)(dispatchToDOM);
415
+ eventBus = appConfig.eventBus || (0, _ui_utils.getGlobalEventBus)(_app_options.AppOptions.get('eventBusDispatchToDOM'));
416
416
  this.eventBus = eventBus;
417
417
  pdfRenderingQueue = new _pdf_rendering_queue.PDFRenderingQueue();
418
418
  pdfRenderingQueue.onIdle = this.cleanup.bind(this);
@@ -454,9 +454,8 @@ var PDFViewerApplication = {
454
454
  });
455
455
  pdfRenderingQueue.setViewer(this.pdfViewer);
456
456
  pdfLinkService.setViewer(this.pdfViewer);
457
- thumbnailContainer = appConfig.sidebar.thumbnailView;
458
457
  this.pdfThumbnailViewer = new _pdf_thumbnail_viewer.PDFThumbnailViewer({
459
- container: thumbnailContainer,
458
+ container: appConfig.sidebar.thumbnailView,
460
459
  renderingQueue: pdfRenderingQueue,
461
460
  linkService: pdfLinkService,
462
461
  l10n: this.l10n
@@ -498,14 +497,17 @@ var PDFViewerApplication = {
498
497
  eventBus: eventBus,
499
498
  downloadManager: downloadManager
500
499
  });
501
- sidebarConfig = Object.create(appConfig.sidebar);
502
- sidebarConfig.pdfViewer = this.pdfViewer;
503
- sidebarConfig.pdfThumbnailViewer = this.pdfThumbnailViewer;
504
- this.pdfSidebar = new _pdf_sidebar.PDFSidebar(sidebarConfig, eventBus, this.l10n);
500
+ this.pdfSidebar = new _pdf_sidebar.PDFSidebar({
501
+ elements: appConfig.sidebar,
502
+ pdfViewer: this.pdfViewer,
503
+ pdfThumbnailViewer: this.pdfThumbnailViewer,
504
+ eventBus: eventBus,
505
+ l10n: this.l10n
506
+ });
505
507
  this.pdfSidebar.onToggled = this.forceRendering.bind(this);
506
508
  this.pdfSidebarResizer = new _pdf_sidebar_resizer.PDFSidebarResizer(appConfig.sidebarResizer, eventBus, this.l10n);
507
509
 
508
- case 39:
510
+ case 34:
509
511
  case "end":
510
512
  return _context5.stop();
511
513
  }
@@ -544,6 +546,17 @@ var PDFViewerApplication = {
544
546
 
545
547
  this.pdfViewer.currentScaleValue = newScale;
546
548
  },
549
+ zoomReset: function zoomReset() {
550
+ var ignoreDuplicate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
551
+
552
+ if (this.pdfViewer.isInPresentationMode) {
553
+ return;
554
+ } else if (ignoreDuplicate && this.pdfViewer.currentScaleValue === _ui_utils.DEFAULT_SCALE_VALUE) {
555
+ return;
556
+ }
557
+
558
+ this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
559
+ },
547
560
 
548
561
  get pagesCount() {
549
562
  return this.pdfDocument ? this.pdfDocument.numPages : 0;
@@ -627,9 +640,9 @@ var PDFViewerApplication = {
627
640
  close: function () {
628
641
  var _close = _asyncToGenerator(
629
642
  /*#__PURE__*/
630
- _regenerator.default.mark(function _callee6() {
643
+ _regenerator["default"].mark(function _callee6() {
631
644
  var errorWrapper, promise;
632
- return _regenerator.default.wrap(function _callee6$(_context6) {
645
+ return _regenerator["default"].wrap(function _callee6$(_context6) {
633
646
  while (1) {
634
647
  switch (_context6.prev = _context6.next) {
635
648
  case 0:
@@ -641,7 +654,7 @@ var PDFViewerApplication = {
641
654
  break;
642
655
  }
643
656
 
644
- return _context6.abrupt("return");
657
+ return _context6.abrupt("return", undefined);
645
658
 
646
659
  case 4:
647
660
  promise = this.pdfLoadingTask.destroy();
@@ -691,12 +704,12 @@ var PDFViewerApplication = {
691
704
  open: function () {
692
705
  var _open = _asyncToGenerator(
693
706
  /*#__PURE__*/
694
- _regenerator.default.mark(function _callee7(file, args) {
707
+ _regenerator["default"].mark(function _callee7(file, args) {
695
708
  var _this2 = this;
696
709
 
697
710
  var workerParameters, key, parameters, apiParameters, _key, prop, loadingTask;
698
711
 
699
- return _regenerator.default.wrap(function _callee7$(_context7) {
712
+ return _regenerator["default"].wrap(function _callee7$(_context7) {
700
713
  while (1) {
701
714
  switch (_context7.prev = _context7.next) {
702
715
  case 0:
@@ -709,7 +722,7 @@ var PDFViewerApplication = {
709
722
  return this.close();
710
723
 
711
724
  case 3:
712
- workerParameters = _app_options.AppOptions.getAll('worker');
725
+ workerParameters = _app_options.AppOptions.getAll(_app_options.OptionKind.WORKER);
713
726
 
714
727
  for (key in workerParameters) {
715
728
  _pdf.GlobalWorkerOptions[key] = workerParameters[key];
@@ -727,7 +740,7 @@ var PDFViewerApplication = {
727
740
  parameters.url = file.url;
728
741
  }
729
742
 
730
- apiParameters = _app_options.AppOptions.getAll('api');
743
+ apiParameters = _app_options.AppOptions.getAll(_app_options.OptionKind.API);
731
744
 
732
745
  for (_key in apiParameters) {
733
746
  parameters[_key] = apiParameters[_key];
@@ -764,7 +777,7 @@ var PDFViewerApplication = {
764
777
  _this2.load(pdfDocument);
765
778
  }, function (exception) {
766
779
  if (loadingTask !== _this2.pdfLoadingTask) {
767
- return;
780
+ return undefined;
768
781
  }
769
782
 
770
783
  var message = exception && exception.message;
@@ -828,7 +841,7 @@ var PDFViewerApplication = {
828
841
  type: 'application/pdf'
829
842
  });
830
843
  downloadManager.download(blob, url, filename);
831
- }).catch(downloadByUrl);
844
+ })["catch"](downloadByUrl);
832
845
  },
833
846
  fallback: function fallback(featureId) {},
834
847
  error: function error(message, moreInfo) {
@@ -941,8 +954,9 @@ var PDFViewerApplication = {
941
954
  });
942
955
  });
943
956
  });
944
- var pageModePromise = pdfDocument.getPageMode().catch(function () {});
945
- var openActionDestPromise = pdfDocument.getOpenActionDestination().catch(function () {});
957
+ var pageLayoutPromise = pdfDocument.getPageLayout()["catch"](function () {});
958
+ var pageModePromise = pdfDocument.getPageMode()["catch"](function () {});
959
+ var openActionDestPromise = pdfDocument.getOpenActionDestination()["catch"](function () {});
946
960
  this.toolbar.setPagesCount(pdfDocument.numPages, false);
947
961
  this.secondaryToolbar.setPagesCount(pdfDocument.numPages);
948
962
  var store = this.store = new _view_history.ViewHistory(pdfDocument.fingerprint);
@@ -969,20 +983,20 @@ var PDFViewerApplication = {
969
983
  sidebarView: _pdf_sidebar.SidebarView.UNKNOWN,
970
984
  scrollMode: _ui_utils.ScrollMode.UNKNOWN,
971
985
  spreadMode: _ui_utils.SpreadMode.UNKNOWN
972
- }).catch(function () {});
973
- Promise.all([storePromise, pageModePromise, openActionDestPromise]).then(
986
+ })["catch"](function () {});
987
+ Promise.all([storePromise, pageLayoutPromise, pageModePromise, openActionDestPromise]).then(
974
988
  /*#__PURE__*/
975
989
  function () {
976
990
  var _ref3 = _asyncToGenerator(
977
991
  /*#__PURE__*/
978
- _regenerator.default.mark(function _callee8(_ref2) {
979
- var _ref4, _ref4$, values, pageMode, openActionDest, viewOnLoad, initialBookmark, zoom, hash, rotation, sidebarView, scrollMode, spreadMode;
992
+ _regenerator["default"].mark(function _callee8(_ref2) {
993
+ var _ref4, _ref4$, values, pageLayout, pageMode, openActionDest, viewOnLoad, initialBookmark, zoom, hash, rotation, sidebarView, scrollMode, spreadMode;
980
994
 
981
- return _regenerator.default.wrap(function _callee8$(_context8) {
995
+ return _regenerator["default"].wrap(function _callee8$(_context8) {
982
996
  while (1) {
983
997
  switch (_context8.prev = _context8.next) {
984
998
  case 0:
985
- _ref4 = _slicedToArray(_ref2, 3), _ref4$ = _ref4[0], values = _ref4$ === void 0 ? {} : _ref4$, pageMode = _ref4[1], openActionDest = _ref4[2];
999
+ _ref4 = _slicedToArray(_ref2, 4), _ref4$ = _ref4[0], values = _ref4$ === void 0 ? {} : _ref4$, pageLayout = _ref4[1], pageMode = _ref4[2], openActionDest = _ref4[3];
986
1000
  viewOnLoad = _app_options.AppOptions.get('viewOnLoad');
987
1001
 
988
1002
  _this5._initializePdfHistory({
@@ -1020,6 +1034,10 @@ var PDFViewerApplication = {
1020
1034
  sidebarView = apiPageModeToSidebarView(pageMode);
1021
1035
  }
1022
1036
 
1037
+ if (pageLayout && spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
1038
+ spreadMode = apiPageLayoutToSpreadMode(pageLayout);
1039
+ }
1040
+
1023
1041
  _this5.setInitialView(hash, {
1024
1042
  rotation: rotation,
1025
1043
  sidebarView: sidebarView,
@@ -1035,45 +1053,45 @@ var PDFViewerApplication = {
1035
1053
  pdfViewer.focus();
1036
1054
  }
1037
1055
 
1038
- _context8.next = 17;
1056
+ _context8.next = 18;
1039
1057
  return Promise.race([pagesPromise, new Promise(function (resolve) {
1040
1058
  setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT);
1041
1059
  })]);
1042
1060
 
1043
- case 17:
1061
+ case 18:
1044
1062
  if (!(!initialBookmark && !hash)) {
1045
- _context8.next = 19;
1063
+ _context8.next = 20;
1046
1064
  break;
1047
1065
  }
1048
1066
 
1049
1067
  return _context8.abrupt("return");
1050
1068
 
1051
- case 19:
1069
+ case 20:
1052
1070
  if (!pdfViewer.hasEqualPageSizes) {
1053
- _context8.next = 21;
1071
+ _context8.next = 22;
1054
1072
  break;
1055
1073
  }
1056
1074
 
1057
1075
  return _context8.abrupt("return");
1058
1076
 
1059
- case 21:
1077
+ case 22:
1060
1078
  _this5.initialBookmark = initialBookmark;
1061
1079
  pdfViewer.currentScaleValue = pdfViewer.currentScaleValue;
1062
1080
 
1063
1081
  _this5.setInitialView(hash);
1064
1082
 
1065
- case 24:
1083
+ case 25:
1066
1084
  case "end":
1067
1085
  return _context8.stop();
1068
1086
  }
1069
1087
  }
1070
- }, _callee8, this);
1088
+ }, _callee8);
1071
1089
  }));
1072
1090
 
1073
1091
  return function (_x4) {
1074
1092
  return _ref3.apply(this, arguments);
1075
1093
  };
1076
- }()).catch(function () {
1094
+ }())["catch"](function () {
1077
1095
  _this5.setInitialView();
1078
1096
  }).then(function () {
1079
1097
  pdfViewer.update();
@@ -1361,6 +1379,7 @@ var PDFViewerApplication = {
1361
1379
  eventBus.on('previouspage', webViewerPreviousPage);
1362
1380
  eventBus.on('zoomin', webViewerZoomIn);
1363
1381
  eventBus.on('zoomout', webViewerZoomOut);
1382
+ eventBus.on('zoomreset', webViewerZoomReset);
1364
1383
  eventBus.on('pagenumberchanged', webViewerPageNumberChanged);
1365
1384
  eventBus.on('scalechanged', webViewerScaleChanged);
1366
1385
  eventBus.on('rotatecw', webViewerRotateCw);
@@ -1406,7 +1425,9 @@ var PDFViewerApplication = {
1406
1425
  };
1407
1426
 
1408
1427
  window.addEventListener('visibilitychange', webViewerVisibilityChange);
1409
- window.addEventListener('wheel', webViewerWheel);
1428
+ window.addEventListener('wheel', webViewerWheel, {
1429
+ passive: false
1430
+ });
1410
1431
  window.addEventListener('click', webViewerClick);
1411
1432
  window.addEventListener('keydown', webViewerKeyDown);
1412
1433
  window.addEventListener('resize', _boundEvents.windowResize);
@@ -1441,6 +1462,7 @@ var PDFViewerApplication = {
1441
1462
  eventBus.off('previouspage', webViewerPreviousPage);
1442
1463
  eventBus.off('zoomin', webViewerZoomIn);
1443
1464
  eventBus.off('zoomout', webViewerZoomOut);
1465
+ eventBus.off('zoomreset', webViewerZoomReset);
1444
1466
  eventBus.off('pagenumberchanged', webViewerPageNumberChanged);
1445
1467
  eventBus.off('scalechanged', webViewerScaleChanged);
1446
1468
  eventBus.off('rotatecw', webViewerRotateCw);
@@ -1726,7 +1748,7 @@ function webViewerSidebarViewChanged(evt) {
1726
1748
  var store = PDFViewerApplication.store;
1727
1749
 
1728
1750
  if (store && PDFViewerApplication.isInitialViewSet) {
1729
- store.set('sidebarView', evt.view).catch(function () {});
1751
+ store.set('sidebarView', evt.view)["catch"](function () {});
1730
1752
  }
1731
1753
  }
1732
1754
 
@@ -1741,7 +1763,7 @@ function webViewerUpdateViewarea(evt) {
1741
1763
  'scrollLeft': location.left,
1742
1764
  'scrollTop': location.top,
1743
1765
  'rotation': location.rotation
1744
- }).catch(function () {});
1766
+ })["catch"](function () {});
1745
1767
  }
1746
1768
 
1747
1769
  var href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
@@ -1756,7 +1778,7 @@ function webViewerScrollModeChanged(evt) {
1756
1778
  var store = PDFViewerApplication.store;
1757
1779
 
1758
1780
  if (store && PDFViewerApplication.isInitialViewSet) {
1759
- store.set('scrollMode', evt.mode).catch(function () {});
1781
+ store.set('scrollMode', evt.mode)["catch"](function () {});
1760
1782
  }
1761
1783
  }
1762
1784
 
@@ -1764,7 +1786,7 @@ function webViewerSpreadModeChanged(evt) {
1764
1786
  var store = PDFViewerApplication.store;
1765
1787
 
1766
1788
  if (store && PDFViewerApplication.isInitialViewSet) {
1767
- store.set('spreadMode', evt.mode).catch(function () {});
1789
+ store.set('spreadMode', evt.mode)["catch"](function () {});
1768
1790
  }
1769
1791
  }
1770
1792
 
@@ -1884,6 +1906,10 @@ function webViewerZoomOut() {
1884
1906
  PDFViewerApplication.zoomOut();
1885
1907
  }
1886
1908
 
1909
+ function webViewerZoomReset(evt) {
1910
+ PDFViewerApplication.zoomReset(evt && evt.ignoreDuplicate);
1911
+ }
1912
+
1887
1913
  function webViewerPageNumberChanged(evt) {
1888
1914
  var pdfViewer = PDFViewerApplication.pdfViewer;
1889
1915
 
@@ -2139,7 +2165,7 @@ function webViewerKeyDown(evt) {
2139
2165
  case 96:
2140
2166
  if (!isViewerInPresentationMode) {
2141
2167
  setTimeout(function () {
2142
- pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
2168
+ PDFViewerApplication.zoomReset();
2143
2169
  });
2144
2170
  handled = false;
2145
2171
  }
@@ -2366,6 +2392,24 @@ function webViewerKeyDown(evt) {
2366
2392
  }
2367
2393
  }
2368
2394
 
2395
+ function apiPageLayoutToSpreadMode(layout) {
2396
+ switch (layout) {
2397
+ case 'SinglePage':
2398
+ case 'OneColumn':
2399
+ return _ui_utils.SpreadMode.NONE;
2400
+
2401
+ case 'TwoColumnLeft':
2402
+ case 'TwoPageLeft':
2403
+ return _ui_utils.SpreadMode.ODD;
2404
+
2405
+ case 'TwoColumnRight':
2406
+ case 'TwoPageRight':
2407
+ return _ui_utils.SpreadMode.EVEN;
2408
+ }
2409
+
2410
+ return _ui_utils.SpreadMode.NONE;
2411
+ }
2412
+
2369
2413
  function apiPageModeToSidebarView(mode) {
2370
2414
  switch (mode) {
2371
2415
  case 'UseNone':