@vaadin-component-factory/vcf-pdf-viewer 0.9.0 → 0.9.4
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.
- package/README.md +1 -1
- package/package.json +33 -18
- package/{src/display → pdfjs/dist}/display_utils.js +344 -139
- package/{src/display → pdfjs/dist}/fetch_stream.js +115 -97
- package/pdfjs/dist/get.js +1857 -0
- package/pdfjs/dist/index.js +767 -0
- package/pdfjs/dist/l10n_utils.js +140 -0
- package/{src/shared → pdfjs/dist}/message_handler.js +243 -259
- package/{src/display → pdfjs/dist}/network.js +149 -87
- package/{src/display/content_disposition.js → pdfjs/dist/network_utils.js} +167 -55
- package/{src/display → pdfjs/dist}/node_stream.js +133 -98
- package/pdfjs/dist/pdf.js +12778 -0
- package/pdfjs/dist/pdf_link_service.js +638 -0
- package/pdfjs/dist/pdf_rendering_queue.js +199 -0
- package/pdfjs/dist/pdf_thumbnail_viewer.js +819 -0
- package/pdfjs/dist/pdf_viewer.js +3598 -0
- package/pdfjs/dist/typeof.js +100 -0
- package/pdfjs/dist/ui_utils.js +1033 -0
- package/{src/shared → pdfjs/dist}/util.js +301 -287
- package/pdfjs/dist/worker.js +62813 -0
- package/src/vcf-pdf-viewer.js +77 -27
- package/theme/lumo/vcf-pdf-viewer-styles.js +1 -1
- package/theme/material/vcf-pdf-viewer.js +2 -2
- package/src/core/.eslintrc +0 -13
- package/src/core/annotation.js +0 -2948
- package/src/core/arithmetic_decoder.js +0 -182
- package/src/core/ascii_85_stream.js +0 -98
- package/src/core/ascii_hex_stream.js +0 -79
- package/src/core/base_stream.js +0 -110
- package/src/core/bidi.js +0 -438
- package/src/core/calibri_factors.js +0 -308
- package/src/core/catalog.js +0 -1459
- package/src/core/ccitt.js +0 -1062
- package/src/core/ccitt_stream.js +0 -60
- package/src/core/cff_font.js +0 -116
- package/src/core/cff_parser.js +0 -1949
- package/src/core/charsets.js +0 -119
- package/src/core/chunked_stream.js +0 -557
- package/src/core/cmap.js +0 -1039
- package/src/core/colorspace.js +0 -1533
- package/src/core/core_utils.js +0 -464
- package/src/core/crypto.js +0 -1900
- package/src/core/decode_stream.js +0 -170
- package/src/core/decrypt_stream.js +0 -59
- package/src/core/default_appearance.js +0 -99
- package/src/core/document.js +0 -1456
- package/src/core/encodings.js +0 -301
- package/src/core/evaluator.js +0 -4601
- package/src/core/file_spec.js +0 -108
- package/src/core/flate_stream.js +0 -402
- package/src/core/font_renderer.js +0 -882
- package/src/core/fonts.js +0 -3260
- package/src/core/fonts_utils.js +0 -221
- package/src/core/function.js +0 -1257
- package/src/core/glyf.js +0 -706
- package/src/core/glyphlist.js +0 -4558
- package/src/core/helvetica_factors.js +0 -353
- package/src/core/image.js +0 -802
- package/src/core/image_utils.js +0 -291
- package/src/core/jbig2.js +0 -2572
- package/src/core/jbig2_stream.js +0 -73
- package/src/core/jpeg_stream.js +0 -105
- package/src/core/jpg.js +0 -1416
- package/src/core/jpx.js +0 -2343
- package/src/core/jpx_stream.js +0 -87
- package/src/core/liberationsans_widths.js +0 -221
- package/src/core/lzw_stream.js +0 -150
- package/src/core/metadata_parser.js +0 -146
- package/src/core/metrics.js +0 -2970
- package/src/core/murmurhash3.js +0 -139
- package/src/core/myriadpro_factors.js +0 -290
- package/src/core/name_number_tree.js +0 -153
- package/src/core/object_loader.js +0 -149
- package/src/core/opentype_file_builder.js +0 -154
- package/src/core/operator_list.js +0 -734
- package/src/core/parser.js +0 -1416
- package/src/core/pattern.js +0 -985
- package/src/core/pdf_manager.js +0 -217
- package/src/core/predictor_stream.js +0 -238
- package/src/core/primitives.js +0 -402
- package/src/core/ps_parser.js +0 -272
- package/src/core/run_length_stream.js +0 -61
- package/src/core/segoeui_factors.js +0 -308
- package/src/core/standard_fonts.js +0 -817
- package/src/core/stream.js +0 -103
- package/src/core/struct_tree.js +0 -335
- package/src/core/to_unicode_map.js +0 -103
- package/src/core/type1_font.js +0 -421
- package/src/core/type1_parser.js +0 -776
- package/src/core/unicode.js +0 -1649
- package/src/core/worker.js +0 -848
- package/src/core/worker_stream.js +0 -135
- package/src/core/writer.js +0 -278
- package/src/core/xfa/bind.js +0 -652
- package/src/core/xfa/builder.js +0 -207
- package/src/core/xfa/config.js +0 -1926
- package/src/core/xfa/connection_set.js +0 -202
- package/src/core/xfa/data.js +0 -82
- package/src/core/xfa/datasets.js +0 -76
- package/src/core/xfa/factory.js +0 -111
- package/src/core/xfa/fonts.js +0 -181
- package/src/core/xfa/formcalc_lexer.js +0 -385
- package/src/core/xfa/formcalc_parser.js +0 -1340
- package/src/core/xfa/html_utils.js +0 -639
- package/src/core/xfa/layout.js +0 -383
- package/src/core/xfa/locale_set.js +0 -345
- package/src/core/xfa/namespaces.js +0 -81
- package/src/core/xfa/parser.js +0 -184
- package/src/core/xfa/setup.js +0 -38
- package/src/core/xfa/signature.js +0 -40
- package/src/core/xfa/som.js +0 -338
- package/src/core/xfa/stylesheet.js +0 -40
- package/src/core/xfa/template.js +0 -6260
- package/src/core/xfa/text.js +0 -290
- package/src/core/xfa/unknown.js +0 -29
- package/src/core/xfa/utils.js +0 -217
- package/src/core/xfa/xdp.js +0 -59
- package/src/core/xfa/xfa_object.js +0 -1130
- package/src/core/xfa/xhtml.js +0 -543
- package/src/core/xfa_fonts.js +0 -208
- package/src/core/xml_parser.js +0 -507
- package/src/core/xref.js +0 -899
- package/src/display/annotation_layer.js +0 -2107
- package/src/display/annotation_storage.js +0 -113
- package/src/display/api.js +0 -3292
- package/src/display/base_factory.js +0 -180
- package/src/display/canvas.js +0 -2828
- package/src/display/font_loader.js +0 -484
- package/src/display/metadata.js +0 -41
- package/src/display/network_utils.js +0 -100
- package/src/display/node_utils.js +0 -83
- package/src/display/optional_content_config.js +0 -189
- package/src/display/pattern_helper.js +0 -659
- package/src/display/svg.js +0 -1709
- package/src/display/text_layer.js +0 -847
- package/src/display/transport_stream.js +0 -303
- package/src/display/worker_options.js +0 -40
- package/src/display/xfa_layer.js +0 -204
- package/src/doc_helper.js +0 -25
- package/src/images/logo.svg +0 -41
- package/src/interfaces.js +0 -169
- package/src/license_header.js +0 -14
- package/src/license_header_libre.js +0 -21
- package/src/pdf.image_decoders.js +0 -46
- package/src/pdf.js +0 -146
- package/src/pdf.sandbox.external.js +0 -181
- package/src/pdf.sandbox.js +0 -151
- package/src/pdf.scripting.js +0 -25
- package/src/pdf.worker.entry.js +0 -19
- package/src/pdf.worker.js +0 -23
- package/src/scripting_api/aform.js +0 -608
- package/src/scripting_api/app.js +0 -621
- package/src/scripting_api/color.js +0 -129
- package/src/scripting_api/common.js +0 -58
- package/src/scripting_api/console.js +0 -38
- package/src/scripting_api/constants.js +0 -208
- package/src/scripting_api/doc.js +0 -1195
- package/src/scripting_api/error.js +0 -23
- package/src/scripting_api/event.js +0 -232
- package/src/scripting_api/field.js +0 -620
- package/src/scripting_api/fullscreen.js +0 -145
- package/src/scripting_api/initialization.js +0 -223
- package/src/scripting_api/pdf_object.js +0 -24
- package/src/scripting_api/print_params.js +0 -146
- package/src/scripting_api/proxy.js +0 -139
- package/src/scripting_api/thermometer.js +0 -69
- package/src/scripting_api/util.js +0 -581
- package/src/shared/.eslintrc +0 -13
- package/src/shared/cffStandardStrings.js +0 -311
- package/src/shared/compatibility.js +0 -114
- package/src/shared/fonts_utils.js +0 -429
- package/src/shared/is_node.js +0 -27
- package/src/shared/scripting_utils.js +0 -85
- package/src/worker_loader.js +0 -32
package/src/core/image_utils.js
DELETED
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
/* Copyright 2019 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 { assert, shadow, unreachable, warn } from "../shared/util.js";
|
|
17
|
-
import { RefSetCache } from "./primitives.js";
|
|
18
|
-
|
|
19
|
-
class BaseLocalCache {
|
|
20
|
-
constructor(options) {
|
|
21
|
-
if (this.constructor === BaseLocalCache) {
|
|
22
|
-
unreachable("Cannot initialize BaseLocalCache.");
|
|
23
|
-
}
|
|
24
|
-
if (!options || !options.onlyRefs) {
|
|
25
|
-
this._nameRefMap = new Map();
|
|
26
|
-
this._imageMap = new Map();
|
|
27
|
-
}
|
|
28
|
-
this._imageCache = new RefSetCache();
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
getByName(name) {
|
|
32
|
-
const ref = this._nameRefMap.get(name);
|
|
33
|
-
if (ref) {
|
|
34
|
-
return this.getByRef(ref);
|
|
35
|
-
}
|
|
36
|
-
return this._imageMap.get(name) || null;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
getByRef(ref) {
|
|
40
|
-
return this._imageCache.get(ref) || null;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
set(name, ref, data) {
|
|
44
|
-
unreachable("Abstract method `set` called.");
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
class LocalImageCache extends BaseLocalCache {
|
|
49
|
-
set(name, ref = null, data) {
|
|
50
|
-
if (typeof name !== "string") {
|
|
51
|
-
throw new Error('LocalImageCache.set - expected "name" argument.');
|
|
52
|
-
}
|
|
53
|
-
if (ref) {
|
|
54
|
-
if (this._imageCache.has(ref)) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
this._nameRefMap.set(name, ref);
|
|
58
|
-
this._imageCache.put(ref, data);
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
// name
|
|
62
|
-
if (this._imageMap.has(name)) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
this._imageMap.set(name, data);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
class LocalColorSpaceCache extends BaseLocalCache {
|
|
70
|
-
set(name = null, ref = null, data) {
|
|
71
|
-
if (typeof name !== "string" && !ref) {
|
|
72
|
-
throw new Error(
|
|
73
|
-
'LocalColorSpaceCache.set - expected "name" and/or "ref" argument.'
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
if (ref) {
|
|
77
|
-
if (this._imageCache.has(ref)) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
if (name !== null) {
|
|
81
|
-
// Optional when `ref` is defined.
|
|
82
|
-
this._nameRefMap.set(name, ref);
|
|
83
|
-
}
|
|
84
|
-
this._imageCache.put(ref, data);
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
// name
|
|
88
|
-
if (this._imageMap.has(name)) {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
this._imageMap.set(name, data);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
class LocalFunctionCache extends BaseLocalCache {
|
|
96
|
-
constructor(options) {
|
|
97
|
-
super({ onlyRefs: true });
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
getByName(name) {
|
|
101
|
-
unreachable("Should not call `getByName` method.");
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
set(name = null, ref, data) {
|
|
105
|
-
if (!ref) {
|
|
106
|
-
throw new Error('LocalFunctionCache.set - expected "ref" argument.');
|
|
107
|
-
}
|
|
108
|
-
if (this._imageCache.has(ref)) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
this._imageCache.put(ref, data);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
class LocalGStateCache extends BaseLocalCache {
|
|
116
|
-
set(name, ref = null, data) {
|
|
117
|
-
if (typeof name !== "string") {
|
|
118
|
-
throw new Error('LocalGStateCache.set - expected "name" argument.');
|
|
119
|
-
}
|
|
120
|
-
if (ref) {
|
|
121
|
-
if (this._imageCache.has(ref)) {
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
this._nameRefMap.set(name, ref);
|
|
125
|
-
this._imageCache.put(ref, data);
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
// name
|
|
129
|
-
if (this._imageMap.has(name)) {
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
this._imageMap.set(name, data);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
class LocalTilingPatternCache extends BaseLocalCache {
|
|
137
|
-
set(name, ref = null, data) {
|
|
138
|
-
if (typeof name !== "string") {
|
|
139
|
-
throw new Error(
|
|
140
|
-
'LocalTilingPatternCache.set - expected "name" argument.'
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
if (ref) {
|
|
144
|
-
if (this._imageCache.has(ref)) {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
this._nameRefMap.set(name, ref);
|
|
148
|
-
this._imageCache.put(ref, data);
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
// name
|
|
152
|
-
if (this._imageMap.has(name)) {
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
this._imageMap.set(name, data);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
class GlobalImageCache {
|
|
160
|
-
static get NUM_PAGES_THRESHOLD() {
|
|
161
|
-
return shadow(this, "NUM_PAGES_THRESHOLD", 2);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
static get MIN_IMAGES_TO_CACHE() {
|
|
165
|
-
return shadow(this, "MIN_IMAGES_TO_CACHE", 10);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
static get MAX_BYTE_SIZE() {
|
|
169
|
-
return shadow(this, "MAX_BYTE_SIZE", /* Forty megabytes = */ 40e6);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
constructor() {
|
|
173
|
-
if (
|
|
174
|
-
typeof PDFJSDev === "undefined" ||
|
|
175
|
-
PDFJSDev.test("!PRODUCTION || TESTING")
|
|
176
|
-
) {
|
|
177
|
-
assert(
|
|
178
|
-
GlobalImageCache.NUM_PAGES_THRESHOLD > 1,
|
|
179
|
-
"GlobalImageCache - invalid NUM_PAGES_THRESHOLD constant."
|
|
180
|
-
);
|
|
181
|
-
}
|
|
182
|
-
this._refCache = new RefSetCache();
|
|
183
|
-
this._imageCache = new RefSetCache();
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
get _byteSize() {
|
|
187
|
-
let byteSize = 0;
|
|
188
|
-
this._imageCache.forEach(imageData => {
|
|
189
|
-
byteSize += imageData.byteSize;
|
|
190
|
-
});
|
|
191
|
-
return byteSize;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
get _cacheLimitReached() {
|
|
195
|
-
if (this._imageCache.size < GlobalImageCache.MIN_IMAGES_TO_CACHE) {
|
|
196
|
-
return false;
|
|
197
|
-
}
|
|
198
|
-
if (this._byteSize < GlobalImageCache.MAX_BYTE_SIZE) {
|
|
199
|
-
return false;
|
|
200
|
-
}
|
|
201
|
-
return true;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
shouldCache(ref, pageIndex) {
|
|
205
|
-
const pageIndexSet = this._refCache.get(ref);
|
|
206
|
-
const numPages = pageIndexSet
|
|
207
|
-
? pageIndexSet.size + (pageIndexSet.has(pageIndex) ? 0 : 1)
|
|
208
|
-
: 1;
|
|
209
|
-
|
|
210
|
-
if (numPages < GlobalImageCache.NUM_PAGES_THRESHOLD) {
|
|
211
|
-
return false;
|
|
212
|
-
}
|
|
213
|
-
if (!this._imageCache.has(ref) && this._cacheLimitReached) {
|
|
214
|
-
return false;
|
|
215
|
-
}
|
|
216
|
-
return true;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
addPageIndex(ref, pageIndex) {
|
|
220
|
-
let pageIndexSet = this._refCache.get(ref);
|
|
221
|
-
if (!pageIndexSet) {
|
|
222
|
-
pageIndexSet = new Set();
|
|
223
|
-
this._refCache.put(ref, pageIndexSet);
|
|
224
|
-
}
|
|
225
|
-
pageIndexSet.add(pageIndex);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* PLEASE NOTE: Must be called *after* the `setData` method.
|
|
230
|
-
*/
|
|
231
|
-
addByteSize(ref, byteSize) {
|
|
232
|
-
const imageData = this._imageCache.get(ref);
|
|
233
|
-
if (!imageData) {
|
|
234
|
-
return; // The image data isn't cached (the limit was reached).
|
|
235
|
-
}
|
|
236
|
-
if (imageData.byteSize) {
|
|
237
|
-
return; // The byte-size has already been set.
|
|
238
|
-
}
|
|
239
|
-
imageData.byteSize = byteSize;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
getData(ref, pageIndex) {
|
|
243
|
-
const pageIndexSet = this._refCache.get(ref);
|
|
244
|
-
if (!pageIndexSet) {
|
|
245
|
-
return null;
|
|
246
|
-
}
|
|
247
|
-
if (pageIndexSet.size < GlobalImageCache.NUM_PAGES_THRESHOLD) {
|
|
248
|
-
return null;
|
|
249
|
-
}
|
|
250
|
-
const imageData = this._imageCache.get(ref);
|
|
251
|
-
if (!imageData) {
|
|
252
|
-
return null;
|
|
253
|
-
}
|
|
254
|
-
// Ensure that we keep track of all pages containing the image reference.
|
|
255
|
-
pageIndexSet.add(pageIndex);
|
|
256
|
-
|
|
257
|
-
return imageData;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
setData(ref, data) {
|
|
261
|
-
if (!this._refCache.has(ref)) {
|
|
262
|
-
throw new Error(
|
|
263
|
-
'GlobalImageCache.setData - expected "addPageIndex" to have been called.'
|
|
264
|
-
);
|
|
265
|
-
}
|
|
266
|
-
if (this._imageCache.has(ref)) {
|
|
267
|
-
return;
|
|
268
|
-
}
|
|
269
|
-
if (this._cacheLimitReached) {
|
|
270
|
-
warn("GlobalImageCache.setData - cache limit reached.");
|
|
271
|
-
return;
|
|
272
|
-
}
|
|
273
|
-
this._imageCache.put(ref, data);
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
clear(onlyData = false) {
|
|
277
|
-
if (!onlyData) {
|
|
278
|
-
this._refCache.clear();
|
|
279
|
-
}
|
|
280
|
-
this._imageCache.clear();
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
export {
|
|
285
|
-
GlobalImageCache,
|
|
286
|
-
LocalColorSpaceCache,
|
|
287
|
-
LocalFunctionCache,
|
|
288
|
-
LocalGStateCache,
|
|
289
|
-
LocalImageCache,
|
|
290
|
-
LocalTilingPatternCache,
|
|
291
|
-
};
|