epub-gen3 0.1.0 → 0.2.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.
Binary file
package/index.d.ts CHANGED
@@ -17,6 +17,32 @@ export interface EpubInfo {
17
17
  css?: string
18
18
  /** EPUB spec version (use `3`). */
19
19
  version: number
20
+ /** Raw XML written to `META-INF/encryption.xml`. Pass `null` to omit. */
21
+ encryption?: string
22
+ /** Raw XML written to `META-INF/metadata.xml`. Pass `null` to omit. */
23
+ metadataXml?: string
24
+ /** Raw XML written to `META-INF/manifest.xml`. Pass `null` to omit. */
25
+ manifestXml?: string
26
+ }
27
+ /**
28
+ * An image embedded in the EPUB.
29
+ *
30
+ * Images are written to `OEBPS/images/<path>` and can be referenced from
31
+ * chapter paragraphs with raw markup, e.g.
32
+ * `<img src="images/diagram.png" alt="Diagram" />`.
33
+ */
34
+ export interface EpubImage {
35
+ /** Unique manifest id (letters, digits, `-`, `_`). */
36
+ id: string
37
+ /**
38
+ * File name written under `OEBPS/images/`, e.g. `cover.png`.
39
+ * The extension determines the media-type.
40
+ */
41
+ path: string
42
+ /** Raw image bytes. */
43
+ data: Buffer
44
+ /** When `true`, this image is the book cover (at most one). */
45
+ cover: boolean
20
46
  }
21
47
  /**
22
48
  * EPUB builder.
@@ -28,11 +54,19 @@ export interface EpubInfo {
28
54
  * const epub = new Epub(info, [
29
55
  * ['Chapter One', 'First paragraph.', 'Second paragraph.'],
30
56
  * ]);
57
+ * epub.setImages([
58
+ * { id: 'cover-img', path: 'cover.png', data: coverBytes, cover: true },
59
+ * ]);
31
60
  * ```
32
61
  */
33
62
  export declare class Epub {
34
63
  /** Create a new EPUB builder. */
35
64
  constructor(info: EpubInfo, chapters: Array<Array<string>>)
65
+ /**
66
+ * Attach images to the EPUB. Pass an array of `EpubImage` objects.
67
+ * Flag exactly one with `cover: true` to set the book cover.
68
+ */
69
+ setImages(images: Array<EpubImage>): void
36
70
  /** Build the EPUB and write it to `<title>.epub` in the current working directory. */
37
71
  run(): void
38
72
  /**
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "epub-gen3",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Generate EPUB files from Rust — Node.js native addon",
5
5
  "main": "index.js",
6
+ "browser": "./wasm/epub_gen_wasm.js",
6
7
  "types": "index.d.ts",
7
8
  "napi": {
8
9
  "name": "epub-gen3",
@@ -18,15 +19,18 @@
18
19
  "scripts": {
19
20
  "build": "napi build --platform --release",
20
21
  "build:debug": "napi build --platform",
21
- "prepublish": "napi build --platform --release"
22
+ "build:wasm": "wasm-pack build ../wasm --target web --out-dir ../node/wasm",
23
+ "build:all": "napi build --platform --release && npm run build:wasm"
22
24
  },
23
25
  "devDependencies": {
24
- "@napi-rs/cli": "^2.18.0"
26
+ "@napi-rs/cli": "^2.18.0",
27
+ "wasm-pack": "^0.13.1"
25
28
  },
26
29
  "files": [
27
30
  "index.js",
28
31
  "index.d.ts",
29
- "*.node"
32
+ "*.node",
33
+ "wasm/"
30
34
  ],
31
35
  "license": "MIT"
32
36
  }