mdream 2.1.0 → 2.2.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.
- package/README.md +26 -1
- package/dist/browser-markdown.d.mts +129 -0
- package/dist/browser-markdown.mjs +229 -0
- package/dist/browser.d.mts +33 -12
- package/dist/browser.mjs +106 -63
- package/dist/edge-markdown.d.mts +128 -0
- package/dist/edge-markdown.mjs +222 -0
- package/dist/edge.d.mts +32 -7
- package/dist/edge.mjs +100 -52
- package/dist/iife.js +1 -1
- package/dist/index.mjs +10 -2
- package/dist/wasm.mjs +48 -2
- package/napi/index.mjs +56 -56
- package/package.json +33 -19
- package/wasm/mdream_edge.js +9 -0
- package/{wasm-bundler → wasm}/mdream_edge_bg.js +9 -0
- package/wasm/mdream_edge_bg.wasm +0 -0
- package/wasm/package.json +1 -1
- package/wasm-bundler/mdream_edge.js +4 -4
- package/wasm-bundler/mdream_markdown.d.ts +45 -0
- package/wasm-bundler/mdream_markdown.js +15 -0
- package/wasm-bundler/mdream_markdown_bg.js +372 -0
- package/wasm-bundler/mdream_markdown_bg.wasm +0 -0
- package/wasm-bundler/mdream_markdown_web.d.ts +90 -0
- package/wasm-bundler/mdream_markdown_web.js +476 -0
- package/wasm-bundler/mdream_edge_bg.wasm +0 -0
- package/wasm-bundler/mdream_edge_bg.wasm.d.ts +0 -20
- package/wasm-bundler/package.json +0 -19
package/dist/index.mjs
CHANGED
|
@@ -120,16 +120,23 @@ function deliverPluginData(data, { frontmatterCallback, extractionHandlers }) {
|
|
|
120
120
|
function hasCallbacks({ frontmatterCallback, extractionHandlers }) {
|
|
121
121
|
return !!frontmatterCallback || !!extractionHandlers;
|
|
122
122
|
}
|
|
123
|
+
new TextEncoder();
|
|
123
124
|
function convertResult(convert, html, options = {}) {
|
|
124
125
|
const resolved = resolveOptions(options);
|
|
125
126
|
const result = convert(html, resolved.napiOpts);
|
|
126
127
|
deliverPluginData(result, resolved);
|
|
127
128
|
return result;
|
|
128
129
|
}
|
|
130
|
+
function freeStream(stream) {
|
|
131
|
+
try {
|
|
132
|
+
stream.free?.();
|
|
133
|
+
} catch {}
|
|
134
|
+
}
|
|
129
135
|
async function* pumpStream(stream, htmlStream, callbacks, { mapError = (error) => error } = {}) {
|
|
130
|
-
const reader = htmlStream.getReader();
|
|
131
136
|
const decoder = stream.processChunkBytes ? void 0 : new TextDecoder();
|
|
137
|
+
let reader;
|
|
132
138
|
try {
|
|
139
|
+
reader = htmlStream.getReader();
|
|
133
140
|
while (true) {
|
|
134
141
|
const { done, value } = await reader.read();
|
|
135
142
|
if (done) break;
|
|
@@ -149,7 +156,8 @@ async function* pumpStream(stream, htmlStream, callbacks, { mapError = (error) =
|
|
|
149
156
|
} catch (error) {
|
|
150
157
|
throw mapError(error);
|
|
151
158
|
} finally {
|
|
152
|
-
|
|
159
|
+
freeStream(stream);
|
|
160
|
+
reader?.releaseLock();
|
|
153
161
|
}
|
|
154
162
|
}
|
|
155
163
|
function createSurrogateCarry() {
|
package/dist/wasm.mjs
CHANGED
|
@@ -117,14 +117,60 @@ function deliverPluginData(data, { frontmatterCallback, extractionHandlers }) {
|
|
|
117
117
|
if (data.frontmatter && frontmatterCallback) frontmatterCallback(data.frontmatter);
|
|
118
118
|
if (data.extracted?.length && extractionHandlers) for (const element of data.extracted) extractionHandlers[element.selector]?.(element);
|
|
119
119
|
}
|
|
120
|
+
const utf8 = new TextEncoder();
|
|
121
|
+
const WASM_CHUNK_BYTES = 16384;
|
|
122
|
+
const WASM_ONE_SHOT_MAX = 256;
|
|
123
|
+
function convertWasm(html, napiOpts, engine) {
|
|
124
|
+
if (html.length <= WASM_ONE_SHOT_MAX) return engine.oneShot(html, napiOpts);
|
|
125
|
+
return withWasmStream(engine, napiOpts, (stream) => {
|
|
126
|
+
let markdown = "";
|
|
127
|
+
if (html.charCodeAt(0) === 65279) {
|
|
128
|
+
markdown += stream.processChunk(String.fromCharCode(65279));
|
|
129
|
+
html = html.slice(1);
|
|
130
|
+
}
|
|
131
|
+
const bytes = new Uint8Array(WASM_CHUNK_BYTES);
|
|
132
|
+
for (let start = 0; start < html.length;) {
|
|
133
|
+
const { read, written } = utf8.encodeInto(html.slice(start, start + WASM_CHUNK_BYTES), bytes);
|
|
134
|
+
markdown += stream.processChunkBytes(bytes.subarray(0, written));
|
|
135
|
+
start += read;
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
markdown: markdown + stream.finish(),
|
|
139
|
+
...stream.takeData()
|
|
140
|
+
};
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
function convertWasmBytes(html, napiOpts, engine) {
|
|
144
|
+
if (html.length <= WASM_ONE_SHOT_MAX && engine.bytes) return engine.bytes(html, napiOpts);
|
|
145
|
+
return withWasmStream(engine, napiOpts, (stream) => {
|
|
146
|
+
let markdown = "";
|
|
147
|
+
for (let start = 0; start < html.length; start += WASM_CHUNK_BYTES) markdown += stream.processChunkBytes(html.subarray(start, start + WASM_CHUNK_BYTES));
|
|
148
|
+
return markdown + stream.finish();
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
function withWasmStream(engine, napiOpts, use) {
|
|
152
|
+
const stream = new engine.Stream(napiOpts);
|
|
153
|
+
try {
|
|
154
|
+
return use(stream);
|
|
155
|
+
} finally {
|
|
156
|
+
try {
|
|
157
|
+
stream.free();
|
|
158
|
+
} catch {}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
120
161
|
function convertResult(convert, html, options = {}) {
|
|
121
162
|
const resolved = resolveOptions(options);
|
|
122
163
|
const result = convert(html, resolved.napiOpts);
|
|
123
164
|
deliverPluginData(result, resolved);
|
|
124
165
|
return result;
|
|
125
166
|
}
|
|
167
|
+
const engine = {
|
|
168
|
+
oneShot: htmlToMarkdownResult$1,
|
|
169
|
+
bytes: htmlToMarkdownBytes$1,
|
|
170
|
+
Stream: MarkdownStream$1
|
|
171
|
+
};
|
|
126
172
|
function htmlToMarkdownResult(html, options = {}) {
|
|
127
|
-
return convertResult(
|
|
173
|
+
return convertResult((text, napiOpts) => convertWasm(text, napiOpts, engine), html, options);
|
|
128
174
|
}
|
|
129
175
|
function htmlToMarkdown(html, options = {}) {
|
|
130
176
|
return htmlToMarkdownResult(html, options).markdown || "";
|
|
@@ -132,7 +178,7 @@ function htmlToMarkdown(html, options = {}) {
|
|
|
132
178
|
function htmlToMarkdownBytes(html, options = {}) {
|
|
133
179
|
const resolved = resolveOptions(options);
|
|
134
180
|
if (resolved.frontmatterCallback || resolved.extractionHandlers) return htmlToMarkdown(new TextDecoder().decode(html), options);
|
|
135
|
-
return
|
|
181
|
+
return convertWasmBytes(html, resolved.napiOpts, engine);
|
|
136
182
|
}
|
|
137
183
|
var MarkdownStream = class extends MarkdownStream$1 {
|
|
138
184
|
_callbacks;
|
package/napi/index.mjs
CHANGED
|
@@ -97,8 +97,8 @@ function requireNative() {
|
|
|
97
97
|
try {
|
|
98
98
|
const binding = require('@mdream/rust-android-arm64')
|
|
99
99
|
const bindingPackageVersion = require('@mdream/rust-android-arm64/package.json').version
|
|
100
|
-
if (bindingPackageVersion !== '2.
|
|
101
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
100
|
+
if (bindingPackageVersion !== '2.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
101
|
+
throw new Error(`Native binding package version mismatch, expected 2.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
102
102
|
}
|
|
103
103
|
return binding
|
|
104
104
|
} catch (e) {
|
|
@@ -113,8 +113,8 @@ function requireNative() {
|
|
|
113
113
|
try {
|
|
114
114
|
const binding = require('@mdream/rust-android-arm-eabi')
|
|
115
115
|
const bindingPackageVersion = require('@mdream/rust-android-arm-eabi/package.json').version
|
|
116
|
-
if (bindingPackageVersion !== '2.
|
|
117
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
116
|
+
if (bindingPackageVersion !== '2.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
117
|
+
throw new Error(`Native binding package version mismatch, expected 2.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
118
118
|
}
|
|
119
119
|
return binding
|
|
120
120
|
} catch (e) {
|
|
@@ -134,8 +134,8 @@ function requireNative() {
|
|
|
134
134
|
try {
|
|
135
135
|
const binding = require('@mdream/rust-win32-x64-gnu')
|
|
136
136
|
const bindingPackageVersion = require('@mdream/rust-win32-x64-gnu/package.json').version
|
|
137
|
-
if (bindingPackageVersion !== '2.
|
|
138
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
137
|
+
if (bindingPackageVersion !== '2.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
138
|
+
throw new Error(`Native binding package version mismatch, expected 2.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
139
139
|
}
|
|
140
140
|
return binding
|
|
141
141
|
} catch (e) {
|
|
@@ -150,8 +150,8 @@ function requireNative() {
|
|
|
150
150
|
try {
|
|
151
151
|
const binding = require('@mdream/rust-win32-x64-msvc')
|
|
152
152
|
const bindingPackageVersion = require('@mdream/rust-win32-x64-msvc/package.json').version
|
|
153
|
-
if (bindingPackageVersion !== '2.
|
|
154
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
153
|
+
if (bindingPackageVersion !== '2.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
154
|
+
throw new Error(`Native binding package version mismatch, expected 2.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
155
155
|
}
|
|
156
156
|
return binding
|
|
157
157
|
} catch (e) {
|
|
@@ -167,8 +167,8 @@ function requireNative() {
|
|
|
167
167
|
try {
|
|
168
168
|
const binding = require('@mdream/rust-win32-ia32-msvc')
|
|
169
169
|
const bindingPackageVersion = require('@mdream/rust-win32-ia32-msvc/package.json').version
|
|
170
|
-
if (bindingPackageVersion !== '2.
|
|
171
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
170
|
+
if (bindingPackageVersion !== '2.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
171
|
+
throw new Error(`Native binding package version mismatch, expected 2.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
172
172
|
}
|
|
173
173
|
return binding
|
|
174
174
|
} catch (e) {
|
|
@@ -183,8 +183,8 @@ function requireNative() {
|
|
|
183
183
|
try {
|
|
184
184
|
const binding = require('@mdream/rust-win32-arm64-msvc')
|
|
185
185
|
const bindingPackageVersion = require('@mdream/rust-win32-arm64-msvc/package.json').version
|
|
186
|
-
if (bindingPackageVersion !== '2.
|
|
187
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
186
|
+
if (bindingPackageVersion !== '2.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
187
|
+
throw new Error(`Native binding package version mismatch, expected 2.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
188
188
|
}
|
|
189
189
|
return binding
|
|
190
190
|
} catch (e) {
|
|
@@ -202,8 +202,8 @@ function requireNative() {
|
|
|
202
202
|
try {
|
|
203
203
|
const binding = require('@mdream/rust-darwin-universal')
|
|
204
204
|
const bindingPackageVersion = require('@mdream/rust-darwin-universal/package.json').version
|
|
205
|
-
if (bindingPackageVersion !== '2.
|
|
206
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
205
|
+
if (bindingPackageVersion !== '2.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
206
|
+
throw new Error(`Native binding package version mismatch, expected 2.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
207
207
|
}
|
|
208
208
|
return binding
|
|
209
209
|
} catch (e) {
|
|
@@ -218,8 +218,8 @@ function requireNative() {
|
|
|
218
218
|
try {
|
|
219
219
|
const binding = require('@mdream/rust-darwin-x64')
|
|
220
220
|
const bindingPackageVersion = require('@mdream/rust-darwin-x64/package.json').version
|
|
221
|
-
if (bindingPackageVersion !== '2.
|
|
222
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
221
|
+
if (bindingPackageVersion !== '2.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
222
|
+
throw new Error(`Native binding package version mismatch, expected 2.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
223
223
|
}
|
|
224
224
|
return binding
|
|
225
225
|
} catch (e) {
|
|
@@ -234,8 +234,8 @@ function requireNative() {
|
|
|
234
234
|
try {
|
|
235
235
|
const binding = require('@mdream/rust-darwin-arm64')
|
|
236
236
|
const bindingPackageVersion = require('@mdream/rust-darwin-arm64/package.json').version
|
|
237
|
-
if (bindingPackageVersion !== '2.
|
|
238
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
237
|
+
if (bindingPackageVersion !== '2.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
238
|
+
throw new Error(`Native binding package version mismatch, expected 2.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
239
239
|
}
|
|
240
240
|
return binding
|
|
241
241
|
} catch (e) {
|
|
@@ -254,8 +254,8 @@ function requireNative() {
|
|
|
254
254
|
try {
|
|
255
255
|
const binding = require('@mdream/rust-freebsd-x64')
|
|
256
256
|
const bindingPackageVersion = require('@mdream/rust-freebsd-x64/package.json').version
|
|
257
|
-
if (bindingPackageVersion !== '2.
|
|
258
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
257
|
+
if (bindingPackageVersion !== '2.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
258
|
+
throw new Error(`Native binding package version mismatch, expected 2.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
259
259
|
}
|
|
260
260
|
return binding
|
|
261
261
|
} catch (e) {
|
|
@@ -270,8 +270,8 @@ function requireNative() {
|
|
|
270
270
|
try {
|
|
271
271
|
const binding = require('@mdream/rust-freebsd-arm64')
|
|
272
272
|
const bindingPackageVersion = require('@mdream/rust-freebsd-arm64/package.json').version
|
|
273
|
-
if (bindingPackageVersion !== '2.
|
|
274
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
273
|
+
if (bindingPackageVersion !== '2.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
274
|
+
throw new Error(`Native binding package version mismatch, expected 2.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
275
275
|
}
|
|
276
276
|
return binding
|
|
277
277
|
} catch (e) {
|
|
@@ -286,8 +286,8 @@ function requireNative() {
|
|
|
286
286
|
try {
|
|
287
287
|
const binding = require('@mdream/rust-freebsd-ppc64')
|
|
288
288
|
const bindingPackageVersion = require('@mdream/rust-freebsd-ppc64/package.json').version
|
|
289
|
-
if (bindingPackageVersion !== '2.
|
|
290
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
289
|
+
if (bindingPackageVersion !== '2.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
290
|
+
throw new Error(`Native binding package version mismatch, expected 2.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
291
291
|
}
|
|
292
292
|
return binding
|
|
293
293
|
} catch (e) {
|
|
@@ -307,8 +307,8 @@ function requireNative() {
|
|
|
307
307
|
try {
|
|
308
308
|
const binding = require('@mdream/rust-linux-x64-musl')
|
|
309
309
|
const bindingPackageVersion = require('@mdream/rust-linux-x64-musl/package.json').version
|
|
310
|
-
if (bindingPackageVersion !== '2.
|
|
311
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
310
|
+
if (bindingPackageVersion !== '2.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
311
|
+
throw new Error(`Native binding package version mismatch, expected 2.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
312
312
|
}
|
|
313
313
|
return binding
|
|
314
314
|
} catch (e) {
|
|
@@ -323,8 +323,8 @@ function requireNative() {
|
|
|
323
323
|
try {
|
|
324
324
|
const binding = require('@mdream/rust-linux-x64-gnu')
|
|
325
325
|
const bindingPackageVersion = require('@mdream/rust-linux-x64-gnu/package.json').version
|
|
326
|
-
if (bindingPackageVersion !== '2.
|
|
327
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
326
|
+
if (bindingPackageVersion !== '2.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
327
|
+
throw new Error(`Native binding package version mismatch, expected 2.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
328
328
|
}
|
|
329
329
|
return binding
|
|
330
330
|
} catch (e) {
|
|
@@ -341,8 +341,8 @@ function requireNative() {
|
|
|
341
341
|
try {
|
|
342
342
|
const binding = require('@mdream/rust-linux-arm64-musl')
|
|
343
343
|
const bindingPackageVersion = require('@mdream/rust-linux-arm64-musl/package.json').version
|
|
344
|
-
if (bindingPackageVersion !== '2.
|
|
345
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
344
|
+
if (bindingPackageVersion !== '2.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
345
|
+
throw new Error(`Native binding package version mismatch, expected 2.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
346
346
|
}
|
|
347
347
|
return binding
|
|
348
348
|
} catch (e) {
|
|
@@ -357,8 +357,8 @@ function requireNative() {
|
|
|
357
357
|
try {
|
|
358
358
|
const binding = require('@mdream/rust-linux-arm64-gnu')
|
|
359
359
|
const bindingPackageVersion = require('@mdream/rust-linux-arm64-gnu/package.json').version
|
|
360
|
-
if (bindingPackageVersion !== '2.
|
|
361
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
360
|
+
if (bindingPackageVersion !== '2.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
361
|
+
throw new Error(`Native binding package version mismatch, expected 2.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
362
362
|
}
|
|
363
363
|
return binding
|
|
364
364
|
} catch (e) {
|
|
@@ -375,8 +375,8 @@ function requireNative() {
|
|
|
375
375
|
try {
|
|
376
376
|
const binding = require('@mdream/rust-linux-arm-musleabihf')
|
|
377
377
|
const bindingPackageVersion = require('@mdream/rust-linux-arm-musleabihf/package.json').version
|
|
378
|
-
if (bindingPackageVersion !== '2.
|
|
379
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
378
|
+
if (bindingPackageVersion !== '2.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
379
|
+
throw new Error(`Native binding package version mismatch, expected 2.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
380
380
|
}
|
|
381
381
|
return binding
|
|
382
382
|
} catch (e) {
|
|
@@ -391,8 +391,8 @@ function requireNative() {
|
|
|
391
391
|
try {
|
|
392
392
|
const binding = require('@mdream/rust-linux-arm-gnueabihf')
|
|
393
393
|
const bindingPackageVersion = require('@mdream/rust-linux-arm-gnueabihf/package.json').version
|
|
394
|
-
if (bindingPackageVersion !== '2.
|
|
395
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
394
|
+
if (bindingPackageVersion !== '2.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
395
|
+
throw new Error(`Native binding package version mismatch, expected 2.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
396
396
|
}
|
|
397
397
|
return binding
|
|
398
398
|
} catch (e) {
|
|
@@ -409,8 +409,8 @@ function requireNative() {
|
|
|
409
409
|
try {
|
|
410
410
|
const binding = require('@mdream/rust-linux-loong64-musl')
|
|
411
411
|
const bindingPackageVersion = require('@mdream/rust-linux-loong64-musl/package.json').version
|
|
412
|
-
if (bindingPackageVersion !== '2.
|
|
413
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
412
|
+
if (bindingPackageVersion !== '2.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
413
|
+
throw new Error(`Native binding package version mismatch, expected 2.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
414
414
|
}
|
|
415
415
|
return binding
|
|
416
416
|
} catch (e) {
|
|
@@ -425,8 +425,8 @@ function requireNative() {
|
|
|
425
425
|
try {
|
|
426
426
|
const binding = require('@mdream/rust-linux-loong64-gnu')
|
|
427
427
|
const bindingPackageVersion = require('@mdream/rust-linux-loong64-gnu/package.json').version
|
|
428
|
-
if (bindingPackageVersion !== '2.
|
|
429
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
428
|
+
if (bindingPackageVersion !== '2.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
429
|
+
throw new Error(`Native binding package version mismatch, expected 2.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
430
430
|
}
|
|
431
431
|
return binding
|
|
432
432
|
} catch (e) {
|
|
@@ -443,8 +443,8 @@ function requireNative() {
|
|
|
443
443
|
try {
|
|
444
444
|
const binding = require('@mdream/rust-linux-riscv64-musl')
|
|
445
445
|
const bindingPackageVersion = require('@mdream/rust-linux-riscv64-musl/package.json').version
|
|
446
|
-
if (bindingPackageVersion !== '2.
|
|
447
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
446
|
+
if (bindingPackageVersion !== '2.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
447
|
+
throw new Error(`Native binding package version mismatch, expected 2.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
448
448
|
}
|
|
449
449
|
return binding
|
|
450
450
|
} catch (e) {
|
|
@@ -459,8 +459,8 @@ function requireNative() {
|
|
|
459
459
|
try {
|
|
460
460
|
const binding = require('@mdream/rust-linux-riscv64-gnu')
|
|
461
461
|
const bindingPackageVersion = require('@mdream/rust-linux-riscv64-gnu/package.json').version
|
|
462
|
-
if (bindingPackageVersion !== '2.
|
|
463
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
462
|
+
if (bindingPackageVersion !== '2.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
463
|
+
throw new Error(`Native binding package version mismatch, expected 2.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
464
464
|
}
|
|
465
465
|
return binding
|
|
466
466
|
} catch (e) {
|
|
@@ -476,8 +476,8 @@ function requireNative() {
|
|
|
476
476
|
try {
|
|
477
477
|
const binding = require('@mdream/rust-linux-ppc64-gnu')
|
|
478
478
|
const bindingPackageVersion = require('@mdream/rust-linux-ppc64-gnu/package.json').version
|
|
479
|
-
if (bindingPackageVersion !== '2.
|
|
480
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
479
|
+
if (bindingPackageVersion !== '2.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
480
|
+
throw new Error(`Native binding package version mismatch, expected 2.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
481
481
|
}
|
|
482
482
|
return binding
|
|
483
483
|
} catch (e) {
|
|
@@ -492,8 +492,8 @@ function requireNative() {
|
|
|
492
492
|
try {
|
|
493
493
|
const binding = require('@mdream/rust-linux-s390x-gnu')
|
|
494
494
|
const bindingPackageVersion = require('@mdream/rust-linux-s390x-gnu/package.json').version
|
|
495
|
-
if (bindingPackageVersion !== '2.
|
|
496
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
495
|
+
if (bindingPackageVersion !== '2.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
496
|
+
throw new Error(`Native binding package version mismatch, expected 2.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
497
497
|
}
|
|
498
498
|
return binding
|
|
499
499
|
} catch (e) {
|
|
@@ -512,8 +512,8 @@ function requireNative() {
|
|
|
512
512
|
try {
|
|
513
513
|
const binding = require('@mdream/rust-openharmony-arm64')
|
|
514
514
|
const bindingPackageVersion = require('@mdream/rust-openharmony-arm64/package.json').version
|
|
515
|
-
if (bindingPackageVersion !== '2.
|
|
516
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
515
|
+
if (bindingPackageVersion !== '2.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
516
|
+
throw new Error(`Native binding package version mismatch, expected 2.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
517
517
|
}
|
|
518
518
|
return binding
|
|
519
519
|
} catch (e) {
|
|
@@ -528,8 +528,8 @@ function requireNative() {
|
|
|
528
528
|
try {
|
|
529
529
|
const binding = require('@mdream/rust-openharmony-x64')
|
|
530
530
|
const bindingPackageVersion = require('@mdream/rust-openharmony-x64/package.json').version
|
|
531
|
-
if (bindingPackageVersion !== '2.
|
|
532
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
531
|
+
if (bindingPackageVersion !== '2.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
532
|
+
throw new Error(`Native binding package version mismatch, expected 2.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
533
533
|
}
|
|
534
534
|
return binding
|
|
535
535
|
} catch (e) {
|
|
@@ -544,8 +544,8 @@ function requireNative() {
|
|
|
544
544
|
try {
|
|
545
545
|
const binding = require('@mdream/rust-openharmony-arm')
|
|
546
546
|
const bindingPackageVersion = require('@mdream/rust-openharmony-arm/package.json').version
|
|
547
|
-
if (bindingPackageVersion !== '2.
|
|
548
|
-
throw new Error(`Native binding package version mismatch, expected 2.
|
|
547
|
+
if (bindingPackageVersion !== '2.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
548
|
+
throw new Error(`Native binding package version mismatch, expected 2.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
549
549
|
}
|
|
550
550
|
return binding
|
|
551
551
|
} catch (e) {
|
|
@@ -686,8 +686,8 @@ if (!nativeBinding || forceWasi) {
|
|
|
686
686
|
if (!candidateFailed) {
|
|
687
687
|
if (process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
688
688
|
const bindingPackageVersion = require('@mdream/rust-wasm32-wasi/package.json').version
|
|
689
|
-
if (bindingPackageVersion !== '2.
|
|
690
|
-
throw new Error(`WASI binding package version mismatch, expected 2.
|
|
689
|
+
if (bindingPackageVersion !== '2.2.0') {
|
|
690
|
+
throw new Error(`WASI binding package version mismatch, expected 2.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
691
691
|
}
|
|
692
692
|
}
|
|
693
693
|
wasiBinding = require('@mdream/rust-wasm32-wasi')
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mdream",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.2.0",
|
|
5
5
|
"description": "Ultra-performant HTML to Markdown Convertor Optimized for LLMs and llm.txt artifacts.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Harlan Wilton",
|
|
@@ -25,15 +25,24 @@
|
|
|
25
25
|
"directory": "packages/mdream"
|
|
26
26
|
},
|
|
27
27
|
"sideEffects": [
|
|
28
|
-
"./wasm-bundler/mdream_edge.js"
|
|
28
|
+
"./wasm-bundler/mdream_edge.js",
|
|
29
|
+
"./wasm-bundler/mdream_markdown.js"
|
|
29
30
|
],
|
|
30
31
|
"exports": {
|
|
31
32
|
".": {
|
|
32
33
|
"workerd": {
|
|
34
|
+
"mdream-markdown": {
|
|
35
|
+
"types": "./dist/edge-markdown.d.mts",
|
|
36
|
+
"default": "./dist/edge-markdown.mjs"
|
|
37
|
+
},
|
|
33
38
|
"types": "./dist/edge.d.mts",
|
|
34
39
|
"default": "./dist/edge.mjs"
|
|
35
40
|
},
|
|
36
41
|
"edge-light": {
|
|
42
|
+
"mdream-markdown": {
|
|
43
|
+
"types": "./dist/edge-markdown.d.mts",
|
|
44
|
+
"default": "./dist/edge-markdown.mjs"
|
|
45
|
+
},
|
|
37
46
|
"types": "./dist/edge.d.mts",
|
|
38
47
|
"default": "./dist/edge.mjs"
|
|
39
48
|
},
|
|
@@ -46,6 +55,10 @@
|
|
|
46
55
|
"default": "./dist/index.mjs"
|
|
47
56
|
},
|
|
48
57
|
"./browser": {
|
|
58
|
+
"mdream-markdown": {
|
|
59
|
+
"types": "./dist/browser-markdown.d.mts",
|
|
60
|
+
"default": "./dist/browser-markdown.mjs"
|
|
61
|
+
},
|
|
49
62
|
"types": "./dist/browser.d.mts",
|
|
50
63
|
"default": "./dist/browser.mjs"
|
|
51
64
|
},
|
|
@@ -72,24 +85,24 @@
|
|
|
72
85
|
],
|
|
73
86
|
"dependencies": {},
|
|
74
87
|
"optionalDependencies": {
|
|
75
|
-
"@mdream/rust-android-arm-eabi": "2.
|
|
76
|
-
"@mdream/rust-android-arm64": "2.
|
|
77
|
-
"@mdream/rust-darwin-arm64": "2.
|
|
78
|
-
"@mdream/rust-darwin-x64": "2.
|
|
79
|
-
"@mdream/rust-freebsd-x64": "2.
|
|
80
|
-
"@mdream/rust-linux-arm-gnueabihf": "2.
|
|
81
|
-
"@mdream/rust-linux-arm64-gnu": "2.
|
|
82
|
-
"@mdream/rust-linux-arm64-musl": "2.
|
|
83
|
-
"@mdream/rust-linux-x64-gnu": "2.
|
|
84
|
-
"@mdream/rust-linux-x64-musl": "2.
|
|
85
|
-
"@mdream/rust-wasm32-wasi": "2.
|
|
86
|
-
"@mdream/rust-win32-arm64-msvc": "2.
|
|
87
|
-
"@mdream/rust-win32-x64-msvc": "2.
|
|
88
|
+
"@mdream/rust-android-arm-eabi": "2.2.0",
|
|
89
|
+
"@mdream/rust-android-arm64": "2.2.0",
|
|
90
|
+
"@mdream/rust-darwin-arm64": "2.2.0",
|
|
91
|
+
"@mdream/rust-darwin-x64": "2.2.0",
|
|
92
|
+
"@mdream/rust-freebsd-x64": "2.2.0",
|
|
93
|
+
"@mdream/rust-linux-arm-gnueabihf": "2.2.0",
|
|
94
|
+
"@mdream/rust-linux-arm64-gnu": "2.2.0",
|
|
95
|
+
"@mdream/rust-linux-arm64-musl": "2.2.0",
|
|
96
|
+
"@mdream/rust-linux-x64-gnu": "2.2.0",
|
|
97
|
+
"@mdream/rust-linux-x64-musl": "2.2.0",
|
|
98
|
+
"@mdream/rust-wasm32-wasi": "2.2.0",
|
|
99
|
+
"@mdream/rust-win32-arm64-msvc": "2.2.0",
|
|
100
|
+
"@mdream/rust-win32-x64-msvc": "2.2.0"
|
|
88
101
|
},
|
|
89
102
|
"devDependencies": {
|
|
90
|
-
"@mdream/js": "2.
|
|
91
|
-
"@mdream/rust-build": "2.
|
|
92
|
-
"rolldown": "^1.3.
|
|
103
|
+
"@mdream/js": "2.2.0",
|
|
104
|
+
"@mdream/rust-build": "2.2.0",
|
|
105
|
+
"rolldown": "^1.3.2"
|
|
93
106
|
},
|
|
94
107
|
"scripts": {
|
|
95
108
|
"ts": "node --experimental-strip-types",
|
|
@@ -101,9 +114,10 @@
|
|
|
101
114
|
"test:wiki-small:file": "cat test/fixtures/wikipedia-small.html | node ./bin/mdream.mjs --origin https://en.wikipedia.org | tee test/wiki-markdown.md",
|
|
102
115
|
"build": "obuild",
|
|
103
116
|
"build:native": "pnpm --dir ../../crates/node run build:platform",
|
|
104
|
-
"build:edge": "node ../../scripts/build-wasm-edge.mjs --target web --out-dir
|
|
117
|
+
"build:edge": "node ../../scripts/build-wasm-edge.mjs --target web --out-dir wasm && node ../../scripts/build-wasm-edge.mjs --target bundler --out-dir wasm-bundler --shared-wasm-dir wasm",
|
|
105
118
|
"typecheck": "tsc --noEmit",
|
|
106
119
|
"dev:prepare": "obuild --stub",
|
|
120
|
+
"postbuild:edge": "node ../../scripts/build-wasm-markdown.ts",
|
|
107
121
|
"test": "vitest test",
|
|
108
122
|
"test:attw": "attw --pack"
|
|
109
123
|
}
|
package/wasm/mdream_edge.js
CHANGED
|
@@ -199,10 +199,19 @@ function __wbg_get_imports() {
|
|
|
199
199
|
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
200
200
|
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
201
201
|
},
|
|
202
|
+
__wbg___wbindgen_is_function_1f9d30630b8b1d3d: function(arg0) {
|
|
203
|
+
const ret = typeof(getObject(arg0)) === 'function';
|
|
204
|
+
return ret;
|
|
205
|
+
},
|
|
202
206
|
__wbg___wbindgen_is_null_e343b7d08827ba72: function(arg0) {
|
|
203
207
|
const ret = getObject(arg0) === null;
|
|
204
208
|
return ret;
|
|
205
209
|
},
|
|
210
|
+
__wbg___wbindgen_is_object_3c45d4f2dde4e749: function(arg0) {
|
|
211
|
+
const val = getObject(arg0);
|
|
212
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
213
|
+
return ret;
|
|
214
|
+
},
|
|
206
215
|
__wbg___wbindgen_is_undefined_8865fb403f8fe9d8: function(arg0) {
|
|
207
216
|
const ret = getObject(arg0) === undefined;
|
|
208
217
|
return ret;
|
|
@@ -194,10 +194,19 @@ export function __wbg___wbindgen_boolean_get_5b446f51afd21013(arg0) {
|
|
|
194
194
|
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
195
195
|
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
196
196
|
}
|
|
197
|
+
export function __wbg___wbindgen_is_function_1f9d30630b8b1d3d(arg0) {
|
|
198
|
+
const ret = typeof(getObject(arg0)) === 'function';
|
|
199
|
+
return ret;
|
|
200
|
+
}
|
|
197
201
|
export function __wbg___wbindgen_is_null_e343b7d08827ba72(arg0) {
|
|
198
202
|
const ret = getObject(arg0) === null;
|
|
199
203
|
return ret;
|
|
200
204
|
}
|
|
205
|
+
export function __wbg___wbindgen_is_object_3c45d4f2dde4e749(arg0) {
|
|
206
|
+
const val = getObject(arg0);
|
|
207
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
208
|
+
return ret;
|
|
209
|
+
}
|
|
201
210
|
export function __wbg___wbindgen_is_undefined_8865fb403f8fe9d8(arg0) {
|
|
202
211
|
const ret = getObject(arg0) === undefined;
|
|
203
212
|
return ret;
|
package/wasm/mdream_edge_bg.wasm
CHANGED
|
Binary file
|
package/wasm/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/* @ts-self-types="./mdream_edge.d.ts" */
|
|
2
|
-
import wasmModule from "
|
|
3
|
-
import * as imports from "
|
|
2
|
+
import wasmModule from "../wasm/mdream_edge_bg.wasm";
|
|
3
|
+
import * as imports from "../wasm/mdream_edge_bg.js";
|
|
4
4
|
const wasm = wasmModule instanceof WebAssembly.Module
|
|
5
5
|
? new WebAssembly.Instance(wasmModule, { "./mdream_edge_bg.js": imports }).exports
|
|
6
6
|
: wasmModule;
|
|
7
|
-
import { __wbg_set_wasm } from "
|
|
7
|
+
import { __wbg_set_wasm } from "../wasm/mdream_edge_bg.js";
|
|
8
8
|
|
|
9
9
|
__wbg_set_wasm(wasm);
|
|
10
10
|
wasm.__wbindgen_start();
|
|
11
11
|
export {
|
|
12
12
|
MarkdownStream, __mdreamTakePanicMessage, htmlToMarkdown, htmlToMarkdownBytes, htmlToMarkdownResult, install_panic_hook
|
|
13
|
-
} from "
|
|
13
|
+
} from "../wasm/mdream_edge_bg.js";
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
export class MarkdownStream {
|
|
5
|
+
free(): void;
|
|
6
|
+
[Symbol.dispose](): void;
|
|
7
|
+
finish(): string;
|
|
8
|
+
constructor(options: any);
|
|
9
|
+
/**
|
|
10
|
+
* Byte chunk in, string out, skipping the transcode per chunk. A sequence
|
|
11
|
+
* split across chunks carries to the next call rather than decoding early,
|
|
12
|
+
* matching `TextDecoder({ stream: true })`; invalid bytes become U+FFFD.
|
|
13
|
+
*/
|
|
14
|
+
processChunkBytes(chunk: Uint8Array): string;
|
|
15
|
+
/**
|
|
16
|
+
* A carried byte tail cannot be completed by a string chunk, so it is
|
|
17
|
+
* flushed first. Byte and string chunks may be mixed freely.
|
|
18
|
+
*/
|
|
19
|
+
processChunk(chunk: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Frontmatter and extracted elements collected so far, as
|
|
22
|
+
* `{ frontmatter?, extracted? }`. Call after `finish()` for the complete
|
|
23
|
+
* data. Extracted elements drain on each call.
|
|
24
|
+
*/
|
|
25
|
+
takeData(): any;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Consumes the message of the panic that aborted the last export call.
|
|
30
|
+
*/
|
|
31
|
+
export function __mdreamTakePanicMessage(): string | undefined;
|
|
32
|
+
|
|
33
|
+
export function htmlToMarkdown(html: string, options: any): string;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Bytes in, string out: skips the transcode (~14% of a convert) for a
|
|
37
|
+
* caller already holding UTF-8 bytes. Encoding a string to get here
|
|
38
|
+
* measures 1-16% *slower* than [`html_to_markdown`] — only worth it when
|
|
39
|
+
* the bytes are already in hand.
|
|
40
|
+
*/
|
|
41
|
+
export function htmlToMarkdownBytes(html: Uint8Array, options: any): string;
|
|
42
|
+
|
|
43
|
+
export function htmlToMarkdownResult(html: string, options: any): any;
|
|
44
|
+
|
|
45
|
+
export function install_panic_hook(): void;
|