epub-gen3 0.2.2 → 0.3.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/dist/browser.d.mts +63 -0
- package/dist/browser.mjs +45 -0
- package/dist/index.d.mts +59 -0
- package/dist/index.mjs +40 -0
- package/epub-gen3.win32-x64-msvc.node +0 -0
- package/index.d.ts +11 -0
- package/package.json +18 -11
- package/wasm/epub_gen_wasm.d.ts +6 -0
- package/wasm/epub_gen_wasm.js +11 -0
- package/wasm/epub_gen_wasm_bg.wasm +0 -0
- package/wasm/epub_gen_wasm_bg.wasm.d.ts +1 -0
- package/browser.js +0 -14
- package/index.mjs +0 -4
- package/wasm/epub_gen_wasm_bg.js +0 -423
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
//#region src/types.d.ts
|
|
2
|
+
/** Metadata for the EPUB document. */
|
|
3
|
+
interface EpubInfo {
|
|
4
|
+
title: string;
|
|
5
|
+
description: string;
|
|
6
|
+
publisher: string;
|
|
7
|
+
author: string;
|
|
8
|
+
/** Label used for the Table of Contents page. */
|
|
9
|
+
tocTitle: string;
|
|
10
|
+
lang: string;
|
|
11
|
+
fonts: string[];
|
|
12
|
+
/** Raw CSS injected as `styles.css`. Omit for an empty stylesheet. */
|
|
13
|
+
css?: string;
|
|
14
|
+
/** EPUB spec version (use `3`). */
|
|
15
|
+
version: number;
|
|
16
|
+
/** Raw XML written to `META-INF/encryption.xml`. Omit to skip. */
|
|
17
|
+
encryption?: string;
|
|
18
|
+
/** Raw XML written to `META-INF/metadata.xml`. Omit to skip. */
|
|
19
|
+
metadataXml?: string;
|
|
20
|
+
/** Raw XML written to `META-INF/manifest.xml`. Omit to skip. */
|
|
21
|
+
manifestXml?: string;
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/browser.d.ts
|
|
25
|
+
interface EpubStylesheet {
|
|
26
|
+
id: string;
|
|
27
|
+
path: string;
|
|
28
|
+
content: string;
|
|
29
|
+
}
|
|
30
|
+
interface EpubImageBrowser {
|
|
31
|
+
id: string;
|
|
32
|
+
path: string;
|
|
33
|
+
/** Raw image bytes as a `Uint8Array`, or a base64-encoded string. */
|
|
34
|
+
data: Uint8Array | string;
|
|
35
|
+
/** When `true`, this image is the book cover (at most one). */
|
|
36
|
+
cover: boolean;
|
|
37
|
+
}
|
|
38
|
+
/** Typed wrapper around the WASM Epub for browser environments. */
|
|
39
|
+
declare class Epub {
|
|
40
|
+
private inner;
|
|
41
|
+
constructor(info: EpubInfo, chapters: string[][]);
|
|
42
|
+
/** Attach additional CSS stylesheets. Linked after `css` (from info), in order. */
|
|
43
|
+
setStylesheets(stylesheets: EpubStylesheet[]): void;
|
|
44
|
+
/** Attach images. `data` may be a `Uint8Array` or a base64-encoded string. */
|
|
45
|
+
setImages(images: EpubImageBrowser[]): void;
|
|
46
|
+
/**
|
|
47
|
+
* Build the EPUB and return its bytes as a `Uint8Array`.
|
|
48
|
+
* No filesystem access is performed — use `Blob` + `URL.createObjectURL` to download.
|
|
49
|
+
*/
|
|
50
|
+
archive(): Uint8Array;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Resolves once the WASM module is initialised.
|
|
54
|
+
*
|
|
55
|
+
* ```ts
|
|
56
|
+
* import { Epub, ready } from 'epub-gen3/browser'
|
|
57
|
+
* await ready
|
|
58
|
+
* const epub = new Epub(info, chapters)
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
declare const ready: Promise<void>;
|
|
62
|
+
//#endregion
|
|
63
|
+
export { Epub, EpubImageBrowser, type EpubInfo, EpubStylesheet, ready };
|
package/dist/browser.mjs
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import wasmInit, { Epub as Epub$1 } from "../wasm/epub_gen_wasm.js";
|
|
2
|
+
//#region src/browser.ts
|
|
3
|
+
function resolveData(data) {
|
|
4
|
+
if (typeof data !== "string") return data;
|
|
5
|
+
const binary = atob(data);
|
|
6
|
+
const out = new Uint8Array(binary.length);
|
|
7
|
+
for (let i = 0; i < binary.length; i++) out[i] = binary.charCodeAt(i);
|
|
8
|
+
return out;
|
|
9
|
+
}
|
|
10
|
+
/** Typed wrapper around the WASM Epub for browser environments. */
|
|
11
|
+
var Epub = class {
|
|
12
|
+
constructor(info, chapters) {
|
|
13
|
+
this.inner = new Epub$1(info, chapters);
|
|
14
|
+
}
|
|
15
|
+
/** Attach additional CSS stylesheets. Linked after `css` (from info), in order. */
|
|
16
|
+
setStylesheets(stylesheets) {
|
|
17
|
+
this.inner.setStylesheets(stylesheets);
|
|
18
|
+
}
|
|
19
|
+
/** Attach images. `data` may be a `Uint8Array` or a base64-encoded string. */
|
|
20
|
+
setImages(images) {
|
|
21
|
+
this.inner.setImages(images.map((img) => ({
|
|
22
|
+
...img,
|
|
23
|
+
data: resolveData(img.data)
|
|
24
|
+
})));
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Build the EPUB and return its bytes as a `Uint8Array`.
|
|
28
|
+
* No filesystem access is performed — use `Blob` + `URL.createObjectURL` to download.
|
|
29
|
+
*/
|
|
30
|
+
archive() {
|
|
31
|
+
return this.inner.archive();
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Resolves once the WASM module is initialised.
|
|
36
|
+
*
|
|
37
|
+
* ```ts
|
|
38
|
+
* import { Epub, ready } from 'epub-gen3/browser'
|
|
39
|
+
* await ready
|
|
40
|
+
* const epub = new Epub(info, chapters)
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
const ready = wasmInit().then(() => void 0);
|
|
44
|
+
//#endregion
|
|
45
|
+
export { Epub, ready };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
//#region src/types.d.ts
|
|
2
|
+
/** Metadata for the EPUB document. */
|
|
3
|
+
interface EpubInfo {
|
|
4
|
+
title: string;
|
|
5
|
+
description: string;
|
|
6
|
+
publisher: string;
|
|
7
|
+
author: string;
|
|
8
|
+
/** Label used for the Table of Contents page. */
|
|
9
|
+
tocTitle: string;
|
|
10
|
+
lang: string;
|
|
11
|
+
fonts: string[];
|
|
12
|
+
/** Raw CSS injected as `styles.css`. Omit for an empty stylesheet. */
|
|
13
|
+
css?: string;
|
|
14
|
+
/** EPUB spec version (use `3`). */
|
|
15
|
+
version: number;
|
|
16
|
+
/** Raw XML written to `META-INF/encryption.xml`. Omit to skip. */
|
|
17
|
+
encryption?: string;
|
|
18
|
+
/** Raw XML written to `META-INF/metadata.xml`. Omit to skip. */
|
|
19
|
+
metadataXml?: string;
|
|
20
|
+
/** Raw XML written to `META-INF/manifest.xml`. Omit to skip. */
|
|
21
|
+
manifestXml?: string;
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/node.d.ts
|
|
25
|
+
interface EpubStylesheet {
|
|
26
|
+
id: string;
|
|
27
|
+
path: string;
|
|
28
|
+
content: string;
|
|
29
|
+
}
|
|
30
|
+
interface EpubImage {
|
|
31
|
+
id: string;
|
|
32
|
+
path: string;
|
|
33
|
+
/** Raw image bytes as a `Buffer`, or a base64-encoded string. */
|
|
34
|
+
data: Buffer | string;
|
|
35
|
+
/** When `true`, this image is the book cover (at most one). */
|
|
36
|
+
cover: boolean;
|
|
37
|
+
}
|
|
38
|
+
/** EPUB builder — Node.js native addon. */
|
|
39
|
+
declare class Epub {
|
|
40
|
+
private inner;
|
|
41
|
+
constructor(info: EpubInfo, chapters: string[][]);
|
|
42
|
+
/** Attach additional CSS stylesheets. Linked after `css` (from info), in order. */
|
|
43
|
+
setStylesheets(stylesheets: EpubStylesheet[]): void;
|
|
44
|
+
/** Attach images. `data` may be a `Buffer` or a base64-encoded string. */
|
|
45
|
+
setImages(images: EpubImage[]): void;
|
|
46
|
+
/** Build the EPUB and write it to `<title>.epub` in the current working directory. */
|
|
47
|
+
run(): void;
|
|
48
|
+
/**
|
|
49
|
+
* Build the EPUB and return its contents as a `Buffer`.
|
|
50
|
+
*
|
|
51
|
+
* ```ts
|
|
52
|
+
* const buf = epub.archive()
|
|
53
|
+
* fs.writeFileSync('book.epub', buf)
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
archive(): Buffer;
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
export { Epub, EpubImage, type EpubInfo, EpubStylesheet };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
//#region src/node.ts
|
|
3
|
+
const NapiEpub = createRequire(import.meta.url)("../index.js").Epub;
|
|
4
|
+
function resolveData(data) {
|
|
5
|
+
return typeof data === "string" ? Buffer.from(data, "base64") : data;
|
|
6
|
+
}
|
|
7
|
+
/** EPUB builder — Node.js native addon. */
|
|
8
|
+
var Epub = class {
|
|
9
|
+
constructor(info, chapters) {
|
|
10
|
+
this.inner = new NapiEpub(info, chapters);
|
|
11
|
+
}
|
|
12
|
+
/** Attach additional CSS stylesheets. Linked after `css` (from info), in order. */
|
|
13
|
+
setStylesheets(stylesheets) {
|
|
14
|
+
this.inner.setStylesheets(stylesheets);
|
|
15
|
+
}
|
|
16
|
+
/** Attach images. `data` may be a `Buffer` or a base64-encoded string. */
|
|
17
|
+
setImages(images) {
|
|
18
|
+
this.inner.setImages(images.map((img) => ({
|
|
19
|
+
...img,
|
|
20
|
+
data: resolveData(img.data)
|
|
21
|
+
})));
|
|
22
|
+
}
|
|
23
|
+
/** Build the EPUB and write it to `<title>.epub` in the current working directory. */
|
|
24
|
+
run() {
|
|
25
|
+
this.inner.run();
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Build the EPUB and return its contents as a `Buffer`.
|
|
29
|
+
*
|
|
30
|
+
* ```ts
|
|
31
|
+
* const buf = epub.archive()
|
|
32
|
+
* fs.writeFileSync('book.epub', buf)
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
archive() {
|
|
36
|
+
return this.inner.archive();
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
//#endregion
|
|
40
|
+
export { Epub };
|
|
Binary file
|
package/index.d.ts
CHANGED
|
@@ -24,6 +24,15 @@ export interface EpubInfo {
|
|
|
24
24
|
/** Raw XML written to `META-INF/manifest.xml`. Pass `null` to omit. */
|
|
25
25
|
manifestXml?: string
|
|
26
26
|
}
|
|
27
|
+
/** A CSS stylesheet included in the EPUB. */
|
|
28
|
+
export interface EpubStylesheet {
|
|
29
|
+
/** Unique manifest id (letters, digits, `-`, `_`). */
|
|
30
|
+
id: string
|
|
31
|
+
/** Path relative to `OEBPS/`, e.g. `"css/typography.css"`. */
|
|
32
|
+
path: string
|
|
33
|
+
/** Raw CSS content. */
|
|
34
|
+
content: string
|
|
35
|
+
}
|
|
27
36
|
/**
|
|
28
37
|
* An image embedded in the EPUB.
|
|
29
38
|
*
|
|
@@ -62,6 +71,8 @@ export interface EpubImage {
|
|
|
62
71
|
export declare class Epub {
|
|
63
72
|
/** Create a new EPUB builder. */
|
|
64
73
|
constructor(info: EpubInfo, chapters: Array<Array<string>>)
|
|
74
|
+
/** Attach additional CSS stylesheets. Linked after `css` (from `EpubInfo`), in order. */
|
|
75
|
+
setStylesheets(stylesheets: Array<EpubStylesheet>): void
|
|
65
76
|
/**
|
|
66
77
|
* Attach images to the EPUB. Pass an array of `EpubImage` objects.
|
|
67
78
|
* Flag exactly one with `cover: true` to set the book cover.
|
package/package.json
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "epub-gen3",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Generate EPUB files from Rust — Node.js native addon",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "index.js",
|
|
6
|
-
"browser": "./browser.
|
|
7
|
-
"types": "index.d.
|
|
7
|
+
"browser": "./dist/browser.mjs",
|
|
8
|
+
"types": "dist/index.d.mts",
|
|
8
9
|
"exports": {
|
|
9
10
|
".": {
|
|
10
|
-
"browser": "./browser.
|
|
11
|
-
"import": "./index.mjs",
|
|
11
|
+
"browser": "./dist/browser.mjs",
|
|
12
|
+
"import": "./dist/index.mjs",
|
|
12
13
|
"require": "./index.js"
|
|
13
14
|
},
|
|
14
|
-
"./browser":
|
|
15
|
+
"./browser": {
|
|
16
|
+
"import": "./dist/browser.mjs",
|
|
17
|
+
"types": "./dist/browser.d.mts"
|
|
18
|
+
},
|
|
15
19
|
"./wasm/*": "./wasm/*"
|
|
16
20
|
},
|
|
17
21
|
"napi": {
|
|
@@ -28,21 +32,24 @@
|
|
|
28
32
|
"scripts": {
|
|
29
33
|
"build": "napi build --platform --release",
|
|
30
34
|
"build:debug": "napi build --platform",
|
|
35
|
+
"build:ts": "tsdown",
|
|
31
36
|
"build:wasm": "wasm-pack build ../wasm --target web --out-dir ../node/wasm && node -e \"require('fs').writeFileSync('wasm/.gitignore', '')\"",
|
|
32
|
-
"build:all": "napi build --platform --release && npm run build:wasm",
|
|
33
|
-
"prepublishOnly": "npm run build:wasm"
|
|
37
|
+
"build:all": "napi build --platform --release && npm run build:wasm && npm run build:ts",
|
|
38
|
+
"prepublishOnly": "npm run build:wasm && npm run build:ts"
|
|
34
39
|
},
|
|
35
40
|
"devDependencies": {
|
|
36
41
|
"@napi-rs/cli": "^2.18.0",
|
|
42
|
+
"@types/node": "^20.0.0",
|
|
43
|
+
"tsdown": "^0.22.2",
|
|
44
|
+
"typescript": "^5.4.0",
|
|
37
45
|
"wasm-pack": "^0.13.1"
|
|
38
46
|
},
|
|
39
47
|
"files": [
|
|
40
48
|
"index.js",
|
|
41
|
-
"index.mjs",
|
|
42
|
-
"browser.js",
|
|
43
49
|
"index.d.ts",
|
|
50
|
+
"dist/",
|
|
44
51
|
"*.node",
|
|
45
52
|
"wasm/"
|
|
46
53
|
],
|
|
47
54
|
"license": "MIT"
|
|
48
|
-
}
|
|
55
|
+
}
|
package/wasm/epub_gen_wasm.d.ts
CHANGED
|
@@ -42,6 +42,11 @@ export class Epub {
|
|
|
42
42
|
* with `cover: true` to set the book cover.
|
|
43
43
|
*/
|
|
44
44
|
setImages(images: any): void;
|
|
45
|
+
/**
|
|
46
|
+
* Attach additional CSS stylesheets. Linked after `css` (from info), in order.
|
|
47
|
+
* Each entry: `{ id: string, path: string, content: string }`.
|
|
48
|
+
*/
|
|
49
|
+
setStylesheets(stylesheets: any): void;
|
|
45
50
|
}
|
|
46
51
|
|
|
47
52
|
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
@@ -52,6 +57,7 @@ export interface InitOutput {
|
|
|
52
57
|
readonly epub_archive: (a: number) => [number, number, number, number];
|
|
53
58
|
readonly epub_new: (a: any, b: any) => [number, number, number];
|
|
54
59
|
readonly epub_setImages: (a: number, b: any) => [number, number];
|
|
60
|
+
readonly epub_setStylesheets: (a: number, b: any) => [number, number];
|
|
55
61
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
56
62
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
57
63
|
readonly __wbindgen_exn_store: (a: number) => void;
|
package/wasm/epub_gen_wasm.js
CHANGED
|
@@ -74,6 +74,17 @@ export class Epub {
|
|
|
74
74
|
throw takeFromExternrefTable0(ret[0]);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Attach additional CSS stylesheets. Linked after `css` (from info), in order.
|
|
79
|
+
* Each entry: `{ id: string, path: string, content: string }`.
|
|
80
|
+
* @param {any} stylesheets
|
|
81
|
+
*/
|
|
82
|
+
setStylesheets(stylesheets) {
|
|
83
|
+
const ret = wasm.epub_setStylesheets(this.__wbg_ptr, stylesheets);
|
|
84
|
+
if (ret[1]) {
|
|
85
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
77
88
|
}
|
|
78
89
|
if (Symbol.dispose) Epub.prototype[Symbol.dispose] = Epub.prototype.free;
|
|
79
90
|
function __wbg_get_imports() {
|
|
Binary file
|
|
@@ -5,6 +5,7 @@ export const __wbg_epub_free: (a: number, b: number) => void;
|
|
|
5
5
|
export const epub_archive: (a: number) => [number, number, number, number];
|
|
6
6
|
export const epub_new: (a: any, b: any) => [number, number, number];
|
|
7
7
|
export const epub_setImages: (a: number, b: any) => [number, number];
|
|
8
|
+
export const epub_setStylesheets: (a: number, b: any) => [number, number];
|
|
8
9
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
9
10
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
10
11
|
export const __wbindgen_exn_store: (a: number) => void;
|
package/browser.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Browser entry-point for epub-gen3.
|
|
3
|
-
*
|
|
4
|
-
* Re-exports the WASM Epub class and a ready promise that resolves once the
|
|
5
|
-
* WASM module is initialised. Import this instead of the raw wasm glue:
|
|
6
|
-
*
|
|
7
|
-
* import { Epub, ready } from 'epub-gen3/browser'
|
|
8
|
-
* await ready
|
|
9
|
-
* const epub = new Epub(info, chapters)
|
|
10
|
-
*/
|
|
11
|
-
import init, { Epub } from './wasm/epub_gen_wasm.js'
|
|
12
|
-
|
|
13
|
-
export { Epub }
|
|
14
|
-
export const ready = init()
|
package/index.mjs
DELETED
package/wasm/epub_gen_wasm_bg.js
DELETED
|
@@ -1,423 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* EPUB builder for browser environments.
|
|
3
|
-
*
|
|
4
|
-
* ```js
|
|
5
|
-
* import init, { Epub } from 'epub-gen3/wasm/epub_gen_wasm.js'
|
|
6
|
-
* await init()
|
|
7
|
-
*
|
|
8
|
-
* const epub = new Epub(
|
|
9
|
-
* { title: 'My Book', description: '...', publisher: '...', author: '...',
|
|
10
|
-
* tocTitle: 'Contents', lang: 'en', fonts: [], version: 3 },
|
|
11
|
-
* [['Chapter One', 'First paragraph.', 'Second paragraph.']]
|
|
12
|
-
* )
|
|
13
|
-
* const bytes = epub.archive() // Uint8Array
|
|
14
|
-
* const blob = new Blob([bytes], { type: 'application/epub+zip' })
|
|
15
|
-
* const url = URL.createObjectURL(blob)
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export class Epub {
|
|
19
|
-
__destroy_into_raw() {
|
|
20
|
-
const ptr = this.__wbg_ptr;
|
|
21
|
-
this.__wbg_ptr = 0;
|
|
22
|
-
EpubFinalization.unregister(this);
|
|
23
|
-
return ptr;
|
|
24
|
-
}
|
|
25
|
-
free() {
|
|
26
|
-
const ptr = this.__destroy_into_raw();
|
|
27
|
-
wasm.__wbg_epub_free(ptr, 0);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Build the EPUB and return its bytes as a `Uint8Array`.
|
|
31
|
-
*
|
|
32
|
-
* No filesystem access is performed — it is up to the caller to write or
|
|
33
|
-
* stream the returned bytes (e.g. via `Blob` + `URL.createObjectURL`).
|
|
34
|
-
* @returns {Uint8Array}
|
|
35
|
-
*/
|
|
36
|
-
archive() {
|
|
37
|
-
const ret = wasm.epub_archive(this.__wbg_ptr);
|
|
38
|
-
if (ret[3]) {
|
|
39
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
40
|
-
}
|
|
41
|
-
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
42
|
-
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
43
|
-
return v1;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Create a new EPUB builder.
|
|
47
|
-
*
|
|
48
|
-
* `info` — plain JS object matching `EpubInfo`.
|
|
49
|
-
* `chapters` — `string[][]` where index 0 of each inner array is the
|
|
50
|
-
* chapter title and remaining entries become `<p>` elements.
|
|
51
|
-
* @param {any} info
|
|
52
|
-
* @param {any} chapters
|
|
53
|
-
*/
|
|
54
|
-
constructor(info, chapters) {
|
|
55
|
-
const ret = wasm.epub_new(info, chapters);
|
|
56
|
-
if (ret[2]) {
|
|
57
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
58
|
-
}
|
|
59
|
-
this.__wbg_ptr = ret[0];
|
|
60
|
-
EpubFinalization.register(this, this.__wbg_ptr, this);
|
|
61
|
-
return this;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
if (Symbol.dispose) Epub.prototype[Symbol.dispose] = Epub.prototype.free;
|
|
65
|
-
export function __wbg_Error_9dc85fe1bc224456(arg0, arg1) {
|
|
66
|
-
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
67
|
-
return ret;
|
|
68
|
-
}
|
|
69
|
-
export function __wbg_Number_4779d427bae39753(arg0) {
|
|
70
|
-
const ret = Number(arg0);
|
|
71
|
-
return ret;
|
|
72
|
-
}
|
|
73
|
-
export function __wbg_String_8564e559799eccda(arg0, arg1) {
|
|
74
|
-
const ret = String(arg1);
|
|
75
|
-
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
76
|
-
const len1 = WASM_VECTOR_LEN;
|
|
77
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
78
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
79
|
-
}
|
|
80
|
-
export function __wbg___wbindgen_boolean_get_b131b2f36d6b2f55(arg0) {
|
|
81
|
-
const v = arg0;
|
|
82
|
-
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
83
|
-
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
84
|
-
}
|
|
85
|
-
export function __wbg___wbindgen_debug_string_56c147eb1a51f0c4(arg0, arg1) {
|
|
86
|
-
const ret = debugString(arg1);
|
|
87
|
-
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
88
|
-
const len1 = WASM_VECTOR_LEN;
|
|
89
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
90
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
91
|
-
}
|
|
92
|
-
export function __wbg___wbindgen_in_ce8569b2fc6f5088(arg0, arg1) {
|
|
93
|
-
const ret = arg0 in arg1;
|
|
94
|
-
return ret;
|
|
95
|
-
}
|
|
96
|
-
export function __wbg___wbindgen_is_function_147961669f068cd4(arg0) {
|
|
97
|
-
const ret = typeof(arg0) === 'function';
|
|
98
|
-
return ret;
|
|
99
|
-
}
|
|
100
|
-
export function __wbg___wbindgen_is_object_3a2c414391dbf751(arg0) {
|
|
101
|
-
const val = arg0;
|
|
102
|
-
const ret = typeof(val) === 'object' && val !== null;
|
|
103
|
-
return ret;
|
|
104
|
-
}
|
|
105
|
-
export function __wbg___wbindgen_is_undefined_4410e3c20a99fa97(arg0) {
|
|
106
|
-
const ret = arg0 === undefined;
|
|
107
|
-
return ret;
|
|
108
|
-
}
|
|
109
|
-
export function __wbg___wbindgen_jsval_loose_eq_e07e3b1f5db6da6c(arg0, arg1) {
|
|
110
|
-
const ret = arg0 == arg1;
|
|
111
|
-
return ret;
|
|
112
|
-
}
|
|
113
|
-
export function __wbg___wbindgen_number_get_588ed6b97f0d7e14(arg0, arg1) {
|
|
114
|
-
const obj = arg1;
|
|
115
|
-
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
116
|
-
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
117
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
118
|
-
}
|
|
119
|
-
export function __wbg___wbindgen_string_get_fa2687d531ed17a5(arg0, arg1) {
|
|
120
|
-
const obj = arg1;
|
|
121
|
-
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
122
|
-
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
123
|
-
var len1 = WASM_VECTOR_LEN;
|
|
124
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
125
|
-
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
126
|
-
}
|
|
127
|
-
export function __wbg___wbindgen_throw_bbadd78c1bac3a77(arg0, arg1) {
|
|
128
|
-
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
129
|
-
}
|
|
130
|
-
export function __wbg_call_91f00ddc43e01490() { return handleError(function (arg0, arg1) {
|
|
131
|
-
const ret = arg0.call(arg1);
|
|
132
|
-
return ret;
|
|
133
|
-
}, arguments); }
|
|
134
|
-
export function __wbg_done_6a8439e544ec6206(arg0) {
|
|
135
|
-
const ret = arg0.done;
|
|
136
|
-
return ret;
|
|
137
|
-
}
|
|
138
|
-
export function __wbg_getRandomValues_a697888e9ba1eee3() { return handleError(function (arg0, arg1) {
|
|
139
|
-
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
140
|
-
}, arguments); }
|
|
141
|
-
export function __wbg_getTime_ef2e115ede346a26(arg0) {
|
|
142
|
-
const ret = arg0.getTime();
|
|
143
|
-
return ret;
|
|
144
|
-
}
|
|
145
|
-
export function __wbg_get_44e98e27bda25b5b() { return handleError(function (arg0, arg1) {
|
|
146
|
-
const ret = Reflect.get(arg0, arg1);
|
|
147
|
-
return ret;
|
|
148
|
-
}, arguments); }
|
|
149
|
-
export function __wbg_get_unchecked_46e778e3cec74b5e(arg0, arg1) {
|
|
150
|
-
const ret = arg0[arg1 >>> 0];
|
|
151
|
-
return ret;
|
|
152
|
-
}
|
|
153
|
-
export function __wbg_get_with_ref_key_6412cf3094599694(arg0, arg1) {
|
|
154
|
-
const ret = arg0[arg1];
|
|
155
|
-
return ret;
|
|
156
|
-
}
|
|
157
|
-
export function __wbg_instanceof_ArrayBuffer_a581da923203f29f(arg0) {
|
|
158
|
-
let result;
|
|
159
|
-
try {
|
|
160
|
-
result = arg0 instanceof ArrayBuffer;
|
|
161
|
-
} catch (_) {
|
|
162
|
-
result = false;
|
|
163
|
-
}
|
|
164
|
-
const ret = result;
|
|
165
|
-
return ret;
|
|
166
|
-
}
|
|
167
|
-
export function __wbg_instanceof_Uint8Array_b6fe1ac89eba107e(arg0) {
|
|
168
|
-
let result;
|
|
169
|
-
try {
|
|
170
|
-
result = arg0 instanceof Uint8Array;
|
|
171
|
-
} catch (_) {
|
|
172
|
-
result = false;
|
|
173
|
-
}
|
|
174
|
-
const ret = result;
|
|
175
|
-
return ret;
|
|
176
|
-
}
|
|
177
|
-
export function __wbg_isArray_139f48e3c057ede8(arg0) {
|
|
178
|
-
const ret = Array.isArray(arg0);
|
|
179
|
-
return ret;
|
|
180
|
-
}
|
|
181
|
-
export function __wbg_isSafeInteger_c22ccb4af2201fe9(arg0) {
|
|
182
|
-
const ret = Number.isSafeInteger(arg0);
|
|
183
|
-
return ret;
|
|
184
|
-
}
|
|
185
|
-
export function __wbg_iterator_9b36cebf3be7b7cd() {
|
|
186
|
-
const ret = Symbol.iterator;
|
|
187
|
-
return ret;
|
|
188
|
-
}
|
|
189
|
-
export function __wbg_length_68a9d5278d084f4f(arg0) {
|
|
190
|
-
const ret = arg0.length;
|
|
191
|
-
return ret;
|
|
192
|
-
}
|
|
193
|
-
export function __wbg_length_fb04d16d7bdf6d4c(arg0) {
|
|
194
|
-
const ret = arg0.length;
|
|
195
|
-
return ret;
|
|
196
|
-
}
|
|
197
|
-
export function __wbg_new_0_878c6ec3a1c600f3() {
|
|
198
|
-
const ret = new Date();
|
|
199
|
-
return ret;
|
|
200
|
-
}
|
|
201
|
-
export function __wbg_new_b06772b280cc6e52(arg0) {
|
|
202
|
-
const ret = new Uint8Array(arg0);
|
|
203
|
-
return ret;
|
|
204
|
-
}
|
|
205
|
-
export function __wbg_next_8cb028b6ba50743f() { return handleError(function (arg0) {
|
|
206
|
-
const ret = arg0.next();
|
|
207
|
-
return ret;
|
|
208
|
-
}, arguments); }
|
|
209
|
-
export function __wbg_next_cfd0b146c9538df8(arg0) {
|
|
210
|
-
const ret = arg0.next;
|
|
211
|
-
return ret;
|
|
212
|
-
}
|
|
213
|
-
export function __wbg_prototypesetcall_956c7493c68e29b4(arg0, arg1, arg2) {
|
|
214
|
-
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
215
|
-
}
|
|
216
|
-
export function __wbg_value_3d3defe09fb1ffca(arg0) {
|
|
217
|
-
const ret = arg0.value;
|
|
218
|
-
return ret;
|
|
219
|
-
}
|
|
220
|
-
export function __wbindgen_cast_0000000000000001(arg0, arg1) {
|
|
221
|
-
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
222
|
-
const ret = getStringFromWasm0(arg0, arg1);
|
|
223
|
-
return ret;
|
|
224
|
-
}
|
|
225
|
-
export function __wbindgen_init_externref_table() {
|
|
226
|
-
const table = wasm.__wbindgen_externrefs;
|
|
227
|
-
const offset = table.grow(4);
|
|
228
|
-
table.set(0, undefined);
|
|
229
|
-
table.set(offset + 0, undefined);
|
|
230
|
-
table.set(offset + 1, null);
|
|
231
|
-
table.set(offset + 2, true);
|
|
232
|
-
table.set(offset + 3, false);
|
|
233
|
-
}
|
|
234
|
-
const EpubFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
235
|
-
? { register: () => {}, unregister: () => {} }
|
|
236
|
-
: new FinalizationRegistry(ptr => wasm.__wbg_epub_free(ptr, 1));
|
|
237
|
-
|
|
238
|
-
function addToExternrefTable0(obj) {
|
|
239
|
-
const idx = wasm.__externref_table_alloc();
|
|
240
|
-
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
241
|
-
return idx;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
function debugString(val) {
|
|
245
|
-
// primitive types
|
|
246
|
-
const type = typeof val;
|
|
247
|
-
if (type == 'number' || type == 'boolean' || val == null) {
|
|
248
|
-
return `${val}`;
|
|
249
|
-
}
|
|
250
|
-
if (type == 'string') {
|
|
251
|
-
return `"${val}"`;
|
|
252
|
-
}
|
|
253
|
-
if (type == 'symbol') {
|
|
254
|
-
const description = val.description;
|
|
255
|
-
if (description == null) {
|
|
256
|
-
return 'Symbol';
|
|
257
|
-
} else {
|
|
258
|
-
return `Symbol(${description})`;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
if (type == 'function') {
|
|
262
|
-
const name = val.name;
|
|
263
|
-
if (typeof name == 'string' && name.length > 0) {
|
|
264
|
-
return `Function(${name})`;
|
|
265
|
-
} else {
|
|
266
|
-
return 'Function';
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
// objects
|
|
270
|
-
if (Array.isArray(val)) {
|
|
271
|
-
const length = val.length;
|
|
272
|
-
let debug = '[';
|
|
273
|
-
if (length > 0) {
|
|
274
|
-
debug += debugString(val[0]);
|
|
275
|
-
}
|
|
276
|
-
for(let i = 1; i < length; i++) {
|
|
277
|
-
debug += ', ' + debugString(val[i]);
|
|
278
|
-
}
|
|
279
|
-
debug += ']';
|
|
280
|
-
return debug;
|
|
281
|
-
}
|
|
282
|
-
// Test for built-in
|
|
283
|
-
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
284
|
-
let className;
|
|
285
|
-
if (builtInMatches && builtInMatches.length > 1) {
|
|
286
|
-
className = builtInMatches[1];
|
|
287
|
-
} else {
|
|
288
|
-
// Failed to match the standard '[object ClassName]'
|
|
289
|
-
return toString.call(val);
|
|
290
|
-
}
|
|
291
|
-
if (className == 'Object') {
|
|
292
|
-
// we're a user defined class or Object
|
|
293
|
-
// JSON.stringify avoids problems with cycles, and is generally much
|
|
294
|
-
// easier than looping through ownProperties of `val`.
|
|
295
|
-
try {
|
|
296
|
-
return 'Object(' + JSON.stringify(val) + ')';
|
|
297
|
-
} catch (_) {
|
|
298
|
-
return 'Object';
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
// errors
|
|
302
|
-
if (val instanceof Error) {
|
|
303
|
-
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
304
|
-
}
|
|
305
|
-
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
306
|
-
return className;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
function getArrayU8FromWasm0(ptr, len) {
|
|
310
|
-
ptr = ptr >>> 0;
|
|
311
|
-
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
let cachedDataViewMemory0 = null;
|
|
315
|
-
function getDataViewMemory0() {
|
|
316
|
-
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
317
|
-
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
318
|
-
}
|
|
319
|
-
return cachedDataViewMemory0;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
function getStringFromWasm0(ptr, len) {
|
|
323
|
-
return decodeText(ptr >>> 0, len);
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
let cachedUint8ArrayMemory0 = null;
|
|
327
|
-
function getUint8ArrayMemory0() {
|
|
328
|
-
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
329
|
-
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
330
|
-
}
|
|
331
|
-
return cachedUint8ArrayMemory0;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
function handleError(f, args) {
|
|
335
|
-
try {
|
|
336
|
-
return f.apply(this, args);
|
|
337
|
-
} catch (e) {
|
|
338
|
-
const idx = addToExternrefTable0(e);
|
|
339
|
-
wasm.__wbindgen_exn_store(idx);
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
function isLikeNone(x) {
|
|
344
|
-
return x === undefined || x === null;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
function passStringToWasm0(arg, malloc, realloc) {
|
|
348
|
-
if (realloc === undefined) {
|
|
349
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
350
|
-
const ptr = malloc(buf.length, 1) >>> 0;
|
|
351
|
-
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
352
|
-
WASM_VECTOR_LEN = buf.length;
|
|
353
|
-
return ptr;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
let len = arg.length;
|
|
357
|
-
let ptr = malloc(len, 1) >>> 0;
|
|
358
|
-
|
|
359
|
-
const mem = getUint8ArrayMemory0();
|
|
360
|
-
|
|
361
|
-
let offset = 0;
|
|
362
|
-
|
|
363
|
-
for (; offset < len; offset++) {
|
|
364
|
-
const code = arg.charCodeAt(offset);
|
|
365
|
-
if (code > 0x7F) break;
|
|
366
|
-
mem[ptr + offset] = code;
|
|
367
|
-
}
|
|
368
|
-
if (offset !== len) {
|
|
369
|
-
if (offset !== 0) {
|
|
370
|
-
arg = arg.slice(offset);
|
|
371
|
-
}
|
|
372
|
-
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
373
|
-
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
374
|
-
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
375
|
-
|
|
376
|
-
offset += ret.written;
|
|
377
|
-
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
WASM_VECTOR_LEN = offset;
|
|
381
|
-
return ptr;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
function takeFromExternrefTable0(idx) {
|
|
385
|
-
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
386
|
-
wasm.__externref_table_dealloc(idx);
|
|
387
|
-
return value;
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
391
|
-
cachedTextDecoder.decode();
|
|
392
|
-
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
393
|
-
let numBytesDecoded = 0;
|
|
394
|
-
function decodeText(ptr, len) {
|
|
395
|
-
numBytesDecoded += len;
|
|
396
|
-
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
397
|
-
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
398
|
-
cachedTextDecoder.decode();
|
|
399
|
-
numBytesDecoded = len;
|
|
400
|
-
}
|
|
401
|
-
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
const cachedTextEncoder = new TextEncoder();
|
|
405
|
-
|
|
406
|
-
if (!('encodeInto' in cachedTextEncoder)) {
|
|
407
|
-
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
408
|
-
const buf = cachedTextEncoder.encode(arg);
|
|
409
|
-
view.set(buf);
|
|
410
|
-
return {
|
|
411
|
-
read: arg.length,
|
|
412
|
-
written: buf.length
|
|
413
|
-
};
|
|
414
|
-
};
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
let WASM_VECTOR_LEN = 0;
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
let wasm;
|
|
421
|
-
export function __wbg_set_wasm(val) {
|
|
422
|
-
wasm = val;
|
|
423
|
-
}
|