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
@@ -1,441 +0,0 @@
1
- /**
2
- * @licstart The following is the entire license notice for the
3
- * Javascript code in this page
4
- *
5
- * Copyright 2018 Mozilla Foundation
6
- *
7
- * Licensed under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License.
9
- * You may obtain a copy of the License at
10
- *
11
- * http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- *
19
- * @licend The above is the entire license notice for the
20
- * Javascript code in this page
21
- */
22
- 'use strict';
23
-
24
- Object.defineProperty(exports, "__esModule", {
25
- value: true
26
- });
27
- exports.loadScript = exports.DummyStatTimer = exports.StatTimer = exports.DOMSVGFactory = exports.DOMCMapReaderFactory = exports.DOMCanvasFactory = exports.DEFAULT_LINK_REL = exports.LinkTarget = exports.getFilenameFromUrl = exports.addLinkAttributes = exports.RenderingCancelledException = exports.PageViewport = undefined;
28
-
29
- var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
30
-
31
- var _util = require('../shared/util');
32
-
33
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
34
-
35
- var DEFAULT_LINK_REL = 'noopener noreferrer nofollow';
36
- var SVG_NS = 'http://www.w3.org/2000/svg';
37
-
38
- var DOMCanvasFactory = function () {
39
- function DOMCanvasFactory() {
40
- _classCallCheck(this, DOMCanvasFactory);
41
- }
42
-
43
- _createClass(DOMCanvasFactory, [{
44
- key: 'create',
45
- value: function create(width, height) {
46
- if (width <= 0 || height <= 0) {
47
- throw new Error('invalid canvas size');
48
- }
49
- var canvas = document.createElement('canvas');
50
- var context = canvas.getContext('2d');
51
- canvas.width = width;
52
- canvas.height = height;
53
- return {
54
- canvas: canvas,
55
- context: context
56
- };
57
- }
58
- }, {
59
- key: 'reset',
60
- value: function reset(canvasAndContext, width, height) {
61
- if (!canvasAndContext.canvas) {
62
- throw new Error('canvas is not specified');
63
- }
64
- if (width <= 0 || height <= 0) {
65
- throw new Error('invalid canvas size');
66
- }
67
- canvasAndContext.canvas.width = width;
68
- canvasAndContext.canvas.height = height;
69
- }
70
- }, {
71
- key: 'destroy',
72
- value: function destroy(canvasAndContext) {
73
- if (!canvasAndContext.canvas) {
74
- throw new Error('canvas is not specified');
75
- }
76
- canvasAndContext.canvas.width = 0;
77
- canvasAndContext.canvas.height = 0;
78
- canvasAndContext.canvas = null;
79
- canvasAndContext.context = null;
80
- }
81
- }]);
82
-
83
- return DOMCanvasFactory;
84
- }();
85
-
86
- var DOMCMapReaderFactory = function () {
87
- function DOMCMapReaderFactory(_ref) {
88
- var _ref$baseUrl = _ref.baseUrl,
89
- baseUrl = _ref$baseUrl === undefined ? null : _ref$baseUrl,
90
- _ref$isCompressed = _ref.isCompressed,
91
- isCompressed = _ref$isCompressed === undefined ? false : _ref$isCompressed;
92
-
93
- _classCallCheck(this, DOMCMapReaderFactory);
94
-
95
- this.baseUrl = baseUrl;
96
- this.isCompressed = isCompressed;
97
- }
98
-
99
- _createClass(DOMCMapReaderFactory, [{
100
- key: 'fetch',
101
- value: function fetch(_ref2) {
102
- var _this = this;
103
-
104
- var name = _ref2.name;
105
-
106
- if (!this.baseUrl) {
107
- return Promise.reject(new Error('The CMap "baseUrl" parameter must be specified, ensure that ' + 'the "cMapUrl" and "cMapPacked" API parameters are provided.'));
108
- }
109
- if (!name) {
110
- return Promise.reject(new Error('CMap name must be specified.'));
111
- }
112
- return new Promise(function (resolve, reject) {
113
- var url = _this.baseUrl + name + (_this.isCompressed ? '.bcmap' : '');
114
- var request = new XMLHttpRequest();
115
- request.open('GET', url, true);
116
- if (_this.isCompressed) {
117
- request.responseType = 'arraybuffer';
118
- }
119
- request.onreadystatechange = function () {
120
- if (request.readyState !== XMLHttpRequest.DONE) {
121
- return;
122
- }
123
- if (request.status === 200 || request.status === 0) {
124
- var data = void 0;
125
- if (_this.isCompressed && request.response) {
126
- data = new Uint8Array(request.response);
127
- } else if (!_this.isCompressed && request.responseText) {
128
- data = (0, _util.stringToBytes)(request.responseText);
129
- }
130
- if (data) {
131
- resolve({
132
- cMapData: data,
133
- compressionType: _this.isCompressed ? _util.CMapCompressionType.BINARY : _util.CMapCompressionType.NONE
134
- });
135
- return;
136
- }
137
- }
138
- reject(new Error('Unable to load ' + (_this.isCompressed ? 'binary ' : '') + 'CMap at: ' + url));
139
- };
140
- request.send(null);
141
- });
142
- }
143
- }]);
144
-
145
- return DOMCMapReaderFactory;
146
- }();
147
-
148
- var DOMSVGFactory = function () {
149
- function DOMSVGFactory() {
150
- _classCallCheck(this, DOMSVGFactory);
151
- }
152
-
153
- _createClass(DOMSVGFactory, [{
154
- key: 'create',
155
- value: function create(width, height) {
156
- (0, _util.assert)(width > 0 && height > 0, 'Invalid SVG dimensions');
157
- var svg = document.createElementNS(SVG_NS, 'svg:svg');
158
- svg.setAttribute('version', '1.1');
159
- svg.setAttribute('width', width + 'px');
160
- svg.setAttribute('height', height + 'px');
161
- svg.setAttribute('preserveAspectRatio', 'none');
162
- svg.setAttribute('viewBox', '0 0 ' + width + ' ' + height);
163
- return svg;
164
- }
165
- }, {
166
- key: 'createElement',
167
- value: function createElement(type) {
168
- (0, _util.assert)(typeof type === 'string', 'Invalid SVG element type');
169
- return document.createElementNS(SVG_NS, type);
170
- }
171
- }]);
172
-
173
- return DOMSVGFactory;
174
- }();
175
-
176
- var PageViewport = function () {
177
- function PageViewport(_ref3) {
178
- var viewBox = _ref3.viewBox,
179
- scale = _ref3.scale,
180
- rotation = _ref3.rotation,
181
- _ref3$offsetX = _ref3.offsetX,
182
- offsetX = _ref3$offsetX === undefined ? 0 : _ref3$offsetX,
183
- _ref3$offsetY = _ref3.offsetY,
184
- offsetY = _ref3$offsetY === undefined ? 0 : _ref3$offsetY,
185
- _ref3$dontFlip = _ref3.dontFlip,
186
- dontFlip = _ref3$dontFlip === undefined ? false : _ref3$dontFlip;
187
-
188
- _classCallCheck(this, PageViewport);
189
-
190
- this.viewBox = viewBox;
191
- this.scale = scale;
192
- this.rotation = rotation;
193
- this.offsetX = offsetX;
194
- this.offsetY = offsetY;
195
- var centerX = (viewBox[2] + viewBox[0]) / 2;
196
- var centerY = (viewBox[3] + viewBox[1]) / 2;
197
- var rotateA = void 0,
198
- rotateB = void 0,
199
- rotateC = void 0,
200
- rotateD = void 0;
201
- rotation = rotation % 360;
202
- rotation = rotation < 0 ? rotation + 360 : rotation;
203
- switch (rotation) {
204
- case 180:
205
- rotateA = -1;
206
- rotateB = 0;
207
- rotateC = 0;
208
- rotateD = 1;
209
- break;
210
- case 90:
211
- rotateA = 0;
212
- rotateB = 1;
213
- rotateC = 1;
214
- rotateD = 0;
215
- break;
216
- case 270:
217
- rotateA = 0;
218
- rotateB = -1;
219
- rotateC = -1;
220
- rotateD = 0;
221
- break;
222
- default:
223
- rotateA = 1;
224
- rotateB = 0;
225
- rotateC = 0;
226
- rotateD = -1;
227
- break;
228
- }
229
- if (dontFlip) {
230
- rotateC = -rotateC;
231
- rotateD = -rotateD;
232
- }
233
- var offsetCanvasX = void 0,
234
- offsetCanvasY = void 0;
235
- var width = void 0,
236
- height = void 0;
237
- if (rotateA === 0) {
238
- offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
239
- offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
240
- width = Math.abs(viewBox[3] - viewBox[1]) * scale;
241
- height = Math.abs(viewBox[2] - viewBox[0]) * scale;
242
- } else {
243
- offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
244
- offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
245
- width = Math.abs(viewBox[2] - viewBox[0]) * scale;
246
- height = Math.abs(viewBox[3] - viewBox[1]) * scale;
247
- }
248
- this.transform = [rotateA * scale, rotateB * scale, rotateC * scale, rotateD * scale, offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY, offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY];
249
- this.width = width;
250
- this.height = height;
251
- }
252
-
253
- _createClass(PageViewport, [{
254
- key: 'clone',
255
- value: function clone() {
256
- var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
257
- _ref4$scale = _ref4.scale,
258
- scale = _ref4$scale === undefined ? this.scale : _ref4$scale,
259
- _ref4$rotation = _ref4.rotation,
260
- rotation = _ref4$rotation === undefined ? this.rotation : _ref4$rotation,
261
- _ref4$dontFlip = _ref4.dontFlip,
262
- dontFlip = _ref4$dontFlip === undefined ? false : _ref4$dontFlip;
263
-
264
- return new PageViewport({
265
- viewBox: this.viewBox.slice(),
266
- scale: scale,
267
- rotation: rotation,
268
- offsetX: this.offsetX,
269
- offsetY: this.offsetY,
270
- dontFlip: dontFlip
271
- });
272
- }
273
- }, {
274
- key: 'convertToViewportPoint',
275
- value: function convertToViewportPoint(x, y) {
276
- return _util.Util.applyTransform([x, y], this.transform);
277
- }
278
- }, {
279
- key: 'convertToViewportRectangle',
280
- value: function convertToViewportRectangle(rect) {
281
- var tl = _util.Util.applyTransform([rect[0], rect[1]], this.transform);
282
- var br = _util.Util.applyTransform([rect[2], rect[3]], this.transform);
283
- return [tl[0], tl[1], br[0], br[1]];
284
- }
285
- }, {
286
- key: 'convertToPdfPoint',
287
- value: function convertToPdfPoint(x, y) {
288
- return _util.Util.applyInverseTransform([x, y], this.transform);
289
- }
290
- }]);
291
-
292
- return PageViewport;
293
- }();
294
-
295
- var RenderingCancelledException = function RenderingCancelledException() {
296
- function RenderingCancelledException(msg, type) {
297
- this.message = msg;
298
- this.type = type;
299
- }
300
- RenderingCancelledException.prototype = new Error();
301
- RenderingCancelledException.prototype.name = 'RenderingCancelledException';
302
- RenderingCancelledException.constructor = RenderingCancelledException;
303
- return RenderingCancelledException;
304
- }();
305
- var LinkTarget = {
306
- NONE: 0,
307
- SELF: 1,
308
- BLANK: 2,
309
- PARENT: 3,
310
- TOP: 4
311
- };
312
- var LinkTargetStringMap = ['', '_self', '_blank', '_parent', '_top'];
313
- function addLinkAttributes(link) {
314
- var _ref5 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
315
- url = _ref5.url,
316
- target = _ref5.target,
317
- rel = _ref5.rel;
318
-
319
- link.href = link.title = url ? (0, _util.removeNullCharacters)(url) : '';
320
- if (url) {
321
- var LinkTargetValues = Object.values(LinkTarget);
322
- var targetIndex = LinkTargetValues.includes(target) ? target : LinkTarget.NONE;
323
- link.target = LinkTargetStringMap[targetIndex];
324
- link.rel = typeof rel === 'string' ? rel : DEFAULT_LINK_REL;
325
- }
326
- }
327
- function getFilenameFromUrl(url) {
328
- var anchor = url.indexOf('#');
329
- var query = url.indexOf('?');
330
- var end = Math.min(anchor > 0 ? anchor : url.length, query > 0 ? query : url.length);
331
- return url.substring(url.lastIndexOf('/', end) + 1, end);
332
- }
333
-
334
- var StatTimer = function () {
335
- function StatTimer() {
336
- var enable = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
337
-
338
- _classCallCheck(this, StatTimer);
339
-
340
- this.enabled = !!enable;
341
- this.started = Object.create(null);
342
- this.times = [];
343
- }
344
-
345
- _createClass(StatTimer, [{
346
- key: 'time',
347
- value: function time(name) {
348
- if (!this.enabled) {
349
- return;
350
- }
351
- if (name in this.started) {
352
- (0, _util.warn)('Timer is already running for ' + name);
353
- }
354
- this.started[name] = Date.now();
355
- }
356
- }, {
357
- key: 'timeEnd',
358
- value: function timeEnd(name) {
359
- if (!this.enabled) {
360
- return;
361
- }
362
- if (!(name in this.started)) {
363
- (0, _util.warn)('Timer has not been started for ' + name);
364
- }
365
- this.times.push({
366
- 'name': name,
367
- 'start': this.started[name],
368
- 'end': Date.now()
369
- });
370
- delete this.started[name];
371
- }
372
- }, {
373
- key: 'toString',
374
- value: function toString() {
375
- var times = this.times;
376
- var out = '',
377
- longest = 0;
378
- for (var i = 0, ii = times.length; i < ii; ++i) {
379
- var name = times[i]['name'];
380
- if (name.length > longest) {
381
- longest = name.length;
382
- }
383
- }
384
- for (var _i = 0, _ii = times.length; _i < _ii; ++_i) {
385
- var span = times[_i];
386
- var duration = span.end - span.start;
387
- out += span['name'].padEnd(longest) + ' ' + duration + 'ms\n';
388
- }
389
- return out;
390
- }
391
- }]);
392
-
393
- return StatTimer;
394
- }();
395
-
396
- var DummyStatTimer = function () {
397
- function DummyStatTimer() {
398
- _classCallCheck(this, DummyStatTimer);
399
-
400
- (0, _util.unreachable)('Cannot initialize DummyStatTimer.');
401
- }
402
-
403
- _createClass(DummyStatTimer, null, [{
404
- key: 'time',
405
- value: function time(name) {}
406
- }, {
407
- key: 'timeEnd',
408
- value: function timeEnd(name) {}
409
- }, {
410
- key: 'toString',
411
- value: function toString() {
412
- return '';
413
- }
414
- }]);
415
-
416
- return DummyStatTimer;
417
- }();
418
-
419
- function loadScript(src) {
420
- return new Promise(function (resolve, reject) {
421
- var script = document.createElement('script');
422
- script.src = src;
423
- script.onload = resolve;
424
- script.onerror = function () {
425
- reject(new Error('Cannot load script at: ' + script.src));
426
- };
427
- (document.head || document.documentElement).appendChild(script);
428
- });
429
- }
430
- exports.PageViewport = PageViewport;
431
- exports.RenderingCancelledException = RenderingCancelledException;
432
- exports.addLinkAttributes = addLinkAttributes;
433
- exports.getFilenameFromUrl = getFilenameFromUrl;
434
- exports.LinkTarget = LinkTarget;
435
- exports.DEFAULT_LINK_REL = DEFAULT_LINK_REL;
436
- exports.DOMCanvasFactory = DOMCanvasFactory;
437
- exports.DOMCMapReaderFactory = DOMCMapReaderFactory;
438
- exports.DOMSVGFactory = DOMSVGFactory;
439
- exports.StatTimer = StatTimer;
440
- exports.DummyStatTimer = DummyStatTimer;
441
- exports.loadScript = loadScript;
@@ -1,39 +0,0 @@
1
- /**
2
- * @licstart The following is the entire license notice for the
3
- * Javascript code in this page
4
- *
5
- * Copyright 2018 Mozilla Foundation
6
- *
7
- * Licensed under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License.
9
- * You may obtain a copy of the License at
10
- *
11
- * http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- *
19
- * @licend The above is the entire license notice for the
20
- * Javascript code in this page
21
- */
22
- 'use strict';
23
-
24
- var isReadableStreamSupported = false;
25
- if (typeof ReadableStream !== 'undefined') {
26
- try {
27
- new ReadableStream({
28
- start: function start(controller) {
29
- controller.close();
30
- }
31
- });
32
- isReadableStreamSupported = true;
33
- } catch (e) {}
34
- }
35
- if (isReadableStreamSupported) {
36
- exports.ReadableStream = ReadableStream;
37
- } else {
38
- exports.ReadableStream = require('../../external/streams/streams-lib').ReadableStream;
39
- }
@@ -1,50 +0,0 @@
1
- /**
2
- * @licstart The following is the entire license notice for the
3
- * Javascript code in this page
4
- *
5
- * Copyright 2018 Mozilla Foundation
6
- *
7
- * Licensed under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License.
9
- * You may obtain a copy of the License at
10
- *
11
- * http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- *
19
- * @licend The above is the entire license notice for the
20
- * Javascript code in this page
21
- */
22
- 'use strict';
23
-
24
- 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; };
25
-
26
- {
27
- var isURLSupported = false;
28
- try {
29
- if (typeof URL === 'function' && _typeof(URL.prototype) === 'object' && 'origin' in URL.prototype) {
30
- var u = new URL('b', 'http://a');
31
- u.pathname = 'c%20d';
32
- isURLSupported = u.href === 'http://a/c%20d';
33
- }
34
- } catch (ex) {}
35
- if (isURLSupported) {
36
- exports.URL = URL;
37
- } else {
38
- var PolyfillURL = require('../../external/url/url-lib').URL;
39
- var OriginalURL = require('./global_scope').URL;
40
- if (OriginalURL) {
41
- PolyfillURL.createObjectURL = function (blob) {
42
- return OriginalURL.createObjectURL.apply(OriginalURL, arguments);
43
- };
44
- PolyfillURL.revokeObjectURL = function (url) {
45
- OriginalURL.revokeObjectURL(url);
46
- };
47
- }
48
- exports.URL = PolyfillURL;
49
- }
50
- }
@@ -1,89 +0,0 @@
1
- /**
2
- * @licstart The following is the entire license notice for the
3
- * Javascript code in this page
4
- *
5
- * Copyright 2018 Mozilla Foundation
6
- *
7
- * Licensed under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License.
9
- * You may obtain a copy of the License at
10
- *
11
- * http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- *
19
- * @licend The above is the entire license notice for the
20
- * Javascript code in this page
21
- */
22
- 'use strict';
23
-
24
- var _dom_utils = require('../../display/dom_utils');
25
-
26
- var _is_node = require('../../shared/is_node');
27
-
28
- var _is_node2 = _interopRequireDefault(_is_node);
29
-
30
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
-
32
- describe('dom_utils', function () {
33
- describe('DOMSVGFactory', function () {
34
- var svgFactory = void 0;
35
- beforeAll(function (done) {
36
- svgFactory = new _dom_utils.DOMSVGFactory();
37
- done();
38
- });
39
- afterAll(function () {
40
- svgFactory = null;
41
- });
42
- it('`create` should throw an error if the dimensions are invalid', function () {
43
- expect(function () {
44
- return svgFactory.create(-1, 0);
45
- }).toThrow(new Error('Invalid SVG dimensions'));
46
- expect(function () {
47
- return svgFactory.create(0, -1);
48
- }).toThrow(new Error('Invalid SVG dimensions'));
49
- });
50
- it('`create` should return an SVG element if the dimensions are valid', function () {
51
- if ((0, _is_node2.default)()) {
52
- pending('Document is not supported in Node.js.');
53
- }
54
- var svg = svgFactory.create(20, 40);
55
- expect(svg instanceof SVGSVGElement).toBe(true);
56
- expect(svg.getAttribute('version')).toBe('1.1');
57
- expect(svg.getAttribute('width')).toBe('20px');
58
- expect(svg.getAttribute('height')).toBe('40px');
59
- expect(svg.getAttribute('preserveAspectRatio')).toBe('none');
60
- expect(svg.getAttribute('viewBox')).toBe('0 0 20 40');
61
- });
62
- it('`createElement` should throw an error if the type is not a string', function () {
63
- expect(function () {
64
- return svgFactory.createElement(true);
65
- }).toThrow(new Error('Invalid SVG element type'));
66
- });
67
- it('`createElement` should return an SVG element if the type is valid', function () {
68
- if ((0, _is_node2.default)()) {
69
- pending('Document is not supported in Node.js.');
70
- }
71
- var svg = svgFactory.createElement('svg:rect');
72
- expect(svg instanceof SVGRectElement).toBe(true);
73
- });
74
- });
75
- describe('getFilenameFromUrl', function () {
76
- it('should get the filename from an absolute URL', function () {
77
- var url = 'http://server.org/filename.pdf';
78
- var result = (0, _dom_utils.getFilenameFromUrl)(url);
79
- var expected = 'filename.pdf';
80
- expect(result).toEqual(expected);
81
- });
82
- it('should get the filename from a relative URL', function () {
83
- var url = '../../filename.pdf';
84
- var result = (0, _dom_utils.getFilenameFromUrl)(url);
85
- var expected = 'filename.pdf';
86
- expect(result).toEqual(expected);
87
- });
88
- });
89
- });