pdfjs-dist 2.0.943 → 2.1.266

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 (159) hide show
  1. package/bower.json +1 -1
  2. package/build/pdf.js +15329 -11095
  3. package/build/pdf.js.map +1 -1
  4. package/build/pdf.min.js +1 -1
  5. package/build/pdf.worker.js +12497 -4184
  6. package/build/pdf.worker.js.map +1 -1
  7. package/build/pdf.worker.min.js +1 -1
  8. package/image_decoders/pdf.image_decoders.js +3438 -1209
  9. package/image_decoders/pdf.image_decoders.js.map +1 -1
  10. package/image_decoders/pdf.image_decoders.min.js +1 -1
  11. package/lib/core/annotation.js +335 -109
  12. package/lib/core/arithmetic_decoder.js +274 -244
  13. package/lib/core/bidi.js +64 -5
  14. package/lib/core/ccitt.js +172 -17
  15. package/lib/core/ccitt_stream.js +14 -5
  16. package/lib/core/cff_parser.js +304 -28
  17. package/lib/core/charsets.js +4 -3
  18. package/lib/core/chunked_stream.js +379 -149
  19. package/lib/core/cmap.js +210 -40
  20. package/lib/core/colorspace.js +332 -187
  21. package/lib/core/crypto.js +289 -44
  22. package/lib/core/document.js +508 -249
  23. package/lib/core/encodings.js +18 -9
  24. package/lib/core/evaluator.js +657 -119
  25. package/lib/core/font_renderer.js +217 -34
  26. package/lib/core/fonts.js +632 -41
  27. package/lib/core/function.js +252 -26
  28. package/lib/core/glyphlist.js +2 -1
  29. package/lib/core/image.js +124 -27
  30. package/lib/core/jbig2.js +425 -65
  31. package/lib/core/jbig2_stream.js +18 -7
  32. package/lib/core/jpeg_stream.js +24 -8
  33. package/lib/core/jpg.js +208 -16
  34. package/lib/core/jpx.js +395 -5
  35. package/lib/core/jpx_stream.js +17 -5
  36. package/lib/core/metrics.js +3 -3
  37. package/lib/core/murmurhash3.js +23 -5
  38. package/lib/core/obj.js +625 -132
  39. package/lib/core/operator_list.js +104 -3
  40. package/lib/core/parser.js +262 -25
  41. package/lib/core/pattern.js +144 -12
  42. package/lib/core/pdf_manager.js +104 -70
  43. package/lib/core/primitives.js +74 -21
  44. package/lib/core/ps_parser.js +133 -44
  45. package/lib/core/standard_fonts.js +9 -9
  46. package/lib/core/stream.js +283 -31
  47. package/lib/core/type1_parser.js +138 -6
  48. package/lib/core/unicode.js +28 -1
  49. package/lib/core/worker.js +192 -57
  50. package/lib/display/annotation_layer.js +303 -123
  51. package/lib/display/api.js +1073 -574
  52. package/lib/display/api_compatibility.js +4 -1
  53. package/lib/display/canvas.js +314 -18
  54. package/lib/display/content_disposition.js +70 -23
  55. package/lib/display/dom_utils.js +112 -59
  56. package/lib/display/fetch_stream.js +95 -50
  57. package/lib/display/font_loader.js +250 -132
  58. package/lib/display/metadata.js +37 -15
  59. package/lib/display/network.js +123 -34
  60. package/lib/display/network_utils.js +23 -10
  61. package/lib/display/node_stream.js +162 -65
  62. package/lib/display/pattern_helper.js +57 -6
  63. package/lib/display/svg.js +194 -18
  64. package/lib/display/text_layer.js +128 -14
  65. package/lib/display/transport_stream.js +83 -27
  66. package/lib/display/webgl.js +63 -17
  67. package/lib/display/worker_options.js +4 -3
  68. package/lib/display/xml_parser.js +162 -52
  69. package/lib/examples/node/domstubs.js +56 -3
  70. package/lib/pdf.js +15 -2
  71. package/lib/pdf.worker.js +4 -2
  72. package/lib/shared/compatibility.js +129 -26
  73. package/lib/shared/global_scope.js +1 -1
  74. package/lib/shared/is_node.js +3 -3
  75. package/lib/shared/message_handler.js +103 -45
  76. package/lib/shared/streams_polyfill.js +20 -16
  77. package/lib/shared/url_polyfill.js +8 -2
  78. package/lib/shared/util.js +246 -84
  79. package/lib/test/unit/annotation_spec.js +99 -73
  80. package/lib/test/unit/api_spec.js +347 -113
  81. package/lib/test/unit/bidi_spec.js +6 -6
  82. package/lib/test/unit/cff_parser_spec.js +17 -5
  83. package/lib/test/unit/clitests_helper.js +7 -8
  84. package/lib/test/unit/cmap_spec.js +79 -25
  85. package/lib/test/unit/colorspace_spec.js +65 -18
  86. package/lib/test/unit/crypto_spec.js +16 -4
  87. package/lib/test/unit/custom_spec.js +40 -52
  88. package/lib/test/unit/display_svg_spec.js +32 -16
  89. package/lib/test/unit/document_spec.js +2 -2
  90. package/lib/test/unit/dom_utils_spec.js +8 -8
  91. package/lib/test/unit/encodings_spec.js +24 -44
  92. package/lib/test/unit/evaluator_spec.js +15 -8
  93. package/lib/test/unit/function_spec.js +16 -4
  94. package/lib/test/unit/jasmine-boot.js +29 -16
  95. package/lib/test/unit/message_handler_spec.js +19 -6
  96. package/lib/test/unit/metadata_spec.js +64 -11
  97. package/lib/test/unit/murmurhash3_spec.js +2 -2
  98. package/lib/test/unit/network_spec.js +19 -4
  99. package/lib/test/unit/network_utils_spec.js +6 -4
  100. package/lib/test/unit/node_stream_spec.js +50 -26
  101. package/lib/test/unit/parser_spec.js +13 -29
  102. package/lib/test/unit/pdf_find_controller_spec.js +144 -32
  103. package/lib/test/unit/pdf_find_utils_spec.js +10 -9
  104. package/lib/test/unit/pdf_history_spec.js +20 -8
  105. package/lib/test/unit/primitives_spec.js +23 -3
  106. package/lib/test/unit/stream_spec.js +8 -3
  107. package/lib/test/unit/test_utils.js +89 -26
  108. package/lib/test/unit/testreporter.js +19 -1
  109. package/lib/test/unit/type1_parser_spec.js +7 -5
  110. package/lib/test/unit/ui_utils_spec.js +162 -38
  111. package/lib/test/unit/unicode_spec.js +13 -10
  112. package/lib/test/unit/util_spec.js +89 -9
  113. package/lib/web/annotation_layer_builder.js +38 -21
  114. package/lib/web/app.js +610 -245
  115. package/lib/web/app_options.js +54 -34
  116. package/lib/web/base_viewer.js +359 -162
  117. package/lib/web/chromecom.js +159 -80
  118. package/lib/web/debugger.js +161 -17
  119. package/lib/web/download_manager.js +29 -11
  120. package/lib/web/firefox_print_service.js +16 -8
  121. package/lib/web/firefoxcom.js +127 -91
  122. package/lib/web/genericcom.js +50 -31
  123. package/lib/web/genericl10n.js +46 -34
  124. package/lib/web/grab_to_pan.js +25 -3
  125. package/lib/web/interfaces.js +108 -61
  126. package/lib/web/overlay_manager.js +67 -45
  127. package/lib/web/password_prompt.js +20 -12
  128. package/lib/web/pdf_attachment_viewer.js +37 -17
  129. package/lib/web/pdf_cursor_tools.js +38 -15
  130. package/lib/web/pdf_document_properties.js +65 -24
  131. package/lib/web/pdf_find_bar.js +48 -20
  132. package/lib/web/pdf_find_controller.js +290 -89
  133. package/lib/web/pdf_find_utils.js +19 -3
  134. package/lib/web/pdf_history.js +186 -49
  135. package/lib/web/pdf_link_service.js +127 -52
  136. package/lib/web/pdf_outline_viewer.js +71 -21
  137. package/lib/web/pdf_page_view.js +188 -63
  138. package/lib/web/pdf_presentation_mode.js +98 -33
  139. package/lib/web/pdf_print_service.js +54 -10
  140. package/lib/web/pdf_rendering_queue.js +26 -4
  141. package/lib/web/pdf_sidebar.js +116 -62
  142. package/lib/web/pdf_sidebar_resizer.js +41 -15
  143. package/lib/web/pdf_single_page_viewer.js +65 -68
  144. package/lib/web/pdf_thumbnail_view.js +102 -31
  145. package/lib/web/pdf_thumbnail_viewer.js +62 -22
  146. package/lib/web/pdf_viewer.component.js +111 -31
  147. package/lib/web/pdf_viewer.js +80 -60
  148. package/lib/web/preferences.js +61 -39
  149. package/lib/web/secondary_toolbar.js +101 -82
  150. package/lib/web/text_layer_builder.js +124 -69
  151. package/lib/web/toolbar.js +67 -27
  152. package/lib/web/ui_utils.js +284 -128
  153. package/lib/web/view_history.js +75 -51
  154. package/lib/web/viewer_compatibility.js +2 -1
  155. package/package.json +1 -1
  156. package/web/pdf_viewer.css +1 -1
  157. package/web/pdf_viewer.js +2200 -973
  158. package/web/pdf_viewer.js.map +1 -1
  159. package/lib/web/dom_events.js +0 -140
@@ -19,30 +19,37 @@
19
19
  * @licend The above is the entire license notice for the
20
20
  * Javascript code in this page
21
21
  */
22
- 'use strict';
22
+ "use strict";
23
23
 
24
24
  Object.defineProperty(exports, "__esModule", {
25
25
  value: true
26
26
  });
27
- exports.PDFSidebar = exports.SidebarView = undefined;
27
+ exports.PDFSidebar = exports.SidebarView = void 0;
28
28
 
29
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
29
+ var _ui_utils = require("./ui_utils");
30
30
 
31
- var _ui_utils = require('./ui_utils');
32
-
33
- var _pdf_rendering_queue = require('./pdf_rendering_queue');
31
+ var _pdf_rendering_queue = require("./pdf_rendering_queue");
34
32
 
35
33
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
36
34
 
35
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
36
+
37
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
38
+
37
39
  var UI_NOTIFICATION_CLASS = 'pdfSidebarNotification';
38
40
  var SidebarView = {
41
+ UNKNOWN: -1,
39
42
  NONE: 0,
40
43
  THUMBS: 1,
41
44
  OUTLINE: 2,
42
- ATTACHMENTS: 3
45
+ ATTACHMENTS: 3,
46
+ LAYERS: 4
43
47
  };
48
+ exports.SidebarView = SidebarView;
44
49
 
45
- var PDFSidebar = function () {
50
+ var PDFSidebar =
51
+ /*#__PURE__*/
52
+ function () {
46
53
  function PDFSidebar(options, eventBus) {
47
54
  var l10n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _ui_utils.NullL10n;
48
55
 
@@ -66,132 +73,157 @@ var PDFSidebar = function () {
66
73
  this.disableNotification = options.disableNotification || false;
67
74
  this.eventBus = eventBus;
68
75
  this.l10n = l10n;
76
+
69
77
  this._addEventListeners();
70
78
  }
71
79
 
72
80
  _createClass(PDFSidebar, [{
73
- key: 'reset',
81
+ key: "reset",
74
82
  value: function reset() {
75
83
  this.isInitialViewSet = false;
84
+
76
85
  this._hideUINotification(null);
86
+
77
87
  this.switchView(SidebarView.THUMBS);
78
88
  this.outlineButton.disabled = false;
79
89
  this.attachmentsButton.disabled = false;
80
90
  }
81
91
  }, {
82
- key: 'setInitialView',
92
+ key: "setInitialView",
83
93
  value: function setInitialView() {
84
94
  var view = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : SidebarView.NONE;
85
95
 
86
96
  if (this.isInitialViewSet) {
87
97
  return;
88
98
  }
99
+
89
100
  this.isInitialViewSet = true;
90
- if (this.isOpen && view === SidebarView.NONE) {
101
+
102
+ if (view === SidebarView.NONE || view === SidebarView.UNKNOWN) {
91
103
  this._dispatchEvent();
104
+
92
105
  return;
93
106
  }
94
- var isViewPreserved = view === this.visibleView;
95
- this.switchView(view, true);
96
- if (isViewPreserved) {
107
+
108
+ if (!this._switchView(view, true)) {
97
109
  this._dispatchEvent();
98
110
  }
99
111
  }
100
112
  }, {
101
- key: 'switchView',
113
+ key: "switchView",
102
114
  value: function switchView(view) {
103
115
  var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
104
116
 
105
- if (view === SidebarView.NONE) {
106
- this.close();
107
- return;
108
- }
117
+ this._switchView(view, forceOpen);
118
+ }
119
+ }, {
120
+ key: "_switchView",
121
+ value: function _switchView(view) {
122
+ var forceOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
109
123
  var isViewChanged = view !== this.active;
110
124
  var shouldForceRendering = false;
125
+
111
126
  switch (view) {
127
+ case SidebarView.NONE:
128
+ if (this.isOpen) {
129
+ this.close();
130
+ return true;
131
+ }
132
+
133
+ return false;
134
+
112
135
  case SidebarView.THUMBS:
113
- this.thumbnailButton.classList.add('toggled');
114
- this.outlineButton.classList.remove('toggled');
115
- this.attachmentsButton.classList.remove('toggled');
116
- this.thumbnailView.classList.remove('hidden');
117
- this.outlineView.classList.add('hidden');
118
- this.attachmentsView.classList.add('hidden');
119
136
  if (this.isOpen && isViewChanged) {
120
- this._updateThumbnailViewer();
121
137
  shouldForceRendering = true;
122
138
  }
139
+
123
140
  break;
141
+
124
142
  case SidebarView.OUTLINE:
125
143
  if (this.outlineButton.disabled) {
126
- return;
144
+ return false;
127
145
  }
128
- this.thumbnailButton.classList.remove('toggled');
129
- this.outlineButton.classList.add('toggled');
130
- this.attachmentsButton.classList.remove('toggled');
131
- this.thumbnailView.classList.add('hidden');
132
- this.outlineView.classList.remove('hidden');
133
- this.attachmentsView.classList.add('hidden');
146
+
134
147
  break;
148
+
135
149
  case SidebarView.ATTACHMENTS:
136
150
  if (this.attachmentsButton.disabled) {
137
- return;
151
+ return false;
138
152
  }
139
- this.thumbnailButton.classList.remove('toggled');
140
- this.outlineButton.classList.remove('toggled');
141
- this.attachmentsButton.classList.add('toggled');
142
- this.thumbnailView.classList.add('hidden');
143
- this.outlineView.classList.add('hidden');
144
- this.attachmentsView.classList.remove('hidden');
153
+
145
154
  break;
155
+
146
156
  default:
147
- console.error('PDFSidebar_switchView: "' + view + '" is an unsupported value.');
148
- return;
157
+ console.error("PDFSidebar._switchView: \"".concat(view, "\" is not a valid view."));
158
+ return false;
149
159
  }
150
- this.active = view | 0;
160
+
161
+ this.active = view;
162
+ this.thumbnailButton.classList.toggle('toggled', view === SidebarView.THUMBS);
163
+ this.outlineButton.classList.toggle('toggled', view === SidebarView.OUTLINE);
164
+ this.attachmentsButton.classList.toggle('toggled', view === SidebarView.ATTACHMENTS);
165
+ this.thumbnailView.classList.toggle('hidden', view !== SidebarView.THUMBS);
166
+ this.outlineView.classList.toggle('hidden', view !== SidebarView.OUTLINE);
167
+ this.attachmentsView.classList.toggle('hidden', view !== SidebarView.ATTACHMENTS);
168
+
151
169
  if (forceOpen && !this.isOpen) {
152
170
  this.open();
153
- return;
171
+ return true;
154
172
  }
173
+
155
174
  if (shouldForceRendering) {
175
+ this._updateThumbnailViewer();
176
+
156
177
  this._forceRendering();
157
178
  }
179
+
158
180
  if (isViewChanged) {
159
181
  this._dispatchEvent();
160
182
  }
183
+
161
184
  this._hideUINotification(this.active);
185
+
186
+ return isViewChanged;
162
187
  }
163
188
  }, {
164
- key: 'open',
189
+ key: "open",
165
190
  value: function open() {
166
191
  if (this.isOpen) {
167
192
  return;
168
193
  }
194
+
169
195
  this.isOpen = true;
170
196
  this.toggleButton.classList.add('toggled');
171
- this.outerContainer.classList.add('sidebarMoving');
172
- this.outerContainer.classList.add('sidebarOpen');
197
+ this.outerContainer.classList.add('sidebarMoving', 'sidebarOpen');
198
+
173
199
  if (this.active === SidebarView.THUMBS) {
174
200
  this._updateThumbnailViewer();
175
201
  }
202
+
176
203
  this._forceRendering();
204
+
177
205
  this._dispatchEvent();
206
+
178
207
  this._hideUINotification(this.active);
179
208
  }
180
209
  }, {
181
- key: 'close',
210
+ key: "close",
182
211
  value: function close() {
183
212
  if (!this.isOpen) {
184
213
  return;
185
214
  }
215
+
186
216
  this.isOpen = false;
187
217
  this.toggleButton.classList.remove('toggled');
188
218
  this.outerContainer.classList.add('sidebarMoving');
189
219
  this.outerContainer.classList.remove('sidebarOpen');
220
+
190
221
  this._forceRendering();
222
+
191
223
  this._dispatchEvent();
192
224
  }
193
225
  }, {
194
- key: 'toggle',
226
+ key: "toggle",
195
227
  value: function toggle() {
196
228
  if (this.isOpen) {
197
229
  this.close();
@@ -200,7 +232,7 @@ var PDFSidebar = function () {
200
232
  }
201
233
  }
202
234
  }, {
203
- key: '_dispatchEvent',
235
+ key: "_dispatchEvent",
204
236
  value: function _dispatchEvent() {
205
237
  this.eventBus.dispatch('sidebarviewchanged', {
206
238
  source: this,
@@ -208,7 +240,7 @@ var PDFSidebar = function () {
208
240
  });
209
241
  }
210
242
  }, {
211
- key: '_forceRendering',
243
+ key: "_forceRendering",
212
244
  value: function _forceRendering() {
213
245
  if (this.onToggled) {
214
246
  this.onToggled();
@@ -218,81 +250,96 @@ var PDFSidebar = function () {
218
250
  }
219
251
  }
220
252
  }, {
221
- key: '_updateThumbnailViewer',
253
+ key: "_updateThumbnailViewer",
222
254
  value: function _updateThumbnailViewer() {
223
255
  var pdfViewer = this.pdfViewer,
224
256
  pdfThumbnailViewer = this.pdfThumbnailViewer;
225
-
226
257
  var pagesCount = pdfViewer.pagesCount;
258
+
227
259
  for (var pageIndex = 0; pageIndex < pagesCount; pageIndex++) {
228
260
  var pageView = pdfViewer.getPageView(pageIndex);
261
+
229
262
  if (pageView && pageView.renderingState === _pdf_rendering_queue.RenderingStates.FINISHED) {
230
263
  var thumbnailView = pdfThumbnailViewer.getThumbnail(pageIndex);
231
264
  thumbnailView.setImage(pageView);
232
265
  }
233
266
  }
267
+
234
268
  pdfThumbnailViewer.scrollThumbnailIntoView(pdfViewer.currentPageNumber);
235
269
  }
236
270
  }, {
237
- key: '_showUINotification',
271
+ key: "_showUINotification",
238
272
  value: function _showUINotification(view) {
239
273
  var _this = this;
240
274
 
241
275
  if (this.disableNotification) {
242
276
  return;
243
277
  }
278
+
244
279
  this.l10n.get('toggle_sidebar_notification.title', null, 'Toggle Sidebar (document contains outline/attachments)').then(function (msg) {
245
280
  _this.toggleButton.title = msg;
246
281
  });
282
+
247
283
  if (!this.isOpen) {
248
284
  this.toggleButton.classList.add(UI_NOTIFICATION_CLASS);
249
285
  } else if (view === this.active) {
250
286
  return;
251
287
  }
288
+
252
289
  switch (view) {
253
290
  case SidebarView.OUTLINE:
254
291
  this.outlineButton.classList.add(UI_NOTIFICATION_CLASS);
255
292
  break;
293
+
256
294
  case SidebarView.ATTACHMENTS:
257
295
  this.attachmentsButton.classList.add(UI_NOTIFICATION_CLASS);
258
296
  break;
259
297
  }
260
298
  }
261
299
  }, {
262
- key: '_hideUINotification',
300
+ key: "_hideUINotification",
263
301
  value: function _hideUINotification(view) {
264
302
  var _this2 = this;
265
303
 
266
304
  if (this.disableNotification) {
267
305
  return;
268
306
  }
307
+
269
308
  var removeNotification = function removeNotification(view) {
270
309
  switch (view) {
271
310
  case SidebarView.OUTLINE:
272
311
  _this2.outlineButton.classList.remove(UI_NOTIFICATION_CLASS);
312
+
273
313
  break;
314
+
274
315
  case SidebarView.ATTACHMENTS:
275
316
  _this2.attachmentsButton.classList.remove(UI_NOTIFICATION_CLASS);
317
+
276
318
  break;
277
319
  }
278
320
  };
321
+
279
322
  if (!this.isOpen && view !== null) {
280
323
  return;
281
324
  }
325
+
282
326
  this.toggleButton.classList.remove(UI_NOTIFICATION_CLASS);
327
+
283
328
  if (view !== null) {
284
329
  removeNotification(view);
285
330
  return;
286
331
  }
332
+
287
333
  for (view in SidebarView) {
288
334
  removeNotification(SidebarView[view]);
289
335
  }
336
+
290
337
  this.l10n.get('toggle_sidebar.title', null, 'Toggle Sidebar').then(function (msg) {
291
338
  _this2.toggleButton.title = msg;
292
339
  });
293
340
  }
294
341
  }, {
295
- key: '_addEventListeners',
342
+ key: "_addEventListeners",
296
343
  value: function _addEventListeners() {
297
344
  var _this3 = this;
298
345
 
@@ -308,7 +355,9 @@ var PDFSidebar = function () {
308
355
  _this3.switchView(SidebarView.OUTLINE);
309
356
  });
310
357
  this.outlineButton.addEventListener('dblclick', function () {
311
- _this3.eventBus.dispatch('toggleoutlinetree', { source: _this3 });
358
+ _this3.eventBus.dispatch('toggleoutlinetree', {
359
+ source: _this3
360
+ });
312
361
  });
313
362
  this.attachmentsButton.addEventListener('click', function () {
314
363
  _this3.switchView(SidebarView.ATTACHMENTS);
@@ -316,6 +365,7 @@ var PDFSidebar = function () {
316
365
  this.eventBus.on('outlineloaded', function (evt) {
317
366
  var outlineCount = evt.outlineCount;
318
367
  _this3.outlineButton.disabled = !outlineCount;
368
+
319
369
  if (outlineCount) {
320
370
  _this3._showUINotification(SidebarView.OUTLINE);
321
371
  } else if (_this3.active === SidebarView.OUTLINE) {
@@ -325,14 +375,19 @@ var PDFSidebar = function () {
325
375
  this.eventBus.on('attachmentsloaded', function (evt) {
326
376
  if (evt.attachmentsCount) {
327
377
  _this3.attachmentsButton.disabled = false;
378
+
328
379
  _this3._showUINotification(SidebarView.ATTACHMENTS);
380
+
329
381
  return;
330
382
  }
383
+
331
384
  Promise.resolve().then(function () {
332
385
  if (_this3.attachmentsView.hasChildNodes()) {
333
386
  return;
334
387
  }
388
+
335
389
  _this3.attachmentsButton.disabled = true;
390
+
336
391
  if (_this3.active === SidebarView.ATTACHMENTS) {
337
392
  _this3.switchView(SidebarView.THUMBS);
338
393
  }
@@ -345,22 +400,22 @@ var PDFSidebar = function () {
345
400
  });
346
401
  }
347
402
  }, {
348
- key: 'visibleView',
403
+ key: "visibleView",
349
404
  get: function get() {
350
405
  return this.isOpen ? this.active : SidebarView.NONE;
351
406
  }
352
407
  }, {
353
- key: 'isThumbnailViewVisible',
408
+ key: "isThumbnailViewVisible",
354
409
  get: function get() {
355
410
  return this.isOpen && this.active === SidebarView.THUMBS;
356
411
  }
357
412
  }, {
358
- key: 'isOutlineViewVisible',
413
+ key: "isOutlineViewVisible",
359
414
  get: function get() {
360
415
  return this.isOpen && this.active === SidebarView.OUTLINE;
361
416
  }
362
417
  }, {
363
- key: 'isAttachmentsViewVisible',
418
+ key: "isAttachmentsViewVisible",
364
419
  get: function get() {
365
420
  return this.isOpen && this.active === SidebarView.ATTACHMENTS;
366
421
  }
@@ -369,5 +424,4 @@ var PDFSidebar = function () {
369
424
  return PDFSidebar;
370
425
  }();
371
426
 
372
- exports.SidebarView = SidebarView;
373
427
  exports.PDFSidebar = PDFSidebar;
@@ -19,24 +19,28 @@
19
19
  * @licend The above is the entire license notice for the
20
20
  * Javascript code in this page
21
21
  */
22
- 'use strict';
22
+ "use strict";
23
23
 
24
24
  Object.defineProperty(exports, "__esModule", {
25
25
  value: true
26
26
  });
27
- exports.PDFSidebarResizer = undefined;
27
+ exports.PDFSidebarResizer = void 0;
28
28
 
29
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
30
-
31
- var _ui_utils = require('./ui_utils');
29
+ var _ui_utils = require("./ui_utils");
32
30
 
33
31
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
34
32
 
33
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
34
+
35
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
36
+
35
37
  var SIDEBAR_WIDTH_VAR = '--sidebar-width';
36
38
  var SIDEBAR_MIN_WIDTH = 200;
37
39
  var SIDEBAR_RESIZING_CLASS = 'sidebarResizing';
38
40
 
39
- var PDFSidebarResizer = function () {
41
+ var PDFSidebarResizer =
42
+ /*#__PURE__*/
43
+ function () {
40
44
  function PDFSidebarResizer(options, eventBus) {
41
45
  var _this = this;
42
46
 
@@ -55,66 +59,79 @@ var PDFSidebarResizer = function () {
55
59
  this.resizer = options.resizer;
56
60
  this.eventBus = eventBus;
57
61
  this.l10n = l10n;
58
- if (typeof CSS === 'undefined' || typeof CSS.supports !== 'function' || !CSS.supports(SIDEBAR_WIDTH_VAR, 'calc(-1 * ' + SIDEBAR_MIN_WIDTH + 'px)')) {
62
+
63
+ if (typeof CSS === 'undefined' || typeof CSS.supports !== 'function' || !CSS.supports(SIDEBAR_WIDTH_VAR, "calc(-1 * ".concat(SIDEBAR_MIN_WIDTH, "px)"))) {
59
64
  console.warn('PDFSidebarResizer: ' + 'The browser does not support resizing of the sidebar.');
60
65
  return;
61
66
  }
67
+
62
68
  this.enabled = true;
63
69
  this.resizer.classList.remove('hidden');
64
70
  this.l10n.getDirection().then(function (dir) {
65
71
  _this.isRTL = dir === 'rtl';
66
72
  });
73
+
67
74
  this._addEventListeners();
68
75
  }
69
76
 
70
77
  _createClass(PDFSidebarResizer, [{
71
- key: '_updateWidth',
78
+ key: "_updateWidth",
72
79
  value: function _updateWidth() {
73
80
  var width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
74
81
 
75
82
  if (!this.enabled) {
76
83
  return false;
77
84
  }
85
+
78
86
  var maxWidth = Math.floor(this.outerContainerWidth / 2);
87
+
79
88
  if (width > maxWidth) {
80
89
  width = maxWidth;
81
90
  }
91
+
82
92
  if (width < SIDEBAR_MIN_WIDTH) {
83
93
  width = SIDEBAR_MIN_WIDTH;
84
94
  }
95
+
85
96
  if (width === this._width) {
86
97
  return false;
87
98
  }
99
+
88
100
  this._width = width;
89
- this.doc.style.setProperty(SIDEBAR_WIDTH_VAR, width + 'px');
101
+ this.doc.style.setProperty(SIDEBAR_WIDTH_VAR, "".concat(width, "px"));
90
102
  return true;
91
103
  }
92
104
  }, {
93
- key: '_mouseMove',
105
+ key: "_mouseMove",
94
106
  value: function _mouseMove(evt) {
95
107
  var width = evt.clientX;
108
+
96
109
  if (this.isRTL) {
97
110
  width = this.outerContainerWidth - width;
98
111
  }
112
+
99
113
  this._updateWidth(width);
100
114
  }
101
115
  }, {
102
- key: '_mouseUp',
116
+ key: "_mouseUp",
103
117
  value: function _mouseUp(evt) {
104
118
  this.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
105
- this.eventBus.dispatch('resize', { source: this });
119
+ this.eventBus.dispatch('resize', {
120
+ source: this
121
+ });
106
122
  var _boundEvents = this._boundEvents;
107
123
  window.removeEventListener('mousemove', _boundEvents.mouseMove);
108
124
  window.removeEventListener('mouseup', _boundEvents.mouseUp);
109
125
  }
110
126
  }, {
111
- key: '_addEventListeners',
127
+ key: "_addEventListeners",
112
128
  value: function _addEventListeners() {
113
129
  var _this2 = this;
114
130
 
115
131
  if (!this.enabled) {
116
132
  return;
117
133
  }
134
+
118
135
  var _boundEvents = this._boundEvents;
119
136
  _boundEvents.mouseMove = this._mouseMove.bind(this);
120
137
  _boundEvents.mouseUp = this._mouseUp.bind(this);
@@ -122,7 +139,9 @@ var PDFSidebarResizer = function () {
122
139
  if (evt.button !== 0) {
123
140
  return;
124
141
  }
142
+
125
143
  _this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
144
+
126
145
  window.addEventListener('mousemove', _boundEvents.mouseMove);
127
146
  window.addEventListener('mouseup', _boundEvents.mouseUp);
128
147
  });
@@ -132,14 +151,20 @@ var PDFSidebarResizer = function () {
132
151
  this.eventBus.on('resize', function (evt) {
133
152
  if (evt && evt.source === window) {
134
153
  _this2._outerContainerWidth = null;
154
+
135
155
  if (_this2._width) {
136
156
  if (_this2.sidebarOpen) {
137
157
  _this2.outerContainer.classList.add(SIDEBAR_RESIZING_CLASS);
158
+
138
159
  var updated = _this2._updateWidth(_this2._width);
160
+
139
161
  Promise.resolve().then(function () {
140
162
  _this2.outerContainer.classList.remove(SIDEBAR_RESIZING_CLASS);
163
+
141
164
  if (updated) {
142
- _this2.eventBus.dispatch('resize', { source: _this2 });
165
+ _this2.eventBus.dispatch('resize', {
166
+ source: _this2
167
+ });
143
168
  }
144
169
  });
145
170
  } else {
@@ -150,11 +175,12 @@ var PDFSidebarResizer = function () {
150
175
  });
151
176
  }
152
177
  }, {
153
- key: 'outerContainerWidth',
178
+ key: "outerContainerWidth",
154
179
  get: function get() {
155
180
  if (!this._outerContainerWidth) {
156
181
  this._outerContainerWidth = this.outerContainer.clientWidth;
157
182
  }
183
+
158
184
  return this._outerContainerWidth;
159
185
  }
160
186
  }]);