@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,429 +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
- /* globals CFFDictDataMap, CFFDictPrivateDataMap, CFFEncodingMap, CFFStrings,
16
- Components, Dict, dump, FormatError, isNum, netscape, Stream */
17
-
18
- 'use strict';
19
-
20
- /*
21
- * The Type2 reader code below is only used for debugging purpose since Type2
22
- * is only a CharString format and is never used directly as a Font file.
23
- *
24
- * So the code here is useful for dumping the data content of a .cff file in
25
- * order to investigate the similarity between a Type1 CharString and a Type2
26
- * CharString or to understand the structure of the CFF format.
27
- */
28
-
29
- /*
30
- * Build a charset by assigning the glyph name and the human readable form
31
- * of the glyph data.
32
- */
33
- function readCharset(aStream, aCharstrings) {
34
- var charset = {};
35
-
36
- var format = aStream.getByte();
37
- var count = aCharstrings.length - 1;
38
- var i, sid;
39
- if (format === 0) {
40
- charset['.notdef'] = readCharstringEncoding(aCharstrings[0]);
41
-
42
- for (i = 1; i < count + 1; i++) {
43
- sid = aStream.getByte() << 8 | aStream.getByte();
44
- charset[CFFStrings[sid]] = readCharstringEncoding(aCharstrings[i]);
45
- }
46
- } else if (format === 1) {
47
- for (i = 1; i < count + 1; i++) {
48
- var first = aStream.getByte();
49
- first = (first << 8) | aStream.getByte();
50
- var numLeft = aStream.getByte();
51
- for (var j = 0; j <= numLeft; j++) {
52
- sid = first++;
53
- charset[CFFStrings[sid]] = readCharstringEncoding(aCharstrings[j]);
54
- }
55
- }
56
- } else {
57
- throw new FormatError('Invalid charset format');
58
- }
59
-
60
- return charset;
61
- }
62
-
63
- /*
64
- * Take a Type2 binary charstring as input and transform it to a human
65
- * readable representation as specified by the 'The Type 2 Charstring Format',
66
- * chapter 3.1.
67
- */
68
- function readCharstringEncoding(aString) {
69
- if (!aString) {
70
- return '';
71
- }
72
-
73
- var charstringTokens = [];
74
-
75
- var count = aString.length;
76
- for (var i = 0; i < count; ) {
77
- var value = aString[i++] | 0;
78
- var token = null;
79
-
80
- if (value < 0) {
81
- continue;
82
- } else if (value <= 11) {
83
- token = CFFEncodingMap[value];
84
- } else if (value === 12) {
85
- token = CFFEncodingMap[value][aString[i++]];
86
- } else if (value <= 18) {
87
- token = CFFEncodingMap[value];
88
- } else if (value <= 20) {
89
- ++i; // var mask = aString[i++];
90
- token = CFFEncodingMap[value];
91
- } else if (value <= 27) {
92
- token = CFFEncodingMap[value];
93
- } else if (value === 28) {
94
- token = aString[i++] << 8 | aString[i++];
95
- } else if (value <= 31) {
96
- token = CFFEncodingMap[value];
97
- } else if (value < 247) {
98
- token = parseInt(value, 10) - 139;
99
- } else if (value < 251) {
100
- token = (value - 247) * 256 + aString[i++] + 108;
101
- } else if (value < 255) {
102
- token = -(value - 251) * 256 - aString[i++] - 108;
103
- } else { // value === 255
104
- token = aString[i++] << 24 | aString[i++] << 16 |
105
- aString[i++] << 8 | aString[i];
106
- }
107
-
108
- charstringTokens.push(token);
109
- }
110
-
111
- return charstringTokens;
112
- }
113
-
114
-
115
- /*
116
- * Take a binary DICT Data as input and transform it into a human readable
117
- * form as specified by 'The Compact Font Format Specification', chapter 5.
118
- */
119
- function readFontDictData(aString, aMap) {
120
- var fontDictDataTokens = [];
121
-
122
- var count = aString.length;
123
- for (var i = 0; i < count; ) {
124
- var value = aString[i++] | 0;
125
- var token = null;
126
-
127
- if (value === 12) {
128
- token = aMap[value][aString[i++]];
129
- } else if (value === 28) {
130
- token = aString[i++] << 8 | aString[i++];
131
- } else if (value === 29) {
132
- token = aString[i++] << 24 |
133
- aString[i++] << 16 |
134
- aString[i++] << 8 |
135
- aString[i++];
136
- } else if (value === 30) {
137
- token = '';
138
- var parsed = false;
139
- while (!parsed) {
140
- var octet = aString[i++];
141
-
142
- var nibbles = [parseInt(octet / 16, 10), parseInt(octet % 16, 10)];
143
- for (var j = 0; j < nibbles.length; j++) {
144
- var nibble = nibbles[j];
145
- switch (nibble) {
146
- case 0xA:
147
- token += '.';
148
- break;
149
- case 0xB:
150
- token += 'E';
151
- break;
152
- case 0xC:
153
- token += 'E-';
154
- break;
155
- case 0xD:
156
- break;
157
- case 0xE:
158
- token += '-';
159
- break;
160
- case 0xF:
161
- parsed = true;
162
- break;
163
- default:
164
- token += nibble;
165
- break;
166
- }
167
- }
168
- }
169
- token = parseFloat(token);
170
- } else if (value <= 31) {
171
- token = aMap[value];
172
- } else if (value <= 246) {
173
- token = parseInt(value, 10) - 139;
174
- } else if (value <= 250) {
175
- token = (value - 247) * 256 + aString[i++] + 108;
176
- } else if (value <= 254) {
177
- token = -(value - 251) * 256 - aString[i++] - 108;
178
- } else if (value === 255) {
179
- throw new FormatError('255 is not a valid DICT command');
180
- }
181
-
182
- fontDictDataTokens.push(token);
183
- }
184
-
185
- return fontDictDataTokens;
186
- }
187
-
188
- /*
189
- * Take a stream as input and return an array of objects.
190
- * In CFF an INDEX is a structure with the following format:
191
- * {
192
- * count: 2 bytes (Number of objects stored in INDEX),
193
- * offsize: 1 byte (Offset array element size),
194
- * offset: [count + 1] bytes (Offsets array),
195
- * data: - (Objects data)
196
- * }
197
- *
198
- * More explanation are given in the 'CFF Font Format Specification',
199
- * chapter 5.
200
- */
201
- function readFontIndexData(aStream, aIsByte) {
202
- var count = aStream.getByte() << 8 | aStream.getByte();
203
- var offsize = aStream.getByte();
204
-
205
- function getNextOffset() {
206
- switch (offsize) {
207
- case 0:
208
- return 0;
209
- case 1:
210
- return aStream.getByte();
211
- case 2:
212
- return aStream.getByte() << 8 | aStream.getByte();
213
- case 3:
214
- return aStream.getByte() << 16 | aStream.getByte() << 8 |
215
- aStream.getByte();
216
- case 4:
217
- return aStream.getByte() << 24 | aStream.getByte() << 16 |
218
- aStream.getByte() << 8 | aStream.getByte();
219
- }
220
- throw new FormatError(offsize + ' is not a valid offset size');
221
- }
222
-
223
- var offsets = [];
224
- var i;
225
- for (i = 0; i < count + 1; i++) {
226
- offsets.push(getNextOffset());
227
- }
228
-
229
- dump('Found ' + count + ' objects at offsets :' +
230
- offsets + ' (offsize: ' + offsize + ')');
231
-
232
- // Now extract the objects
233
- var relativeOffset = aStream.pos;
234
- var objects = [];
235
- for (i = 0; i < count; i++) {
236
- var offset = offsets[i];
237
- aStream.pos = relativeOffset + offset - 1;
238
-
239
- var data = [];
240
- var length = offsets[i + 1] - 1;
241
- for (var j = offset - 1; j < length; j++) {
242
- data.push(aIsByte ? aStream.getByte() : aStream.getChar());
243
- }
244
- objects.push(data);
245
- }
246
-
247
- return objects;
248
- }
249
-
250
- var Type2Parser = function type2Parser(aFilePath) {
251
- var font = new Dict(null);
252
-
253
- var xhr = new XMLHttpRequest();
254
- xhr.open('GET', aFilePath, false);
255
- xhr.responseType = 'arraybuffer';
256
- xhr.expected = document.URL.startsWith('file:') ? 0 : 200;
257
- xhr.send(null);
258
- this.data = new Stream(xhr.response);
259
-
260
- // Turn on this flag for additional debugging logs
261
- var debug = false;
262
-
263
- function dump(aStr) {
264
- if (debug) {
265
- console.log(aStr);
266
- }
267
- }
268
-
269
- function parseAsToken(aString, aMap) {
270
- var decoded = readFontDictData(aString, aMap);
271
-
272
- var stack = [];
273
- var count = decoded.length;
274
- for (var i = 0; i < count; i++) {
275
- var token = decoded[i];
276
- if (isNum(token)) {
277
- stack.push(token);
278
- } else {
279
- switch (token.operand) {
280
- case 'SID':
281
- font.set(token.name, CFFStrings[stack.pop()]);
282
- break;
283
- case 'number number':
284
- font.set(token.name, {
285
- offset: stack.pop(),
286
- size: stack.pop()
287
- });
288
- break;
289
- case 'boolean':
290
- font.set(token.name, stack.pop());
291
- break;
292
- case 'delta':
293
- font.set(token.name, stack.pop());
294
- break;
295
- default:
296
- if (token.operand && token.operand.length) {
297
- var array = [];
298
- for (var j = 0; j < token.operand.length; j++) {
299
- array.push(stack.pop());
300
- }
301
- font.set(token.name, array);
302
- } else {
303
- font.set(token.name, stack.pop());
304
- }
305
- break;
306
- }
307
- }
308
- }
309
- }
310
-
311
- this.parse = function type2ParserParse(aStream) {
312
- font.set('major', aStream.getByte());
313
- font.set('minor', aStream.getByte());
314
- font.set('hdrSize', aStream.getByte());
315
- font.set('offsize', aStream.getByte());
316
-
317
- // Read the NAME Index
318
- dump('Reading Index: Names');
319
- font.set('Names', readFontIndexData(aStream));
320
- dump('Names: ' + font.get('Names'));
321
-
322
- // Read the Top Dict Index
323
- dump('Reading Index: TopDict');
324
- var topDict = readFontIndexData(aStream, true);
325
- dump('TopDict: ' + topDict);
326
-
327
- // Read the String Index
328
- dump('Reading Index: Strings');
329
- var strings = readFontIndexData(aStream);
330
- dump('strings: ' + strings);
331
-
332
- // Fill up the Strings dictionary with the new unique strings
333
- var i;
334
- for (i = 0; i < strings.length; i++) {
335
- CFFStrings.push(strings[i].join(''));
336
- }
337
-
338
- // Parse the TopDict operator
339
- var count = topDict.length;
340
- for (i = 0; i < count; i++) {
341
- parseAsToken(topDict[i], CFFDictDataMap);
342
- }
343
-
344
- // Read the Global Subr Index that comes just after the Strings Index
345
- // (cf. "The Compact Font Format Specification" Chapter 16)
346
- dump('Reading Global Subr Index');
347
- var subrs = readFontIndexData(aStream, true);
348
- dump(subrs);
349
-
350
- // Reading Private Dict
351
- var priv = font.get('Private');
352
- dump('Reading Private Dict (offset: ' + priv.offset +
353
- ' size: ' + priv.size + ')');
354
- aStream.pos = priv.offset;
355
-
356
- var privateDict = [];
357
- for (i = 0; i < priv.size; i++) {
358
- privateDict.push(aStream.getByte());
359
- }
360
- dump('privateData:' + privateDict);
361
- parseAsToken(privateDict, CFFDictPrivateDataMap);
362
-
363
- font.forEach(function(key, value) {
364
- dump(key + '::' + value);
365
- });
366
-
367
- // Read CharStrings Index
368
- var charStringsOffset = font.get('CharStrings');
369
- dump('Read CharStrings Index (offset: ' + charStringsOffset + ')');
370
- aStream.pos = charStringsOffset;
371
- var charStrings = readFontIndexData(aStream, true);
372
-
373
- // Read Charset
374
- dump('Read Charset for ' + charStrings.length + ' glyphs');
375
- var charsetEntry = font.get('charset');
376
- if (charsetEntry === 0) {
377
- throw new FormatError('Need to support CFFISOAdobeCharset');
378
- } else if (charsetEntry === 1) {
379
- throw new FormatError('Need to support CFFExpert');
380
- } else if (charsetEntry === 2) {
381
- throw new FormatError('Need to support CFFExpertSubsetCharset');
382
- } else {
383
- aStream.pos = charsetEntry;
384
- readCharset(aStream, charStrings);
385
- }
386
- };
387
- };
388
-
389
- /*
390
- * To try the Type2 decoder on a local file in the current directory:
391
- *
392
- * var cff = new Type2Parser("file.cff");
393
- * cff.parse(this.data);
394
- *
395
- * To try the Type2 decoder on a custom built CFF array:
396
- *
397
- * var file = new Uint8Array(cffFileArray, 0, cffFileSize);
398
- * var parser = new Type2Parser();
399
- * parser.parse(new Stream(file));
400
- */
401
-
402
- /*
403
- * Write to a file to the disk (works only on Firefox in privilege mode)
404
- * but this is useful for dumping a font file to the disk and check with
405
- * fontforge or the ots program what's wrong with the file.
406
- *
407
- * writeToFile(fontData, "/tmp/pdf.js." + fontCount + ".cff");
408
- */
409
- function writeToFile(aBytes, aFilePath) {
410
- if (!('netscape' in window)) {
411
- return;
412
- }
413
-
414
- netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
415
- var Cc = Components.classes,
416
- Ci = Components.interfaces;
417
- var file = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsILocalFile);
418
- file.initWithPath(aFilePath);
419
-
420
- var stream = Cc['@mozilla.org/network/file-output-stream;1']
421
- .createInstance(Ci.nsIFileOutputStream);
422
- stream.init(file, 0x04 | 0x08 | 0x20, 0x180, 0);
423
-
424
- var bos = Cc['@mozilla.org/binaryoutputstream;1']
425
- .createInstance(Ci.nsIBinaryOutputStream);
426
- bos.setOutputStream(stream);
427
- bos.writeByteArray(aBytes, aBytes.length);
428
- stream.close();
429
- }
@@ -1,27 +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
- /* globals process */
16
-
17
- // NW.js / Electron is a browser context, but copies some Node.js objects; see
18
- // http://docs.nwjs.io/en/latest/For%20Users/Advanced/JavaScript%20Contexts%20in%20NW.js/#access-nodejs-and-nwjs-api-in-browser-context
19
- // https://www.electronjs.org/docs/api/process#processversionselectron-readonly
20
- // https://www.electronjs.org/docs/api/process#processtype-readonly
21
- const isNodeJS =
22
- typeof process === "object" &&
23
- process + "" === "[object process]" &&
24
- !process.versions.nw &&
25
- !(process.versions.electron && process.type && process.type !== "browser");
26
-
27
- export { isNodeJS };
@@ -1,85 +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
- /**
17
- * PLEASE NOTE: This file is currently imported in both the `../display/` and
18
- * `../scripting_api/` folders, hence be EXTREMELY careful about
19
- * introducing any dependencies here since that can lead to an
20
- * unexpected/unnecessary size increase of the *built* files.
21
- */
22
-
23
- function makeColorComp(n) {
24
- return Math.floor(Math.max(0, Math.min(1, n)) * 255)
25
- .toString(16)
26
- .padStart(2, "0");
27
- }
28
-
29
- // PDF specifications section 10.3
30
- class ColorConverters {
31
- static CMYK_G([c, y, m, k]) {
32
- return ["G", 1 - Math.min(1, 0.3 * c + 0.59 * m + 0.11 * y + k)];
33
- }
34
-
35
- static G_CMYK([g]) {
36
- return ["CMYK", 0, 0, 0, 1 - g];
37
- }
38
-
39
- static G_RGB([g]) {
40
- return ["RGB", g, g, g];
41
- }
42
-
43
- static G_HTML([g]) {
44
- const G = makeColorComp(g);
45
- return `#${G}${G}${G}`;
46
- }
47
-
48
- static RGB_G([r, g, b]) {
49
- return ["G", 0.3 * r + 0.59 * g + 0.11 * b];
50
- }
51
-
52
- static RGB_HTML([r, g, b]) {
53
- const R = makeColorComp(r);
54
- const G = makeColorComp(g);
55
- const B = makeColorComp(b);
56
- return `#${R}${G}${B}`;
57
- }
58
-
59
- static T_HTML() {
60
- return "#00000000";
61
- }
62
-
63
- static CMYK_RGB([c, y, m, k]) {
64
- return [
65
- "RGB",
66
- 1 - Math.min(1, c + k),
67
- 1 - Math.min(1, m + k),
68
- 1 - Math.min(1, y + k),
69
- ];
70
- }
71
-
72
- static CMYK_HTML(components) {
73
- return this.RGB_HTML(this.CMYK_RGB(components));
74
- }
75
-
76
- static RGB_CMYK([r, g, b]) {
77
- const c = 1 - r;
78
- const m = 1 - g;
79
- const y = 1 - b;
80
- const k = Math.min(c, m, y);
81
- return ["CMYK", c, m, y, k];
82
- }
83
- }
84
-
85
- export { ColorConverters };
@@ -1,32 +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
- "use strict";
17
-
18
- // Patch importScripts to work around a bug in WebKit and Chrome 48-.
19
- // See https://crbug.com/572225 and https://webkit.org/b/153317.
20
- self.importScripts = (function (importScripts) {
21
- return function () {
22
- setTimeout(function () {}, 0);
23
- return importScripts.apply(this, arguments);
24
- };
25
- })(importScripts);
26
-
27
- importScripts("../node_modules/systemjs/dist/system.js");
28
- importScripts("../systemjs.config.js");
29
-
30
- SystemJS.import("./core/worker.js").then(function () {
31
- // Worker is loaded at this point.
32
- });