@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.
Files changed (174) hide show
  1. package/README.md +1 -1
  2. package/package.json +33 -18
  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/get.js +1857 -0
  6. package/pdfjs/dist/index.js +767 -0
  7. package/pdfjs/dist/l10n_utils.js +140 -0
  8. package/{src/shared → pdfjs/dist}/message_handler.js +243 -259
  9. package/{src/display → pdfjs/dist}/network.js +149 -87
  10. package/{src/display/content_disposition.js → pdfjs/dist/network_utils.js} +167 -55
  11. package/{src/display → pdfjs/dist}/node_stream.js +133 -98
  12. package/pdfjs/dist/pdf.js +12778 -0
  13. package/pdfjs/dist/pdf_link_service.js +638 -0
  14. package/pdfjs/dist/pdf_rendering_queue.js +199 -0
  15. package/pdfjs/dist/pdf_thumbnail_viewer.js +819 -0
  16. package/pdfjs/dist/pdf_viewer.js +3598 -0
  17. package/pdfjs/dist/typeof.js +100 -0
  18. package/pdfjs/dist/ui_utils.js +1033 -0
  19. package/{src/shared → pdfjs/dist}/util.js +301 -287
  20. package/pdfjs/dist/worker.js +62813 -0
  21. package/src/vcf-pdf-viewer.js +77 -27
  22. package/theme/lumo/vcf-pdf-viewer-styles.js +1 -1
  23. package/theme/material/vcf-pdf-viewer.js +2 -2
  24. package/src/core/.eslintrc +0 -13
  25. package/src/core/annotation.js +0 -2948
  26. package/src/core/arithmetic_decoder.js +0 -182
  27. package/src/core/ascii_85_stream.js +0 -98
  28. package/src/core/ascii_hex_stream.js +0 -79
  29. package/src/core/base_stream.js +0 -110
  30. package/src/core/bidi.js +0 -438
  31. package/src/core/calibri_factors.js +0 -308
  32. package/src/core/catalog.js +0 -1459
  33. package/src/core/ccitt.js +0 -1062
  34. package/src/core/ccitt_stream.js +0 -60
  35. package/src/core/cff_font.js +0 -116
  36. package/src/core/cff_parser.js +0 -1949
  37. package/src/core/charsets.js +0 -119
  38. package/src/core/chunked_stream.js +0 -557
  39. package/src/core/cmap.js +0 -1039
  40. package/src/core/colorspace.js +0 -1533
  41. package/src/core/core_utils.js +0 -464
  42. package/src/core/crypto.js +0 -1900
  43. package/src/core/decode_stream.js +0 -170
  44. package/src/core/decrypt_stream.js +0 -59
  45. package/src/core/default_appearance.js +0 -99
  46. package/src/core/document.js +0 -1456
  47. package/src/core/encodings.js +0 -301
  48. package/src/core/evaluator.js +0 -4601
  49. package/src/core/file_spec.js +0 -108
  50. package/src/core/flate_stream.js +0 -402
  51. package/src/core/font_renderer.js +0 -882
  52. package/src/core/fonts.js +0 -3260
  53. package/src/core/fonts_utils.js +0 -221
  54. package/src/core/function.js +0 -1257
  55. package/src/core/glyf.js +0 -706
  56. package/src/core/glyphlist.js +0 -4558
  57. package/src/core/helvetica_factors.js +0 -353
  58. package/src/core/image.js +0 -802
  59. package/src/core/image_utils.js +0 -291
  60. package/src/core/jbig2.js +0 -2572
  61. package/src/core/jbig2_stream.js +0 -73
  62. package/src/core/jpeg_stream.js +0 -105
  63. package/src/core/jpg.js +0 -1416
  64. package/src/core/jpx.js +0 -2343
  65. package/src/core/jpx_stream.js +0 -87
  66. package/src/core/liberationsans_widths.js +0 -221
  67. package/src/core/lzw_stream.js +0 -150
  68. package/src/core/metadata_parser.js +0 -146
  69. package/src/core/metrics.js +0 -2970
  70. package/src/core/murmurhash3.js +0 -139
  71. package/src/core/myriadpro_factors.js +0 -290
  72. package/src/core/name_number_tree.js +0 -153
  73. package/src/core/object_loader.js +0 -149
  74. package/src/core/opentype_file_builder.js +0 -154
  75. package/src/core/operator_list.js +0 -734
  76. package/src/core/parser.js +0 -1416
  77. package/src/core/pattern.js +0 -985
  78. package/src/core/pdf_manager.js +0 -217
  79. package/src/core/predictor_stream.js +0 -238
  80. package/src/core/primitives.js +0 -402
  81. package/src/core/ps_parser.js +0 -272
  82. package/src/core/run_length_stream.js +0 -61
  83. package/src/core/segoeui_factors.js +0 -308
  84. package/src/core/standard_fonts.js +0 -817
  85. package/src/core/stream.js +0 -103
  86. package/src/core/struct_tree.js +0 -335
  87. package/src/core/to_unicode_map.js +0 -103
  88. package/src/core/type1_font.js +0 -421
  89. package/src/core/type1_parser.js +0 -776
  90. package/src/core/unicode.js +0 -1649
  91. package/src/core/worker.js +0 -848
  92. package/src/core/worker_stream.js +0 -135
  93. package/src/core/writer.js +0 -278
  94. package/src/core/xfa/bind.js +0 -652
  95. package/src/core/xfa/builder.js +0 -207
  96. package/src/core/xfa/config.js +0 -1926
  97. package/src/core/xfa/connection_set.js +0 -202
  98. package/src/core/xfa/data.js +0 -82
  99. package/src/core/xfa/datasets.js +0 -76
  100. package/src/core/xfa/factory.js +0 -111
  101. package/src/core/xfa/fonts.js +0 -181
  102. package/src/core/xfa/formcalc_lexer.js +0 -385
  103. package/src/core/xfa/formcalc_parser.js +0 -1340
  104. package/src/core/xfa/html_utils.js +0 -639
  105. package/src/core/xfa/layout.js +0 -383
  106. package/src/core/xfa/locale_set.js +0 -345
  107. package/src/core/xfa/namespaces.js +0 -81
  108. package/src/core/xfa/parser.js +0 -184
  109. package/src/core/xfa/setup.js +0 -38
  110. package/src/core/xfa/signature.js +0 -40
  111. package/src/core/xfa/som.js +0 -338
  112. package/src/core/xfa/stylesheet.js +0 -40
  113. package/src/core/xfa/template.js +0 -6260
  114. package/src/core/xfa/text.js +0 -290
  115. package/src/core/xfa/unknown.js +0 -29
  116. package/src/core/xfa/utils.js +0 -217
  117. package/src/core/xfa/xdp.js +0 -59
  118. package/src/core/xfa/xfa_object.js +0 -1130
  119. package/src/core/xfa/xhtml.js +0 -543
  120. package/src/core/xfa_fonts.js +0 -208
  121. package/src/core/xml_parser.js +0 -507
  122. package/src/core/xref.js +0 -899
  123. package/src/display/annotation_layer.js +0 -2107
  124. package/src/display/annotation_storage.js +0 -113
  125. package/src/display/api.js +0 -3292
  126. package/src/display/base_factory.js +0 -180
  127. package/src/display/canvas.js +0 -2828
  128. package/src/display/font_loader.js +0 -484
  129. package/src/display/metadata.js +0 -41
  130. package/src/display/network_utils.js +0 -100
  131. package/src/display/node_utils.js +0 -83
  132. package/src/display/optional_content_config.js +0 -189
  133. package/src/display/pattern_helper.js +0 -659
  134. package/src/display/svg.js +0 -1709
  135. package/src/display/text_layer.js +0 -847
  136. package/src/display/transport_stream.js +0 -303
  137. package/src/display/worker_options.js +0 -40
  138. package/src/display/xfa_layer.js +0 -204
  139. package/src/doc_helper.js +0 -25
  140. package/src/images/logo.svg +0 -41
  141. package/src/interfaces.js +0 -169
  142. package/src/license_header.js +0 -14
  143. package/src/license_header_libre.js +0 -21
  144. package/src/pdf.image_decoders.js +0 -46
  145. package/src/pdf.js +0 -146
  146. package/src/pdf.sandbox.external.js +0 -181
  147. package/src/pdf.sandbox.js +0 -151
  148. package/src/pdf.scripting.js +0 -25
  149. package/src/pdf.worker.entry.js +0 -19
  150. package/src/pdf.worker.js +0 -23
  151. package/src/scripting_api/aform.js +0 -608
  152. package/src/scripting_api/app.js +0 -621
  153. package/src/scripting_api/color.js +0 -129
  154. package/src/scripting_api/common.js +0 -58
  155. package/src/scripting_api/console.js +0 -38
  156. package/src/scripting_api/constants.js +0 -208
  157. package/src/scripting_api/doc.js +0 -1195
  158. package/src/scripting_api/error.js +0 -23
  159. package/src/scripting_api/event.js +0 -232
  160. package/src/scripting_api/field.js +0 -620
  161. package/src/scripting_api/fullscreen.js +0 -145
  162. package/src/scripting_api/initialization.js +0 -223
  163. package/src/scripting_api/pdf_object.js +0 -24
  164. package/src/scripting_api/print_params.js +0 -146
  165. package/src/scripting_api/proxy.js +0 -139
  166. package/src/scripting_api/thermometer.js +0 -69
  167. package/src/scripting_api/util.js +0 -581
  168. package/src/shared/.eslintrc +0 -13
  169. package/src/shared/cffStandardStrings.js +0 -311
  170. package/src/shared/compatibility.js +0 -114
  171. package/src/shared/fonts_utils.js +0 -429
  172. package/src/shared/is_node.js +0 -27
  173. package/src/shared/scripting_utils.js +0 -85
  174. package/src/worker_loader.js +0 -32
@@ -1,182 +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
- // Table C-2
17
- const QeTable = [
18
- { qe: 0x5601, nmps: 1, nlps: 1, switchFlag: 1 },
19
- { qe: 0x3401, nmps: 2, nlps: 6, switchFlag: 0 },
20
- { qe: 0x1801, nmps: 3, nlps: 9, switchFlag: 0 },
21
- { qe: 0x0ac1, nmps: 4, nlps: 12, switchFlag: 0 },
22
- { qe: 0x0521, nmps: 5, nlps: 29, switchFlag: 0 },
23
- { qe: 0x0221, nmps: 38, nlps: 33, switchFlag: 0 },
24
- { qe: 0x5601, nmps: 7, nlps: 6, switchFlag: 1 },
25
- { qe: 0x5401, nmps: 8, nlps: 14, switchFlag: 0 },
26
- { qe: 0x4801, nmps: 9, nlps: 14, switchFlag: 0 },
27
- { qe: 0x3801, nmps: 10, nlps: 14, switchFlag: 0 },
28
- { qe: 0x3001, nmps: 11, nlps: 17, switchFlag: 0 },
29
- { qe: 0x2401, nmps: 12, nlps: 18, switchFlag: 0 },
30
- { qe: 0x1c01, nmps: 13, nlps: 20, switchFlag: 0 },
31
- { qe: 0x1601, nmps: 29, nlps: 21, switchFlag: 0 },
32
- { qe: 0x5601, nmps: 15, nlps: 14, switchFlag: 1 },
33
- { qe: 0x5401, nmps: 16, nlps: 14, switchFlag: 0 },
34
- { qe: 0x5101, nmps: 17, nlps: 15, switchFlag: 0 },
35
- { qe: 0x4801, nmps: 18, nlps: 16, switchFlag: 0 },
36
- { qe: 0x3801, nmps: 19, nlps: 17, switchFlag: 0 },
37
- { qe: 0x3401, nmps: 20, nlps: 18, switchFlag: 0 },
38
- { qe: 0x3001, nmps: 21, nlps: 19, switchFlag: 0 },
39
- { qe: 0x2801, nmps: 22, nlps: 19, switchFlag: 0 },
40
- { qe: 0x2401, nmps: 23, nlps: 20, switchFlag: 0 },
41
- { qe: 0x2201, nmps: 24, nlps: 21, switchFlag: 0 },
42
- { qe: 0x1c01, nmps: 25, nlps: 22, switchFlag: 0 },
43
- { qe: 0x1801, nmps: 26, nlps: 23, switchFlag: 0 },
44
- { qe: 0x1601, nmps: 27, nlps: 24, switchFlag: 0 },
45
- { qe: 0x1401, nmps: 28, nlps: 25, switchFlag: 0 },
46
- { qe: 0x1201, nmps: 29, nlps: 26, switchFlag: 0 },
47
- { qe: 0x1101, nmps: 30, nlps: 27, switchFlag: 0 },
48
- { qe: 0x0ac1, nmps: 31, nlps: 28, switchFlag: 0 },
49
- { qe: 0x09c1, nmps: 32, nlps: 29, switchFlag: 0 },
50
- { qe: 0x08a1, nmps: 33, nlps: 30, switchFlag: 0 },
51
- { qe: 0x0521, nmps: 34, nlps: 31, switchFlag: 0 },
52
- { qe: 0x0441, nmps: 35, nlps: 32, switchFlag: 0 },
53
- { qe: 0x02a1, nmps: 36, nlps: 33, switchFlag: 0 },
54
- { qe: 0x0221, nmps: 37, nlps: 34, switchFlag: 0 },
55
- { qe: 0x0141, nmps: 38, nlps: 35, switchFlag: 0 },
56
- { qe: 0x0111, nmps: 39, nlps: 36, switchFlag: 0 },
57
- { qe: 0x0085, nmps: 40, nlps: 37, switchFlag: 0 },
58
- { qe: 0x0049, nmps: 41, nlps: 38, switchFlag: 0 },
59
- { qe: 0x0025, nmps: 42, nlps: 39, switchFlag: 0 },
60
- { qe: 0x0015, nmps: 43, nlps: 40, switchFlag: 0 },
61
- { qe: 0x0009, nmps: 44, nlps: 41, switchFlag: 0 },
62
- { qe: 0x0005, nmps: 45, nlps: 42, switchFlag: 0 },
63
- { qe: 0x0001, nmps: 45, nlps: 43, switchFlag: 0 },
64
- { qe: 0x5601, nmps: 46, nlps: 46, switchFlag: 0 },
65
- ];
66
-
67
- /**
68
- * This class implements the QM Coder decoding as defined in
69
- * JPEG 2000 Part I Final Committee Draft Version 1.0
70
- * Annex C.3 Arithmetic decoding procedure
71
- * available at http://www.jpeg.org/public/fcd15444-1.pdf
72
- *
73
- * The arithmetic decoder is used in conjunction with context models to decode
74
- * JPEG2000 and JBIG2 streams.
75
- */
76
- class ArithmeticDecoder {
77
- // C.3.5 Initialisation of the decoder (INITDEC)
78
- constructor(data, start, end) {
79
- this.data = data;
80
- this.bp = start;
81
- this.dataEnd = end;
82
-
83
- this.chigh = data[start];
84
- this.clow = 0;
85
-
86
- this.byteIn();
87
-
88
- this.chigh = ((this.chigh << 7) & 0xffff) | ((this.clow >> 9) & 0x7f);
89
- this.clow = (this.clow << 7) & 0xffff;
90
- this.ct -= 7;
91
- this.a = 0x8000;
92
- }
93
-
94
- // C.3.4 Compressed data input (BYTEIN)
95
- byteIn() {
96
- const data = this.data;
97
- let bp = this.bp;
98
-
99
- if (data[bp] === 0xff) {
100
- if (data[bp + 1] > 0x8f) {
101
- this.clow += 0xff00;
102
- this.ct = 8;
103
- } else {
104
- bp++;
105
- this.clow += data[bp] << 9;
106
- this.ct = 7;
107
- this.bp = bp;
108
- }
109
- } else {
110
- bp++;
111
- this.clow += bp < this.dataEnd ? data[bp] << 8 : 0xff00;
112
- this.ct = 8;
113
- this.bp = bp;
114
- }
115
- if (this.clow > 0xffff) {
116
- this.chigh += this.clow >> 16;
117
- this.clow &= 0xffff;
118
- }
119
- }
120
-
121
- // C.3.2 Decoding a decision (DECODE)
122
- readBit(contexts, pos) {
123
- // Contexts are packed into 1 byte:
124
- // highest 7 bits carry cx.index, lowest bit carries cx.mps
125
- let cx_index = contexts[pos] >> 1,
126
- cx_mps = contexts[pos] & 1;
127
- const qeTableIcx = QeTable[cx_index];
128
- const qeIcx = qeTableIcx.qe;
129
- let d;
130
- let a = this.a - qeIcx;
131
-
132
- if (this.chigh < qeIcx) {
133
- // exchangeLps
134
- if (a < qeIcx) {
135
- a = qeIcx;
136
- d = cx_mps;
137
- cx_index = qeTableIcx.nmps;
138
- } else {
139
- a = qeIcx;
140
- d = 1 ^ cx_mps;
141
- if (qeTableIcx.switchFlag === 1) {
142
- cx_mps = d;
143
- }
144
- cx_index = qeTableIcx.nlps;
145
- }
146
- } else {
147
- this.chigh -= qeIcx;
148
- if ((a & 0x8000) !== 0) {
149
- this.a = a;
150
- return cx_mps;
151
- }
152
- // exchangeMps
153
- if (a < qeIcx) {
154
- d = 1 ^ cx_mps;
155
- if (qeTableIcx.switchFlag === 1) {
156
- cx_mps = d;
157
- }
158
- cx_index = qeTableIcx.nlps;
159
- } else {
160
- d = cx_mps;
161
- cx_index = qeTableIcx.nmps;
162
- }
163
- }
164
- // C.3.3 renormD;
165
- do {
166
- if (this.ct === 0) {
167
- this.byteIn();
168
- }
169
-
170
- a <<= 1;
171
- this.chigh = ((this.chigh << 1) & 0xffff) | ((this.clow >> 15) & 1);
172
- this.clow = (this.clow << 1) & 0xffff;
173
- this.ct--;
174
- } while ((a & 0x8000) === 0);
175
- this.a = a;
176
-
177
- contexts[pos] = (cx_index << 1) | cx_mps;
178
- return d;
179
- }
180
- }
181
-
182
- export { ArithmeticDecoder };
@@ -1,98 +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 { DecodeStream } from "./decode_stream.js";
17
- import { isWhiteSpace } from "./core_utils.js";
18
-
19
- class Ascii85Stream extends DecodeStream {
20
- constructor(str, maybeLength) {
21
- // Most streams increase in size when decoded, but Ascii85 streams
22
- // typically shrink by ~20%.
23
- if (maybeLength) {
24
- maybeLength *= 0.8;
25
- }
26
- super(maybeLength);
27
-
28
- this.str = str;
29
- this.dict = str.dict;
30
- this.input = new Uint8Array(5);
31
- }
32
-
33
- readBlock() {
34
- const TILDA_CHAR = 0x7e; // '~'
35
- const Z_LOWER_CHAR = 0x7a; // 'z'
36
- const EOF = -1;
37
-
38
- const str = this.str;
39
-
40
- let c = str.getByte();
41
- while (isWhiteSpace(c)) {
42
- c = str.getByte();
43
- }
44
-
45
- if (c === EOF || c === TILDA_CHAR) {
46
- this.eof = true;
47
- return;
48
- }
49
-
50
- const bufferLength = this.bufferLength;
51
- let buffer, i;
52
-
53
- // special code for z
54
- if (c === Z_LOWER_CHAR) {
55
- buffer = this.ensureBuffer(bufferLength + 4);
56
- for (i = 0; i < 4; ++i) {
57
- buffer[bufferLength + i] = 0;
58
- }
59
- this.bufferLength += 4;
60
- } else {
61
- const input = this.input;
62
- input[0] = c;
63
- for (i = 1; i < 5; ++i) {
64
- c = str.getByte();
65
- while (isWhiteSpace(c)) {
66
- c = str.getByte();
67
- }
68
-
69
- input[i] = c;
70
-
71
- if (c === EOF || c === TILDA_CHAR) {
72
- break;
73
- }
74
- }
75
- buffer = this.ensureBuffer(bufferLength + i - 1);
76
- this.bufferLength += i - 1;
77
-
78
- // partial ending;
79
- if (i < 5) {
80
- for (; i < 5; ++i) {
81
- input[i] = 0x21 + 84;
82
- }
83
- this.eof = true;
84
- }
85
- let t = 0;
86
- for (i = 0; i < 5; ++i) {
87
- t = t * 85 + (input[i] - 0x21);
88
- }
89
-
90
- for (i = 3; i >= 0; --i) {
91
- buffer[bufferLength + i] = t & 0xff;
92
- t >>= 8;
93
- }
94
- }
95
- }
96
- }
97
-
98
- export { Ascii85Stream };
@@ -1,79 +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 { DecodeStream } from "./decode_stream.js";
17
-
18
- class AsciiHexStream extends DecodeStream {
19
- constructor(str, maybeLength) {
20
- // Most streams increase in size when decoded, but AsciiHex streams shrink
21
- // by 50%.
22
- if (maybeLength) {
23
- maybeLength *= 0.5;
24
- }
25
- super(maybeLength);
26
-
27
- this.str = str;
28
- this.dict = str.dict;
29
-
30
- this.firstDigit = -1;
31
- }
32
-
33
- readBlock() {
34
- const UPSTREAM_BLOCK_SIZE = 8000;
35
- const bytes = this.str.getBytes(UPSTREAM_BLOCK_SIZE);
36
- if (!bytes.length) {
37
- this.eof = true;
38
- return;
39
- }
40
-
41
- const maxDecodeLength = (bytes.length + 1) >> 1;
42
- const buffer = this.ensureBuffer(this.bufferLength + maxDecodeLength);
43
- let bufferLength = this.bufferLength;
44
-
45
- let firstDigit = this.firstDigit;
46
- for (const ch of bytes) {
47
- let digit;
48
- if (ch >= /* '0' = */ 0x30 && ch <= /* '9' = */ 0x39) {
49
- digit = ch & 0x0f;
50
- } else if (
51
- (ch >= /* 'A' = */ 0x41 && ch <= /* 'Z' = */ 0x46) ||
52
- (ch >= /* 'a' = */ 0x61 && ch <= /* 'z' = */ 0x66)
53
- ) {
54
- digit = (ch & 0x0f) + 9;
55
- } else if (ch === /* '>' = */ 0x3e) {
56
- this.eof = true;
57
- break;
58
- } else {
59
- // Probably whitespace, ignoring.
60
- continue;
61
- }
62
- if (firstDigit < 0) {
63
- firstDigit = digit;
64
- } else {
65
- buffer[bufferLength++] = (firstDigit << 4) | digit;
66
- firstDigit = -1;
67
- }
68
- }
69
- if (firstDigit >= 0 && this.eof) {
70
- // incomplete byte
71
- buffer[bufferLength++] = firstDigit << 4;
72
- firstDigit = -1;
73
- }
74
- this.firstDigit = firstDigit;
75
- this.bufferLength = bufferLength;
76
- }
77
- }
78
-
79
- export { AsciiHexStream };
@@ -1,110 +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 { bytesToString, shadow, unreachable } from "../shared/util.js";
17
-
18
- class BaseStream {
19
- constructor() {
20
- if (this.constructor === BaseStream) {
21
- unreachable("Cannot initialize BaseStream.");
22
- }
23
- }
24
-
25
- // eslint-disable-next-line getter-return
26
- get length() {
27
- unreachable("Abstract getter `length` accessed");
28
- }
29
-
30
- // eslint-disable-next-line getter-return
31
- get isEmpty() {
32
- unreachable("Abstract getter `isEmpty` accessed");
33
- }
34
-
35
- get isDataLoaded() {
36
- return shadow(this, "isDataLoaded", true);
37
- }
38
-
39
- getByte() {
40
- unreachable("Abstract method `getByte` called");
41
- }
42
-
43
- getBytes(length, forceClamped = false) {
44
- unreachable("Abstract method `getBytes` called");
45
- }
46
-
47
- peekByte() {
48
- const peekedByte = this.getByte();
49
- if (peekedByte !== -1) {
50
- this.pos--;
51
- }
52
- return peekedByte;
53
- }
54
-
55
- peekBytes(length, forceClamped = false) {
56
- const bytes = this.getBytes(length, forceClamped);
57
- this.pos -= bytes.length;
58
- return bytes;
59
- }
60
-
61
- getUint16() {
62
- const b0 = this.getByte();
63
- const b1 = this.getByte();
64
- if (b0 === -1 || b1 === -1) {
65
- return -1;
66
- }
67
- return (b0 << 8) + b1;
68
- }
69
-
70
- getInt32() {
71
- const b0 = this.getByte();
72
- const b1 = this.getByte();
73
- const b2 = this.getByte();
74
- const b3 = this.getByte();
75
- return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
76
- }
77
-
78
- getByteRange(begin, end) {
79
- unreachable("Abstract method `getByteRange` called");
80
- }
81
-
82
- getString(length) {
83
- return bytesToString(this.getBytes(length, /* forceClamped = */ false));
84
- }
85
-
86
- skip(n) {
87
- this.pos += n || 1;
88
- }
89
-
90
- reset() {
91
- unreachable("Abstract method `reset` called");
92
- }
93
-
94
- moveStart() {
95
- unreachable("Abstract method `moveStart` called");
96
- }
97
-
98
- makeSubStream(start, length, dict = null) {
99
- unreachable("Abstract method `makeSubStream` called");
100
- }
101
-
102
- /**
103
- * @returns {Array | null}
104
- */
105
- getBaseStreams() {
106
- return null;
107
- }
108
- }
109
-
110
- export { BaseStream };