nuxt-ai-ready 2.5.0 → 2.5.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/dist/chunks/agent-skills.mjs +1 -1
- package/dist/chunks/prerender.mjs +1 -1
- package/dist/cli.mjs +2 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/server/db/drizzle/queries.js +0 -1
- package/dist/runtime/server/db/queries.d.ts +2 -0
- package/dist/runtime/server/db/queries.js +11 -5
- package/dist/runtime/server/db/seed.d.ts +2 -2
- package/dist/runtime/server/routes/__ai-ready/reindex.post.js +2 -0
- package/dist/runtime/server/utils/batchIndex.js +4 -2
- package/dist/runtime/server/utils/checkStale.d.ts +1 -1
- package/dist/runtime/server/utils/checkStale.js +1 -1
- package/dist/runtime/server/utils/indexPage.d.ts +8 -1
- package/dist/runtime/server/utils/indexPage.js +13 -5
- package/dist/shared/{nuxt-ai-ready.DsokNmXc.mjs → nuxt-ai-ready.CLSWou20.mjs} +2 -0
- package/node_modules/@mdream/js/LICENSE.md +9 -0
- package/node_modules/@mdream/js/README.md +792 -0
- package/node_modules/@mdream/js/bin/mdream.mjs +2 -0
- package/node_modules/@mdream/js/dist/_chunks/const.mjs +134 -0
- package/node_modules/@mdream/js/dist/_chunks/index.d.mts +9 -0
- package/node_modules/@mdream/js/dist/_chunks/markdown-processor.mjs +1968 -0
- package/node_modules/@mdream/js/dist/_chunks/minimal.d.mts +6 -0
- package/node_modules/@mdream/js/dist/_chunks/parse.mjs +2756 -0
- package/node_modules/@mdream/js/dist/_chunks/plugins.mjs +725 -0
- package/node_modules/@mdream/js/dist/_chunks/resolve-plugins.mjs +44 -0
- package/node_modules/@mdream/js/dist/_chunks/stream.mjs +37 -0
- package/node_modules/@mdream/js/dist/_chunks/types.d.mts +473 -0
- package/node_modules/@mdream/js/dist/cli.d.mts +1 -0
- package/node_modules/@mdream/js/dist/cli.mjs +32 -0
- package/node_modules/@mdream/js/dist/core.d.mts +15 -0
- package/node_modules/@mdream/js/dist/core.mjs +28 -0
- package/node_modules/@mdream/js/dist/index.d.mts +4 -0
- package/node_modules/@mdream/js/dist/index.mjs +58 -0
- package/node_modules/@mdream/js/dist/llms-txt.d.mts +86 -0
- package/node_modules/@mdream/js/dist/llms-txt.mjs +308 -0
- package/node_modules/@mdream/js/dist/negotiate.d.mts +35 -0
- package/node_modules/@mdream/js/dist/negotiate.mjs +121 -0
- package/node_modules/@mdream/js/dist/parse.d.mts +90 -0
- package/node_modules/@mdream/js/dist/parse.mjs +2 -0
- package/node_modules/@mdream/js/dist/plugins.d.mts +85 -0
- package/node_modules/@mdream/js/dist/plugins.mjs +2 -0
- package/node_modules/@mdream/js/dist/preset/minimal.d.mts +2 -0
- package/node_modules/@mdream/js/dist/preset/minimal.mjs +33 -0
- package/node_modules/@mdream/js/dist/splitter.d.mts +18 -0
- package/node_modules/@mdream/js/dist/splitter.mjs +194 -0
- package/node_modules/@mdream/js/package.json +103 -0
- package/node_modules/cac/LICENSE +21 -0
- package/node_modules/cac/README.md +492 -0
- package/node_modules/cac/dist/index.d.ts +196 -0
- package/node_modules/cac/dist/index.js +638 -0
- package/node_modules/cac/package.json +72 -0
- package/node_modules/mdream/LICENSE.md +9 -0
- package/node_modules/mdream/README.md +1091 -0
- package/node_modules/mdream/bin/mdream.mjs +46 -0
- package/node_modules/mdream/dist/browser.d.mts +105 -0
- package/node_modules/mdream/dist/browser.mjs +262 -0
- package/node_modules/mdream/dist/edge.d.mts +100 -0
- package/node_modules/mdream/dist/edge.mjs +250 -0
- package/node_modules/mdream/dist/iife.js +605 -0
- package/node_modules/mdream/dist/index.d.mts +89 -0
- package/node_modules/mdream/dist/index.mjs +184 -0
- package/node_modules/mdream/dist/wasm.d.mts +100 -0
- package/node_modules/mdream/dist/wasm.mjs +140 -0
- package/node_modules/mdream/dist/worker.d.mts +101 -0
- package/node_modules/mdream/dist/worker.mjs +217 -0
- package/node_modules/mdream/napi/index.d.mts +127 -0
- package/node_modules/mdream/napi/index.d.ts +127 -0
- package/node_modules/mdream/napi/index.mjs +725 -0
- package/node_modules/mdream/napi/rust.android-arm-eabi.node +0 -0
- package/node_modules/mdream/napi/rust.android-arm64.node +0 -0
- package/node_modules/mdream/napi/rust.darwin-arm64.node +0 -0
- package/node_modules/mdream/napi/rust.darwin-x64.node +0 -0
- package/node_modules/mdream/napi/rust.freebsd-x64.node +0 -0
- package/node_modules/mdream/napi/rust.linux-arm-gnueabihf.node +0 -0
- package/node_modules/mdream/napi/rust.linux-arm64-gnu.node +0 -0
- package/node_modules/mdream/napi/rust.linux-arm64-musl.node +0 -0
- package/node_modules/mdream/napi/rust.linux-x64-gnu.node +0 -0
- package/node_modules/mdream/napi/rust.linux-x64-musl.node +0 -0
- package/node_modules/mdream/napi/rust.wasi.cjs +2144 -0
- package/node_modules/mdream/napi/rust.wasm32-wasi.wasm +0 -0
- package/node_modules/mdream/napi/rust.win32-arm64-msvc.node +0 -0
- package/node_modules/mdream/napi/rust.win32-x64-msvc.node +0 -0
- package/node_modules/mdream/node_modules/@emnapi/core/LICENSE +21 -0
- package/node_modules/mdream/node_modules/@emnapi/core/README.md +1 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/emnapi-core.d.ts +392 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/emnapi-core.full.d.ts +392 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/emnapi-core.full.js +8351 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/emnapi-core.js +7268 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/async-work.d.ts +5 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/async-work.js +843 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/index.d.ts +4 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/index.js +3 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/threadsafe-function.d.ts +5 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/threadsafe-function.js +1010 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/v8.d.ts +5 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/v8.js +1446 -0
- package/node_modules/mdream/node_modules/@emnapi/core/package.json +39 -0
- package/node_modules/mdream/node_modules/@emnapi/core/rollup.config.js +60 -0
- package/node_modules/mdream/node_modules/@emnapi/runtime/LICENSE +21 -0
- package/node_modules/mdream/node_modules/@emnapi/runtime/README.md +1 -0
- package/node_modules/mdream/node_modules/@emnapi/runtime/dist/emnapi.d.ts +833 -0
- package/node_modules/mdream/node_modules/@emnapi/runtime/dist/emnapi.js +2306 -0
- package/node_modules/mdream/node_modules/@emnapi/runtime/dist/emnapi.js.map +1 -0
- package/node_modules/mdream/node_modules/@emnapi/runtime/index.cjs +63 -0
- package/node_modules/mdream/node_modules/@emnapi/runtime/package.json +39 -0
- package/node_modules/mdream/node_modules/@emnapi/runtime/rollup.config.js +25 -0
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/LICENSE +21 -0
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/README.md +203 -0
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/dist/wasi-threads.d.ts +236 -0
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/dist/wasi-threads.js +1086 -0
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/package.json +35 -0
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/rollup.config.js +6 -0
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/dist/emnapi-plugins.cjs +1472 -0
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/dist/emnapi-plugins.js +1470 -0
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/dist/fs-proxy.cjs +237 -0
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/dist/fs.js +18260 -0
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/fs-proxy.js +317 -0
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/package.json +67 -0
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/runtime.cjs +39 -0
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/runtime.js +36 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/LICENSE +21 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/README.md +193 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/tsdoc-metadata.json +11 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.d.ts +423 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.esm-bundler.js +2932 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.esm.js +2932 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.esm.min.js +1 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.js +2954 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.min.js +1 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/asyncify.js +158 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/index.js +13 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/jspi.js +46 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/load.js +97 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/memory.js +35 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/error.js +103 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/fd.js +268 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/fs.js +3 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/index.js +192 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/path.js +316 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/preview1.js +1599 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/rights.js +141 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/types.js +220 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/util.js +128 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/webassembly.js +13 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/asyncify.mjs +153 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/index.mjs +9 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/jspi.mjs +39 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/load.mjs +89 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/memory.mjs +28 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/error.mjs +97 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/fd.mjs +256 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/fs.mjs +1 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/index.mjs +186 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/path.mjs +310 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/preview1.mjs +1593 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/rights.mjs +135 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/types.mjs +216 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/util.mjs +113 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/webassembly.mjs +9 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/package.json +58 -0
- package/node_modules/mdream/node_modules/tslib/CopyrightNotice.txt +15 -0
- package/node_modules/mdream/node_modules/tslib/LICENSE.txt +12 -0
- package/node_modules/mdream/node_modules/tslib/README.md +164 -0
- package/node_modules/mdream/node_modules/tslib/SECURITY.md +41 -0
- package/node_modules/mdream/node_modules/tslib/modules/index.d.ts +38 -0
- package/node_modules/mdream/node_modules/tslib/modules/index.js +70 -0
- package/node_modules/mdream/node_modules/tslib/modules/package.json +3 -0
- package/node_modules/mdream/node_modules/tslib/package.json +47 -0
- package/node_modules/mdream/node_modules/tslib/tslib.d.ts +460 -0
- package/node_modules/mdream/node_modules/tslib/tslib.es6.html +1 -0
- package/node_modules/mdream/node_modules/tslib/tslib.es6.js +402 -0
- package/node_modules/mdream/node_modules/tslib/tslib.es6.mjs +401 -0
- package/node_modules/mdream/node_modules/tslib/tslib.html +1 -0
- package/node_modules/mdream/node_modules/tslib/tslib.js +484 -0
- package/node_modules/mdream/package.json +110 -0
- package/node_modules/mdream/skills/mdream/SKILL.md +124 -0
- package/node_modules/mdream/skills/mdream/references/runtimes.md +49 -0
- package/node_modules/mdream/wasm/mdream_edge.d.ts +90 -0
- package/node_modules/mdream/wasm/mdream_edge.js +517 -0
- package/node_modules/mdream/wasm/mdream_edge_bg.wasm +0 -0
- package/node_modules/mdream/wasm/mdream_edge_bg.wasm.d.ts +20 -0
- package/node_modules/mdream/wasm/package.json +17 -0
- package/node_modules/mdream/wasm-bundler/mdream_edge.d.ts +45 -0
- package/node_modules/mdream/wasm-bundler/mdream_edge.js +13 -0
- package/node_modules/mdream/wasm-bundler/mdream_edge_bg.js +413 -0
- package/node_modules/mdream/wasm-bundler/mdream_edge_bg.wasm +0 -0
- package/node_modules/mdream/wasm-bundler/mdream_edge_bg.wasm.d.ts +20 -0
- package/node_modules/mdream/wasm-bundler/package.json +19 -0
- package/node_modules/pathe/LICENSE +70 -0
- package/node_modules/pathe/README.md +73 -0
- package/node_modules/pathe/dist/index.cjs +39 -0
- package/node_modules/pathe/dist/index.d.cts +47 -0
- package/node_modules/pathe/dist/index.d.mts +47 -0
- package/node_modules/pathe/dist/index.d.ts +47 -0
- package/node_modules/pathe/dist/index.mjs +19 -0
- package/node_modules/pathe/dist/shared/pathe.BSlhyZSM.cjs +266 -0
- package/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs +249 -0
- package/node_modules/pathe/dist/utils.cjs +82 -0
- package/node_modules/pathe/dist/utils.d.cts +32 -0
- package/node_modules/pathe/dist/utils.d.mts +32 -0
- package/node_modules/pathe/dist/utils.d.ts +32 -0
- package/node_modules/pathe/dist/utils.mjs +77 -0
- package/node_modules/pathe/package.json +61 -0
- package/node_modules/pathe/utils.d.ts +1 -0
- package/package.json +8 -64
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
const MINIMAL_FILTER_EXCLUDE = [
|
|
2
|
+
"form",
|
|
3
|
+
"fieldset",
|
|
4
|
+
"object",
|
|
5
|
+
"embed",
|
|
6
|
+
"footer",
|
|
7
|
+
"aside",
|
|
8
|
+
"iframe",
|
|
9
|
+
"input",
|
|
10
|
+
"textarea",
|
|
11
|
+
"select",
|
|
12
|
+
"button",
|
|
13
|
+
"nav"
|
|
14
|
+
];
|
|
15
|
+
const CLEAN_ALL = {
|
|
16
|
+
urls: true,
|
|
17
|
+
fragments: true,
|
|
18
|
+
emptyLinks: true,
|
|
19
|
+
redundantLinks: true,
|
|
20
|
+
selfLinkHeadings: true,
|
|
21
|
+
emptyImages: true,
|
|
22
|
+
emptyLinkText: true
|
|
23
|
+
};
|
|
24
|
+
function resolveCleanConfig(options, minimal) {
|
|
25
|
+
const cleanUrls = options.cleanUrls === true;
|
|
26
|
+
let cleanOpt = options.clean;
|
|
27
|
+
if (cleanOpt === void 0) {
|
|
28
|
+
if (!minimal) return { cleanUrls };
|
|
29
|
+
cleanOpt = true;
|
|
30
|
+
}
|
|
31
|
+
if (!cleanOpt) return { cleanUrls };
|
|
32
|
+
const resolved = cleanOpt === true ? CLEAN_ALL : cleanOpt;
|
|
33
|
+
return {
|
|
34
|
+
cleanUrls: cleanUrls || resolved.urls === true,
|
|
35
|
+
clean: resolved
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function resolveFrontmatter(opt) {
|
|
39
|
+
if (typeof opt === "function") return {
|
|
40
|
+
config: {},
|
|
41
|
+
callback: opt
|
|
42
|
+
};
|
|
43
|
+
if (opt && typeof opt === "object") {
|
|
44
|
+
const { onExtract, ...config } = opt;
|
|
45
|
+
return {
|
|
46
|
+
config,
|
|
47
|
+
callback: onExtract
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return { config: {} };
|
|
51
|
+
}
|
|
52
|
+
function resolveOptions(options) {
|
|
53
|
+
if (Array.isArray(options.plugins)) throw new TypeError("Custom hook plugins require @mdream/js. Pass declarative config (e.g. { frontmatter: true }) to the Rust engine, or import { htmlToMarkdown } from '@mdream/js' for hook-based plugins. See https://mdream.dev/v1-migration#custom-plugins");
|
|
54
|
+
const minimal = options.minimal === true;
|
|
55
|
+
const plugins = options.plugins ? { ...options.plugins } : {};
|
|
56
|
+
let frontmatterCallback;
|
|
57
|
+
const frontmatterDisabled = options.frontmatter === false;
|
|
58
|
+
if (minimal ? !frontmatterDisabled : !!options.frontmatter) {
|
|
59
|
+
const fm = resolveFrontmatter(options.frontmatter);
|
|
60
|
+
plugins.frontmatter = fm.config;
|
|
61
|
+
frontmatterCallback = fm.callback;
|
|
62
|
+
} else if (frontmatterDisabled) delete plugins.frontmatter;
|
|
63
|
+
const isolateMainDisabled = options.isolateMain === false;
|
|
64
|
+
if (minimal ? !isolateMainDisabled : options.isolateMain) plugins.isolateMain = true;
|
|
65
|
+
else if (isolateMainDisabled) delete plugins.isolateMain;
|
|
66
|
+
const tailwindDisabled = options.tailwind === false;
|
|
67
|
+
if (minimal ? !tailwindDisabled : options.tailwind) plugins.tailwind = true;
|
|
68
|
+
else if (tailwindDisabled) delete plugins.tailwind;
|
|
69
|
+
if (options.filter === false) delete plugins.filter;
|
|
70
|
+
else if (minimal) plugins.filter = {
|
|
71
|
+
...options.filter,
|
|
72
|
+
exclude: [...MINIMAL_FILTER_EXCLUDE, ...options.filter?.exclude ?? []]
|
|
73
|
+
};
|
|
74
|
+
else if (options.filter) plugins.filter = options.filter;
|
|
75
|
+
const extraction = options.extraction;
|
|
76
|
+
let extractionHandlers;
|
|
77
|
+
if (extraction) {
|
|
78
|
+
plugins.extraction = { selectors: Object.keys(extraction) };
|
|
79
|
+
extractionHandlers = extraction;
|
|
80
|
+
}
|
|
81
|
+
const tagOverrides = options.tagOverrides;
|
|
82
|
+
if (tagOverrides) {
|
|
83
|
+
const overrides = {};
|
|
84
|
+
for (const tag in tagOverrides) {
|
|
85
|
+
const value = tagOverrides[tag];
|
|
86
|
+
if (value) overrides[tag] = typeof value === "string" ? { alias: value } : value;
|
|
87
|
+
}
|
|
88
|
+
plugins.tagOverrides = overrides;
|
|
89
|
+
}
|
|
90
|
+
const { cleanUrls, clean } = resolveCleanConfig(options, minimal);
|
|
91
|
+
return {
|
|
92
|
+
napiOpts: {
|
|
93
|
+
origin: options.origin,
|
|
94
|
+
cleanUrls,
|
|
95
|
+
clean,
|
|
96
|
+
plugins,
|
|
97
|
+
wrapWidth: options.wrapWidth,
|
|
98
|
+
format: options.format
|
|
99
|
+
},
|
|
100
|
+
extractionHandlers,
|
|
101
|
+
frontmatterCallback
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function deliverPluginData(data, { frontmatterCallback, extractionHandlers }) {
|
|
105
|
+
if (data.frontmatter && frontmatterCallback) frontmatterCallback(data.frontmatter);
|
|
106
|
+
if (data.extracted?.length && extractionHandlers) for (const element of data.extracted) extractionHandlers[element.selector]?.(element);
|
|
107
|
+
}
|
|
108
|
+
let _worker = null;
|
|
109
|
+
let _ready = null;
|
|
110
|
+
let _idCounter = 0;
|
|
111
|
+
const _pending = /* @__PURE__ */ new Map();
|
|
112
|
+
const WASM_RE = /\.wasm$/;
|
|
113
|
+
function getWorkerBlob(wasmUrl) {
|
|
114
|
+
const code = `
|
|
115
|
+
// namespace import: the URL is caller-supplied and may point at an older build
|
|
116
|
+
import init, * as engine from '${wasmUrl.replace(WASM_RE, ".js")}';
|
|
117
|
+
const { htmlToMarkdownResult } = engine;
|
|
118
|
+
|
|
119
|
+
let ready = false;
|
|
120
|
+
|
|
121
|
+
async function initialize() {
|
|
122
|
+
await init('${wasmUrl}');
|
|
123
|
+
ready = true;
|
|
124
|
+
self.postMessage({ type: 'ready' });
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
initialize().catch(e => {
|
|
128
|
+
self.postMessage({ type: 'error', id: -1, message: 'WASM init failed: ' + e.message });
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
self.onmessage = function(e) {
|
|
132
|
+
const msg = e.data;
|
|
133
|
+
if (msg.type === 'convert') {
|
|
134
|
+
if (!ready) {
|
|
135
|
+
self.postMessage({ id: msg.id, type: 'error', message: 'Worker not ready' });
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
try {
|
|
139
|
+
const result = htmlToMarkdownResult(msg.html, msg.options || {});
|
|
140
|
+
self.postMessage({ id: msg.id, type: 'result', data: result });
|
|
141
|
+
} catch (err) {
|
|
142
|
+
// WASM aborts on panic (#195): the message is stashed by the panic hook
|
|
143
|
+
const panic = engine.__mdreamTakePanicMessage?.();
|
|
144
|
+
self.postMessage({ id: msg.id, type: 'error', message: panic || err.message });
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
};`;
|
|
148
|
+
return new Blob([code], { type: "application/javascript" });
|
|
149
|
+
}
|
|
150
|
+
function onMessage(e) {
|
|
151
|
+
const msg = e.data;
|
|
152
|
+
if (msg.type === "ready") return;
|
|
153
|
+
if ("id" in msg) {
|
|
154
|
+
const pending = _pending.get(msg.id);
|
|
155
|
+
if (!pending) return;
|
|
156
|
+
_pending.delete(msg.id);
|
|
157
|
+
if (msg.type === "result") try {
|
|
158
|
+
deliverPluginData(msg.data, pending.callbacks);
|
|
159
|
+
pending.resolve(msg.data.markdown || "");
|
|
160
|
+
} catch (error) {
|
|
161
|
+
pending.reject(error);
|
|
162
|
+
}
|
|
163
|
+
else pending.reject(new Error(msg.message));
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function initWorker(wasmUrl) {
|
|
167
|
+
if (_ready) return _ready;
|
|
168
|
+
_ready = new Promise((resolve, reject) => {
|
|
169
|
+
const blob = getWorkerBlob(wasmUrl);
|
|
170
|
+
const url = URL.createObjectURL(blob);
|
|
171
|
+
_worker = new Worker(url, { type: "module" });
|
|
172
|
+
_worker.onmessage = (e) => {
|
|
173
|
+
if (e.data.type === "ready") {
|
|
174
|
+
_worker.onmessage = onMessage;
|
|
175
|
+
URL.revokeObjectURL(url);
|
|
176
|
+
resolve();
|
|
177
|
+
} else if (e.data.type === "error") reject(new Error(e.data.message));
|
|
178
|
+
};
|
|
179
|
+
_worker.onerror = (e) => {
|
|
180
|
+
reject(/* @__PURE__ */ new Error(`Worker error: ${e.message}`));
|
|
181
|
+
};
|
|
182
|
+
});
|
|
183
|
+
return _ready;
|
|
184
|
+
}
|
|
185
|
+
function htmlToMarkdown(html, options) {
|
|
186
|
+
if (!_worker || !_ready) return Promise.reject(/* @__PURE__ */ new Error("Call initWorker() before htmlToMarkdown()"));
|
|
187
|
+
return _ready.then(() => {
|
|
188
|
+
const { napiOpts, frontmatterCallback, extractionHandlers } = resolveOptions(options ?? {});
|
|
189
|
+
const id = _idCounter++;
|
|
190
|
+
return new Promise((resolve, reject) => {
|
|
191
|
+
_pending.set(id, {
|
|
192
|
+
resolve,
|
|
193
|
+
reject,
|
|
194
|
+
callbacks: {
|
|
195
|
+
frontmatterCallback,
|
|
196
|
+
extractionHandlers
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
_worker.postMessage({
|
|
200
|
+
id,
|
|
201
|
+
type: "convert",
|
|
202
|
+
html,
|
|
203
|
+
options: napiOpts
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
function terminateWorker() {
|
|
209
|
+
if (_worker) {
|
|
210
|
+
_worker.terminate();
|
|
211
|
+
_worker = null;
|
|
212
|
+
}
|
|
213
|
+
_ready = null;
|
|
214
|
+
for (const [, pending] of _pending) pending.reject(/* @__PURE__ */ new Error("Worker terminated"));
|
|
215
|
+
_pending.clear();
|
|
216
|
+
}
|
|
217
|
+
export { htmlToMarkdown, initWorker, terminateWorker };
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/* auto-generated by NAPI-RS */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Which binding artifact the generated loader actually loaded: `'native'` for
|
|
6
|
+
* a native addon, otherwise the `platformArchABI` of the WASI flavor. Every
|
|
7
|
+
* flavor napi-rs can build is listed, because `NAPI_RS_NATIVE_LIBRARY_PATH`
|
|
8
|
+
* can point the loader at a WASI artifact this package does not build itself.
|
|
9
|
+
*/
|
|
10
|
+
export declare const __napiBindingTarget: 'native' | 'wasm32-wasi' | 'wasm32-wasip1'
|
|
11
|
+
|
|
12
|
+
export declare class MarkdownStream {
|
|
13
|
+
constructor(options?: HtmlToMarkdownOptions | undefined | null)
|
|
14
|
+
processChunk(chunk: string): string
|
|
15
|
+
processChunkBytes(chunk: Uint8Array): string
|
|
16
|
+
finish(): string
|
|
17
|
+
/**
|
|
18
|
+
* Frontmatter and extracted elements collected so far. Call after
|
|
19
|
+
* `finish()` for the complete data. Extracted elements drain on each call.
|
|
20
|
+
*/
|
|
21
|
+
takeData(): MdreamStreamData
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface ChunkLocNapi {
|
|
25
|
+
from: number
|
|
26
|
+
to: number
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface ChunkMetadataNapi {
|
|
30
|
+
headers?: Record<string, string>
|
|
31
|
+
code?: string
|
|
32
|
+
loc?: ChunkLocNapi
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface CleanOptionsNapi {
|
|
36
|
+
urls?: boolean
|
|
37
|
+
fragments?: boolean
|
|
38
|
+
emptyLinks?: boolean
|
|
39
|
+
blankLines?: boolean
|
|
40
|
+
redundantLinks?: boolean
|
|
41
|
+
selfLinkHeadings?: boolean
|
|
42
|
+
emptyImages?: boolean
|
|
43
|
+
emptyLinkText?: boolean
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface ExtractedElementNapi {
|
|
47
|
+
selector: string
|
|
48
|
+
tagName: string
|
|
49
|
+
textContent: string
|
|
50
|
+
attributes: Record<string, string>
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface ExtractionOptions {
|
|
54
|
+
selectors: Array<string>
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface FilterOptions {
|
|
58
|
+
include?: Array<string>
|
|
59
|
+
exclude?: Array<string>
|
|
60
|
+
processChildren?: boolean
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface FrontmatterOptions {
|
|
64
|
+
additionalFields?: Record<string, string>
|
|
65
|
+
metaFields?: Array<string>
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export declare function htmlToMarkdown(html: string, options?: HtmlToMarkdownOptions | undefined | null): MdreamNapiResult
|
|
69
|
+
|
|
70
|
+
export declare function htmlToMarkdownBytes(html: Uint8Array, options?: HtmlToMarkdownOptions | undefined | null): MdreamNapiResult
|
|
71
|
+
|
|
72
|
+
export declare function htmlToMarkdownChunks(html: string, options?: HtmlToMarkdownOptions | undefined | null, splitterOptions?: SplitterOptionsNapi | undefined | null): Array<MarkdownChunkNapi>
|
|
73
|
+
|
|
74
|
+
export interface HtmlToMarkdownOptions {
|
|
75
|
+
origin?: string
|
|
76
|
+
cleanUrls?: boolean
|
|
77
|
+
clean?: CleanOptionsNapi
|
|
78
|
+
plugins?: PluginOptions
|
|
79
|
+
wrapWidth?: number
|
|
80
|
+
format?: "markdown" | "text" | "html"
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface MarkdownChunkNapi {
|
|
84
|
+
content: string
|
|
85
|
+
metadata: ChunkMetadataNapi
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface MdreamNapiResult {
|
|
89
|
+
markdown: string
|
|
90
|
+
extracted?: Array<ExtractedElementNapi>
|
|
91
|
+
frontmatter?: Record<string, string>
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Plugin data a stream collected: frontmatter and extracted elements. */
|
|
95
|
+
export interface MdreamStreamData {
|
|
96
|
+
extracted?: Array<ExtractedElementNapi>
|
|
97
|
+
frontmatter?: Record<string, string>
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface PluginOptions {
|
|
101
|
+
filter?: FilterOptions
|
|
102
|
+
isolateMain?: boolean
|
|
103
|
+
frontmatter?: FrontmatterOptions
|
|
104
|
+
tailwind?: boolean
|
|
105
|
+
extraction?: ExtractionOptions
|
|
106
|
+
tagOverrides?: Record<string, TagOverrideNapi>
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export declare function splitMarkdown(markdown: string, options?: SplitterOptionsNapi | undefined | null): Array<MarkdownChunkNapi>
|
|
110
|
+
|
|
111
|
+
export interface SplitterOptionsNapi {
|
|
112
|
+
headersToSplitOn?: Array<number>
|
|
113
|
+
returnEachLine?: boolean
|
|
114
|
+
stripHeaders?: boolean
|
|
115
|
+
chunkSize?: number
|
|
116
|
+
chunkOverlap?: number
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface TagOverrideNapi {
|
|
120
|
+
enter?: string
|
|
121
|
+
exit?: string
|
|
122
|
+
spacing?: Array<number>
|
|
123
|
+
isInline?: boolean
|
|
124
|
+
isSelfClosing?: boolean
|
|
125
|
+
collapsesInnerWhiteSpace?: boolean
|
|
126
|
+
alias?: string
|
|
127
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/* auto-generated by NAPI-RS */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Which binding artifact the generated loader actually loaded: `'native'` for
|
|
6
|
+
* a native addon, otherwise the `platformArchABI` of the WASI flavor. Every
|
|
7
|
+
* flavor napi-rs can build is listed, because `NAPI_RS_NATIVE_LIBRARY_PATH`
|
|
8
|
+
* can point the loader at a WASI artifact this package does not build itself.
|
|
9
|
+
*/
|
|
10
|
+
export declare const __napiBindingTarget: 'native' | 'wasm32-wasi' | 'wasm32-wasip1'
|
|
11
|
+
|
|
12
|
+
export declare class MarkdownStream {
|
|
13
|
+
constructor(options?: HtmlToMarkdownOptions | undefined | null)
|
|
14
|
+
processChunk(chunk: string): string
|
|
15
|
+
processChunkBytes(chunk: Uint8Array): string
|
|
16
|
+
finish(): string
|
|
17
|
+
/**
|
|
18
|
+
* Frontmatter and extracted elements collected so far. Call after
|
|
19
|
+
* `finish()` for the complete data. Extracted elements drain on each call.
|
|
20
|
+
*/
|
|
21
|
+
takeData(): MdreamStreamData
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface ChunkLocNapi {
|
|
25
|
+
from: number
|
|
26
|
+
to: number
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface ChunkMetadataNapi {
|
|
30
|
+
headers?: Record<string, string>
|
|
31
|
+
code?: string
|
|
32
|
+
loc?: ChunkLocNapi
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface CleanOptionsNapi {
|
|
36
|
+
urls?: boolean
|
|
37
|
+
fragments?: boolean
|
|
38
|
+
emptyLinks?: boolean
|
|
39
|
+
blankLines?: boolean
|
|
40
|
+
redundantLinks?: boolean
|
|
41
|
+
selfLinkHeadings?: boolean
|
|
42
|
+
emptyImages?: boolean
|
|
43
|
+
emptyLinkText?: boolean
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface ExtractedElementNapi {
|
|
47
|
+
selector: string
|
|
48
|
+
tagName: string
|
|
49
|
+
textContent: string
|
|
50
|
+
attributes: Record<string, string>
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface ExtractionOptions {
|
|
54
|
+
selectors: Array<string>
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface FilterOptions {
|
|
58
|
+
include?: Array<string>
|
|
59
|
+
exclude?: Array<string>
|
|
60
|
+
processChildren?: boolean
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface FrontmatterOptions {
|
|
64
|
+
additionalFields?: Record<string, string>
|
|
65
|
+
metaFields?: Array<string>
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export declare function htmlToMarkdown(html: string, options?: HtmlToMarkdownOptions | undefined | null): MdreamNapiResult
|
|
69
|
+
|
|
70
|
+
export declare function htmlToMarkdownBytes(html: Uint8Array, options?: HtmlToMarkdownOptions | undefined | null): MdreamNapiResult
|
|
71
|
+
|
|
72
|
+
export declare function htmlToMarkdownChunks(html: string, options?: HtmlToMarkdownOptions | undefined | null, splitterOptions?: SplitterOptionsNapi | undefined | null): Array<MarkdownChunkNapi>
|
|
73
|
+
|
|
74
|
+
export interface HtmlToMarkdownOptions {
|
|
75
|
+
origin?: string
|
|
76
|
+
cleanUrls?: boolean
|
|
77
|
+
clean?: CleanOptionsNapi
|
|
78
|
+
plugins?: PluginOptions
|
|
79
|
+
wrapWidth?: number
|
|
80
|
+
format?: "markdown" | "text" | "html"
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface MarkdownChunkNapi {
|
|
84
|
+
content: string
|
|
85
|
+
metadata: ChunkMetadataNapi
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface MdreamNapiResult {
|
|
89
|
+
markdown: string
|
|
90
|
+
extracted?: Array<ExtractedElementNapi>
|
|
91
|
+
frontmatter?: Record<string, string>
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Plugin data a stream collected: frontmatter and extracted elements. */
|
|
95
|
+
export interface MdreamStreamData {
|
|
96
|
+
extracted?: Array<ExtractedElementNapi>
|
|
97
|
+
frontmatter?: Record<string, string>
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface PluginOptions {
|
|
101
|
+
filter?: FilterOptions
|
|
102
|
+
isolateMain?: boolean
|
|
103
|
+
frontmatter?: FrontmatterOptions
|
|
104
|
+
tailwind?: boolean
|
|
105
|
+
extraction?: ExtractionOptions
|
|
106
|
+
tagOverrides?: Record<string, TagOverrideNapi>
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export declare function splitMarkdown(markdown: string, options?: SplitterOptionsNapi | undefined | null): Array<MarkdownChunkNapi>
|
|
110
|
+
|
|
111
|
+
export interface SplitterOptionsNapi {
|
|
112
|
+
headersToSplitOn?: Array<number>
|
|
113
|
+
returnEachLine?: boolean
|
|
114
|
+
stripHeaders?: boolean
|
|
115
|
+
chunkSize?: number
|
|
116
|
+
chunkOverlap?: number
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface TagOverrideNapi {
|
|
120
|
+
enter?: string
|
|
121
|
+
exit?: string
|
|
122
|
+
spacing?: Array<number>
|
|
123
|
+
isInline?: boolean
|
|
124
|
+
isSelfClosing?: boolean
|
|
125
|
+
collapsesInnerWhiteSpace?: boolean
|
|
126
|
+
alias?: string
|
|
127
|
+
}
|