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.
Files changed (206) hide show
  1. package/dist/chunks/agent-skills.mjs +1 -1
  2. package/dist/chunks/prerender.mjs +1 -1
  3. package/dist/cli.mjs +2 -0
  4. package/dist/module.json +1 -1
  5. package/dist/module.mjs +1 -1
  6. package/dist/runtime/server/db/drizzle/queries.js +0 -1
  7. package/dist/runtime/server/db/queries.d.ts +2 -0
  8. package/dist/runtime/server/db/queries.js +11 -5
  9. package/dist/runtime/server/db/seed.d.ts +2 -2
  10. package/dist/runtime/server/routes/__ai-ready/reindex.post.js +2 -0
  11. package/dist/runtime/server/utils/batchIndex.js +4 -2
  12. package/dist/runtime/server/utils/checkStale.d.ts +1 -1
  13. package/dist/runtime/server/utils/checkStale.js +1 -1
  14. package/dist/runtime/server/utils/indexPage.d.ts +8 -1
  15. package/dist/runtime/server/utils/indexPage.js +13 -5
  16. package/dist/shared/{nuxt-ai-ready.DsokNmXc.mjs → nuxt-ai-ready.CLSWou20.mjs} +2 -0
  17. package/node_modules/@mdream/js/LICENSE.md +9 -0
  18. package/node_modules/@mdream/js/README.md +792 -0
  19. package/node_modules/@mdream/js/bin/mdream.mjs +2 -0
  20. package/node_modules/@mdream/js/dist/_chunks/const.mjs +134 -0
  21. package/node_modules/@mdream/js/dist/_chunks/index.d.mts +9 -0
  22. package/node_modules/@mdream/js/dist/_chunks/markdown-processor.mjs +1968 -0
  23. package/node_modules/@mdream/js/dist/_chunks/minimal.d.mts +6 -0
  24. package/node_modules/@mdream/js/dist/_chunks/parse.mjs +2756 -0
  25. package/node_modules/@mdream/js/dist/_chunks/plugins.mjs +725 -0
  26. package/node_modules/@mdream/js/dist/_chunks/resolve-plugins.mjs +44 -0
  27. package/node_modules/@mdream/js/dist/_chunks/stream.mjs +37 -0
  28. package/node_modules/@mdream/js/dist/_chunks/types.d.mts +473 -0
  29. package/node_modules/@mdream/js/dist/cli.d.mts +1 -0
  30. package/node_modules/@mdream/js/dist/cli.mjs +32 -0
  31. package/node_modules/@mdream/js/dist/core.d.mts +15 -0
  32. package/node_modules/@mdream/js/dist/core.mjs +28 -0
  33. package/node_modules/@mdream/js/dist/index.d.mts +4 -0
  34. package/node_modules/@mdream/js/dist/index.mjs +58 -0
  35. package/node_modules/@mdream/js/dist/llms-txt.d.mts +86 -0
  36. package/node_modules/@mdream/js/dist/llms-txt.mjs +308 -0
  37. package/node_modules/@mdream/js/dist/negotiate.d.mts +35 -0
  38. package/node_modules/@mdream/js/dist/negotiate.mjs +121 -0
  39. package/node_modules/@mdream/js/dist/parse.d.mts +90 -0
  40. package/node_modules/@mdream/js/dist/parse.mjs +2 -0
  41. package/node_modules/@mdream/js/dist/plugins.d.mts +85 -0
  42. package/node_modules/@mdream/js/dist/plugins.mjs +2 -0
  43. package/node_modules/@mdream/js/dist/preset/minimal.d.mts +2 -0
  44. package/node_modules/@mdream/js/dist/preset/minimal.mjs +33 -0
  45. package/node_modules/@mdream/js/dist/splitter.d.mts +18 -0
  46. package/node_modules/@mdream/js/dist/splitter.mjs +194 -0
  47. package/node_modules/@mdream/js/package.json +103 -0
  48. package/node_modules/cac/LICENSE +21 -0
  49. package/node_modules/cac/README.md +492 -0
  50. package/node_modules/cac/dist/index.d.ts +196 -0
  51. package/node_modules/cac/dist/index.js +638 -0
  52. package/node_modules/cac/package.json +72 -0
  53. package/node_modules/mdream/LICENSE.md +9 -0
  54. package/node_modules/mdream/README.md +1091 -0
  55. package/node_modules/mdream/bin/mdream.mjs +46 -0
  56. package/node_modules/mdream/dist/browser.d.mts +105 -0
  57. package/node_modules/mdream/dist/browser.mjs +262 -0
  58. package/node_modules/mdream/dist/edge.d.mts +100 -0
  59. package/node_modules/mdream/dist/edge.mjs +250 -0
  60. package/node_modules/mdream/dist/iife.js +605 -0
  61. package/node_modules/mdream/dist/index.d.mts +89 -0
  62. package/node_modules/mdream/dist/index.mjs +184 -0
  63. package/node_modules/mdream/dist/wasm.d.mts +100 -0
  64. package/node_modules/mdream/dist/wasm.mjs +140 -0
  65. package/node_modules/mdream/dist/worker.d.mts +101 -0
  66. package/node_modules/mdream/dist/worker.mjs +217 -0
  67. package/node_modules/mdream/napi/index.d.mts +127 -0
  68. package/node_modules/mdream/napi/index.d.ts +127 -0
  69. package/node_modules/mdream/napi/index.mjs +725 -0
  70. package/node_modules/mdream/napi/rust.android-arm-eabi.node +0 -0
  71. package/node_modules/mdream/napi/rust.android-arm64.node +0 -0
  72. package/node_modules/mdream/napi/rust.darwin-arm64.node +0 -0
  73. package/node_modules/mdream/napi/rust.darwin-x64.node +0 -0
  74. package/node_modules/mdream/napi/rust.freebsd-x64.node +0 -0
  75. package/node_modules/mdream/napi/rust.linux-arm-gnueabihf.node +0 -0
  76. package/node_modules/mdream/napi/rust.linux-arm64-gnu.node +0 -0
  77. package/node_modules/mdream/napi/rust.linux-arm64-musl.node +0 -0
  78. package/node_modules/mdream/napi/rust.linux-x64-gnu.node +0 -0
  79. package/node_modules/mdream/napi/rust.linux-x64-musl.node +0 -0
  80. package/node_modules/mdream/napi/rust.wasi.cjs +2144 -0
  81. package/node_modules/mdream/napi/rust.wasm32-wasi.wasm +0 -0
  82. package/node_modules/mdream/napi/rust.win32-arm64-msvc.node +0 -0
  83. package/node_modules/mdream/napi/rust.win32-x64-msvc.node +0 -0
  84. package/node_modules/mdream/node_modules/@emnapi/core/LICENSE +21 -0
  85. package/node_modules/mdream/node_modules/@emnapi/core/README.md +1 -0
  86. package/node_modules/mdream/node_modules/@emnapi/core/dist/emnapi-core.d.ts +392 -0
  87. package/node_modules/mdream/node_modules/@emnapi/core/dist/emnapi-core.full.d.ts +392 -0
  88. package/node_modules/mdream/node_modules/@emnapi/core/dist/emnapi-core.full.js +8351 -0
  89. package/node_modules/mdream/node_modules/@emnapi/core/dist/emnapi-core.js +7268 -0
  90. package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/async-work.d.ts +5 -0
  91. package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/async-work.js +843 -0
  92. package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/index.d.ts +4 -0
  93. package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/index.js +3 -0
  94. package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/threadsafe-function.d.ts +5 -0
  95. package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/threadsafe-function.js +1010 -0
  96. package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/v8.d.ts +5 -0
  97. package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/v8.js +1446 -0
  98. package/node_modules/mdream/node_modules/@emnapi/core/package.json +39 -0
  99. package/node_modules/mdream/node_modules/@emnapi/core/rollup.config.js +60 -0
  100. package/node_modules/mdream/node_modules/@emnapi/runtime/LICENSE +21 -0
  101. package/node_modules/mdream/node_modules/@emnapi/runtime/README.md +1 -0
  102. package/node_modules/mdream/node_modules/@emnapi/runtime/dist/emnapi.d.ts +833 -0
  103. package/node_modules/mdream/node_modules/@emnapi/runtime/dist/emnapi.js +2306 -0
  104. package/node_modules/mdream/node_modules/@emnapi/runtime/dist/emnapi.js.map +1 -0
  105. package/node_modules/mdream/node_modules/@emnapi/runtime/index.cjs +63 -0
  106. package/node_modules/mdream/node_modules/@emnapi/runtime/package.json +39 -0
  107. package/node_modules/mdream/node_modules/@emnapi/runtime/rollup.config.js +25 -0
  108. package/node_modules/mdream/node_modules/@emnapi/wasi-threads/LICENSE +21 -0
  109. package/node_modules/mdream/node_modules/@emnapi/wasi-threads/README.md +203 -0
  110. package/node_modules/mdream/node_modules/@emnapi/wasi-threads/dist/wasi-threads.d.ts +236 -0
  111. package/node_modules/mdream/node_modules/@emnapi/wasi-threads/dist/wasi-threads.js +1086 -0
  112. package/node_modules/mdream/node_modules/@emnapi/wasi-threads/package.json +35 -0
  113. package/node_modules/mdream/node_modules/@emnapi/wasi-threads/rollup.config.js +6 -0
  114. package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/dist/emnapi-plugins.cjs +1472 -0
  115. package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/dist/emnapi-plugins.js +1470 -0
  116. package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/dist/fs-proxy.cjs +237 -0
  117. package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/dist/fs.js +18260 -0
  118. package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/fs-proxy.js +317 -0
  119. package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/package.json +67 -0
  120. package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/runtime.cjs +39 -0
  121. package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/runtime.js +36 -0
  122. package/node_modules/mdream/node_modules/@tybys/wasm-util/LICENSE +21 -0
  123. package/node_modules/mdream/node_modules/@tybys/wasm-util/README.md +193 -0
  124. package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/tsdoc-metadata.json +11 -0
  125. package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.d.ts +423 -0
  126. package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.esm-bundler.js +2932 -0
  127. package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.esm.js +2932 -0
  128. package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.esm.min.js +1 -0
  129. package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.js +2954 -0
  130. package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.min.js +1 -0
  131. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/asyncify.js +158 -0
  132. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/index.js +13 -0
  133. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/jspi.js +46 -0
  134. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/load.js +97 -0
  135. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/memory.js +35 -0
  136. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/error.js +103 -0
  137. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/fd.js +268 -0
  138. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/fs.js +3 -0
  139. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/index.js +192 -0
  140. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/path.js +316 -0
  141. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/preview1.js +1599 -0
  142. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/rights.js +141 -0
  143. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/types.js +220 -0
  144. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/util.js +128 -0
  145. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/webassembly.js +13 -0
  146. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/asyncify.mjs +153 -0
  147. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/index.mjs +9 -0
  148. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/jspi.mjs +39 -0
  149. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/load.mjs +89 -0
  150. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/memory.mjs +28 -0
  151. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/error.mjs +97 -0
  152. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/fd.mjs +256 -0
  153. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/fs.mjs +1 -0
  154. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/index.mjs +186 -0
  155. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/path.mjs +310 -0
  156. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/preview1.mjs +1593 -0
  157. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/rights.mjs +135 -0
  158. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/types.mjs +216 -0
  159. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/util.mjs +113 -0
  160. package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/webassembly.mjs +9 -0
  161. package/node_modules/mdream/node_modules/@tybys/wasm-util/package.json +58 -0
  162. package/node_modules/mdream/node_modules/tslib/CopyrightNotice.txt +15 -0
  163. package/node_modules/mdream/node_modules/tslib/LICENSE.txt +12 -0
  164. package/node_modules/mdream/node_modules/tslib/README.md +164 -0
  165. package/node_modules/mdream/node_modules/tslib/SECURITY.md +41 -0
  166. package/node_modules/mdream/node_modules/tslib/modules/index.d.ts +38 -0
  167. package/node_modules/mdream/node_modules/tslib/modules/index.js +70 -0
  168. package/node_modules/mdream/node_modules/tslib/modules/package.json +3 -0
  169. package/node_modules/mdream/node_modules/tslib/package.json +47 -0
  170. package/node_modules/mdream/node_modules/tslib/tslib.d.ts +460 -0
  171. package/node_modules/mdream/node_modules/tslib/tslib.es6.html +1 -0
  172. package/node_modules/mdream/node_modules/tslib/tslib.es6.js +402 -0
  173. package/node_modules/mdream/node_modules/tslib/tslib.es6.mjs +401 -0
  174. package/node_modules/mdream/node_modules/tslib/tslib.html +1 -0
  175. package/node_modules/mdream/node_modules/tslib/tslib.js +484 -0
  176. package/node_modules/mdream/package.json +110 -0
  177. package/node_modules/mdream/skills/mdream/SKILL.md +124 -0
  178. package/node_modules/mdream/skills/mdream/references/runtimes.md +49 -0
  179. package/node_modules/mdream/wasm/mdream_edge.d.ts +90 -0
  180. package/node_modules/mdream/wasm/mdream_edge.js +517 -0
  181. package/node_modules/mdream/wasm/mdream_edge_bg.wasm +0 -0
  182. package/node_modules/mdream/wasm/mdream_edge_bg.wasm.d.ts +20 -0
  183. package/node_modules/mdream/wasm/package.json +17 -0
  184. package/node_modules/mdream/wasm-bundler/mdream_edge.d.ts +45 -0
  185. package/node_modules/mdream/wasm-bundler/mdream_edge.js +13 -0
  186. package/node_modules/mdream/wasm-bundler/mdream_edge_bg.js +413 -0
  187. package/node_modules/mdream/wasm-bundler/mdream_edge_bg.wasm +0 -0
  188. package/node_modules/mdream/wasm-bundler/mdream_edge_bg.wasm.d.ts +20 -0
  189. package/node_modules/mdream/wasm-bundler/package.json +19 -0
  190. package/node_modules/pathe/LICENSE +70 -0
  191. package/node_modules/pathe/README.md +73 -0
  192. package/node_modules/pathe/dist/index.cjs +39 -0
  193. package/node_modules/pathe/dist/index.d.cts +47 -0
  194. package/node_modules/pathe/dist/index.d.mts +47 -0
  195. package/node_modules/pathe/dist/index.d.ts +47 -0
  196. package/node_modules/pathe/dist/index.mjs +19 -0
  197. package/node_modules/pathe/dist/shared/pathe.BSlhyZSM.cjs +266 -0
  198. package/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs +249 -0
  199. package/node_modules/pathe/dist/utils.cjs +82 -0
  200. package/node_modules/pathe/dist/utils.d.cts +32 -0
  201. package/node_modules/pathe/dist/utils.d.mts +32 -0
  202. package/node_modules/pathe/dist/utils.d.ts +32 -0
  203. package/node_modules/pathe/dist/utils.mjs +77 -0
  204. package/node_modules/pathe/package.json +61 -0
  205. package/node_modules/pathe/utils.d.ts +1 -0
  206. package/package.json +8 -64
@@ -0,0 +1,90 @@
1
+ import { ElementNode, Node, NodeEvent, TagHandler, TransformPlugin } from "./_chunks/types.mjs";
2
+ /**
3
+ * Commit end-of-input state: flush trailing buffered text and close any open
4
+ * elements. The streaming parser keeps trailing text and unclosed elements
5
+ * pending (a later chunk might continue them); at true EOF they must be
6
+ * committed so trailing content is not dropped (e.g. `<p>a<p>b`).
7
+ *
8
+ * `leftover` is the residual returned by the final `parseHtmlStream`. Trailing
9
+ * text is emitted; a residual that is an incomplete start tag is dropped,
10
+ * matching the browser tokenizer's EOF-in-tag behaviour. A leading `<` alone
11
+ * does not make it a tag: `<3` is text. The text-buffer flags set while the
12
+ * trailing text was scanned persist on `state`, so `processTextBuffer` commits
13
+ * it as if the next tag had triggered the flush.
14
+ */
15
+ export declare function finalizeParse(leftover: string, state: ParseState, handleEvent: (event: NodeEvent) => void): void;
16
+ export interface ParseOptions {
17
+ resolvedPlugins?: TransformPlugin[];
18
+ }
19
+ export interface ParseState {
20
+ /** Map of tag names to their current nesting depth - uses TypedArray for performance */
21
+ depthMap: Uint16Array;
22
+ /** Current overall nesting depth */
23
+ depth: number;
24
+ /** Root tag currently flattened beyond the rich element depth. */
25
+ flattenedTagName?: string;
26
+ /** Resolved built-in identity of the flattened root. */
27
+ flattenedTagId?: number;
28
+ /** Same-name nesting below the flattened root. */
29
+ flattenedTagDepth?: number;
30
+ /** Exact output-excluded scope nested inside the flattened subtree. */
31
+ flattenedOpaqueTagName?: string;
32
+ flattenedOpaqueDepth?: number;
33
+ /** Raw-text tag currently open inside the flattened subtree. */
34
+ flattenedRawTagName?: string;
35
+ /** Whether flattened raw text must be excluded from output. */
36
+ flattenedRawExcludesText?: boolean;
37
+ /** Currently processing element node */
38
+ currentNode?: ElementNode | null;
39
+ /** Whether current content contains HTML entities that need decoding */
40
+ hasEncodedHtmlEntity?: boolean;
41
+ /** Whether the last processed character was whitespace - for collapsing whitespace */
42
+ lastCharWasWhitespace?: boolean;
43
+ /** Whether the last processed buffer has whitespace - optimization flag */
44
+ textBufferContainsWhitespace?: boolean;
45
+ /** Whether the last processed buffer contains non-whitespace characters */
46
+ textBufferContainsNonWhitespace?: boolean;
47
+ /** Whether a tag was just closed - affects whitespace handling */
48
+ justClosedTag?: boolean;
49
+ /** Whether the next text node is the first in its element - for whitespace trimming */
50
+ isFirstTextInElement?: boolean;
51
+ /** Persisted HTML tokenizer state while streaming a built-in script body. */
52
+ scriptDataState?: number;
53
+ /** Consumed script chunks retained for extraction/plugin text events. */
54
+ scriptTextChunks?: string[];
55
+ /** Reference to the last processed text node - for context tracking */
56
+ lastTextNode?: Node;
57
+ /** @deprecated No longer read or written. Retained for source compatibility. */
58
+ inSingleQuote?: boolean;
59
+ /** @deprecated No longer read or written. Retained for source compatibility. */
60
+ inDoubleQuote?: boolean;
61
+ /** @deprecated No longer read or written. Retained for source compatibility. */
62
+ inBacktick?: boolean;
63
+ /** @deprecated Rawtext parsing is no longer quote-aware. Retained for source compatibility. */
64
+ inRawTextQuoteAware?: boolean;
65
+ /** @deprecated No longer read or written. Retained for source compatibility. */
66
+ lastCharWasBackslash?: boolean;
67
+ /** Resolved plugin instances for event processing */
68
+ resolvedPlugins?: TransformPlugin[];
69
+ /** Tag override handlers built from declarative tagOverrides config */
70
+ tagOverrideHandlers?: Map<string, TagHandler>;
71
+ /** Whether emitted text should skip Markdown-only escaping */
72
+ plainText?: boolean;
73
+ }
74
+ export interface ParseResult {
75
+ events: NodeEvent[];
76
+ remainingHtml: string;
77
+ }
78
+ /**
79
+ * Pure HTML parser that emits DOM events
80
+ * Completely decoupled from markdown generation
81
+ */
82
+ export declare function parseHtml(html: string, options?: ParseOptions): ParseResult;
83
+ /**
84
+ * Streaming HTML parser - calls onEvent for each DOM event
85
+ */
86
+ export declare function parseHtmlStream(html: string, state: ParseState, onEvent: (event: NodeEvent) => void): string;
87
+ /**
88
+ * Parse HTML attributes string into key-value object
89
+ */
90
+ export declare function parseAttributes(attrStr: string): Record<string, string>;
@@ -0,0 +1,2 @@
1
+ import { finalizeParse, parseAttributes, parseHtml, parseHtmlStream } from "./_chunks/parse.mjs";
2
+ export { finalizeParse, parseAttributes, parseHtml, parseHtmlStream };
@@ -0,0 +1,85 @@
1
+ import { ElementNode, ExtractedElement as ExtractedElement$1, MdreamRuntimeState, TransformPlugin } from "./_chunks/types.mjs";
2
+ import { createPlugin } from "./_chunks/index.mjs";
3
+ interface ExtractedElement extends ElementNode {
4
+ textContent: string;
5
+ }
6
+ type ExtractionCallback = (element: ExtractedElement, state: MdreamRuntimeState) => void;
7
+ /** Extract matching elements through the composable JavaScript plugin interface. */
8
+ export declare function extractionPlugin(selectors: Record<string, ExtractionCallback>): TransformPlugin;
9
+ /**
10
+ * Extraction collector for `plugins.extraction` config.
11
+ * Collects results during processing; callbacks are called post-conversion
12
+ * to match Rust engine behavior.
13
+ */
14
+ export declare function extractionCollectorPlugin(config: Record<string, (element: ExtractedElement$1) => void>): {
15
+ plugin: TransformPlugin;
16
+ getResults: () => ExtractedElement$1[];
17
+ callHandlers: () => void;
18
+ };
19
+ /**
20
+ * Plugin that filters nodes based on CSS selectors.
21
+ * Allows including or excluding nodes based on selectors.
22
+ *
23
+ * @example
24
+ * // Include only heading elements and their children
25
+ * withQuerySelectorPlugin({ include: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'] })
26
+ *
27
+ * @example
28
+ * // Exclude navigation, sidebar, and footer
29
+ * withQuerySelectorPlugin({ exclude: ['nav', '#sidebar', '.footer'] })
30
+ */
31
+ export declare function filterPlugin(options?: {
32
+ /** CSS selectors, tag names, or TAG_* constants for elements to include (all others will be excluded) */
33
+ include?: (string | number)[];
34
+ /** CSS selectors, tag names, or TAG_* constants for elements to exclude */
35
+ exclude?: (string | number)[];
36
+ /** Whether to also process the children of matching elements */
37
+ processChildren?: boolean;
38
+ keepAbsolute?: boolean;
39
+ }): TransformPlugin;
40
+ interface FrontmatterPluginOptions {
41
+ /** Additional frontmatter fields to include */
42
+ additionalFields?: Record<string, string>;
43
+ /** Meta tag names to extract (beyond the standard ones) */
44
+ metaFields?: string[];
45
+ }
46
+ /**
47
+ * A plugin that manages frontmatter generation from HTML head elements
48
+ * Extracts metadata from meta tags and title and generates YAML frontmatter
49
+ */
50
+ export declare function frontmatterPlugin(options?: FrontmatterPluginOptions): TransformPlugin;
51
+ /**
52
+ * Plugin that isolates main content using the following priority order:
53
+ * 1. If an explicit <main> element exists (within 5 depth levels), use its content exclusively
54
+ * 2. Otherwise, find content between the first header tag (h1-h6) and first footer
55
+ * 3. If footer is within 5 levels of nesting from the header, use it as the end boundary
56
+ * 4. Exclude all content before the start marker and after the end marker
57
+ *
58
+ * @example
59
+ * ```html
60
+ * <body>
61
+ * <nav>Navigation (excluded)</nav>
62
+ * <main>
63
+ * <h1>Main Title (included)</h1>
64
+ * <p>Main content (included)</p>
65
+ * </main>
66
+ * <footer>Footer (excluded)</footer>
67
+ * </body>
68
+ * ```
69
+ *
70
+ * @example
71
+ * ```html
72
+ * <body>
73
+ * <nav>Navigation (excluded)</nav>
74
+ * <h1>Main Title (included)</h1>
75
+ * <p>Main content (included)</p>
76
+ * <footer>Footer (excluded)</footer>
77
+ * </body>
78
+ * ```
79
+ */
80
+ export declare function isolateMainPlugin(): TransformPlugin;
81
+ /**
82
+ * Creates a plugin that adds Tailwind class processing
83
+ */
84
+ export declare function tailwindPlugin(): TransformPlugin;
85
+ export { type ExtractedElement, createPlugin };
@@ -0,0 +1,2 @@
1
+ import { createPlugin, extractionCollectorPlugin, extractionPlugin, filterPlugin, frontmatterPlugin, isolateMainPlugin, tailwindPlugin } from "./_chunks/plugins.mjs";
2
+ export { createPlugin, extractionCollectorPlugin, extractionPlugin, filterPlugin, frontmatterPlugin, isolateMainPlugin, tailwindPlugin };
@@ -0,0 +1,2 @@
1
+ import { withMinimalPreset } from "../_chunks/minimal.mjs";
2
+ export { withMinimalPreset };
@@ -0,0 +1,33 @@
1
+ import "../_chunks/const.mjs";
2
+ const MINIMAL_EXCLUDE = [
3
+ 40,
4
+ 68,
5
+ 103,
6
+ 58,
7
+ 47,
8
+ 88,
9
+ 73,
10
+ 59,
11
+ 66,
12
+ 65,
13
+ 43,
14
+ 41
15
+ ];
16
+ function withMinimalPreset(options = {}) {
17
+ const filter = options.plugins?.filter;
18
+ return {
19
+ clean: options.clean !== void 0 ? options.clean : true,
20
+ ...options,
21
+ plugins: {
22
+ frontmatter: true,
23
+ isolateMain: true,
24
+ tailwind: true,
25
+ ...options.plugins,
26
+ filter: filter === false ? false : {
27
+ ...filter,
28
+ exclude: [...MINIMAL_EXCLUDE, ...filter?.exclude ?? []]
29
+ }
30
+ }
31
+ };
32
+ }
33
+ export { withMinimalPreset };
@@ -0,0 +1,18 @@
1
+ import { MarkdownChunk, SplitterOptions } from "./_chunks/types.mjs";
2
+ /**
3
+ * Convert HTML to Markdown and split into chunks in single pass.
4
+ * Yields chunks during HTML event processing for better memory efficiency.
5
+ *
6
+ * **JavaScript engine only** — uses the JS engine's internal processing pipeline.
7
+ * Not compatible with the Rust engine.
8
+ */
9
+ export declare function htmlToMarkdownSplitChunksStream(html: string, options?: SplitterOptions): Generator<MarkdownChunk, void, undefined>;
10
+ /**
11
+ * Convert HTML to Markdown and split into chunks in single pass.
12
+ * Chunks are created during HTML event processing.
13
+ *
14
+ * **JavaScript engine only** — uses the JS engine's internal processing pipeline.
15
+ * Not compatible with the Rust engine.
16
+ */
17
+ export declare function htmlToMarkdownSplitChunks(html: string, options?: SplitterOptions): MarkdownChunk[];
18
+ export type { MarkdownChunk, SplitterOptions };
@@ -0,0 +1,194 @@
1
+ import "./_chunks/const.mjs";
2
+ import { parseHtmlStream } from "./_chunks/parse.mjs";
3
+ import { createMarkdownProcessor, processPluginsForEvent } from "./_chunks/markdown-processor.mjs";
4
+ import { resolvePlugins } from "./_chunks/resolve-plugins.mjs";
5
+ const MARKDOWN_HEADER_LINE_RE = /^#{1,6}\s+/;
6
+ const NEWLINE_RE = /\n/g;
7
+ const DEFAULT_HEADERS_TO_SPLIT_ON = [
8
+ 8,
9
+ 9,
10
+ 10,
11
+ 11,
12
+ 12
13
+ ];
14
+ function createOptions(options) {
15
+ return {
16
+ headersToSplitOn: options.headersToSplitOn ?? DEFAULT_HEADERS_TO_SPLIT_ON,
17
+ returnEachLine: options.returnEachLine ?? false,
18
+ stripHeaders: options.stripHeaders ?? true,
19
+ chunkSize: options.chunkSize ?? 1e3,
20
+ chunkOverlap: options.chunkOverlap ?? 200,
21
+ lengthFunction: options.lengthFunction ?? ((text) => text.length),
22
+ keepSeparator: options.keepSeparator ?? false,
23
+ resolvedPlugins: resolvePlugins(options).plugins
24
+ };
25
+ }
26
+ function shouldSplitOnHeader(tagId, options) {
27
+ return options.headersToSplitOn.includes(tagId);
28
+ }
29
+ function getCurrentMarkdown(state) {
30
+ return state.buffer.join("").trimStart();
31
+ }
32
+ function* htmlToMarkdownSplitChunksStream(html, options = {}) {
33
+ const opts = createOptions(options);
34
+ if (opts.chunkOverlap >= opts.chunkSize) throw new Error("chunkOverlap must be less than chunkSize");
35
+ let currentChunkCodeLanguage = "";
36
+ const processor = createMarkdownProcessor(options, opts.resolvedPlugins);
37
+ processor.state.onCodeFenceOpen = (language) => {
38
+ if (language && !currentChunkCodeLanguage) currentChunkCodeLanguage = language;
39
+ };
40
+ const headerHierarchy = /* @__PURE__ */ new Map();
41
+ const seenSplitHeaders = /* @__PURE__ */ new Set();
42
+ let collectingHeaderText = false;
43
+ let currentHeaderTagId = null;
44
+ let currentHeaderText = "";
45
+ let lineNumber = 1;
46
+ let lastChunkEndPosition = 0;
47
+ let lastSplitPosition = 0;
48
+ function* flushChunk(endPosition, applyOverlap = false) {
49
+ const currentMd = getCurrentMarkdown(processor.state);
50
+ const chunkEnd = endPosition ?? currentMd.length;
51
+ const originalChunkContent = currentMd.slice(lastChunkEndPosition, chunkEnd);
52
+ if (!originalChunkContent.trim()) {
53
+ lastChunkEndPosition = chunkEnd;
54
+ return;
55
+ }
56
+ let chunkContent = originalChunkContent;
57
+ if (opts.stripHeaders) {
58
+ chunkContent = chunkContent.split("\n").filter((line) => !MARKDOWN_HEADER_LINE_RE.test(line)).join("\n").trim();
59
+ if (!chunkContent) {
60
+ lastChunkEndPosition = chunkEnd;
61
+ return;
62
+ }
63
+ }
64
+ const chunk = {
65
+ content: chunkContent.trimEnd(),
66
+ metadata: { loc: { lines: {
67
+ from: lineNumber,
68
+ to: lineNumber + (originalChunkContent.match(NEWLINE_RE) || []).length
69
+ } } }
70
+ };
71
+ if (headerHierarchy.size > 0) {
72
+ chunk.metadata.headers = {};
73
+ for (const [tagId, text] of headerHierarchy.entries()) {
74
+ const level = `h${tagId - 7 + 1}`;
75
+ chunk.metadata.headers[level] = text;
76
+ }
77
+ }
78
+ if (currentChunkCodeLanguage) chunk.metadata.code = currentChunkCodeLanguage;
79
+ yield chunk;
80
+ currentChunkCodeLanguage = "";
81
+ lastSplitPosition = chunkEnd;
82
+ if (applyOverlap && opts.chunkOverlap > 0) {
83
+ const maxOverlap = Math.max(0, originalChunkContent.length - 1);
84
+ lastChunkEndPosition = chunkEnd - Math.min(opts.chunkOverlap, maxOverlap);
85
+ } else lastChunkEndPosition = chunkEnd;
86
+ lineNumber += (originalChunkContent.match(NEWLINE_RE) || []).length;
87
+ }
88
+ const parseState = {
89
+ depthMap: processor.state.depthMap,
90
+ depth: 0,
91
+ resolvedPlugins: opts.resolvedPlugins
92
+ };
93
+ const eventBuffer = [];
94
+ const processResolvedEvent = opts.resolvedPlugins?.length ? (event) => processPluginsForEvent(event, opts.resolvedPlugins, processor.state, processor.processEvent) : processor.processEvent;
95
+ parseHtmlStream(html, parseState, (event) => {
96
+ eventBuffer.push(event);
97
+ });
98
+ for (const event of eventBuffer) {
99
+ const { type: eventType, node } = event;
100
+ const eventDepthMap = node.type === 1 ? node.depthMap : node.parent?.depthMap;
101
+ if (eventDepthMap) processor.state.depthMap.set(eventDepthMap);
102
+ else processor.state.depthMap.fill(0);
103
+ if (eventType === 1 && node.type === 1) {
104
+ const tagId = node.tagId;
105
+ if (tagId !== void 0 && tagId >= 0 && tagId < processor.state.depthMap.length) processor.state.depthMap[tagId] = Math.max(0, processor.state.depthMap[tagId] - 1);
106
+ }
107
+ if (node.type === 1) {
108
+ const tagId = node.tagId;
109
+ if (tagId && tagId >= 7 && tagId <= 12) {
110
+ if (eventType === 0) {
111
+ collectingHeaderText = true;
112
+ currentHeaderTagId = tagId;
113
+ currentHeaderText = "";
114
+ if (shouldSplitOnHeader(tagId, opts)) {
115
+ if (seenSplitHeaders.has(tagId)) {
116
+ yield* flushChunk();
117
+ for (let i = tagId; i <= 12; i++) headerHierarchy.delete(i);
118
+ }
119
+ seenSplitHeaders.add(tagId);
120
+ }
121
+ } else if (eventType === 1 && currentHeaderTagId === tagId) {
122
+ headerHierarchy.set(tagId, currentHeaderText.trim());
123
+ collectingHeaderText = false;
124
+ currentHeaderTagId = null;
125
+ }
126
+ }
127
+ if (tagId === 13 && eventType === 0) yield* flushChunk();
128
+ }
129
+ if (collectingHeaderText && node.type === 2) currentHeaderText += node.value;
130
+ processResolvedEvent(event);
131
+ if (!opts.returnEachLine) {
132
+ const currentMd = getCurrentMarkdown(processor.state);
133
+ if (opts.lengthFunction(currentMd.slice(lastChunkEndPosition)) > opts.chunkSize) {
134
+ const idealSplitPos = lastChunkEndPosition + opts.chunkSize;
135
+ const separators = [
136
+ "\n\n",
137
+ "```\n",
138
+ "\n",
139
+ " "
140
+ ];
141
+ let splitPosition = -1;
142
+ for (const sep of separators) {
143
+ const idx = currentMd.lastIndexOf(sep, idealSplitPos);
144
+ const candidateSplitPos = idx + sep.length;
145
+ if (idx >= 0) {
146
+ const beforeSplit = currentMd.slice(0, candidateSplitPos);
147
+ let backtickCount = 0;
148
+ let pos = beforeSplit.indexOf("```", 0);
149
+ while (pos !== -1) {
150
+ backtickCount++;
151
+ pos = beforeSplit.indexOf("```", pos + 3);
152
+ }
153
+ if (backtickCount % 2 === 1) continue;
154
+ }
155
+ if (idx >= 0 && candidateSplitPos > lastSplitPosition) {
156
+ splitPosition = candidateSplitPos;
157
+ break;
158
+ }
159
+ }
160
+ if (splitPosition === -1 || splitPosition <= lastChunkEndPosition) splitPosition = currentMd.length;
161
+ yield* flushChunk(splitPosition, true);
162
+ }
163
+ }
164
+ }
165
+ yield* flushChunk();
166
+ }
167
+ function htmlToMarkdownSplitChunks(html, options = {}) {
168
+ const opts = createOptions(options);
169
+ const chunks = [];
170
+ for (const chunk of htmlToMarkdownSplitChunksStream(html, options)) chunks.push(chunk);
171
+ if (opts.returnEachLine && chunks.length > 0) {
172
+ const lineChunks = [];
173
+ for (const chunk of chunks) {
174
+ const lines = chunk.content.split("\n");
175
+ const chunkStartLine = chunk.metadata.loc?.lines.from || 1;
176
+ for (let i = 0; i < lines.length; i++) {
177
+ const line = lines[i];
178
+ if (line && line.trim()) lineChunks.push({
179
+ content: line,
180
+ metadata: {
181
+ ...chunk.metadata,
182
+ loc: { lines: {
183
+ from: chunkStartLine + i,
184
+ to: chunkStartLine + i
185
+ } }
186
+ }
187
+ });
188
+ }
189
+ }
190
+ return lineChunks;
191
+ }
192
+ return chunks;
193
+ }
194
+ export { htmlToMarkdownSplitChunks, htmlToMarkdownSplitChunksStream };
@@ -0,0 +1,103 @@
1
+ {
2
+ "name": "@mdream/js",
3
+ "type": "module",
4
+ "version": "2.0.0-beta.1",
5
+ "description": "JavaScript HTML-to-Markdown engine for mdream. Escape hatch for hooks and edge runtimes.",
6
+ "author": {
7
+ "name": "Harlan Wilton",
8
+ "email": "harlan@harlanzw.com",
9
+ "url": "https://harlanzw.com/"
10
+ },
11
+ "license": "MIT",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/harlan-zw/mdream",
15
+ "directory": "packages/js"
16
+ },
17
+ "sideEffects": false,
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.mts",
21
+ "import": {
22
+ "types": "./dist/index.d.mts",
23
+ "default": "./dist/index.mjs"
24
+ },
25
+ "default": "./dist/index.mjs"
26
+ },
27
+ "./core": {
28
+ "types": "./dist/core.d.mts",
29
+ "import": {
30
+ "types": "./dist/core.d.mts",
31
+ "default": "./dist/core.mjs"
32
+ },
33
+ "default": "./dist/core.mjs"
34
+ },
35
+ "./negotiate": {
36
+ "types": "./dist/negotiate.d.mts",
37
+ "import": {
38
+ "types": "./dist/negotiate.d.mts",
39
+ "default": "./dist/negotiate.mjs"
40
+ },
41
+ "default": "./dist/negotiate.mjs"
42
+ },
43
+ "./plugins": {
44
+ "types": "./dist/plugins.d.mts",
45
+ "import": {
46
+ "types": "./dist/plugins.d.mts",
47
+ "default": "./dist/plugins.mjs"
48
+ },
49
+ "default": "./dist/plugins.mjs"
50
+ },
51
+ "./preset/minimal": {
52
+ "types": "./dist/preset/minimal.d.mts",
53
+ "import": {
54
+ "types": "./dist/preset/minimal.d.mts",
55
+ "default": "./dist/preset/minimal.mjs"
56
+ },
57
+ "default": "./dist/preset/minimal.mjs"
58
+ },
59
+ "./splitter": {
60
+ "types": "./dist/splitter.d.mts",
61
+ "import": {
62
+ "types": "./dist/splitter.d.mts",
63
+ "default": "./dist/splitter.mjs"
64
+ },
65
+ "default": "./dist/splitter.mjs"
66
+ },
67
+ "./parse": {
68
+ "types": "./dist/parse.d.mts",
69
+ "import": {
70
+ "types": "./dist/parse.d.mts",
71
+ "default": "./dist/parse.mjs"
72
+ },
73
+ "default": "./dist/parse.mjs"
74
+ },
75
+ "./llms-txt": {
76
+ "types": "./dist/llms-txt.d.mts",
77
+ "import": {
78
+ "types": "./dist/llms-txt.d.mts",
79
+ "default": "./dist/llms-txt.mjs"
80
+ },
81
+ "default": "./dist/llms-txt.mjs"
82
+ }
83
+ },
84
+ "main": "./dist/index.mjs",
85
+ "types": "./dist/index.d.mts",
86
+ "bin": {
87
+ "mdream-js": "./bin/mdream.mjs"
88
+ },
89
+ "files": [
90
+ "bin",
91
+ "dist"
92
+ ],
93
+ "dependencies": {
94
+ "cac": "^7.0.0",
95
+ "pathe": "^2.0.3"
96
+ },
97
+ "scripts": {
98
+ "build": "obuild",
99
+ "typecheck": "tsc --noEmit",
100
+ "dev:prepare": "obuild --stub",
101
+ "test:attw": "attw --pack --profile esm-only"
102
+ }
103
+ }
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) EGOIST <0x142857@gmail.com> (https://github.com/egoist)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.