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,234 +19,254 @@
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.PDFThumbnailViewer = undefined;
27
+ exports.PDFThumbnailViewer = 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.js");
30
30
 
31
- var _ui_utils = require('./ui_utils');
31
+ var _pdf_thumbnail_view = require("./pdf_thumbnail_view.js");
32
32
 
33
- var _pdf_thumbnail_view = require('./pdf_thumbnail_view');
34
-
35
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
36
-
37
- var THUMBNAIL_SCROLL_MARGIN = -19;
38
- var THUMBNAIL_SELECTED_CLASS = 'selected';
39
-
40
- var PDFThumbnailViewer = function () {
41
- function PDFThumbnailViewer(_ref) {
42
- var container = _ref.container,
43
- linkService = _ref.linkService,
44
- renderingQueue = _ref.renderingQueue,
45
- _ref$l10n = _ref.l10n,
46
- l10n = _ref$l10n === undefined ? _ui_utils.NullL10n : _ref$l10n;
47
-
48
- _classCallCheck(this, PDFThumbnailViewer);
33
+ const THUMBNAIL_SCROLL_MARGIN = -19;
34
+ const THUMBNAIL_SELECTED_CLASS = "selected";
49
35
 
36
+ class PDFThumbnailViewer {
37
+ constructor({
38
+ container,
39
+ linkService,
40
+ renderingQueue,
41
+ l10n = _ui_utils.NullL10n
42
+ }) {
50
43
  this.container = container;
51
44
  this.linkService = linkService;
52
45
  this.renderingQueue = renderingQueue;
53
46
  this.l10n = l10n;
54
47
  this.scroll = (0, _ui_utils.watchScroll)(this.container, this._scrollUpdated.bind(this));
48
+
55
49
  this._resetView();
56
50
  }
57
51
 
58
- _createClass(PDFThumbnailViewer, [{
59
- key: '_scrollUpdated',
60
- value: function _scrollUpdated() {
61
- this.renderingQueue.renderHighestPriority();
62
- }
63
- }, {
64
- key: 'getThumbnail',
65
- value: function getThumbnail(index) {
66
- return this._thumbnails[index];
67
- }
68
- }, {
69
- key: '_getVisibleThumbs',
70
- value: function _getVisibleThumbs() {
71
- return (0, _ui_utils.getVisibleElements)(this.container, this._thumbnails);
72
- }
73
- }, {
74
- key: 'scrollThumbnailIntoView',
75
- value: function scrollThumbnailIntoView(pageNumber) {
76
- if (!this.pdfDocument) {
77
- return;
78
- }
79
- var thumbnailView = this._thumbnails[pageNumber - 1];
80
- if (!thumbnailView) {
81
- console.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.');
82
- return;
83
- }
84
- if (pageNumber !== this._currentPageNumber) {
85
- var prevThumbnailView = this._thumbnails[this._currentPageNumber - 1];
86
- prevThumbnailView.div.classList.remove(THUMBNAIL_SELECTED_CLASS);
87
- thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
88
- }
89
- var visibleThumbs = this._getVisibleThumbs();
90
- var numVisibleThumbs = visibleThumbs.views.length;
91
- if (numVisibleThumbs > 0) {
92
- var first = visibleThumbs.first.id;
93
- var last = numVisibleThumbs > 1 ? visibleThumbs.last.id : first;
94
- var shouldScroll = false;
95
- if (pageNumber <= first || pageNumber >= last) {
96
- shouldScroll = true;
97
- } else {
98
- visibleThumbs.views.some(function (view) {
99
- if (view.id !== pageNumber) {
100
- return false;
101
- }
102
- shouldScroll = view.percent < 100;
103
- return true;
104
- });
105
- }
106
- if (shouldScroll) {
107
- (0, _ui_utils.scrollIntoView)(thumbnailView.div, { top: THUMBNAIL_SCROLL_MARGIN });
108
- }
109
- }
110
- this._currentPageNumber = pageNumber;
111
- }
112
- }, {
113
- key: 'cleanup',
114
- value: function cleanup() {
115
- _pdf_thumbnail_view.PDFThumbnailView.cleanup();
116
- }
117
- }, {
118
- key: '_resetView',
119
- value: function _resetView() {
120
- this._thumbnails = [];
121
- this._currentPageNumber = 1;
122
- this._pageLabels = null;
123
- this._pagesRotation = 0;
124
- this._pagesRequests = [];
125
- this.container.textContent = '';
126
- }
127
- }, {
128
- key: 'setDocument',
129
- value: function setDocument(pdfDocument) {
130
- var _this = this;
131
-
132
- if (this.pdfDocument) {
133
- this._cancelRendering();
134
- this._resetView();
135
- }
136
- this.pdfDocument = pdfDocument;
137
- if (!pdfDocument) {
138
- return;
139
- }
140
- pdfDocument.getPage(1).then(function (firstPage) {
141
- var pagesCount = pdfDocument.numPages;
142
- var viewport = firstPage.getViewport(1.0);
143
- for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
144
- var thumbnail = new _pdf_thumbnail_view.PDFThumbnailView({
145
- container: _this.container,
146
- id: pageNum,
147
- defaultViewport: viewport.clone(),
148
- linkService: _this.linkService,
149
- renderingQueue: _this.renderingQueue,
150
- disableCanvasToImageConversion: false,
151
- l10n: _this.l10n
152
- });
153
- _this._thumbnails.push(thumbnail);
154
- }
155
- var thumbnailView = _this._thumbnails[_this._currentPageNumber - 1];
156
- thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
157
- }).catch(function (reason) {
158
- console.error('Unable to initialize thumbnail viewer', reason);
159
- });
52
+ _scrollUpdated() {
53
+ this.renderingQueue.renderHighestPriority();
54
+ }
55
+
56
+ getThumbnail(index) {
57
+ return this._thumbnails[index];
58
+ }
59
+
60
+ _getVisibleThumbs() {
61
+ return (0, _ui_utils.getVisibleElements)(this.container, this._thumbnails);
62
+ }
63
+
64
+ scrollThumbnailIntoView(pageNumber) {
65
+ if (!this.pdfDocument) {
66
+ return;
160
67
  }
161
- }, {
162
- key: '_cancelRendering',
163
- value: function _cancelRendering() {
164
- for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
165
- if (this._thumbnails[i]) {
166
- this._thumbnails[i].cancelRendering();
167
- }
168
- }
68
+
69
+ const thumbnailView = this._thumbnails[pageNumber - 1];
70
+
71
+ if (!thumbnailView) {
72
+ console.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.');
73
+ return;
169
74
  }
170
- }, {
171
- key: 'setPageLabels',
172
- value: function setPageLabels(labels) {
173
- if (!this.pdfDocument) {
174
- return;
175
- }
176
- if (!labels) {
177
- this._pageLabels = null;
178
- } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
179
- this._pageLabels = null;
180
- console.error('PDFThumbnailViewer_setPageLabels: Invalid page labels.');
75
+
76
+ if (pageNumber !== this._currentPageNumber) {
77
+ const prevThumbnailView = this._thumbnails[this._currentPageNumber - 1];
78
+ prevThumbnailView.div.classList.remove(THUMBNAIL_SELECTED_CLASS);
79
+ thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
80
+ }
81
+
82
+ const visibleThumbs = this._getVisibleThumbs();
83
+
84
+ const numVisibleThumbs = visibleThumbs.views.length;
85
+
86
+ if (numVisibleThumbs > 0) {
87
+ const first = visibleThumbs.first.id;
88
+ const last = numVisibleThumbs > 1 ? visibleThumbs.last.id : first;
89
+ let shouldScroll = false;
90
+
91
+ if (pageNumber <= first || pageNumber >= last) {
92
+ shouldScroll = true;
181
93
  } else {
182
- this._pageLabels = labels;
94
+ visibleThumbs.views.some(function (view) {
95
+ if (view.id !== pageNumber) {
96
+ return false;
97
+ }
98
+
99
+ shouldScroll = view.percent < 100;
100
+ return true;
101
+ });
183
102
  }
184
- for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
185
- var label = this._pageLabels && this._pageLabels[i];
186
- this._thumbnails[i].setPageLabel(label);
103
+
104
+ if (shouldScroll) {
105
+ (0, _ui_utils.scrollIntoView)(thumbnailView.div, {
106
+ top: THUMBNAIL_SCROLL_MARGIN
107
+ });
187
108
  }
188
109
  }
189
- }, {
190
- key: '_ensurePdfPageLoaded',
191
- value: function _ensurePdfPageLoaded(thumbView) {
192
- var _this2 = this;
193
110
 
194
- if (thumbView.pdfPage) {
195
- return Promise.resolve(thumbView.pdfPage);
196
- }
197
- var pageNumber = thumbView.id;
198
- if (this._pagesRequests[pageNumber]) {
199
- return this._pagesRequests[pageNumber];
200
- }
201
- var promise = this.pdfDocument.getPage(pageNumber).then(function (pdfPage) {
202
- thumbView.setPdfPage(pdfPage);
203
- _this2._pagesRequests[pageNumber] = null;
204
- return pdfPage;
205
- }).catch(function (reason) {
206
- console.error('Unable to get page for thumb view', reason);
207
- _this2._pagesRequests[pageNumber] = null;
111
+ this._currentPageNumber = pageNumber;
112
+ }
113
+
114
+ get pagesRotation() {
115
+ return this._pagesRotation;
116
+ }
117
+
118
+ set pagesRotation(rotation) {
119
+ if (!(0, _ui_utils.isValidRotation)(rotation)) {
120
+ throw new Error("Invalid thumbnails rotation angle.");
121
+ }
122
+
123
+ if (!this.pdfDocument) {
124
+ return;
125
+ }
126
+
127
+ if (this._pagesRotation === rotation) {
128
+ return;
129
+ }
130
+
131
+ this._pagesRotation = rotation;
132
+
133
+ for (let i = 0, ii = this._thumbnails.length; i < ii; i++) {
134
+ this._thumbnails[i].update(rotation);
135
+ }
136
+ }
137
+
138
+ cleanup() {
139
+ _pdf_thumbnail_view.PDFThumbnailView.cleanup();
140
+ }
141
+
142
+ _resetView() {
143
+ this._thumbnails = [];
144
+ this._currentPageNumber = 1;
145
+ this._pageLabels = null;
146
+ this._pagesRotation = 0;
147
+ this._pagesRequests = new WeakMap();
148
+ this.container.textContent = "";
149
+ }
150
+
151
+ setDocument(pdfDocument) {
152
+ if (this.pdfDocument) {
153
+ this._cancelRendering();
154
+
155
+ this._resetView();
156
+ }
157
+
158
+ this.pdfDocument = pdfDocument;
159
+
160
+ if (!pdfDocument) {
161
+ return;
162
+ }
163
+
164
+ pdfDocument.getPage(1).then(firstPdfPage => {
165
+ const pagesCount = pdfDocument.numPages;
166
+ const viewport = firstPdfPage.getViewport({
167
+ scale: 1
208
168
  });
209
- this._pagesRequests[pageNumber] = promise;
210
- return promise;
211
- }
212
- }, {
213
- key: 'forceRendering',
214
- value: function forceRendering() {
215
- var _this3 = this;
216
-
217
- var visibleThumbs = this._getVisibleThumbs();
218
- var thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, this.scroll.down);
219
- if (thumbView) {
220
- this._ensurePdfPageLoaded(thumbView).then(function () {
221
- _this3.renderingQueue.renderView(thumbView);
169
+
170
+ for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
171
+ const thumbnail = new _pdf_thumbnail_view.PDFThumbnailView({
172
+ container: this.container,
173
+ id: pageNum,
174
+ defaultViewport: viewport.clone(),
175
+ linkService: this.linkService,
176
+ renderingQueue: this.renderingQueue,
177
+ disableCanvasToImageConversion: false,
178
+ l10n: this.l10n
222
179
  });
223
- return true;
224
- }
225
- return false;
226
- }
227
- }, {
228
- key: 'pagesRotation',
229
- get: function get() {
230
- return this._pagesRotation;
231
- },
232
- set: function set(rotation) {
233
- if (!(0, _ui_utils.isValidRotation)(rotation)) {
234
- throw new Error('Invalid thumbnails rotation angle.');
180
+
181
+ this._thumbnails.push(thumbnail);
235
182
  }
236
- if (!this.pdfDocument) {
237
- return;
183
+
184
+ const firstThumbnailView = this._thumbnails[0];
185
+
186
+ if (firstThumbnailView) {
187
+ firstThumbnailView.setPdfPage(firstPdfPage);
238
188
  }
239
- if (this._pagesRotation === rotation) {
240
- return;
189
+
190
+ const thumbnailView = this._thumbnails[this._currentPageNumber - 1];
191
+ thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
192
+ }).catch(reason => {
193
+ console.error("Unable to initialize thumbnail viewer", reason);
194
+ });
195
+ }
196
+
197
+ _cancelRendering() {
198
+ for (let i = 0, ii = this._thumbnails.length; i < ii; i++) {
199
+ if (this._thumbnails[i]) {
200
+ this._thumbnails[i].cancelRendering();
241
201
  }
242
- this._pagesRotation = rotation;
243
- for (var i = 0, ii = this._thumbnails.length; i < ii; i++) {
244
- this._thumbnails[i].update(rotation);
202
+ }
203
+ }
204
+
205
+ setPageLabels(labels) {
206
+ if (!this.pdfDocument) {
207
+ return;
208
+ }
209
+
210
+ if (!labels) {
211
+ this._pageLabels = null;
212
+ } else if (!(Array.isArray(labels) && this.pdfDocument.numPages === labels.length)) {
213
+ this._pageLabels = null;
214
+ console.error("PDFThumbnailViewer_setPageLabels: Invalid page labels.");
215
+ } else {
216
+ this._pageLabels = labels;
217
+ }
218
+
219
+ for (let i = 0, ii = this._thumbnails.length; i < ii; i++) {
220
+ const label = this._pageLabels && this._pageLabels[i];
221
+
222
+ this._thumbnails[i].setPageLabel(label);
223
+ }
224
+ }
225
+
226
+ _ensurePdfPageLoaded(thumbView) {
227
+ if (thumbView.pdfPage) {
228
+ return Promise.resolve(thumbView.pdfPage);
229
+ }
230
+
231
+ if (this._pagesRequests.has(thumbView)) {
232
+ return this._pagesRequests.get(thumbView);
233
+ }
234
+
235
+ const promise = this.pdfDocument.getPage(thumbView.id).then(pdfPage => {
236
+ if (!thumbView.pdfPage) {
237
+ thumbView.setPdfPage(pdfPage);
245
238
  }
239
+
240
+ this._pagesRequests.delete(thumbView);
241
+
242
+ return pdfPage;
243
+ }).catch(reason => {
244
+ console.error("Unable to get page for thumb view", reason);
245
+
246
+ this._pagesRequests.delete(thumbView);
247
+ });
248
+
249
+ this._pagesRequests.set(thumbView, promise);
250
+
251
+ return promise;
252
+ }
253
+
254
+ forceRendering() {
255
+ const visibleThumbs = this._getVisibleThumbs();
256
+
257
+ const thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, this.scroll.down);
258
+
259
+ if (thumbView) {
260
+ this._ensurePdfPageLoaded(thumbView).then(() => {
261
+ this.renderingQueue.renderView(thumbView);
262
+ });
263
+
264
+ return true;
246
265
  }
247
- }]);
248
266
 
249
- return PDFThumbnailViewer;
250
- }();
267
+ return false;
268
+ }
269
+
270
+ }
251
271
 
252
272
  exports.PDFThumbnailViewer = PDFThumbnailViewer;
@@ -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,50 +19,129 @@
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.NullL10n = exports.GenericL10n = exports.ProgressBar = exports.DownloadManager = exports.EventBus = exports.PDFFindController = exports.PDFHistory = exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = exports.DefaultTextLayerFactory = exports.TextLayerBuilder = exports.SimpleLinkService = exports.PDFLinkService = exports.PDFPageView = exports.PDFSinglePageViewer = exports.PDFViewer = undefined;
27
+ Object.defineProperty(exports, "AnnotationLayerBuilder", {
28
+ enumerable: true,
29
+ get: function () {
30
+ return _annotation_layer_builder.AnnotationLayerBuilder;
31
+ }
32
+ });
33
+ Object.defineProperty(exports, "DefaultAnnotationLayerFactory", {
34
+ enumerable: true,
35
+ get: function () {
36
+ return _annotation_layer_builder.DefaultAnnotationLayerFactory;
37
+ }
38
+ });
39
+ Object.defineProperty(exports, "DefaultTextLayerFactory", {
40
+ enumerable: true,
41
+ get: function () {
42
+ return _text_layer_builder.DefaultTextLayerFactory;
43
+ }
44
+ });
45
+ Object.defineProperty(exports, "TextLayerBuilder", {
46
+ enumerable: true,
47
+ get: function () {
48
+ return _text_layer_builder.TextLayerBuilder;
49
+ }
50
+ });
51
+ Object.defineProperty(exports, "EventBus", {
52
+ enumerable: true,
53
+ get: function () {
54
+ return _ui_utils.EventBus;
55
+ }
56
+ });
57
+ Object.defineProperty(exports, "NullL10n", {
58
+ enumerable: true,
59
+ get: function () {
60
+ return _ui_utils.NullL10n;
61
+ }
62
+ });
63
+ Object.defineProperty(exports, "ProgressBar", {
64
+ enumerable: true,
65
+ get: function () {
66
+ return _ui_utils.ProgressBar;
67
+ }
68
+ });
69
+ Object.defineProperty(exports, "PDFLinkService", {
70
+ enumerable: true,
71
+ get: function () {
72
+ return _pdf_link_service.PDFLinkService;
73
+ }
74
+ });
75
+ Object.defineProperty(exports, "SimpleLinkService", {
76
+ enumerable: true,
77
+ get: function () {
78
+ return _pdf_link_service.SimpleLinkService;
79
+ }
80
+ });
81
+ Object.defineProperty(exports, "DownloadManager", {
82
+ enumerable: true,
83
+ get: function () {
84
+ return _download_manager.DownloadManager;
85
+ }
86
+ });
87
+ Object.defineProperty(exports, "GenericL10n", {
88
+ enumerable: true,
89
+ get: function () {
90
+ return _genericl10n.GenericL10n;
91
+ }
92
+ });
93
+ Object.defineProperty(exports, "PDFFindController", {
94
+ enumerable: true,
95
+ get: function () {
96
+ return _pdf_find_controller.PDFFindController;
97
+ }
98
+ });
99
+ Object.defineProperty(exports, "PDFHistory", {
100
+ enumerable: true,
101
+ get: function () {
102
+ return _pdf_history.PDFHistory;
103
+ }
104
+ });
105
+ Object.defineProperty(exports, "PDFPageView", {
106
+ enumerable: true,
107
+ get: function () {
108
+ return _pdf_page_view.PDFPageView;
109
+ }
110
+ });
111
+ Object.defineProperty(exports, "PDFSinglePageViewer", {
112
+ enumerable: true,
113
+ get: function () {
114
+ return _pdf_single_page_viewer.PDFSinglePageViewer;
115
+ }
116
+ });
117
+ Object.defineProperty(exports, "PDFViewer", {
118
+ enumerable: true,
119
+ get: function () {
120
+ return _pdf_viewer.PDFViewer;
121
+ }
122
+ });
28
123
 
29
- var _annotation_layer_builder = require('./annotation_layer_builder.js');
124
+ var _annotation_layer_builder = require("./annotation_layer_builder.js");
30
125
 
31
- var _text_layer_builder = require('./text_layer_builder.js');
126
+ var _text_layer_builder = require("./text_layer_builder.js");
32
127
 
33
- var _ui_utils = require('./ui_utils.js');
128
+ var _ui_utils = require("./ui_utils.js");
34
129
 
35
- var _pdf_link_service = require('./pdf_link_service.js');
130
+ var _pdf_link_service = require("./pdf_link_service.js");
36
131
 
37
- var _download_manager = require('./download_manager.js');
132
+ var _download_manager = require("./download_manager.js");
38
133
 
39
- var _genericl10n = require('./genericl10n.js');
134
+ var _genericl10n = require("./genericl10n.js");
40
135
 
41
- var _pdf_find_controller = require('./pdf_find_controller.js');
136
+ var _pdf_find_controller = require("./pdf_find_controller.js");
42
137
 
43
- var _pdf_history = require('./pdf_history.js');
138
+ var _pdf_history = require("./pdf_history.js");
44
139
 
45
- var _pdf_page_view = require('./pdf_page_view.js');
140
+ var _pdf_page_view = require("./pdf_page_view.js");
46
141
 
47
- var _pdf_single_page_viewer = require('./pdf_single_page_viewer');
142
+ var _pdf_single_page_viewer = require("./pdf_single_page_viewer.js");
48
143
 
49
- var _pdf_viewer = require('./pdf_viewer.js');
144
+ var _pdf_viewer = require("./pdf_viewer.js");
50
145
 
51
- var pdfjsVersion = '2.0.943';
52
- var pdfjsBuild = 'dc98bf76';
53
- exports.PDFViewer = _pdf_viewer.PDFViewer;
54
- exports.PDFSinglePageViewer = _pdf_single_page_viewer.PDFSinglePageViewer;
55
- exports.PDFPageView = _pdf_page_view.PDFPageView;
56
- exports.PDFLinkService = _pdf_link_service.PDFLinkService;
57
- exports.SimpleLinkService = _pdf_link_service.SimpleLinkService;
58
- exports.TextLayerBuilder = _text_layer_builder.TextLayerBuilder;
59
- exports.DefaultTextLayerFactory = _text_layer_builder.DefaultTextLayerFactory;
60
- exports.AnnotationLayerBuilder = _annotation_layer_builder.AnnotationLayerBuilder;
61
- exports.DefaultAnnotationLayerFactory = _annotation_layer_builder.DefaultAnnotationLayerFactory;
62
- exports.PDFHistory = _pdf_history.PDFHistory;
63
- exports.PDFFindController = _pdf_find_controller.PDFFindController;
64
- exports.EventBus = _ui_utils.EventBus;
65
- exports.DownloadManager = _download_manager.DownloadManager;
66
- exports.ProgressBar = _ui_utils.ProgressBar;
67
- exports.GenericL10n = _genericl10n.GenericL10n;
68
- exports.NullL10n = _ui_utils.NullL10n;
146
+ const pdfjsVersion = '2.4.456';
147
+ const pdfjsBuild = '228a591c';