@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.
- package/README.md +1 -1
- package/package.json +42 -26
- package/{src/display → pdfjs/dist}/display_utils.js +344 -139
- package/{src/display → pdfjs/dist}/fetch_stream.js +115 -97
- 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/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 +98 -46
- package/theme/lumo/vcf-pdf-viewer-styles.js +4 -4
- package/theme/material/vcf-pdf-viewer-styles.js +4 -4
- 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/interfaces.js
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
/* Copyright 2018 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
|
-
/**
|
|
17
|
-
* Interface that represents PDF data transport. If possible, it allows
|
|
18
|
-
* progressively load entire or fragment of the PDF binary data.
|
|
19
|
-
*
|
|
20
|
-
* @interface
|
|
21
|
-
*/
|
|
22
|
-
class IPDFStream {
|
|
23
|
-
/**
|
|
24
|
-
* Gets a reader for the entire PDF data.
|
|
25
|
-
* @returns {IPDFStreamReader}
|
|
26
|
-
*/
|
|
27
|
-
getFullReader() {
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Gets a reader for the range of the PDF data.
|
|
33
|
-
* @param {number} begin - the start offset of the data.
|
|
34
|
-
* @param {number} end - the end offset of the data.
|
|
35
|
-
* @returns {IPDFStreamRangeReader}
|
|
36
|
-
*/
|
|
37
|
-
getRangeReader(begin, end) {
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Cancels all opened reader and closes all their opened requests.
|
|
43
|
-
* @param {Object} reason - the reason for cancelling
|
|
44
|
-
*/
|
|
45
|
-
cancelAllRequests(reason) {}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Interface for a PDF binary data reader.
|
|
50
|
-
*
|
|
51
|
-
* @interface
|
|
52
|
-
*/
|
|
53
|
-
class IPDFStreamReader {
|
|
54
|
-
constructor() {
|
|
55
|
-
/**
|
|
56
|
-
* Sets or gets the progress callback. The callback can be useful when the
|
|
57
|
-
* isStreamingSupported property of the object is defined as false.
|
|
58
|
-
* The callback is called with one parameter: an object with the loaded and
|
|
59
|
-
* total properties.
|
|
60
|
-
*/
|
|
61
|
-
this.onProgress = null;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Gets a promise that is resolved when the headers and other metadata of
|
|
66
|
-
* the PDF data stream are available.
|
|
67
|
-
* @type {Promise}
|
|
68
|
-
*/
|
|
69
|
-
get headersReady() {
|
|
70
|
-
return Promise.resolve();
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Gets the Content-Disposition filename. It is defined after the headersReady
|
|
75
|
-
* promise is resolved.
|
|
76
|
-
* @type {string|null} The filename, or `null` if the Content-Disposition
|
|
77
|
-
* header is missing/invalid.
|
|
78
|
-
*/
|
|
79
|
-
get filename() {
|
|
80
|
-
return null;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Gets PDF binary data length. It is defined after the headersReady promise
|
|
85
|
-
* is resolved.
|
|
86
|
-
* @type {number} The data length (or 0 if unknown).
|
|
87
|
-
*/
|
|
88
|
-
get contentLength() {
|
|
89
|
-
return 0;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Gets ability of the stream to handle range requests. It is defined after
|
|
94
|
-
* the headersReady promise is resolved. Rejected when the reader is cancelled
|
|
95
|
-
* or an error occurs.
|
|
96
|
-
* @type {boolean}
|
|
97
|
-
*/
|
|
98
|
-
get isRangeSupported() {
|
|
99
|
-
return false;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Gets ability of the stream to progressively load binary data. It is defined
|
|
104
|
-
* after the headersReady promise is resolved.
|
|
105
|
-
* @type {boolean}
|
|
106
|
-
*/
|
|
107
|
-
get isStreamingSupported() {
|
|
108
|
-
return false;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Requests a chunk of the binary data. The method returns the promise, which
|
|
113
|
-
* is resolved into object with properties "value" and "done". If the done
|
|
114
|
-
* is set to true, then the stream has reached its end, otherwise the value
|
|
115
|
-
* contains binary data. Cancelled requests will be resolved with the done is
|
|
116
|
-
* set to true.
|
|
117
|
-
* @returns {Promise}
|
|
118
|
-
*/
|
|
119
|
-
async read() {}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Cancels all pending read requests and closes the stream.
|
|
123
|
-
* @param {Object} reason
|
|
124
|
-
*/
|
|
125
|
-
cancel(reason) {}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Interface for a PDF binary data fragment reader.
|
|
130
|
-
*
|
|
131
|
-
* @interface
|
|
132
|
-
*/
|
|
133
|
-
class IPDFStreamRangeReader {
|
|
134
|
-
constructor() {
|
|
135
|
-
/**
|
|
136
|
-
* Sets or gets the progress callback. The callback can be useful when the
|
|
137
|
-
* isStreamingSupported property of the object is defined as false.
|
|
138
|
-
* The callback is called with one parameter: an object with the loaded
|
|
139
|
-
* property.
|
|
140
|
-
*/
|
|
141
|
-
this.onProgress = null;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Gets ability of the stream to progressively load binary data.
|
|
146
|
-
* @type {boolean}
|
|
147
|
-
*/
|
|
148
|
-
get isStreamingSupported() {
|
|
149
|
-
return false;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Requests a chunk of the binary data. The method returns the promise, which
|
|
154
|
-
* is resolved into object with properties "value" and "done". If the done
|
|
155
|
-
* is set to true, then the stream has reached its end, otherwise the value
|
|
156
|
-
* contains binary data. Cancelled requests will be resolved with the done is
|
|
157
|
-
* set to true.
|
|
158
|
-
* @returns {Promise}
|
|
159
|
-
*/
|
|
160
|
-
async read() {}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Cancels all pending read requests and closes the stream.
|
|
164
|
-
* @param {Object} reason
|
|
165
|
-
*/
|
|
166
|
-
cancel(reason) {}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
export { IPDFStream, IPDFStreamRangeReader, IPDFStreamReader };
|
package/src/license_header.js
DELETED
|
@@ -1,14 +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
|
-
*/
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @licstart The following is the entire license notice for the
|
|
3
|
-
* Javascript code in this page
|
|
4
|
-
*
|
|
5
|
-
* Copyright 2021 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
|
-
*/
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/* Copyright 2018 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 { getVerbosityLevel, setVerbosityLevel } from "./shared/util.js";
|
|
17
|
-
import { Jbig2Image } from "./core/jbig2.js";
|
|
18
|
-
import { JpegImage } from "./core/jpg.js";
|
|
19
|
-
import { JpxImage } from "./core/jpx.js";
|
|
20
|
-
|
|
21
|
-
// To ensure that the standalone PDF.js image decoders have the same
|
|
22
|
-
// browser/environment compatibility as the regular PDF.js library,
|
|
23
|
-
// the standard set of polyfills are thus included in this build as well.
|
|
24
|
-
//
|
|
25
|
-
// Given that the (current) image decoders don't use all of the features
|
|
26
|
-
// of the complete PDF.js library, e.g. they are completely synchronous,
|
|
27
|
-
// some of the larger polyfills are thus unnecessary.
|
|
28
|
-
//
|
|
29
|
-
// In an attempt to reduce the size of the standalone PDF.js image decoders,
|
|
30
|
-
// the following polyfills are currently being excluded:
|
|
31
|
-
// - ReadableStream
|
|
32
|
-
// - Promise
|
|
33
|
-
// - URL
|
|
34
|
-
|
|
35
|
-
// eslint-disable-next-line no-unused-vars
|
|
36
|
-
const pdfjsVersion = PDFJSDev.eval("BUNDLE_VERSION");
|
|
37
|
-
// eslint-disable-next-line no-unused-vars
|
|
38
|
-
const pdfjsBuild = PDFJSDev.eval("BUNDLE_BUILD");
|
|
39
|
-
|
|
40
|
-
export {
|
|
41
|
-
getVerbosityLevel,
|
|
42
|
-
Jbig2Image,
|
|
43
|
-
JpegImage,
|
|
44
|
-
JpxImage,
|
|
45
|
-
setVerbosityLevel,
|
|
46
|
-
};
|
package/src/pdf.js
DELETED
|
@@ -1,146 +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
|
-
/* eslint-disable sort-exports/sort-exports */
|
|
16
|
-
|
|
17
|
-
import {
|
|
18
|
-
addLinkAttributes,
|
|
19
|
-
getFilenameFromUrl,
|
|
20
|
-
getPdfFilenameFromUrl,
|
|
21
|
-
getXfaPageViewport,
|
|
22
|
-
isPdfFile,
|
|
23
|
-
isValidFetchUrl,
|
|
24
|
-
LinkTarget,
|
|
25
|
-
loadScript,
|
|
26
|
-
PDFDateString,
|
|
27
|
-
RenderingCancelledException,
|
|
28
|
-
} from "./display/display_utils.js";
|
|
29
|
-
import {
|
|
30
|
-
build,
|
|
31
|
-
getDocument,
|
|
32
|
-
LoopbackPort,
|
|
33
|
-
PDFDataRangeTransport,
|
|
34
|
-
PDFWorker,
|
|
35
|
-
setPDFNetworkStreamFactory,
|
|
36
|
-
version,
|
|
37
|
-
} from "./display/api.js";
|
|
38
|
-
import {
|
|
39
|
-
CMapCompressionType,
|
|
40
|
-
createObjectURL,
|
|
41
|
-
createPromiseCapability,
|
|
42
|
-
createValidAbsoluteUrl,
|
|
43
|
-
InvalidPDFException,
|
|
44
|
-
MissingPDFException,
|
|
45
|
-
OPS,
|
|
46
|
-
PasswordResponses,
|
|
47
|
-
PermissionFlag,
|
|
48
|
-
removeNullCharacters,
|
|
49
|
-
shadow,
|
|
50
|
-
UnexpectedResponseException,
|
|
51
|
-
UNSUPPORTED_FEATURES,
|
|
52
|
-
Util,
|
|
53
|
-
VerbosityLevel,
|
|
54
|
-
} from "./shared/util.js";
|
|
55
|
-
import { AnnotationLayer } from "./display/annotation_layer.js";
|
|
56
|
-
import { GlobalWorkerOptions } from "./display/worker_options.js";
|
|
57
|
-
import { isNodeJS } from "./shared/is_node.js";
|
|
58
|
-
import { renderTextLayer } from "./display/text_layer.js";
|
|
59
|
-
import { SVGGraphics } from "./display/svg.js";
|
|
60
|
-
import { XfaLayer } from "./display/xfa_layer.js";
|
|
61
|
-
|
|
62
|
-
/* eslint-disable-next-line no-unused-vars */
|
|
63
|
-
const pdfjsVersion =
|
|
64
|
-
typeof PDFJSDev !== "undefined" ? PDFJSDev.eval("BUNDLE_VERSION") : void 0;
|
|
65
|
-
/* eslint-disable-next-line no-unused-vars */
|
|
66
|
-
const pdfjsBuild =
|
|
67
|
-
typeof PDFJSDev !== "undefined" ? PDFJSDev.eval("BUNDLE_BUILD") : void 0;
|
|
68
|
-
|
|
69
|
-
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) {
|
|
70
|
-
const streamsPromise = Promise.all([
|
|
71
|
-
import("./display/network.js"),
|
|
72
|
-
import("./display/fetch_stream.js"),
|
|
73
|
-
]);
|
|
74
|
-
|
|
75
|
-
setPDFNetworkStreamFactory(async params => {
|
|
76
|
-
const [{ PDFNetworkStream }, { PDFFetchStream }] = await streamsPromise;
|
|
77
|
-
if (isValidFetchUrl(params.url)) {
|
|
78
|
-
return new PDFFetchStream(params);
|
|
79
|
-
}
|
|
80
|
-
return new PDFNetworkStream(params);
|
|
81
|
-
});
|
|
82
|
-
} else if (PDFJSDev.test("GENERIC || CHROME")) {
|
|
83
|
-
if (PDFJSDev.test("GENERIC") && isNodeJS) {
|
|
84
|
-
const { PDFNodeStream } = require("./display/node_stream.js");
|
|
85
|
-
|
|
86
|
-
setPDFNetworkStreamFactory(params => {
|
|
87
|
-
return new PDFNodeStream(params);
|
|
88
|
-
});
|
|
89
|
-
} else {
|
|
90
|
-
const { PDFNetworkStream } = require("./display/network.js");
|
|
91
|
-
const { PDFFetchStream } = require("./display/fetch_stream.js");
|
|
92
|
-
|
|
93
|
-
setPDFNetworkStreamFactory(params => {
|
|
94
|
-
if (isValidFetchUrl(params.url)) {
|
|
95
|
-
return new PDFFetchStream(params);
|
|
96
|
-
}
|
|
97
|
-
return new PDFNetworkStream(params);
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export {
|
|
103
|
-
// From "./display/display_utils.js":
|
|
104
|
-
addLinkAttributes,
|
|
105
|
-
getFilenameFromUrl,
|
|
106
|
-
getPdfFilenameFromUrl,
|
|
107
|
-
isPdfFile,
|
|
108
|
-
LinkTarget,
|
|
109
|
-
loadScript,
|
|
110
|
-
PDFDateString,
|
|
111
|
-
RenderingCancelledException,
|
|
112
|
-
getXfaPageViewport,
|
|
113
|
-
// From "./display/api.js":
|
|
114
|
-
build,
|
|
115
|
-
getDocument,
|
|
116
|
-
LoopbackPort,
|
|
117
|
-
PDFDataRangeTransport,
|
|
118
|
-
PDFWorker,
|
|
119
|
-
version,
|
|
120
|
-
// From "./shared/util.js":
|
|
121
|
-
CMapCompressionType,
|
|
122
|
-
createObjectURL,
|
|
123
|
-
createPromiseCapability,
|
|
124
|
-
createValidAbsoluteUrl,
|
|
125
|
-
InvalidPDFException,
|
|
126
|
-
MissingPDFException,
|
|
127
|
-
OPS,
|
|
128
|
-
PasswordResponses,
|
|
129
|
-
PermissionFlag,
|
|
130
|
-
removeNullCharacters,
|
|
131
|
-
shadow,
|
|
132
|
-
UnexpectedResponseException,
|
|
133
|
-
UNSUPPORTED_FEATURES,
|
|
134
|
-
Util,
|
|
135
|
-
VerbosityLevel,
|
|
136
|
-
// From "./display/annotation_layer.js":
|
|
137
|
-
AnnotationLayer,
|
|
138
|
-
// From "./display/worker_options.js":
|
|
139
|
-
GlobalWorkerOptions,
|
|
140
|
-
// From "./display/text_layer.js":
|
|
141
|
-
renderTextLayer,
|
|
142
|
-
// From "./display/svg.js":
|
|
143
|
-
SVGGraphics,
|
|
144
|
-
// From "./display/xfa_layer.js":
|
|
145
|
-
XfaLayer,
|
|
146
|
-
};
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
/* Copyright 2020 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
|
-
// In mozilla-central, this file is loaded as non-module script,
|
|
17
|
-
// so it mustn't have any dependencies.
|
|
18
|
-
|
|
19
|
-
class SandboxSupportBase {
|
|
20
|
-
/**
|
|
21
|
-
* @param {DOMWindow} - win
|
|
22
|
-
*/
|
|
23
|
-
constructor(win) {
|
|
24
|
-
this.win = win;
|
|
25
|
-
this.timeoutIds = new Map();
|
|
26
|
-
|
|
27
|
-
// Will be assigned after the sandbox is initialized
|
|
28
|
-
this.commFun = null;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
destroy() {
|
|
32
|
-
this.commFunc = null;
|
|
33
|
-
this.timeoutIds.forEach(([_, id]) => this.win.clearTimeout(id));
|
|
34
|
-
this.timeoutIds = null;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* @param {Object} val - Export a value in the sandbox.
|
|
39
|
-
*/
|
|
40
|
-
exportValueToSandbox(val) {
|
|
41
|
-
throw new Error("Not implemented");
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* @param {Object} val - Import a value from the sandbox.
|
|
46
|
-
*/
|
|
47
|
-
importValueFromSandbox(val) {
|
|
48
|
-
throw new Error("Not implemented");
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* @param {String} errorMessage - Create an error in the sandbox.
|
|
53
|
-
*/
|
|
54
|
-
createErrorForSandbox(errorMessage) {
|
|
55
|
-
throw new Error("Not implemented");
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* @param {String} name - Name of the function to call in the sandbox
|
|
60
|
-
* @param {Array<Object>} args - Arguments of the function.
|
|
61
|
-
*/
|
|
62
|
-
callSandboxFunction(name, args) {
|
|
63
|
-
try {
|
|
64
|
-
args = this.exportValueToSandbox(args);
|
|
65
|
-
this.commFun(name, args);
|
|
66
|
-
} catch (e) {
|
|
67
|
-
this.win.console.error(e);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
createSandboxExternals() {
|
|
72
|
-
// All the functions in externals object are called
|
|
73
|
-
// from the sandbox.
|
|
74
|
-
const externals = {
|
|
75
|
-
setTimeout: (callbackId, nMilliseconds) => {
|
|
76
|
-
if (
|
|
77
|
-
typeof callbackId !== "number" ||
|
|
78
|
-
typeof nMilliseconds !== "number"
|
|
79
|
-
) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
const id = this.win.setTimeout(() => {
|
|
83
|
-
this.timeoutIds.delete(callbackId);
|
|
84
|
-
this.callSandboxFunction("timeoutCb", {
|
|
85
|
-
callbackId,
|
|
86
|
-
interval: false,
|
|
87
|
-
});
|
|
88
|
-
}, nMilliseconds);
|
|
89
|
-
this.timeoutIds.set(callbackId, id);
|
|
90
|
-
},
|
|
91
|
-
clearTimeout: id => {
|
|
92
|
-
this.win.clearTimeout(this.timeoutIds.get(id));
|
|
93
|
-
this.timeoutIds.delete(id);
|
|
94
|
-
},
|
|
95
|
-
setInterval: (callbackId, nMilliseconds) => {
|
|
96
|
-
if (
|
|
97
|
-
typeof callbackId !== "number" ||
|
|
98
|
-
typeof nMilliseconds !== "number"
|
|
99
|
-
) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
const id = this.win.setInterval(() => {
|
|
103
|
-
this.callSandboxFunction("timeoutCb", {
|
|
104
|
-
callbackId,
|
|
105
|
-
interval: true,
|
|
106
|
-
});
|
|
107
|
-
}, nMilliseconds);
|
|
108
|
-
this.timeoutIds.set(callbackId, id);
|
|
109
|
-
},
|
|
110
|
-
clearInterval: id => {
|
|
111
|
-
this.win.clearInterval(this.timeoutIds.get(id));
|
|
112
|
-
this.timeoutIds.delete(id);
|
|
113
|
-
},
|
|
114
|
-
alert: cMsg => {
|
|
115
|
-
if (typeof cMsg !== "string") {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
this.win.alert(cMsg);
|
|
119
|
-
},
|
|
120
|
-
confirm: cMsg => {
|
|
121
|
-
if (typeof cMsg !== "string") {
|
|
122
|
-
return false;
|
|
123
|
-
}
|
|
124
|
-
return this.win.confirm(cMsg);
|
|
125
|
-
},
|
|
126
|
-
prompt: (cQuestion, cDefault) => {
|
|
127
|
-
if (typeof cQuestion !== "string" || typeof cDefault !== "string") {
|
|
128
|
-
return null;
|
|
129
|
-
}
|
|
130
|
-
return this.win.prompt(cQuestion, cDefault);
|
|
131
|
-
},
|
|
132
|
-
parseURL: cUrl => {
|
|
133
|
-
const url = new this.win.URL(cUrl);
|
|
134
|
-
const props = [
|
|
135
|
-
"hash",
|
|
136
|
-
"host",
|
|
137
|
-
"hostname",
|
|
138
|
-
"href",
|
|
139
|
-
"origin",
|
|
140
|
-
"password",
|
|
141
|
-
"pathname",
|
|
142
|
-
"port",
|
|
143
|
-
"protocol",
|
|
144
|
-
"search",
|
|
145
|
-
"searchParams",
|
|
146
|
-
"username",
|
|
147
|
-
];
|
|
148
|
-
|
|
149
|
-
return Object.fromEntries(
|
|
150
|
-
props.map(name => [name, url[name].toString()])
|
|
151
|
-
);
|
|
152
|
-
},
|
|
153
|
-
send: data => {
|
|
154
|
-
if (!data) {
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
const event = new this.win.CustomEvent("updatefromsandbox", {
|
|
158
|
-
detail: this.importValueFromSandbox(data),
|
|
159
|
-
});
|
|
160
|
-
this.win.dispatchEvent(event);
|
|
161
|
-
},
|
|
162
|
-
};
|
|
163
|
-
Object.setPrototypeOf(externals, null);
|
|
164
|
-
|
|
165
|
-
return (name, args) => {
|
|
166
|
-
try {
|
|
167
|
-
const result = externals[name](...args);
|
|
168
|
-
return this.exportValueToSandbox(result);
|
|
169
|
-
} catch (error) {
|
|
170
|
-
throw this.createErrorForSandbox(error?.toString() ?? "");
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
|
|
177
|
-
exports.SandboxSupportBase = SandboxSupportBase;
|
|
178
|
-
} else {
|
|
179
|
-
/* eslint-disable-next-line no-unused-vars, no-var */
|
|
180
|
-
var EXPORTED_SYMBOLS = ["SandboxSupportBase"];
|
|
181
|
-
}
|