mdream 1.5.10 → 1.5.11
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 +13 -0
- package/dist/browser.mjs +34 -5
- package/dist/edge.mjs +38 -6
- package/dist/iife.js +28 -2
- package/dist/worker.mjs +6 -2
- package/package.json +15 -15
- package/wasm/mdream_edge.d.ts +10 -0
- package/wasm/mdream_edge.js +26 -0
- package/wasm/mdream_edge_bg.wasm +0 -0
- package/wasm/mdream_edge_bg.wasm.d.ts +3 -0
- package/wasm/package.json +1 -1
- package/wasm-bundler/mdream_edge.d.ts +7 -0
- package/wasm-bundler/mdream_edge.js +2 -2
- package/wasm-bundler/mdream_edge_bg.js +25 -0
- package/wasm-bundler/mdream_edge_bg.wasm +0 -0
- package/wasm-bundler/mdream_edge_bg.wasm.d.ts +3 -0
- package/wasm-bundler/package.json +1 -1
package/dist/worker.mjs
CHANGED
|
@@ -5,7 +5,9 @@ const _pending = /* @__PURE__ */ new Map();
|
|
|
5
5
|
const WASM_RE = /\.wasm$/;
|
|
6
6
|
function getWorkerBlob(wasmUrl) {
|
|
7
7
|
const code = `
|
|
8
|
-
import
|
|
8
|
+
// namespace import: the URL is caller-supplied and may point at an older build
|
|
9
|
+
import init, * as engine from '${wasmUrl.replace(WASM_RE, ".js")}';
|
|
10
|
+
const { htmlToMarkdownResult } = engine;
|
|
9
11
|
|
|
10
12
|
let ready = false;
|
|
11
13
|
|
|
@@ -30,7 +32,9 @@ self.onmessage = function(e) {
|
|
|
30
32
|
const result = htmlToMarkdownResult(msg.html, msg.options || {});
|
|
31
33
|
self.postMessage({ id: msg.id, type: 'result', data: result.markdown || '' });
|
|
32
34
|
} catch (err) {
|
|
33
|
-
|
|
35
|
+
// WASM aborts on panic (#195): the message is stashed by the panic hook
|
|
36
|
+
const panic = engine.__mdreamTakePanicMessage?.();
|
|
37
|
+
self.postMessage({ id: msg.id, type: 'error', message: panic || err.message });
|
|
34
38
|
}
|
|
35
39
|
}
|
|
36
40
|
};`;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mdream",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.5.
|
|
4
|
+
"version": "1.5.11",
|
|
5
5
|
"description": "Ultra-performant HTML to Markdown Convertor Optimized for LLMs and llm.txt artifacts.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Harlan Wilton",
|
|
@@ -57,22 +57,22 @@
|
|
|
57
57
|
"browser": "./dist/browser.mjs",
|
|
58
58
|
"dependencies": {},
|
|
59
59
|
"optionalDependencies": {
|
|
60
|
-
"@mdream/rust-
|
|
61
|
-
"@mdream/rust-
|
|
62
|
-
"@mdream/rust-
|
|
63
|
-
"@mdream/rust-
|
|
64
|
-
"@mdream/rust-
|
|
65
|
-
"@mdream/rust-linux-
|
|
66
|
-
"@mdream/rust-linux-arm64-
|
|
67
|
-
"@mdream/rust-
|
|
68
|
-
"@mdream/rust-
|
|
69
|
-
"@mdream/rust-linux-x64-musl": "1.5.
|
|
70
|
-
"@mdream/rust-
|
|
71
|
-
"@mdream/rust-win32-
|
|
72
|
-
"@mdream/rust-win32-
|
|
60
|
+
"@mdream/rust-android-arm64": "1.5.11",
|
|
61
|
+
"@mdream/rust-android-arm-eabi": "1.5.11",
|
|
62
|
+
"@mdream/rust-freebsd-x64": "1.5.11",
|
|
63
|
+
"@mdream/rust-darwin-x64": "1.5.11",
|
|
64
|
+
"@mdream/rust-darwin-arm64": "1.5.11",
|
|
65
|
+
"@mdream/rust-linux-arm-gnueabihf": "1.5.11",
|
|
66
|
+
"@mdream/rust-linux-arm64-gnu": "1.5.11",
|
|
67
|
+
"@mdream/rust-linux-x64-gnu": "1.5.11",
|
|
68
|
+
"@mdream/rust-linux-arm64-musl": "1.5.11",
|
|
69
|
+
"@mdream/rust-linux-x64-musl": "1.5.11",
|
|
70
|
+
"@mdream/rust-wasm32-wasi": "1.5.11",
|
|
71
|
+
"@mdream/rust-win32-arm64-msvc": "1.5.11",
|
|
72
|
+
"@mdream/rust-win32-x64-msvc": "1.5.11"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
|
-
"@mdream/js": "1.5.
|
|
75
|
+
"@mdream/js": "1.5.11"
|
|
76
76
|
},
|
|
77
77
|
"scripts": {
|
|
78
78
|
"flame": "pnpm build && unbuild bench/bundle && clinic flame -- node bench/bundle/dist/string.mjs 10",
|
package/wasm/mdream_edge.d.ts
CHANGED
|
@@ -9,17 +9,26 @@ export class MarkdownStream {
|
|
|
9
9
|
processChunk(chunk: string): string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Consumes the message of the panic that aborted the last export call.
|
|
14
|
+
*/
|
|
15
|
+
export function __mdreamTakePanicMessage(): string | undefined;
|
|
16
|
+
|
|
12
17
|
export function htmlToMarkdown(html: string, options: any): string;
|
|
13
18
|
|
|
14
19
|
export function htmlToMarkdownResult(html: string, options: any): any;
|
|
15
20
|
|
|
21
|
+
export function install_panic_hook(): void;
|
|
22
|
+
|
|
16
23
|
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
17
24
|
|
|
18
25
|
export interface InitOutput {
|
|
19
26
|
readonly memory: WebAssembly.Memory;
|
|
27
|
+
readonly __mdreamTakePanicMessage: (a: number) => void;
|
|
20
28
|
readonly __wbg_markdownstream_free: (a: number, b: number) => void;
|
|
21
29
|
readonly htmlToMarkdown: (a: number, b: number, c: number, d: number) => void;
|
|
22
30
|
readonly htmlToMarkdownResult: (a: number, b: number, c: number) => number;
|
|
31
|
+
readonly install_panic_hook: () => void;
|
|
23
32
|
readonly markdownstream_finish: (a: number, b: number) => void;
|
|
24
33
|
readonly markdownstream_new: (a: number) => number;
|
|
25
34
|
readonly markdownstream_processChunk: (a: number, b: number, c: number, d: number) => void;
|
|
@@ -28,6 +37,7 @@ export interface InitOutput {
|
|
|
28
37
|
readonly __wbindgen_export3: (a: number) => void;
|
|
29
38
|
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
30
39
|
readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
|
|
40
|
+
readonly __wbindgen_start: () => void;
|
|
31
41
|
}
|
|
32
42
|
|
|
33
43
|
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
package/wasm/mdream_edge.js
CHANGED
|
@@ -64,6 +64,27 @@ export class MarkdownStream {
|
|
|
64
64
|
}
|
|
65
65
|
if (Symbol.dispose) MarkdownStream.prototype[Symbol.dispose] = MarkdownStream.prototype.free;
|
|
66
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Consumes the message of the panic that aborted the last export call.
|
|
69
|
+
* @returns {string | undefined}
|
|
70
|
+
*/
|
|
71
|
+
export function __mdreamTakePanicMessage() {
|
|
72
|
+
try {
|
|
73
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
74
|
+
wasm.__mdreamTakePanicMessage(retptr);
|
|
75
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
76
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
77
|
+
let v1;
|
|
78
|
+
if (r0 !== 0) {
|
|
79
|
+
v1 = getStringFromWasm0(r0, r1).slice();
|
|
80
|
+
wasm.__wbindgen_export4(r0, r1 * 1, 1);
|
|
81
|
+
}
|
|
82
|
+
return v1;
|
|
83
|
+
} finally {
|
|
84
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
67
88
|
/**
|
|
68
89
|
* @param {string} html
|
|
69
90
|
* @param {any} options
|
|
@@ -99,6 +120,10 @@ export function htmlToMarkdownResult(html, options) {
|
|
|
99
120
|
const ret = wasm.htmlToMarkdownResult(ptr0, len0, addHeapObject(options));
|
|
100
121
|
return takeObject(ret);
|
|
101
122
|
}
|
|
123
|
+
|
|
124
|
+
export function install_panic_hook() {
|
|
125
|
+
wasm.install_panic_hook();
|
|
126
|
+
}
|
|
102
127
|
function __wbg_get_imports() {
|
|
103
128
|
const import0 = {
|
|
104
129
|
__proto__: null,
|
|
@@ -328,6 +353,7 @@ function __wbg_finalize_init(instance, module) {
|
|
|
328
353
|
wasmModule = module;
|
|
329
354
|
cachedDataViewMemory0 = null;
|
|
330
355
|
cachedUint8ArrayMemory0 = null;
|
|
356
|
+
wasm.__wbindgen_start();
|
|
331
357
|
return wasm;
|
|
332
358
|
}
|
|
333
359
|
|
package/wasm/mdream_edge_bg.wasm
CHANGED
|
Binary file
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __mdreamTakePanicMessage: (a: number) => void;
|
|
4
5
|
export const __wbg_markdownstream_free: (a: number, b: number) => void;
|
|
5
6
|
export const htmlToMarkdown: (a: number, b: number, c: number, d: number) => void;
|
|
6
7
|
export const htmlToMarkdownResult: (a: number, b: number, c: number) => number;
|
|
8
|
+
export const install_panic_hook: () => void;
|
|
7
9
|
export const markdownstream_finish: (a: number, b: number) => void;
|
|
8
10
|
export const markdownstream_new: (a: number) => number;
|
|
9
11
|
export const markdownstream_processChunk: (a: number, b: number, c: number, d: number) => void;
|
|
@@ -12,3 +14,4 @@ export const __wbindgen_export2: (a: number, b: number, c: number, d: number) =>
|
|
|
12
14
|
export const __wbindgen_export3: (a: number) => void;
|
|
13
15
|
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
14
16
|
export const __wbindgen_export4: (a: number, b: number, c: number) => void;
|
|
17
|
+
export const __wbindgen_start: () => void;
|
package/wasm/package.json
CHANGED
|
@@ -9,6 +9,13 @@ export class MarkdownStream {
|
|
|
9
9
|
processChunk(chunk: string): string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Consumes the message of the panic that aborted the last export call.
|
|
14
|
+
*/
|
|
15
|
+
export function __mdreamTakePanicMessage(): string | undefined;
|
|
16
|
+
|
|
12
17
|
export function htmlToMarkdown(html: string, options: any): string;
|
|
13
18
|
|
|
14
19
|
export function htmlToMarkdownResult(html: string, options: any): any;
|
|
20
|
+
|
|
21
|
+
export function install_panic_hook(): void;
|
|
@@ -3,7 +3,7 @@ import * as wasm from "./mdream_edge_bg.wasm";
|
|
|
3
3
|
import { __wbg_set_wasm } from "./mdream_edge_bg.js";
|
|
4
4
|
|
|
5
5
|
__wbg_set_wasm(wasm);
|
|
6
|
-
|
|
6
|
+
wasm.__wbindgen_start();
|
|
7
7
|
export {
|
|
8
|
-
MarkdownStream, htmlToMarkdown, htmlToMarkdownResult
|
|
8
|
+
MarkdownStream, __mdreamTakePanicMessage, htmlToMarkdown, htmlToMarkdownResult, install_panic_hook
|
|
9
9
|
} from "./mdream_edge_bg.js";
|
|
@@ -62,6 +62,27 @@ export class MarkdownStream {
|
|
|
62
62
|
}
|
|
63
63
|
if (Symbol.dispose) MarkdownStream.prototype[Symbol.dispose] = MarkdownStream.prototype.free;
|
|
64
64
|
|
|
65
|
+
/**
|
|
66
|
+
* Consumes the message of the panic that aborted the last export call.
|
|
67
|
+
* @returns {string | undefined}
|
|
68
|
+
*/
|
|
69
|
+
export function __mdreamTakePanicMessage() {
|
|
70
|
+
try {
|
|
71
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
72
|
+
wasm.__mdreamTakePanicMessage(retptr);
|
|
73
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
74
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
75
|
+
let v1;
|
|
76
|
+
if (r0 !== 0) {
|
|
77
|
+
v1 = getStringFromWasm0(r0, r1).slice();
|
|
78
|
+
wasm.__wbindgen_export4(r0, r1 * 1, 1);
|
|
79
|
+
}
|
|
80
|
+
return v1;
|
|
81
|
+
} finally {
|
|
82
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
65
86
|
/**
|
|
66
87
|
* @param {string} html
|
|
67
88
|
* @param {any} options
|
|
@@ -97,6 +118,10 @@ export function htmlToMarkdownResult(html, options) {
|
|
|
97
118
|
const ret = wasm.htmlToMarkdownResult(ptr0, len0, addHeapObject(options));
|
|
98
119
|
return takeObject(ret);
|
|
99
120
|
}
|
|
121
|
+
|
|
122
|
+
export function install_panic_hook() {
|
|
123
|
+
wasm.install_panic_hook();
|
|
124
|
+
}
|
|
100
125
|
export function __wbg___wbindgen_boolean_get_b131b2f36d6b2f55(arg0) {
|
|
101
126
|
const v = getObject(arg0);
|
|
102
127
|
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
Binary file
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __mdreamTakePanicMessage: (a: number) => void;
|
|
4
5
|
export const __wbg_markdownstream_free: (a: number, b: number) => void;
|
|
5
6
|
export const htmlToMarkdown: (a: number, b: number, c: number, d: number) => void;
|
|
6
7
|
export const htmlToMarkdownResult: (a: number, b: number, c: number) => number;
|
|
8
|
+
export const install_panic_hook: () => void;
|
|
7
9
|
export const markdownstream_finish: (a: number, b: number) => void;
|
|
8
10
|
export const markdownstream_new: (a: number) => number;
|
|
9
11
|
export const markdownstream_processChunk: (a: number, b: number, c: number, d: number) => void;
|
|
@@ -12,3 +14,4 @@ export const __wbindgen_export2: (a: number, b: number, c: number, d: number) =>
|
|
|
12
14
|
export const __wbindgen_export3: (a: number) => void;
|
|
13
15
|
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
14
16
|
export const __wbindgen_export4: (a: number, b: number, c: number) => void;
|
|
17
|
+
export const __wbindgen_start: () => void;
|