epub-gen3 0.2.1 → 0.2.2
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/package.json +4 -3
- package/wasm/epub_gen_wasm.d.ts +85 -0
- package/wasm/epub_gen_wasm.js +535 -0
- package/wasm/epub_gen_wasm_bg.js +423 -0
- package/wasm/epub_gen_wasm_bg.wasm +0 -0
- package/wasm/epub_gen_wasm_bg.wasm.d.ts +15 -0
- package/wasm/package.json +15 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "epub-gen3",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Generate EPUB files from Rust — Node.js native addon",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"browser": "./browser.js",
|
|
@@ -28,8 +28,9 @@
|
|
|
28
28
|
"scripts": {
|
|
29
29
|
"build": "napi build --platform --release",
|
|
30
30
|
"build:debug": "napi build --platform",
|
|
31
|
-
"build:wasm": "wasm-pack build ../wasm --target web --out-dir ../node/wasm",
|
|
32
|
-
"build:all": "napi build --platform --release && npm run build:wasm"
|
|
31
|
+
"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"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
36
|
"@napi-rs/cli": "^2.18.0",
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* EPUB builder for browser environments.
|
|
6
|
+
*
|
|
7
|
+
* ```js
|
|
8
|
+
* import init, { Epub } from 'epub-gen3/wasm/epub_gen_wasm.js'
|
|
9
|
+
* await init()
|
|
10
|
+
*
|
|
11
|
+
* const epub = new Epub(
|
|
12
|
+
* { title: 'My Book', description: '...', publisher: '...', author: '...',
|
|
13
|
+
* tocTitle: 'Contents', lang: 'en', fonts: [], version: 3 },
|
|
14
|
+
* [['Chapter One', 'First paragraph.', 'Second paragraph.']]
|
|
15
|
+
* )
|
|
16
|
+
* const bytes = epub.archive() // Uint8Array
|
|
17
|
+
* const blob = new Blob([bytes], { type: 'application/epub+zip' })
|
|
18
|
+
* const url = URL.createObjectURL(blob)
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export class Epub {
|
|
22
|
+
free(): void;
|
|
23
|
+
[Symbol.dispose](): void;
|
|
24
|
+
/**
|
|
25
|
+
* Build the EPUB and return its bytes as a `Uint8Array`.
|
|
26
|
+
*
|
|
27
|
+
* No filesystem access is performed — it is up to the caller to write or
|
|
28
|
+
* stream the returned bytes (e.g. via `Blob` + `URL.createObjectURL`).
|
|
29
|
+
*/
|
|
30
|
+
archive(): Uint8Array;
|
|
31
|
+
/**
|
|
32
|
+
* Create a new EPUB builder.
|
|
33
|
+
*
|
|
34
|
+
* `info` — plain JS object matching `EpubInfo`.
|
|
35
|
+
* `chapters` — `string[][]` where index 0 of each inner array is the
|
|
36
|
+
* chapter title and remaining entries become `<p>` elements.
|
|
37
|
+
*/
|
|
38
|
+
constructor(info: any, chapters: any);
|
|
39
|
+
/**
|
|
40
|
+
* Attach images. Pass an array of `{ id, path, data, cover }` objects
|
|
41
|
+
* where `data` is a `Uint8Array` of the raw image bytes. Flag exactly one
|
|
42
|
+
* with `cover: true` to set the book cover.
|
|
43
|
+
*/
|
|
44
|
+
setImages(images: any): void;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
48
|
+
|
|
49
|
+
export interface InitOutput {
|
|
50
|
+
readonly memory: WebAssembly.Memory;
|
|
51
|
+
readonly __wbg_epub_free: (a: number, b: number) => void;
|
|
52
|
+
readonly epub_archive: (a: number) => [number, number, number, number];
|
|
53
|
+
readonly epub_new: (a: any, b: any) => [number, number, number];
|
|
54
|
+
readonly epub_setImages: (a: number, b: any) => [number, number];
|
|
55
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
56
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
57
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
58
|
+
readonly __externref_table_alloc: () => number;
|
|
59
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
60
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
61
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
62
|
+
readonly __wbindgen_start: () => void;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
69
|
+
* a precompiled `WebAssembly.Module`.
|
|
70
|
+
*
|
|
71
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
72
|
+
*
|
|
73
|
+
* @returns {InitOutput}
|
|
74
|
+
*/
|
|
75
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
79
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
80
|
+
*
|
|
81
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
82
|
+
*
|
|
83
|
+
* @returns {Promise<InitOutput>}
|
|
84
|
+
*/
|
|
85
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
@@ -0,0 +1,535 @@
|
|
|
1
|
+
/* @ts-self-types="./epub_gen_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* EPUB builder for browser environments.
|
|
5
|
+
*
|
|
6
|
+
* ```js
|
|
7
|
+
* import init, { Epub } from 'epub-gen3/wasm/epub_gen_wasm.js'
|
|
8
|
+
* await init()
|
|
9
|
+
*
|
|
10
|
+
* const epub = new Epub(
|
|
11
|
+
* { title: 'My Book', description: '...', publisher: '...', author: '...',
|
|
12
|
+
* tocTitle: 'Contents', lang: 'en', fonts: [], version: 3 },
|
|
13
|
+
* [['Chapter One', 'First paragraph.', 'Second paragraph.']]
|
|
14
|
+
* )
|
|
15
|
+
* const bytes = epub.archive() // Uint8Array
|
|
16
|
+
* const blob = new Blob([bytes], { type: 'application/epub+zip' })
|
|
17
|
+
* const url = URL.createObjectURL(blob)
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export class Epub {
|
|
21
|
+
__destroy_into_raw() {
|
|
22
|
+
const ptr = this.__wbg_ptr;
|
|
23
|
+
this.__wbg_ptr = 0;
|
|
24
|
+
EpubFinalization.unregister(this);
|
|
25
|
+
return ptr;
|
|
26
|
+
}
|
|
27
|
+
free() {
|
|
28
|
+
const ptr = this.__destroy_into_raw();
|
|
29
|
+
wasm.__wbg_epub_free(ptr, 0);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Build the EPUB and return its bytes as a `Uint8Array`.
|
|
33
|
+
*
|
|
34
|
+
* No filesystem access is performed — it is up to the caller to write or
|
|
35
|
+
* stream the returned bytes (e.g. via `Blob` + `URL.createObjectURL`).
|
|
36
|
+
* @returns {Uint8Array}
|
|
37
|
+
*/
|
|
38
|
+
archive() {
|
|
39
|
+
const ret = wasm.epub_archive(this.__wbg_ptr);
|
|
40
|
+
if (ret[3]) {
|
|
41
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
42
|
+
}
|
|
43
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
44
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
45
|
+
return v1;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Create a new EPUB builder.
|
|
49
|
+
*
|
|
50
|
+
* `info` — plain JS object matching `EpubInfo`.
|
|
51
|
+
* `chapters` — `string[][]` where index 0 of each inner array is the
|
|
52
|
+
* chapter title and remaining entries become `<p>` elements.
|
|
53
|
+
* @param {any} info
|
|
54
|
+
* @param {any} chapters
|
|
55
|
+
*/
|
|
56
|
+
constructor(info, chapters) {
|
|
57
|
+
const ret = wasm.epub_new(info, chapters);
|
|
58
|
+
if (ret[2]) {
|
|
59
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
60
|
+
}
|
|
61
|
+
this.__wbg_ptr = ret[0];
|
|
62
|
+
EpubFinalization.register(this, this.__wbg_ptr, this);
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Attach images. Pass an array of `{ id, path, data, cover }` objects
|
|
67
|
+
* where `data` is a `Uint8Array` of the raw image bytes. Flag exactly one
|
|
68
|
+
* with `cover: true` to set the book cover.
|
|
69
|
+
* @param {any} images
|
|
70
|
+
*/
|
|
71
|
+
setImages(images) {
|
|
72
|
+
const ret = wasm.epub_setImages(this.__wbg_ptr, images);
|
|
73
|
+
if (ret[1]) {
|
|
74
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (Symbol.dispose) Epub.prototype[Symbol.dispose] = Epub.prototype.free;
|
|
79
|
+
function __wbg_get_imports() {
|
|
80
|
+
const import0 = {
|
|
81
|
+
__proto__: null,
|
|
82
|
+
__wbg_Error_9dc85fe1bc224456: function(arg0, arg1) {
|
|
83
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
84
|
+
return ret;
|
|
85
|
+
},
|
|
86
|
+
__wbg_Number_4779d427bae39753: function(arg0) {
|
|
87
|
+
const ret = Number(arg0);
|
|
88
|
+
return ret;
|
|
89
|
+
},
|
|
90
|
+
__wbg_String_8564e559799eccda: function(arg0, arg1) {
|
|
91
|
+
const ret = String(arg1);
|
|
92
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
93
|
+
const len1 = WASM_VECTOR_LEN;
|
|
94
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
95
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
96
|
+
},
|
|
97
|
+
__wbg___wbindgen_boolean_get_b131b2f36d6b2f55: function(arg0) {
|
|
98
|
+
const v = arg0;
|
|
99
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
100
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
101
|
+
},
|
|
102
|
+
__wbg___wbindgen_debug_string_56c147eb1a51f0c4: function(arg0, arg1) {
|
|
103
|
+
const ret = debugString(arg1);
|
|
104
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
105
|
+
const len1 = WASM_VECTOR_LEN;
|
|
106
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
107
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
108
|
+
},
|
|
109
|
+
__wbg___wbindgen_in_ce8569b2fc6f5088: function(arg0, arg1) {
|
|
110
|
+
const ret = arg0 in arg1;
|
|
111
|
+
return ret;
|
|
112
|
+
},
|
|
113
|
+
__wbg___wbindgen_is_function_147961669f068cd4: function(arg0) {
|
|
114
|
+
const ret = typeof(arg0) === 'function';
|
|
115
|
+
return ret;
|
|
116
|
+
},
|
|
117
|
+
__wbg___wbindgen_is_object_3a2c414391dbf751: function(arg0) {
|
|
118
|
+
const val = arg0;
|
|
119
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
120
|
+
return ret;
|
|
121
|
+
},
|
|
122
|
+
__wbg___wbindgen_is_undefined_4410e3c20a99fa97: function(arg0) {
|
|
123
|
+
const ret = arg0 === undefined;
|
|
124
|
+
return ret;
|
|
125
|
+
},
|
|
126
|
+
__wbg___wbindgen_jsval_loose_eq_e07e3b1f5db6da6c: function(arg0, arg1) {
|
|
127
|
+
const ret = arg0 == arg1;
|
|
128
|
+
return ret;
|
|
129
|
+
},
|
|
130
|
+
__wbg___wbindgen_number_get_588ed6b97f0d7e14: function(arg0, arg1) {
|
|
131
|
+
const obj = arg1;
|
|
132
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
133
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
134
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
135
|
+
},
|
|
136
|
+
__wbg___wbindgen_string_get_fa2687d531ed17a5: function(arg0, arg1) {
|
|
137
|
+
const obj = arg1;
|
|
138
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
139
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
140
|
+
var len1 = WASM_VECTOR_LEN;
|
|
141
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
142
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
143
|
+
},
|
|
144
|
+
__wbg___wbindgen_throw_bbadd78c1bac3a77: function(arg0, arg1) {
|
|
145
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
146
|
+
},
|
|
147
|
+
__wbg_call_91f00ddc43e01490: function() { return handleError(function (arg0, arg1) {
|
|
148
|
+
const ret = arg0.call(arg1);
|
|
149
|
+
return ret;
|
|
150
|
+
}, arguments); },
|
|
151
|
+
__wbg_done_6a8439e544ec6206: function(arg0) {
|
|
152
|
+
const ret = arg0.done;
|
|
153
|
+
return ret;
|
|
154
|
+
},
|
|
155
|
+
__wbg_getRandomValues_a697888e9ba1eee3: function() { return handleError(function (arg0, arg1) {
|
|
156
|
+
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
157
|
+
}, arguments); },
|
|
158
|
+
__wbg_getTime_ef2e115ede346a26: function(arg0) {
|
|
159
|
+
const ret = arg0.getTime();
|
|
160
|
+
return ret;
|
|
161
|
+
},
|
|
162
|
+
__wbg_get_44e98e27bda25b5b: function() { return handleError(function (arg0, arg1) {
|
|
163
|
+
const ret = Reflect.get(arg0, arg1);
|
|
164
|
+
return ret;
|
|
165
|
+
}, arguments); },
|
|
166
|
+
__wbg_get_unchecked_46e778e3cec74b5e: function(arg0, arg1) {
|
|
167
|
+
const ret = arg0[arg1 >>> 0];
|
|
168
|
+
return ret;
|
|
169
|
+
},
|
|
170
|
+
__wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
|
|
171
|
+
const ret = arg0[arg1];
|
|
172
|
+
return ret;
|
|
173
|
+
},
|
|
174
|
+
__wbg_instanceof_ArrayBuffer_a581da923203f29f: function(arg0) {
|
|
175
|
+
let result;
|
|
176
|
+
try {
|
|
177
|
+
result = arg0 instanceof ArrayBuffer;
|
|
178
|
+
} catch (_) {
|
|
179
|
+
result = false;
|
|
180
|
+
}
|
|
181
|
+
const ret = result;
|
|
182
|
+
return ret;
|
|
183
|
+
},
|
|
184
|
+
__wbg_instanceof_Uint8Array_b6fe1ac89eba107e: function(arg0) {
|
|
185
|
+
let result;
|
|
186
|
+
try {
|
|
187
|
+
result = arg0 instanceof Uint8Array;
|
|
188
|
+
} catch (_) {
|
|
189
|
+
result = false;
|
|
190
|
+
}
|
|
191
|
+
const ret = result;
|
|
192
|
+
return ret;
|
|
193
|
+
},
|
|
194
|
+
__wbg_isArray_139f48e3c057ede8: function(arg0) {
|
|
195
|
+
const ret = Array.isArray(arg0);
|
|
196
|
+
return ret;
|
|
197
|
+
},
|
|
198
|
+
__wbg_isSafeInteger_c22ccb4af2201fe9: function(arg0) {
|
|
199
|
+
const ret = Number.isSafeInteger(arg0);
|
|
200
|
+
return ret;
|
|
201
|
+
},
|
|
202
|
+
__wbg_iterator_9b36cebf3be7b7cd: function() {
|
|
203
|
+
const ret = Symbol.iterator;
|
|
204
|
+
return ret;
|
|
205
|
+
},
|
|
206
|
+
__wbg_length_68a9d5278d084f4f: function(arg0) {
|
|
207
|
+
const ret = arg0.length;
|
|
208
|
+
return ret;
|
|
209
|
+
},
|
|
210
|
+
__wbg_length_fb04d16d7bdf6d4c: function(arg0) {
|
|
211
|
+
const ret = arg0.length;
|
|
212
|
+
return ret;
|
|
213
|
+
},
|
|
214
|
+
__wbg_new_0_878c6ec3a1c600f3: function() {
|
|
215
|
+
const ret = new Date();
|
|
216
|
+
return ret;
|
|
217
|
+
},
|
|
218
|
+
__wbg_new_b06772b280cc6e52: function(arg0) {
|
|
219
|
+
const ret = new Uint8Array(arg0);
|
|
220
|
+
return ret;
|
|
221
|
+
},
|
|
222
|
+
__wbg_next_8cb028b6ba50743f: function() { return handleError(function (arg0) {
|
|
223
|
+
const ret = arg0.next();
|
|
224
|
+
return ret;
|
|
225
|
+
}, arguments); },
|
|
226
|
+
__wbg_next_cfd0b146c9538df8: function(arg0) {
|
|
227
|
+
const ret = arg0.next;
|
|
228
|
+
return ret;
|
|
229
|
+
},
|
|
230
|
+
__wbg_prototypesetcall_956c7493c68e29b4: function(arg0, arg1, arg2) {
|
|
231
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
232
|
+
},
|
|
233
|
+
__wbg_value_3d3defe09fb1ffca: function(arg0) {
|
|
234
|
+
const ret = arg0.value;
|
|
235
|
+
return ret;
|
|
236
|
+
},
|
|
237
|
+
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
238
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
239
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
240
|
+
return ret;
|
|
241
|
+
},
|
|
242
|
+
__wbindgen_init_externref_table: function() {
|
|
243
|
+
const table = wasm.__wbindgen_externrefs;
|
|
244
|
+
const offset = table.grow(4);
|
|
245
|
+
table.set(0, undefined);
|
|
246
|
+
table.set(offset + 0, undefined);
|
|
247
|
+
table.set(offset + 1, null);
|
|
248
|
+
table.set(offset + 2, true);
|
|
249
|
+
table.set(offset + 3, false);
|
|
250
|
+
},
|
|
251
|
+
};
|
|
252
|
+
return {
|
|
253
|
+
__proto__: null,
|
|
254
|
+
"./epub_gen_wasm_bg.js": import0,
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
const EpubFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
259
|
+
? { register: () => {}, unregister: () => {} }
|
|
260
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_epub_free(ptr, 1));
|
|
261
|
+
|
|
262
|
+
function addToExternrefTable0(obj) {
|
|
263
|
+
const idx = wasm.__externref_table_alloc();
|
|
264
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
265
|
+
return idx;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function debugString(val) {
|
|
269
|
+
// primitive types
|
|
270
|
+
const type = typeof val;
|
|
271
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
272
|
+
return `${val}`;
|
|
273
|
+
}
|
|
274
|
+
if (type == 'string') {
|
|
275
|
+
return `"${val}"`;
|
|
276
|
+
}
|
|
277
|
+
if (type == 'symbol') {
|
|
278
|
+
const description = val.description;
|
|
279
|
+
if (description == null) {
|
|
280
|
+
return 'Symbol';
|
|
281
|
+
} else {
|
|
282
|
+
return `Symbol(${description})`;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
if (type == 'function') {
|
|
286
|
+
const name = val.name;
|
|
287
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
288
|
+
return `Function(${name})`;
|
|
289
|
+
} else {
|
|
290
|
+
return 'Function';
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
// objects
|
|
294
|
+
if (Array.isArray(val)) {
|
|
295
|
+
const length = val.length;
|
|
296
|
+
let debug = '[';
|
|
297
|
+
if (length > 0) {
|
|
298
|
+
debug += debugString(val[0]);
|
|
299
|
+
}
|
|
300
|
+
for(let i = 1; i < length; i++) {
|
|
301
|
+
debug += ', ' + debugString(val[i]);
|
|
302
|
+
}
|
|
303
|
+
debug += ']';
|
|
304
|
+
return debug;
|
|
305
|
+
}
|
|
306
|
+
// Test for built-in
|
|
307
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
308
|
+
let className;
|
|
309
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
310
|
+
className = builtInMatches[1];
|
|
311
|
+
} else {
|
|
312
|
+
// Failed to match the standard '[object ClassName]'
|
|
313
|
+
return toString.call(val);
|
|
314
|
+
}
|
|
315
|
+
if (className == 'Object') {
|
|
316
|
+
// we're a user defined class or Object
|
|
317
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
318
|
+
// easier than looping through ownProperties of `val`.
|
|
319
|
+
try {
|
|
320
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
321
|
+
} catch (_) {
|
|
322
|
+
return 'Object';
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
// errors
|
|
326
|
+
if (val instanceof Error) {
|
|
327
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
328
|
+
}
|
|
329
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
330
|
+
return className;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
334
|
+
ptr = ptr >>> 0;
|
|
335
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
let cachedDataViewMemory0 = null;
|
|
339
|
+
function getDataViewMemory0() {
|
|
340
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
341
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
342
|
+
}
|
|
343
|
+
return cachedDataViewMemory0;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
function getStringFromWasm0(ptr, len) {
|
|
347
|
+
return decodeText(ptr >>> 0, len);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
let cachedUint8ArrayMemory0 = null;
|
|
351
|
+
function getUint8ArrayMemory0() {
|
|
352
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
353
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
354
|
+
}
|
|
355
|
+
return cachedUint8ArrayMemory0;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
function handleError(f, args) {
|
|
359
|
+
try {
|
|
360
|
+
return f.apply(this, args);
|
|
361
|
+
} catch (e) {
|
|
362
|
+
const idx = addToExternrefTable0(e);
|
|
363
|
+
wasm.__wbindgen_exn_store(idx);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
function isLikeNone(x) {
|
|
368
|
+
return x === undefined || x === null;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
372
|
+
if (realloc === undefined) {
|
|
373
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
374
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
375
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
376
|
+
WASM_VECTOR_LEN = buf.length;
|
|
377
|
+
return ptr;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
let len = arg.length;
|
|
381
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
382
|
+
|
|
383
|
+
const mem = getUint8ArrayMemory0();
|
|
384
|
+
|
|
385
|
+
let offset = 0;
|
|
386
|
+
|
|
387
|
+
for (; offset < len; offset++) {
|
|
388
|
+
const code = arg.charCodeAt(offset);
|
|
389
|
+
if (code > 0x7F) break;
|
|
390
|
+
mem[ptr + offset] = code;
|
|
391
|
+
}
|
|
392
|
+
if (offset !== len) {
|
|
393
|
+
if (offset !== 0) {
|
|
394
|
+
arg = arg.slice(offset);
|
|
395
|
+
}
|
|
396
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
397
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
398
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
399
|
+
|
|
400
|
+
offset += ret.written;
|
|
401
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
WASM_VECTOR_LEN = offset;
|
|
405
|
+
return ptr;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
function takeFromExternrefTable0(idx) {
|
|
409
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
410
|
+
wasm.__externref_table_dealloc(idx);
|
|
411
|
+
return value;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
415
|
+
cachedTextDecoder.decode();
|
|
416
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
417
|
+
let numBytesDecoded = 0;
|
|
418
|
+
function decodeText(ptr, len) {
|
|
419
|
+
numBytesDecoded += len;
|
|
420
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
421
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
422
|
+
cachedTextDecoder.decode();
|
|
423
|
+
numBytesDecoded = len;
|
|
424
|
+
}
|
|
425
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
const cachedTextEncoder = new TextEncoder();
|
|
429
|
+
|
|
430
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
431
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
432
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
433
|
+
view.set(buf);
|
|
434
|
+
return {
|
|
435
|
+
read: arg.length,
|
|
436
|
+
written: buf.length
|
|
437
|
+
};
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
let WASM_VECTOR_LEN = 0;
|
|
442
|
+
|
|
443
|
+
let wasmModule, wasmInstance, wasm;
|
|
444
|
+
function __wbg_finalize_init(instance, module) {
|
|
445
|
+
wasmInstance = instance;
|
|
446
|
+
wasm = instance.exports;
|
|
447
|
+
wasmModule = module;
|
|
448
|
+
cachedDataViewMemory0 = null;
|
|
449
|
+
cachedUint8ArrayMemory0 = null;
|
|
450
|
+
wasm.__wbindgen_start();
|
|
451
|
+
return wasm;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
async function __wbg_load(module, imports) {
|
|
455
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
456
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
457
|
+
try {
|
|
458
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
459
|
+
} catch (e) {
|
|
460
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
461
|
+
|
|
462
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
463
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
464
|
+
|
|
465
|
+
} else { throw e; }
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
const bytes = await module.arrayBuffer();
|
|
470
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
471
|
+
} else {
|
|
472
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
473
|
+
|
|
474
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
475
|
+
return { instance, module };
|
|
476
|
+
} else {
|
|
477
|
+
return instance;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
function expectedResponseType(type) {
|
|
482
|
+
switch (type) {
|
|
483
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
484
|
+
}
|
|
485
|
+
return false;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
function initSync(module) {
|
|
490
|
+
if (wasm !== undefined) return wasm;
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
if (module !== undefined) {
|
|
494
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
495
|
+
({module} = module)
|
|
496
|
+
} else {
|
|
497
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
const imports = __wbg_get_imports();
|
|
502
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
503
|
+
module = new WebAssembly.Module(module);
|
|
504
|
+
}
|
|
505
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
506
|
+
return __wbg_finalize_init(instance, module);
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
async function __wbg_init(module_or_path) {
|
|
510
|
+
if (wasm !== undefined) return wasm;
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
if (module_or_path !== undefined) {
|
|
514
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
515
|
+
({module_or_path} = module_or_path)
|
|
516
|
+
} else {
|
|
517
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
if (module_or_path === undefined) {
|
|
522
|
+
module_or_path = new URL('epub_gen_wasm_bg.wasm', import.meta.url);
|
|
523
|
+
}
|
|
524
|
+
const imports = __wbg_get_imports();
|
|
525
|
+
|
|
526
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
527
|
+
module_or_path = fetch(module_or_path);
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
531
|
+
|
|
532
|
+
return __wbg_finalize_init(instance, module);
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
export { initSync, __wbg_init as default };
|
|
@@ -0,0 +1,423 @@
|
|
|
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
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_epub_free: (a: number, b: number) => void;
|
|
5
|
+
export const epub_archive: (a: number) => [number, number, number, number];
|
|
6
|
+
export const epub_new: (a: any, b: any) => [number, number, number];
|
|
7
|
+
export const epub_setImages: (a: number, b: any) => [number, number];
|
|
8
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
9
|
+
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
10
|
+
export const __wbindgen_exn_store: (a: number) => void;
|
|
11
|
+
export const __externref_table_alloc: () => number;
|
|
12
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
13
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
14
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
15
|
+
export const __wbindgen_start: () => void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "epub-gen-wasm",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"files": [
|
|
6
|
+
"epub_gen_wasm_bg.wasm",
|
|
7
|
+
"epub_gen_wasm.js",
|
|
8
|
+
"epub_gen_wasm.d.ts"
|
|
9
|
+
],
|
|
10
|
+
"main": "epub_gen_wasm.js",
|
|
11
|
+
"types": "epub_gen_wasm.d.ts",
|
|
12
|
+
"sideEffects": [
|
|
13
|
+
"./snippets/*"
|
|
14
|
+
]
|
|
15
|
+
}
|