@file-viewer/core 2.0.11 → 2.1.1

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 (116) hide show
  1. package/README.en.md +2 -2
  2. package/README.md +2 -2
  3. package/dist/config/options.d.ts +1 -1
  4. package/dist/config/options.js +1 -1
  5. package/dist/contracts/types.d.ts +76 -1
  6. package/dist/headless.d.ts +3 -3
  7. package/dist/headless.js +2 -2
  8. package/dist/index.d.ts +10 -7
  9. package/dist/index.js +106 -49
  10. package/dist/lifecycle/operations.d.ts +1 -0
  11. package/dist/lifecycle/operations.js +65 -6
  12. package/dist/platform/assets.d.ts +3 -1
  13. package/dist/platform/assets.js +43 -6
  14. package/dist/registry/capabilities.d.ts +2 -2
  15. package/dist/registry/capabilities.js +2 -1
  16. package/dist/registry/formats.d.ts +20 -7
  17. package/dist/registry/formats.js +14 -5
  18. package/dist/registry/registry.d.ts +8 -1
  19. package/dist/registry/registry.js +29 -0
  20. package/dist/renderers/image.js +1 -10
  21. package/dist/renderers/index.d.ts +320 -2
  22. package/dist/renderers/index.js +27 -157
  23. package/dist/viewer/createViewer.js +86 -3
  24. package/package.json +17 -44
  25. package/dist/renderers/archive.d.ts +0 -2
  26. package/dist/renderers/archive.js +0 -547
  27. package/dist/renderers/archiveCache.d.ts +0 -10
  28. package/dist/renderers/archiveCache.js +0 -96
  29. package/dist/renderers/archiveFallback.d.ts +0 -7
  30. package/dist/renderers/archiveFallback.js +0 -166
  31. package/dist/renderers/archiveShared.d.ts +0 -23
  32. package/dist/renderers/archiveShared.js +0 -71
  33. package/dist/renderers/audio.d.ts +0 -8
  34. package/dist/renderers/audio.js +0 -219
  35. package/dist/renderers/cad.d.ts +0 -2
  36. package/dist/renderers/cad.js +0 -446
  37. package/dist/renderers/code.d.ts +0 -11
  38. package/dist/renderers/code.js +0 -233
  39. package/dist/renderers/data.d.ts +0 -7
  40. package/dist/renderers/data.js +0 -370
  41. package/dist/renderers/drawing.d.ts +0 -10
  42. package/dist/renderers/drawing.js +0 -882
  43. package/dist/renderers/eda.d.ts +0 -2
  44. package/dist/renderers/eda.js +0 -434
  45. package/dist/renderers/edaParser.d.ts +0 -77
  46. package/dist/renderers/edaParser.js +0 -569
  47. package/dist/renderers/email.d.ts +0 -2
  48. package/dist/renderers/email.js +0 -463
  49. package/dist/renderers/epub.d.ts +0 -2
  50. package/dist/renderers/epub.js +0 -331
  51. package/dist/renderers/geo.d.ts +0 -2
  52. package/dist/renderers/geo.js +0 -284
  53. package/dist/renderers/markdown.d.ts +0 -2
  54. package/dist/renderers/markdown.js +0 -83
  55. package/dist/renderers/model.d.ts +0 -2
  56. package/dist/renderers/model.js +0 -567
  57. package/dist/renderers/ofd.d.ts +0 -2
  58. package/dist/renderers/ofd.js +0 -256
  59. package/dist/renderers/openDocument.d.ts +0 -2
  60. package/dist/renderers/openDocument.js +0 -122
  61. package/dist/renderers/pdf.d.ts +0 -3
  62. package/dist/renderers/pdf.js +0 -1001
  63. package/dist/renderers/pdfStyles.d.ts +0 -1
  64. package/dist/renderers/pdfStyles.js +0 -1
  65. package/dist/renderers/pptx.d.ts +0 -2
  66. package/dist/renderers/pptx.js +0 -217
  67. package/dist/renderers/spreadsheet/state.d.ts +0 -80
  68. package/dist/renderers/spreadsheet/state.js +0 -96
  69. package/dist/renderers/spreadsheet/view.d.ts +0 -25
  70. package/dist/renderers/spreadsheet/view.js +0 -833
  71. package/dist/renderers/spreadsheet/worker/index.d.ts +0 -2
  72. package/dist/renderers/spreadsheet/worker/index.js +0 -1
  73. package/dist/renderers/spreadsheet/worker/sheetjs/SheetJsModel.d.ts +0 -73
  74. package/dist/renderers/spreadsheet/worker/sheetjs/SheetJsModel.js +0 -623
  75. package/dist/renderers/spreadsheet/worker/sheetjs/color.d.ts +0 -2
  76. package/dist/renderers/spreadsheet/worker/sheetjs/color.js +0 -73
  77. package/dist/renderers/spreadsheet/worker/sheetjs/index.d.ts +0 -1
  78. package/dist/renderers/spreadsheet/worker/sheetjs/index.js +0 -1
  79. package/dist/renderers/spreadsheet/worker/sheetjs/parser.d.ts +0 -18
  80. package/dist/renderers/spreadsheet/worker/sheetjs/parser.js +0 -106
  81. package/dist/renderers/spreadsheet/worker/sheetjs/sheet.worker.d.ts +0 -1
  82. package/dist/renderers/spreadsheet/worker/sheetjs/sheet.worker.js +0 -11
  83. package/dist/renderers/spreadsheet/worker/type.d.ts +0 -57
  84. package/dist/renderers/spreadsheet/worker/type.js +0 -1
  85. package/dist/renderers/spreadsheet.d.ts +0 -3
  86. package/dist/renderers/spreadsheet.js +0 -929
  87. package/dist/renderers/typst.d.ts +0 -8
  88. package/dist/renderers/typst.js +0 -547
  89. package/dist/renderers/umd/parser.d.ts +0 -30
  90. package/dist/renderers/umd/parser.js +0 -408
  91. package/dist/renderers/umd.d.ts +0 -2
  92. package/dist/renderers/umd.js +0 -297
  93. package/dist/renderers/video.d.ts +0 -8
  94. package/dist/renderers/video.js +0 -108
  95. package/dist/renderers/wordDoc.d.ts +0 -5
  96. package/dist/renderers/wordDoc.js +0 -284
  97. package/dist/renderers/wordDocx.d.ts +0 -5
  98. package/dist/renderers/wordDocx.js +0 -985
  99. package/dist/renderers/wordDocx.worker.d.ts +0 -1
  100. package/dist/renderers/wordDocx.worker.js +0 -96
  101. package/vendor/ofd/dltech/jbig2/arithmetic_decoder.js +0 -183
  102. package/vendor/ofd/dltech/jbig2/ccitt.js +0 -1070
  103. package/vendor/ofd/dltech/jbig2/compatibility.js +0 -12
  104. package/vendor/ofd/dltech/jbig2/core_utils.js +0 -180
  105. package/vendor/ofd/dltech/jbig2/is_node.js +0 -27
  106. package/vendor/ofd/dltech/jbig2/jbig2.js +0 -2589
  107. package/vendor/ofd/dltech/jbig2/jbig2_stream.js +0 -81
  108. package/vendor/ofd/dltech/jbig2/primitives.js +0 -387
  109. package/vendor/ofd/dltech/jbig2/stream.js +0 -1348
  110. package/vendor/ofd/dltech/jbig2/util.js +0 -972
  111. package/vendor/ofd/dltech/ofd/ofd.d.ts +0 -11
  112. package/vendor/ofd/dltech/ofd/ofd.js +0 -100
  113. package/vendor/ofd/dltech/ofd/ofd_parser.js +0 -395
  114. package/vendor/ofd/dltech/ofd/ofd_render.js +0 -473
  115. package/vendor/ofd/dltech/ofd/ofd_util.js +0 -350
  116. package/vendor/ofd/dltech/ofd/pipeline.js +0 -26
@@ -1,81 +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 { isDict, isStream } from "./primitives.js";
17
- import { DecodeStream } from "./stream.js";
18
- import { Jbig2Image } from "./jbig2.js";
19
- import { shadow } from "./util.js";
20
-
21
- /**
22
- * For JBIG2's we use a library to decode these images and
23
- * the stream behaves like all the other DecodeStreams.
24
- */
25
- const Jbig2Stream = (function Jbig2StreamClosure() {
26
- // eslint-disable-next-line no-shadow
27
- function Jbig2Stream(stream, maybeLength, dict, params) {
28
- this.stream = stream;
29
- this.maybeLength = maybeLength;
30
- this.dict = dict;
31
- this.params = params;
32
-
33
- DecodeStream.call(this, maybeLength);
34
- }
35
-
36
- Jbig2Stream.prototype = Object.create(DecodeStream.prototype);
37
-
38
- Object.defineProperty(Jbig2Stream.prototype, "bytes", {
39
- get() {
40
- // If `this.maybeLength` is null, we'll get the entire stream.
41
- return shadow(this, "bytes", this.stream.getBytes(this.maybeLength));
42
- },
43
- configurable: true,
44
- });
45
-
46
- Jbig2Stream.prototype.ensureBuffer = function (requested) {
47
- // No-op, since `this.readBlock` will always parse the entire image and
48
- // directly insert all of its data into `this.buffer`.
49
- };
50
-
51
- Jbig2Stream.prototype.readBlock = function () {
52
- if (this.eof) {
53
- return;
54
- }
55
- const jbig2Image = new Jbig2Image();
56
-
57
- const chunks = [];
58
- if (isDict(this.params)) {
59
- const globalsStream = this.params.get("JBIG2Globals");
60
- if (isStream(globalsStream)) {
61
- const globals = globalsStream.getBytes();
62
- chunks.push({ data: globals, start: 0, end: globals.length });
63
- }
64
- }
65
- chunks.push({ data: this.bytes, start: 0, end: this.bytes.length });
66
- const data = jbig2Image.parseChunks(chunks);
67
- const dataLength = data.length;
68
-
69
- // JBIG2 had black as 1 and white as 0, inverting the colors
70
- for (let i = 0; i < dataLength; i++) {
71
- data[i] ^= 0xff;
72
- }
73
- this.buffer = data;
74
- this.bufferLength = dataLength;
75
- this.eof = true;
76
- };
77
-
78
- return Jbig2Stream;
79
- })();
80
-
81
- export { Jbig2Stream };
@@ -1,387 +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
- /* uses XRef */
16
-
17
- import { assert, unreachable } from "./util.js";
18
-
19
- var EOF = {};
20
-
21
- var Name = (function NameClosure() {
22
- let nameCache = Object.create(null);
23
-
24
- // eslint-disable-next-line no-shadow
25
- function Name(name) {
26
- this.name = name;
27
- }
28
-
29
- Name.prototype = {};
30
-
31
- Name.get = function Name_get(name) {
32
- var nameValue = nameCache[name];
33
- // eslint-disable-next-line no-restricted-syntax
34
- return nameValue ? nameValue : (nameCache[name] = new Name(name));
35
- };
36
-
37
- Name._clearCache = function () {
38
- nameCache = Object.create(null);
39
- };
40
-
41
- return Name;
42
- })();
43
-
44
- var Cmd = (function CmdClosure() {
45
- let cmdCache = Object.create(null);
46
-
47
- // eslint-disable-next-line no-shadow
48
- function Cmd(cmd) {
49
- this.cmd = cmd;
50
- }
51
-
52
- Cmd.prototype = {};
53
-
54
- Cmd.get = function Cmd_get(cmd) {
55
- var cmdValue = cmdCache[cmd];
56
- // eslint-disable-next-line no-restricted-syntax
57
- return cmdValue ? cmdValue : (cmdCache[cmd] = new Cmd(cmd));
58
- };
59
-
60
- Cmd._clearCache = function () {
61
- cmdCache = Object.create(null);
62
- };
63
-
64
- return Cmd;
65
- })();
66
-
67
- var Dict = (function DictClosure() {
68
- var nonSerializable = function nonSerializableClosure() {
69
- return nonSerializable; // creating closure on some variable
70
- };
71
-
72
- // xref is optional
73
- // eslint-disable-next-line no-shadow
74
- function Dict(xref) {
75
- // Map should only be used internally, use functions below to access.
76
- this._map = Object.create(null);
77
- this.xref = xref;
78
- this.objId = null;
79
- this.suppressEncryption = false;
80
- this.__nonSerializable__ = nonSerializable; // disable cloning of the Dict
81
- }
82
-
83
- Dict.prototype = {
84
- assignXref: function Dict_assignXref(newXref) {
85
- this.xref = newXref;
86
- },
87
-
88
- get size() {
89
- return Object.keys(this._map).length;
90
- },
91
-
92
- // automatically dereferences Ref objects
93
- get(key1, key2, key3) {
94
- let value = this._map[key1];
95
- if (value === undefined && key2 !== undefined) {
96
- value = this._map[key2];
97
- if (value === undefined && key3 !== undefined) {
98
- value = this._map[key3];
99
- }
100
- }
101
- if (value instanceof Ref && this.xref) {
102
- return this.xref.fetch(value, this.suppressEncryption);
103
- }
104
- return value;
105
- },
106
-
107
- // Same as get(), but returns a promise and uses fetchIfRefAsync().
108
- async getAsync(key1, key2, key3) {
109
- let value = this._map[key1];
110
- if (value === undefined && key2 !== undefined) {
111
- value = this._map[key2];
112
- if (value === undefined && key3 !== undefined) {
113
- value = this._map[key3];
114
- }
115
- }
116
- if (value instanceof Ref && this.xref) {
117
- return this.xref.fetchAsync(value, this.suppressEncryption);
118
- }
119
- return value;
120
- },
121
-
122
- // Same as get(), but dereferences all elements if the result is an Array.
123
- getArray(key1, key2, key3) {
124
- let value = this.get(key1, key2, key3);
125
- if (!Array.isArray(value) || !this.xref) {
126
- return value;
127
- }
128
- value = value.slice(); // Ensure that we don't modify the Dict data.
129
- for (let i = 0, ii = value.length; i < ii; i++) {
130
- if (!(value[i] instanceof Ref)) {
131
- continue;
132
- }
133
- value[i] = this.xref.fetch(value[i], this.suppressEncryption);
134
- }
135
- return value;
136
- },
137
-
138
- // no dereferencing
139
- getRaw: function Dict_getRaw(key) {
140
- return this._map[key];
141
- },
142
-
143
- getKeys: function Dict_getKeys() {
144
- return Object.keys(this._map);
145
- },
146
-
147
- // no dereferencing
148
- getRawValues: function Dict_getRawValues() {
149
- return Object.values(this._map);
150
- },
151
-
152
- set: function Dict_set(key, value) {
153
- if (
154
- (typeof PDFJSDev === "undefined" ||
155
- PDFJSDev.test("!PRODUCTION || TESTING")) &&
156
- value === undefined
157
- ) {
158
- unreachable('Dict.set: The "value" cannot be undefined.');
159
- }
160
- this._map[key] = value;
161
- },
162
-
163
- has: function Dict_has(key) {
164
- return this._map[key] !== undefined;
165
- },
166
-
167
- forEach: function Dict_forEach(callback) {
168
- for (var key in this._map) {
169
- callback(key, this.get(key));
170
- }
171
- },
172
- };
173
-
174
- Dict.empty = new Dict(null);
175
-
176
- Dict.merge = function ({ xref, dictArray, mergeSubDicts = false }) {
177
- const mergedDict = new Dict(xref);
178
-
179
- if (!mergeSubDicts) {
180
- for (const dict of dictArray) {
181
- if (!(dict instanceof Dict)) {
182
- continue;
183
- }
184
- for (const [key, value] of Object.entries(dict._map)) {
185
- if (mergedDict._map[key] === undefined) {
186
- mergedDict._map[key] = value;
187
- }
188
- }
189
- }
190
- return mergedDict.size > 0 ? mergedDict : Dict.empty;
191
- }
192
- const properties = new Map();
193
-
194
- for (const dict of dictArray) {
195
- if (!(dict instanceof Dict)) {
196
- continue;
197
- }
198
- for (const [key, value] of Object.entries(dict._map)) {
199
- let property = properties.get(key);
200
- if (property === undefined) {
201
- property = [];
202
- properties.set(key, property);
203
- }
204
- property.push(value);
205
- }
206
- }
207
- for (const [name, values] of properties) {
208
- if (values.length === 1 || !(values[0] instanceof Dict)) {
209
- mergedDict._map[name] = values[0];
210
- continue;
211
- }
212
- const subDict = new Dict(xref);
213
-
214
- for (const dict of values) {
215
- if (!(dict instanceof Dict)) {
216
- continue;
217
- }
218
- for (const [key, value] of Object.entries(dict._map)) {
219
- if (subDict._map[key] === undefined) {
220
- subDict._map[key] = value;
221
- }
222
- }
223
- }
224
- if (subDict.size > 0) {
225
- mergedDict._map[name] = subDict;
226
- }
227
- }
228
- properties.clear();
229
-
230
- return mergedDict.size > 0 ? mergedDict : Dict.empty;
231
- };
232
-
233
- return Dict;
234
- })();
235
-
236
- var Ref = (function RefClosure() {
237
- let refCache = Object.create(null);
238
-
239
- // eslint-disable-next-line no-shadow
240
- function Ref(num, gen) {
241
- this.num = num;
242
- this.gen = gen;
243
- }
244
-
245
- Ref.prototype = {
246
- toString: function Ref_toString() {
247
- // This function is hot, so we make the string as compact as possible.
248
- // |this.gen| is almost always zero, so we treat that case specially.
249
- if (this.gen === 0) {
250
- return `${this.num}R`;
251
- }
252
- return `${this.num}R${this.gen}`;
253
- },
254
- };
255
-
256
- Ref.get = function (num, gen) {
257
- const key = gen === 0 ? `${num}R` : `${num}R${gen}`;
258
- const refValue = refCache[key];
259
- // eslint-disable-next-line no-restricted-syntax
260
- return refValue ? refValue : (refCache[key] = new Ref(num, gen));
261
- };
262
-
263
- Ref._clearCache = function () {
264
- refCache = Object.create(null);
265
- };
266
-
267
- return Ref;
268
- })();
269
-
270
- // The reference is identified by number and generation.
271
- // This structure stores only one instance of the reference.
272
- class RefSet {
273
- constructor() {
274
- this._set = new Set();
275
- }
276
-
277
- has(ref) {
278
- return this._set.has(ref.toString());
279
- }
280
-
281
- put(ref) {
282
- this._set.add(ref.toString());
283
- }
284
-
285
- remove(ref) {
286
- this._set.delete(ref.toString());
287
- }
288
- }
289
-
290
- class RefSetCache {
291
- constructor() {
292
- this._map = new Map();
293
- }
294
-
295
- get size() {
296
- return this._map.size;
297
- }
298
-
299
- get(ref) {
300
- return this._map.get(ref.toString());
301
- }
302
-
303
- has(ref) {
304
- return this._map.has(ref.toString());
305
- }
306
-
307
- put(ref, obj) {
308
- this._map.set(ref.toString(), obj);
309
- }
310
-
311
- putAlias(ref, aliasRef) {
312
- this._map.set(ref.toString(), this.get(aliasRef));
313
- }
314
-
315
- forEach(callback) {
316
- for (const value of this._map.values()) {
317
- callback(value);
318
- }
319
- }
320
-
321
- clear() {
322
- this._map.clear();
323
- }
324
- }
325
-
326
- function isEOF(v) {
327
- return v === EOF;
328
- }
329
-
330
- function isName(v, name) {
331
- return v instanceof Name && (name === undefined || v.name === name);
332
- }
333
-
334
- function isCmd(v, cmd) {
335
- return v instanceof Cmd && (cmd === undefined || v.cmd === cmd);
336
- }
337
-
338
- function isDict(v, type) {
339
- return (
340
- v instanceof Dict && (type === undefined || isName(v.get("Type"), type))
341
- );
342
- }
343
-
344
- function isRef(v) {
345
- return v instanceof Ref;
346
- }
347
-
348
- function isRefsEqual(v1, v2) {
349
- if (
350
- typeof PDFJSDev === "undefined" ||
351
- PDFJSDev.test("!PRODUCTION || TESTING")
352
- ) {
353
- assert(
354
- v1 instanceof Ref && v2 instanceof Ref,
355
- "isRefsEqual: Both parameters should be `Ref`s."
356
- );
357
- }
358
- return v1.num === v2.num && v1.gen === v2.gen;
359
- }
360
-
361
- function isStream(v) {
362
- return typeof v === "object" && v !== null && v.getBytes !== undefined;
363
- }
364
-
365
- function clearPrimitiveCaches() {
366
- Cmd._clearCache();
367
- Name._clearCache();
368
- Ref._clearCache();
369
- }
370
-
371
- export {
372
- EOF,
373
- clearPrimitiveCaches,
374
- Cmd,
375
- Dict,
376
- Name,
377
- Ref,
378
- RefSet,
379
- RefSetCache,
380
- isEOF,
381
- isCmd,
382
- isDict,
383
- isName,
384
- isRef,
385
- isRefsEqual,
386
- isStream,
387
- };