@patrickdk77/archive-defuse 0.0.0-stage → 0.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 (122) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +378 -2
  3. package/dist/aes7z.d.ts +16 -0
  4. package/dist/aes7z.js +131 -0
  5. package/dist/alone.d.ts +21 -0
  6. package/dist/alone.js +65 -0
  7. package/dist/bcj2.d.ts +21 -0
  8. package/dist/bcj2.js +140 -0
  9. package/dist/bzip2.d.ts +21 -0
  10. package/dist/bzip2.js +688 -0
  11. package/dist/cab.d.ts +63 -0
  12. package/dist/cab.js +493 -0
  13. package/dist/checks.d.ts +23 -0
  14. package/dist/checks.js +123 -0
  15. package/dist/cli.d.ts +2 -0
  16. package/dist/cli.js +364 -0
  17. package/dist/codecs.d.ts +39 -0
  18. package/dist/codecs.js +124 -0
  19. package/dist/coders.d.ts +58 -0
  20. package/dist/coders.js +392 -0
  21. package/dist/crc32.d.ts +8 -0
  22. package/dist/crc32.js +59 -0
  23. package/dist/detect.d.ts +10 -0
  24. package/dist/detect.js +95 -0
  25. package/dist/encoder.d.ts +44 -0
  26. package/dist/encoder.js +114 -0
  27. package/dist/engine.d.ts +44 -0
  28. package/dist/engine.js +753 -0
  29. package/dist/errors.d.ts +64 -0
  30. package/dist/errors.js +98 -0
  31. package/dist/filters.d.ts +34 -0
  32. package/dist/filters.js +385 -0
  33. package/dist/findings.d.ts +26 -0
  34. package/dist/findings.js +176 -0
  35. package/dist/formats.d.ts +24 -0
  36. package/dist/formats.js +106 -0
  37. package/dist/index.d.ts +9 -0
  38. package/dist/index.js +53 -0
  39. package/dist/index.mjs +3 -0
  40. package/dist/inflate64.d.ts +6 -0
  41. package/dist/inflate64.js +388 -0
  42. package/dist/io.d.ts +78 -0
  43. package/dist/io.js +379 -0
  44. package/dist/lzma-formats.d.ts +75 -0
  45. package/dist/lzma-formats.js +373 -0
  46. package/dist/lzma-sniff.d.ts +20 -0
  47. package/dist/lzma-sniff.js +73 -0
  48. package/dist/lzma-writers.d.ts +35 -0
  49. package/dist/lzma-writers.js +276 -0
  50. package/dist/lzma1/LICENSE +201 -0
  51. package/dist/lzma1/NOTICE +36 -0
  52. package/dist/lzma1/crc32.d.ts +4 -0
  53. package/dist/lzma1/crc32.js +19 -0
  54. package/dist/lzma1/hash234.d.ts +22 -0
  55. package/dist/lzma1/hash234.js +75 -0
  56. package/dist/lzma1/hc4.d.ts +30 -0
  57. package/dist/lzma1/hc4.js +142 -0
  58. package/dist/lzma1/header.d.ts +32 -0
  59. package/dist/lzma1/header.js +73 -0
  60. package/dist/lzma1/lz-decoder.d.ts +41 -0
  61. package/dist/lzma1/lz-decoder.js +128 -0
  62. package/dist/lzma1/lz-encoder.d.ts +87 -0
  63. package/dist/lzma1/lz-encoder.js +166 -0
  64. package/dist/lzma1/lzma-coder.d.ts +107 -0
  65. package/dist/lzma1/lzma-coder.js +162 -0
  66. package/dist/lzma1/lzma-decoder.d.ts +36 -0
  67. package/dist/lzma1/lzma-decoder.js +484 -0
  68. package/dist/lzma1/lzma-encoder-fast.d.ts +13 -0
  69. package/dist/lzma1/lzma-encoder-fast.js +114 -0
  70. package/dist/lzma1/lzma-encoder.d.ts +105 -0
  71. package/dist/lzma1/lzma-encoder.js +497 -0
  72. package/dist/lzma1/lzma2-decoder.d.ts +85 -0
  73. package/dist/lzma1/lzma2-decoder.js +249 -0
  74. package/dist/lzma1/range-coder.d.ts +18 -0
  75. package/dist/lzma1/range-coder.js +23 -0
  76. package/dist/lzma1/range-decoder.d.ts +41 -0
  77. package/dist/lzma1/range-decoder.js +78 -0
  78. package/dist/lzma1/range-encoder.d.ts +53 -0
  79. package/dist/lzma1/range-encoder.js +269 -0
  80. package/dist/lzma1-stream.d.ts +60 -0
  81. package/dist/lzma1-stream.js +202 -0
  82. package/dist/model.d.ts +141 -0
  83. package/dist/model.js +16 -0
  84. package/dist/names.d.ts +13 -0
  85. package/dist/names.js +66 -0
  86. package/dist/pack.d.ts +79 -0
  87. package/dist/pack.js +590 -0
  88. package/dist/plugins.d.ts +13 -0
  89. package/dist/plugins.js +56 -0
  90. package/dist/rules.d.ts +25 -0
  91. package/dist/rules.js +403 -0
  92. package/dist/score.d.ts +17 -0
  93. package/dist/score.js +58 -0
  94. package/dist/seven.d.ts +75 -0
  95. package/dist/seven.js +492 -0
  96. package/dist/sevenzip.d.ts +133 -0
  97. package/dist/sevenzip.js +529 -0
  98. package/dist/single.d.ts +103 -0
  99. package/dist/single.js +453 -0
  100. package/dist/sniff.d.ts +20 -0
  101. package/dist/sniff.js +224 -0
  102. package/dist/stream-meter.d.ts +39 -0
  103. package/dist/stream-meter.js +54 -0
  104. package/dist/tar.d.ts +102 -0
  105. package/dist/tar.js +765 -0
  106. package/dist/types.d.ts +311 -0
  107. package/dist/types.js +133 -0
  108. package/dist/unpack.d.ts +67 -0
  109. package/dist/unpack.js +194 -0
  110. package/dist/xz.d.ts +25 -0
  111. package/dist/xz.js +333 -0
  112. package/dist/zip-lzma.d.ts +15 -0
  113. package/dist/zip-lzma.js +137 -0
  114. package/dist/zip-writer.d.ts +51 -0
  115. package/dist/zip-writer.js +305 -0
  116. package/dist/zip.d.ts +99 -0
  117. package/dist/zip.js +901 -0
  118. package/dist/zipcrypt.d.ts +47 -0
  119. package/dist/zipcrypt.js +233 -0
  120. package/dist/zstd.d.ts +25 -0
  121. package/dist/zstd.js +160 -0
  122. package/package.json +94 -4
package/dist/io.js ADDED
@@ -0,0 +1,379 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.SpillSink = exports.TempDir = exports.Reader = void 0;
37
+ exports.bufferSource = bufferSource;
38
+ exports.fileSource = fileSource;
39
+ exports.bufferSink = bufferSink;
40
+ exports.fileSink = fileSink;
41
+ exports.writableSink = writableSink;
42
+ exports.copyToSink = copyToSink;
43
+ // Copied from office-defuse src/io.ts. Changed: the TempDir prefix, and bufferSource and fileSource read only whole offsets inside the source, as pdf-defuse's do.
44
+ const crypto = __importStar(require("node:crypto"));
45
+ const fsp = __importStar(require("node:fs/promises"));
46
+ const os = __importStar(require("node:os"));
47
+ const path = __importStar(require("node:path"));
48
+ /**
49
+ * The bytes [start, end) a read covers in a source of `size` bytes, or undefined when it covers none. Offsets read
50
+ * from a file can be negative or fractional, and such a read gets no bytes rather than bytes from somewhere else.
51
+ */
52
+ function span(offset, length, size) {
53
+ if (!Number.isSafeInteger(offset) || offset < 0 || offset >= size || !(length >= 1))
54
+ return undefined;
55
+ return [offset, Math.min(size, offset + Math.floor(length))];
56
+ }
57
+ /** A source over bytes already in memory. Reads return views, not copies. */
58
+ function bufferSource(bytes) {
59
+ return {
60
+ size: async () => bytes.length,
61
+ read: async (offset, length) => {
62
+ const s = span(offset, length, bytes.length);
63
+ return s ? bytes.subarray(s[0], s[1]) : new Uint8Array(0);
64
+ },
65
+ };
66
+ }
67
+ /** A source over a local file, read at offsets through one file handle. */
68
+ function fileSource(filePath) {
69
+ // The pending open is shared, so concurrent first calls get one handle and close() closes it.
70
+ let opening;
71
+ let size;
72
+ const open = () => {
73
+ opening ??= fsp.open(filePath, 'r');
74
+ return opening;
75
+ };
76
+ const getSize = async () => {
77
+ size ??= (await (await open()).stat()).size;
78
+ return size;
79
+ };
80
+ return {
81
+ size: getSize,
82
+ async read(offset, length) {
83
+ const h = await open();
84
+ // Node reads position -1 from the file's current position, so a negative offset never reaches it.
85
+ const s = span(offset, length, await getSize());
86
+ if (!s)
87
+ return Buffer.alloc(0);
88
+ const n = s[1] - offset;
89
+ const buf = Buffer.allocUnsafe(n);
90
+ let done = 0;
91
+ while (done < n) {
92
+ const { bytesRead } = await h.read(buf, done, n - done, offset + done);
93
+ if (bytesRead === 0)
94
+ break;
95
+ done += bytesRead;
96
+ }
97
+ return buf.subarray(0, done);
98
+ },
99
+ async close() {
100
+ const p = opening;
101
+ opening = undefined;
102
+ await p?.then(h => h.close(), () => {
103
+ // An open that failed left nothing to close.
104
+ });
105
+ },
106
+ };
107
+ }
108
+ /**
109
+ * Random-access reader with a small block cache, so the ZIP reader can ask for small overlapping windows cheaply. Its
110
+ * reads span at most a few blocks: a header, a name and its extra field, or the end of the file.
111
+ */
112
+ class Reader {
113
+ source;
114
+ size;
115
+ blockSize;
116
+ maxBlocks;
117
+ /** Blocks by index, oldest first. */
118
+ cache = new Map();
119
+ constructor(source, size, blockSize = 65536, maxBlocks = 16) {
120
+ this.source = source;
121
+ this.size = size;
122
+ this.blockSize = blockSize;
123
+ this.maxBlocks = maxBlocks;
124
+ }
125
+ async block(index) {
126
+ const hit = this.cache.get(index);
127
+ if (hit)
128
+ return hit;
129
+ const data = await this.source.read(index * this.blockSize, Math.min(this.blockSize, this.size - index * this.blockSize));
130
+ if (this.cache.size >= this.maxBlocks) {
131
+ for (const oldest of this.cache.keys()) {
132
+ this.cache.delete(oldest);
133
+ break;
134
+ }
135
+ }
136
+ this.cache.set(index, data);
137
+ return data;
138
+ }
139
+ /** Reads up to `length` bytes at `offset`; shorter only at the end of the source. */
140
+ async read(offset, length) {
141
+ const end = Math.min(this.size, offset + length);
142
+ if (end <= offset)
143
+ return new Uint8Array(0);
144
+ const first = Math.floor(offset / this.blockSize);
145
+ const last = Math.floor((end - 1) / this.blockSize);
146
+ const out = new Uint8Array(end - offset);
147
+ for (let i = first; i <= last; i++) {
148
+ const b = await this.block(i);
149
+ const from = i === first ? offset - first * this.blockSize : 0;
150
+ const to = i === last ? end - i * this.blockSize : b.length;
151
+ out.set(b.subarray(from, to), i === first ? 0 : i * this.blockSize - offset);
152
+ }
153
+ return out;
154
+ }
155
+ /** Yields the range in chunks without caching them. */
156
+ async *chunks(offset, length, chunkSize = 262144) {
157
+ const end = Math.min(this.size, offset + length);
158
+ for (let pos = offset; pos < end; pos += chunkSize)
159
+ yield this.source.read(pos, Math.min(chunkSize, end - pos));
160
+ }
161
+ }
162
+ exports.Reader = Reader;
163
+ /** Collects output in memory. */
164
+ function bufferSink() {
165
+ const chunks = [];
166
+ let size = 0;
167
+ return {
168
+ async write(chunk) {
169
+ chunks.push(Buffer.from(chunk));
170
+ size += chunk.length;
171
+ },
172
+ async close() {
173
+ // Nothing to release. The chunks stay for result().
174
+ },
175
+ result: () => Buffer.concat(chunks),
176
+ size: () => size,
177
+ };
178
+ }
179
+ /** FileHandle.write may write less than asked, for example at a file size limit; the next write then reports why. */
180
+ async function writeAll(handle, chunk) {
181
+ for (let done = 0; done < chunk.length;)
182
+ done += (await handle.write(chunk, done, chunk.length - done)).bytesWritten;
183
+ }
184
+ /** Writes to a local file. The file is created on the first write. */
185
+ function fileSink(filePath) {
186
+ let handle;
187
+ return {
188
+ async write(chunk) {
189
+ handle ??= await fsp.open(filePath, 'w');
190
+ await writeAll(handle, chunk);
191
+ },
192
+ async close() {
193
+ handle ??= await fsp.open(filePath, 'w');
194
+ await handle.close();
195
+ },
196
+ async abort() {
197
+ const h = handle;
198
+ handle = undefined;
199
+ if (!h)
200
+ return;
201
+ // A partial regular file goes. abort() never unlinks a device or pipe the caller named.
202
+ const partial = (await h.stat().catch(() => undefined))?.isFile();
203
+ await h.close().catch(() => {
204
+ // abort() runs after a failure, which is the error to report.
205
+ });
206
+ if (partial)
207
+ await fsp.rm(filePath, { force: true });
208
+ },
209
+ };
210
+ }
211
+ /**
212
+ * Wraps any Node Writable, waiting for 'drain' when it applies backpressure. The stream's first error, or its
213
+ * closing before the end, fails the pending write and every later one.
214
+ */
215
+ function writableSink(stream) {
216
+ let failure;
217
+ const pending = new Set();
218
+ const fail = (e) => {
219
+ failure ??= e;
220
+ for (const reject of pending)
221
+ reject(failure);
222
+ pending.clear();
223
+ };
224
+ // Node emits some errors after the write callback, and an 'error' with no listener crashes the process, so this
225
+ // listener stays for the stream's whole life.
226
+ stream.on('error', fail);
227
+ stream.on('close', () => {
228
+ if (!stream.writableFinished)
229
+ fail(stream.errored ?? new Error('The output stream closed before all data was written'));
230
+ });
231
+ const settle = (start) => new Promise((resolve, reject) => {
232
+ if (failure)
233
+ return reject(failure);
234
+ if (stream.destroyed)
235
+ return reject(stream.errored ?? new Error('The output stream was destroyed'));
236
+ pending.add(reject);
237
+ start(err => {
238
+ pending.delete(reject);
239
+ if (err)
240
+ reject(err);
241
+ else
242
+ resolve();
243
+ });
244
+ });
245
+ return {
246
+ write: chunk => settle(done => (stream.write(chunk) ? done() : stream.once('drain', () => done()))),
247
+ close: () => settle(done => stream.end((err) => done(err))),
248
+ // The reader sees an error instead of an end, so it cannot mistake a partial output for a whole one.
249
+ abort: async (error) => {
250
+ stream.destroy(error instanceof Error ? error : new Error(String(error)));
251
+ },
252
+ };
253
+ }
254
+ /** A private temporary directory, removed by cleanup(). It also keeps the run's first I/O error. */
255
+ class TempDir {
256
+ base;
257
+ // The pending mkdtemp is shared, so concurrent first calls make one directory and cleanup() removes it.
258
+ dir;
259
+ seq = 0;
260
+ /** The first error from a temporary file, which the engine throws instead of a verdict on the file. */
261
+ ioError;
262
+ constructor(base = os.tmpdir()) {
263
+ this.base = base;
264
+ }
265
+ async file(suffix = '.bin') {
266
+ this.dir ??= fsp.mkdtemp(path.join(this.base, 'archive-defuse-'));
267
+ return path.join(await this.dir, `${this.seq++}${suffix}`);
268
+ }
269
+ async cleanup() {
270
+ const dir = await this.dir?.catch(() => undefined);
271
+ this.dir = undefined;
272
+ if (dir)
273
+ await fsp.rm(dir, { recursive: true, force: true });
274
+ }
275
+ }
276
+ exports.TempDir = TempDir;
277
+ /**
278
+ * A sink that keeps what it is given in memory up to `threshold` bytes and in a temporary file past that, with the MD5
279
+ * of the bytes, which tells the output check that a file inside is the one a plugin returned.
280
+ */
281
+ class SpillSink {
282
+ temp;
283
+ threshold;
284
+ chunks = [];
285
+ size = 0;
286
+ filePath;
287
+ handle;
288
+ md5 = crypto.createHash('md5');
289
+ hex;
290
+ spilled = false;
291
+ constructor(temp, threshold) {
292
+ this.temp = temp;
293
+ this.threshold = threshold;
294
+ }
295
+ async write(chunk) {
296
+ this.md5.update(chunk);
297
+ this.size += chunk.length;
298
+ if (!this.handle && this.size <= this.threshold) {
299
+ this.chunks.push(Buffer.from(chunk));
300
+ return;
301
+ }
302
+ try {
303
+ if (!this.handle) {
304
+ this.filePath = await this.temp.file('.spill');
305
+ this.handle = await fsp.open(this.filePath, 'w');
306
+ this.spilled = true;
307
+ for (const c of this.chunks)
308
+ await writeAll(this.handle, c);
309
+ this.chunks = [];
310
+ }
311
+ await writeAll(this.handle, chunk);
312
+ }
313
+ catch (e) {
314
+ this.temp.ioError ??= e;
315
+ throw e;
316
+ }
317
+ }
318
+ async close() {
319
+ await this.handle?.close();
320
+ this.handle = undefined;
321
+ }
322
+ /** Closes the sink and deletes its temporary file, once nothing will read what it holds again. */
323
+ async dispose() {
324
+ await this.close();
325
+ this.chunks = [];
326
+ const file = this.filePath;
327
+ this.filePath = undefined;
328
+ if (file === undefined)
329
+ return;
330
+ try {
331
+ await fsp.rm(file, { force: true });
332
+ }
333
+ catch (e) {
334
+ this.temp.ioError ??= e;
335
+ throw e;
336
+ }
337
+ }
338
+ get length() {
339
+ return this.size;
340
+ }
341
+ digest() {
342
+ this.hex ??= this.md5.digest('hex');
343
+ return this.hex;
344
+ }
345
+ /** A source over what was written. Call after close(). */
346
+ source() {
347
+ return this.filePath ? fileSource(this.filePath) : bufferSource(Buffer.concat(this.chunks));
348
+ }
349
+ /** What was written, in chunks. Call after close(). */
350
+ async *read(chunkSize = 262144) {
351
+ const src = this.source();
352
+ // A consumer that stops early, such as a failed output write, still closes the file.
353
+ try {
354
+ const total = await src.size();
355
+ for (let pos = 0; pos < total; pos += chunkSize)
356
+ yield await src.read(pos, Math.min(chunkSize, total - pos));
357
+ }
358
+ finally {
359
+ await src.close?.();
360
+ }
361
+ }
362
+ }
363
+ exports.SpillSink = SpillSink;
364
+ /**
365
+ * Copies a whole source, calling `checkTime` before each chunk. A read that returns more or fewer bytes than it asked
366
+ * for fails the copy, which would otherwise shift every byte after it.
367
+ */
368
+ async function copyToSink(source, sink, checkTime) {
369
+ const total = await source.size();
370
+ const chunk = 262144;
371
+ for (let pos = 0; pos < total; pos += chunk) {
372
+ checkTime?.();
373
+ const want = Math.min(chunk, total - pos);
374
+ const b = await source.read(pos, want);
375
+ if (b.length !== want)
376
+ throw Object.assign(new Error(`The source returned ${b.length} bytes at offset ${pos} where ${want} were expected`), { code: 'EIO' });
377
+ await sink.write(b);
378
+ }
379
+ }
@@ -0,0 +1,75 @@
1
+ import { type Reader as ByteReader } from './io';
2
+ import { type Archive, type Entry, type Meter, type Note, type WriteContext, type WritePlan } from './model';
3
+ import { type SevenEntry } from './seven';
4
+ import type { Limits } from './stream-meter';
5
+ import { type ByteSink, type ByteSource } from './types';
6
+ export interface SevenZipEntry extends Entry {
7
+ seven: SevenEntry;
8
+ }
9
+ export declare class SevenZipArchive implements Archive<SevenZipEntry> {
10
+ private readonly reader;
11
+ private readonly seven;
12
+ readonly notes: Note[];
13
+ private readonly passwords;
14
+ readonly format = "7z";
15
+ readonly single = false;
16
+ readonly nameless: boolean;
17
+ readonly lateNotes: Note[];
18
+ readonly entries: SevenZipEntry[];
19
+ private readonly contents;
20
+ private constructor();
21
+ static open(source: ByteSource, limits: Limits, deadline: number | undefined, passwords: string[]): Promise<SevenZipArchive>;
22
+ hasMetadata(): boolean;
23
+ unlock(e: SevenZipEntry, password: string): Promise<boolean>;
24
+ read(e: SevenZipEntry, meter: Meter, password?: string): AsyncGenerator<Uint8Array>;
25
+ /** A symbolic link's target, which a 7z archive keeps as the link's content. */
26
+ linkTarget(e: SevenZipEntry, meter: Meter): Promise<string | undefined>;
27
+ write(plan: WritePlan<SevenZipEntry>, sink: ByteSink, context: WriteContext): Promise<void>;
28
+ /** One kept entry as the writer takes it, with its name and permissions as the rules left them. */
29
+ private out;
30
+ }
31
+ interface LzmaSingleEntry extends Entry {
32
+ decoded?: number;
33
+ }
34
+ /** A file that compresses one file: its one entry has no name, and its content goes to the plugins like any other. */
35
+ declare abstract class LzmaSingle implements Archive<LzmaSingleEntry> {
36
+ protected readonly reader: ByteReader;
37
+ protected readonly limits: Limits;
38
+ abstract readonly format: 'xz' | 'lzma';
39
+ readonly single = true;
40
+ readonly notes: Note[];
41
+ readonly lateNotes: Note[];
42
+ readonly entries: LzmaSingleEntry[];
43
+ /** Set once the entry has been read: where data after the stream starts, when the file goes on. */
44
+ protected trailingAt?: number;
45
+ /** Set once the entry has been read and nothing about the stream needs writing again: it can be copied as it is. */
46
+ protected copyable: boolean;
47
+ constructor(reader: ByteReader, limits: Limits);
48
+ unlock(): Promise<boolean>;
49
+ hasMetadata(): boolean;
50
+ abstract read(e: LzmaSingleEntry, meter: Meter): AsyncGenerator<Uint8Array>;
51
+ /** Writes `content` in the format. With `store`, a format that can store data uncompressed does. */
52
+ protected abstract encode(content: ByteSource | undefined, sink: ByteSink, time: () => void, store: boolean): Promise<void>;
53
+ /** True when encode() can store data uncompressed. */
54
+ protected readonly canStore: boolean;
55
+ /** Notes what the read found besides the content, and whether the stream can be copied as it is. */
56
+ protected finishRead(e: LzmaSingleEntry, total: number, notes: Note[], oneStream: boolean, trailingAt: number | undefined): Promise<void>;
57
+ write(plan: WritePlan<LzmaSingleEntry>, sink: ByteSink, context: WriteContext): Promise<void>;
58
+ private writeContent;
59
+ }
60
+ export declare class XzArchive extends LzmaSingle {
61
+ readonly format = "xz";
62
+ /** The check the rewrite writes: the one every stream used when this package can compute it, else CRC64. */
63
+ private checkId;
64
+ static open(source: ByteSource, limits: Limits): Promise<XzArchive>;
65
+ read(e: LzmaSingleEntry, meter: Meter): AsyncGenerator<Uint8Array>;
66
+ protected readonly canStore = true;
67
+ protected encode(content: ByteSource | undefined, sink: ByteSink, time: () => void, store: boolean): Promise<void>;
68
+ }
69
+ export declare class LzmaArchive extends LzmaSingle {
70
+ readonly format = "lzma";
71
+ static open(source: ByteSource, limits: Limits): Promise<LzmaArchive>;
72
+ read(e: LzmaSingleEntry, meter: Meter): AsyncGenerator<Uint8Array>;
73
+ protected encode(content: ByteSource | undefined, sink: ByteSink, time: () => void): Promise<void>;
74
+ }
75
+ export {};