pdfjs-dist 2.2.228 → 2.6.347

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