@docmux/wasm 0.2.0 → 0.4.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.
@@ -0,0 +1,708 @@
1
+ /* @ts-self-types="./docmux_wasm.d.ts" */
2
+
3
+ /**
4
+ * Convert a document from one format to another (fragment mode).
5
+ *
6
+ * # Arguments
7
+ * - `input` — the source document as a string
8
+ * - `from` — input format name or extension (e.g. `"markdown"`, `"md"`)
9
+ * - `to` — output format name or extension (e.g. `"html"`)
10
+ * @param {string} input
11
+ * @param {string} from
12
+ * @param {string} to
13
+ * @returns {string}
14
+ */
15
+ export function convert(input, from, to) {
16
+ let deferred5_0;
17
+ let deferred5_1;
18
+ try {
19
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
20
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export, wasm.__wbindgen_export2);
21
+ const len0 = WASM_VECTOR_LEN;
22
+ const ptr1 = passStringToWasm0(from, wasm.__wbindgen_export, wasm.__wbindgen_export2);
23
+ const len1 = WASM_VECTOR_LEN;
24
+ const ptr2 = passStringToWasm0(to, wasm.__wbindgen_export, wasm.__wbindgen_export2);
25
+ const len2 = WASM_VECTOR_LEN;
26
+ wasm.convert(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
27
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
28
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
29
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
30
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
31
+ var ptr4 = r0;
32
+ var len4 = r1;
33
+ if (r3) {
34
+ ptr4 = 0; len4 = 0;
35
+ throw takeObject(r2);
36
+ }
37
+ deferred5_0 = ptr4;
38
+ deferred5_1 = len4;
39
+ return getStringFromWasm0(ptr4, len4);
40
+ } finally {
41
+ wasm.__wbindgen_add_to_stack_pointer(16);
42
+ wasm.__wbindgen_export3(deferred5_0, deferred5_1, 1);
43
+ }
44
+ }
45
+
46
+ /**
47
+ * Convert binary input (e.g. DOCX bytes) to another format (fragment mode).
48
+ *
49
+ * # Arguments
50
+ * - `input` — the raw binary content (e.g. DOCX bytes from `FileReader`)
51
+ * - `from` — input format name or extension (e.g. `"docx"`)
52
+ * - `to` — output format name or extension (e.g. `"html"`)
53
+ * @param {Uint8Array} input
54
+ * @param {string} from
55
+ * @param {string} to
56
+ * @returns {string}
57
+ */
58
+ export function convertBytes(input, from, to) {
59
+ let deferred5_0;
60
+ let deferred5_1;
61
+ try {
62
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
63
+ const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_export);
64
+ const len0 = WASM_VECTOR_LEN;
65
+ const ptr1 = passStringToWasm0(from, wasm.__wbindgen_export, wasm.__wbindgen_export2);
66
+ const len1 = WASM_VECTOR_LEN;
67
+ const ptr2 = passStringToWasm0(to, wasm.__wbindgen_export, wasm.__wbindgen_export2);
68
+ const len2 = WASM_VECTOR_LEN;
69
+ wasm.convertBytes(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
70
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
71
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
72
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
73
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
74
+ var ptr4 = r0;
75
+ var len4 = r1;
76
+ if (r3) {
77
+ ptr4 = 0; len4 = 0;
78
+ throw takeObject(r2);
79
+ }
80
+ deferred5_0 = ptr4;
81
+ deferred5_1 = len4;
82
+ return getStringFromWasm0(ptr4, len4);
83
+ } finally {
84
+ wasm.__wbindgen_add_to_stack_pointer(16);
85
+ wasm.__wbindgen_export3(deferred5_0, deferred5_1, 1);
86
+ }
87
+ }
88
+
89
+ /**
90
+ * Convert binary input producing a standalone file (full HTML, LaTeX with preamble, etc.).
91
+ * @param {Uint8Array} input
92
+ * @param {string} from
93
+ * @param {string} to
94
+ * @returns {string}
95
+ */
96
+ export function convertBytesStandalone(input, from, to) {
97
+ let deferred5_0;
98
+ let deferred5_1;
99
+ try {
100
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
101
+ const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_export);
102
+ const len0 = WASM_VECTOR_LEN;
103
+ const ptr1 = passStringToWasm0(from, wasm.__wbindgen_export, wasm.__wbindgen_export2);
104
+ const len1 = WASM_VECTOR_LEN;
105
+ const ptr2 = passStringToWasm0(to, wasm.__wbindgen_export, wasm.__wbindgen_export2);
106
+ const len2 = WASM_VECTOR_LEN;
107
+ wasm.convertBytesStandalone(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
108
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
109
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
110
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
111
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
112
+ var ptr4 = r0;
113
+ var len4 = r1;
114
+ if (r3) {
115
+ ptr4 = 0; len4 = 0;
116
+ throw takeObject(r2);
117
+ }
118
+ deferred5_0 = ptr4;
119
+ deferred5_1 = len4;
120
+ return getStringFromWasm0(ptr4, len4);
121
+ } finally {
122
+ wasm.__wbindgen_add_to_stack_pointer(16);
123
+ wasm.__wbindgen_export3(deferred5_0, deferred5_1, 1);
124
+ }
125
+ }
126
+
127
+ /**
128
+ * Convert binary input to binary output (e.g. DOCX → DOCX), with additional resources.
129
+ * @param {Uint8Array} input
130
+ * @param {string} from
131
+ * @param {string} to
132
+ * @param {Map<any, any>} resources
133
+ * @returns {Uint8Array}
134
+ */
135
+ export function convertBytesToBytes(input, from, to, resources) {
136
+ try {
137
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
138
+ const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_export);
139
+ const len0 = WASM_VECTOR_LEN;
140
+ const ptr1 = passStringToWasm0(from, wasm.__wbindgen_export, wasm.__wbindgen_export2);
141
+ const len1 = WASM_VECTOR_LEN;
142
+ const ptr2 = passStringToWasm0(to, wasm.__wbindgen_export, wasm.__wbindgen_export2);
143
+ const len2 = WASM_VECTOR_LEN;
144
+ wasm.convertBytesToBytes(retptr, ptr0, len0, ptr1, len1, ptr2, len2, addBorrowedObject(resources));
145
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
146
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
147
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
148
+ if (r2) {
149
+ throw takeObject(r1);
150
+ }
151
+ return takeObject(r0);
152
+ } finally {
153
+ wasm.__wbindgen_add_to_stack_pointer(16);
154
+ heap[stack_pointer++] = undefined;
155
+ }
156
+ }
157
+
158
+ /**
159
+ * Convert a document producing a standalone file (full HTML document, LaTeX with preamble, etc.).
160
+ * @param {string} input
161
+ * @param {string} from
162
+ * @param {string} to
163
+ * @returns {string}
164
+ */
165
+ export function convertStandalone(input, from, to) {
166
+ let deferred5_0;
167
+ let deferred5_1;
168
+ try {
169
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
170
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export, wasm.__wbindgen_export2);
171
+ const len0 = WASM_VECTOR_LEN;
172
+ const ptr1 = passStringToWasm0(from, wasm.__wbindgen_export, wasm.__wbindgen_export2);
173
+ const len1 = WASM_VECTOR_LEN;
174
+ const ptr2 = passStringToWasm0(to, wasm.__wbindgen_export, wasm.__wbindgen_export2);
175
+ const len2 = WASM_VECTOR_LEN;
176
+ wasm.convertStandalone(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
177
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
178
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
179
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
180
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
181
+ var ptr4 = r0;
182
+ var len4 = r1;
183
+ if (r3) {
184
+ ptr4 = 0; len4 = 0;
185
+ throw takeObject(r2);
186
+ }
187
+ deferred5_0 = ptr4;
188
+ deferred5_1 = len4;
189
+ return getStringFromWasm0(ptr4, len4);
190
+ } finally {
191
+ wasm.__wbindgen_add_to_stack_pointer(16);
192
+ wasm.__wbindgen_export3(deferred5_0, deferred5_1, 1);
193
+ }
194
+ }
195
+
196
+ /**
197
+ * Convert text input to binary output (e.g. markdown → DOCX), with image resources.
198
+ * @param {string} input
199
+ * @param {string} from
200
+ * @param {string} to
201
+ * @param {Map<any, any>} resources
202
+ * @returns {Uint8Array}
203
+ */
204
+ export function convertToBytes(input, from, to, resources) {
205
+ try {
206
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
207
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export, wasm.__wbindgen_export2);
208
+ const len0 = WASM_VECTOR_LEN;
209
+ const ptr1 = passStringToWasm0(from, wasm.__wbindgen_export, wasm.__wbindgen_export2);
210
+ const len1 = WASM_VECTOR_LEN;
211
+ const ptr2 = passStringToWasm0(to, wasm.__wbindgen_export, wasm.__wbindgen_export2);
212
+ const len2 = WASM_VECTOR_LEN;
213
+ wasm.convertToBytes(retptr, ptr0, len0, ptr1, len1, ptr2, len2, addBorrowedObject(resources));
214
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
215
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
216
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
217
+ if (r2) {
218
+ throw takeObject(r1);
219
+ }
220
+ return takeObject(r0);
221
+ } finally {
222
+ wasm.__wbindgen_add_to_stack_pointer(16);
223
+ heap[stack_pointer++] = undefined;
224
+ }
225
+ }
226
+
227
+ /**
228
+ * Convert text input to string output, with image resources for embedding.
229
+ * @param {string} input
230
+ * @param {string} from
231
+ * @param {string} to
232
+ * @param {Map<any, any>} resources
233
+ * @returns {string}
234
+ */
235
+ export function convertWithResources(input, from, to, resources) {
236
+ let deferred5_0;
237
+ let deferred5_1;
238
+ try {
239
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
240
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export, wasm.__wbindgen_export2);
241
+ const len0 = WASM_VECTOR_LEN;
242
+ const ptr1 = passStringToWasm0(from, wasm.__wbindgen_export, wasm.__wbindgen_export2);
243
+ const len1 = WASM_VECTOR_LEN;
244
+ const ptr2 = passStringToWasm0(to, wasm.__wbindgen_export, wasm.__wbindgen_export2);
245
+ const len2 = WASM_VECTOR_LEN;
246
+ wasm.convertWithResources(retptr, ptr0, len0, ptr1, len1, ptr2, len2, addBorrowedObject(resources));
247
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
248
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
249
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
250
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
251
+ var ptr4 = r0;
252
+ var len4 = r1;
253
+ if (r3) {
254
+ ptr4 = 0; len4 = 0;
255
+ throw takeObject(r2);
256
+ }
257
+ deferred5_0 = ptr4;
258
+ deferred5_1 = len4;
259
+ return getStringFromWasm0(ptr4, len4);
260
+ } finally {
261
+ wasm.__wbindgen_add_to_stack_pointer(16);
262
+ heap[stack_pointer++] = undefined;
263
+ wasm.__wbindgen_export3(deferred5_0, deferred5_1, 1);
264
+ }
265
+ }
266
+
267
+ /**
268
+ * Return a list of supported input format names.
269
+ * @returns {string[]}
270
+ */
271
+ export function inputFormats() {
272
+ try {
273
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
274
+ wasm.inputFormats(retptr);
275
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
276
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
277
+ var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
278
+ wasm.__wbindgen_export3(r0, r1 * 4, 4);
279
+ return v1;
280
+ } finally {
281
+ wasm.__wbindgen_add_to_stack_pointer(16);
282
+ }
283
+ }
284
+
285
+ /**
286
+ * Convert markdown to HTML (convenience wrapper).
287
+ * @param {string} input
288
+ * @returns {string}
289
+ */
290
+ export function markdownToHtml(input) {
291
+ let deferred3_0;
292
+ let deferred3_1;
293
+ try {
294
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
295
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export, wasm.__wbindgen_export2);
296
+ const len0 = WASM_VECTOR_LEN;
297
+ wasm.markdownToHtml(retptr, ptr0, len0);
298
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
299
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
300
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
301
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
302
+ var ptr2 = r0;
303
+ var len2 = r1;
304
+ if (r3) {
305
+ ptr2 = 0; len2 = 0;
306
+ throw takeObject(r2);
307
+ }
308
+ deferred3_0 = ptr2;
309
+ deferred3_1 = len2;
310
+ return getStringFromWasm0(ptr2, len2);
311
+ } finally {
312
+ wasm.__wbindgen_add_to_stack_pointer(16);
313
+ wasm.__wbindgen_export3(deferred3_0, deferred3_1, 1);
314
+ }
315
+ }
316
+
317
+ /**
318
+ * Return a list of supported output format names.
319
+ * @returns {string[]}
320
+ */
321
+ export function outputFormats() {
322
+ try {
323
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
324
+ wasm.outputFormats(retptr);
325
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
326
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
327
+ var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
328
+ wasm.__wbindgen_export3(r0, r1 * 4, 4);
329
+ return v1;
330
+ } finally {
331
+ wasm.__wbindgen_add_to_stack_pointer(16);
332
+ }
333
+ }
334
+
335
+ /**
336
+ * Parse binary input and return the AST as pretty-printed JSON.
337
+ * @param {Uint8Array} input
338
+ * @param {string} from
339
+ * @returns {string}
340
+ */
341
+ export function parseBytesToJson(input, from) {
342
+ let deferred4_0;
343
+ let deferred4_1;
344
+ try {
345
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
346
+ const ptr0 = passArray8ToWasm0(input, wasm.__wbindgen_export);
347
+ const len0 = WASM_VECTOR_LEN;
348
+ const ptr1 = passStringToWasm0(from, wasm.__wbindgen_export, wasm.__wbindgen_export2);
349
+ const len1 = WASM_VECTOR_LEN;
350
+ wasm.parseBytesToJson(retptr, ptr0, len0, ptr1, len1);
351
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
352
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
353
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
354
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
355
+ var ptr3 = r0;
356
+ var len3 = r1;
357
+ if (r3) {
358
+ ptr3 = 0; len3 = 0;
359
+ throw takeObject(r2);
360
+ }
361
+ deferred4_0 = ptr3;
362
+ deferred4_1 = len3;
363
+ return getStringFromWasm0(ptr3, len3);
364
+ } finally {
365
+ wasm.__wbindgen_add_to_stack_pointer(16);
366
+ wasm.__wbindgen_export3(deferred4_0, deferred4_1, 1);
367
+ }
368
+ }
369
+
370
+ /**
371
+ * Parse a document and return the AST as pretty-printed JSON.
372
+ * @param {string} input
373
+ * @param {string} from
374
+ * @returns {string}
375
+ */
376
+ export function parseToJson(input, from) {
377
+ let deferred4_0;
378
+ let deferred4_1;
379
+ try {
380
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
381
+ const ptr0 = passStringToWasm0(input, wasm.__wbindgen_export, wasm.__wbindgen_export2);
382
+ const len0 = WASM_VECTOR_LEN;
383
+ const ptr1 = passStringToWasm0(from, wasm.__wbindgen_export, wasm.__wbindgen_export2);
384
+ const len1 = WASM_VECTOR_LEN;
385
+ wasm.parseToJson(retptr, ptr0, len0, ptr1, len1);
386
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
387
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
388
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
389
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
390
+ var ptr3 = r0;
391
+ var len3 = r1;
392
+ if (r3) {
393
+ ptr3 = 0; len3 = 0;
394
+ throw takeObject(r2);
395
+ }
396
+ deferred4_0 = ptr3;
397
+ deferred4_1 = len3;
398
+ return getStringFromWasm0(ptr3, len3);
399
+ } finally {
400
+ wasm.__wbindgen_add_to_stack_pointer(16);
401
+ wasm.__wbindgen_export3(deferred4_0, deferred4_1, 1);
402
+ }
403
+ }
404
+ function __wbg_get_imports() {
405
+ const import0 = {
406
+ __proto__: null,
407
+ __wbg_Error_960c155d3d49e4c2: function(arg0, arg1) {
408
+ const ret = Error(getStringFromWasm0(arg0, arg1));
409
+ return addHeapObject(ret);
410
+ },
411
+ __wbg___wbindgen_string_get_7ed5322991caaec5: function(arg0, arg1) {
412
+ const obj = getObject(arg1);
413
+ const ret = typeof(obj) === 'string' ? obj : undefined;
414
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
415
+ var len1 = WASM_VECTOR_LEN;
416
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
417
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
418
+ },
419
+ __wbg___wbindgen_throw_6b64449b9b9ed33c: function(arg0, arg1) {
420
+ throw new Error(getStringFromWasm0(arg0, arg1));
421
+ },
422
+ __wbg_forEach_5bdeef2ab2f0b065: function(arg0, arg1, arg2) {
423
+ try {
424
+ var state0 = {a: arg1, b: arg2};
425
+ var cb0 = (arg0, arg1) => {
426
+ const a = state0.a;
427
+ state0.a = 0;
428
+ try {
429
+ return __wasm_bindgen_func_elem_332(a, state0.b, arg0, arg1);
430
+ } finally {
431
+ state0.a = a;
432
+ }
433
+ };
434
+ getObject(arg0).forEach(cb0);
435
+ } finally {
436
+ state0.a = 0;
437
+ }
438
+ },
439
+ __wbg_length_9f1775224cf1d815: function(arg0) {
440
+ const ret = getObject(arg0).length;
441
+ return ret;
442
+ },
443
+ __wbg_new_from_slice_b5ea43e23f6008c0: function(arg0, arg1) {
444
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
445
+ return addHeapObject(ret);
446
+ },
447
+ __wbg_prototypesetcall_a6b02eb00b0f4ce2: function(arg0, arg1, arg2) {
448
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
449
+ },
450
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
451
+ // Cast intrinsic for `Ref(String) -> Externref`.
452
+ const ret = getStringFromWasm0(arg0, arg1);
453
+ return addHeapObject(ret);
454
+ },
455
+ __wbindgen_object_drop_ref: function(arg0) {
456
+ takeObject(arg0);
457
+ },
458
+ };
459
+ return {
460
+ __proto__: null,
461
+ "./docmux_wasm_bg.js": import0,
462
+ };
463
+ }
464
+
465
+ function __wasm_bindgen_func_elem_332(arg0, arg1, arg2, arg3) {
466
+ wasm.__wasm_bindgen_func_elem_332(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
467
+ }
468
+
469
+ function addHeapObject(obj) {
470
+ if (heap_next === heap.length) heap.push(heap.length + 1);
471
+ const idx = heap_next;
472
+ heap_next = heap[idx];
473
+
474
+ heap[idx] = obj;
475
+ return idx;
476
+ }
477
+
478
+ function addBorrowedObject(obj) {
479
+ if (stack_pointer == 1) throw new Error('out of js stack');
480
+ heap[--stack_pointer] = obj;
481
+ return stack_pointer;
482
+ }
483
+
484
+ function dropObject(idx) {
485
+ if (idx < 1028) return;
486
+ heap[idx] = heap_next;
487
+ heap_next = idx;
488
+ }
489
+
490
+ function getArrayJsValueFromWasm0(ptr, len) {
491
+ ptr = ptr >>> 0;
492
+ const mem = getDataViewMemory0();
493
+ const result = [];
494
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
495
+ result.push(takeObject(mem.getUint32(i, true)));
496
+ }
497
+ return result;
498
+ }
499
+
500
+ function getArrayU8FromWasm0(ptr, len) {
501
+ ptr = ptr >>> 0;
502
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
503
+ }
504
+
505
+ let cachedDataViewMemory0 = null;
506
+ function getDataViewMemory0() {
507
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
508
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
509
+ }
510
+ return cachedDataViewMemory0;
511
+ }
512
+
513
+ function getStringFromWasm0(ptr, len) {
514
+ ptr = ptr >>> 0;
515
+ return decodeText(ptr, len);
516
+ }
517
+
518
+ let cachedUint8ArrayMemory0 = null;
519
+ function getUint8ArrayMemory0() {
520
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
521
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
522
+ }
523
+ return cachedUint8ArrayMemory0;
524
+ }
525
+
526
+ function getObject(idx) { return heap[idx]; }
527
+
528
+ let heap = new Array(1024).fill(undefined);
529
+ heap.push(undefined, null, true, false);
530
+
531
+ let heap_next = heap.length;
532
+
533
+ function isLikeNone(x) {
534
+ return x === undefined || x === null;
535
+ }
536
+
537
+ function passArray8ToWasm0(arg, malloc) {
538
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
539
+ getUint8ArrayMemory0().set(arg, ptr / 1);
540
+ WASM_VECTOR_LEN = arg.length;
541
+ return ptr;
542
+ }
543
+
544
+ function passStringToWasm0(arg, malloc, realloc) {
545
+ if (realloc === undefined) {
546
+ const buf = cachedTextEncoder.encode(arg);
547
+ const ptr = malloc(buf.length, 1) >>> 0;
548
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
549
+ WASM_VECTOR_LEN = buf.length;
550
+ return ptr;
551
+ }
552
+
553
+ let len = arg.length;
554
+ let ptr = malloc(len, 1) >>> 0;
555
+
556
+ const mem = getUint8ArrayMemory0();
557
+
558
+ let offset = 0;
559
+
560
+ for (; offset < len; offset++) {
561
+ const code = arg.charCodeAt(offset);
562
+ if (code > 0x7F) break;
563
+ mem[ptr + offset] = code;
564
+ }
565
+ if (offset !== len) {
566
+ if (offset !== 0) {
567
+ arg = arg.slice(offset);
568
+ }
569
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
570
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
571
+ const ret = cachedTextEncoder.encodeInto(arg, view);
572
+
573
+ offset += ret.written;
574
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
575
+ }
576
+
577
+ WASM_VECTOR_LEN = offset;
578
+ return ptr;
579
+ }
580
+
581
+ let stack_pointer = 1024;
582
+
583
+ function takeObject(idx) {
584
+ const ret = getObject(idx);
585
+ dropObject(idx);
586
+ return ret;
587
+ }
588
+
589
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
590
+ cachedTextDecoder.decode();
591
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
592
+ let numBytesDecoded = 0;
593
+ function decodeText(ptr, len) {
594
+ numBytesDecoded += len;
595
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
596
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
597
+ cachedTextDecoder.decode();
598
+ numBytesDecoded = len;
599
+ }
600
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
601
+ }
602
+
603
+ const cachedTextEncoder = new TextEncoder();
604
+
605
+ if (!('encodeInto' in cachedTextEncoder)) {
606
+ cachedTextEncoder.encodeInto = function (arg, view) {
607
+ const buf = cachedTextEncoder.encode(arg);
608
+ view.set(buf);
609
+ return {
610
+ read: arg.length,
611
+ written: buf.length
612
+ };
613
+ };
614
+ }
615
+
616
+ let WASM_VECTOR_LEN = 0;
617
+
618
+ let wasmModule, wasm;
619
+ function __wbg_finalize_init(instance, module) {
620
+ wasm = instance.exports;
621
+ wasmModule = module;
622
+ cachedDataViewMemory0 = null;
623
+ cachedUint8ArrayMemory0 = null;
624
+ return wasm;
625
+ }
626
+
627
+ async function __wbg_load(module, imports) {
628
+ if (typeof Response === 'function' && module instanceof Response) {
629
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
630
+ try {
631
+ return await WebAssembly.instantiateStreaming(module, imports);
632
+ } catch (e) {
633
+ const validResponse = module.ok && expectedResponseType(module.type);
634
+
635
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
636
+ 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);
637
+
638
+ } else { throw e; }
639
+ }
640
+ }
641
+
642
+ const bytes = await module.arrayBuffer();
643
+ return await WebAssembly.instantiate(bytes, imports);
644
+ } else {
645
+ const instance = await WebAssembly.instantiate(module, imports);
646
+
647
+ if (instance instanceof WebAssembly.Instance) {
648
+ return { instance, module };
649
+ } else {
650
+ return instance;
651
+ }
652
+ }
653
+
654
+ function expectedResponseType(type) {
655
+ switch (type) {
656
+ case 'basic': case 'cors': case 'default': return true;
657
+ }
658
+ return false;
659
+ }
660
+ }
661
+
662
+ function initSync(module) {
663
+ if (wasm !== undefined) return wasm;
664
+
665
+
666
+ if (module !== undefined) {
667
+ if (Object.getPrototypeOf(module) === Object.prototype) {
668
+ ({module} = module)
669
+ } else {
670
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
671
+ }
672
+ }
673
+
674
+ const imports = __wbg_get_imports();
675
+ if (!(module instanceof WebAssembly.Module)) {
676
+ module = new WebAssembly.Module(module);
677
+ }
678
+ const instance = new WebAssembly.Instance(module, imports);
679
+ return __wbg_finalize_init(instance, module);
680
+ }
681
+
682
+ async function __wbg_init(module_or_path) {
683
+ if (wasm !== undefined) return wasm;
684
+
685
+
686
+ if (module_or_path !== undefined) {
687
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
688
+ ({module_or_path} = module_or_path)
689
+ } else {
690
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
691
+ }
692
+ }
693
+
694
+ if (module_or_path === undefined) {
695
+ module_or_path = new URL('docmux_wasm_bg.wasm', import.meta.url);
696
+ }
697
+ const imports = __wbg_get_imports();
698
+
699
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
700
+ module_or_path = fetch(module_or_path);
701
+ }
702
+
703
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
704
+
705
+ return __wbg_finalize_init(instance, module);
706
+ }
707
+
708
+ export { initSync, __wbg_init as default };
Binary file