@ac-kit/format-zip 0.3.3 → 0.4.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/CHANGELOG.md +26 -0
- package/README.md +3 -2
- package/dist/zip-source.d.ts +9 -20
- package/dist/zip-source.d.ts.map +1 -1
- package/dist/zip-source.js +8 -1
- package/dist/zip-source.js.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @ac-kit/format-zip
|
|
2
2
|
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 5c203e7: `openZipSource` reads by ranges from `@ac-kit/core`'s `ByteRangeSource`, the
|
|
8
|
+
ranged source shared with the other readers; `ZipSource` is removed, with no
|
|
9
|
+
alias. The shape is the same (`size`, `read(offset, length, signal?)`, optional
|
|
10
|
+
`stream`), and so is the behaviour: a `Blob` or bytes in memory are still taken
|
|
11
|
+
directly, and a read giving fewer bytes than asked is still a
|
|
12
|
+
`ZipFormatError`.
|
|
13
|
+
|
|
14
|
+
**Migration:** import the type from `@ac-kit/core`:
|
|
15
|
+
`import type { ByteRangeSource } from "@ac-kit/core"` in place of
|
|
16
|
+
`import type { ZipSource } from "@ac-kit/format-zip"`. A `Blob` can also be
|
|
17
|
+
wrapped with `byteRangeSourceFromBlob`.
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies [5c203e7]
|
|
22
|
+
- Updated dependencies [5c203e7]
|
|
23
|
+
- Updated dependencies [5c203e7]
|
|
24
|
+
- Updated dependencies [5c203e7]
|
|
25
|
+
- Updated dependencies [5c203e7]
|
|
26
|
+
- @ac-kit/core@0.14.0
|
|
27
|
+
- @ac-kit/noncrypto-hash@0.3.0
|
|
28
|
+
|
|
3
29
|
## 0.3.3
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -63,8 +63,9 @@ const head = await new Response(archive.streamRange(warc, 0, 8)).text();
|
|
|
63
63
|
Names are UTF-8 when flagged, from an Info-ZIP Unicode Path field when
|
|
64
64
|
present, code page 437 otherwise.
|
|
65
65
|
- `openZipSource` — the same from a `Blob` (a `File`, Node's `fs.openAsBlob`) or
|
|
66
|
-
a `
|
|
67
|
-
`stream(offset, length)`: a file, HTTP `Range` requests, storage):
|
|
66
|
+
a `ByteRangeSource` from `@ac-kit/core` (`size`, `read(offset, length)`,
|
|
67
|
+
optionally `stream(offset, length)`: a file, HTTP `Range` requests, storage):
|
|
68
|
+
one read of
|
|
68
69
|
the end records, one of the directory (bounded by `maxDirectorySize`), and
|
|
69
70
|
one of each entry's local header the first time it is read, cached after.
|
|
70
71
|
- `ZipArchive.read` — an entry's content, stored or deflated, inflated with
|
package/dist/zip-source.d.ts
CHANGED
|
@@ -1,23 +1,5 @@
|
|
|
1
|
+
import { type ByteRangeSource } from "@ac-kit/core";
|
|
1
2
|
import type { ZipArchive, ZipLimits } from "./zip-archive.js";
|
|
2
|
-
/**
|
|
3
|
-
* An archive {@link openZipSource} reads by ranges: a file, an HTTP resource
|
|
4
|
-
* fetched with `Range`, storage with ranged reads.
|
|
5
|
-
*/
|
|
6
|
-
export type ZipSource = {
|
|
7
|
-
/** The archive's length in bytes, a safe non-negative integer. */
|
|
8
|
-
readonly size: number;
|
|
9
|
-
/**
|
|
10
|
-
* Exactly `length` bytes at `offset`; fewer is a truncated archive. Used for
|
|
11
|
-
* the end records, the central directory and local headers, and for entry
|
|
12
|
-
* data, in chunks of 1 MiB, when `stream` is absent.
|
|
13
|
-
*/
|
|
14
|
-
read(offset: number, length: number, signal?: AbortSignal): Promise<Uint8Array>;
|
|
15
|
-
/**
|
|
16
|
-
* Optional: exactly `length` bytes at `offset` as a stream, which entry data
|
|
17
|
-
* is read through when present, in one request however large the entry.
|
|
18
|
-
*/
|
|
19
|
-
stream?(offset: number, length: number, signal?: AbortSignal): ReadableStream<Uint8Array>;
|
|
20
|
-
};
|
|
21
3
|
/** The limits {@link openZipSource} holds an archive to. */
|
|
22
4
|
export type ZipSourceLimits = ZipLimits & {
|
|
23
5
|
/**
|
|
@@ -40,6 +22,13 @@ export type ZipSourceLimits = ZipLimits & {
|
|
|
40
22
|
* in the central directory, bounded by `maxDirectorySize`, plus one offset per
|
|
41
23
|
* entry read.
|
|
42
24
|
*
|
|
25
|
+
* Any other `ByteRangeSource` (`@ac-kit/core`: a file, an HTTP resource fetched
|
|
26
|
+
* with `Range`, storage with ranged reads) serves the end records, the central
|
|
27
|
+
* directory and local headers through `read`, and entry data through `stream`
|
|
28
|
+
* when it has one, in one request however large the entry, or else through
|
|
29
|
+
* `read` in chunks of 1 MiB. A read giving fewer bytes than asked is a
|
|
30
|
+
* truncated archive.
|
|
31
|
+
*
|
|
43
32
|
* @example
|
|
44
33
|
* const archive = await openZipSource(await fs.openAsBlob(path), limits);
|
|
45
34
|
* const entry = archive.entry("archive/data.warc.gz")!;
|
|
@@ -55,5 +44,5 @@ export type ZipSourceLimits = ZipLimits & {
|
|
|
55
44
|
* integer.
|
|
56
45
|
* @throws When `signal` aborts, its reason; the source's own read error.
|
|
57
46
|
*/
|
|
58
|
-
export declare function openZipSource(source:
|
|
47
|
+
export declare function openZipSource(source: ByteRangeSource | Blob | Uint8Array<ArrayBuffer>, limits: ZipSourceLimits, signal?: AbortSignal): Promise<ZipArchive>;
|
|
59
48
|
//# sourceMappingURL=zip-source.d.ts.map
|
package/dist/zip-source.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zip-source.d.ts","sourceRoot":"","sources":["../src/zip-source.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"zip-source.d.ts","sourceRoot":"","sources":["../src/zip-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAoB,MAAM,cAAc,CAAC;AAUtE,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAG9D,4DAA4D;AAC5D,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG;IACzC;;;OAGG;IACH,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;CAClC,CAAC;AAKF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAsB,aAAa,CAClC,MAAM,EAAE,eAAe,GAAG,IAAI,GAAG,UAAU,CAAC,WAAW,CAAC,EACxD,MAAM,EAAE,eAAe,EACvB,MAAM,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,UAAU,CAAC,CAgCrB"}
|
package/dist/zip-source.js
CHANGED
|
@@ -3,7 +3,7 @@ import { producerStream_ } from "./_producer-stream.js";
|
|
|
3
3
|
import { MAX_TAIL_, readArchiveDirectory_ } from "./_zip-directory.js";
|
|
4
4
|
import { bytesRanges_, createArchive_, ownBuffer_, } from "./_zip-entries.js";
|
|
5
5
|
import { ZipFormatError } from "./zip-error.js";
|
|
6
|
-
/** Bytes per read of entry data from a
|
|
6
|
+
/** Bytes per read of entry data from a `ByteRangeSource` without `stream`. */
|
|
7
7
|
const READ_CHUNK_ = 1024 * 1024;
|
|
8
8
|
/**
|
|
9
9
|
* Reads a ZIP archive by ranges, without holding it whole: one read of its end
|
|
@@ -19,6 +19,13 @@ const READ_CHUNK_ = 1024 * 1024;
|
|
|
19
19
|
* in the central directory, bounded by `maxDirectorySize`, plus one offset per
|
|
20
20
|
* entry read.
|
|
21
21
|
*
|
|
22
|
+
* Any other `ByteRangeSource` (`@ac-kit/core`: a file, an HTTP resource fetched
|
|
23
|
+
* with `Range`, storage with ranged reads) serves the end records, the central
|
|
24
|
+
* directory and local headers through `read`, and entry data through `stream`
|
|
25
|
+
* when it has one, in one request however large the entry, or else through
|
|
26
|
+
* `read` in chunks of 1 MiB. A read giving fewer bytes than asked is a
|
|
27
|
+
* truncated archive.
|
|
28
|
+
*
|
|
22
29
|
* @example
|
|
23
30
|
* const archive = await openZipSource(await fs.openAsBlob(path), limits);
|
|
24
31
|
* const entry = archive.entry("archive/data.warc.gz")!;
|
package/dist/zip-source.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zip-source.js","sourceRoot":"","sources":["../src/zip-source.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"zip-source.js","sourceRoot":"","sources":["../src/zip-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEtE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EACN,YAAY,EACZ,cAAc,EACd,UAAU,GAEV,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAWhD,8EAA8E;AAC9E,MAAM,WAAW,GAAG,IAAI,GAAG,IAAI,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAClC,MAAwD,EACxD,MAAuB,EACvB,MAAoB;IAEpB,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,IAAI,MAAkB,CAAC;IACvB,IAAI,MAAM,YAAY,UAAU,EAAE,CAAC;QAClC,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;SAAM,IAAI,MAAM,YAAY,IAAI,EAAE,CAAC;QACnC,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;SAAM,CAAC;QACP,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;IACD,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;IACxB,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,CAA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G,EAAE,GAAE,CAAC,CAAC,CAAC;YACtD,CAAC;YACD,QAAQ,CAAC,cAAc,EAAE,CAAC;YAC1B,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;gBACzB,MAAM,IAAI,cAAc,CACvB,mBAAmB,QAAQ,qBAAqB,MAAM,EAAE,EACxD,MAAM,CACN,CAAC;YACH,CAAC;QACF,CAAC,EAAE,MAAM,CAAC;QACX,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE,CACxB,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC;KACvE,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CACpB,KAAiB,EACjB,MAAc,EACd,MAAc;IAEd,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;QAC7B,MAAM,IAAI,cAAc,CACvB,mBAAmB,KAAK,CAAC,MAAM,qBAAqB,MAAM,EAAE,EAC5D,MAAM,CACN,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ac-kit/format-zip",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "ZIP archives: read from memory or by ranges, written whole or streamed, ZIP64 included, entries inflated on demand within limits.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"archive",
|
|
@@ -45,15 +45,15 @@
|
|
|
45
45
|
"prepack": "yarn build"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@ac-kit/core": "^0.
|
|
49
|
-
"@ac-kit/noncrypto-hash": "^0.
|
|
48
|
+
"@ac-kit/core": "^0.14.0",
|
|
49
|
+
"@ac-kit/noncrypto-hash": "^0.3.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@ac-kit/integration-test-util": "0.6.
|
|
53
|
-
"@ac-kit/math-random": "0.4.
|
|
52
|
+
"@ac-kit/integration-test-util": "0.6.1",
|
|
53
|
+
"@ac-kit/math-random": "0.4.2",
|
|
54
54
|
"@ac-kit/tsconfig": "0.1.0",
|
|
55
55
|
"@ac-kit/typedoc-config": "0.1.0",
|
|
56
|
-
"@ac-kit/vitest-config": "0.
|
|
56
|
+
"@ac-kit/vitest-config": "0.3.0",
|
|
57
57
|
"@types/node": "^26.5.1",
|
|
58
58
|
"@typescript/native": "typescript@7.0.2",
|
|
59
59
|
"rimraf": "6.1.4",
|