pdfjs-dist 2.0.943 → 2.4.456

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pdfjs-dist might be problematic. Click here for more details.

Files changed (192) hide show
  1. package/CODE_OF_CONDUCT.md +15 -0
  2. package/README.md +4 -0
  3. package/bower.json +1 -1
  4. package/build/pdf.js +8286 -14230
  5. package/build/pdf.js.map +1 -1
  6. package/build/pdf.min.js +22 -1
  7. package/build/pdf.worker.entry.js +5 -3
  8. package/build/pdf.worker.js +25500 -26628
  9. package/build/pdf.worker.js.map +1 -1
  10. package/build/pdf.worker.min.js +22 -1
  11. package/es5/build/pdf.js +25473 -0
  12. package/es5/build/pdf.js.map +1 -0
  13. package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
  14. package/es5/build/pdf.worker.js +57878 -0
  15. package/es5/build/pdf.worker.js.map +1 -0
  16. package/es5/web/images/annotation-check.svg +11 -0
  17. package/es5/web/images/annotation-comment.svg +16 -0
  18. package/es5/web/images/annotation-help.svg +26 -0
  19. package/es5/web/images/annotation-insert.svg +10 -0
  20. package/es5/web/images/annotation-key.svg +11 -0
  21. package/es5/web/images/annotation-newparagraph.svg +11 -0
  22. package/es5/web/images/annotation-noicon.svg +7 -0
  23. package/es5/web/images/annotation-note.svg +42 -0
  24. package/es5/web/images/annotation-paragraph.svg +16 -0
  25. package/es5/web/images/loading-icon.gif +0 -0
  26. package/es5/web/images/shadow.png +0 -0
  27. package/es5/web/images/texture.png +0 -0
  28. package/es5/web/pdf_viewer.css +407 -0
  29. package/es5/web/pdf_viewer.js +7757 -0
  30. package/es5/web/pdf_viewer.js.map +1 -0
  31. package/image_decoders/pdf.image_decoders.js +2887 -4094
  32. package/image_decoders/pdf.image_decoders.js.map +1 -1
  33. package/image_decoders/pdf.image_decoders.min.js +22 -1
  34. package/lib/README.md +7 -0
  35. package/lib/core/annotation.js +855 -778
  36. package/lib/core/arithmetic_decoder.js +325 -311
  37. package/lib/core/bidi.js +117 -50
  38. package/lib/core/ccitt.js +251 -89
  39. package/lib/core/ccitt_stream.js +26 -16
  40. package/lib/core/cff_parser.js +525 -197
  41. package/lib/core/charsets.js +6 -5
  42. package/lib/core/chunked_stream.js +541 -406
  43. package/lib/core/cmap.js +368 -253
  44. package/lib/core/colorspace.js +781 -800
  45. package/lib/core/core_utils.js +152 -0
  46. package/lib/core/crypto.js +609 -422
  47. package/lib/core/document.js +649 -481
  48. package/lib/core/encodings.js +33 -24
  49. package/lib/core/evaluator.js +1471 -736
  50. package/lib/core/font_renderer.js +289 -149
  51. package/lib/core/fonts.js +1067 -413
  52. package/lib/core/function.js +517 -287
  53. package/lib/core/glyphlist.js +4529 -4527
  54. package/lib/core/image.js +232 -114
  55. package/lib/core/image_utils.js +94 -0
  56. package/lib/core/jbig2.js +711 -342
  57. package/lib/core/jbig2_stream.js +31 -19
  58. package/lib/core/jpeg_stream.js +151 -26
  59. package/lib/core/jpg.js +433 -181
  60. package/lib/core/jpx.js +551 -143
  61. package/lib/core/jpx_stream.js +40 -28
  62. package/lib/core/metrics.js +2931 -2931
  63. package/lib/core/murmurhash3.js +104 -97
  64. package/lib/core/obj.js +1561 -1053
  65. package/lib/core/operator_list.js +192 -64
  66. package/lib/core/parser.js +1162 -864
  67. package/lib/core/pattern.js +224 -75
  68. package/lib/core/pdf_manager.js +154 -285
  69. package/lib/core/primitives.js +145 -69
  70. package/lib/core/ps_parser.js +212 -162
  71. package/lib/core/standard_fonts.js +245 -244
  72. package/lib/core/stream.js +353 -81
  73. package/lib/core/type1_parser.js +218 -68
  74. package/lib/core/unicode.js +1682 -1655
  75. package/lib/core/worker.js +233 -302
  76. package/lib/core/worker_stream.js +168 -0
  77. package/lib/display/annotation_layer.js +808 -862
  78. package/lib/display/api.js +1778 -1462
  79. package/lib/display/api_compatibility.js +14 -9
  80. package/lib/display/canvas.js +463 -140
  81. package/lib/display/content_disposition.js +86 -58
  82. package/lib/display/display_utils.js +524 -0
  83. package/lib/display/fetch_stream.js +202 -274
  84. package/lib/display/font_loader.js +311 -333
  85. package/lib/display/metadata.js +98 -88
  86. package/lib/display/network.js +343 -347
  87. package/lib/display/network_utils.js +46 -26
  88. package/lib/display/node_stream.js +326 -404
  89. package/lib/display/pattern_helper.js +168 -69
  90. package/lib/display/svg.js +1296 -885
  91. package/lib/display/text_layer.js +229 -103
  92. package/lib/display/transport_stream.js +290 -250
  93. package/lib/display/webgl.js +116 -83
  94. package/lib/display/worker_options.js +6 -5
  95. package/lib/display/xml_parser.js +358 -337
  96. package/lib/examples/node/domstubs.js +95 -39
  97. package/lib/pdf.js +49 -31
  98. package/lib/pdf.worker.js +7 -5
  99. package/lib/shared/compatibility.js +3 -145
  100. package/lib/shared/is_node.js +8 -7
  101. package/lib/shared/message_handler.js +367 -314
  102. package/lib/shared/util.js +421 -415
  103. package/lib/test/unit/annotation_spec.js +1570 -690
  104. package/lib/test/unit/api_spec.js +855 -493
  105. package/lib/test/unit/bidi_spec.js +12 -12
  106. package/lib/test/unit/cff_parser_spec.js +88 -61
  107. package/lib/test/unit/clitests_helper.js +9 -12
  108. package/lib/test/unit/cmap_spec.js +140 -88
  109. package/lib/test/unit/colorspace_spec.js +204 -152
  110. package/lib/test/unit/core_utils_spec.js +211 -0
  111. package/lib/test/unit/crypto_spec.js +194 -182
  112. package/lib/test/unit/custom_spec.js +50 -64
  113. package/lib/test/unit/display_svg_spec.js +53 -38
  114. package/lib/test/unit/display_utils_spec.js +263 -0
  115. package/lib/test/unit/document_spec.js +17 -22
  116. package/lib/test/unit/encodings_spec.js +15 -57
  117. package/lib/test/unit/evaluator_spec.js +90 -83
  118. package/lib/test/unit/fetch_stream_spec.js +111 -0
  119. package/lib/test/unit/function_spec.js +219 -205
  120. package/lib/test/unit/jasmine-boot.js +68 -39
  121. package/lib/test/unit/message_handler_spec.js +187 -160
  122. package/lib/test/unit/metadata_spec.js +87 -34
  123. package/lib/test/unit/murmurhash3_spec.js +13 -13
  124. package/lib/test/unit/network_spec.js +26 -59
  125. package/lib/test/unit/network_utils_spec.js +187 -121
  126. package/lib/test/unit/node_stream_spec.js +98 -90
  127. package/lib/test/unit/parser_spec.js +173 -131
  128. package/lib/test/unit/pdf_find_controller_spec.js +148 -67
  129. package/lib/test/unit/pdf_find_utils_spec.js +35 -34
  130. package/lib/test/unit/pdf_history_spec.js +45 -33
  131. package/lib/test/unit/primitives_spec.js +161 -126
  132. package/lib/test/unit/stream_spec.js +22 -15
  133. package/lib/test/unit/test_utils.js +149 -98
  134. package/lib/test/unit/testreporter.js +36 -18
  135. package/lib/test/unit/type1_parser_spec.js +46 -44
  136. package/lib/test/unit/ui_utils_spec.js +388 -372
  137. package/lib/test/unit/unicode_spec.js +49 -46
  138. package/lib/test/unit/util_spec.js +144 -248
  139. package/lib/web/annotation_layer_builder.js +75 -95
  140. package/lib/web/app.js +1538 -1147
  141. package/lib/web/app_options.js +116 -104
  142. package/lib/web/base_viewer.js +950 -775
  143. package/lib/web/chromecom.js +217 -225
  144. package/lib/web/debugger.js +236 -148
  145. package/lib/web/download_manager.js +50 -50
  146. package/lib/web/firefox_print_service.js +51 -33
  147. package/lib/web/firefoxcom.js +225 -352
  148. package/lib/web/genericcom.js +30 -93
  149. package/lib/web/genericl10n.js +26 -143
  150. package/lib/web/grab_to_pan.js +57 -33
  151. package/lib/web/interfaces.js +105 -232
  152. package/lib/web/overlay_manager.js +73 -227
  153. package/lib/web/password_prompt.js +44 -62
  154. package/lib/web/pdf_attachment_viewer.js +118 -123
  155. package/lib/web/pdf_cursor_tools.js +89 -93
  156. package/lib/web/pdf_document_properties.js +242 -281
  157. package/lib/web/pdf_find_bar.js +157 -163
  158. package/lib/web/pdf_find_controller.js +598 -454
  159. package/lib/web/pdf_find_utils.js +32 -16
  160. package/lib/web/pdf_history.js +481 -355
  161. package/lib/web/pdf_link_service.js +355 -323
  162. package/lib/web/pdf_outline_viewer.js +167 -152
  163. package/lib/web/pdf_page_view.js +511 -457
  164. package/lib/web/pdf_presentation_mode.js +347 -335
  165. package/lib/web/pdf_print_service.js +133 -103
  166. package/lib/web/pdf_rendering_queue.js +98 -100
  167. package/lib/web/pdf_sidebar.js +323 -299
  168. package/lib/web/pdf_sidebar_resizer.js +107 -108
  169. package/lib/web/pdf_single_page_viewer.js +94 -146
  170. package/lib/web/pdf_thumbnail_view.js +319 -269
  171. package/lib/web/pdf_thumbnail_viewer.js +219 -199
  172. package/lib/web/pdf_viewer.component.js +111 -32
  173. package/lib/web/pdf_viewer.js +61 -101
  174. package/lib/web/preferences.js +87 -272
  175. package/lib/web/secondary_toolbar.js +207 -220
  176. package/lib/web/text_layer_builder.js +322 -322
  177. package/lib/web/toolbar.js +227 -180
  178. package/lib/web/ui_utils.js +476 -421
  179. package/lib/web/view_history.js +59 -208
  180. package/lib/web/viewer_compatibility.js +9 -6
  181. package/package.json +2 -9
  182. package/web/pdf_viewer.css +36 -22
  183. package/web/pdf_viewer.js +4407 -4516
  184. package/web/pdf_viewer.js.map +1 -1
  185. package/webpack.js +14 -5
  186. package/external/streams/streams-lib.js +0 -3962
  187. package/external/url/url-lib.js +0 -627
  188. package/lib/display/dom_utils.js +0 -441
  189. package/lib/shared/streams_polyfill.js +0 -39
  190. package/lib/shared/url_polyfill.js +0 -50
  191. package/lib/test/unit/dom_utils_spec.js +0 -89
  192. package/lib/web/dom_events.js +0 -140
@@ -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 2020 Mozilla Foundation
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -19,324 +19,180 @@
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.FirefoxCom = exports.DownloadManager = undefined;
27
+ exports.FirefoxCom = exports.DownloadManager = void 0;
28
28
 
29
- var _regenerator = require('babel-runtime/regenerator');
29
+ require("../extensions/firefox/tools/l10n.js");
30
30
 
31
- var _regenerator2 = _interopRequireDefault(_regenerator);
31
+ var _pdf = require("../pdf");
32
32
 
33
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
33
+ var _app = require("./app.js");
34
34
 
35
- 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; }; }();
35
+ var _preferences = require("./preferences.js");
36
36
 
37
- require('../extensions/firefox/tools/l10n');
38
-
39
- var _pdf = require('../pdf');
40
-
41
- var _preferences = require('./preferences');
42
-
43
- var _app = require('./app');
44
-
45
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
46
-
47
- function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
48
-
49
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
50
-
51
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
52
-
53
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
37
+ var _ui_utils = require("./ui_utils.js");
54
38
 
55
39
  {
56
- throw new Error('Module "pdfjs-web/firefoxcom" shall not be used outside ' + 'FIREFOX and MOZCENTRAL builds.');
40
+ throw new Error('Module "./firefoxcom.js" shall not be used outside MOZCENTRAL builds.');
57
41
  }
58
- var FirefoxCom = function FirefoxComClosure() {
42
+
43
+ const FirefoxCom = function FirefoxComClosure() {
59
44
  return {
60
- requestSync: function requestSync(action, data) {
61
- var request = document.createTextNode('');
45
+ requestSync(action, data) {
46
+ const request = document.createTextNode("");
62
47
  document.documentElement.appendChild(request);
63
- var sender = document.createEvent('CustomEvent');
64
- sender.initCustomEvent('pdf.js.message', true, false, {
65
- action: action,
66
- data: data,
48
+ const sender = document.createEvent("CustomEvent");
49
+ sender.initCustomEvent("pdf.js.message", true, false, {
50
+ action,
51
+ data,
67
52
  sync: true
68
53
  });
69
54
  request.dispatchEvent(sender);
70
- var response = sender.detail.response;
55
+ const response = sender.detail.response;
71
56
  document.documentElement.removeChild(request);
72
57
  return response;
73
58
  },
74
- request: function request(action, data, callback) {
75
- var request = document.createTextNode('');
59
+
60
+ request(action, data, callback) {
61
+ const request = document.createTextNode("");
62
+
76
63
  if (callback) {
77
- document.addEventListener('pdf.js.response', function listener(event) {
78
- var node = event.target;
79
- var response = event.detail.response;
64
+ document.addEventListener("pdf.js.response", function listener(event) {
65
+ const node = event.target;
66
+ const response = event.detail.response;
80
67
  document.documentElement.removeChild(node);
81
- document.removeEventListener('pdf.js.response', listener);
68
+ document.removeEventListener("pdf.js.response", listener);
82
69
  return callback(response);
83
70
  });
84
71
  }
72
+
85
73
  document.documentElement.appendChild(request);
86
- var sender = document.createEvent('CustomEvent');
87
- sender.initCustomEvent('pdf.js.message', true, false, {
88
- action: action,
89
- data: data,
74
+ const sender = document.createEvent("CustomEvent");
75
+ sender.initCustomEvent("pdf.js.message", true, false, {
76
+ action,
77
+ data,
90
78
  sync: false,
91
79
  responseExpected: !!callback
92
80
  });
93
81
  return request.dispatchEvent(sender);
94
82
  }
83
+
95
84
  };
96
85
  }();
97
86
 
98
- var DownloadManager = function () {
99
- function DownloadManager(options) {
100
- _classCallCheck(this, DownloadManager);
87
+ exports.FirefoxCom = FirefoxCom;
101
88
 
89
+ class DownloadManager {
90
+ constructor(options) {
102
91
  this.disableCreateObjectURL = false;
103
92
  }
104
93
 
105
- _createClass(DownloadManager, [{
106
- key: 'downloadUrl',
107
- value: function downloadUrl(url, filename) {
108
- FirefoxCom.request('download', {
109
- originalUrl: url,
110
- filename: filename
111
- });
112
- }
113
- }, {
114
- key: 'downloadData',
115
- value: function downloadData(data, filename, contentType) {
116
- var blobUrl = (0, _pdf.createObjectURL)(data, contentType);
117
- FirefoxCom.request('download', {
118
- blobUrl: blobUrl,
119
- originalUrl: blobUrl,
120
- filename: filename,
121
- isAttachment: true
122
- });
123
- }
124
- }, {
125
- key: 'download',
126
- value: function download(blob, url, filename) {
127
- var _this = this;
128
-
129
- var blobUrl = _pdf.URL.createObjectURL(blob);
130
- var onResponse = function onResponse(err) {
131
- if (err && _this.onerror) {
132
- _this.onerror(err);
133
- }
134
- _pdf.URL.revokeObjectURL(blobUrl);
135
- };
136
- FirefoxCom.request('download', {
137
- blobUrl: blobUrl,
138
- originalUrl: url,
139
- filename: filename
140
- }, onResponse);
141
- }
142
- }]);
143
-
144
- return DownloadManager;
145
- }();
146
-
147
- var FirefoxPreferences = function (_BasePreferences) {
148
- _inherits(FirefoxPreferences, _BasePreferences);
149
-
150
- function FirefoxPreferences() {
151
- _classCallCheck(this, FirefoxPreferences);
94
+ downloadUrl(url, filename) {
95
+ FirefoxCom.request("download", {
96
+ originalUrl: url,
97
+ filename
98
+ });
99
+ }
152
100
 
153
- return _possibleConstructorReturn(this, (FirefoxPreferences.__proto__ || Object.getPrototypeOf(FirefoxPreferences)).apply(this, arguments));
101
+ downloadData(data, filename, contentType) {
102
+ const blobUrl = (0, _pdf.createObjectURL)(data, contentType);
103
+ FirefoxCom.request("download", {
104
+ blobUrl,
105
+ originalUrl: blobUrl,
106
+ filename,
107
+ isAttachment: true
108
+ });
154
109
  }
155
110
 
156
- _createClass(FirefoxPreferences, [{
157
- key: '_writeToStorage',
158
- value: function () {
159
- var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee(prefObj) {
160
- return _regenerator2.default.wrap(function _callee$(_context) {
161
- while (1) {
162
- switch (_context.prev = _context.next) {
163
- case 0:
164
- return _context.abrupt('return', new Promise(function (resolve) {
165
- FirefoxCom.request('setPreferences', prefObj, resolve);
166
- }));
167
-
168
- case 1:
169
- case 'end':
170
- return _context.stop();
171
- }
172
- }
173
- }, _callee, this);
174
- }));
111
+ download(blob, url, filename) {
112
+ const blobUrl = URL.createObjectURL(blob);
175
113
 
176
- function _writeToStorage(_x) {
177
- return _ref.apply(this, arguments);
114
+ const onResponse = err => {
115
+ if (err && this.onerror) {
116
+ this.onerror(err);
178
117
  }
179
118
 
180
- return _writeToStorage;
181
- }()
182
- }, {
183
- key: '_readFromStorage',
184
- value: function () {
185
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2(prefObj) {
186
- return _regenerator2.default.wrap(function _callee2$(_context2) {
187
- while (1) {
188
- switch (_context2.prev = _context2.next) {
189
- case 0:
190
- return _context2.abrupt('return', new Promise(function (resolve) {
191
- FirefoxCom.request('getPreferences', prefObj, function (prefStr) {
192
- var readPrefs = JSON.parse(prefStr);
193
- resolve(readPrefs);
194
- });
195
- }));
196
-
197
- case 1:
198
- case 'end':
199
- return _context2.stop();
200
- }
201
- }
202
- }, _callee2, this);
203
- }));
204
-
205
- function _readFromStorage(_x2) {
206
- return _ref2.apply(this, arguments);
207
- }
119
+ URL.revokeObjectURL(blobUrl);
120
+ };
208
121
 
209
- return _readFromStorage;
210
- }()
211
- }]);
122
+ FirefoxCom.request("download", {
123
+ blobUrl,
124
+ originalUrl: url,
125
+ filename
126
+ }, onResponse);
127
+ }
212
128
 
213
- return FirefoxPreferences;
214
- }(_preferences.BasePreferences);
129
+ }
215
130
 
216
- var MozL10n = function () {
217
- function MozL10n(mozL10n) {
218
- _classCallCheck(this, MozL10n);
131
+ exports.DownloadManager = DownloadManager;
219
132
 
220
- this.mozL10n = mozL10n;
133
+ class FirefoxPreferences extends _preferences.BasePreferences {
134
+ async _writeToStorage(prefObj) {
135
+ return new Promise(function (resolve) {
136
+ FirefoxCom.request("setPreferences", prefObj, resolve);
137
+ });
221
138
  }
222
139
 
223
- _createClass(MozL10n, [{
224
- key: 'getLanguage',
225
- value: function () {
226
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee3() {
227
- return _regenerator2.default.wrap(function _callee3$(_context3) {
228
- while (1) {
229
- switch (_context3.prev = _context3.next) {
230
- case 0:
231
- return _context3.abrupt('return', this.mozL10n.getLanguage());
232
-
233
- case 1:
234
- case 'end':
235
- return _context3.stop();
236
- }
237
- }
238
- }, _callee3, this);
239
- }));
240
-
241
- function getLanguage() {
242
- return _ref3.apply(this, arguments);
243
- }
244
-
245
- return getLanguage;
246
- }()
247
- }, {
248
- key: 'getDirection',
249
- value: function () {
250
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee4() {
251
- return _regenerator2.default.wrap(function _callee4$(_context4) {
252
- while (1) {
253
- switch (_context4.prev = _context4.next) {
254
- case 0:
255
- return _context4.abrupt('return', this.mozL10n.getDirection());
256
-
257
- case 1:
258
- case 'end':
259
- return _context4.stop();
260
- }
261
- }
262
- }, _callee4, this);
263
- }));
140
+ async _readFromStorage(prefObj) {
141
+ return new Promise(function (resolve) {
142
+ FirefoxCom.request("getPreferences", prefObj, function (prefStr) {
143
+ const readPrefs = JSON.parse(prefStr);
144
+ resolve(readPrefs);
145
+ });
146
+ });
147
+ }
264
148
 
265
- function getDirection() {
266
- return _ref4.apply(this, arguments);
267
- }
149
+ }
268
150
 
269
- return getDirection;
270
- }()
271
- }, {
272
- key: 'get',
273
- value: function () {
274
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee5(property, args, fallback) {
275
- return _regenerator2.default.wrap(function _callee5$(_context5) {
276
- while (1) {
277
- switch (_context5.prev = _context5.next) {
278
- case 0:
279
- return _context5.abrupt('return', this.mozL10n.get(property, args, fallback));
280
-
281
- case 1:
282
- case 'end':
283
- return _context5.stop();
284
- }
285
- }
286
- }, _callee5, this);
287
- }));
151
+ class MozL10n {
152
+ constructor(mozL10n) {
153
+ this.mozL10n = mozL10n;
154
+ }
288
155
 
289
- function get(_x3, _x4, _x5) {
290
- return _ref5.apply(this, arguments);
291
- }
156
+ async getLanguage() {
157
+ return this.mozL10n.getLanguage();
158
+ }
292
159
 
293
- return get;
294
- }()
295
- }, {
296
- key: 'translate',
297
- value: function () {
298
- var _ref6 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee6(element) {
299
- return _regenerator2.default.wrap(function _callee6$(_context6) {
300
- while (1) {
301
- switch (_context6.prev = _context6.next) {
302
- case 0:
303
- this.mozL10n.translate(element);
304
-
305
- case 1:
306
- case 'end':
307
- return _context6.stop();
308
- }
309
- }
310
- }, _callee6, this);
311
- }));
160
+ async getDirection() {
161
+ return this.mozL10n.getDirection();
162
+ }
312
163
 
313
- function translate(_x6) {
314
- return _ref6.apply(this, arguments);
315
- }
164
+ async get(property, args, fallback) {
165
+ return this.mozL10n.get(property, args, fallback);
166
+ }
316
167
 
317
- return translate;
318
- }()
319
- }]);
168
+ async translate(element) {
169
+ this.mozL10n.translate(element);
170
+ }
320
171
 
321
- return MozL10n;
322
- }();
172
+ }
323
173
 
324
174
  (function listenFindEvents() {
325
- var events = ['find', 'findagain', 'findhighlightallchange', 'findcasesensitivitychange', 'findentirewordchange', 'findbarclose'];
326
- var handleEvent = function handleEvent(_ref7) {
327
- var type = _ref7.type,
328
- detail = _ref7.detail;
175
+ const events = ["find", "findagain", "findhighlightallchange", "findcasesensitivitychange", "findentirewordchange", "findbarclose"];
329
176
 
177
+ const handleEvent = function ({
178
+ type,
179
+ detail
180
+ }) {
330
181
  if (!_app.PDFViewerApplication.initialized) {
331
182
  return;
332
183
  }
333
- if (type === 'findbarclose') {
334
- _app.PDFViewerApplication.eventBus.dispatch('findbarclose', { source: window });
184
+
185
+ if (type === "findbarclose") {
186
+ _app.PDFViewerApplication.eventBus.dispatch(type, {
187
+ source: window
188
+ });
189
+
335
190
  return;
336
191
  }
337
- _app.PDFViewerApplication.eventBus.dispatch('find', {
192
+
193
+ _app.PDFViewerApplication.eventBus.dispatch("find", {
338
194
  source: window,
339
- type: type.substring('find'.length),
195
+ type: type.substring("find".length),
340
196
  query: detail.query,
341
197
  phraseSearch: true,
342
198
  caseSensitive: !!detail.caseSensitive,
@@ -345,146 +201,163 @@ var MozL10n = function () {
345
201
  findPrevious: !!detail.findPrevious
346
202
  });
347
203
  };
348
- var _iteratorNormalCompletion = true;
349
- var _didIteratorError = false;
350
- var _iteratorError = undefined;
351
204
 
352
- try {
353
- for (var _iterator = events[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
354
- var event = _step.value;
205
+ for (const event of events) {
206
+ window.addEventListener(event, handleEvent);
207
+ }
208
+ })();
209
+
210
+ (function listenZoomEvents() {
211
+ const events = ["zoomin", "zoomout", "zoomreset"];
355
212
 
356
- window.addEventListener(event, handleEvent);
213
+ const handleEvent = function ({
214
+ type,
215
+ detail
216
+ }) {
217
+ if (!_app.PDFViewerApplication.initialized) {
218
+ return;
357
219
  }
358
- } catch (err) {
359
- _didIteratorError = true;
360
- _iteratorError = err;
361
- } finally {
362
- try {
363
- if (!_iteratorNormalCompletion && _iterator.return) {
364
- _iterator.return();
365
- }
366
- } finally {
367
- if (_didIteratorError) {
368
- throw _iteratorError;
369
- }
220
+
221
+ if (type === "zoomreset" && _app.PDFViewerApplication.pdfViewer.currentScaleValue === _ui_utils.DEFAULT_SCALE_VALUE) {
222
+ return;
370
223
  }
224
+
225
+ _app.PDFViewerApplication.eventBus.dispatch(type, {
226
+ source: window
227
+ });
228
+ };
229
+
230
+ for (const event of events) {
231
+ window.addEventListener(event, handleEvent);
371
232
  }
372
233
  })();
373
234
 
374
- var FirefoxComDataRangeTransport = function (_PDFDataRangeTranspor) {
375
- _inherits(FirefoxComDataRangeTransport, _PDFDataRangeTranspor);
376
-
377
- function FirefoxComDataRangeTransport() {
378
- _classCallCheck(this, FirefoxComDataRangeTransport);
235
+ class FirefoxComDataRangeTransport extends _pdf.PDFDataRangeTransport {
236
+ requestDataRange(begin, end) {
237
+ FirefoxCom.request("requestDataRange", {
238
+ begin,
239
+ end
240
+ });
241
+ }
379
242
 
380
- return _possibleConstructorReturn(this, (FirefoxComDataRangeTransport.__proto__ || Object.getPrototypeOf(FirefoxComDataRangeTransport)).apply(this, arguments));
243
+ abort() {
244
+ FirefoxCom.requestSync("abortLoading", null);
381
245
  }
382
246
 
383
- _createClass(FirefoxComDataRangeTransport, [{
384
- key: 'requestDataRange',
385
- value: function requestDataRange(begin, end) {
386
- FirefoxCom.request('requestDataRange', {
387
- begin: begin,
388
- end: end
389
- });
390
- }
391
- }, {
392
- key: 'abort',
393
- value: function abort() {
394
- FirefoxCom.requestSync('abortLoading', null);
395
- }
396
- }]);
247
+ }
248
+
249
+ class FirefoxExternalServices extends _app.DefaultExternalServices {
250
+ static updateFindControlState(data) {
251
+ FirefoxCom.request("updateFindControlState", data);
252
+ }
397
253
 
398
- return FirefoxComDataRangeTransport;
399
- }(_pdf.PDFDataRangeTransport);
254
+ static updateFindMatchesCount(data) {
255
+ FirefoxCom.request("updateFindMatchesCount", data);
256
+ }
400
257
 
401
- _app.PDFViewerApplication.externalServices = {
402
- updateFindControlState: function updateFindControlState(data) {
403
- FirefoxCom.request('updateFindControlState', data);
404
- },
405
- updateFindMatchesCount: function updateFindMatchesCount(data) {
406
- FirefoxCom.request('updateFindMatchesCount', data);
407
- },
408
- initPassiveLoading: function initPassiveLoading(callbacks) {
409
- var pdfDataRangeTransport = void 0;
410
- window.addEventListener('message', function windowMessage(e) {
258
+ static initPassiveLoading(callbacks) {
259
+ let pdfDataRangeTransport;
260
+ window.addEventListener("message", function windowMessage(e) {
411
261
  if (e.source !== null) {
412
- console.warn('Rejected untrusted message from ' + e.origin);
262
+ console.warn("Rejected untrusted message from " + e.origin);
413
263
  return;
414
264
  }
415
- var args = e.data;
416
- if ((typeof args === 'undefined' ? 'undefined' : _typeof(args)) !== 'object' || !('pdfjsLoadAction' in args)) {
265
+
266
+ const args = e.data;
267
+
268
+ if (typeof args !== "object" || !("pdfjsLoadAction" in args)) {
417
269
  return;
418
270
  }
271
+
419
272
  switch (args.pdfjsLoadAction) {
420
- case 'supportsRangedLoading':
421
- pdfDataRangeTransport = new FirefoxComDataRangeTransport(args.length, args.data);
273
+ case "supportsRangedLoading":
274
+ pdfDataRangeTransport = new FirefoxComDataRangeTransport(args.length, args.data, args.done);
422
275
  callbacks.onOpenWithTransport(args.pdfUrl, args.length, pdfDataRangeTransport);
423
276
  break;
424
- case 'range':
277
+
278
+ case "range":
425
279
  pdfDataRangeTransport.onDataRange(args.begin, args.chunk);
426
280
  break;
427
- case 'rangeProgress':
281
+
282
+ case "rangeProgress":
428
283
  pdfDataRangeTransport.onDataProgress(args.loaded);
429
284
  break;
430
- case 'progressiveRead':
285
+
286
+ case "progressiveRead":
431
287
  pdfDataRangeTransport.onDataProgressiveRead(args.chunk);
288
+ pdfDataRangeTransport.onDataProgress(args.loaded, args.total);
289
+ break;
290
+
291
+ case "progressiveDone":
292
+ if (pdfDataRangeTransport) {
293
+ pdfDataRangeTransport.onDataProgressiveDone();
294
+ }
295
+
432
296
  break;
433
- case 'progress':
297
+
298
+ case "progress":
434
299
  callbacks.onProgress(args.loaded, args.total);
435
300
  break;
436
- case 'complete':
301
+
302
+ case "complete":
437
303
  if (!args.data) {
438
304
  callbacks.onError(args.errorCode);
439
305
  break;
440
306
  }
307
+
441
308
  callbacks.onOpenWithData(args.data);
442
309
  break;
443
310
  }
444
311
  });
445
- FirefoxCom.requestSync('initPassiveLoading', null);
446
- },
447
- fallback: function fallback(data, callback) {
448
- FirefoxCom.request('fallback', data, callback);
449
- },
450
- reportTelemetry: function reportTelemetry(data) {
451
- FirefoxCom.request('reportTelemetry', JSON.stringify(data));
452
- },
453
- createDownloadManager: function createDownloadManager(options) {
312
+ FirefoxCom.requestSync("initPassiveLoading", null);
313
+ }
314
+
315
+ static fallback(data, callback) {
316
+ FirefoxCom.request("fallback", data, callback);
317
+ }
318
+
319
+ static reportTelemetry(data) {
320
+ FirefoxCom.request("reportTelemetry", JSON.stringify(data));
321
+ }
322
+
323
+ static createDownloadManager(options) {
454
324
  return new DownloadManager(options);
455
- },
456
- createPreferences: function createPreferences() {
325
+ }
326
+
327
+ static createPreferences() {
457
328
  return new FirefoxPreferences();
458
- },
459
- createL10n: function createL10n(options) {
460
- var mozL10n = document.mozL10n;
329
+ }
330
+
331
+ static createL10n(options) {
332
+ const mozL10n = document.mozL10n;
461
333
  return new MozL10n(mozL10n);
462
- },
334
+ }
463
335
 
464
- get supportsIntegratedFind() {
465
- var support = FirefoxCom.requestSync('supportsIntegratedFind');
466
- return (0, _pdf.shadow)(this, 'supportsIntegratedFind', support);
467
- },
468
- get supportsDocumentFonts() {
469
- var support = FirefoxCom.requestSync('supportsDocumentFonts');
470
- return (0, _pdf.shadow)(this, 'supportsDocumentFonts', support);
471
- },
472
- get supportsDocumentColors() {
473
- var support = FirefoxCom.requestSync('supportsDocumentColors');
474
- return (0, _pdf.shadow)(this, 'supportsDocumentColors', support);
475
- },
476
- get supportedMouseWheelZoomModifierKeys() {
477
- var support = FirefoxCom.requestSync('supportedMouseWheelZoomModifierKeys');
478
- return (0, _pdf.shadow)(this, 'supportedMouseWheelZoomModifierKeys', support);
336
+ static get supportsIntegratedFind() {
337
+ const support = FirefoxCom.requestSync("supportsIntegratedFind");
338
+ return (0, _pdf.shadow)(this, "supportsIntegratedFind", support);
339
+ }
340
+
341
+ static get supportsDocumentFonts() {
342
+ const support = FirefoxCom.requestSync("supportsDocumentFonts");
343
+ return (0, _pdf.shadow)(this, "supportsDocumentFonts", support);
344
+ }
345
+
346
+ static get supportedMouseWheelZoomModifierKeys() {
347
+ const support = FirefoxCom.requestSync("supportedMouseWheelZoomModifierKeys");
348
+ return (0, _pdf.shadow)(this, "supportedMouseWheelZoomModifierKeys", support);
479
349
  }
480
- };
350
+
351
+ }
352
+
353
+ _app.PDFViewerApplication.externalServices = FirefoxExternalServices;
481
354
  document.mozL10n.setExternalLocalizerServices({
482
- getLocale: function getLocale() {
483
- return FirefoxCom.requestSync('getLocale', null);
355
+ getLocale() {
356
+ return FirefoxCom.requestSync("getLocale", null);
484
357
  },
485
- getStrings: function getStrings(key) {
486
- return FirefoxCom.requestSync('getStrings', key);
358
+
359
+ getStrings(key) {
360
+ return FirefoxCom.requestSync("getStrings", key);
487
361
  }
488
- });
489
- exports.DownloadManager = DownloadManager;
490
- exports.FirefoxCom = FirefoxCom;
362
+
363
+ });