pdfjs-dist 2.3.200 → 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.
- package/README.md +4 -0
- package/bower.json +1 -1
- package/build/pdf.js +6499 -17971
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +22 -1
- package/build/pdf.worker.entry.js +5 -3
- package/build/pdf.worker.js +19303 -29896
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +22 -1
- package/es5/build/pdf.js +25473 -0
- package/es5/build/pdf.js.map +1 -0
- package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
- package/es5/build/pdf.worker.js +57878 -0
- package/es5/build/pdf.worker.js.map +1 -0
- package/es5/web/images/annotation-check.svg +11 -0
- package/es5/web/images/annotation-comment.svg +16 -0
- package/es5/web/images/annotation-help.svg +26 -0
- package/es5/web/images/annotation-insert.svg +10 -0
- package/es5/web/images/annotation-key.svg +11 -0
- package/es5/web/images/annotation-newparagraph.svg +11 -0
- package/es5/web/images/annotation-noicon.svg +7 -0
- package/es5/web/images/annotation-note.svg +42 -0
- package/es5/web/images/annotation-paragraph.svg +16 -0
- package/es5/web/images/loading-icon.gif +0 -0
- package/es5/web/images/shadow.png +0 -0
- package/es5/web/images/texture.png +0 -0
- package/es5/web/pdf_viewer.css +407 -0
- package/es5/web/pdf_viewer.js +7757 -0
- package/es5/web/pdf_viewer.js.map +1 -0
- package/image_decoders/pdf.image_decoders.js +1333 -4839
- package/image_decoders/pdf.image_decoders.js.map +1 -1
- package/image_decoders/pdf.image_decoders.min.js +22 -1
- package/lib/README.md +7 -0
- package/lib/core/annotation.js +683 -1066
- package/lib/core/arithmetic_decoder.js +81 -97
- package/lib/core/bidi.js +54 -46
- package/lib/core/ccitt.js +88 -81
- package/lib/core/ccitt_stream.js +15 -14
- package/lib/core/cff_parser.js +196 -193
- package/lib/core/charsets.js +4 -4
- package/lib/core/chunked_stream.js +441 -569
- package/lib/core/cmap.js +220 -279
- package/lib/core/colorspace.js +699 -863
- package/lib/core/core_utils.js +59 -80
- package/lib/core/crypto.js +379 -437
- package/lib/core/document.js +564 -673
- package/lib/core/encodings.js +15 -15
- package/lib/core/evaluator.js +983 -889
- package/lib/core/font_renderer.js +128 -171
- package/lib/core/fonts.js +451 -400
- package/lib/core/function.js +289 -285
- package/lib/core/glyphlist.js +4527 -4527
- package/lib/core/image.js +138 -117
- package/lib/core/image_utils.js +46 -63
- package/lib/core/jbig2.js +324 -332
- package/lib/core/jbig2_stream.js +18 -17
- package/lib/core/jpeg_stream.js +133 -24
- package/lib/core/jpg.js +238 -210
- package/lib/core/jpx.js +158 -157
- package/lib/core/jpx_stream.js +28 -28
- package/lib/core/metrics.js +2928 -2928
- package/lib/core/murmurhash3.js +87 -102
- package/lib/core/obj.js +1111 -1302
- package/lib/core/operator_list.js +55 -42
- package/lib/core/parser.js +956 -987
- package/lib/core/pattern.js +69 -69
- package/lib/core/pdf_manager.js +149 -316
- package/lib/core/primitives.js +45 -77
- package/lib/core/ps_parser.js +175 -214
- package/lib/core/standard_fonts.js +237 -236
- package/lib/core/stream.js +83 -77
- package/lib/core/type1_parser.js +78 -68
- package/lib/core/unicode.js +1654 -1654
- package/lib/core/worker.js +148 -196
- package/lib/core/worker_stream.js +101 -210
- package/lib/display/annotation_layer.js +733 -1155
- package/lib/display/api.js +1539 -1928
- package/lib/display/api_compatibility.js +10 -8
- package/lib/display/canvas.js +159 -158
- package/lib/display/content_disposition.js +36 -55
- package/lib/display/display_utils.js +298 -551
- package/lib/display/fetch_stream.js +181 -305
- package/lib/display/font_loader.js +273 -416
- package/lib/display/metadata.js +86 -98
- package/lib/display/network.js +376 -511
- package/lib/display/network_utils.js +20 -19
- package/lib/display/node_stream.js +276 -460
- package/lib/display/pattern_helper.js +76 -44
- package/lib/display/svg.js +1137 -1405
- package/lib/display/text_layer.js +75 -82
- package/lib/display/transport_stream.js +236 -374
- package/lib/display/webgl.js +70 -83
- package/lib/display/worker_options.js +3 -3
- package/lib/display/xml_parser.js +303 -392
- package/lib/examples/node/domstubs.js +37 -37
- package/lib/pdf.js +22 -21
- package/lib/pdf.worker.js +5 -5
- package/lib/shared/compatibility.js +2 -251
- package/lib/shared/is_node.js +7 -6
- package/lib/shared/message_handler.js +222 -194
- package/lib/shared/util.js +269 -405
- package/lib/test/unit/annotation_spec.js +1089 -1014
- package/lib/test/unit/api_spec.js +617 -544
- package/lib/test/unit/bidi_spec.js +7 -7
- package/lib/test/unit/cff_parser_spec.js +63 -62
- package/lib/test/unit/clitests_helper.js +7 -9
- package/lib/test/unit/cmap_spec.js +84 -86
- package/lib/test/unit/colorspace_spec.js +154 -154
- package/lib/test/unit/core_utils_spec.js +125 -105
- package/lib/test/unit/crypto_spec.js +181 -181
- package/lib/test/unit/custom_spec.js +22 -24
- package/lib/test/unit/display_svg_spec.js +35 -36
- package/lib/test/unit/display_utils_spec.js +139 -149
- package/lib/test/unit/document_spec.js +16 -16
- package/lib/test/unit/encodings_spec.js +12 -34
- package/lib/test/unit/evaluator_spec.js +81 -95
- package/lib/test/unit/fetch_stream_spec.js +30 -30
- package/lib/test/unit/function_spec.js +206 -204
- package/lib/test/unit/jasmine-boot.js +48 -32
- package/lib/test/unit/message_handler_spec.js +172 -162
- package/lib/test/unit/metadata_spec.js +69 -69
- package/lib/test/unit/murmurhash3_spec.js +12 -12
- package/lib/test/unit/network_spec.js +12 -12
- package/lib/test/unit/network_utils_spec.js +152 -152
- package/lib/test/unit/node_stream_spec.js +74 -90
- package/lib/test/unit/parser_spec.js +107 -113
- package/lib/test/unit/pdf_find_controller_spec.js +55 -86
- package/lib/test/unit/pdf_find_utils_spec.js +32 -32
- package/lib/test/unit/pdf_history_spec.js +32 -32
- package/lib/test/unit/primitives_spec.js +117 -115
- package/lib/test/unit/stream_spec.js +16 -14
- package/lib/test/unit/test_utils.js +119 -285
- package/lib/test/unit/testreporter.js +19 -19
- package/lib/test/unit/type1_parser_spec.js +41 -41
- package/lib/test/unit/ui_utils_spec.js +318 -426
- package/lib/test/unit/unicode_spec.js +42 -42
- package/lib/test/unit/util_spec.js +122 -143
- package/lib/web/annotation_layer_builder.js +66 -103
- package/lib/web/app.js +1166 -1196
- package/lib/web/app_options.js +61 -77
- package/lib/web/base_viewer.js +804 -850
- package/lib/web/chromecom.js +164 -249
- package/lib/web/debugger.js +149 -205
- package/lib/web/download_manager.js +38 -57
- package/lib/web/firefox_print_service.js +35 -30
- package/lib/web/firefoxcom.js +175 -374
- package/lib/web/genericcom.js +26 -108
- package/lib/web/genericl10n.js +24 -153
- package/lib/web/grab_to_pan.js +30 -30
- package/lib/web/interfaces.js +80 -258
- package/lib/web/overlay_manager.js +70 -246
- package/lib/web/password_prompt.js +38 -64
- package/lib/web/pdf_attachment_viewer.js +105 -130
- package/lib/web/pdf_cursor_tools.js +75 -102
- package/lib/web/pdf_document_properties.js +227 -376
- package/lib/web/pdf_find_bar.js +137 -171
- package/lib/web/pdf_find_controller.js +492 -549
- package/lib/web/pdf_find_utils.js +13 -13
- package/lib/web/pdf_history.js +395 -406
- package/lib/web/pdf_link_service.js +302 -349
- package/lib/web/pdf_outline_viewer.js +148 -209
- package/lib/web/pdf_page_view.js +449 -507
- package/lib/web/pdf_presentation_mode.js +304 -357
- package/lib/web/pdf_print_service.js +90 -104
- package/lib/web/pdf_rendering_queue.js +87 -108
- package/lib/web/pdf_sidebar.js +264 -304
- package/lib/web/pdf_sidebar_resizer.js +92 -119
- package/lib/web/pdf_single_page_viewer.js +77 -126
- package/lib/web/pdf_thumbnail_view.js +276 -297
- package/lib/web/pdf_thumbnail_viewer.js +186 -206
- package/lib/web/pdf_viewer.component.js +20 -21
- package/lib/web/pdf_viewer.js +55 -115
- package/lib/web/preferences.js +66 -273
- package/lib/web/secondary_toolbar.js +164 -196
- package/lib/web/text_layer_builder.js +284 -317
- package/lib/web/toolbar.js +216 -211
- package/lib/web/ui_utils.js +303 -404
- package/lib/web/view_history.js +49 -222
- package/lib/web/viewer_compatibility.js +7 -5
- package/package.json +2 -9
- package/web/pdf_viewer.css +25 -18
- package/web/pdf_viewer.js +3481 -4764
- package/web/pdf_viewer.js.map +1 -1
- package/webpack.js +14 -5
- package/lib/shared/streams_polyfill.js +0 -43
@@ -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
|
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.
|
@@ -21,41 +21,41 @@
|
|
21
21
|
*/
|
22
22
|
"use strict";
|
23
23
|
|
24
|
-
var _pdf_find_utils = require("../../web/pdf_find_utils");
|
24
|
+
var _pdf_find_utils = require("../../web/pdf_find_utils.js");
|
25
25
|
|
26
|
-
describe(
|
27
|
-
describe(
|
28
|
-
it(
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
26
|
+
describe("pdf_find_utils", function () {
|
27
|
+
describe("getCharacterType", function () {
|
28
|
+
it("gets expected character types", function () {
|
29
|
+
const characters = {
|
30
|
+
A: _pdf_find_utils.CharacterType.ALPHA_LETTER,
|
31
|
+
a: _pdf_find_utils.CharacterType.ALPHA_LETTER,
|
32
|
+
"0": _pdf_find_utils.CharacterType.ALPHA_LETTER,
|
33
|
+
"5": _pdf_find_utils.CharacterType.ALPHA_LETTER,
|
34
|
+
Ä: _pdf_find_utils.CharacterType.ALPHA_LETTER,
|
35
|
+
ä: _pdf_find_utils.CharacterType.ALPHA_LETTER,
|
36
|
+
_: _pdf_find_utils.CharacterType.ALPHA_LETTER,
|
37
|
+
" ": _pdf_find_utils.CharacterType.SPACE,
|
38
|
+
"\t": _pdf_find_utils.CharacterType.SPACE,
|
39
|
+
"\r": _pdf_find_utils.CharacterType.SPACE,
|
40
|
+
"\n": _pdf_find_utils.CharacterType.SPACE,
|
41
|
+
"\xA0": _pdf_find_utils.CharacterType.SPACE,
|
42
|
+
"-": _pdf_find_utils.CharacterType.PUNCT,
|
43
|
+
",": _pdf_find_utils.CharacterType.PUNCT,
|
44
|
+
".": _pdf_find_utils.CharacterType.PUNCT,
|
45
|
+
";": _pdf_find_utils.CharacterType.PUNCT,
|
46
|
+
":": _pdf_find_utils.CharacterType.PUNCT,
|
47
47
|
"\u2122": _pdf_find_utils.CharacterType.ALPHA_LETTER,
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
48
|
+
ล: _pdf_find_utils.CharacterType.THAI_LETTER,
|
49
|
+
䀀: _pdf_find_utils.CharacterType.HAN_LETTER,
|
50
|
+
縷: _pdf_find_utils.CharacterType.HAN_LETTER,
|
51
|
+
ダ: _pdf_find_utils.CharacterType.KATAKANA_LETTER,
|
52
|
+
ぐ: _pdf_find_utils.CharacterType.HIRAGANA_LETTER,
|
53
|
+
タ: _pdf_find_utils.CharacterType.HALFWIDTH_KATAKANA_LETTER
|
54
54
|
};
|
55
55
|
|
56
|
-
for (
|
57
|
-
|
58
|
-
|
56
|
+
for (const character in characters) {
|
57
|
+
const charCode = character.charCodeAt(0);
|
58
|
+
const type = characters[character];
|
59
59
|
expect((0, _pdf_find_utils.getCharacterType)(charCode)).toEqual(type);
|
60
60
|
}
|
61
61
|
});
|
@@ -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
|
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.
|
@@ -21,73 +21,73 @@
|
|
21
21
|
*/
|
22
22
|
"use strict";
|
23
23
|
|
24
|
-
var _pdf_history = require("../../web/pdf_history");
|
24
|
+
var _pdf_history = require("../../web/pdf_history.js");
|
25
25
|
|
26
|
-
describe(
|
27
|
-
describe(
|
28
|
-
it(
|
29
|
-
expect((0, _pdf_history.isDestHashesEqual)(null,
|
30
|
-
expect((0, _pdf_history.isDestHashesEqual)(
|
31
|
-
expect((0, _pdf_history.isDestHashesEqual)(
|
32
|
-
expect((0, _pdf_history.isDestHashesEqual)(
|
33
|
-
expect((0, _pdf_history.isDestHashesEqual)(
|
34
|
-
|
26
|
+
describe("pdf_history", function () {
|
27
|
+
describe("isDestHashesEqual", function () {
|
28
|
+
it("should reject non-equal destination hashes", function () {
|
29
|
+
expect((0, _pdf_history.isDestHashesEqual)(null, "page.157")).toEqual(false);
|
30
|
+
expect((0, _pdf_history.isDestHashesEqual)("title.0", "page.157")).toEqual(false);
|
31
|
+
expect((0, _pdf_history.isDestHashesEqual)("page=1&zoom=auto", "page.157")).toEqual(false);
|
32
|
+
expect((0, _pdf_history.isDestHashesEqual)("nameddest-page.157", "page.157")).toEqual(false);
|
33
|
+
expect((0, _pdf_history.isDestHashesEqual)("page.157", "nameddest=page.157")).toEqual(false);
|
34
|
+
const destArrayString = JSON.stringify([{
|
35
35
|
num: 3757,
|
36
36
|
gen: 0
|
37
37
|
}, {
|
38
|
-
name:
|
38
|
+
name: "XYZ"
|
39
39
|
}, 92.918, 748.972, null]);
|
40
|
-
expect((0, _pdf_history.isDestHashesEqual)(destArrayString,
|
41
|
-
expect((0, _pdf_history.isDestHashesEqual)(
|
40
|
+
expect((0, _pdf_history.isDestHashesEqual)(destArrayString, "page.157")).toEqual(false);
|
41
|
+
expect((0, _pdf_history.isDestHashesEqual)("page.157", destArrayString)).toEqual(false);
|
42
42
|
});
|
43
|
-
it(
|
44
|
-
expect((0, _pdf_history.isDestHashesEqual)(
|
45
|
-
expect((0, _pdf_history.isDestHashesEqual)(
|
46
|
-
expect((0, _pdf_history.isDestHashesEqual)(
|
43
|
+
it("should accept equal destination hashes", function () {
|
44
|
+
expect((0, _pdf_history.isDestHashesEqual)("page.157", "page.157")).toEqual(true);
|
45
|
+
expect((0, _pdf_history.isDestHashesEqual)("nameddest=page.157", "page.157")).toEqual(true);
|
46
|
+
expect((0, _pdf_history.isDestHashesEqual)("nameddest=page.157&zoom=100", "page.157")).toEqual(true);
|
47
47
|
});
|
48
48
|
});
|
49
|
-
describe(
|
50
|
-
|
49
|
+
describe("isDestArraysEqual", function () {
|
50
|
+
const firstDest = [{
|
51
51
|
num: 1,
|
52
52
|
gen: 0
|
53
53
|
}, {
|
54
|
-
name:
|
54
|
+
name: "XYZ"
|
55
55
|
}, 0, 375, null];
|
56
|
-
|
56
|
+
const secondDest = [{
|
57
57
|
num: 5,
|
58
58
|
gen: 0
|
59
59
|
}, {
|
60
|
-
name:
|
60
|
+
name: "XYZ"
|
61
61
|
}, 0, 375, null];
|
62
|
-
|
62
|
+
const thirdDest = [{
|
63
63
|
num: 1,
|
64
64
|
gen: 0
|
65
65
|
}, {
|
66
|
-
name:
|
66
|
+
name: "XYZ"
|
67
67
|
}, 750, 0, null];
|
68
|
-
|
68
|
+
const fourthDest = [{
|
69
69
|
num: 1,
|
70
70
|
gen: 0
|
71
71
|
}, {
|
72
|
-
name:
|
72
|
+
name: "XYZ"
|
73
73
|
}, 0, 375, 1.0];
|
74
|
-
|
74
|
+
const fifthDest = [{
|
75
75
|
gen: 0,
|
76
76
|
num: 1
|
77
77
|
}, {
|
78
|
-
name:
|
78
|
+
name: "XYZ"
|
79
79
|
}, 0, 375, null];
|
80
|
-
it(
|
80
|
+
it("should reject non-equal destination arrays", function () {
|
81
81
|
expect((0, _pdf_history.isDestArraysEqual)(firstDest, undefined)).toEqual(false);
|
82
82
|
expect((0, _pdf_history.isDestArraysEqual)(firstDest, [1, 2, 3, 4, 5])).toEqual(false);
|
83
83
|
expect((0, _pdf_history.isDestArraysEqual)(firstDest, secondDest)).toEqual(false);
|
84
84
|
expect((0, _pdf_history.isDestArraysEqual)(firstDest, thirdDest)).toEqual(false);
|
85
85
|
expect((0, _pdf_history.isDestArraysEqual)(firstDest, fourthDest)).toEqual(false);
|
86
86
|
});
|
87
|
-
it(
|
87
|
+
it("should accept equal destination arrays", function () {
|
88
88
|
expect((0, _pdf_history.isDestArraysEqual)(firstDest, firstDest)).toEqual(true);
|
89
89
|
expect((0, _pdf_history.isDestArraysEqual)(firstDest, fifthDest)).toEqual(true);
|
90
|
-
|
90
|
+
const firstDestCopy = firstDest.slice();
|
91
91
|
expect(firstDest).not.toBe(firstDestCopy);
|
92
92
|
expect((0, _pdf_history.isDestArraysEqual)(firstDest, firstDestCopy)).toEqual(true);
|
93
93
|
});
|
@@ -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
|
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.
|
@@ -21,146 +21,148 @@
|
|
21
21
|
*/
|
22
22
|
"use strict";
|
23
23
|
|
24
|
-
var _primitives = require("../../core/primitives");
|
24
|
+
var _primitives = require("../../core/primitives.js");
|
25
25
|
|
26
|
-
var _test_utils = require("./test_utils");
|
26
|
+
var _test_utils = require("./test_utils.js");
|
27
27
|
|
28
|
-
describe(
|
29
|
-
describe(
|
30
|
-
it(
|
31
|
-
var givenName =
|
28
|
+
describe("primitives", function () {
|
29
|
+
describe("Name", function () {
|
30
|
+
it("should retain the given name", function () {
|
31
|
+
var givenName = "Font";
|
32
32
|
|
33
33
|
var name = _primitives.Name.get(givenName);
|
34
34
|
|
35
35
|
expect(name.name).toEqual(givenName);
|
36
36
|
});
|
37
|
-
it(
|
38
|
-
var firstFont = _primitives.Name.get(
|
37
|
+
it("should create only one object for a name and cache it", function () {
|
38
|
+
var firstFont = _primitives.Name.get("Font");
|
39
39
|
|
40
|
-
var secondFont = _primitives.Name.get(
|
40
|
+
var secondFont = _primitives.Name.get("Font");
|
41
41
|
|
42
|
-
var firstSubtype = _primitives.Name.get(
|
42
|
+
var firstSubtype = _primitives.Name.get("Subtype");
|
43
43
|
|
44
|
-
var secondSubtype = _primitives.Name.get(
|
44
|
+
var secondSubtype = _primitives.Name.get("Subtype");
|
45
45
|
|
46
46
|
expect(firstFont).toBe(secondFont);
|
47
47
|
expect(firstSubtype).toBe(secondSubtype);
|
48
48
|
expect(firstFont).not.toBe(firstSubtype);
|
49
49
|
});
|
50
50
|
});
|
51
|
-
describe(
|
52
|
-
it(
|
53
|
-
var givenCmd =
|
51
|
+
describe("Cmd", function () {
|
52
|
+
it("should retain the given cmd name", function () {
|
53
|
+
var givenCmd = "BT";
|
54
54
|
|
55
55
|
var cmd = _primitives.Cmd.get(givenCmd);
|
56
56
|
|
57
57
|
expect(cmd.cmd).toEqual(givenCmd);
|
58
58
|
});
|
59
|
-
it(
|
60
|
-
var firstBT = _primitives.Cmd.get(
|
59
|
+
it("should create only one object for a command and cache it", function () {
|
60
|
+
var firstBT = _primitives.Cmd.get("BT");
|
61
61
|
|
62
|
-
var secondBT = _primitives.Cmd.get(
|
62
|
+
var secondBT = _primitives.Cmd.get("BT");
|
63
63
|
|
64
|
-
var firstET = _primitives.Cmd.get(
|
64
|
+
var firstET = _primitives.Cmd.get("ET");
|
65
65
|
|
66
|
-
var secondET = _primitives.Cmd.get(
|
66
|
+
var secondET = _primitives.Cmd.get("ET");
|
67
67
|
|
68
68
|
expect(firstBT).toBe(secondBT);
|
69
69
|
expect(firstET).toBe(secondET);
|
70
70
|
expect(firstBT).not.toBe(firstET);
|
71
71
|
});
|
72
72
|
});
|
73
|
-
describe(
|
74
|
-
var checkInvalidHasValues = function
|
73
|
+
describe("Dict", function () {
|
74
|
+
var checkInvalidHasValues = function (dict) {
|
75
75
|
expect(dict.has()).toBeFalsy();
|
76
|
-
expect(dict.has(
|
76
|
+
expect(dict.has("Prev")).toBeFalsy();
|
77
77
|
};
|
78
78
|
|
79
|
-
var checkInvalidKeyValues = function
|
79
|
+
var checkInvalidKeyValues = function (dict) {
|
80
80
|
expect(dict.get()).toBeUndefined();
|
81
|
-
expect(dict.get(
|
82
|
-
expect(dict.get(
|
83
|
-
expect(dict.get(
|
81
|
+
expect(dict.get("Prev")).toBeUndefined();
|
82
|
+
expect(dict.get("Decode", "D")).toBeUndefined();
|
83
|
+
expect(dict.get("FontFile", "FontFile2", "FontFile3")).toBeUndefined();
|
84
84
|
};
|
85
85
|
|
86
86
|
var emptyDict, dictWithSizeKey, dictWithManyKeys;
|
87
87
|
var storedSize = 42;
|
88
|
-
var testFontFile =
|
89
|
-
var testFontFile2 =
|
90
|
-
var testFontFile3 =
|
88
|
+
var testFontFile = "file1";
|
89
|
+
var testFontFile2 = "file2";
|
90
|
+
var testFontFile3 = "file3";
|
91
91
|
beforeAll(function (done) {
|
92
92
|
emptyDict = new _primitives.Dict();
|
93
93
|
dictWithSizeKey = new _primitives.Dict();
|
94
|
-
dictWithSizeKey.set(
|
94
|
+
dictWithSizeKey.set("Size", storedSize);
|
95
95
|
dictWithManyKeys = new _primitives.Dict();
|
96
|
-
dictWithManyKeys.set(
|
97
|
-
dictWithManyKeys.set(
|
98
|
-
dictWithManyKeys.set(
|
96
|
+
dictWithManyKeys.set("FontFile", testFontFile);
|
97
|
+
dictWithManyKeys.set("FontFile2", testFontFile2);
|
98
|
+
dictWithManyKeys.set("FontFile3", testFontFile3);
|
99
99
|
done();
|
100
100
|
});
|
101
101
|
afterAll(function () {
|
102
102
|
emptyDict = dictWithSizeKey = dictWithManyKeys = null;
|
103
103
|
});
|
104
|
-
it(
|
104
|
+
it("should return invalid values for unknown keys", function () {
|
105
105
|
checkInvalidHasValues(emptyDict);
|
106
106
|
checkInvalidKeyValues(emptyDict);
|
107
107
|
});
|
108
|
-
it(
|
109
|
-
expect(dictWithSizeKey.has(
|
110
|
-
expect(dictWithSizeKey.get(
|
111
|
-
expect(dictWithSizeKey.get(
|
112
|
-
expect(dictWithSizeKey.get(
|
108
|
+
it("should return correct value for stored Size key", function () {
|
109
|
+
expect(dictWithSizeKey.has("Size")).toBeTruthy();
|
110
|
+
expect(dictWithSizeKey.get("Size")).toEqual(storedSize);
|
111
|
+
expect(dictWithSizeKey.get("Prev", "Size")).toEqual(storedSize);
|
112
|
+
expect(dictWithSizeKey.get("Prev", "Root", "Size")).toEqual(storedSize);
|
113
113
|
});
|
114
|
-
it(
|
114
|
+
it("should return invalid values for unknown keys when Size key is stored", function () {
|
115
115
|
checkInvalidHasValues(dictWithSizeKey);
|
116
116
|
checkInvalidKeyValues(dictWithSizeKey);
|
117
117
|
});
|
118
|
-
it(
|
119
|
-
|
120
|
-
|
121
|
-
|
118
|
+
it("should not accept to set a key with an undefined value", function () {
|
119
|
+
const dict = new _primitives.Dict();
|
120
|
+
expect(function () {
|
121
|
+
dict.set("Size");
|
122
|
+
}).toThrow(new Error('Dict.set: The "value" cannot be undefined.'));
|
123
|
+
expect(dict.has("Size")).toBeFalsy();
|
122
124
|
checkInvalidKeyValues(dict);
|
123
125
|
});
|
124
|
-
it(
|
125
|
-
expect(dictWithManyKeys.has(
|
126
|
-
expect(dictWithManyKeys.has(
|
127
|
-
expect(dictWithManyKeys.has(
|
128
|
-
expect(dictWithManyKeys.get(
|
129
|
-
expect(dictWithManyKeys.get(
|
130
|
-
expect(dictWithManyKeys.get(
|
126
|
+
it("should return correct values for multiple stored keys", function () {
|
127
|
+
expect(dictWithManyKeys.has("FontFile")).toBeTruthy();
|
128
|
+
expect(dictWithManyKeys.has("FontFile2")).toBeTruthy();
|
129
|
+
expect(dictWithManyKeys.has("FontFile3")).toBeTruthy();
|
130
|
+
expect(dictWithManyKeys.get("FontFile3")).toEqual(testFontFile3);
|
131
|
+
expect(dictWithManyKeys.get("FontFile2", "FontFile3")).toEqual(testFontFile2);
|
132
|
+
expect(dictWithManyKeys.get("FontFile", "FontFile2", "FontFile3")).toEqual(testFontFile);
|
131
133
|
});
|
132
|
-
it(
|
133
|
-
var keyPromises = [dictWithManyKeys.getAsync(
|
134
|
+
it("should asynchronously fetch unknown keys", function (done) {
|
135
|
+
var keyPromises = [dictWithManyKeys.getAsync("Size"), dictWithSizeKey.getAsync("FontFile", "FontFile2", "FontFile3")];
|
134
136
|
Promise.all(keyPromises).then(function (values) {
|
135
137
|
expect(values[0]).toBeUndefined();
|
136
138
|
expect(values[1]).toBeUndefined();
|
137
139
|
done();
|
138
|
-
})
|
140
|
+
}).catch(function (reason) {
|
139
141
|
done.fail(reason);
|
140
142
|
});
|
141
143
|
});
|
142
|
-
it(
|
143
|
-
var keyPromises = [dictWithManyKeys.getAsync(
|
144
|
+
it("should asynchronously fetch correct values for multiple stored keys", function (done) {
|
145
|
+
var keyPromises = [dictWithManyKeys.getAsync("FontFile3"), dictWithManyKeys.getAsync("FontFile2", "FontFile3"), dictWithManyKeys.getAsync("FontFile", "FontFile2", "FontFile3")];
|
144
146
|
Promise.all(keyPromises).then(function (values) {
|
145
147
|
expect(values[0]).toEqual(testFontFile3);
|
146
148
|
expect(values[1]).toEqual(testFontFile2);
|
147
149
|
expect(values[2]).toEqual(testFontFile);
|
148
150
|
done();
|
149
|
-
})
|
151
|
+
}).catch(function (reason) {
|
150
152
|
done.fail(reason);
|
151
153
|
});
|
152
154
|
});
|
153
|
-
it(
|
154
|
-
var callbackSpy = jasmine.createSpy(
|
155
|
+
it("should callback for each stored key", function () {
|
156
|
+
var callbackSpy = jasmine.createSpy("spy on callback in dictionary");
|
155
157
|
dictWithManyKeys.forEach(callbackSpy);
|
156
158
|
expect(callbackSpy).toHaveBeenCalled();
|
157
159
|
var callbackSpyCalls = callbackSpy.calls;
|
158
|
-
expect(callbackSpyCalls.argsFor(0)).toEqual([
|
159
|
-
expect(callbackSpyCalls.argsFor(1)).toEqual([
|
160
|
-
expect(callbackSpyCalls.argsFor(2)).toEqual([
|
160
|
+
expect(callbackSpyCalls.argsFor(0)).toEqual(["FontFile", testFontFile]);
|
161
|
+
expect(callbackSpyCalls.argsFor(1)).toEqual(["FontFile2", testFontFile2]);
|
162
|
+
expect(callbackSpyCalls.argsFor(2)).toEqual(["FontFile3", testFontFile3]);
|
161
163
|
expect(callbackSpyCalls.count()).toEqual(3);
|
162
164
|
});
|
163
|
-
it(
|
165
|
+
it("should handle keys pointing to indirect objects, both sync and async", function (done) {
|
164
166
|
var fontRef = _primitives.Ref.get(1, 0);
|
165
167
|
|
166
168
|
var xref = new _test_utils.XRefMock([{
|
@@ -168,17 +170,17 @@ describe('primitives', function () {
|
|
168
170
|
data: testFontFile
|
169
171
|
}]);
|
170
172
|
var fontDict = new _primitives.Dict(xref);
|
171
|
-
fontDict.set(
|
172
|
-
expect(fontDict.getRaw(
|
173
|
-
expect(fontDict.get(
|
174
|
-
fontDict.getAsync(
|
173
|
+
fontDict.set("FontFile", fontRef);
|
174
|
+
expect(fontDict.getRaw("FontFile")).toEqual(fontRef);
|
175
|
+
expect(fontDict.get("FontFile", "FontFile2", "FontFile3")).toEqual(testFontFile);
|
176
|
+
fontDict.getAsync("FontFile", "FontFile2", "FontFile3").then(function (value) {
|
175
177
|
expect(value).toEqual(testFontFile);
|
176
178
|
done();
|
177
|
-
})
|
179
|
+
}).catch(function (reason) {
|
178
180
|
done.fail(reason);
|
179
181
|
});
|
180
182
|
});
|
181
|
-
it(
|
183
|
+
it("should handle arrays containing indirect objects", function () {
|
182
184
|
var minCoordRef = _primitives.Ref.get(1, 0),
|
183
185
|
maxCoordRef = _primitives.Ref.get(2, 0);
|
184
186
|
|
@@ -192,35 +194,35 @@ describe('primitives', function () {
|
|
192
194
|
data: maxCoord
|
193
195
|
}]);
|
194
196
|
var xObjectDict = new _primitives.Dict(xref);
|
195
|
-
xObjectDict.set(
|
196
|
-
expect(xObjectDict.get(
|
197
|
-
expect(xObjectDict.getArray(
|
197
|
+
xObjectDict.set("BBox", [minCoord, maxCoord, minCoordRef, maxCoordRef]);
|
198
|
+
expect(xObjectDict.get("BBox")).toEqual([minCoord, maxCoord, minCoordRef, maxCoordRef]);
|
199
|
+
expect(xObjectDict.getArray("BBox")).toEqual([minCoord, maxCoord, minCoord, maxCoord]);
|
198
200
|
});
|
199
|
-
it(
|
200
|
-
var expectedKeys = [
|
201
|
+
it("should get all key names", function () {
|
202
|
+
var expectedKeys = ["FontFile", "FontFile2", "FontFile3"];
|
201
203
|
var keys = dictWithManyKeys.getKeys();
|
202
204
|
expect(keys.sort()).toEqual(expectedKeys);
|
203
205
|
});
|
204
|
-
it(
|
206
|
+
it("should create only one object for Dict.empty", function () {
|
205
207
|
var firstDictEmpty = _primitives.Dict.empty;
|
206
208
|
var secondDictEmpty = _primitives.Dict.empty;
|
207
209
|
expect(firstDictEmpty).toBe(secondDictEmpty);
|
208
210
|
expect(firstDictEmpty).not.toBe(emptyDict);
|
209
211
|
});
|
210
|
-
it(
|
211
|
-
var expectedKeys = [
|
212
|
+
it("should correctly merge dictionaries", function () {
|
213
|
+
var expectedKeys = ["FontFile", "FontFile2", "FontFile3", "Size"];
|
212
214
|
var fontFileDict = new _primitives.Dict();
|
213
|
-
fontFileDict.set(
|
215
|
+
fontFileDict.set("FontFile", "Type1 font file");
|
214
216
|
|
215
217
|
var mergedDict = _primitives.Dict.merge(null, [dictWithManyKeys, dictWithSizeKey, fontFileDict]);
|
216
218
|
|
217
219
|
var mergedKeys = mergedDict.getKeys();
|
218
220
|
expect(mergedKeys.sort()).toEqual(expectedKeys);
|
219
|
-
expect(mergedDict.get(
|
221
|
+
expect(mergedDict.get("FontFile")).toEqual(testFontFile);
|
220
222
|
});
|
221
223
|
});
|
222
|
-
describe(
|
223
|
-
it(
|
224
|
+
describe("Ref", function () {
|
225
|
+
it("should retain the stored values", function () {
|
224
226
|
var storedNum = 4;
|
225
227
|
var storedGen = 2;
|
226
228
|
|
@@ -230,15 +232,15 @@ describe('primitives', function () {
|
|
230
232
|
expect(ref.gen).toEqual(storedGen);
|
231
233
|
});
|
232
234
|
});
|
233
|
-
describe(
|
234
|
-
it(
|
235
|
+
describe("RefSet", function () {
|
236
|
+
it("should have a stored value", function () {
|
235
237
|
var ref = _primitives.Ref.get(4, 2);
|
236
238
|
|
237
239
|
var refset = new _primitives.RefSet();
|
238
240
|
refset.put(ref);
|
239
241
|
expect(refset.has(ref)).toBeTruthy();
|
240
242
|
});
|
241
|
-
it(
|
243
|
+
it("should not have an unknown value", function () {
|
242
244
|
var ref = _primitives.Ref.get(4, 2);
|
243
245
|
|
244
246
|
var refset = new _primitives.RefSet();
|
@@ -250,77 +252,77 @@ describe('primitives', function () {
|
|
250
252
|
expect(refset.has(anotherRef)).toBeFalsy();
|
251
253
|
});
|
252
254
|
});
|
253
|
-
describe(
|
254
|
-
it(
|
255
|
+
describe("isName", function () {
|
256
|
+
it("handles non-names", function () {
|
255
257
|
var nonName = {};
|
256
258
|
expect((0, _primitives.isName)(nonName)).toEqual(false);
|
257
259
|
});
|
258
|
-
it(
|
259
|
-
var name = _primitives.Name.get(
|
260
|
+
it("handles names", function () {
|
261
|
+
var name = _primitives.Name.get("Font");
|
260
262
|
|
261
263
|
expect((0, _primitives.isName)(name)).toEqual(true);
|
262
264
|
});
|
263
|
-
it(
|
264
|
-
var name = _primitives.Name.get(
|
265
|
+
it("handles names with name check", function () {
|
266
|
+
var name = _primitives.Name.get("Font");
|
265
267
|
|
266
|
-
expect((0, _primitives.isName)(name,
|
267
|
-
expect((0, _primitives.isName)(name,
|
268
|
+
expect((0, _primitives.isName)(name, "Font")).toEqual(true);
|
269
|
+
expect((0, _primitives.isName)(name, "Subtype")).toEqual(false);
|
268
270
|
});
|
269
271
|
});
|
270
|
-
describe(
|
271
|
-
it(
|
272
|
+
describe("isCmd", function () {
|
273
|
+
it("handles non-commands", function () {
|
272
274
|
var nonCmd = {};
|
273
275
|
expect((0, _primitives.isCmd)(nonCmd)).toEqual(false);
|
274
276
|
});
|
275
|
-
it(
|
276
|
-
var cmd = _primitives.Cmd.get(
|
277
|
+
it("handles commands", function () {
|
278
|
+
var cmd = _primitives.Cmd.get("BT");
|
277
279
|
|
278
280
|
expect((0, _primitives.isCmd)(cmd)).toEqual(true);
|
279
281
|
});
|
280
|
-
it(
|
281
|
-
var cmd = _primitives.Cmd.get(
|
282
|
+
it("handles commands with cmd check", function () {
|
283
|
+
var cmd = _primitives.Cmd.get("BT");
|
282
284
|
|
283
|
-
expect((0, _primitives.isCmd)(cmd,
|
284
|
-
expect((0, _primitives.isCmd)(cmd,
|
285
|
+
expect((0, _primitives.isCmd)(cmd, "BT")).toEqual(true);
|
286
|
+
expect((0, _primitives.isCmd)(cmd, "ET")).toEqual(false);
|
285
287
|
});
|
286
288
|
});
|
287
|
-
describe(
|
288
|
-
it(
|
289
|
+
describe("isDict", function () {
|
290
|
+
it("handles non-dictionaries", function () {
|
289
291
|
var nonDict = {};
|
290
292
|
expect((0, _primitives.isDict)(nonDict)).toEqual(false);
|
291
293
|
});
|
292
|
-
it(
|
294
|
+
it("handles empty dictionaries with type check", function () {
|
293
295
|
var dict = _primitives.Dict.empty;
|
294
296
|
expect((0, _primitives.isDict)(dict)).toEqual(true);
|
295
|
-
expect((0, _primitives.isDict)(dict,
|
297
|
+
expect((0, _primitives.isDict)(dict, "Page")).toEqual(false);
|
296
298
|
});
|
297
|
-
it(
|
299
|
+
it("handles dictionaries with type check", function () {
|
298
300
|
var dict = new _primitives.Dict();
|
299
|
-
dict.set(
|
300
|
-
expect((0, _primitives.isDict)(dict,
|
301
|
-
expect((0, _primitives.isDict)(dict,
|
301
|
+
dict.set("Type", _primitives.Name.get("Page"));
|
302
|
+
expect((0, _primitives.isDict)(dict, "Page")).toEqual(true);
|
303
|
+
expect((0, _primitives.isDict)(dict, "Contents")).toEqual(false);
|
302
304
|
});
|
303
305
|
});
|
304
|
-
describe(
|
305
|
-
it(
|
306
|
+
describe("isRef", function () {
|
307
|
+
it("handles non-refs", function () {
|
306
308
|
var nonRef = {};
|
307
309
|
expect((0, _primitives.isRef)(nonRef)).toEqual(false);
|
308
310
|
});
|
309
|
-
it(
|
311
|
+
it("handles refs", function () {
|
310
312
|
var ref = _primitives.Ref.get(1, 0);
|
311
313
|
|
312
314
|
expect((0, _primitives.isRef)(ref)).toEqual(true);
|
313
315
|
});
|
314
316
|
});
|
315
|
-
describe(
|
316
|
-
it(
|
317
|
+
describe("isRefsEqual", function () {
|
318
|
+
it("should handle Refs pointing to the same object", function () {
|
317
319
|
var ref1 = _primitives.Ref.get(1, 0);
|
318
320
|
|
319
321
|
var ref2 = _primitives.Ref.get(1, 0);
|
320
322
|
|
321
323
|
expect((0, _primitives.isRefsEqual)(ref1, ref2)).toEqual(true);
|
322
324
|
});
|
323
|
-
it(
|
325
|
+
it("should handle Refs pointing to different objects", function () {
|
324
326
|
var ref1 = _primitives.Ref.get(1, 0);
|
325
327
|
|
326
328
|
var ref2 = _primitives.Ref.get(2, 0);
|