@vaadin-component-factory/vcf-pdf-viewer 0.9.0 → 1.0.0

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.
Files changed (172) hide show
  1. package/README.md +1 -1
  2. package/package.json +42 -26
  3. package/{src/display → pdfjs/dist}/display_utils.js +344 -139
  4. package/{src/display → pdfjs/dist}/fetch_stream.js +115 -97
  5. package/pdfjs/dist/l10n_utils.js +140 -0
  6. package/{src/shared → pdfjs/dist}/message_handler.js +243 -259
  7. package/{src/display → pdfjs/dist}/network.js +149 -87
  8. package/{src/display/content_disposition.js → pdfjs/dist/network_utils.js} +167 -55
  9. package/{src/display → pdfjs/dist}/node_stream.js +133 -98
  10. package/pdfjs/dist/pdf.js +12778 -0
  11. package/pdfjs/dist/pdf_link_service.js +638 -0
  12. package/pdfjs/dist/pdf_rendering_queue.js +199 -0
  13. package/pdfjs/dist/pdf_thumbnail_viewer.js +819 -0
  14. package/pdfjs/dist/pdf_viewer.js +3598 -0
  15. package/pdfjs/dist/ui_utils.js +1033 -0
  16. package/{src/shared → pdfjs/dist}/util.js +301 -287
  17. package/pdfjs/dist/worker.js +62813 -0
  18. package/src/vcf-pdf-viewer.js +98 -46
  19. package/theme/lumo/vcf-pdf-viewer-styles.js +4 -4
  20. package/theme/material/vcf-pdf-viewer-styles.js +4 -4
  21. package/theme/material/vcf-pdf-viewer.js +2 -2
  22. package/src/core/.eslintrc +0 -13
  23. package/src/core/annotation.js +0 -2948
  24. package/src/core/arithmetic_decoder.js +0 -182
  25. package/src/core/ascii_85_stream.js +0 -98
  26. package/src/core/ascii_hex_stream.js +0 -79
  27. package/src/core/base_stream.js +0 -110
  28. package/src/core/bidi.js +0 -438
  29. package/src/core/calibri_factors.js +0 -308
  30. package/src/core/catalog.js +0 -1459
  31. package/src/core/ccitt.js +0 -1062
  32. package/src/core/ccitt_stream.js +0 -60
  33. package/src/core/cff_font.js +0 -116
  34. package/src/core/cff_parser.js +0 -1949
  35. package/src/core/charsets.js +0 -119
  36. package/src/core/chunked_stream.js +0 -557
  37. package/src/core/cmap.js +0 -1039
  38. package/src/core/colorspace.js +0 -1533
  39. package/src/core/core_utils.js +0 -464
  40. package/src/core/crypto.js +0 -1900
  41. package/src/core/decode_stream.js +0 -170
  42. package/src/core/decrypt_stream.js +0 -59
  43. package/src/core/default_appearance.js +0 -99
  44. package/src/core/document.js +0 -1456
  45. package/src/core/encodings.js +0 -301
  46. package/src/core/evaluator.js +0 -4601
  47. package/src/core/file_spec.js +0 -108
  48. package/src/core/flate_stream.js +0 -402
  49. package/src/core/font_renderer.js +0 -882
  50. package/src/core/fonts.js +0 -3260
  51. package/src/core/fonts_utils.js +0 -221
  52. package/src/core/function.js +0 -1257
  53. package/src/core/glyf.js +0 -706
  54. package/src/core/glyphlist.js +0 -4558
  55. package/src/core/helvetica_factors.js +0 -353
  56. package/src/core/image.js +0 -802
  57. package/src/core/image_utils.js +0 -291
  58. package/src/core/jbig2.js +0 -2572
  59. package/src/core/jbig2_stream.js +0 -73
  60. package/src/core/jpeg_stream.js +0 -105
  61. package/src/core/jpg.js +0 -1416
  62. package/src/core/jpx.js +0 -2343
  63. package/src/core/jpx_stream.js +0 -87
  64. package/src/core/liberationsans_widths.js +0 -221
  65. package/src/core/lzw_stream.js +0 -150
  66. package/src/core/metadata_parser.js +0 -146
  67. package/src/core/metrics.js +0 -2970
  68. package/src/core/murmurhash3.js +0 -139
  69. package/src/core/myriadpro_factors.js +0 -290
  70. package/src/core/name_number_tree.js +0 -153
  71. package/src/core/object_loader.js +0 -149
  72. package/src/core/opentype_file_builder.js +0 -154
  73. package/src/core/operator_list.js +0 -734
  74. package/src/core/parser.js +0 -1416
  75. package/src/core/pattern.js +0 -985
  76. package/src/core/pdf_manager.js +0 -217
  77. package/src/core/predictor_stream.js +0 -238
  78. package/src/core/primitives.js +0 -402
  79. package/src/core/ps_parser.js +0 -272
  80. package/src/core/run_length_stream.js +0 -61
  81. package/src/core/segoeui_factors.js +0 -308
  82. package/src/core/standard_fonts.js +0 -817
  83. package/src/core/stream.js +0 -103
  84. package/src/core/struct_tree.js +0 -335
  85. package/src/core/to_unicode_map.js +0 -103
  86. package/src/core/type1_font.js +0 -421
  87. package/src/core/type1_parser.js +0 -776
  88. package/src/core/unicode.js +0 -1649
  89. package/src/core/worker.js +0 -848
  90. package/src/core/worker_stream.js +0 -135
  91. package/src/core/writer.js +0 -278
  92. package/src/core/xfa/bind.js +0 -652
  93. package/src/core/xfa/builder.js +0 -207
  94. package/src/core/xfa/config.js +0 -1926
  95. package/src/core/xfa/connection_set.js +0 -202
  96. package/src/core/xfa/data.js +0 -82
  97. package/src/core/xfa/datasets.js +0 -76
  98. package/src/core/xfa/factory.js +0 -111
  99. package/src/core/xfa/fonts.js +0 -181
  100. package/src/core/xfa/formcalc_lexer.js +0 -385
  101. package/src/core/xfa/formcalc_parser.js +0 -1340
  102. package/src/core/xfa/html_utils.js +0 -639
  103. package/src/core/xfa/layout.js +0 -383
  104. package/src/core/xfa/locale_set.js +0 -345
  105. package/src/core/xfa/namespaces.js +0 -81
  106. package/src/core/xfa/parser.js +0 -184
  107. package/src/core/xfa/setup.js +0 -38
  108. package/src/core/xfa/signature.js +0 -40
  109. package/src/core/xfa/som.js +0 -338
  110. package/src/core/xfa/stylesheet.js +0 -40
  111. package/src/core/xfa/template.js +0 -6260
  112. package/src/core/xfa/text.js +0 -290
  113. package/src/core/xfa/unknown.js +0 -29
  114. package/src/core/xfa/utils.js +0 -217
  115. package/src/core/xfa/xdp.js +0 -59
  116. package/src/core/xfa/xfa_object.js +0 -1130
  117. package/src/core/xfa/xhtml.js +0 -543
  118. package/src/core/xfa_fonts.js +0 -208
  119. package/src/core/xml_parser.js +0 -507
  120. package/src/core/xref.js +0 -899
  121. package/src/display/annotation_layer.js +0 -2107
  122. package/src/display/annotation_storage.js +0 -113
  123. package/src/display/api.js +0 -3292
  124. package/src/display/base_factory.js +0 -180
  125. package/src/display/canvas.js +0 -2828
  126. package/src/display/font_loader.js +0 -484
  127. package/src/display/metadata.js +0 -41
  128. package/src/display/network_utils.js +0 -100
  129. package/src/display/node_utils.js +0 -83
  130. package/src/display/optional_content_config.js +0 -189
  131. package/src/display/pattern_helper.js +0 -659
  132. package/src/display/svg.js +0 -1709
  133. package/src/display/text_layer.js +0 -847
  134. package/src/display/transport_stream.js +0 -303
  135. package/src/display/worker_options.js +0 -40
  136. package/src/display/xfa_layer.js +0 -204
  137. package/src/doc_helper.js +0 -25
  138. package/src/images/logo.svg +0 -41
  139. package/src/interfaces.js +0 -169
  140. package/src/license_header.js +0 -14
  141. package/src/license_header_libre.js +0 -21
  142. package/src/pdf.image_decoders.js +0 -46
  143. package/src/pdf.js +0 -146
  144. package/src/pdf.sandbox.external.js +0 -181
  145. package/src/pdf.sandbox.js +0 -151
  146. package/src/pdf.scripting.js +0 -25
  147. package/src/pdf.worker.entry.js +0 -19
  148. package/src/pdf.worker.js +0 -23
  149. package/src/scripting_api/aform.js +0 -608
  150. package/src/scripting_api/app.js +0 -621
  151. package/src/scripting_api/color.js +0 -129
  152. package/src/scripting_api/common.js +0 -58
  153. package/src/scripting_api/console.js +0 -38
  154. package/src/scripting_api/constants.js +0 -208
  155. package/src/scripting_api/doc.js +0 -1195
  156. package/src/scripting_api/error.js +0 -23
  157. package/src/scripting_api/event.js +0 -232
  158. package/src/scripting_api/field.js +0 -620
  159. package/src/scripting_api/fullscreen.js +0 -145
  160. package/src/scripting_api/initialization.js +0 -223
  161. package/src/scripting_api/pdf_object.js +0 -24
  162. package/src/scripting_api/print_params.js +0 -146
  163. package/src/scripting_api/proxy.js +0 -139
  164. package/src/scripting_api/thermometer.js +0 -69
  165. package/src/scripting_api/util.js +0 -581
  166. package/src/shared/.eslintrc +0 -13
  167. package/src/shared/cffStandardStrings.js +0 -311
  168. package/src/shared/compatibility.js +0 -114
  169. package/src/shared/fonts_utils.js +0 -429
  170. package/src/shared/is_node.js +0 -27
  171. package/src/shared/scripting_utils.js +0 -85
  172. package/src/worker_loader.js +0 -32
@@ -1,149 +0,0 @@
1
- /* Copyright 2021 Mozilla Foundation
2
- *
3
- * Licensed under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License.
5
- * You may obtain a copy of the License at
6
- *
7
- * http://www.apache.org/licenses/LICENSE-2.0
8
- *
9
- * Unless required by applicable law or agreed to in writing, software
10
- * distributed under the License is distributed on an "AS IS" BASIS,
11
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- * See the License for the specific language governing permissions and
13
- * limitations under the License.
14
- */
15
-
16
- import { Dict, isStream, Ref, RefSet } from "./primitives.js";
17
- import { MissingDataException } from "./core_utils.js";
18
- import { warn } from "../shared/util.js";
19
-
20
- function mayHaveChildren(value) {
21
- return (
22
- value instanceof Ref ||
23
- value instanceof Dict ||
24
- Array.isArray(value) ||
25
- isStream(value)
26
- );
27
- }
28
-
29
- function addChildren(node, nodesToVisit) {
30
- if (node instanceof Dict) {
31
- node = node.getRawValues();
32
- } else if (isStream(node)) {
33
- node = node.dict.getRawValues();
34
- } else if (!Array.isArray(node)) {
35
- return;
36
- }
37
- for (const rawValue of node) {
38
- if (mayHaveChildren(rawValue)) {
39
- nodesToVisit.push(rawValue);
40
- }
41
- }
42
- }
43
-
44
- /**
45
- * A helper for loading missing data in `Dict` graphs. It traverses the graph
46
- * depth first and queues up any objects that have missing data. Once it has
47
- * has traversed as many objects that are available it attempts to bundle the
48
- * missing data requests and then resume from the nodes that weren't ready.
49
- *
50
- * NOTE: It provides protection from circular references by keeping track of
51
- * loaded references. However, you must be careful not to load any graphs
52
- * that have references to the catalog or other pages since that will cause the
53
- * entire PDF document object graph to be traversed.
54
- */
55
- class ObjectLoader {
56
- constructor(dict, keys, xref) {
57
- this.dict = dict;
58
- this.keys = keys;
59
- this.xref = xref;
60
- this.refSet = null;
61
- }
62
-
63
- async load() {
64
- // Don't walk the graph if all the data is already loaded.
65
- if (this.xref.stream.isDataLoaded) {
66
- return undefined;
67
- }
68
-
69
- const { keys, dict } = this;
70
- this.refSet = new RefSet();
71
- // Setup the initial nodes to visit.
72
- const nodesToVisit = [];
73
- for (let i = 0, ii = keys.length; i < ii; i++) {
74
- const rawValue = dict.getRaw(keys[i]);
75
- // Skip nodes that are guaranteed to be empty.
76
- if (rawValue !== undefined) {
77
- nodesToVisit.push(rawValue);
78
- }
79
- }
80
- return this._walk(nodesToVisit);
81
- }
82
-
83
- async _walk(nodesToVisit) {
84
- const nodesToRevisit = [];
85
- const pendingRequests = [];
86
- // DFS walk of the object graph.
87
- while (nodesToVisit.length) {
88
- let currentNode = nodesToVisit.pop();
89
-
90
- // Only references or chunked streams can cause missing data exceptions.
91
- if (currentNode instanceof Ref) {
92
- // Skip nodes that have already been visited.
93
- if (this.refSet.has(currentNode)) {
94
- continue;
95
- }
96
- try {
97
- this.refSet.put(currentNode);
98
- currentNode = this.xref.fetch(currentNode);
99
- } catch (ex) {
100
- if (!(ex instanceof MissingDataException)) {
101
- warn(`ObjectLoader._walk - requesting all data: "${ex}".`);
102
- this.refSet = null;
103
-
104
- const { manager } = this.xref.stream;
105
- return manager.requestAllChunks();
106
- }
107
- nodesToRevisit.push(currentNode);
108
- pendingRequests.push({ begin: ex.begin, end: ex.end });
109
- }
110
- }
111
- if (isStream(currentNode)) {
112
- const baseStreams = currentNode.getBaseStreams();
113
- if (baseStreams) {
114
- let foundMissingData = false;
115
- for (const stream of baseStreams) {
116
- if (stream.isDataLoaded) {
117
- continue;
118
- }
119
- foundMissingData = true;
120
- pendingRequests.push({ begin: stream.start, end: stream.end });
121
- }
122
- if (foundMissingData) {
123
- nodesToRevisit.push(currentNode);
124
- }
125
- }
126
- }
127
-
128
- addChildren(currentNode, nodesToVisit);
129
- }
130
-
131
- if (pendingRequests.length) {
132
- await this.xref.stream.manager.requestRanges(pendingRequests);
133
-
134
- for (const node of nodesToRevisit) {
135
- // Remove any reference nodes from the current `RefSet` so they
136
- // aren't skipped when we revist them.
137
- if (node instanceof Ref) {
138
- this.refSet.remove(node);
139
- }
140
- }
141
- return this._walk(nodesToRevisit);
142
- }
143
- // Everything is loaded.
144
- this.refSet = null;
145
- return undefined;
146
- }
147
- }
148
-
149
- export { ObjectLoader };
@@ -1,154 +0,0 @@
1
- /* Copyright 2012 Mozilla Foundation
2
- *
3
- * Licensed under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License.
5
- * You may obtain a copy of the License at
6
- *
7
- * http://www.apache.org/licenses/LICENSE-2.0
8
- *
9
- * Unless required by applicable law or agreed to in writing, software
10
- * distributed under the License is distributed on an "AS IS" BASIS,
11
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- * See the License for the specific language governing permissions and
13
- * limitations under the License.
14
- */
15
-
16
- import { readUint32 } from "./core_utils.js";
17
- import { string32 } from "../shared/util.js";
18
-
19
- function writeInt16(dest, offset, num) {
20
- dest[offset] = (num >> 8) & 0xff;
21
- dest[offset + 1] = num & 0xff;
22
- }
23
-
24
- function writeInt32(dest, offset, num) {
25
- dest[offset] = (num >> 24) & 0xff;
26
- dest[offset + 1] = (num >> 16) & 0xff;
27
- dest[offset + 2] = (num >> 8) & 0xff;
28
- dest[offset + 3] = num & 0xff;
29
- }
30
-
31
- function writeData(dest, offset, data) {
32
- if (data instanceof Uint8Array) {
33
- dest.set(data, offset);
34
- } else if (typeof data === "string") {
35
- for (let i = 0, ii = data.length; i < ii; i++) {
36
- dest[offset++] = data.charCodeAt(i) & 0xff;
37
- }
38
- } else {
39
- // treating everything else as array
40
- for (let i = 0, ii = data.length; i < ii; i++) {
41
- dest[offset++] = data[i] & 0xff;
42
- }
43
- }
44
- }
45
-
46
- const OTF_HEADER_SIZE = 12;
47
- const OTF_TABLE_ENTRY_SIZE = 16;
48
-
49
- class OpenTypeFileBuilder {
50
- constructor(sfnt) {
51
- this.sfnt = sfnt;
52
- this.tables = Object.create(null);
53
- }
54
-
55
- static getSearchParams(entriesCount, entrySize) {
56
- let maxPower2 = 1,
57
- log2 = 0;
58
- while ((maxPower2 ^ entriesCount) > maxPower2) {
59
- maxPower2 <<= 1;
60
- log2++;
61
- }
62
- const searchRange = maxPower2 * entrySize;
63
- return {
64
- range: searchRange,
65
- entry: log2,
66
- rangeShift: entrySize * entriesCount - searchRange,
67
- };
68
- }
69
-
70
- toArray() {
71
- let sfnt = this.sfnt;
72
-
73
- // Tables needs to be written by ascendant alphabetic order
74
- const tables = this.tables;
75
- const tablesNames = Object.keys(tables);
76
- tablesNames.sort();
77
- const numTables = tablesNames.length;
78
-
79
- let i, j, jj, table, tableName;
80
- // layout the tables data
81
- let offset = OTF_HEADER_SIZE + numTables * OTF_TABLE_ENTRY_SIZE;
82
- const tableOffsets = [offset];
83
- for (i = 0; i < numTables; i++) {
84
- table = tables[tablesNames[i]];
85
- const paddedLength = ((table.length + 3) & ~3) >>> 0;
86
- offset += paddedLength;
87
- tableOffsets.push(offset);
88
- }
89
-
90
- const file = new Uint8Array(offset);
91
- // write the table data first (mostly for checksum)
92
- for (i = 0; i < numTables; i++) {
93
- table = tables[tablesNames[i]];
94
- writeData(file, tableOffsets[i], table);
95
- }
96
-
97
- // sfnt version (4 bytes)
98
- if (sfnt === "true") {
99
- // Windows hates the Mac TrueType sfnt version number
100
- sfnt = string32(0x00010000);
101
- }
102
- file[0] = sfnt.charCodeAt(0) & 0xff;
103
- file[1] = sfnt.charCodeAt(1) & 0xff;
104
- file[2] = sfnt.charCodeAt(2) & 0xff;
105
- file[3] = sfnt.charCodeAt(3) & 0xff;
106
-
107
- // numTables (2 bytes)
108
- writeInt16(file, 4, numTables);
109
-
110
- const searchParams = OpenTypeFileBuilder.getSearchParams(numTables, 16);
111
-
112
- // searchRange (2 bytes)
113
- writeInt16(file, 6, searchParams.range);
114
- // entrySelector (2 bytes)
115
- writeInt16(file, 8, searchParams.entry);
116
- // rangeShift (2 bytes)
117
- writeInt16(file, 10, searchParams.rangeShift);
118
-
119
- offset = OTF_HEADER_SIZE;
120
- // writing table entries
121
- for (i = 0; i < numTables; i++) {
122
- tableName = tablesNames[i];
123
- file[offset] = tableName.charCodeAt(0) & 0xff;
124
- file[offset + 1] = tableName.charCodeAt(1) & 0xff;
125
- file[offset + 2] = tableName.charCodeAt(2) & 0xff;
126
- file[offset + 3] = tableName.charCodeAt(3) & 0xff;
127
-
128
- // checksum
129
- let checksum = 0;
130
- for (j = tableOffsets[i], jj = tableOffsets[i + 1]; j < jj; j += 4) {
131
- const quad = readUint32(file, j);
132
- checksum = (checksum + quad) >>> 0;
133
- }
134
- writeInt32(file, offset + 4, checksum);
135
-
136
- // offset
137
- writeInt32(file, offset + 8, tableOffsets[i]);
138
- // length
139
- writeInt32(file, offset + 12, tables[tableName].length);
140
-
141
- offset += OTF_TABLE_ENTRY_SIZE;
142
- }
143
- return file;
144
- }
145
-
146
- addTable(tag, data) {
147
- if (tag in this.tables) {
148
- throw new Error("Table " + tag + " already exists");
149
- }
150
- this.tables[tag] = data;
151
- }
152
- }
153
-
154
- export { OpenTypeFileBuilder };