epub-wasm 0.1.0 → 0.1.1

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.
Files changed (2) hide show
  1. package/epub_wasm_bg.js +120 -0
  2. package/package.json +2 -1
@@ -0,0 +1,120 @@
1
+ let wasm;
2
+ export function __wbg_set_wasm(val) {
3
+ wasm = val;
4
+ }
5
+
6
+ function addHeapObject(obj) {
7
+ if (heap_next === heap.length) heap.push(heap.length + 1);
8
+ const idx = heap_next;
9
+ heap_next = heap[idx];
10
+
11
+ heap[idx] = obj;
12
+ return idx;
13
+ }
14
+
15
+ function dropObject(idx) {
16
+ if (idx < 132) return;
17
+ heap[idx] = heap_next;
18
+ heap_next = idx;
19
+ }
20
+
21
+ function getArrayU8FromWasm0(ptr, len) {
22
+ ptr = ptr >>> 0;
23
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
24
+ }
25
+
26
+ let cachedDataViewMemory0 = null;
27
+ function getDataViewMemory0() {
28
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
29
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
30
+ }
31
+ return cachedDataViewMemory0;
32
+ }
33
+
34
+ function getStringFromWasm0(ptr, len) {
35
+ ptr = ptr >>> 0;
36
+ return decodeText(ptr, len);
37
+ }
38
+
39
+ let cachedUint8ArrayMemory0 = null;
40
+ function getUint8ArrayMemory0() {
41
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
42
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
43
+ }
44
+ return cachedUint8ArrayMemory0;
45
+ }
46
+
47
+ function getObject(idx) { return heap[idx]; }
48
+
49
+ function handleError(f, args) {
50
+ try {
51
+ return f.apply(this, args);
52
+ } catch (e) {
53
+ wasm.__wbindgen_export(addHeapObject(e));
54
+ }
55
+ }
56
+
57
+ let heap = new Array(128).fill(undefined);
58
+ heap.push(undefined, null, true, false);
59
+
60
+ let heap_next = heap.length;
61
+
62
+ function passArray8ToWasm0(arg, malloc) {
63
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
64
+ getUint8ArrayMemory0().set(arg, ptr / 1);
65
+ WASM_VECTOR_LEN = arg.length;
66
+ return ptr;
67
+ }
68
+
69
+ function takeObject(idx) {
70
+ const ret = getObject(idx);
71
+ dropObject(idx);
72
+ return ret;
73
+ }
74
+
75
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
76
+ cachedTextDecoder.decode();
77
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
78
+ let numBytesDecoded = 0;
79
+ function decodeText(ptr, len) {
80
+ numBytesDecoded += len;
81
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
82
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
83
+ cachedTextDecoder.decode();
84
+ numBytesDecoded = len;
85
+ }
86
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
87
+ }
88
+
89
+ let WASM_VECTOR_LEN = 0;
90
+
91
+ /**
92
+ * @param {Uint8Array} data
93
+ * @returns {string}
94
+ */
95
+ export function parse_epub(data) {
96
+ let deferred2_0;
97
+ let deferred2_1;
98
+ try {
99
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
100
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export2);
101
+ const len0 = WASM_VECTOR_LEN;
102
+ wasm.parse_epub(retptr, ptr0, len0);
103
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
104
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
105
+ deferred2_0 = r0;
106
+ deferred2_1 = r1;
107
+ return getStringFromWasm0(r0, r1);
108
+ } finally {
109
+ wasm.__wbindgen_add_to_stack_pointer(16);
110
+ wasm.__wbindgen_export3(deferred2_0, deferred2_1, 1);
111
+ }
112
+ }
113
+
114
+ export function __wbg_getRandomValues_9b655bdd369112f2() { return handleError(function (arg0, arg1) {
115
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
116
+ }, arguments) };
117
+
118
+ export function __wbindgen_object_drop_ref(arg0) {
119
+ takeObject(arg0);
120
+ };
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "Mikiyas <0xmik@proton.me>"
6
6
  ],
7
7
  "description": "EPUB utilities compiled to WebAssembly",
8
- "version": "0.1.0",
8
+ "version": "0.1.1",
9
9
  "license": "MIT/Apache-2.0",
10
10
  "repository": {
11
11
  "type": "git",
@@ -14,6 +14,7 @@
14
14
  "files": [
15
15
  "epub_wasm.js",
16
16
  "epub_wasm_bg.wasm",
17
+ "epub_wasm_bg.js",
17
18
  "epub_wasm.d.ts",
18
19
  "epub_wasm_bg.wasm.d.ts",
19
20
  "package.json",