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,23 +19,31 @@
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.PDFDocumentProperties = undefined;
27
+ exports.PDFDocumentProperties = void 0;
28
28
 
29
- var _slicedToArray = function () { function sliceIterator(arr, i) { 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"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
29
+ var _ui_utils = require("./ui_utils");
30
30
 
31
- 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; }; }();
31
+ var _pdf = require("../pdf");
32
32
 
33
- var _ui_utils = require('./ui_utils');
33
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
34
34
 
35
- var _pdf = require('../pdf');
35
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
36
+
37
+ function _iterableToArrayLimit(arr, i) { 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; }
38
+
39
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
36
40
 
37
41
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
38
42
 
43
+ 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); } }
44
+
45
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
46
+
39
47
  var DEFAULT_FIELD_CONTENT = '-';
40
48
  var NON_METRIC_LOCALES = ['en-us', 'en-lr', 'my'];
41
49
  var US_PAGE_NAMES = {
@@ -46,21 +54,23 @@ var METRIC_PAGE_NAMES = {
46
54
  '297x420': 'A3',
47
55
  '210x297': 'A4'
48
56
  };
57
+
49
58
  function getPageName(size, isPortrait, pageNames) {
50
59
  var width = isPortrait ? size.width : size.height;
51
60
  var height = isPortrait ? size.height : size.width;
52
- return pageNames[width + 'x' + height];
61
+ return pageNames["".concat(width, "x").concat(height)];
53
62
  }
54
63
 
55
- var PDFDocumentProperties = function () {
64
+ var PDFDocumentProperties =
65
+ /*#__PURE__*/
66
+ function () {
56
67
  function PDFDocumentProperties(_ref, overlayManager, eventBus) {
68
+ var _this = this;
69
+
57
70
  var overlayName = _ref.overlayName,
58
71
  fields = _ref.fields,
59
72
  container = _ref.container,
60
73
  closeButton = _ref.closeButton;
61
-
62
- var _this = this;
63
-
64
74
  var l10n = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _ui_utils.NullL10n;
65
75
 
66
76
  _classCallCheck(this, PDFDocumentProperties);
@@ -70,11 +80,15 @@ var PDFDocumentProperties = function () {
70
80
  this.container = container;
71
81
  this.overlayManager = overlayManager;
72
82
  this.l10n = l10n;
83
+
73
84
  this._reset();
85
+
74
86
  if (closeButton) {
75
87
  closeButton.addEventListener('click', this.close.bind(this));
76
88
  }
89
+
77
90
  this.overlayManager.register(this.overlayName, this.container, this.close.bind(this));
91
+
78
92
  if (eventBus) {
79
93
  eventBus.on('pagechanging', function (evt) {
80
94
  _this._currentPageNumber = evt.pageNumber;
@@ -83,6 +97,7 @@ var PDFDocumentProperties = function () {
83
97
  _this._pagesRotation = evt.pagesRotation;
84
98
  });
85
99
  }
100
+
86
101
  this._isNonMetricLocale = true;
87
102
  l10n.getLanguage().then(function (locale) {
88
103
  _this._isNonMetricLocale = NON_METRIC_LOCALES.includes(locale);
@@ -90,7 +105,7 @@ var PDFDocumentProperties = function () {
90
105
  }
91
106
 
92
107
  _createClass(PDFDocumentProperties, [{
93
- key: 'open',
108
+ key: "open",
94
109
  value: function open() {
95
110
  var _this2 = this;
96
111
 
@@ -102,18 +117,21 @@ var PDFDocumentProperties = function () {
102
117
  configurable: true
103
118
  });
104
119
  };
120
+
105
121
  Promise.all([this.overlayManager.open(this.overlayName), this._dataAvailableCapability.promise]).then(function () {
106
122
  var currentPageNumber = _this2._currentPageNumber;
107
123
  var pagesRotation = _this2._pagesRotation;
124
+
108
125
  if (_this2.fieldData && currentPageNumber === _this2.fieldData['_currentPageNumber'] && pagesRotation === _this2.fieldData['_pagesRotation']) {
109
126
  _this2._updateUI();
127
+
110
128
  return;
111
129
  }
130
+
112
131
  _this2.pdfDocument.getMetadata().then(function (_ref2) {
113
132
  var info = _ref2.info,
114
133
  metadata = _ref2.metadata,
115
134
  contentDispositionFilename = _ref2.contentDispositionFilename;
116
-
117
135
  return Promise.all([info, metadata, contentDispositionFilename || (0, _ui_utils.getPDFFileNameFromURL)(_this2.url || ''), _this2._parseFileSize(_this2.maybeFileSize), _this2._parseDate(info.CreationDate), _this2._parseDate(info.ModDate), _this2.pdfDocument.getPage(currentPageNumber).then(function (pdfPage) {
118
136
  return _this2._parsePageSize((0, _ui_utils.getPageSizeInches)(pdfPage), pagesRotation);
119
137
  }), _this2._parseLinearization(info.IsLinearized)]);
@@ -146,54 +164,61 @@ var PDFDocumentProperties = function () {
146
164
  '_currentPageNumber': currentPageNumber,
147
165
  '_pagesRotation': pagesRotation
148
166
  });
167
+
149
168
  _this2._updateUI();
169
+
150
170
  return _this2.pdfDocument.getDownloadInfo();
151
171
  }).then(function (_ref5) {
152
172
  var length = _ref5.length;
153
-
154
173
  _this2.maybeFileSize = length;
155
174
  return _this2._parseFileSize(length);
156
175
  }).then(function (fileSize) {
157
176
  if (fileSize === _this2.fieldData['fileSize']) {
158
177
  return;
159
178
  }
179
+
160
180
  var data = Object.assign(Object.create(null), _this2.fieldData);
161
181
  data['fileSize'] = fileSize;
162
182
  freezeFieldData(data);
183
+
163
184
  _this2._updateUI();
164
185
  });
165
186
  });
166
187
  }
167
188
  }, {
168
- key: 'close',
189
+ key: "close",
169
190
  value: function close() {
170
191
  this.overlayManager.close(this.overlayName);
171
192
  }
172
193
  }, {
173
- key: 'setDocument',
194
+ key: "setDocument",
174
195
  value: function setDocument(pdfDocument) {
175
196
  var url = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
176
197
 
177
198
  if (this.pdfDocument) {
178
199
  this._reset();
200
+
179
201
  this._updateUI(true);
180
202
  }
203
+
181
204
  if (!pdfDocument) {
182
205
  return;
183
206
  }
207
+
184
208
  this.pdfDocument = pdfDocument;
185
209
  this.url = url;
210
+
186
211
  this._dataAvailableCapability.resolve();
187
212
  }
188
213
  }, {
189
- key: 'setFileSize',
214
+ key: "setFileSize",
190
215
  value: function setFileSize(fileSize) {
191
216
  if (Number.isInteger(fileSize) && fileSize > 0) {
192
217
  this.maybeFileSize = fileSize;
193
218
  }
194
219
  }
195
220
  }, {
196
- key: '_reset',
221
+ key: "_reset",
197
222
  value: function _reset() {
198
223
  this.pdfDocument = null;
199
224
  this.url = null;
@@ -204,7 +229,7 @@ var PDFDocumentProperties = function () {
204
229
  this._pagesRotation = 0;
205
230
  }
206
231
  }, {
207
- key: '_updateUI',
232
+ key: "_updateUI",
208
233
  value: function _updateUI() {
209
234
  var reset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
210
235
 
@@ -212,22 +237,25 @@ var PDFDocumentProperties = function () {
212
237
  for (var id in this.fields) {
213
238
  this.fields[id].textContent = DEFAULT_FIELD_CONTENT;
214
239
  }
240
+
215
241
  return;
216
242
  }
243
+
217
244
  if (this.overlayManager.active !== this.overlayName) {
218
245
  return;
219
246
  }
247
+
220
248
  for (var _id in this.fields) {
221
249
  var content = this.fieldData[_id];
222
250
  this.fields[_id].textContent = content || content === 0 ? content : DEFAULT_FIELD_CONTENT;
223
251
  }
224
252
  }
225
253
  }, {
226
- key: '_parseFileSize',
254
+ key: "_parseFileSize",
227
255
  value: function _parseFileSize() {
228
256
  var fileSize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
229
-
230
257
  var kb = fileSize / 1024;
258
+
231
259
  if (!kb) {
232
260
  return Promise.resolve(undefined);
233
261
  } else if (kb < 1024) {
@@ -236,25 +264,28 @@ var PDFDocumentProperties = function () {
236
264
  size_b: fileSize.toLocaleString()
237
265
  }, '{{size_kb}} KB ({{size_b}} bytes)');
238
266
  }
267
+
239
268
  return this.l10n.get('document_properties_mb', {
240
269
  size_mb: (+(kb / 1024).toPrecision(3)).toLocaleString(),
241
270
  size_b: fileSize.toLocaleString()
242
271
  }, '{{size_mb}} MB ({{size_b}} bytes)');
243
272
  }
244
273
  }, {
245
- key: '_parsePageSize',
274
+ key: "_parsePageSize",
246
275
  value: function _parsePageSize(pageSizeInches, pagesRotation) {
247
276
  var _this3 = this;
248
277
 
249
278
  if (!pageSizeInches) {
250
279
  return Promise.resolve(undefined);
251
280
  }
281
+
252
282
  if (pagesRotation % 180 !== 0) {
253
283
  pageSizeInches = {
254
284
  width: pageSizeInches.height,
255
285
  height: pageSizeInches.width
256
286
  };
257
287
  }
288
+
258
289
  var isPortrait = (0, _ui_utils.isPortraitOrientation)(pageSizeInches);
259
290
  var sizeInches = {
260
291
  width: Math.round(pageSizeInches.width * 100) / 100,
@@ -266,6 +297,7 @@ var PDFDocumentProperties = function () {
266
297
  };
267
298
  var pageName = null;
268
299
  var name = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) || getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES);
300
+
269
301
  if (!name && !(Number.isInteger(sizeMillimeters.width) && Number.isInteger(sizeMillimeters.height))) {
270
302
  var exactMillimeters = {
271
303
  width: pageSizeInches.width * 25.4,
@@ -275,8 +307,10 @@ var PDFDocumentProperties = function () {
275
307
  width: Math.round(sizeMillimeters.width),
276
308
  height: Math.round(sizeMillimeters.height)
277
309
  };
310
+
278
311
  if (Math.abs(exactMillimeters.width - intMillimeters.width) < 0.1 && Math.abs(exactMillimeters.height - intMillimeters.height) < 0.1) {
279
312
  name = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES);
313
+
280
314
  if (name) {
281
315
  sizeInches = {
282
316
  width: Math.round(intMillimeters.width / 25.4 * 100) / 100,
@@ -286,9 +320,11 @@ var PDFDocumentProperties = function () {
286
320
  }
287
321
  }
288
322
  }
323
+
289
324
  if (name) {
290
325
  pageName = this.l10n.get('document_properties_page_size_name_' + name.toLowerCase(), null, name);
291
326
  }
327
+
292
328
  return Promise.all([this._isNonMetricLocale ? sizeInches : sizeMillimeters, this.l10n.get('document_properties_page_size_unit_' + (this._isNonMetricLocale ? 'inches' : 'millimeters'), null, this._isNonMetricLocale ? 'in' : 'mm'), pageName, this.l10n.get('document_properties_page_size_orientation_' + (isPortrait ? 'portrait' : 'landscape'), null, isPortrait ? 'portrait' : 'landscape')]).then(function (_ref6) {
293
329
  var _ref7 = _slicedToArray(_ref6, 4),
294
330
  _ref7$ = _ref7[0],
@@ -308,15 +344,18 @@ var PDFDocumentProperties = function () {
308
344
  });
309
345
  }
310
346
  }, {
311
- key: '_parseDate',
347
+ key: "_parseDate",
312
348
  value: function _parseDate(inputDate) {
313
349
  if (!inputDate) {
314
350
  return;
315
351
  }
352
+
316
353
  var dateToParse = inputDate;
354
+
317
355
  if (dateToParse.substring(0, 2) === 'D:') {
318
356
  dateToParse = dateToParse.substring(2);
319
357
  }
358
+
320
359
  var year = parseInt(dateToParse.substring(0, 4), 10);
321
360
  var month = parseInt(dateToParse.substring(4, 6), 10) - 1;
322
361
  var day = parseInt(dateToParse.substring(6, 8), 10);
@@ -326,6 +365,7 @@ var PDFDocumentProperties = function () {
326
365
  var utRel = dateToParse.substring(14, 15);
327
366
  var offsetHours = parseInt(dateToParse.substring(15, 17), 10);
328
367
  var offsetMinutes = parseInt(dateToParse.substring(18, 20), 10);
368
+
329
369
  if (utRel === '-') {
330
370
  hours += offsetHours;
331
371
  minutes += offsetMinutes;
@@ -333,6 +373,7 @@ var PDFDocumentProperties = function () {
333
373
  hours -= offsetHours;
334
374
  minutes -= offsetMinutes;
335
375
  }
376
+
336
377
  var date = new Date(Date.UTC(year, month, day, hours, minutes, seconds));
337
378
  var dateString = date.toLocaleDateString();
338
379
  var timeString = date.toLocaleTimeString();
@@ -342,7 +383,7 @@ var PDFDocumentProperties = function () {
342
383
  }, '{{date}}, {{time}}');
343
384
  }
344
385
  }, {
345
- key: '_parseLinearization',
386
+ key: "_parseLinearization",
346
387
  value: function _parseLinearization(isLinearized) {
347
388
  return this.l10n.get('document_properties_linearized_' + (isLinearized ? 'yes' : 'no'), null, isLinearized ? 'Yes' : 'No');
348
389
  }
@@ -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.PDFFindBar = undefined;
27
+ exports.PDFFindBar = 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_find_controller = require('./pdf_find_controller');
31
+ var _pdf_find_controller = require("./pdf_find_controller");
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 MATCHES_COUNT_LIMIT = 1000;
38
40
 
39
- var PDFFindBar = function () {
41
+ var PDFFindBar =
42
+ /*#__PURE__*/
43
+ function () {
40
44
  function PDFFindBar(options) {
41
45
  var _this = this;
42
46
 
@@ -70,9 +74,12 @@ var PDFFindBar = function () {
70
74
  if (e.target === _this.findField) {
71
75
  _this.dispatchEvent('again', e.shiftKey);
72
76
  }
77
+
73
78
  break;
79
+
74
80
  case 27:
75
81
  _this.close();
82
+
76
83
  break;
77
84
  }
78
85
  });
@@ -95,12 +102,12 @@ var PDFFindBar = function () {
95
102
  }
96
103
 
97
104
  _createClass(PDFFindBar, [{
98
- key: 'reset',
105
+ key: "reset",
99
106
  value: function reset() {
100
107
  this.updateUIState();
101
108
  }
102
109
  }, {
103
- key: 'dispatchEvent',
110
+ key: "dispatchEvent",
104
111
  value: function dispatchEvent(type, findPrev) {
105
112
  this.eventBus.dispatch('find', {
106
113
  source: this,
@@ -114,58 +121,69 @@ var PDFFindBar = function () {
114
121
  });
115
122
  }
116
123
  }, {
117
- key: 'updateUIState',
124
+ key: "updateUIState",
118
125
  value: function updateUIState(state, previous, matchesCount) {
119
126
  var _this2 = this;
120
127
 
121
128
  var notFound = false;
122
129
  var findMsg = '';
123
130
  var status = '';
131
+
124
132
  switch (state) {
125
133
  case _pdf_find_controller.FindState.FOUND:
126
134
  break;
135
+
127
136
  case _pdf_find_controller.FindState.PENDING:
128
137
  status = 'pending';
129
138
  break;
139
+
130
140
  case _pdf_find_controller.FindState.NOT_FOUND:
131
141
  findMsg = this.l10n.get('find_not_found', null, 'Phrase not found');
132
142
  notFound = true;
133
143
  break;
144
+
134
145
  case _pdf_find_controller.FindState.WRAPPED:
135
146
  if (previous) {
136
147
  findMsg = this.l10n.get('find_reached_top', null, 'Reached top of document, continued from bottom');
137
148
  } else {
138
149
  findMsg = this.l10n.get('find_reached_bottom', null, 'Reached end of document, continued from top');
139
150
  }
151
+
140
152
  break;
141
153
  }
154
+
142
155
  this.findField.classList.toggle('notFound', notFound);
143
156
  this.findField.setAttribute('data-status', status);
144
157
  Promise.resolve(findMsg).then(function (msg) {
145
158
  _this2.findMsg.textContent = msg;
159
+
146
160
  _this2._adjustWidth();
147
161
  });
148
162
  this.updateResultsCount(matchesCount);
149
163
  }
150
164
  }, {
151
- key: 'updateResultsCount',
165
+ key: "updateResultsCount",
152
166
  value: function updateResultsCount() {
153
167
  var _this3 = this;
154
168
 
155
169
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
156
170
  _ref$current = _ref.current,
157
- current = _ref$current === undefined ? 0 : _ref$current,
171
+ current = _ref$current === void 0 ? 0 : _ref$current,
158
172
  _ref$total = _ref.total,
159
- total = _ref$total === undefined ? 0 : _ref$total;
173
+ total = _ref$total === void 0 ? 0 : _ref$total;
160
174
 
161
175
  if (!this.findResultsCount) {
162
176
  return;
163
177
  }
178
+
164
179
  var matchesCountMsg = '',
165
180
  limit = MATCHES_COUNT_LIMIT;
181
+
166
182
  if (total > 0) {
167
183
  if (total > limit) {
168
- matchesCountMsg = this.l10n.get('find_match_count_limit', { limit: limit }, 'More than {{limit}} match' + (limit !== 1 ? 'es' : ''));
184
+ matchesCountMsg = this.l10n.get('find_match_count_limit', {
185
+ limit: limit
186
+ }, 'More than {{limit}} match' + (limit !== 1 ? 'es' : ''));
169
187
  } else {
170
188
  matchesCountMsg = this.l10n.get('find_match_count', {
171
189
  current: current,
@@ -173,37 +191,45 @@ var PDFFindBar = function () {
173
191
  }, '{{current}} of {{total}} match' + (total !== 1 ? 'es' : ''));
174
192
  }
175
193
  }
194
+
176
195
  Promise.resolve(matchesCountMsg).then(function (msg) {
177
196
  _this3.findResultsCount.textContent = msg;
178
- _this3.findResultsCount.classList[!total ? 'add' : 'remove']('hidden');
197
+
198
+ _this3.findResultsCount.classList.toggle('hidden', !total);
199
+
179
200
  _this3._adjustWidth();
180
201
  });
181
202
  }
182
203
  }, {
183
- key: 'open',
204
+ key: "open",
184
205
  value: function open() {
185
206
  if (!this.opened) {
186
207
  this.opened = true;
187
208
  this.toggleButton.classList.add('toggled');
188
209
  this.bar.classList.remove('hidden');
189
210
  }
211
+
190
212
  this.findField.select();
191
213
  this.findField.focus();
214
+
192
215
  this._adjustWidth();
193
216
  }
194
217
  }, {
195
- key: 'close',
218
+ key: "close",
196
219
  value: function close() {
197
220
  if (!this.opened) {
198
221
  return;
199
222
  }
223
+
200
224
  this.opened = false;
201
225
  this.toggleButton.classList.remove('toggled');
202
226
  this.bar.classList.add('hidden');
203
- this.eventBus.dispatch('findbarclose', { source: this });
227
+ this.eventBus.dispatch('findbarclose', {
228
+ source: this
229
+ });
204
230
  }
205
231
  }, {
206
- key: 'toggle',
232
+ key: "toggle",
207
233
  value: function toggle() {
208
234
  if (this.opened) {
209
235
  this.close();
@@ -212,14 +238,16 @@ var PDFFindBar = function () {
212
238
  }
213
239
  }
214
240
  }, {
215
- key: '_adjustWidth',
241
+ key: "_adjustWidth",
216
242
  value: function _adjustWidth() {
217
243
  if (!this.opened) {
218
244
  return;
219
245
  }
246
+
220
247
  this.bar.classList.remove('wrapContainers');
221
248
  var findbarHeight = this.bar.clientHeight;
222
249
  var inputContainerHeight = this.bar.firstElementChild.clientHeight;
250
+
223
251
  if (findbarHeight > inputContainerHeight) {
224
252
  this.bar.classList.add('wrapContainers');
225
253
  }