-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
306 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export const MIMETYPE = 'application/epub+zip'; | ||
|
||
export const ImageGif = 'image/gif'; | ||
export const ImageJpeg = 'image/jpeg'; | ||
export const ImagePng = 'image/png'; | ||
export const ImageSvg = 'image/svg+xml'; | ||
export const ImageWebp = 'image/webp'; | ||
|
||
export type ImageMediaType = typeof ImageGif | typeof ImageJpeg | typeof ImagePng; | ||
|
||
export const TextCSS = 'text/css'; | ||
|
||
export const XHTML = 'application/xhtml+xml'; | ||
|
||
export type MediaType = ImageMediaType | typeof TextCSS | typeof XHTML; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { type PathLike, promises as fs } from 'node:fs'; | ||
|
||
import { PackageDocument } from './opf'; | ||
|
||
export class Epubook { | ||
/** | ||
* See: https://www.w3.org/TR/epub-33/#sec-package-doc | ||
* | ||
* Now, it only supports single opf (OEBPS/content.opf) | ||
* | ||
* @returns list of package documents | ||
*/ | ||
private opfs: PackageDocument[] = [new PackageDocument('OEBPS/content.opf')]; | ||
|
||
constructor() {} | ||
|
||
public packageDocuments(): PackageDocument[] { | ||
return this.opfs; | ||
} | ||
|
||
public mainPackageDocument() { | ||
return this.opfs[0]; | ||
} | ||
|
||
async bundle() { | ||
const { bundle } = await import('../bundle'); | ||
return await bundle(this); | ||
} | ||
|
||
async writeFile(file: PathLike) { | ||
const buffer = await this.bundle(); | ||
await fs.writeFile(file, buffer); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './epub'; | ||
|
||
export * from './opf'; |
Oops, something went wrong.