@clearmist-labs/comic-archive-handler 1.1.1 → 1.3.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 +1 -1
- package/dist/index.d.mts +32 -5
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +216 -76
- package/dist/index.mjs.map +1 -1
- package/docs/API.md +34 -0
- package/package.json +1 -1
package/docs/API.md
CHANGED
|
@@ -100,6 +100,22 @@ Reads one archive entry and returns its contents as a `Buffer`. Throws `Metadata
|
|
|
100
100
|
const page = await cah.readArchiveEntry(comicBuffer, 'P00001.jpg');
|
|
101
101
|
```
|
|
102
102
|
|
|
103
|
+
### `readArchiveEntries(input)`
|
|
104
|
+
|
|
105
|
+
Reads every entry's contents and SHA256 in a single pass over the archive, yielding `{ path, size?, buffer, sha256 }` in archive iteration order. Prefer this over calling `readArchiveEntry`/`sha256ArchiveEntry` once per entry: zip and asar support real random access, but the sequential/CLI-driven formats (rar, 7z, ace, tar) re-scan the archive from the start on every such call — reading every entry that way costs O(n^2) instead of O(n) for those formats. It also avoids reading each entry's data twice (once for the hash, once for the buffer).
|
|
106
|
+
|
|
107
|
+
**Options**
|
|
108
|
+
|
|
109
|
+
- `input: ArchiveInput` - A filesystem path or archive `Buffer`.
|
|
110
|
+
|
|
111
|
+
**Example**
|
|
112
|
+
|
|
113
|
+
```js
|
|
114
|
+
for await (const entry of cah.readArchiveEntries(comicBuffer)) {
|
|
115
|
+
console.log(entry.path, entry.sha256);
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
103
119
|
### `renameArchiveImagesSequentially(input, options?)`
|
|
104
120
|
|
|
105
121
|
Renames image entries in natural-sort order to `P#####.<extension>`, while leaving other entries unchanged.
|
|
@@ -156,6 +172,23 @@ const cleaned = await cah.stripNonEssentialFiles(comicBuffer, {
|
|
|
156
172
|
});
|
|
157
173
|
```
|
|
158
174
|
|
|
175
|
+
### `removeArchiveEntry(input, entryPath, options?)`
|
|
176
|
+
|
|
177
|
+
Removes a single named entry from an archive, leaving every other entry unchanged. Throws `MetadataNotFoundError` when no entry matches `entryPath`.
|
|
178
|
+
|
|
179
|
+
**Options**
|
|
180
|
+
|
|
181
|
+
- `input: ArchiveInput` - A filesystem path or archive `Buffer`.
|
|
182
|
+
- `entryPath: string` - Exact archive entry path to remove.
|
|
183
|
+
- `options.tempDir?: string` - Temporary staging directory for ASAR or 7z operations.
|
|
184
|
+
- `options.output?: string | Writable` - Output destination. Without it, returns a `Buffer`.
|
|
185
|
+
|
|
186
|
+
**Example**
|
|
187
|
+
|
|
188
|
+
```js
|
|
189
|
+
const trimmed = await cah.removeArchiveEntry(comicBuffer, 'thumbs.db');
|
|
190
|
+
```
|
|
191
|
+
|
|
159
192
|
## Metadata
|
|
160
193
|
|
|
161
194
|
`ComicMetadata` is the canonical metadata shape, covering every field defined by both bundled schemas (`schemas/ComicInfo v2.1.xsd` and `schemas/MetronInfo v1.1.xsd`) — see [`schemaVersions.ts`](../src/metadata/schemaVersions.ts) if those XSDs are ever upgraded. Conversion between ComicInfo.xml and MetronInfo.xml is intentionally lossy when a field has no equivalent in the target schema; the complete field mapping is maintained in `src/metadata/schema.ts`.
|
|
@@ -589,6 +622,7 @@ The following types are exported for TypeScript consumers.
|
|
|
589
622
|
- `AddMetadataOptions` - Archive write options plus `overwrite?: boolean`.
|
|
590
623
|
- `RenameOptions` - Archive write options plus `start?: number` and `pad?: number`.
|
|
591
624
|
- `StripOptions` - Archive write options plus `extraKeepExtensions?: string[]`.
|
|
625
|
+
- `RemoveEntryOptions` - Archive write options (no additional fields).
|
|
592
626
|
- `ImageConvertOptions` - `webp?`, `jpeg?`, and `png?` format option groups.
|
|
593
627
|
- `WebpOptions` - `quality?`, `effort?`, and `smartSubsample?`.
|
|
594
628
|
- `JpegOptions` - `quality?`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clearmist-labs/comic-archive-handler",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Detect, convert, and manipulate comic book archives: container conversion, edit metadata, image re-encoding, perceptual + content hashing.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"7z",
|