tar 7.5.24 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1705 -1147
- package/dist/commonjs/bytes.d.ts +21 -0
- package/dist/commonjs/bytes.d.ts.map +1 -0
- package/dist/commonjs/bytes.js +83 -0
- package/dist/commonjs/bytes.js.map +1 -0
- package/dist/commonjs/codec.d.ts +53 -0
- package/dist/commonjs/codec.d.ts.map +1 -0
- package/dist/commonjs/codec.js +35 -0
- package/dist/commonjs/codec.js.map +1 -0
- package/dist/commonjs/concat.d.ts +3 -0
- package/dist/commonjs/concat.d.ts.map +1 -0
- package/dist/commonjs/concat.js +20 -0
- package/dist/commonjs/concat.js.map +1 -0
- package/dist/commonjs/create.d.ts +39 -2
- package/dist/commonjs/create.d.ts.map +1 -1
- package/dist/commonjs/create.js +150 -64
- package/dist/commonjs/create.js.map +1 -1
- package/dist/commonjs/dealias.d.ts +79 -0
- package/dist/commonjs/dealias.d.ts.map +1 -0
- package/dist/commonjs/dealias.js +50 -0
- package/dist/commonjs/dealias.js.map +1 -0
- package/dist/commonjs/delete.d.ts +19 -0
- package/dist/commonjs/delete.d.ts.map +1 -0
- package/dist/commonjs/delete.js +121 -0
- package/dist/commonjs/delete.js.map +1 -0
- package/dist/commonjs/entries.d.ts +82 -0
- package/dist/commonjs/entries.d.ts.map +1 -0
- package/dist/commonjs/entries.js +398 -0
- package/dist/commonjs/entries.js.map +1 -0
- package/dist/commonjs/extract.d.ts +14 -2
- package/dist/commonjs/extract.d.ts.map +1 -1
- package/dist/commonjs/extract.js +40 -81
- package/dist/commonjs/extract.js.map +1 -1
- package/dist/commonjs/fs.d.ts +201 -0
- package/dist/commonjs/fs.d.ts.map +1 -0
- package/dist/commonjs/fs.js +5 -0
- package/dist/commonjs/fs.js.map +1 -0
- package/dist/commonjs/header.d.ts +4 -4
- package/dist/commonjs/header.d.ts.map +1 -1
- package/dist/commonjs/header.js +38 -42
- package/dist/commonjs/header.js.map +1 -1
- package/dist/commonjs/index.d.ts +25 -18
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +46 -18
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/index.min.js +2 -3
- package/dist/commonjs/index.min.js.map +4 -4
- package/dist/commonjs/large-numbers.d.ts +2 -2
- package/dist/commonjs/large-numbers.d.ts.map +1 -1
- package/dist/commonjs/large-numbers.js +4 -4
- package/dist/commonjs/large-numbers.js.map +1 -1
- package/dist/commonjs/list.d.ts +23 -6
- package/dist/commonjs/list.d.ts.map +1 -1
- package/dist/commonjs/list.js +99 -138
- package/dist/commonjs/list.js.map +1 -1
- package/dist/commonjs/mkdir.d.ts +16 -11
- package/dist/commonjs/mkdir.d.ts.map +1 -1
- package/dist/commonjs/mkdir.js +121 -159
- package/dist/commonjs/mkdir.js.map +1 -1
- package/dist/commonjs/options.d.ts +284 -513
- package/dist/commonjs/options.d.ts.map +1 -1
- package/dist/commonjs/options.js +20 -61
- package/dist/commonjs/options.js.map +1 -1
- package/dist/commonjs/pack.d.ts +150 -96
- package/dist/commonjs/pack.d.ts.map +1 -1
- package/dist/commonjs/pack.js +752 -445
- package/dist/commonjs/pack.js.map +1 -1
- package/dist/commonjs/parser.d.ts +94 -0
- package/dist/commonjs/parser.d.ts.map +1 -0
- package/dist/commonjs/parser.js +381 -0
- package/dist/commonjs/parser.js.map +1 -0
- package/dist/commonjs/path-reservations.d.ts +17 -7
- package/dist/commonjs/path-reservations.d.ts.map +1 -1
- package/dist/commonjs/path-reservations.js +96 -119
- package/dist/commonjs/path-reservations.js.map +1 -1
- package/dist/commonjs/path.d.ts +19 -0
- package/dist/commonjs/path.d.ts.map +1 -0
- package/dist/commonjs/path.js +90 -0
- package/dist/commonjs/path.js.map +1 -0
- package/dist/commonjs/pax.d.ts +3 -1
- package/dist/commonjs/pax.d.ts.map +1 -1
- package/dist/commonjs/pax.js +53 -43
- package/dist/commonjs/pax.js.map +1 -1
- package/dist/commonjs/read-entry.d.ts +97 -11
- package/dist/commonjs/read-entry.d.ts.map +1 -1
- package/dist/commonjs/read-entry.js +248 -97
- package/dist/commonjs/read-entry.js.map +1 -1
- package/dist/commonjs/read-file.d.ts +22 -0
- package/dist/commonjs/read-file.d.ts.map +1 -0
- package/dist/commonjs/read-file.js +104 -0
- package/dist/commonjs/read-file.js.map +1 -0
- package/dist/commonjs/replace.d.ts +45 -1
- package/dist/commonjs/replace.d.ts.map +1 -1
- package/dist/commonjs/replace.js +165 -211
- package/dist/commonjs/replace.js.map +1 -1
- package/dist/commonjs/server/codecs.d.ts +38 -0
- package/dist/commonjs/server/codecs.d.ts.map +1 -0
- package/dist/commonjs/server/codecs.js +252 -0
- package/dist/commonjs/server/codecs.js.map +1 -0
- package/dist/commonjs/server/index.d.ts +115 -0
- package/dist/commonjs/server/index.d.ts.map +1 -0
- package/dist/commonjs/server/index.js +166 -0
- package/dist/commonjs/server/index.js.map +1 -0
- package/dist/commonjs/server/index.min.js +3 -0
- package/dist/commonjs/server/index.min.js.map +7 -0
- package/dist/commonjs/strip-absolute-path.d.ts +8 -0
- package/dist/commonjs/strip-absolute-path.d.ts.map +1 -1
- package/dist/commonjs/strip-absolute-path.js +17 -20
- package/dist/commonjs/strip-absolute-path.js.map +1 -1
- package/dist/commonjs/to-stream.d.ts +7 -0
- package/dist/commonjs/to-stream.d.ts.map +1 -0
- package/dist/commonjs/to-stream.js +22 -0
- package/dist/commonjs/to-stream.js.map +1 -0
- package/dist/commonjs/types.d.ts +4 -3
- package/dist/commonjs/types.d.ts.map +1 -1
- package/dist/commonjs/types.js +4 -3
- package/dist/commonjs/types.js.map +1 -1
- package/dist/commonjs/unpack.d.ts +135 -89
- package/dist/commonjs/unpack.d.ts.map +1 -1
- package/dist/commonjs/unpack.js +760 -727
- package/dist/commonjs/unpack.js.map +1 -1
- package/dist/commonjs/update.d.ts +11 -1
- package/dist/commonjs/update.d.ts.map +1 -1
- package/dist/commonjs/update.js +37 -28
- package/dist/commonjs/update.js.map +1 -1
- package/dist/commonjs/warn.d.ts +27 -0
- package/dist/commonjs/warn.d.ts.map +1 -0
- package/dist/commonjs/warn.js +36 -0
- package/dist/commonjs/warn.js.map +1 -0
- package/dist/commonjs/win32-path.d.ts +16 -0
- package/dist/commonjs/win32-path.d.ts.map +1 -0
- package/dist/commonjs/win32-path.js +67 -0
- package/dist/commonjs/win32-path.js.map +1 -0
- package/dist/commonjs/write-entry.d.ts +64 -111
- package/dist/commonjs/write-entry.d.ts.map +1 -1
- package/dist/commonjs/write-entry.js +108 -672
- package/dist/commonjs/write-entry.js.map +1 -1
- package/dist/commonjs/write-flag.d.ts +18 -0
- package/dist/commonjs/write-flag.d.ts.map +1 -0
- package/dist/commonjs/write-flag.js +29 -0
- package/dist/commonjs/write-flag.js.map +1 -0
- package/dist/esm/bytes.d.ts +21 -0
- package/dist/esm/bytes.d.ts.map +1 -0
- package/dist/esm/bytes.js +72 -0
- package/dist/esm/bytes.js.map +1 -0
- package/dist/esm/codec.d.ts +53 -0
- package/dist/esm/codec.d.ts.map +1 -0
- package/dist/esm/codec.js +32 -0
- package/dist/esm/codec.js.map +1 -0
- package/dist/esm/concat.d.ts +3 -0
- package/dist/esm/concat.d.ts.map +1 -0
- package/dist/esm/concat.js +16 -0
- package/dist/esm/concat.js.map +1 -0
- package/dist/esm/create.d.ts +39 -2
- package/dist/esm/create.d.ts.map +1 -1
- package/dist/esm/create.js +144 -61
- package/dist/esm/create.js.map +1 -1
- package/dist/esm/dealias.d.ts +79 -0
- package/dist/esm/dealias.d.ts.map +1 -0
- package/dist/esm/dealias.js +46 -0
- package/dist/esm/dealias.js.map +1 -0
- package/dist/esm/delete.d.ts +19 -0
- package/dist/esm/delete.d.ts.map +1 -0
- package/dist/esm/delete.js +117 -0
- package/dist/esm/delete.js.map +1 -0
- package/dist/esm/entries.d.ts +82 -0
- package/dist/esm/entries.d.ts.map +1 -0
- package/dist/esm/entries.js +388 -0
- package/dist/esm/entries.js.map +1 -0
- package/dist/esm/extract.d.ts +14 -2
- package/dist/esm/extract.d.ts.map +1 -1
- package/dist/esm/extract.js +37 -44
- package/dist/esm/extract.js.map +1 -1
- package/dist/esm/fs.d.ts +201 -0
- package/dist/esm/fs.d.ts.map +1 -0
- package/dist/esm/fs.js +4 -0
- package/dist/esm/fs.js.map +1 -0
- package/dist/esm/header.d.ts +4 -4
- package/dist/esm/header.d.ts.map +1 -1
- package/dist/esm/header.js +38 -42
- package/dist/esm/header.js.map +1 -1
- package/dist/esm/index.d.ts +25 -18
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +23 -18
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.min.js +2 -3
- package/dist/esm/index.min.js.map +4 -4
- package/dist/esm/large-numbers.d.ts +2 -2
- package/dist/esm/large-numbers.d.ts.map +1 -1
- package/dist/esm/large-numbers.js +4 -4
- package/dist/esm/large-numbers.js.map +1 -1
- package/dist/esm/list.d.ts +23 -6
- package/dist/esm/list.d.ts.map +1 -1
- package/dist/esm/list.js +96 -101
- package/dist/esm/list.js.map +1 -1
- package/dist/esm/mkdir.d.ts +16 -11
- package/dist/esm/mkdir.d.ts.map +1 -1
- package/dist/esm/mkdir.js +119 -154
- package/dist/esm/mkdir.js.map +1 -1
- package/dist/esm/options.d.ts +284 -513
- package/dist/esm/options.d.ts.map +1 -1
- package/dist/esm/options.js +17 -51
- package/dist/esm/options.js.map +1 -1
- package/dist/esm/pack.d.ts +150 -96
- package/dist/esm/pack.d.ts.map +1 -1
- package/dist/esm/pack.js +750 -441
- package/dist/esm/pack.js.map +1 -1
- package/dist/esm/parser.d.ts +94 -0
- package/dist/esm/parser.d.ts.map +1 -0
- package/dist/esm/parser.js +377 -0
- package/dist/esm/parser.js.map +1 -0
- package/dist/esm/path-reservations.d.ts +17 -7
- package/dist/esm/path-reservations.d.ts.map +1 -1
- package/dist/esm/path-reservations.js +96 -119
- package/dist/esm/path-reservations.js.map +1 -1
- package/dist/esm/path.d.ts +19 -0
- package/dist/esm/path.d.ts.map +1 -0
- package/dist/esm/path.js +80 -0
- package/dist/esm/path.js.map +1 -0
- package/dist/esm/pax.d.ts +3 -1
- package/dist/esm/pax.d.ts.map +1 -1
- package/dist/esm/pax.js +52 -42
- package/dist/esm/pax.js.map +1 -1
- package/dist/esm/read-entry.d.ts +97 -11
- package/dist/esm/read-entry.d.ts.map +1 -1
- package/dist/esm/read-entry.js +245 -96
- package/dist/esm/read-entry.js.map +1 -1
- package/dist/esm/read-file.d.ts +22 -0
- package/dist/esm/read-file.d.ts.map +1 -0
- package/dist/esm/read-file.js +99 -0
- package/dist/esm/read-file.js.map +1 -0
- package/dist/esm/replace.d.ts +45 -1
- package/dist/esm/replace.d.ts.map +1 -1
- package/dist/esm/replace.js +161 -207
- package/dist/esm/replace.js.map +1 -1
- package/dist/esm/server/codecs.d.ts +38 -0
- package/dist/esm/server/codecs.d.ts.map +1 -0
- package/dist/esm/server/codecs.js +214 -0
- package/dist/esm/server/codecs.js.map +1 -0
- package/dist/esm/server/index.d.ts +115 -0
- package/dist/esm/server/index.d.ts.map +1 -0
- package/dist/esm/server/index.js +102 -0
- package/dist/esm/server/index.js.map +1 -0
- package/dist/esm/server/index.min.js +3 -0
- package/dist/esm/server/index.min.js.map +7 -0
- package/dist/esm/strip-absolute-path.d.ts +8 -0
- package/dist/esm/strip-absolute-path.d.ts.map +1 -1
- package/dist/esm/strip-absolute-path.js +17 -20
- package/dist/esm/strip-absolute-path.js.map +1 -1
- package/dist/esm/to-stream.d.ts +7 -0
- package/dist/esm/to-stream.d.ts.map +1 -0
- package/dist/esm/to-stream.js +18 -0
- package/dist/esm/to-stream.js.map +1 -0
- package/dist/esm/types.d.ts +4 -3
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/types.js +4 -3
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/unpack.d.ts +135 -89
- package/dist/esm/unpack.d.ts.map +1 -1
- package/dist/esm/unpack.js +756 -721
- package/dist/esm/unpack.js.map +1 -1
- package/dist/esm/update.d.ts +11 -1
- package/dist/esm/update.d.ts.map +1 -1
- package/dist/esm/update.js +35 -28
- package/dist/esm/update.js.map +1 -1
- package/dist/esm/warn.d.ts +27 -0
- package/dist/esm/warn.d.ts.map +1 -0
- package/dist/esm/warn.js +31 -0
- package/dist/esm/warn.js.map +1 -0
- package/dist/esm/win32-path.d.ts +16 -0
- package/dist/esm/win32-path.d.ts.map +1 -0
- package/dist/esm/win32-path.js +60 -0
- package/dist/esm/win32-path.js.map +1 -0
- package/dist/esm/write-entry.d.ts +64 -111
- package/dist/esm/write-entry.d.ts.map +1 -1
- package/dist/esm/write-entry.js +107 -633
- package/dist/esm/write-entry.js.map +1 -1
- package/dist/esm/write-flag.d.ts +18 -0
- package/dist/esm/write-flag.d.ts.map +1 -0
- package/dist/esm/write-flag.js +25 -0
- package/dist/esm/write-flag.js.map +1 -0
- package/package.json +68 -224
- package/dist/commonjs/get-write-flag.d.ts +0 -2
- package/dist/commonjs/get-write-flag.d.ts.map +0 -1
- package/dist/commonjs/get-write-flag.js +0 -32
- package/dist/commonjs/get-write-flag.js.map +0 -1
- package/dist/commonjs/make-command.d.ts +0 -49
- package/dist/commonjs/make-command.d.ts.map +0 -1
- package/dist/commonjs/make-command.js +0 -52
- package/dist/commonjs/make-command.js.map +0 -1
- package/dist/commonjs/normalize-windows-path.d.ts +0 -2
- package/dist/commonjs/normalize-windows-path.d.ts.map +0 -1
- package/dist/commonjs/normalize-windows-path.js +0 -12
- package/dist/commonjs/normalize-windows-path.js.map +0 -1
- package/dist/commonjs/parse.d.ts +0 -92
- package/dist/commonjs/parse.d.ts.map +0 -1
- package/dist/commonjs/parse.js +0 -655
- package/dist/commonjs/parse.js.map +0 -1
- package/dist/commonjs/process-umask.d.ts +0 -2
- package/dist/commonjs/process-umask.d.ts.map +0 -1
- package/dist/commonjs/process-umask.js +0 -7
- package/dist/commonjs/process-umask.js.map +0 -1
- package/dist/commonjs/warn-method.d.ts +0 -24
- package/dist/commonjs/warn-method.d.ts.map +0 -1
- package/dist/commonjs/warn-method.js +0 -31
- package/dist/commonjs/warn-method.js.map +0 -1
- package/dist/esm/get-write-flag.d.ts +0 -2
- package/dist/esm/get-write-flag.d.ts.map +0 -1
- package/dist/esm/get-write-flag.js +0 -26
- package/dist/esm/get-write-flag.js.map +0 -1
- package/dist/esm/make-command.d.ts +0 -49
- package/dist/esm/make-command.d.ts.map +0 -1
- package/dist/esm/make-command.js +0 -48
- package/dist/esm/make-command.js.map +0 -1
- package/dist/esm/normalize-windows-path.d.ts +0 -2
- package/dist/esm/normalize-windows-path.d.ts.map +0 -1
- package/dist/esm/normalize-windows-path.js +0 -9
- package/dist/esm/normalize-windows-path.js.map +0 -1
- package/dist/esm/parse.d.ts +0 -92
- package/dist/esm/parse.d.ts.map +0 -1
- package/dist/esm/parse.js +0 -651
- package/dist/esm/parse.js.map +0 -1
- package/dist/esm/process-umask.d.ts +0 -2
- package/dist/esm/process-umask.d.ts.map +0 -1
- package/dist/esm/process-umask.js +0 -3
- package/dist/esm/process-umask.js.map +0 -1
- package/dist/esm/warn-method.d.ts +0 -24
- package/dist/esm/warn-method.d.ts.map +0 -1
- package/dist/esm/warn-method.js +0 -27
- package/dist/esm/warn-method.js.map +0 -1
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Transform } from 'node:stream';
|
|
2
|
+
import * as nodeZlib from 'node:zlib';
|
|
3
|
+
import type { Codec, CodecStream } from '../codec.js';
|
|
4
|
+
/**
|
|
5
|
+
* The functions of `node:zlib` that the codecs use. A runtime can
|
|
6
|
+
* have no brotli functions or no zstd functions.
|
|
7
|
+
*/
|
|
8
|
+
export type ZlibModule = Pick<typeof nodeZlib, 'createGzip' | 'createGunzip' | 'gzipSync' | 'gunzipSync'> & Partial<Pick<typeof nodeZlib, 'createBrotliCompress' | 'createBrotliDecompress' | 'brotliCompressSync' | 'brotliDecompressSync' | 'createZstdCompress' | 'createZstdDecompress' | 'zstdCompressSync' | 'zstdDecompressSync'>>;
|
|
9
|
+
/**
|
|
10
|
+
* Make the two web streams of a `node:zlib` stream, or of another
|
|
11
|
+
* `Transform` stream of `node:stream`. The result fits the
|
|
12
|
+
* `transform` option of `extract`.
|
|
13
|
+
*
|
|
14
|
+
* As with a `TransformStream`, a write is complete only when the
|
|
15
|
+
* reader asks for more output than the stream has. The zlib stream
|
|
16
|
+
* makes output only until its buffer is full. So the reader of an
|
|
17
|
+
* archive can stop before more is decompressed.
|
|
18
|
+
*
|
|
19
|
+
* @param batch put small chunks of input together for one write.
|
|
20
|
+
* Each write is a task for a thread.
|
|
21
|
+
* @param first called with the first chunk of output
|
|
22
|
+
*/
|
|
23
|
+
export declare const codecStream: (stream: Transform, batch?: boolean, first?: (chunk: Uint8Array) => void) => CodecStream;
|
|
24
|
+
/**
|
|
25
|
+
* The codecs of a `node:zlib` module: gzip, then brotli and zstd if
|
|
26
|
+
* the module has their functions.
|
|
27
|
+
*
|
|
28
|
+
* The value of a `gzip`, `brotli`, or `zstd` option of `create` goes
|
|
29
|
+
* to the zlib function as its options. A gzip codec reads the tar
|
|
30
|
+
* option `portable` in its options: it makes output that does not
|
|
31
|
+
* name the system.
|
|
32
|
+
*
|
|
33
|
+
* A brotli archive has no magic number. The readers use the brotli
|
|
34
|
+
* codec for a file with a name that ends in `.tar.br` or `.tbr`, if
|
|
35
|
+
* the file does not start with a tar header.
|
|
36
|
+
*/
|
|
37
|
+
export declare const zlibCodecs: (z?: ZlibModule) => Codec[];
|
|
38
|
+
//# sourceMappingURL=codecs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codecs.d.ts","sourceRoot":"","sources":["../../../src/server/codecs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,KAAK,QAAQ,MAAM,WAAW,CAAA;AACrC,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAErD;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,IAAI,CAC3B,OAAO,QAAQ,EACf,YAAY,GAAG,cAAc,GAAG,UAAU,GAAG,YAAY,CAC1D,GACC,OAAO,CACL,IAAI,CACF,OAAO,QAAQ,EACb,sBAAsB,GACtB,wBAAwB,GACxB,oBAAoB,GACpB,sBAAsB,GACtB,oBAAoB,GACpB,sBAAsB,GACtB,kBAAkB,GAClB,oBAAoB,CACvB,CACF,CAAA;AAQH;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,WAAW,GACtB,QAAQ,SAAS,EACjB,QAAO,OAAe,EACtB,QAAQ,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,KAClC,WAyGF,CAAA;AAwCD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,UAAU,GAAI,IAAG,UAAqB,KAAG,KAAK,EAgF1D,CAAA"}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { constants } from 'node:buffer';
|
|
2
|
+
import * as nodeZlib from 'node:zlib';
|
|
3
|
+
// The size of each chunk of decompressed output, and the size below
|
|
4
|
+
// which chunks of input to compress are put together.
|
|
5
|
+
const CHUNK = 64 * 1024;
|
|
6
|
+
/**
|
|
7
|
+
* Make the two web streams of a `node:zlib` stream, or of another
|
|
8
|
+
* `Transform` stream of `node:stream`. The result fits the
|
|
9
|
+
* `transform` option of `extract`.
|
|
10
|
+
*
|
|
11
|
+
* As with a `TransformStream`, a write is complete only when the
|
|
12
|
+
* reader asks for more output than the stream has. The zlib stream
|
|
13
|
+
* makes output only until its buffer is full. So the reader of an
|
|
14
|
+
* archive can stop before more is decompressed.
|
|
15
|
+
*
|
|
16
|
+
* @param batch put small chunks of input together for one write.
|
|
17
|
+
* Each write is a task for a thread.
|
|
18
|
+
* @param first called with the first chunk of output
|
|
19
|
+
*/
|
|
20
|
+
export const codecStream = (stream, batch = false, first) => {
|
|
21
|
+
let output;
|
|
22
|
+
let input;
|
|
23
|
+
// True while the reader waits for output.
|
|
24
|
+
let wanted = false;
|
|
25
|
+
// True when the zlib stream is closed.
|
|
26
|
+
let done = false;
|
|
27
|
+
// settles the write or the close that waits for the zlib stream
|
|
28
|
+
let settle;
|
|
29
|
+
// settles the write that waits for the reader
|
|
30
|
+
let wake;
|
|
31
|
+
const held = batch ? new Uint8Array(CHUNK) : undefined;
|
|
32
|
+
let used = 0;
|
|
33
|
+
const write = (chunk) => new Promise(res => {
|
|
34
|
+
settle = res;
|
|
35
|
+
stream.write(chunk, () => res());
|
|
36
|
+
});
|
|
37
|
+
const flush = async (held) => {
|
|
38
|
+
if (used)
|
|
39
|
+
await write(held.subarray(0, used));
|
|
40
|
+
used = 0;
|
|
41
|
+
};
|
|
42
|
+
// A write has no callback when the zlib stream fails or is
|
|
43
|
+
// destroyed.
|
|
44
|
+
const release = () => {
|
|
45
|
+
done = true;
|
|
46
|
+
settle?.();
|
|
47
|
+
wake?.();
|
|
48
|
+
};
|
|
49
|
+
const stop = () => {
|
|
50
|
+
release();
|
|
51
|
+
stream.destroy();
|
|
52
|
+
};
|
|
53
|
+
stream.pause();
|
|
54
|
+
stream.on('data', (chunk) => {
|
|
55
|
+
first?.(chunk);
|
|
56
|
+
first = undefined;
|
|
57
|
+
wanted = false;
|
|
58
|
+
stream.pause();
|
|
59
|
+
output.enqueue(chunk);
|
|
60
|
+
});
|
|
61
|
+
// On Deno, a zlib stream that already has all its output emits
|
|
62
|
+
// 'end' after it is destroyed. The output is then closed already.
|
|
63
|
+
stream.on('end', () => {
|
|
64
|
+
if (!done)
|
|
65
|
+
output.close();
|
|
66
|
+
});
|
|
67
|
+
stream.on('error', er => {
|
|
68
|
+
output.error(er);
|
|
69
|
+
input.error(er);
|
|
70
|
+
release();
|
|
71
|
+
});
|
|
72
|
+
stream.on('close', release);
|
|
73
|
+
return {
|
|
74
|
+
readable: new ReadableStream({
|
|
75
|
+
start: controller => {
|
|
76
|
+
output = controller;
|
|
77
|
+
},
|
|
78
|
+
pull: () => {
|
|
79
|
+
wanted = true;
|
|
80
|
+
wake?.();
|
|
81
|
+
stream.resume();
|
|
82
|
+
},
|
|
83
|
+
cancel: reason => {
|
|
84
|
+
// Stop the source of the input also.
|
|
85
|
+
input.error(reason);
|
|
86
|
+
stop();
|
|
87
|
+
},
|
|
88
|
+
}, { highWaterMark: 0 }),
|
|
89
|
+
writable: new WritableStream({
|
|
90
|
+
start: controller => {
|
|
91
|
+
input = controller;
|
|
92
|
+
// An abort does not wait for a write that waits.
|
|
93
|
+
const { signal } = controller;
|
|
94
|
+
signal.addEventListener('abort', () => {
|
|
95
|
+
output.error(signal.reason);
|
|
96
|
+
stop();
|
|
97
|
+
});
|
|
98
|
+
},
|
|
99
|
+
write: async (chunk) => {
|
|
100
|
+
if (!held)
|
|
101
|
+
await write(chunk);
|
|
102
|
+
else {
|
|
103
|
+
if (used + chunk.length > CHUNK)
|
|
104
|
+
await flush(held);
|
|
105
|
+
if (chunk.length > CHUNK)
|
|
106
|
+
await write(chunk);
|
|
107
|
+
else {
|
|
108
|
+
held.set(chunk, used);
|
|
109
|
+
used += chunk.length;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// As with a `TransformStream`, the write waits until the
|
|
113
|
+
// reader wants output. Then a pipe from the source does not
|
|
114
|
+
// start a write to a stream that the reader canceled.
|
|
115
|
+
if (!wanted && !done)
|
|
116
|
+
await new Promise(res => (wake = res));
|
|
117
|
+
},
|
|
118
|
+
close: async () => {
|
|
119
|
+
if (held)
|
|
120
|
+
await flush(held);
|
|
121
|
+
await new Promise(res => {
|
|
122
|
+
settle = res;
|
|
123
|
+
stream.end();
|
|
124
|
+
});
|
|
125
|
+
},
|
|
126
|
+
}),
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
// The option of the sync functions that limits the output. They
|
|
130
|
+
// refuse a number that is not in the range of a buffer length.
|
|
131
|
+
const limit = (max) => max >= constants.MAX_LENGTH ?
|
|
132
|
+
{}
|
|
133
|
+
: { maxOutputLength: Math.max(1, Math.floor(max)) };
|
|
134
|
+
const make = (base, compress, decompress, compressSync, decompressSync) => ({
|
|
135
|
+
...base,
|
|
136
|
+
decompress: () => codecStream(decompress({ chunkSize: CHUNK })),
|
|
137
|
+
compress: options => codecStream(compress(options), true),
|
|
138
|
+
decompressSync: (data, { maxOutputLength }) => {
|
|
139
|
+
try {
|
|
140
|
+
return decompressSync(data, limit(maxOutputLength));
|
|
141
|
+
}
|
|
142
|
+
catch (er) {
|
|
143
|
+
if (er?.code !== 'ERR_BUFFER_TOO_LARGE') {
|
|
144
|
+
throw er;
|
|
145
|
+
}
|
|
146
|
+
throw new Error(`max decompression ratio exceeded: the output is larger than ${maxOutputLength} bytes`);
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
compressSync,
|
|
150
|
+
});
|
|
151
|
+
// Byte 9 of a gzip stream names the system that made it. Set it to
|
|
152
|
+
// 255, "unknown", so that each system makes the same bytes.
|
|
153
|
+
const portable = (chunk) => {
|
|
154
|
+
chunk[9] = 255;
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* The codecs of a `node:zlib` module: gzip, then brotli and zstd if
|
|
158
|
+
* the module has their functions.
|
|
159
|
+
*
|
|
160
|
+
* The value of a `gzip`, `brotli`, or `zstd` option of `create` goes
|
|
161
|
+
* to the zlib function as its options. A gzip codec reads the tar
|
|
162
|
+
* option `portable` in its options: it makes output that does not
|
|
163
|
+
* name the system.
|
|
164
|
+
*
|
|
165
|
+
* A brotli archive has no magic number. The readers use the brotli
|
|
166
|
+
* codec for a file with a name that ends in `.tar.br` or `.tbr`, if
|
|
167
|
+
* the file does not start with a tar header.
|
|
168
|
+
*/
|
|
169
|
+
export const zlibCodecs = (z = nodeZlib) => {
|
|
170
|
+
const { createBrotliCompress, createBrotliDecompress, brotliCompressSync, brotliDecompressSync, createZstdCompress, createZstdDecompress, zstdCompressSync, zstdDecompressSync, } = z;
|
|
171
|
+
const gzip = make({
|
|
172
|
+
name: 'gzip',
|
|
173
|
+
headLength: 2,
|
|
174
|
+
detect: head => head[0] === 0x1f && head[1] === 0x8b,
|
|
175
|
+
}, z.createGzip, z.createGunzip, z.gzipSync, z.gunzipSync);
|
|
176
|
+
const codecs = [
|
|
177
|
+
{
|
|
178
|
+
...gzip,
|
|
179
|
+
compress: ({ portable: p, ...options } = {}) => codecStream(z.createGzip(options), true, p ? portable : undefined),
|
|
180
|
+
compressSync: (data, { portable: p, ...options } = {}) => {
|
|
181
|
+
const out = z.gzipSync(data, options);
|
|
182
|
+
if (p)
|
|
183
|
+
portable(out);
|
|
184
|
+
return out;
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
];
|
|
188
|
+
if (createBrotliCompress &&
|
|
189
|
+
createBrotliDecompress &&
|
|
190
|
+
brotliCompressSync &&
|
|
191
|
+
brotliDecompressSync) {
|
|
192
|
+
codecs.push(make({
|
|
193
|
+
name: 'brotli',
|
|
194
|
+
headLength: 0,
|
|
195
|
+
detect: () => false,
|
|
196
|
+
extensions: ['.tar.br', '.tbr'],
|
|
197
|
+
}, createBrotliCompress, createBrotliDecompress, brotliCompressSync, brotliDecompressSync));
|
|
198
|
+
}
|
|
199
|
+
if (createZstdCompress &&
|
|
200
|
+
createZstdDecompress &&
|
|
201
|
+
zstdCompressSync &&
|
|
202
|
+
zstdDecompressSync) {
|
|
203
|
+
codecs.push(make({
|
|
204
|
+
name: 'zstd',
|
|
205
|
+
headLength: 4,
|
|
206
|
+
detect: head => head[0] === 0x28 &&
|
|
207
|
+
head[1] === 0xb5 &&
|
|
208
|
+
head[2] === 0x2f &&
|
|
209
|
+
head[3] === 0xfd,
|
|
210
|
+
}, createZstdCompress, createZstdDecompress, zstdCompressSync, zstdDecompressSync));
|
|
211
|
+
}
|
|
212
|
+
return codecs;
|
|
213
|
+
};
|
|
214
|
+
//# sourceMappingURL=codecs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codecs.js","sourceRoot":"","sources":["../../../src/server/codecs.ts"],"names":[],"mappings":"AAAA,OAAO,EA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tB,kBAAkB;QAClB,oBAAoB,EACpB,CAAC;QACD,MAAM,CAAC,IAAI,CACT,IAAI,CACF;YACE,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE,CAAC;YACb,MAAM,EAAE,GAAG,EAAE,CAAC,KAAK;YACnB,UAAU,EAAE,CAAC,SAAS,EAAE,MAAM,CAAC;SAChC,EACD,oBAAoB,EACpB,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,CACrB,CACF,CAAA;IACH,CAAC;IACD,IACE,kBAAkB;QAClB,oBAAoB;QACpB,gBAAgB;QAChB,kBAAkB,EAClB,CAAC;QACD,MAAM,CAAC,IAAI,CACT,IAAI,CACF;YACE,IAAI,EAAE,MAAM;YACZ,UAAU,EAAE,CAAC;YACb,MAAM,EAAE,IAAI,CAAC,EAAE,CACb,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI;gBAChB,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI;gBAChB,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI;gBAChB,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI;SACnB,EACD,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,kBAAkB,CACnB,CACF,CAAA;IACH,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC,CAAA","sourcesContent":["import { constants } from 'node:buffer'\nimport type { Transform } from 'node:stream'\nimport * as nodeZlib from 'node:zlib'\nimport type { Codec, CodecStream } from '../codec.js'\n\n/**\n * The functions of `node:zlib` that the codecs use. A runtime can\n * have no brotli functions or no zstd functions.\n */\nexport type ZlibModule = Pick<\n typeof nodeZlib,\n 'createGzip' | 'createGunzip' | 'gzipSync' | 'gunzipSync'\n> &\n Partial<\n Pick<\n typeof nodeZlib,\n | 'createBrotliCompress'\n | 'createBrotliDecompress'\n | 'brotliCompressSync'\n | 'brotliDecompressSync'\n | 'createZstdCompress'\n | 'createZstdDecompress'\n | 'zstdCompressSync'\n | 'zstdDecompressSync'\n >\n >\n\ntype Options = Record<string, unknown>\n\n// The size of each chunk of decompressed output, and the size below\n// which chunks of input to compress are put together.\nconst CHUNK = 64 * 1024\n\n/**\n * Make the two web streams of a `node:zlib` stream, or of another\n * `Transform` stream of `node:stream`. The result fits the\n * `transform` option of `extract`.\n *\n * As with a `TransformStream`, a write is complete only when the\n * reader asks for more output than the stream has. The zlib stream\n * makes output only until its buffer is full. So the reader of an\n * archive can stop before more is decompressed.\n *\n * @param batch put small chunks of input together for one write.\n * Each write is a task for a thread.\n * @param first called with the first chunk of output\n */\nexport const codecStream = (\n stream: Transform,\n batch: boolean = false,\n first?: (chunk: Uint8Array) => void,\n): CodecStream => {\n let output!: ReadableStreamDefaultController<Uint8Array>\n let input!: WritableStreamDefaultController\n // True while the reader waits for output.\n let wanted = false\n // True when the zlib stream is closed.\n let done = false\n // settles the write or the close that waits for the zlib stream\n let settle: (() => void) | undefined\n // settles the write that waits for the reader\n let wake: (() => void) | undefined\n const held = batch ? new Uint8Array(CHUNK) : undefined\n let used = 0\n const write = (chunk: Uint8Array) =>\n new Promise<void>(res => {\n settle = res\n stream.write(chunk, () => res())\n })\n const flush = async (held: Uint8Array) => {\n if (used) await write(held.subarray(0, used))\n used = 0\n }\n // A write has no callback when the zlib stream fails or is\n // destroyed.\n const release = () => {\n done = true\n settle?.()\n wake?.()\n }\n const stop = () => {\n release()\n stream.destroy()\n }\n stream.pause()\n stream.on('data', (chunk: Uint8Array) => {\n first?.(chunk)\n first = undefined\n wanted = false\n stream.pause()\n output.enqueue(chunk)\n })\n // On Deno, a zlib stream that already has all its output emits\n // 'end' after it is destroyed. The output is then closed already.\n stream.on('end', () => {\n if (!done) output.close()\n })\n stream.on('error', er => {\n output.error(er)\n input.error(er)\n release()\n })\n stream.on('close', release)\n return {\n readable: new ReadableStream<Uint8Array>(\n {\n start: controller => {\n output = controller\n },\n pull: () => {\n wanted = true\n wake?.()\n stream.resume()\n },\n cancel: reason => {\n // Stop the source of the input also.\n input.error(reason)\n stop()\n },\n },\n { highWaterMark: 0 },\n ),\n writable: new WritableStream<Uint8Array>({\n start: controller => {\n input = controller\n // An abort does not wait for a write that waits.\n const { signal } = controller\n signal.addEventListener('abort', () => {\n output.error(signal.reason)\n stop()\n })\n },\n write: async chunk => {\n if (!held) await write(chunk)\n else {\n if (used + chunk.length > CHUNK) await flush(held)\n if (chunk.length > CHUNK) await write(chunk)\n else {\n held.set(chunk, used)\n used += chunk.length\n }\n }\n // As with a `TransformStream`, the write waits until the\n // reader wants output. Then a pipe from the source does not\n // start a write to a stream that the reader canceled.\n if (!wanted && !done) await new Promise<void>(res => (wake = res))\n },\n close: async () => {\n if (held) await flush(held)\n await new Promise<void>(res => {\n settle = res\n stream.end()\n })\n },\n }),\n }\n}\n\n// The option of the sync functions that limits the output. They\n// refuse a number that is not in the range of a buffer length.\nconst limit = (max: number) =>\n max >= constants.MAX_LENGTH ?\n {}\n : { maxOutputLength: Math.max(1, Math.floor(max)) }\n\nconst make = (\n base: Pick<Codec, 'name' | 'headLength' | 'detect' | 'extensions'>,\n compress: (options?: Options) => Transform,\n decompress: (options: Options) => Transform,\n compressSync: (data: Uint8Array, options?: Options) => Uint8Array,\n decompressSync: (data: Uint8Array, options: Options) => Uint8Array,\n): Codec => ({\n ...base,\n decompress: () => codecStream(decompress({ chunkSize: CHUNK })),\n compress: options => codecStream(compress(options), true),\n decompressSync: (data, { maxOutputLength }) => {\n try {\n return decompressSync(data, limit(maxOutputLength))\n } catch (er) {\n if ((er as { code?: string })?.code !== 'ERR_BUFFER_TOO_LARGE') {\n throw er\n }\n throw new Error(\n `max decompression ratio exceeded: the output is larger than ${maxOutputLength} bytes`,\n )\n }\n },\n compressSync,\n})\n\n// Byte 9 of a gzip stream names the system that made it. Set it to\n// 255, \"unknown\", so that each system makes the same bytes.\nconst portable = (chunk: Uint8Array) => {\n chunk[9] = 255\n}\n\n/**\n * The codecs of a `node:zlib` module: gzip, then brotli and zstd if\n * the module has their functions.\n *\n * The value of a `gzip`, `brotli`, or `zstd` option of `create` goes\n * to the zlib function as its options. A gzip codec reads the tar\n * option `portable` in its options: it makes output that does not\n * name the system.\n *\n * A brotli archive has no magic number. The readers use the brotli\n * codec for a file with a name that ends in `.tar.br` or `.tbr`, if\n * the file does not start with a tar header.\n */\nexport const zlibCodecs = (z: ZlibModule = nodeZlib): Codec[] => {\n const {\n createBrotliCompress,\n createBrotliDecompress,\n brotliCompressSync,\n brotliDecompressSync,\n createZstdCompress,\n createZstdDecompress,\n zstdCompressSync,\n zstdDecompressSync,\n } = z\n const gzip = make(\n {\n name: 'gzip',\n headLength: 2,\n detect: head => head[0] === 0x1f && head[1] === 0x8b,\n },\n z.createGzip,\n z.createGunzip,\n z.gzipSync,\n z.gunzipSync,\n )\n const codecs: Codec[] = [\n {\n ...gzip,\n compress: ({ portable: p, ...options }: Options = {}) =>\n codecStream(z.createGzip(options), true, p ? portable : undefined),\n compressSync: (data, { portable: p, ...options }: Options = {}) => {\n const out = z.gzipSync(data, options)\n if (p) portable(out)\n return out\n },\n },\n ]\n if (\n createBrotliCompress &&\n createBrotliDecompress &&\n brotliCompressSync &&\n brotliDecompressSync\n ) {\n codecs.push(\n make(\n {\n name: 'brotli',\n headLength: 0,\n detect: () => false,\n extensions: ['.tar.br', '.tbr'],\n },\n createBrotliCompress,\n createBrotliDecompress,\n brotliCompressSync,\n brotliDecompressSync,\n ),\n )\n }\n if (\n createZstdCompress &&\n createZstdDecompress &&\n zstdCompressSync &&\n zstdDecompressSync\n ) {\n codecs.push(\n make(\n {\n name: 'zstd',\n headLength: 4,\n detect: head =>\n head[0] === 0x28 &&\n head[1] === 0xb5 &&\n head[2] === 0x2f &&\n head[3] === 0xfd,\n },\n createZstdCompress,\n createZstdDecompress,\n zstdCompressSync,\n zstdDecompressSync,\n ),\n )\n }\n return codecs\n}\n"]}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { BrotliOptions, ZlibOptions, ZstdOptions } from 'node:zlib';
|
|
2
|
+
import * as core from '../index.js';
|
|
3
|
+
import { type FileOption, type NoFileOption, type WithAliases } from '../dealias.js';
|
|
4
|
+
import type { PackInput, PackInputSync } from '../pack.js';
|
|
5
|
+
import type { ReadEntry, ReadEntrySync } from '../read-entry.js';
|
|
6
|
+
export * from '../index.js';
|
|
7
|
+
export { TarReaderSync } from '../entries.js';
|
|
8
|
+
export { PackSync } from '../pack.js';
|
|
9
|
+
export { ReadEntrySync } from '../read-entry.js';
|
|
10
|
+
export { UnpackSync } from '../unpack.js';
|
|
11
|
+
export { zlibCodecs, codecStream, type ZlibModule } from './codecs.js';
|
|
12
|
+
/** Each member of the option type `T`, with `fs` and `cwd` optional. */
|
|
13
|
+
export type Loose<T> = T extends unknown ? Omit<T, 'fs' | 'cwd'> & Partial<Pick<T, Extract<keyof T, 'fs' | 'cwd'>>> : never;
|
|
14
|
+
/** The compression options, with the option types of `node:zlib`. */
|
|
15
|
+
export type Zip = {
|
|
16
|
+
/** Compress with gzip. An object is the options of `zlib.createGzip`. */
|
|
17
|
+
gzip?: boolean | ZlibOptions;
|
|
18
|
+
/**
|
|
19
|
+
* Compress with brotli. An object is the options of
|
|
20
|
+
* `zlib.createBrotliCompress`.
|
|
21
|
+
*/
|
|
22
|
+
brotli?: boolean | BrotliOptions;
|
|
23
|
+
/**
|
|
24
|
+
* Compress with zstd. An object is the options of
|
|
25
|
+
* `zlib.createZstdCompress`.
|
|
26
|
+
*/
|
|
27
|
+
zstd?: boolean | ZstdOptions;
|
|
28
|
+
};
|
|
29
|
+
/** `Loose<T>`, with the compression options of `Zip`. */
|
|
30
|
+
export type Packing<T> = Omit<Loose<T>, keyof Zip> & Zip;
|
|
31
|
+
/** The options of `entries`. */
|
|
32
|
+
export type ReadOptions = core.ReadOptions;
|
|
33
|
+
/** The options of `entriesSync`. */
|
|
34
|
+
export type ReadOptionsSync = core.ReadOptionsSync;
|
|
35
|
+
/** The options of `list`. Set `input` or `file`. */
|
|
36
|
+
export type ListOptions = Loose<core.ListOptions>;
|
|
37
|
+
/** The options of `listSync`. Set `input` or `file`. */
|
|
38
|
+
export type ListOptionsSync = Loose<core.ListOptionsSync>;
|
|
39
|
+
/** The options of `extract`. The default of `cwd` is `process.cwd()`. */
|
|
40
|
+
export type ExtractOptions = Loose<core.ExtractOptions>;
|
|
41
|
+
/** The options of `extractSync`. */
|
|
42
|
+
export type ExtractOptionsSync = Loose<core.ExtractOptionsSync>;
|
|
43
|
+
/** The options of `create`. The default of `cwd` is `process.cwd()`. */
|
|
44
|
+
export type CreateOptions = Packing<core.CreateOptions>;
|
|
45
|
+
/** The options of `createSync`. */
|
|
46
|
+
export type CreateOptionsSync = Packing<core.CreateOptionsSync>;
|
|
47
|
+
/** The options of `replace` and `update`. */
|
|
48
|
+
export type ReplaceOptions = Packing<core.ReplaceOptions>;
|
|
49
|
+
/** The options of `replaceSync` and `updateSync`. */
|
|
50
|
+
export type ReplaceOptionsSync = Packing<core.ReplaceOptionsSync>;
|
|
51
|
+
/** The options of `delete`. */
|
|
52
|
+
export type DeleteOptions = Loose<core.DeleteOptions>;
|
|
53
|
+
/** The options of `deleteSync`. */
|
|
54
|
+
export type DeleteOptionsSync = Loose<core.DeleteOptionsSync>;
|
|
55
|
+
/**
|
|
56
|
+
* Read the entries of an archive. Gzip, brotli, and zstd input is
|
|
57
|
+
* decompressed, if the runtime has the format.
|
|
58
|
+
*/
|
|
59
|
+
export declare const entries: (input: core.TarInput, opt?: ReadOptions) => AsyncIterableIterator<ReadEntry, undefined>;
|
|
60
|
+
/** The sync form of `entries`. */
|
|
61
|
+
export declare const entriesSync: (input: core.TarInputSync, opt?: ReadOptionsSync) => IterableIterator<ReadEntrySync, undefined>;
|
|
62
|
+
/**
|
|
63
|
+
* Call `opt.onEntry` with each entry of an archive. If `files` is
|
|
64
|
+
* set, only with the entries that it lists, and the entries in the
|
|
65
|
+
* directories that it lists.
|
|
66
|
+
*/
|
|
67
|
+
export declare const list: (opt: WithAliases<ListOptions>, files?: string[]) => Promise<void>;
|
|
68
|
+
/** The sync form of `list`. */
|
|
69
|
+
export declare const listSync: (opt: WithAliases<ListOptionsSync>, files?: string[]) => void;
|
|
70
|
+
/**
|
|
71
|
+
* Extract the entries of an archive into the directory `opt.cwd`.
|
|
72
|
+
* If `files` is set, only the entries that it lists, and the entries
|
|
73
|
+
* in the directories that it lists.
|
|
74
|
+
*/
|
|
75
|
+
export declare const extract: (opt: WithAliases<ExtractOptions>, files?: string[]) => Promise<void>;
|
|
76
|
+
/** The sync form of `extract`. */
|
|
77
|
+
export declare const extractSync: (opt: WithAliases<ExtractOptionsSync>, files?: string[]) => void;
|
|
78
|
+
/**
|
|
79
|
+
* Make an archive of the files. With `opt.file`, the archive is
|
|
80
|
+
* written to that path. With no `opt.file`, the result is a stream
|
|
81
|
+
* of the bytes of the archive.
|
|
82
|
+
*/
|
|
83
|
+
export declare function create(opt: WithAliases<CreateOptions> & FileOption, files: PackInput[]): Promise<void>;
|
|
84
|
+
export declare function create(opt: WithAliases<CreateOptions> & NoFileOption, files: PackInput[]): ReadableStream<Uint8Array>;
|
|
85
|
+
export declare function create(opt: WithAliases<CreateOptions>, files: PackInput[]): Promise<void> | ReadableStream<Uint8Array>;
|
|
86
|
+
/**
|
|
87
|
+
* The sync form of `create`. With no `opt.file`, the result is an
|
|
88
|
+
* iterator of the bytes of the archive.
|
|
89
|
+
*/
|
|
90
|
+
export declare function createSync(opt: WithAliases<CreateOptionsSync> & FileOption, files: PackInputSync[]): void;
|
|
91
|
+
export declare function createSync(opt: WithAliases<CreateOptionsSync> & NoFileOption, files: PackInputSync[]): IterableIterator<Uint8Array, undefined>;
|
|
92
|
+
export declare function createSync(opt: WithAliases<CreateOptionsSync>, files: PackInputSync[]): void | IterableIterator<Uint8Array, undefined>;
|
|
93
|
+
/** Add the files to the end of an archive file that is not compressed. */
|
|
94
|
+
export declare const replace: (opt: WithAliases<ReplaceOptions>, files: PackInput[]) => Promise<void>;
|
|
95
|
+
/** The sync form of `replace`. */
|
|
96
|
+
export declare const replaceSync: (opt: WithAliases<ReplaceOptionsSync>, files: PackInputSync[]) => void;
|
|
97
|
+
/**
|
|
98
|
+
* The same as `replace`, but a file is added only if it is newer than
|
|
99
|
+
* the last entry of the archive that has its path. A directory is
|
|
100
|
+
* always added, and each path in it is checked.
|
|
101
|
+
*/
|
|
102
|
+
export declare const update: (opt: WithAliases<ReplaceOptions>, files: PackInput[]) => Promise<void>;
|
|
103
|
+
/** The sync form of `update`. */
|
|
104
|
+
export declare const updateSync: (opt: WithAliases<ReplaceOptionsSync>, files: PackInputSync[]) => void;
|
|
105
|
+
/**
|
|
106
|
+
* Remove entries from an archive file: each entry that `files` lists,
|
|
107
|
+
* and each entry in a directory that it lists. With `opt.filter`,
|
|
108
|
+
* only if the filter also returns true.
|
|
109
|
+
*/
|
|
110
|
+
declare const del: (opt: WithAliases<DeleteOptions>, files?: string[]) => Promise<void>;
|
|
111
|
+
/** The sync form of `delete`. */
|
|
112
|
+
export declare const deleteSync: (opt: WithAliases<DeleteOptionsSync>, files?: string[]) => void;
|
|
113
|
+
export { del as delete };
|
|
114
|
+
export { create as c, extract as x, list as t, replace as r, update as u };
|
|
115
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAExE,OAAO,KAAK,IAAI,MAAM,aAAa,CAAA;AAGnC,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,WAAW,EACjB,MAAM,eAAe,CAAA;AAItB,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAKhE,cAAc,aAAa,CAAA;AAC3B,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAA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AAE,KACjB,OAAO,CAAC,IAAI,CAA6C,CAAA;AAE5D,kCAAkC;AAClC,eAAO,MAAM,WAAW,GACtB,KAAK,WAAW,CAAC,kBAAkB,CAAC,EACpC,OAAO,aAAa,EAAE,KACrB,IAAuD,CAAA;AAE1D;;;;GAIG;AACH,eAAO,MAAM,MAAM,GACjB,KAAK,WAAW,CAAC,cAAc,CAAC,EAChC,OAAO,SAAS,EAAE,KACjB,OAAO,CAAC,IAAI,CAA4C,CAAA;AAE3D,iCAAiC;AACjC,eAAO,MAAM,UAAU,GACrB,KAAK,WAAW,CAAC,kBAAkB,CAAC,EACpC,OAAO,aAAa,EAAE,KACrB,IAAsD,CAAA;AAEzD;;;;GAIG;AACH,QAAA,MAAM,GAAG,GACP,KAAK,WAAW,CAAC,aAAa,CAAC,EAC/B,QAAQ,MAAM,EAAE,KACf,OAAO,CAAC,IAAI,CAA6C,CAAA;AAE5D,iCAAiC;AACjC,eAAO,MAAM,UAAU,GACrB,KAAK,WAAW,CAAC,iBAAiB,CAAC,EACnC,QAAQ,MAAM,EAAE,KACf,IAAuD,CAAA;AAE1D,OAAO,EAAE,GAAG,IAAI,MAAM,EAAE,CAAA;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,OAAO,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,EAAE,OAAO,IAAI,CAAC,EAAE,MAAM,IAAI,CAAC,EAAE,CAAA"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// The entry point for Node.js, and for each runtime that has the
|
|
2
|
+
// `node:` modules. It has all that the core entry point has. Each
|
|
3
|
+
// command gets defaults for the options that the core cannot know:
|
|
4
|
+
// the file system, the working directory, the platform, the user of
|
|
5
|
+
// the process, and the codecs of `node:zlib`. It adds the sync
|
|
6
|
+
// commands.
|
|
7
|
+
import * as nodeFs from 'node:fs';
|
|
8
|
+
import * as nodeFsPromises from 'node:fs/promises';
|
|
9
|
+
import { resolve } from 'node:path';
|
|
10
|
+
import * as core from '../index.js';
|
|
11
|
+
import { createSync as coreCreateSync } from '../create.js';
|
|
12
|
+
import { deleteSync as coreDeleteSync } from '../delete.js';
|
|
13
|
+
import { dealias, } from '../dealias.js';
|
|
14
|
+
import { entriesSync as coreEntriesSync } from '../entries.js';
|
|
15
|
+
import { extractSync as coreExtractSync } from '../extract.js';
|
|
16
|
+
import { listSync as coreListSync } from '../list.js';
|
|
17
|
+
import { replaceSync as coreReplaceSync } from '../replace.js';
|
|
18
|
+
import { updateSync as coreUpdateSync } from '../update.js';
|
|
19
|
+
import { zlibCodecs } from './codecs.js';
|
|
20
|
+
export * from '../index.js';
|
|
21
|
+
export { TarReaderSync } from '../entries.js';
|
|
22
|
+
export { PackSync } from '../pack.js';
|
|
23
|
+
export { ReadEntrySync } from '../read-entry.js';
|
|
24
|
+
export { UnpackSync } from '../unpack.js';
|
|
25
|
+
export { zlibCodecs, codecStream } from './codecs.js';
|
|
26
|
+
const fs = nodeFsPromises;
|
|
27
|
+
const fsSync = nodeFs;
|
|
28
|
+
const platform = process.platform === 'win32' ? 'win32' : 'posix';
|
|
29
|
+
const codecs = zlibCodecs();
|
|
30
|
+
// A copy of the options, with the name of the option in place of
|
|
31
|
+
// each alias, and a default for each option that is not set. `T` is
|
|
32
|
+
// the option type of the core command.
|
|
33
|
+
const fill = (options, fs, paths) => {
|
|
34
|
+
const opt = dealias(options);
|
|
35
|
+
opt.fs ??= fs;
|
|
36
|
+
opt.platform ??= platform;
|
|
37
|
+
opt.codecs = [...(opt.codecs ?? []), ...codecs];
|
|
38
|
+
// A command that reads an archive, and writes no file, does not
|
|
39
|
+
// need the working directory or the user.
|
|
40
|
+
if (paths) {
|
|
41
|
+
// `resolve` adds `process.cwd()` to a relative path.
|
|
42
|
+
opt.cwd = resolve(opt.cwd ?? '');
|
|
43
|
+
opt.processUid ??= process.getuid?.();
|
|
44
|
+
opt.processGid ??= process.getgid?.();
|
|
45
|
+
opt.processUname ??= process.env.USER;
|
|
46
|
+
if (opt.chmod)
|
|
47
|
+
opt.processUmask ??= process.umask();
|
|
48
|
+
}
|
|
49
|
+
return opt;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Read the entries of an archive. Gzip, brotli, and zstd input is
|
|
53
|
+
* decompressed, if the runtime has the format.
|
|
54
|
+
*/
|
|
55
|
+
export const entries = (input, opt = {}) => core.entries(input, fill(opt, fs, false));
|
|
56
|
+
/** The sync form of `entries`. */
|
|
57
|
+
export const entriesSync = (input, opt = {}) => coreEntriesSync(input, fill(opt, fsSync, false));
|
|
58
|
+
/**
|
|
59
|
+
* Call `opt.onEntry` with each entry of an archive. If `files` is
|
|
60
|
+
* set, only with the entries that it lists, and the entries in the
|
|
61
|
+
* directories that it lists.
|
|
62
|
+
*/
|
|
63
|
+
export const list = (opt, files) => core.list(fill(opt, fs, false), files);
|
|
64
|
+
/** The sync form of `list`. */
|
|
65
|
+
export const listSync = (opt, files) => coreListSync(fill(opt, fsSync, false), files);
|
|
66
|
+
/**
|
|
67
|
+
* Extract the entries of an archive into the directory `opt.cwd`.
|
|
68
|
+
* If `files` is set, only the entries that it lists, and the entries
|
|
69
|
+
* in the directories that it lists.
|
|
70
|
+
*/
|
|
71
|
+
export const extract = (opt, files) => core.extract(fill(opt, fs, true), files);
|
|
72
|
+
/** The sync form of `extract`. */
|
|
73
|
+
export const extractSync = (opt, files) => coreExtractSync(fill(opt, fsSync, true), files);
|
|
74
|
+
export function create(opt, files) {
|
|
75
|
+
return core.create(fill(opt, fs, true), files);
|
|
76
|
+
}
|
|
77
|
+
export function createSync(opt, files) {
|
|
78
|
+
return coreCreateSync(fill(opt, fsSync, true), files);
|
|
79
|
+
}
|
|
80
|
+
/** Add the files to the end of an archive file that is not compressed. */
|
|
81
|
+
export const replace = (opt, files) => core.replace(fill(opt, fs, true), files);
|
|
82
|
+
/** The sync form of `replace`. */
|
|
83
|
+
export const replaceSync = (opt, files) => coreReplaceSync(fill(opt, fsSync, true), files);
|
|
84
|
+
/**
|
|
85
|
+
* The same as `replace`, but a file is added only if it is newer than
|
|
86
|
+
* the last entry of the archive that has its path. A directory is
|
|
87
|
+
* always added, and each path in it is checked.
|
|
88
|
+
*/
|
|
89
|
+
export const update = (opt, files) => core.update(fill(opt, fs, true), files);
|
|
90
|
+
/** The sync form of `update`. */
|
|
91
|
+
export const updateSync = (opt, files) => coreUpdateSync(fill(opt, fsSync, true), files);
|
|
92
|
+
/**
|
|
93
|
+
* Remove entries from an archive file: each entry that `files` lists,
|
|
94
|
+
* and each entry in a directory that it lists. With `opt.filter`,
|
|
95
|
+
* only if the filter also returns true.
|
|
96
|
+
*/
|
|
97
|
+
const del = (opt, files) => core.delete(fill(opt, fs, false), files);
|
|
98
|
+
/** The sync form of `delete`. */
|
|
99
|
+
export const deleteSync = (opt, files) => coreDeleteSync(fill(opt, fsSync, false), files);
|
|
100
|
+
export { del as delete };
|
|
101
|
+
export { create as c, extract as x, list as t, replace as r, update as u };
|
|
102
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,kEAAkE;AAClE,mEAAmE;AACnE,oEAAoE;AACpE,+DAA+D;AAC/D,YAAY;AAEZ,OAAO,KAAK,MAAM,MAAM,SAAS,CAAA;AACjC,OAAO,KAAK,cAAc,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGnC,OAAO,KAAK,IAAI,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,cAAc,CAAA;AAC3D,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,cAAc,CAAA;AAC3D,OAAO,EACL,OAAO,GAIR,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,eAAe,CAAA;AAC9D,OAAO,EAAE,WAAW,IAAI,eAA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AC,MAAM,UAAU,GAAG,CACxB,GAAoC,EACpC,KAAsB,EAChB,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,KAAK,CAAC,CAAA;AAEzD;;;;GAIG;AACH,MAAM,GAAG,GAAG,CACV,GAA+B,EAC/B,KAAgB,EACD,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC,CAAA;AAE5D,iCAAiC;AACjC,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,GAAmC,EACnC,KAAgB,EACV,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC,CAAA;AAE1D,OAAO,EAAE,GAAG,IAAI,MAAM,EAAE,CAAA;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,OAAO,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,EAAE,OAAO,IAAI,CAAC,EAAE,MAAM,IAAI,CAAC,EAAE,CAAA","sourcesContent":["// The entry point for Node.js, and for each runtime that has the\n// `node:` modules. It has all that the core entry point has. Each\n// command gets defaults for the options that the core cannot know:\n// the file system, the working directory, the platform, the user of\n// the process, and the codecs of `node:zlib`. It adds the sync\n// commands.\n\nimport * as nodeFs from 'node:fs'\nimport * as nodeFsPromises from 'node:fs/promises'\nimport { resolve } from 'node:path'\nimport type { BrotliOptions, ZlibOptions, ZstdOptions } from 'node:zlib'\nimport type { Codec } from '../codec.js'\nimport * as core from '../index.js'\nimport { createSync as coreCreateSync } from '../create.js'\nimport { deleteSync as coreDeleteSync } from '../delete.js'\nimport {\n dealias,\n type FileOption,\n type NoFileOption,\n type WithAliases,\n} from '../dealias.js'\nimport { entriesSync as coreEntriesSync } from '../entries.js'\nimport { extractSync as coreExtractSync } from '../extract.js'\nimport { listSync as coreListSync } from '../list.js'\nimport type { PackInput, PackInputSync } from '../pack.js'\nimport type { ReadEntry, ReadEntrySync } from '../read-entry.js'\nimport { replaceSync as coreReplaceSync } from '../replace.js'\nimport { updateSync as coreUpdateSync } from '../update.js'\nimport { zlibCodecs } from './codecs.js'\n\nexport * from '../index.js'\nexport { TarReaderSync } from '../entries.js'\nexport { PackSync } from '../pack.js'\nexport { ReadEntrySync } from '../read-entry.js'\nexport { UnpackSync } from '../unpack.js'\nexport { zlibCodecs, codecStream, type ZlibModule } from './codecs.js'\n\nconst fs: core.TarFS & core.ExtractFS & core.ReplaceFS & core.DeleteFS =\n nodeFsPromises\nconst fsSync: core.TarFSSync &\n core.ExtractFSSync &\n core.ReplaceFSSync &\n core.DeleteFSSync = nodeFs\nconst platform = process.platform === 'win32' ? 'win32' : 'posix'\nconst codecs = zlibCodecs()\n\n/** Each member of the option type `T`, with `fs` and `cwd` optional. */\nexport type Loose<T> =\n T extends unknown ?\n Omit<T, 'fs' | 'cwd'> &\n Partial<Pick<T, Extract<keyof T, 'fs' | 'cwd'>>>\n : never\n\n/** The compression options, with the option types of `node:zlib`. */\nexport type Zip = {\n /** Compress with gzip. An object is the options of `zlib.createGzip`. */\n gzip?: boolean | ZlibOptions\n /**\n * Compress with brotli. An object is the options of\n * `zlib.createBrotliCompress`.\n */\n brotli?: boolean | BrotliOptions\n /**\n * Compress with zstd. An object is the options of\n * `zlib.createZstdCompress`.\n */\n zstd?: boolean | ZstdOptions\n}\n/** `Loose<T>`, with the compression options of `Zip`. */\nexport type Packing<T> = Omit<Loose<T>, keyof Zip> & Zip\n\n/** The options of `entries`. */\nexport type ReadOptions = core.ReadOptions\n/** The options of `entriesSync`. */\nexport type ReadOptionsSync = core.ReadOptionsSync\n/** The options of `list`. Set `input` or `file`. */\nexport type ListOptions = Loose<core.ListOptions>\n/** The options of `listSync`. Set `input` or `file`. */\nexport type ListOptionsSync = Loose<core.ListOptionsSync>\n/** The options of `extract`. The default of `cwd` is `process.cwd()`. */\nexport type ExtractOptions = Loose<core.ExtractOptions>\n/** The options of `extractSync`. */\nexport type ExtractOptionsSync = Loose<core.ExtractOptionsSync>\n/** The options of `create`. The default of `cwd` is `process.cwd()`. */\nexport type CreateOptions = Packing<core.CreateOptions>\n/** The options of `createSync`. */\nexport type CreateOptionsSync = Packing<core.CreateOptionsSync>\n/** The options of `replace` and `update`. */\nexport type ReplaceOptions = Packing<core.ReplaceOptions>\n/** The options of `replaceSync` and `updateSync`. */\nexport type ReplaceOptionsSync = Packing<core.ReplaceOptionsSync>\n/** The options of `delete`. */\nexport type DeleteOptions = Loose<core.DeleteOptions>\n/** The options of `deleteSync`. */\nexport type DeleteOptionsSync = Loose<core.DeleteOptionsSync>\n\n// The options that get a default.\ntype Defaults = {\n fs?: unknown\n cwd?: string\n platform?: 'win32' | 'posix'\n chmod?: boolean\n processUid?: number\n processGid?: number\n processUname?: string\n processUmask?: number\n codecs?: Codec[]\n}\n\n// A copy of the options, with the name of the option in place of\n// each alias, and a default for each option that is not set. `T` is\n// the option type of the core command.\nconst fill = <T>(\n options: WithAliases<Defaults>,\n fs: unknown,\n paths: boolean,\n): T => {\n const opt = dealias<Defaults>(options)\n opt.fs ??= fs\n opt.platform ??= platform\n opt.codecs = [...(opt.codecs ?? []), ...codecs]\n // A command that reads an archive, and writes no file, does not\n // need the working directory or the user.\n if (paths) {\n // `resolve` adds `process.cwd()` to a relative path.\n opt.cwd = resolve(opt.cwd ?? '')\n opt.processUid ??= process.getuid?.()\n opt.processGid ??= process.getgid?.()\n opt.processUname ??= process.env.USER\n if (opt.chmod) opt.processUmask ??= process.umask()\n }\n return opt as T\n}\n\n/**\n * Read the entries of an archive. Gzip, brotli, and zstd input is\n * decompressed, if the runtime has the format.\n */\nexport const entries = (\n input: core.TarInput,\n opt: ReadOptions = {},\n): AsyncIterableIterator<ReadEntry, undefined> =>\n core.entries(input, fill(opt, fs, false))\n\n/** The sync form of `entries`. */\nexport const entriesSync = (\n input: core.TarInputSync,\n opt: ReadOptionsSync = {},\n): IterableIterator<ReadEntrySync, undefined> =>\n coreEntriesSync(input, fill(opt, fsSync, false))\n\n/**\n * Call `opt.onEntry` with each entry of an archive. If `files` is\n * set, only with the entries that it lists, and the entries in the\n * directories that it lists.\n */\nexport const list = (\n opt: WithAliases<ListOptions>,\n files?: string[],\n): Promise<void> => core.list(fill(opt, fs, false), files)\n\n/** The sync form of `list`. */\nexport const listSync = (\n opt: WithAliases<ListOptionsSync>,\n files?: string[],\n): void => coreListSync(fill(opt, fsSync, false), files)\n\n/**\n * Extract the entries of an archive into the directory `opt.cwd`.\n * If `files` is set, only the entries that it lists, and the entries\n * in the directories that it lists.\n */\nexport const extract = (\n opt: WithAliases<ExtractOptions>,\n files?: string[],\n): Promise<void> => core.extract(fill(opt, fs, true), files)\n\n/** The sync form of `extract`. */\nexport const extractSync = (\n opt: WithAliases<ExtractOptionsSync>,\n files?: string[],\n): void => coreExtractSync(fill(opt, fsSync, true), files)\n\n/**\n * Make an archive of the files. With `opt.file`, the archive is\n * written to that path. With no `opt.file`, the result is a stream\n * of the bytes of the archive.\n */\nexport function create(\n opt: WithAliases<CreateOptions> & FileOption,\n files: PackInput[],\n): Promise<void>\nexport function create(\n opt: WithAliases<CreateOptions> & NoFileOption,\n files: PackInput[],\n): ReadableStream<Uint8Array>\nexport function create(\n opt: WithAliases<CreateOptions>,\n files: PackInput[],\n): Promise<void> | ReadableStream<Uint8Array>\nexport function create(\n opt: WithAliases<CreateOptions>,\n files: PackInput[],\n): Promise<void> | ReadableStream<Uint8Array> {\n return core.create(fill(opt, fs, true), files)\n}\n\n/**\n * The sync form of `create`. With no `opt.file`, the result is an\n * iterator of the bytes of the archive.\n */\nexport function createSync(\n opt: WithAliases<CreateOptionsSync> & FileOption,\n files: PackInputSync[],\n): void\nexport function createSync(\n opt: WithAliases<CreateOptionsSync> & NoFileOption,\n files: PackInputSync[],\n): IterableIterator<Uint8Array, undefined>\nexport function createSync(\n opt: WithAliases<CreateOptionsSync>,\n files: PackInputSync[],\n): void | IterableIterator<Uint8Array, undefined>\nexport function createSync(\n opt: WithAliases<CreateOptionsSync>,\n files: PackInputSync[],\n): void | IterableIterator<Uint8Array, undefined> {\n return coreCreateSync(fill(opt, fsSync, true), files)\n}\n\n/** Add the files to the end of an archive file that is not compressed. */\nexport const replace = (\n opt: WithAliases<ReplaceOptions>,\n files: PackInput[],\n): Promise<void> => core.replace(fill(opt, fs, true), files)\n\n/** The sync form of `replace`. */\nexport const replaceSync = (\n opt: WithAliases<ReplaceOptionsSync>,\n files: PackInputSync[],\n): void => coreReplaceSync(fill(opt, fsSync, true), files)\n\n/**\n * The same as `replace`, but a file is added only if it is newer than\n * the last entry of the archive that has its path. A directory is\n * always added, and each path in it is checked.\n */\nexport const update = (\n opt: WithAliases<ReplaceOptions>,\n files: PackInput[],\n): Promise<void> => core.update(fill(opt, fs, true), files)\n\n/** The sync form of `update`. */\nexport const updateSync = (\n opt: WithAliases<ReplaceOptionsSync>,\n files: PackInputSync[],\n): void => coreUpdateSync(fill(opt, fsSync, true), files)\n\n/**\n * Remove entries from an archive file: each entry that `files` lists,\n * and each entry in a directory that it lists. With `opt.filter`,\n * only if the filter also returns true.\n */\nconst del = (\n opt: WithAliases<DeleteOptions>,\n files?: string[],\n): Promise<void> => core.delete(fill(opt, fs, false), files)\n\n/** The sync form of `delete`. */\nexport const deleteSync = (\n opt: WithAliases<DeleteOptionsSync>,\n files?: string[],\n): void => coreDeleteSync(fill(opt, fsSync, false), files)\n\nexport { del as delete }\nexport { create as c, extract as x, list as t, replace as r, update as u }\n"]}
|