epublib 0.1.1 → 0.1.4
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/dist/epub.d.ts.map +1 -1
- package/dist/epub.js +6 -3
- package/package.json +1 -1
package/dist/epub.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"epub.d.ts","sourceRoot":"","sources":["../src/epub.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"epub.d.ts","sourceRoot":"","sources":["../src/epub.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,SAAS,CAAC;AAiB7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAI9C,UAAU,gBAAgB;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B;AAED,UAAU,qBAAqB;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,mBAAmB;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,IAAI,EAAE,UAAU,GAAG,SAAS,CAAC;CAC7B;AAED,qBAAa,QAAQ;;IASpB,IAAI,QAAQ,WAEX;IAED,IAAI,GAAG,WAEN;IAED,IAAI,YAAY;;;;;;;;;;;;;;MAEf;IAED,IAAI,OAAO,cAEV;IAED,IAAI,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAEb;gBAqGW,QAAQ,EAAE,MAAM,EAAE,GAAG,UAAQ;IAgBzC,aAAa,IAAI,IAAI,GAAG,SAAS;IAmFjC,QAAQ,IAAI,gBAAgB;IAmE5B,SAAS,IAAI,MAAM,GAAG,SAAS;IAgE/B,WAAW,IAAI,gBAAgB;IAa/B,aAAa,IAAI,qBAAqB,GAAG,SAAS;IAmFlD,OAAO,CACN,MAAM,GAAE,OAAO,CAAC;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,CAAuB,GAC3D,MAAM,GAAG,SAAS;IAmCrB,YAAY,IAAI,MAAM,GAAG,SAAS;IAMlC,cAAc,CAAC,YAAY,GAAE,OAAc,GAAG,MAAM,GAAG,SAAS;IAWhE,eAAe,CACd,aAAa,GAAE,UAAU,EAAY,GACnC,mBAAmB,EAAE,GAAG,SAAS;CAwEpC"}
|
package/dist/epub.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import AdmZip from "adm-zip";
|
|
2
2
|
import { accessSync, constants } from "node:fs";
|
|
3
|
-
import { basename, dirname,
|
|
3
|
+
import { basename, dirname, normalize, resolve } from "node:path";
|
|
4
|
+
import { join as joinPosix } from "node:path/posix";
|
|
4
5
|
import { satisfies, valid } from "semver";
|
|
5
6
|
import { Temporal } from "temporal-polyfill";
|
|
6
7
|
import z, {} from "zod";
|
|
@@ -120,7 +121,8 @@ export class EpubFile {
|
|
|
120
121
|
if (!manifestItem) {
|
|
121
122
|
return undefined;
|
|
122
123
|
}
|
|
123
|
-
const
|
|
124
|
+
const dirnamePackageOpf = dirname(t.#packageOpfPath);
|
|
125
|
+
const coverImagePath = joinPosix(dirnamePackageOpf === "." ? "" : dirnamePackageOpf, manifestItem["@_href"]);
|
|
124
126
|
const entry = t.#zip.getEntry(coverImagePath);
|
|
125
127
|
if (entry === null) {
|
|
126
128
|
throw new Error(`Could not find "${coverImagePath}" in epub "${t.#filePath}"`);
|
|
@@ -134,7 +136,8 @@ export class EpubFile {
|
|
|
134
136
|
if (typeof coverImageItem === "undefined") {
|
|
135
137
|
return epub2get(this);
|
|
136
138
|
}
|
|
137
|
-
const
|
|
139
|
+
const dirnamePackageOpf = dirname(this.#packageOpfPath);
|
|
140
|
+
const coverImagePath = joinPosix(dirnamePackageOpf === "." ? "" : dirnamePackageOpf, coverImageItem["@_href"]);
|
|
138
141
|
const entry = this.#zip.getEntry(coverImagePath);
|
|
139
142
|
if (entry === null) {
|
|
140
143
|
throw new Error(`Could not find "${coverImagePath}" in epub "${this.#filePath}"`);
|