@storyteller-platform/epub 0.7.1 → 0.8.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.
@@ -7,12 +7,12 @@
7
7
  * - {@link MemoryAdapter} keeps an in-memory zip handle and supports
8
8
  * reads only
9
9
  */
10
- type EpubStorageKind = "tmp-dir" | "in-memory" | (string & {});
11
- interface EpubStorageCapabilities {
10
+ export type EpubStorageKind = "tmp-dir" | "in-memory" | (string & {});
11
+ export interface EpubStorageCapabilities {
12
12
  /** when false, the Epub class refuses every mutation method at runtime */
13
13
  readonly writable: boolean;
14
14
  }
15
- interface EpubListEntry {
15
+ export interface EpubListEntry {
16
16
  /** location the adapter can read the entry back from, in whatever form it stores */
17
17
  absolutePath: string;
18
18
  /** the entry name, as it appears in the archive */
@@ -28,7 +28,7 @@ interface EpubListEntry {
28
28
  * In previous versions of the EPUB lib, this was a little bit more muddled, leading to
29
29
  * eg the TmpFsAdapter trying to read `OEBPS/a%20b.xhtml`, whereas it was stored as `OEBPS/a b.xhtml`
30
30
  */
31
- interface EpubStorageAdapter {
31
+ export interface EpubStorageAdapter {
32
32
  read(entry: string): Promise<Uint8Array>;
33
33
  read(entry: string, encoding: "utf-8"): Promise<string>;
34
34
  /**
@@ -56,7 +56,7 @@ interface EpubStorageAdapter {
56
56
  /** Always called on close or error */
57
57
  dispose(): void | Promise<void>;
58
58
  }
59
- interface EpubStorageAdapterClass<Opts extends object = object> {
59
+ export interface EpubStorageAdapterClass<Opts extends object = object> {
60
60
  readonly kind: EpubStorageKind;
61
61
  readonly capabilities: EpubStorageCapabilities;
62
62
  /**
@@ -70,6 +70,4 @@ interface EpubStorageAdapterClass<Opts extends object = object> {
70
70
  */
71
71
  initEmpty?(opts?: Opts): Promise<EpubStorageAdapter>;
72
72
  }
73
- type AdapterOptions<A> = A extends EpubStorageAdapterClass<infer Opts> ? Opts : object;
74
-
75
- export type { AdapterOptions, EpubListEntry, EpubStorageAdapter, EpubStorageAdapterClass, EpubStorageCapabilities, EpubStorageKind };
73
+ export type AdapterOptions<A> = A extends EpubStorageAdapterClass<infer Opts> ? Opts : object;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +1,5 @@
1
- import { EpubStorageAdapter } from './interface.js';
2
-
3
- interface MemoryAdapterOptions {
1
+ import type { EpubStorageAdapter } from "./interface.ts";
2
+ export interface MemoryAdapterOptions {
4
3
  /**
5
4
  * per-entry decompressed buffer cache
6
5
  * turn it off when opening many EPUBs and reading each entry at most once
@@ -16,7 +15,7 @@ interface MemoryAdapterOptions {
16
15
  * read only
17
16
  *
18
17
  */
19
- declare class MemoryAdapter implements EpubStorageAdapter {
18
+ export declare class MemoryAdapter implements EpubStorageAdapter {
20
19
  private zip;
21
20
  private entries;
22
21
  private cache;
@@ -32,5 +31,3 @@ declare class MemoryAdapter implements EpubStorageAdapter {
32
31
  archiveLength(entry: string): Promise<number>;
33
32
  dispose(): void;
34
33
  }
35
-
36
- export { MemoryAdapter, type MemoryAdapterOptions };
@@ -1,70 +1,75 @@
1
- import "../chunk-BIEQXUOY.js";
2
1
  import { openZip } from "../zip.js";
3
- class MemoryAdapter {
4
- constructor(zip, entries, cache) {
5
- this.zip = zip;
6
- this.entries = entries;
7
- this.cache = cache;
8
- }
9
- static kind = "in-memory";
10
- static capabilities = { writable: false };
11
- static async init(source, opts = {}) {
12
- const { cache = true, signal } = opts;
13
- signal == null ? void 0 : signal.throwIfAborted();
14
- const zip = await openZip(source);
15
- const entries = /* @__PURE__ */ new Map();
16
- try {
17
- for await (const entry of zip) {
18
- signal == null ? void 0 : signal.throwIfAborted();
19
- if (entry.filename.endsWith("/")) continue;
20
- entries.set(entry.filename, entry);
21
- }
22
- } catch (error) {
23
- await zip.close();
24
- throw error;
2
+ /**
3
+ * Loads an EPUB archive into memory and serves all I/O off the in-memory zip handle.
4
+ *
5
+ * read only
6
+ *
7
+ */
8
+ export class MemoryAdapter {
9
+ zip;
10
+ entries;
11
+ cache;
12
+ static kind = "in-memory";
13
+ static capabilities = { writable: false };
14
+ static async init(source, opts = {}) {
15
+ const { cache = true, signal } = opts;
16
+ signal?.throwIfAborted();
17
+ const zip = await openZip(source);
18
+ const entries = new Map();
19
+ try {
20
+ for await (const entry of zip) {
21
+ signal?.throwIfAborted();
22
+ if (entry.filename.endsWith("/"))
23
+ continue;
24
+ entries.set(entry.filename, entry);
25
+ }
26
+ }
27
+ catch (error) {
28
+ await zip.close();
29
+ throw error;
30
+ }
31
+ return new MemoryAdapter(zip, entries, cache ? new Map() : null);
25
32
  }
26
- return new MemoryAdapter(zip, entries, cache ? /* @__PURE__ */ new Map() : null);
27
- }
28
- async read(entry, encoding) {
29
- var _a, _b;
30
- const cached = (_a = this.cache) == null ? void 0 : _a.get(entry);
31
- if (cached) {
32
- return encoding ? cached.toString(encoding) : new Uint8Array(cached);
33
+ constructor(zip, entries, cache) {
34
+ this.zip = zip;
35
+ this.entries = entries;
36
+ this.cache = cache;
33
37
  }
34
- const zipEntry = this.entries.get(entry);
35
- if (!zipEntry) {
36
- const err = new Error(
37
- `ENOENT: zip entry not found in EPUB archive: ${entry}`
38
- );
39
- err.code = "ENOENT";
40
- throw err;
38
+ async read(entry, encoding) {
39
+ const cached = this.cache?.get(entry);
40
+ if (cached) {
41
+ return encoding ? cached.toString(encoding) : new Uint8Array(cached);
42
+ }
43
+ const zipEntry = this.entries.get(entry);
44
+ if (!zipEntry) {
45
+ const err = new Error(`ENOENT: zip entry not found in EPUB archive: ${entry}`);
46
+ err.code = "ENOENT";
47
+ throw err;
48
+ }
49
+ const stream = await zipEntry.openReadStream();
50
+ const chunks = [];
51
+ for await (const chunk of stream) {
52
+ chunks.push(chunk);
53
+ }
54
+ const buf = Buffer.concat(chunks);
55
+ this.cache?.set(entry, buf);
56
+ return encoding ? buf.toString(encoding) : new Uint8Array(buf);
41
57
  }
42
- const stream = await zipEntry.openReadStream();
43
- const chunks = [];
44
- for await (const chunk of stream) {
45
- chunks.push(chunk);
58
+ // eslint-disable-next-line @typescript-eslint/require-await
59
+ async exists(entry) {
60
+ return this.entries.has(entry);
61
+ }
62
+ // eslint-disable-next-line @typescript-eslint/require-await
63
+ async archiveLength(entry) {
64
+ const zipEntry = this.entries.get(entry);
65
+ if (!zipEntry)
66
+ return 0;
67
+ return zipEntry.compressedSize || zipEntry.uncompressedSize;
68
+ }
69
+ dispose() {
70
+ this.entries.clear();
71
+ this.cache?.clear();
72
+ // fire-and-forget: closing the handle just releases the fd
73
+ this.zip.close().catch(() => undefined);
46
74
  }
47
- const buf = Buffer.concat(chunks);
48
- (_b = this.cache) == null ? void 0 : _b.set(entry, buf);
49
- return encoding ? buf.toString(encoding) : new Uint8Array(buf);
50
- }
51
- // eslint-disable-next-line @typescript-eslint/require-await
52
- async exists(entry) {
53
- return this.entries.has(entry);
54
- }
55
- // eslint-disable-next-line @typescript-eslint/require-await
56
- async archiveLength(entry) {
57
- const zipEntry = this.entries.get(entry);
58
- if (!zipEntry) return 0;
59
- return zipEntry.compressedSize || zipEntry.uncompressedSize;
60
- }
61
- dispose() {
62
- var _a;
63
- this.entries.clear();
64
- (_a = this.cache) == null ? void 0 : _a.clear();
65
- this.zip.close().catch(() => void 0);
66
- }
67
75
  }
68
- export {
69
- MemoryAdapter
70
- };
@@ -1,11 +1,10 @@
1
- import { EpubStorageAdapter, EpubListEntry } from './interface.js';
2
-
1
+ import type { EpubListEntry, EpubStorageAdapter } from "./interface.ts";
3
2
  /**
4
3
  * Extracts an EPUB archive to a temp directory and serves all I/O off
5
4
  * the real filesystem.
6
5
  * `Epub.using(TmpFsAdapter).from(...)` returns a writable {@link Epub}.
7
6
  */
8
- declare class TmpFsAdapter implements EpubStorageAdapter {
7
+ export declare class TmpFsAdapter implements EpubStorageAdapter {
9
8
  private readonly rootPath;
10
9
  static readonly kind: "extracted-dir";
11
10
  static readonly capabilities: {
@@ -27,5 +26,3 @@ declare class TmpFsAdapter implements EpubStorageAdapter {
27
26
  serialize(targetPath: string): Promise<void>;
28
27
  dispose(): void;
29
28
  }
30
-
31
- export { TmpFsAdapter };
@@ -1,183 +1,252 @@
1
- import {
2
- __callDispose,
3
- __using
4
- } from "../chunk-BIEQXUOY.js";
1
+ var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
2
+ if (value !== null && value !== void 0) {
3
+ if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
4
+ var dispose, inner;
5
+ if (async) {
6
+ if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
7
+ dispose = value[Symbol.asyncDispose];
8
+ }
9
+ if (dispose === void 0) {
10
+ if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
11
+ dispose = value[Symbol.dispose];
12
+ if (async) inner = dispose;
13
+ }
14
+ if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
15
+ if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
16
+ env.stack.push({ value: value, dispose: dispose, async: async });
17
+ }
18
+ else if (async) {
19
+ env.stack.push({ async: true });
20
+ }
21
+ return value;
22
+ };
23
+ var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
24
+ return function (env) {
25
+ function fail(e) {
26
+ env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
27
+ env.hasError = true;
28
+ }
29
+ var r, s = 0;
30
+ function next() {
31
+ while (r = env.stack.pop()) {
32
+ try {
33
+ if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
34
+ if (r.dispose) {
35
+ var result = r.dispose.call(r.value);
36
+ if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
37
+ }
38
+ else s |= 1;
39
+ }
40
+ catch (e) {
41
+ fail(e);
42
+ }
43
+ }
44
+ if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
45
+ if (env.hasError) throw env.error;
46
+ }
47
+ return next();
48
+ };
49
+ })(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
50
+ var e = new Error(message);
51
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
52
+ });
5
53
  import { randomUUID } from "node:crypto";
6
54
  import { createWriteStream, rmSync } from "node:fs";
7
- import {
8
- cp,
9
- mkdir,
10
- readFile,
11
- readdir,
12
- rm,
13
- stat,
14
- writeFile
15
- } from "node:fs/promises";
55
+ import { cp, mkdir, readFile, readdir, rm, stat, writeFile, } from "node:fs/promises";
16
56
  import { pipeline } from "node:stream/promises";
17
57
  import { ZipFile } from "yazl";
18
58
  import { scratchPath } from "@storyteller-platform/fs";
19
59
  import { MediaType } from "@storyteller-platform/media-types";
20
60
  import { dirname, join, sep } from "@storyteller-platform/path";
21
61
  import { openZip } from "../zip.js";
22
- const PRECOMPRESSED_KINDS = /* @__PURE__ */ new Set([
23
- "audio",
24
- "image",
25
- "archive",
26
- "package"
62
+ const PRECOMPRESSED_KINDS = new Set([
63
+ "audio",
64
+ "image",
65
+ "archive",
66
+ "package",
27
67
  ]);
28
68
  function mintRootPath() {
29
- return scratchPath(`storyteller-platform-epub-${randomUUID()}`);
69
+ return scratchPath(`storyteller-platform-epub-${randomUUID()}`);
30
70
  }
71
+ /**
72
+ * Whether an entry name can be laid down inside the extract root.
73
+ *
74
+ * A `.` or `..` segment cannot name a real file, and joining one onto the
75
+ * root would walk out of it, so such an entry is unreachable here whether it
76
+ * came from a hostile archive or from an href that spelled it `%2E%2E`.
77
+ */
31
78
  function isStorableEntryName(entry) {
32
- return !entry.split("/").some((segment) => segment === "" || segment === "." || segment === "..");
79
+ return !entry
80
+ .split("/")
81
+ .some((segment) => segment === "" || segment === "." || segment === "..");
33
82
  }
34
- class TmpFsAdapter {
35
- constructor(rootPath) {
36
- this.rootPath = rootPath;
37
- }
38
- static kind = "extracted-dir";
39
- static capabilities = { writable: true };
40
- static async init(source) {
41
- const rootPath = mintRootPath();
42
- try {
43
- var _stack = [];
44
- try {
45
- const zipfile = await openZip(source);
46
- const stack = __using(_stack, new AsyncDisposableStack(), true);
47
- stack.defer(async () => {
48
- await zipfile.close();
49
- });
50
- for await (const entry of zipfile) {
51
- if (entry.filename.endsWith("/")) {
52
- continue;
53
- }
54
- if (!isStorableEntryName(entry.filename)) continue;
55
- const writePath = join(rootPath, ...entry.filename.split("/"));
56
- const readStream = await entry.openReadStream();
57
- await mkdir(dirname(writePath), { recursive: true });
58
- const writeStream = createWriteStream(writePath);
59
- await pipeline(readStream, writeStream);
60
- }
61
- } catch (_) {
62
- var _error = _, _hasError = true;
63
- } finally {
64
- var _promise = __callDispose(_stack, _error, _hasError);
65
- _promise && await _promise;
66
- }
67
- } catch (error) {
68
- rmSync(rootPath, { force: true, recursive: true });
69
- throw error;
83
+ /**
84
+ * Extracts an EPUB archive to a temp directory and serves all I/O off
85
+ * the real filesystem.
86
+ * `Epub.using(TmpFsAdapter).from(...)` returns a writable {@link Epub}.
87
+ */
88
+ export class TmpFsAdapter {
89
+ rootPath;
90
+ static kind = "extracted-dir";
91
+ static capabilities = { writable: true };
92
+ static async init(source) {
93
+ const rootPath = mintRootPath();
94
+ try {
95
+ const env_1 = { stack: [], error: void 0, hasError: false };
96
+ try {
97
+ const zipfile = await openZip(source);
98
+ const stack = __addDisposableResource(env_1, new AsyncDisposableStack(), true);
99
+ stack.defer(async () => {
100
+ await zipfile.close();
101
+ });
102
+ for await (const entry of zipfile) {
103
+ if (entry.filename.endsWith("/")) {
104
+ // directory entries are skipped; parent dirs are created implicitly
105
+ continue;
106
+ }
107
+ if (!isStorableEntryName(entry.filename))
108
+ continue;
109
+ const writePath = join(rootPath, ...entry.filename.split("/"));
110
+ const readStream = await entry.openReadStream();
111
+ await mkdir(dirname(writePath), { recursive: true });
112
+ const writeStream = createWriteStream(writePath);
113
+ await pipeline(readStream, writeStream);
114
+ }
115
+ }
116
+ catch (e_1) {
117
+ env_1.error = e_1;
118
+ env_1.hasError = true;
119
+ }
120
+ finally {
121
+ const result_1 = __disposeResources(env_1);
122
+ if (result_1)
123
+ await result_1;
124
+ }
125
+ }
126
+ catch (error) {
127
+ rmSync(rootPath, { force: true, recursive: true });
128
+ throw error;
129
+ }
130
+ return new TmpFsAdapter(rootPath);
131
+ }
132
+ static async initEmpty() {
133
+ const rootPath = mintRootPath();
134
+ await mkdir(rootPath, { recursive: true });
135
+ return new TmpFsAdapter(rootPath);
136
+ }
137
+ constructor(rootPath) {
138
+ this.rootPath = rootPath;
139
+ }
140
+ diskPath(entry) {
141
+ if (!isStorableEntryName(entry)) {
142
+ const err = new Error(`ENOENT: no such entry in EPUB archive: ${entry}`);
143
+ err.code = "ENOENT";
144
+ throw err;
145
+ }
146
+ return join(this.rootPath, ...entry.split("/"));
70
147
  }
71
- return new TmpFsAdapter(rootPath);
72
- }
73
- static async initEmpty() {
74
- const rootPath = mintRootPath();
75
- await mkdir(rootPath, { recursive: true });
76
- return new TmpFsAdapter(rootPath);
77
- }
78
- diskPath(entry) {
79
- if (!isStorableEntryName(entry)) {
80
- const err = new Error(`ENOENT: no such entry in EPUB archive: ${entry}`);
81
- err.code = "ENOENT";
82
- throw err;
148
+ async read(entry, encoding) {
149
+ return await readFile(this.diskPath(entry), encoding);
83
150
  }
84
- return join(this.rootPath, ...entry.split("/"));
85
- }
86
- async read(entry, encoding) {
87
- return await readFile(this.diskPath(entry), encoding);
88
- }
89
- async write(entry, data, encoding) {
90
- const path = this.diskPath(entry);
91
- await mkdir(dirname(path), { recursive: true });
92
- await writeFile(path, data, encoding);
93
- }
94
- async remove(entry) {
95
- await rm(this.diskPath(entry));
96
- }
97
- async exists(entry) {
98
- try {
99
- await stat(this.diskPath(entry));
100
- return true;
101
- } catch {
102
- return false;
151
+ async write(entry, data, encoding) {
152
+ const path = this.diskPath(entry);
153
+ await mkdir(dirname(path), { recursive: true });
154
+ await writeFile(path, data, encoding);
103
155
  }
104
- }
105
- async archiveLength(entry) {
106
- try {
107
- const st = await stat(this.diskPath(entry));
108
- return st.size;
109
- } catch {
110
- return 0;
156
+ async remove(entry) {
157
+ await rm(this.diskPath(entry));
111
158
  }
112
- }
113
- async *list() {
114
- const entries = await readdir(this.rootPath, {
115
- recursive: true,
116
- withFileTypes: true
117
- });
118
- for (const entry of entries) {
119
- if (entry.isDirectory()) continue;
120
- const absolutePath = join(entry.parentPath, entry.name);
121
- yield {
122
- absolutePath,
123
- relativePath: absolutePath.slice(this.rootPath.length + 1).split(sep).join("/")
124
- };
159
+ async exists(entry) {
160
+ try {
161
+ await stat(this.diskPath(entry));
162
+ return true;
163
+ }
164
+ catch {
165
+ return false;
166
+ }
125
167
  }
126
- }
127
- async duplicate() {
128
- const newRoot = mintRootPath();
129
- try {
130
- await cp(this.rootPath, newRoot, { recursive: true });
131
- } catch (error) {
132
- rmSync(newRoot, { force: true, recursive: true });
133
- throw error;
168
+ async archiveLength(entry) {
169
+ try {
170
+ const st = await stat(this.diskPath(entry));
171
+ return st.size;
172
+ }
173
+ catch {
174
+ return 0;
175
+ }
134
176
  }
135
- return new TmpFsAdapter(newRoot);
136
- }
137
- async serialize(targetPath) {
138
- var _a;
139
- var _stack = [];
140
- try {
141
- const tmpArchivePath = mintRootPath();
142
- const { promise, resolve, reject } = Promise.withResolvers();
143
- const zipfile = new ZipFile();
144
- const writeStream = createWriteStream(tmpArchivePath);
145
- writeStream.on("close", () => {
146
- resolve();
147
- });
148
- writeStream.on("error", reject);
149
- zipfile.outputStream.on("error", reject);
150
- const stack = __using(_stack, new AsyncDisposableStack(), true);
151
- stack.defer(async () => {
152
- writeStream.close();
153
- await rm(tmpArchivePath, { force: true });
154
- });
155
- zipfile.outputStream.pipe(writeStream);
156
- zipfile.addBuffer(Buffer.from(MediaType.EPUB.mime), "mimetype", {
157
- compress: false
158
- });
159
- for await (const entry of this.list()) {
160
- if (entry.relativePath === "mimetype") continue;
161
- zipfile.addFile(entry.absolutePath, entry.relativePath, {
162
- compress: !PRECOMPRESSED_KINDS.has(
163
- (_a = MediaType.fromPath(entry.absolutePath)) == null ? void 0 : _a.kind
164
- )
177
+ async *list() {
178
+ const entries = await readdir(this.rootPath, {
179
+ recursive: true,
180
+ withFileTypes: true,
165
181
  });
166
- }
167
- zipfile.end();
168
- await promise;
169
- await cp(tmpArchivePath, targetPath);
170
- } catch (_) {
171
- var _error = _, _hasError = true;
172
- } finally {
173
- var _promise = __callDispose(_stack, _error, _hasError);
174
- _promise && await _promise;
182
+ for (const entry of entries) {
183
+ if (entry.isDirectory())
184
+ continue;
185
+ const absolutePath = join(entry.parentPath, entry.name);
186
+ yield {
187
+ absolutePath,
188
+ relativePath: absolutePath
189
+ .slice(this.rootPath.length + 1)
190
+ .split(sep)
191
+ .join("/"),
192
+ };
193
+ }
194
+ }
195
+ async duplicate() {
196
+ const newRoot = mintRootPath();
197
+ try {
198
+ await cp(this.rootPath, newRoot, { recursive: true });
199
+ }
200
+ catch (error) {
201
+ rmSync(newRoot, { force: true, recursive: true });
202
+ throw error;
203
+ }
204
+ return new TmpFsAdapter(newRoot);
205
+ }
206
+ async serialize(targetPath) {
207
+ const env_2 = { stack: [], error: void 0, hasError: false };
208
+ try {
209
+ const tmpArchivePath = mintRootPath();
210
+ // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
211
+ const { promise, resolve, reject } = Promise.withResolvers();
212
+ const zipfile = new ZipFile();
213
+ const writeStream = createWriteStream(tmpArchivePath);
214
+ writeStream.on("close", () => {
215
+ resolve();
216
+ });
217
+ writeStream.on("error", reject);
218
+ zipfile.outputStream.on("error", reject);
219
+ const stack = __addDisposableResource(env_2, new AsyncDisposableStack(), true);
220
+ stack.defer(async () => {
221
+ writeStream.close();
222
+ await rm(tmpArchivePath, { force: true });
223
+ });
224
+ zipfile.outputStream.pipe(writeStream);
225
+ zipfile.addBuffer(Buffer.from(MediaType.EPUB.mime), "mimetype", {
226
+ compress: false,
227
+ });
228
+ for await (const entry of this.list()) {
229
+ if (entry.relativePath === "mimetype")
230
+ continue;
231
+ zipfile.addFile(entry.absolutePath, entry.relativePath, {
232
+ compress: !PRECOMPRESSED_KINDS.has(MediaType.fromPath(entry.absolutePath)?.kind),
233
+ });
234
+ }
235
+ zipfile.end();
236
+ await promise;
237
+ await cp(tmpArchivePath, targetPath);
238
+ }
239
+ catch (e_2) {
240
+ env_2.error = e_2;
241
+ env_2.hasError = true;
242
+ }
243
+ finally {
244
+ const result_2 = __disposeResources(env_2);
245
+ if (result_2)
246
+ await result_2;
247
+ }
248
+ }
249
+ dispose() {
250
+ rmSync(this.rootPath, { recursive: true, force: true });
175
251
  }
176
- }
177
- dispose() {
178
- rmSync(this.rootPath, { recursive: true, force: true });
179
- }
180
252
  }
181
- export {
182
- TmpFsAdapter
183
- };
@@ -1,4 +1,4 @@
1
- interface Location {
1
+ export interface Location {
2
2
  url: {
3
3
  hierachical: boolean;
4
4
  opaque: boolean;
@@ -8,16 +8,14 @@ interface Location {
8
8
  column: number;
9
9
  context: string | null;
10
10
  }
11
- interface Message {
11
+ export interface Message {
12
12
  ID: string;
13
13
  severity: "FATAL" | "ERROR" | "WARNING" | "INFO" | "USAGE";
14
14
  message: string;
15
15
  additionalLocations: number;
16
16
  locations: Location[];
17
17
  }
18
- interface Report {
18
+ export interface Report {
19
19
  messages: Message[];
20
20
  }
21
- declare function epubcheck(epubFile: string): Promise<Report>;
22
-
23
- export { type Location, type Message, type Report, epubcheck };
21
+ export declare function epubcheck(epubFile: string): Promise<Report>;