html-to-markdown-wasm 2.7.1 → 2.7.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/README.md CHANGED
@@ -92,6 +92,8 @@ console.log(markdown);
92
92
  // This is **fast**!
93
93
  ```
94
94
 
95
+ > **Heads up for edge runtimes:** Cloudflare Workers, Vite dev servers, and other environments that instantiate `.wasm` files asynchronously must call `await initWasm()` (or `await wasmReady`) once during startup before invoking `convert`. Traditional bundlers (Webpack, Rollup) and Deno/Node imports continue to work without manual initialization.
96
+
95
97
  ### Reusing Options Handles
96
98
 
97
99
  ```ts
@@ -212,10 +214,15 @@ const markdown = convert('<h1>Hello</h1>', {
212
214
  ### Cloudflare Workers
213
215
 
214
216
  ```typescript
215
- import { convert } from 'html-to-markdown-wasm';
217
+ import { convert, initWasm, wasmReady } from 'html-to-markdown-wasm';
218
+
219
+ // Cloudflare Workers / other edge runtimes instantiate WASM asynchronously.
220
+ // Kick off initialization once at module scope.
221
+ const ready = wasmReady ?? initWasm();
216
222
 
217
223
  export default {
218
224
  async fetch(request: Request): Promise<Response> {
225
+ await ready;
219
226
  const html = await request.text();
220
227
  const markdown = convert(html, { headingStyle: 'atx' });
221
228
 
@@ -1,7 +1,5 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- export function convertBytesWithInlineImages(html: Uint8Array, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
4
- export function convertBytes(html: Uint8Array, options: any): string;
5
3
  export function createConversionOptionsHandle(options: any): WasmConversionOptionsHandle;
6
4
  /**
7
5
  * Convert HTML to Markdown
@@ -22,7 +20,9 @@ export function createConversionOptionsHandle(options: any): WasmConversionOptio
22
20
  * ```
23
21
  */
24
22
  export function convert(html: string, options: any): string;
23
+ export function convertBytes(html: Uint8Array, options: any): string;
25
24
  export function convertWithOptionsHandle(html: string, handle: WasmConversionOptionsHandle): string;
25
+ export function convertBytesWithInlineImages(html: Uint8Array, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
26
26
  export function convertBytesWithOptionsHandle(html: Uint8Array, handle: WasmConversionOptionsHandle): string;
27
27
  /**
28
28
  * Initialize panic hook for better error messages in the browser
@@ -81,3 +81,6 @@ export class WasmInlineImageWarning {
81
81
  readonly index: number;
82
82
  readonly message: string;
83
83
  }
84
+
85
+ export declare function initWasm(): Promise<void>;
86
+ export declare const wasmReady: Promise<void>;
@@ -1,5 +1,94 @@
1
- import * as wasm from "./html_to_markdown_wasm_bg.wasm";
1
+ import * as wasmModule from "./html_to_markdown_wasm_bg.wasm";
2
2
  export * from "./html_to_markdown_wasm_bg.js";
3
3
  import { __wbg_set_wasm } from "./html_to_markdown_wasm_bg.js";
4
- __wbg_set_wasm(wasm);
5
- wasm.__wbindgen_start();
4
+
5
+ const notReadyError = () =>
6
+ new Error("html-to-markdown-wasm: WebAssembly bundle is still initializing. Await initWasm() before calling convert() in runtimes that load WASM asynchronously (e.g., Cloudflare Workers).");
7
+
8
+ const notReadyProxy = new Proxy({}, {
9
+ get(_target, prop) {
10
+ if (prop === "__esModule") {
11
+ return true;
12
+ }
13
+ throw notReadyError();
14
+ }
15
+ });
16
+
17
+ let wasmExports;
18
+ let initialized = false;
19
+ let initPromise;
20
+
21
+ __wbg_set_wasm(notReadyProxy);
22
+
23
+ function asExports(value) {
24
+ if (!value) {
25
+ return null;
26
+ }
27
+ if (typeof value.__wbindgen_start === "function") {
28
+ return value;
29
+ }
30
+ if (value instanceof WebAssembly.Instance) {
31
+ return value.exports;
32
+ }
33
+ if (typeof value === "object") {
34
+ if (value.instance instanceof WebAssembly.Instance) {
35
+ return value.instance.exports;
36
+ }
37
+ if (value.default instanceof WebAssembly.Instance) {
38
+ return value.default.exports;
39
+ }
40
+ if (value.default && value.default.instance instanceof WebAssembly.Instance) {
41
+ return value.default.instance.exports;
42
+ }
43
+ }
44
+ return null;
45
+ }
46
+
47
+ function finalize(exports) {
48
+ wasmExports = exports;
49
+ __wbg_set_wasm(exports);
50
+ if (typeof exports.__wbindgen_start === "function") {
51
+ exports.__wbindgen_start();
52
+ }
53
+ initialized = true;
54
+ return exports;
55
+ }
56
+
57
+ function trySyncInit() {
58
+ try {
59
+ const exports = asExports(wasmModule);
60
+ if (exports) {
61
+ finalize(exports);
62
+ }
63
+ } catch {
64
+ // ignore and fall back to async init
65
+ }
66
+ }
67
+
68
+ trySyncInit();
69
+
70
+ function ensureInitPromise() {
71
+ if (initialized) {
72
+ return Promise.resolve(wasmExports);
73
+ }
74
+ if (!initPromise) {
75
+ initPromise = (async () => {
76
+ let module = wasmModule;
77
+ if (module && typeof module.then === "function") {
78
+ module = await module;
79
+ }
80
+ const exports = asExports(module);
81
+ if (!exports) {
82
+ throw new Error("html-to-markdown-wasm: failed to initialize WebAssembly bundle. Call initWasm() with a supported bundler configuration.");
83
+ }
84
+ return finalize(exports);
85
+ })();
86
+ }
87
+ return initPromise;
88
+ }
89
+
90
+ export const wasmReady = ensureInitPromise();
91
+
92
+ export async function initWasm() {
93
+ return ensureInitPromise();
94
+ }
@@ -231,69 +231,6 @@ function getArrayJsValueFromWasm0(ptr, len) {
231
231
  }
232
232
  return result;
233
233
  }
234
-
235
- function _assertClass(instance, klass) {
236
- if (!(instance instanceof klass)) {
237
- throw new Error(`expected instance of ${klass.name}`);
238
- }
239
- }
240
- /**
241
- * @param {Uint8Array} html
242
- * @param {any} options
243
- * @param {WasmInlineImageConfig | null} [image_config]
244
- * @returns {WasmHtmlExtraction}
245
- */
246
- export function convertBytesWithInlineImages(html, options, image_config) {
247
- try {
248
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
249
- let ptr0 = 0;
250
- if (!isLikeNone(image_config)) {
251
- _assertClass(image_config, WasmInlineImageConfig);
252
- ptr0 = image_config.__destroy_into_raw();
253
- }
254
- wasm.convertBytesWithInlineImages(retptr, addHeapObject(html), addHeapObject(options), ptr0);
255
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
256
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
257
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
258
- if (r2) {
259
- throw takeObject(r1);
260
- }
261
- return WasmHtmlExtraction.__wrap(r0);
262
- } finally {
263
- wasm.__wbindgen_add_to_stack_pointer(16);
264
- }
265
- }
266
-
267
- /**
268
- * @param {Uint8Array} html
269
- * @param {any} options
270
- * @returns {string}
271
- */
272
- export function convertBytes(html, options) {
273
- let deferred2_0;
274
- let deferred2_1;
275
- try {
276
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
277
- wasm.convertBytes(retptr, addHeapObject(html), addHeapObject(options));
278
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
279
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
280
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
281
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
282
- var ptr1 = r0;
283
- var len1 = r1;
284
- if (r3) {
285
- ptr1 = 0; len1 = 0;
286
- throw takeObject(r2);
287
- }
288
- deferred2_0 = ptr1;
289
- deferred2_1 = len1;
290
- return getStringFromWasm0(ptr1, len1);
291
- } finally {
292
- wasm.__wbindgen_add_to_stack_pointer(16);
293
- wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
294
- }
295
- }
296
-
297
234
  /**
298
235
  * @param {any} options
299
236
  * @returns {WasmConversionOptionsHandle}
@@ -362,6 +299,41 @@ export function convert(html, options) {
362
299
  }
363
300
  }
364
301
 
302
+ /**
303
+ * @param {Uint8Array} html
304
+ * @param {any} options
305
+ * @returns {string}
306
+ */
307
+ export function convertBytes(html, options) {
308
+ let deferred2_0;
309
+ let deferred2_1;
310
+ try {
311
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
312
+ wasm.convertBytes(retptr, addHeapObject(html), addHeapObject(options));
313
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
314
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
315
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
316
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
317
+ var ptr1 = r0;
318
+ var len1 = r1;
319
+ if (r3) {
320
+ ptr1 = 0; len1 = 0;
321
+ throw takeObject(r2);
322
+ }
323
+ deferred2_0 = ptr1;
324
+ deferred2_1 = len1;
325
+ return getStringFromWasm0(ptr1, len1);
326
+ } finally {
327
+ wasm.__wbindgen_add_to_stack_pointer(16);
328
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
329
+ }
330
+ }
331
+
332
+ function _assertClass(instance, klass) {
333
+ if (!(instance instanceof klass)) {
334
+ throw new Error(`expected instance of ${klass.name}`);
335
+ }
336
+ }
365
337
  /**
366
338
  * @param {string} html
367
339
  * @param {WasmConversionOptionsHandle} handle
@@ -395,6 +367,33 @@ export function convertWithOptionsHandle(html, handle) {
395
367
  }
396
368
  }
397
369
 
370
+ /**
371
+ * @param {Uint8Array} html
372
+ * @param {any} options
373
+ * @param {WasmInlineImageConfig | null} [image_config]
374
+ * @returns {WasmHtmlExtraction}
375
+ */
376
+ export function convertBytesWithInlineImages(html, options, image_config) {
377
+ try {
378
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
379
+ let ptr0 = 0;
380
+ if (!isLikeNone(image_config)) {
381
+ _assertClass(image_config, WasmInlineImageConfig);
382
+ ptr0 = image_config.__destroy_into_raw();
383
+ }
384
+ wasm.convertBytesWithInlineImages(retptr, addHeapObject(html), addHeapObject(options), ptr0);
385
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
386
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
387
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
388
+ if (r2) {
389
+ throw takeObject(r1);
390
+ }
391
+ return WasmHtmlExtraction.__wrap(r0);
392
+ } finally {
393
+ wasm.__wbindgen_add_to_stack_pointer(16);
394
+ }
395
+ }
396
+
398
397
  /**
399
398
  * @param {Uint8Array} html
400
399
  * @param {WasmConversionOptionsHandle} handle
Binary file
package/dist/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "collaborators": [
5
5
  "Na'aman Hirschfeld <nhirschfeld@gmail.com>"
6
6
  ],
7
- "version": "2.7.1",
7
+ "version": "2.7.2",
8
8
  "license": "MIT",
9
9
  "repository": {
10
10
  "type": "git",
@@ -1,7 +1,5 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- export function convertBytesWithInlineImages(html: Uint8Array, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
4
- export function convertBytes(html: Uint8Array, options: any): string;
5
3
  export function createConversionOptionsHandle(options: any): WasmConversionOptionsHandle;
6
4
  /**
7
5
  * Convert HTML to Markdown
@@ -22,7 +20,9 @@ export function createConversionOptionsHandle(options: any): WasmConversionOptio
22
20
  * ```
23
21
  */
24
22
  export function convert(html: string, options: any): string;
23
+ export function convertBytes(html: Uint8Array, options: any): string;
25
24
  export function convertWithOptionsHandle(html: string, handle: WasmConversionOptionsHandle): string;
25
+ export function convertBytesWithInlineImages(html: Uint8Array, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
26
26
  export function convertBytesWithOptionsHandle(html: Uint8Array, handle: WasmConversionOptionsHandle): string;
27
27
  /**
28
28
  * Initialize panic hook for better error messages in the browser
@@ -221,69 +221,6 @@ function getArrayJsValueFromWasm0(ptr, len) {
221
221
  }
222
222
  return result;
223
223
  }
224
-
225
- function _assertClass(instance, klass) {
226
- if (!(instance instanceof klass)) {
227
- throw new Error(`expected instance of ${klass.name}`);
228
- }
229
- }
230
- /**
231
- * @param {Uint8Array} html
232
- * @param {any} options
233
- * @param {WasmInlineImageConfig | null} [image_config]
234
- * @returns {WasmHtmlExtraction}
235
- */
236
- exports.convertBytesWithInlineImages = function(html, options, image_config) {
237
- try {
238
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
239
- let ptr0 = 0;
240
- if (!isLikeNone(image_config)) {
241
- _assertClass(image_config, WasmInlineImageConfig);
242
- ptr0 = image_config.__destroy_into_raw();
243
- }
244
- wasm.convertBytesWithInlineImages(retptr, addHeapObject(html), addHeapObject(options), ptr0);
245
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
246
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
247
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
248
- if (r2) {
249
- throw takeObject(r1);
250
- }
251
- return WasmHtmlExtraction.__wrap(r0);
252
- } finally {
253
- wasm.__wbindgen_add_to_stack_pointer(16);
254
- }
255
- };
256
-
257
- /**
258
- * @param {Uint8Array} html
259
- * @param {any} options
260
- * @returns {string}
261
- */
262
- exports.convertBytes = function(html, options) {
263
- let deferred2_0;
264
- let deferred2_1;
265
- try {
266
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
267
- wasm.convertBytes(retptr, addHeapObject(html), addHeapObject(options));
268
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
269
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
270
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
271
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
272
- var ptr1 = r0;
273
- var len1 = r1;
274
- if (r3) {
275
- ptr1 = 0; len1 = 0;
276
- throw takeObject(r2);
277
- }
278
- deferred2_0 = ptr1;
279
- deferred2_1 = len1;
280
- return getStringFromWasm0(ptr1, len1);
281
- } finally {
282
- wasm.__wbindgen_add_to_stack_pointer(16);
283
- wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
284
- }
285
- };
286
-
287
224
  /**
288
225
  * @param {any} options
289
226
  * @returns {WasmConversionOptionsHandle}
@@ -352,6 +289,41 @@ exports.convert = function(html, options) {
352
289
  }
353
290
  };
354
291
 
292
+ /**
293
+ * @param {Uint8Array} html
294
+ * @param {any} options
295
+ * @returns {string}
296
+ */
297
+ exports.convertBytes = function(html, options) {
298
+ let deferred2_0;
299
+ let deferred2_1;
300
+ try {
301
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
302
+ wasm.convertBytes(retptr, addHeapObject(html), addHeapObject(options));
303
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
304
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
305
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
306
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
307
+ var ptr1 = r0;
308
+ var len1 = r1;
309
+ if (r3) {
310
+ ptr1 = 0; len1 = 0;
311
+ throw takeObject(r2);
312
+ }
313
+ deferred2_0 = ptr1;
314
+ deferred2_1 = len1;
315
+ return getStringFromWasm0(ptr1, len1);
316
+ } finally {
317
+ wasm.__wbindgen_add_to_stack_pointer(16);
318
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
319
+ }
320
+ };
321
+
322
+ function _assertClass(instance, klass) {
323
+ if (!(instance instanceof klass)) {
324
+ throw new Error(`expected instance of ${klass.name}`);
325
+ }
326
+ }
355
327
  /**
356
328
  * @param {string} html
357
329
  * @param {WasmConversionOptionsHandle} handle
@@ -385,6 +357,33 @@ exports.convertWithOptionsHandle = function(html, handle) {
385
357
  }
386
358
  };
387
359
 
360
+ /**
361
+ * @param {Uint8Array} html
362
+ * @param {any} options
363
+ * @param {WasmInlineImageConfig | null} [image_config]
364
+ * @returns {WasmHtmlExtraction}
365
+ */
366
+ exports.convertBytesWithInlineImages = function(html, options, image_config) {
367
+ try {
368
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
369
+ let ptr0 = 0;
370
+ if (!isLikeNone(image_config)) {
371
+ _assertClass(image_config, WasmInlineImageConfig);
372
+ ptr0 = image_config.__destroy_into_raw();
373
+ }
374
+ wasm.convertBytesWithInlineImages(retptr, addHeapObject(html), addHeapObject(options), ptr0);
375
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
376
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
377
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
378
+ if (r2) {
379
+ throw takeObject(r1);
380
+ }
381
+ return WasmHtmlExtraction.__wrap(r0);
382
+ } finally {
383
+ wasm.__wbindgen_add_to_stack_pointer(16);
384
+ }
385
+ };
386
+
388
387
  /**
389
388
  * @param {Uint8Array} html
390
389
  * @param {WasmConversionOptionsHandle} handle
@@ -3,7 +3,7 @@
3
3
  "collaborators": [
4
4
  "Na'aman Hirschfeld <nhirschfeld@gmail.com>"
5
5
  ],
6
- "version": "2.7.1",
6
+ "version": "2.7.2",
7
7
  "license": "MIT",
8
8
  "repository": {
9
9
  "type": "git",
@@ -1,7 +1,5 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
- export function convertBytesWithInlineImages(html: Uint8Array, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
4
- export function convertBytes(html: Uint8Array, options: any): string;
5
3
  export function createConversionOptionsHandle(options: any): WasmConversionOptionsHandle;
6
4
  /**
7
5
  * Convert HTML to Markdown
@@ -22,7 +20,9 @@ export function createConversionOptionsHandle(options: any): WasmConversionOptio
22
20
  * ```
23
21
  */
24
22
  export function convert(html: string, options: any): string;
23
+ export function convertBytes(html: Uint8Array, options: any): string;
25
24
  export function convertWithOptionsHandle(html: string, handle: WasmConversionOptionsHandle): string;
25
+ export function convertBytesWithInlineImages(html: Uint8Array, options: any, image_config?: WasmInlineImageConfig | null): WasmHtmlExtraction;
26
26
  export function convertBytesWithOptionsHandle(html: Uint8Array, handle: WasmConversionOptionsHandle): string;
27
27
  /**
28
28
  * Initialize panic hook for better error messages in the browser
@@ -227,69 +227,6 @@ function getArrayJsValueFromWasm0(ptr, len) {
227
227
  }
228
228
  return result;
229
229
  }
230
-
231
- function _assertClass(instance, klass) {
232
- if (!(instance instanceof klass)) {
233
- throw new Error(`expected instance of ${klass.name}`);
234
- }
235
- }
236
- /**
237
- * @param {Uint8Array} html
238
- * @param {any} options
239
- * @param {WasmInlineImageConfig | null} [image_config]
240
- * @returns {WasmHtmlExtraction}
241
- */
242
- export function convertBytesWithInlineImages(html, options, image_config) {
243
- try {
244
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
245
- let ptr0 = 0;
246
- if (!isLikeNone(image_config)) {
247
- _assertClass(image_config, WasmInlineImageConfig);
248
- ptr0 = image_config.__destroy_into_raw();
249
- }
250
- wasm.convertBytesWithInlineImages(retptr, addHeapObject(html), addHeapObject(options), ptr0);
251
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
252
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
253
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
254
- if (r2) {
255
- throw takeObject(r1);
256
- }
257
- return WasmHtmlExtraction.__wrap(r0);
258
- } finally {
259
- wasm.__wbindgen_add_to_stack_pointer(16);
260
- }
261
- }
262
-
263
- /**
264
- * @param {Uint8Array} html
265
- * @param {any} options
266
- * @returns {string}
267
- */
268
- export function convertBytes(html, options) {
269
- let deferred2_0;
270
- let deferred2_1;
271
- try {
272
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
273
- wasm.convertBytes(retptr, addHeapObject(html), addHeapObject(options));
274
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
275
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
276
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
277
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
278
- var ptr1 = r0;
279
- var len1 = r1;
280
- if (r3) {
281
- ptr1 = 0; len1 = 0;
282
- throw takeObject(r2);
283
- }
284
- deferred2_0 = ptr1;
285
- deferred2_1 = len1;
286
- return getStringFromWasm0(ptr1, len1);
287
- } finally {
288
- wasm.__wbindgen_add_to_stack_pointer(16);
289
- wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
290
- }
291
- }
292
-
293
230
  /**
294
231
  * @param {any} options
295
232
  * @returns {WasmConversionOptionsHandle}
@@ -358,6 +295,41 @@ export function convert(html, options) {
358
295
  }
359
296
  }
360
297
 
298
+ /**
299
+ * @param {Uint8Array} html
300
+ * @param {any} options
301
+ * @returns {string}
302
+ */
303
+ export function convertBytes(html, options) {
304
+ let deferred2_0;
305
+ let deferred2_1;
306
+ try {
307
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
308
+ wasm.convertBytes(retptr, addHeapObject(html), addHeapObject(options));
309
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
310
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
311
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
312
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
313
+ var ptr1 = r0;
314
+ var len1 = r1;
315
+ if (r3) {
316
+ ptr1 = 0; len1 = 0;
317
+ throw takeObject(r2);
318
+ }
319
+ deferred2_0 = ptr1;
320
+ deferred2_1 = len1;
321
+ return getStringFromWasm0(ptr1, len1);
322
+ } finally {
323
+ wasm.__wbindgen_add_to_stack_pointer(16);
324
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
325
+ }
326
+ }
327
+
328
+ function _assertClass(instance, klass) {
329
+ if (!(instance instanceof klass)) {
330
+ throw new Error(`expected instance of ${klass.name}`);
331
+ }
332
+ }
361
333
  /**
362
334
  * @param {string} html
363
335
  * @param {WasmConversionOptionsHandle} handle
@@ -391,6 +363,33 @@ export function convertWithOptionsHandle(html, handle) {
391
363
  }
392
364
  }
393
365
 
366
+ /**
367
+ * @param {Uint8Array} html
368
+ * @param {any} options
369
+ * @param {WasmInlineImageConfig | null} [image_config]
370
+ * @returns {WasmHtmlExtraction}
371
+ */
372
+ export function convertBytesWithInlineImages(html, options, image_config) {
373
+ try {
374
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
375
+ let ptr0 = 0;
376
+ if (!isLikeNone(image_config)) {
377
+ _assertClass(image_config, WasmInlineImageConfig);
378
+ ptr0 = image_config.__destroy_into_raw();
379
+ }
380
+ wasm.convertBytesWithInlineImages(retptr, addHeapObject(html), addHeapObject(options), ptr0);
381
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
382
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
383
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
384
+ if (r2) {
385
+ throw takeObject(r1);
386
+ }
387
+ return WasmHtmlExtraction.__wrap(r0);
388
+ } finally {
389
+ wasm.__wbindgen_add_to_stack_pointer(16);
390
+ }
391
+ }
392
+
394
393
  /**
395
394
  * @param {Uint8Array} html
396
395
  * @param {WasmConversionOptionsHandle} handle
@@ -4,7 +4,7 @@
4
4
  "collaborators": [
5
5
  "Na'aman Hirschfeld <nhirschfeld@gmail.com>"
6
6
  ],
7
- "version": "2.7.1",
7
+ "version": "2.7.2",
8
8
  "license": "MIT",
9
9
  "repository": {
10
10
  "type": "git",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "html-to-markdown-wasm",
3
- "version": "2.7.1",
3
+ "version": "2.7.2",
4
4
  "description": "High-performance HTML to Markdown converter - WebAssembly bindings",
5
5
  "main": "dist/html_to_markdown_wasm.js",
6
6
  "types": "dist/html_to_markdown_wasm.d.ts",
@@ -42,7 +42,7 @@
42
42
  "README.md"
43
43
  ],
44
44
  "scripts": {
45
- "build": "wasm-pack build --target bundler --out-dir dist",
45
+ "build": "wasm-pack build --target bundler --out-dir dist && node ./scripts/patch-bundler-entry.js",
46
46
  "build:nodejs": "wasm-pack build --target nodejs --out-dir dist-node",
47
47
  "build:web": "wasm-pack build --target web --out-dir dist-web",
48
48
  "build:all": "pnpm run build && pnpm run build:nodejs && pnpm run build:web && pnpm run cleanup:gitignore",
@@ -53,7 +53,7 @@
53
53
  "clean": "rm -rf dist dist-node dist-web node_modules pkg"
54
54
  },
55
55
  "devDependencies": {
56
- "@types/node": "^24.10.0",
56
+ "@types/node": "^24.10.1",
57
57
  "tsx": "^4.20.6",
58
58
  "vitest": "^4.0.8",
59
59
  "wasm-pack": "^0.13.1"