html-to-markdown-wasm 2.5.6 → 2.6.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.
@@ -0,0 +1,1015 @@
1
+ let wasm;
2
+
3
+ let cachedUint8ArrayMemory0 = null;
4
+
5
+ function getUint8ArrayMemory0() {
6
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
7
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
8
+ }
9
+ return cachedUint8ArrayMemory0;
10
+ }
11
+
12
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
13
+
14
+ cachedTextDecoder.decode();
15
+
16
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
17
+ let numBytesDecoded = 0;
18
+ function decodeText(ptr, len) {
19
+ numBytesDecoded += len;
20
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
21
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
22
+ cachedTextDecoder.decode();
23
+ numBytesDecoded = len;
24
+ }
25
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
26
+ }
27
+
28
+ function getStringFromWasm0(ptr, len) {
29
+ ptr = ptr >>> 0;
30
+ return decodeText(ptr, len);
31
+ }
32
+
33
+ let heap = new Array(128).fill(undefined);
34
+
35
+ heap.push(undefined, null, true, false);
36
+
37
+ let heap_next = heap.length;
38
+
39
+ function addHeapObject(obj) {
40
+ if (heap_next === heap.length) heap.push(heap.length + 1);
41
+ const idx = heap_next;
42
+ heap_next = heap[idx];
43
+
44
+ heap[idx] = obj;
45
+ return idx;
46
+ }
47
+
48
+ function getObject(idx) { return heap[idx]; }
49
+
50
+ let WASM_VECTOR_LEN = 0;
51
+
52
+ const cachedTextEncoder = new TextEncoder();
53
+
54
+ if (!('encodeInto' in cachedTextEncoder)) {
55
+ cachedTextEncoder.encodeInto = function (arg, view) {
56
+ const buf = cachedTextEncoder.encode(arg);
57
+ view.set(buf);
58
+ return {
59
+ read: arg.length,
60
+ written: buf.length
61
+ };
62
+ }
63
+ }
64
+
65
+ function passStringToWasm0(arg, malloc, realloc) {
66
+
67
+ if (realloc === undefined) {
68
+ const buf = cachedTextEncoder.encode(arg);
69
+ const ptr = malloc(buf.length, 1) >>> 0;
70
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
71
+ WASM_VECTOR_LEN = buf.length;
72
+ return ptr;
73
+ }
74
+
75
+ let len = arg.length;
76
+ let ptr = malloc(len, 1) >>> 0;
77
+
78
+ const mem = getUint8ArrayMemory0();
79
+
80
+ let offset = 0;
81
+
82
+ for (; offset < len; offset++) {
83
+ const code = arg.charCodeAt(offset);
84
+ if (code > 0x7F) break;
85
+ mem[ptr + offset] = code;
86
+ }
87
+
88
+ if (offset !== len) {
89
+ if (offset !== 0) {
90
+ arg = arg.slice(offset);
91
+ }
92
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
93
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
94
+ const ret = cachedTextEncoder.encodeInto(arg, view);
95
+
96
+ offset += ret.written;
97
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
98
+ }
99
+
100
+ WASM_VECTOR_LEN = offset;
101
+ return ptr;
102
+ }
103
+
104
+ let cachedDataViewMemory0 = null;
105
+
106
+ function getDataViewMemory0() {
107
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
108
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
109
+ }
110
+ return cachedDataViewMemory0;
111
+ }
112
+
113
+ function isLikeNone(x) {
114
+ return x === undefined || x === null;
115
+ }
116
+
117
+ function debugString(val) {
118
+ // primitive types
119
+ const type = typeof val;
120
+ if (type == 'number' || type == 'boolean' || val == null) {
121
+ return `${val}`;
122
+ }
123
+ if (type == 'string') {
124
+ return `"${val}"`;
125
+ }
126
+ if (type == 'symbol') {
127
+ const description = val.description;
128
+ if (description == null) {
129
+ return 'Symbol';
130
+ } else {
131
+ return `Symbol(${description})`;
132
+ }
133
+ }
134
+ if (type == 'function') {
135
+ const name = val.name;
136
+ if (typeof name == 'string' && name.length > 0) {
137
+ return `Function(${name})`;
138
+ } else {
139
+ return 'Function';
140
+ }
141
+ }
142
+ // objects
143
+ if (Array.isArray(val)) {
144
+ const length = val.length;
145
+ let debug = '[';
146
+ if (length > 0) {
147
+ debug += debugString(val[0]);
148
+ }
149
+ for(let i = 1; i < length; i++) {
150
+ debug += ', ' + debugString(val[i]);
151
+ }
152
+ debug += ']';
153
+ return debug;
154
+ }
155
+ // Test for built-in
156
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
157
+ let className;
158
+ if (builtInMatches && builtInMatches.length > 1) {
159
+ className = builtInMatches[1];
160
+ } else {
161
+ // Failed to match the standard '[object ClassName]'
162
+ return toString.call(val);
163
+ }
164
+ if (className == 'Object') {
165
+ // we're a user defined class or Object
166
+ // JSON.stringify avoids problems with cycles, and is generally much
167
+ // easier than looping through ownProperties of `val`.
168
+ try {
169
+ return 'Object(' + JSON.stringify(val) + ')';
170
+ } catch (_) {
171
+ return 'Object';
172
+ }
173
+ }
174
+ // errors
175
+ if (val instanceof Error) {
176
+ return `${val.name}: ${val.message}\n${val.stack}`;
177
+ }
178
+ // TODO we could test for more things here, like `Set`s and `Map`s.
179
+ return className;
180
+ }
181
+
182
+ function handleError(f, args) {
183
+ try {
184
+ return f.apply(this, args);
185
+ } catch (e) {
186
+ wasm.__wbindgen_export3(addHeapObject(e));
187
+ }
188
+ }
189
+
190
+ function getArrayU8FromWasm0(ptr, len) {
191
+ ptr = ptr >>> 0;
192
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
193
+ }
194
+
195
+ function dropObject(idx) {
196
+ if (idx < 132) return;
197
+ heap[idx] = heap_next;
198
+ heap_next = idx;
199
+ }
200
+
201
+ function takeObject(idx) {
202
+ const ret = getObject(idx);
203
+ dropObject(idx);
204
+ return ret;
205
+ }
206
+
207
+ let cachedUint32ArrayMemory0 = null;
208
+
209
+ function getUint32ArrayMemory0() {
210
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
211
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
212
+ }
213
+ return cachedUint32ArrayMemory0;
214
+ }
215
+
216
+ function getArrayU32FromWasm0(ptr, len) {
217
+ ptr = ptr >>> 0;
218
+ return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
219
+ }
220
+
221
+ function getArrayJsValueFromWasm0(ptr, len) {
222
+ ptr = ptr >>> 0;
223
+ const mem = getDataViewMemory0();
224
+ const result = [];
225
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
226
+ result.push(takeObject(mem.getUint32(i, true)));
227
+ }
228
+ return result;
229
+ }
230
+ /**
231
+ * Initialize panic hook for better error messages in the browser
232
+ */
233
+ export function init() {
234
+ wasm.init();
235
+ }
236
+
237
+ function _assertClass(instance, klass) {
238
+ if (!(instance instanceof klass)) {
239
+ throw new Error(`expected instance of ${klass.name}`);
240
+ }
241
+ }
242
+ /**
243
+ * Convert HTML to Markdown while collecting inline images
244
+ *
245
+ * # Arguments
246
+ *
247
+ * * `html` - The HTML string to convert
248
+ * * `options` - Optional conversion options (as a JavaScript object)
249
+ * * `image_config` - Configuration for inline image extraction
250
+ *
251
+ * # Example
252
+ *
253
+ * ```javascript
254
+ * import { convertWithInlineImages, WasmInlineImageConfig } from '@html-to-markdown/wasm';
255
+ *
256
+ * const html = '<img src="data:image/png;base64,..." alt="test">';
257
+ * const config = new WasmInlineImageConfig(1024 * 1024);
258
+ * config.inferDimensions = true;
259
+ *
260
+ * const result = convertWithInlineImages(html, null, config);
261
+ * console.log(result.markdown);
262
+ * console.log(result.inlineImages.length);
263
+ * ```
264
+ * @param {string} html
265
+ * @param {any} options
266
+ * @param {WasmInlineImageConfig | null} [image_config]
267
+ * @returns {WasmHtmlExtraction}
268
+ */
269
+ export function convertWithInlineImages(html, options, image_config) {
270
+ try {
271
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
272
+ const ptr0 = passStringToWasm0(html, wasm.__wbindgen_export, wasm.__wbindgen_export2);
273
+ const len0 = WASM_VECTOR_LEN;
274
+ let ptr1 = 0;
275
+ if (!isLikeNone(image_config)) {
276
+ _assertClass(image_config, WasmInlineImageConfig);
277
+ ptr1 = image_config.__destroy_into_raw();
278
+ }
279
+ wasm.convertWithInlineImages(retptr, ptr0, len0, addHeapObject(options), ptr1);
280
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
281
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
282
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
283
+ if (r2) {
284
+ throw takeObject(r1);
285
+ }
286
+ return WasmHtmlExtraction.__wrap(r0);
287
+ } finally {
288
+ wasm.__wbindgen_add_to_stack_pointer(16);
289
+ }
290
+ }
291
+
292
+ /**
293
+ * Convert HTML to Markdown
294
+ *
295
+ * # Arguments
296
+ *
297
+ * * `html` - The HTML string to convert
298
+ * * `options` - Optional conversion options (as a JavaScript object)
299
+ *
300
+ * # Example
301
+ *
302
+ * ```javascript
303
+ * import { convert } from '@html-to-markdown/wasm';
304
+ *
305
+ * const html = '<h1>Hello World</h1>';
306
+ * const markdown = convert(html);
307
+ * console.log(markdown); // # Hello World
308
+ * ```
309
+ * @param {string} html
310
+ * @param {any} options
311
+ * @returns {string}
312
+ */
313
+ export function convert(html, options) {
314
+ let deferred3_0;
315
+ let deferred3_1;
316
+ try {
317
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
318
+ const ptr0 = passStringToWasm0(html, wasm.__wbindgen_export, wasm.__wbindgen_export2);
319
+ const len0 = WASM_VECTOR_LEN;
320
+ wasm.convert(retptr, ptr0, len0, addHeapObject(options));
321
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
322
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
323
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
324
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
325
+ var ptr2 = r0;
326
+ var len2 = r1;
327
+ if (r3) {
328
+ ptr2 = 0; len2 = 0;
329
+ throw takeObject(r2);
330
+ }
331
+ deferred3_0 = ptr2;
332
+ deferred3_1 = len2;
333
+ return getStringFromWasm0(ptr2, len2);
334
+ } finally {
335
+ wasm.__wbindgen_add_to_stack_pointer(16);
336
+ wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
337
+ }
338
+ }
339
+
340
+ const WasmHtmlExtractionFinalization = (typeof FinalizationRegistry === 'undefined')
341
+ ? { register: () => {}, unregister: () => {} }
342
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmhtmlextraction_free(ptr >>> 0, 1));
343
+ /**
344
+ * Result of HTML extraction with inline images
345
+ */
346
+ export class WasmHtmlExtraction {
347
+
348
+ static __wrap(ptr) {
349
+ ptr = ptr >>> 0;
350
+ const obj = Object.create(WasmHtmlExtraction.prototype);
351
+ obj.__wbg_ptr = ptr;
352
+ WasmHtmlExtractionFinalization.register(obj, obj.__wbg_ptr, obj);
353
+ return obj;
354
+ }
355
+
356
+ __destroy_into_raw() {
357
+ const ptr = this.__wbg_ptr;
358
+ this.__wbg_ptr = 0;
359
+ WasmHtmlExtractionFinalization.unregister(this);
360
+ return ptr;
361
+ }
362
+
363
+ free() {
364
+ const ptr = this.__destroy_into_raw();
365
+ wasm.__wbg_wasmhtmlextraction_free(ptr, 0);
366
+ }
367
+ /**
368
+ * @returns {WasmInlineImage[]}
369
+ */
370
+ get inlineImages() {
371
+ try {
372
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
373
+ wasm.wasmhtmlextraction_inlineImages(retptr, this.__wbg_ptr);
374
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
375
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
376
+ var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
377
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
378
+ return v1;
379
+ } finally {
380
+ wasm.__wbindgen_add_to_stack_pointer(16);
381
+ }
382
+ }
383
+ /**
384
+ * @returns {string}
385
+ */
386
+ get markdown() {
387
+ let deferred1_0;
388
+ let deferred1_1;
389
+ try {
390
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
391
+ wasm.wasmhtmlextraction_markdown(retptr, this.__wbg_ptr);
392
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
393
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
394
+ deferred1_0 = r0;
395
+ deferred1_1 = r1;
396
+ return getStringFromWasm0(r0, r1);
397
+ } finally {
398
+ wasm.__wbindgen_add_to_stack_pointer(16);
399
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
400
+ }
401
+ }
402
+ /**
403
+ * @returns {WasmInlineImageWarning[]}
404
+ */
405
+ get warnings() {
406
+ try {
407
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
408
+ wasm.wasmhtmlextraction_warnings(retptr, this.__wbg_ptr);
409
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
410
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
411
+ var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
412
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
413
+ return v1;
414
+ } finally {
415
+ wasm.__wbindgen_add_to_stack_pointer(16);
416
+ }
417
+ }
418
+ }
419
+ if (Symbol.dispose) WasmHtmlExtraction.prototype[Symbol.dispose] = WasmHtmlExtraction.prototype.free;
420
+
421
+ const WasmInlineImageFinalization = (typeof FinalizationRegistry === 'undefined')
422
+ ? { register: () => {}, unregister: () => {} }
423
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasminlineimage_free(ptr >>> 0, 1));
424
+ /**
425
+ * Inline image data
426
+ */
427
+ export class WasmInlineImage {
428
+
429
+ static __wrap(ptr) {
430
+ ptr = ptr >>> 0;
431
+ const obj = Object.create(WasmInlineImage.prototype);
432
+ obj.__wbg_ptr = ptr;
433
+ WasmInlineImageFinalization.register(obj, obj.__wbg_ptr, obj);
434
+ return obj;
435
+ }
436
+
437
+ __destroy_into_raw() {
438
+ const ptr = this.__wbg_ptr;
439
+ this.__wbg_ptr = 0;
440
+ WasmInlineImageFinalization.unregister(this);
441
+ return ptr;
442
+ }
443
+
444
+ free() {
445
+ const ptr = this.__destroy_into_raw();
446
+ wasm.__wbg_wasminlineimage_free(ptr, 0);
447
+ }
448
+ /**
449
+ * @returns {any}
450
+ */
451
+ get attributes() {
452
+ const ret = wasm.wasminlineimage_attributes(this.__wbg_ptr);
453
+ return takeObject(ret);
454
+ }
455
+ /**
456
+ * @returns {Uint32Array | undefined}
457
+ */
458
+ get dimensions() {
459
+ try {
460
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
461
+ wasm.wasminlineimage_dimensions(retptr, this.__wbg_ptr);
462
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
463
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
464
+ let v1;
465
+ if (r0 !== 0) {
466
+ v1 = getArrayU32FromWasm0(r0, r1).slice();
467
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
468
+ }
469
+ return v1;
470
+ } finally {
471
+ wasm.__wbindgen_add_to_stack_pointer(16);
472
+ }
473
+ }
474
+ /**
475
+ * @returns {string | undefined}
476
+ */
477
+ get description() {
478
+ try {
479
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
480
+ wasm.wasminlineimage_description(retptr, this.__wbg_ptr);
481
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
482
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
483
+ let v1;
484
+ if (r0 !== 0) {
485
+ v1 = getStringFromWasm0(r0, r1).slice();
486
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
487
+ }
488
+ return v1;
489
+ } finally {
490
+ wasm.__wbindgen_add_to_stack_pointer(16);
491
+ }
492
+ }
493
+ /**
494
+ * @returns {Uint8Array}
495
+ */
496
+ get data() {
497
+ const ret = wasm.wasminlineimage_data(this.__wbg_ptr);
498
+ return takeObject(ret);
499
+ }
500
+ /**
501
+ * @returns {string}
502
+ */
503
+ get format() {
504
+ let deferred1_0;
505
+ let deferred1_1;
506
+ try {
507
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
508
+ wasm.wasminlineimage_format(retptr, this.__wbg_ptr);
509
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
510
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
511
+ deferred1_0 = r0;
512
+ deferred1_1 = r1;
513
+ return getStringFromWasm0(r0, r1);
514
+ } finally {
515
+ wasm.__wbindgen_add_to_stack_pointer(16);
516
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
517
+ }
518
+ }
519
+ /**
520
+ * @returns {string}
521
+ */
522
+ get source() {
523
+ let deferred1_0;
524
+ let deferred1_1;
525
+ try {
526
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
527
+ wasm.wasminlineimage_source(retptr, this.__wbg_ptr);
528
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
529
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
530
+ deferred1_0 = r0;
531
+ deferred1_1 = r1;
532
+ return getStringFromWasm0(r0, r1);
533
+ } finally {
534
+ wasm.__wbindgen_add_to_stack_pointer(16);
535
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
536
+ }
537
+ }
538
+ /**
539
+ * @returns {string | undefined}
540
+ */
541
+ get filename() {
542
+ try {
543
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
544
+ wasm.wasminlineimage_filename(retptr, this.__wbg_ptr);
545
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
546
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
547
+ let v1;
548
+ if (r0 !== 0) {
549
+ v1 = getStringFromWasm0(r0, r1).slice();
550
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
551
+ }
552
+ return v1;
553
+ } finally {
554
+ wasm.__wbindgen_add_to_stack_pointer(16);
555
+ }
556
+ }
557
+ }
558
+ if (Symbol.dispose) WasmInlineImage.prototype[Symbol.dispose] = WasmInlineImage.prototype.free;
559
+
560
+ const WasmInlineImageConfigFinalization = (typeof FinalizationRegistry === 'undefined')
561
+ ? { register: () => {}, unregister: () => {} }
562
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasminlineimageconfig_free(ptr >>> 0, 1));
563
+ /**
564
+ * Inline image configuration
565
+ */
566
+ export class WasmInlineImageConfig {
567
+
568
+ __destroy_into_raw() {
569
+ const ptr = this.__wbg_ptr;
570
+ this.__wbg_ptr = 0;
571
+ WasmInlineImageConfigFinalization.unregister(this);
572
+ return ptr;
573
+ }
574
+
575
+ free() {
576
+ const ptr = this.__destroy_into_raw();
577
+ wasm.__wbg_wasminlineimageconfig_free(ptr, 0);
578
+ }
579
+ /**
580
+ * @param {boolean} capture
581
+ */
582
+ set captureSvg(capture) {
583
+ wasm.wasminlineimageconfig_set_captureSvg(this.__wbg_ptr, capture);
584
+ }
585
+ /**
586
+ * @param {string | null} [prefix]
587
+ */
588
+ set filenamePrefix(prefix) {
589
+ var ptr0 = isLikeNone(prefix) ? 0 : passStringToWasm0(prefix, wasm.__wbindgen_export, wasm.__wbindgen_export2);
590
+ var len0 = WASM_VECTOR_LEN;
591
+ wasm.wasminlineimageconfig_set_filenamePrefix(this.__wbg_ptr, ptr0, len0);
592
+ }
593
+ /**
594
+ * @param {boolean} infer
595
+ */
596
+ set inferDimensions(infer) {
597
+ wasm.wasminlineimageconfig_set_inferDimensions(this.__wbg_ptr, infer);
598
+ }
599
+ /**
600
+ * @param {number | null} [max_decoded_size_bytes]
601
+ */
602
+ constructor(max_decoded_size_bytes) {
603
+ const ret = wasm.wasminlineimageconfig_new(!isLikeNone(max_decoded_size_bytes), isLikeNone(max_decoded_size_bytes) ? 0 : max_decoded_size_bytes);
604
+ this.__wbg_ptr = ret >>> 0;
605
+ WasmInlineImageConfigFinalization.register(this, this.__wbg_ptr, this);
606
+ return this;
607
+ }
608
+ }
609
+ if (Symbol.dispose) WasmInlineImageConfig.prototype[Symbol.dispose] = WasmInlineImageConfig.prototype.free;
610
+
611
+ const WasmInlineImageWarningFinalization = (typeof FinalizationRegistry === 'undefined')
612
+ ? { register: () => {}, unregister: () => {} }
613
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasminlineimagewarning_free(ptr >>> 0, 1));
614
+ /**
615
+ * Warning about inline image processing
616
+ */
617
+ export class WasmInlineImageWarning {
618
+
619
+ static __wrap(ptr) {
620
+ ptr = ptr >>> 0;
621
+ const obj = Object.create(WasmInlineImageWarning.prototype);
622
+ obj.__wbg_ptr = ptr;
623
+ WasmInlineImageWarningFinalization.register(obj, obj.__wbg_ptr, obj);
624
+ return obj;
625
+ }
626
+
627
+ __destroy_into_raw() {
628
+ const ptr = this.__wbg_ptr;
629
+ this.__wbg_ptr = 0;
630
+ WasmInlineImageWarningFinalization.unregister(this);
631
+ return ptr;
632
+ }
633
+
634
+ free() {
635
+ const ptr = this.__destroy_into_raw();
636
+ wasm.__wbg_wasminlineimagewarning_free(ptr, 0);
637
+ }
638
+ /**
639
+ * @returns {number}
640
+ */
641
+ get index() {
642
+ const ret = wasm.wasminlineimagewarning_index(this.__wbg_ptr);
643
+ return ret >>> 0;
644
+ }
645
+ /**
646
+ * @returns {string}
647
+ */
648
+ get message() {
649
+ let deferred1_0;
650
+ let deferred1_1;
651
+ try {
652
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
653
+ wasm.wasminlineimagewarning_message(retptr, this.__wbg_ptr);
654
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
655
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
656
+ deferred1_0 = r0;
657
+ deferred1_1 = r1;
658
+ return getStringFromWasm0(r0, r1);
659
+ } finally {
660
+ wasm.__wbindgen_add_to_stack_pointer(16);
661
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
662
+ }
663
+ }
664
+ }
665
+ if (Symbol.dispose) WasmInlineImageWarning.prototype[Symbol.dispose] = WasmInlineImageWarning.prototype.free;
666
+
667
+ const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
668
+
669
+ async function __wbg_load(module, imports) {
670
+ if (typeof Response === 'function' && module instanceof Response) {
671
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
672
+ try {
673
+ return await WebAssembly.instantiateStreaming(module, imports);
674
+
675
+ } catch (e) {
676
+ const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
677
+
678
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
679
+ 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);
680
+
681
+ } else {
682
+ throw e;
683
+ }
684
+ }
685
+ }
686
+
687
+ const bytes = await module.arrayBuffer();
688
+ return await WebAssembly.instantiate(bytes, imports);
689
+
690
+ } else {
691
+ const instance = await WebAssembly.instantiate(module, imports);
692
+
693
+ if (instance instanceof WebAssembly.Instance) {
694
+ return { instance, module };
695
+
696
+ } else {
697
+ return instance;
698
+ }
699
+ }
700
+ }
701
+
702
+ function __wbg_get_imports() {
703
+ const imports = {};
704
+ imports.wbg = {};
705
+ imports.wbg.__wbg_Error_e83987f665cf5504 = function(arg0, arg1) {
706
+ const ret = Error(getStringFromWasm0(arg0, arg1));
707
+ return addHeapObject(ret);
708
+ };
709
+ imports.wbg.__wbg_Number_bb48ca12f395cd08 = function(arg0) {
710
+ const ret = Number(getObject(arg0));
711
+ return ret;
712
+ };
713
+ imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
714
+ const ret = String(getObject(arg1));
715
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
716
+ const len1 = WASM_VECTOR_LEN;
717
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
718
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
719
+ };
720
+ imports.wbg.__wbg___wbindgen_bigint_get_as_i64_f3ebc5a755000afd = function(arg0, arg1) {
721
+ const v = getObject(arg1);
722
+ const ret = typeof(v) === 'bigint' ? v : undefined;
723
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
724
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
725
+ };
726
+ imports.wbg.__wbg___wbindgen_boolean_get_6d5a1ee65bab5f68 = function(arg0) {
727
+ const v = getObject(arg0);
728
+ const ret = typeof(v) === 'boolean' ? v : undefined;
729
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
730
+ };
731
+ imports.wbg.__wbg___wbindgen_debug_string_df47ffb5e35e6763 = function(arg0, arg1) {
732
+ const ret = debugString(getObject(arg1));
733
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
734
+ const len1 = WASM_VECTOR_LEN;
735
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
736
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
737
+ };
738
+ imports.wbg.__wbg___wbindgen_in_bb933bd9e1b3bc0f = function(arg0, arg1) {
739
+ const ret = getObject(arg0) in getObject(arg1);
740
+ return ret;
741
+ };
742
+ imports.wbg.__wbg___wbindgen_is_bigint_cb320707dcd35f0b = function(arg0) {
743
+ const ret = typeof(getObject(arg0)) === 'bigint';
744
+ return ret;
745
+ };
746
+ imports.wbg.__wbg___wbindgen_is_function_ee8a6c5833c90377 = function(arg0) {
747
+ const ret = typeof(getObject(arg0)) === 'function';
748
+ return ret;
749
+ };
750
+ imports.wbg.__wbg___wbindgen_is_null_5e69f72e906cc57c = function(arg0) {
751
+ const ret = getObject(arg0) === null;
752
+ return ret;
753
+ };
754
+ imports.wbg.__wbg___wbindgen_is_object_c818261d21f283a4 = function(arg0) {
755
+ const val = getObject(arg0);
756
+ const ret = typeof(val) === 'object' && val !== null;
757
+ return ret;
758
+ };
759
+ imports.wbg.__wbg___wbindgen_is_string_fbb76cb2940daafd = function(arg0) {
760
+ const ret = typeof(getObject(arg0)) === 'string';
761
+ return ret;
762
+ };
763
+ imports.wbg.__wbg___wbindgen_is_undefined_2d472862bd29a478 = function(arg0) {
764
+ const ret = getObject(arg0) === undefined;
765
+ return ret;
766
+ };
767
+ imports.wbg.__wbg___wbindgen_jsval_eq_6b13ab83478b1c50 = function(arg0, arg1) {
768
+ const ret = getObject(arg0) === getObject(arg1);
769
+ return ret;
770
+ };
771
+ imports.wbg.__wbg___wbindgen_jsval_loose_eq_b664b38a2f582147 = function(arg0, arg1) {
772
+ const ret = getObject(arg0) == getObject(arg1);
773
+ return ret;
774
+ };
775
+ imports.wbg.__wbg___wbindgen_number_get_a20bf9b85341449d = function(arg0, arg1) {
776
+ const obj = getObject(arg1);
777
+ const ret = typeof(obj) === 'number' ? obj : undefined;
778
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
779
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
780
+ };
781
+ imports.wbg.__wbg___wbindgen_string_get_e4f06c90489ad01b = function(arg0, arg1) {
782
+ const obj = getObject(arg1);
783
+ const ret = typeof(obj) === 'string' ? obj : undefined;
784
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
785
+ var len1 = WASM_VECTOR_LEN;
786
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
787
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
788
+ };
789
+ imports.wbg.__wbg___wbindgen_throw_b855445ff6a94295 = function(arg0, arg1) {
790
+ throw new Error(getStringFromWasm0(arg0, arg1));
791
+ };
792
+ imports.wbg.__wbg_call_e762c39fa8ea36bf = function() { return handleError(function (arg0, arg1) {
793
+ const ret = getObject(arg0).call(getObject(arg1));
794
+ return addHeapObject(ret);
795
+ }, arguments) };
796
+ imports.wbg.__wbg_codePointAt_01a186303396f7ad = function(arg0, arg1) {
797
+ const ret = getObject(arg0).codePointAt(arg1 >>> 0);
798
+ return addHeapObject(ret);
799
+ };
800
+ imports.wbg.__wbg_done_2042aa2670fb1db1 = function(arg0) {
801
+ const ret = getObject(arg0).done;
802
+ return ret;
803
+ };
804
+ imports.wbg.__wbg_entries_e171b586f8f6bdbf = function(arg0) {
805
+ const ret = Object.entries(getObject(arg0));
806
+ return addHeapObject(ret);
807
+ };
808
+ imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {
809
+ let deferred0_0;
810
+ let deferred0_1;
811
+ try {
812
+ deferred0_0 = arg0;
813
+ deferred0_1 = arg1;
814
+ console.error(getStringFromWasm0(arg0, arg1));
815
+ } finally {
816
+ wasm.__wbindgen_export4(deferred0_0, deferred0_1, 1);
817
+ }
818
+ };
819
+ imports.wbg.__wbg_get_7bed016f185add81 = function(arg0, arg1) {
820
+ const ret = getObject(arg0)[arg1 >>> 0];
821
+ return addHeapObject(ret);
822
+ };
823
+ imports.wbg.__wbg_get_efcb449f58ec27c2 = function() { return handleError(function (arg0, arg1) {
824
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
825
+ return addHeapObject(ret);
826
+ }, arguments) };
827
+ imports.wbg.__wbg_get_with_ref_key_1dc361bd10053bfe = function(arg0, arg1) {
828
+ const ret = getObject(arg0)[getObject(arg1)];
829
+ return addHeapObject(ret);
830
+ };
831
+ imports.wbg.__wbg_instanceof_ArrayBuffer_70beb1189ca63b38 = function(arg0) {
832
+ let result;
833
+ try {
834
+ result = getObject(arg0) instanceof ArrayBuffer;
835
+ } catch (_) {
836
+ result = false;
837
+ }
838
+ const ret = result;
839
+ return ret;
840
+ };
841
+ imports.wbg.__wbg_instanceof_Uint8Array_20c8e73002f7af98 = function(arg0) {
842
+ let result;
843
+ try {
844
+ result = getObject(arg0) instanceof Uint8Array;
845
+ } catch (_) {
846
+ result = false;
847
+ }
848
+ const ret = result;
849
+ return ret;
850
+ };
851
+ imports.wbg.__wbg_isArray_96e0af9891d0945d = function(arg0) {
852
+ const ret = Array.isArray(getObject(arg0));
853
+ return ret;
854
+ };
855
+ imports.wbg.__wbg_isSafeInteger_d216eda7911dde36 = function(arg0) {
856
+ const ret = Number.isSafeInteger(getObject(arg0));
857
+ return ret;
858
+ };
859
+ imports.wbg.__wbg_iterator_e5822695327a3c39 = function() {
860
+ const ret = Symbol.iterator;
861
+ return addHeapObject(ret);
862
+ };
863
+ imports.wbg.__wbg_length_69bca3cb64fc8748 = function(arg0) {
864
+ const ret = getObject(arg0).length;
865
+ return ret;
866
+ };
867
+ imports.wbg.__wbg_length_a95b69f903b746c4 = function(arg0) {
868
+ const ret = getObject(arg0).length;
869
+ return ret;
870
+ };
871
+ imports.wbg.__wbg_length_cdd215e10d9dd507 = function(arg0) {
872
+ const ret = getObject(arg0).length;
873
+ return ret;
874
+ };
875
+ imports.wbg.__wbg_new_1acc0b6eea89d040 = function() {
876
+ const ret = new Object();
877
+ return addHeapObject(ret);
878
+ };
879
+ imports.wbg.__wbg_new_5a79be3ab53b8aa5 = function(arg0) {
880
+ const ret = new Uint8Array(getObject(arg0));
881
+ return addHeapObject(ret);
882
+ };
883
+ imports.wbg.__wbg_new_68651c719dcda04e = function() {
884
+ const ret = new Map();
885
+ return addHeapObject(ret);
886
+ };
887
+ imports.wbg.__wbg_new_8a6f238a6ece86ea = function() {
888
+ const ret = new Error();
889
+ return addHeapObject(ret);
890
+ };
891
+ imports.wbg.__wbg_new_from_slice_92f4d78ca282a2d2 = function(arg0, arg1) {
892
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
893
+ return addHeapObject(ret);
894
+ };
895
+ imports.wbg.__wbg_next_020810e0ae8ebcb0 = function() { return handleError(function (arg0) {
896
+ const ret = getObject(arg0).next();
897
+ return addHeapObject(ret);
898
+ }, arguments) };
899
+ imports.wbg.__wbg_next_2c826fe5dfec6b6a = function(arg0) {
900
+ const ret = getObject(arg0).next;
901
+ return addHeapObject(ret);
902
+ };
903
+ imports.wbg.__wbg_prototypesetcall_2a6620b6922694b2 = function(arg0, arg1, arg2) {
904
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
905
+ };
906
+ imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
907
+ getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
908
+ };
909
+ imports.wbg.__wbg_set_907fb406c34a251d = function(arg0, arg1, arg2) {
910
+ const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
911
+ return addHeapObject(ret);
912
+ };
913
+ imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
914
+ const ret = getObject(arg1).stack;
915
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
916
+ const len1 = WASM_VECTOR_LEN;
917
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
918
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
919
+ };
920
+ imports.wbg.__wbg_value_692627309814bb8c = function(arg0) {
921
+ const ret = getObject(arg0).value;
922
+ return addHeapObject(ret);
923
+ };
924
+ imports.wbg.__wbg_wasminlineimage_new = function(arg0) {
925
+ const ret = WasmInlineImage.__wrap(arg0);
926
+ return addHeapObject(ret);
927
+ };
928
+ imports.wbg.__wbg_wasminlineimagewarning_new = function(arg0) {
929
+ const ret = WasmInlineImageWarning.__wrap(arg0);
930
+ return addHeapObject(ret);
931
+ };
932
+ imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
933
+ // Cast intrinsic for `Ref(String) -> Externref`.
934
+ const ret = getStringFromWasm0(arg0, arg1);
935
+ return addHeapObject(ret);
936
+ };
937
+ imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
938
+ // Cast intrinsic for `U64 -> Externref`.
939
+ const ret = BigInt.asUintN(64, arg0);
940
+ return addHeapObject(ret);
941
+ };
942
+ imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
943
+ const ret = getObject(arg0);
944
+ return addHeapObject(ret);
945
+ };
946
+ imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
947
+ takeObject(arg0);
948
+ };
949
+
950
+ return imports;
951
+ }
952
+
953
+ function __wbg_finalize_init(instance, module) {
954
+ wasm = instance.exports;
955
+ __wbg_init.__wbindgen_wasm_module = module;
956
+ cachedDataViewMemory0 = null;
957
+ cachedUint32ArrayMemory0 = null;
958
+ cachedUint8ArrayMemory0 = null;
959
+
960
+
961
+ wasm.__wbindgen_start();
962
+ return wasm;
963
+ }
964
+
965
+ function initSync(module) {
966
+ if (wasm !== undefined) return wasm;
967
+
968
+
969
+ if (typeof module !== 'undefined') {
970
+ if (Object.getPrototypeOf(module) === Object.prototype) {
971
+ ({module} = module)
972
+ } else {
973
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
974
+ }
975
+ }
976
+
977
+ const imports = __wbg_get_imports();
978
+
979
+ if (!(module instanceof WebAssembly.Module)) {
980
+ module = new WebAssembly.Module(module);
981
+ }
982
+
983
+ const instance = new WebAssembly.Instance(module, imports);
984
+
985
+ return __wbg_finalize_init(instance, module);
986
+ }
987
+
988
+ async function __wbg_init(module_or_path) {
989
+ if (wasm !== undefined) return wasm;
990
+
991
+
992
+ if (typeof module_or_path !== 'undefined') {
993
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
994
+ ({module_or_path} = module_or_path)
995
+ } else {
996
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
997
+ }
998
+ }
999
+
1000
+ if (typeof module_or_path === 'undefined') {
1001
+ module_or_path = new URL('html_to_markdown_wasm_bg.wasm', import.meta.url);
1002
+ }
1003
+ const imports = __wbg_get_imports();
1004
+
1005
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
1006
+ module_or_path = fetch(module_or_path);
1007
+ }
1008
+
1009
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
1010
+
1011
+ return __wbg_finalize_init(instance, module);
1012
+ }
1013
+
1014
+ export { initSync };
1015
+ export default __wbg_init;