@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.
- package/README.md +1363 -775
- package/dist/adapters/interface.d.ts +6 -8
- package/dist/adapters/interface.js +1 -0
- package/dist/adapters/memory.d.ts +3 -6
- package/dist/adapters/memory.js +69 -64
- package/dist/adapters/tmpfs.d.ts +2 -5
- package/dist/adapters/tmpfs.js +230 -161
- package/dist/epubcheck.d.ts +4 -6
- package/dist/epubcheck.js +24 -26
- package/dist/index.d.ts +1161 -5
- package/dist/index.js +2581 -2739
- package/dist/upgrade.d.ts +23 -1183
- package/dist/upgrade.js +412 -432
- package/dist/zip.d.ts +2 -5
- package/dist/zip.js +113 -100
- package/package.json +18 -31
- package/dist/adapters/interface.cjs +0 -16
- package/dist/adapters/interface.d.cts +0 -75
- package/dist/adapters/memory.cjs +0 -93
- package/dist/adapters/memory.d.cts +0 -36
- package/dist/adapters/tmpfs.cjs +0 -240
- package/dist/adapters/tmpfs.d.cts +0 -31
- package/dist/chunk-BIEQXUOY.js +0 -50
- package/dist/epubcheck.cjs +0 -60
- package/dist/epubcheck.d.cts +0 -23
- package/dist/index.cjs +0 -2846
- package/dist/index.d.cts +0 -5
- package/dist/upgrade.cjs +0 -523
- package/dist/upgrade.d.cts +0 -1196
- package/dist/zip.cjs +0 -142
- package/dist/zip.d.cts +0 -5
package/dist/epubcheck.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import "./chunk-BIEQXUOY.js";
|
|
2
1
|
import { execFile } from "node:child_process";
|
|
3
2
|
import { randomUUID } from "node:crypto";
|
|
4
3
|
import { readFile, unlink } from "node:fs/promises";
|
|
@@ -8,29 +7,28 @@ import { promisify } from "node:util";
|
|
|
8
7
|
import { scratchPath } from "@storyteller-platform/fs";
|
|
9
8
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
10
9
|
const JAR = join(here, "vendors", "epubcheck-5.3.0", "epubcheck.jar");
|
|
11
|
-
async function epubcheck(epubFile) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
10
|
+
export async function epubcheck(epubFile) {
|
|
11
|
+
const output = scratchPath(`epubcheck-${randomUUID()}.json`);
|
|
12
|
+
const execFilePromise = promisify(execFile);
|
|
13
|
+
try {
|
|
14
|
+
await execFilePromise("java", [
|
|
15
|
+
"-jar",
|
|
16
|
+
JAR,
|
|
17
|
+
"--json",
|
|
18
|
+
output,
|
|
19
|
+
epubFile,
|
|
20
|
+
]).catch((error) => {
|
|
21
|
+
if (error instanceof Error &&
|
|
22
|
+
error.message.includes("Check finished with errors")) {
|
|
23
|
+
// dont throw, just let the caller handle it
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
throw error;
|
|
27
|
+
});
|
|
28
|
+
const json = await readFile(output, "utf8");
|
|
29
|
+
return JSON.parse(json);
|
|
30
|
+
}
|
|
31
|
+
finally {
|
|
32
|
+
await unlink(output).catch(() => { });
|
|
33
|
+
}
|
|
33
34
|
}
|
|
34
|
-
export {
|
|
35
|
-
epubcheck
|
|
36
|
-
};
|