@toaq-oss/omni-mdx 0.1.22 → 0.1.24

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/client.cjs CHANGED
@@ -352,8 +352,31 @@ var MDXErrorBoundary = class extends import_react.Component {
352
352
  }
353
353
  };
354
354
 
355
- // src/MDXClientRenderer.tsx
355
+ // src/utils/basicStyles.tsx
356
356
  var import_jsx_runtime2 = require("react/jsx-runtime");
357
+ var BASIC_STYLES = {
358
+ h1: (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h1", { className: "text-3xl font-bold tracking-tight text-white mt-8 mb-4", ...props }),
359
+ h2: (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h2", { className: "text-2xl font-semibold tracking-tight text-neutral-100 mt-6 mb-3 border-b border-white/5 pb-2", ...props }),
360
+ h3: (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h3", { className: "text-xl font-medium text-neutral-200 mt-4 mb-2", ...props }),
361
+ h4: (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h4", { className: "text-lg font-medium text-neutral-300 mt-4 mb-2", ...props }),
362
+ p: (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "text-base leading-7 text-neutral-400 mb-4", ...props }),
363
+ ul: (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("ul", { className: "list-disc list-inside mb-4 space-y-1 text-neutral-400", ...props }),
364
+ ol: (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("ol", { className: "list-decimal list-inside mb-4 space-y-1 text-neutral-400", ...props }),
365
+ li: (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("li", { className: "ml-4", ...props }),
366
+ code: (props) => {
367
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("code", { className: "inline-code bg-white/10 px-1.5 py-0.5 rounded text-pink-400 font-mono text-sm", ...props });
368
+ },
369
+ blockquote: (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("blockquote", { className: "border-l-4 border-blue-500/50 pl-4 italic text-neutral-500 my-6", ...props }),
370
+ hr: () => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("hr", { className: "border-white/5 my-8" }),
371
+ table: (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "overflow-x-auto mb-6", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("table", { className: "w-full text-sm text-left border-collapse", ...props }) }),
372
+ th: (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("th", { className: "border-b border-white/10 p-2 font-semibold text-neutral-200", ...props }),
373
+ td: (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { className: "border-b border-white/5 p-2 text-neutral-400", ...props }),
374
+ img: (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("img", { className: "rounded-xl border border-white/10 my-8 mx-auto max-w-full h-auto", ...props }),
375
+ a: (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("a", { className: "text-blue-400 hover:text-blue-300 underline underline-offset-4 decoration-blue-500/30 transition-colors", ...props })
376
+ };
377
+
378
+ // src/MDXClientRenderer.tsx
379
+ var import_jsx_runtime3 = require("react/jsx-runtime");
357
380
  function resolveAttr(attr, components) {
358
381
  switch (attr.kind) {
359
382
  case "text":
@@ -373,7 +396,7 @@ function resolveAttr(attr, components) {
373
396
  return raw;
374
397
  }
375
398
  case "ast":
376
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(MDXClientContent, { ast: attr.value, components });
399
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(MDXClientContent, { ast: attr.value, components });
377
400
  default:
378
401
  return void 0;
379
402
  }
@@ -450,24 +473,24 @@ function renderNode(node, index, components) {
450
473
  const key = `${node.node_type}-${index}`;
451
474
  if (node.node_type === "text") return node.content ?? null;
452
475
  if (node.node_type === "fragment") {
453
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react2.default.Fragment, { children: node.children?.map((c, i) => renderNode(c, i, components)) }, key);
476
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react2.default.Fragment, { children: node.children?.map((c, i) => renderNode(c, i, components)) }, key);
454
477
  }
455
478
  if (node.node_type === "InlineMath") {
456
479
  const formula = extractText(node);
457
480
  try {
458
481
  const html = import_katex.default.renderToString(formula, { displayMode: false, throwOnError: false, output: "html" });
459
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "math math-inline", dangerouslySetInnerHTML: { __html: html } }, key);
482
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "math math-inline", dangerouslySetInnerHTML: { __html: html } }, key);
460
483
  } catch {
461
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "math math-inline", children: formula }, key);
484
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "math math-inline", children: formula }, key);
462
485
  }
463
486
  }
464
487
  if (node.node_type === "BlockMath") {
465
488
  const formula = extractText(node);
466
489
  try {
467
490
  const html = import_katex.default.renderToString(formula, { displayMode: true, throwOnError: false, output: "html" });
468
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "math math-display", dangerouslySetInnerHTML: { __html: html } }, key);
491
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "math math-display", dangerouslySetInnerHTML: { __html: html } }, key);
469
492
  } catch {
470
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "math math-display", children: formula }, key);
493
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "math math-display", children: formula }, key);
471
494
  }
472
495
  }
473
496
  const resolvedProps = {};
@@ -480,22 +503,22 @@ function renderNode(node, index, components) {
480
503
  const renderedChildren = node.children?.length ? node.children.map((c, i) => renderNode(c, i, components)) : node.content ?? void 0;
481
504
  const Custom = components[node.node_type];
482
505
  if (Custom) {
483
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(MDXErrorBoundary, { componentName: node.node_type, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Custom, { ...resolvedProps, children: renderedChildren }) }, key);
506
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(MDXErrorBoundary, { componentName: node.node_type, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Custom, { ...resolvedProps, children: renderedChildren }) }, key);
484
507
  }
485
508
  if (HTML_TAGS.has(node.node_type)) {
486
509
  const Tag = node.node_type;
487
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Tag, { ...resolvedProps, children: renderedChildren }, key);
510
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Tag, { ...resolvedProps, children: renderedChildren }, key);
488
511
  }
489
512
  if (true) {
490
513
  console.warn(`[toaq-oss/omni-mdx] Unknown component: <${node.node_type}>`);
491
514
  }
492
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { "data-missing-component": node.node_type, className: "mdx-missing-component", children: renderedChildren }, key);
515
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { "data-missing-component": node.node_type, className: "mdx-missing-component", children: renderedChildren }, key);
493
516
  }
494
517
  function MDXClientContent({
495
518
  ast,
496
519
  components
497
520
  }) {
498
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: ast.map((node, i) => renderNode(node, i, components)) });
521
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children: ast.map((node, i) => renderNode(node, i, components)) });
499
522
  }
500
523
  function MDXClientRenderer({
501
524
  ast,
@@ -503,7 +526,11 @@ function MDXClientRenderer({
503
526
  }) {
504
527
  const rootRef = (0, import_react2.useRef)(null);
505
528
  if (!ast || !Array.isArray(ast)) return null;
506
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "omni-mdx-root", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(MDXClientContent, { ast, components }) });
529
+ const finalComponents = {
530
+ ...BASIC_STYLES,
531
+ ...components
532
+ };
533
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "omni-mdx-root", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(MDXClientContent, { ast, components: finalComponents }) });
507
534
  }
508
535
 
509
536
  // src/utils/binaryDecoder.ts
@@ -1 +1 @@
1
- {"version":3,"sources":["../wasm/omni_mdx_core.js","../src/client.ts","../src/MDXClientRenderer.tsx","../src/MDXErrorBoundary.tsx","../src/utils/binaryDecoder.ts","../src/parse.client.ts"],"sourcesContent":["/* @ts-self-types=\"./omni_mdx_core.d.ts\" */\n\n/**\n * Compiles the raw MDX input into a minified JSON string representing the AST.\n *\n * This function is exposed directly to JavaScript via `wasm-bindgen`.\n * It returns a standard `JsError` if the parsing fails, ensuring that Node.js\n * or the browser can `try/catch` the error cleanly instead of encountering a WASM panic.\n * @param {string} input\n * @returns {string}\n */\nexport function parse_mdx_to_json(input) {\n let deferred3_0;\n let deferred3_1;\n try {\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.parse_mdx_to_json(ptr0, len0);\n var ptr2 = ret[0];\n var len2 = ret[1];\n if (ret[3]) {\n ptr2 = 0; len2 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred3_0 = ptr2;\n deferred3_1 = len2;\n return getStringFromWasm0(ptr2, len2);\n } finally {\n wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);\n }\n}\n\n/**\n * Compiles the raw MDX input into a pretty-printed JSON string.\n *\n * Useful for debugging, logging, or local development environments where\n * human-readable AST introspection is required.\n * @param {string} input\n * @returns {string}\n */\nexport function parse_mdx_to_json_pretty(input) {\n let deferred3_0;\n let deferred3_1;\n try {\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.parse_mdx_to_json_pretty(ptr0, len0);\n var ptr2 = ret[0];\n var len2 = ret[1];\n if (ret[3]) {\n ptr2 = 0; len2 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred3_0 = ptr2;\n deferred3_1 = len2;\n return getStringFromWasm0(ptr2, len2);\n } finally {\n wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);\n }\n}\n\n/**\n * Utility function exposed to JavaScript to fetch the compiled parser's version,\n * allowing the frontend package to verify WASM binary compatibility.\n * @returns {string}\n */\nexport function parse_mdx_version() {\n let deferred1_0;\n let deferred1_1;\n try {\n const ret = wasm.parse_mdx_version();\n deferred1_0 = ret[0];\n deferred1_1 = ret[1];\n return getStringFromWasm0(ret[0], ret[1]);\n } finally {\n wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);\n }\n}\n\n/**\n * @param {Uint8Array} mdx_input\n * @returns {Uint8Array}\n */\nexport function parse_to_binary(mdx_input) {\n const ptr0 = passArray8ToWasm0(mdx_input, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.parse_to_binary(ptr0, len0);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v2;\n}\n\nfunction __wbg_get_imports() {\n const import0 = {\n __proto__: null,\n __wbg_Error_83742b46f01ce22d: function(arg0, arg1) {\n const ret = Error(getStringFromWasm0(arg0, arg1));\n return ret;\n },\n __wbindgen_cast_0000000000000001: function(arg0, arg1) {\n // Cast intrinsic for `Ref(String) -> Externref`.\n const ret = getStringFromWasm0(arg0, arg1);\n return ret;\n },\n __wbindgen_init_externref_table: function() {\n const table = wasm.__wbindgen_externrefs;\n const offset = table.grow(4);\n table.set(0, undefined);\n table.set(offset + 0, undefined);\n table.set(offset + 1, null);\n table.set(offset + 2, true);\n table.set(offset + 3, false);\n },\n };\n return {\n __proto__: null,\n \"./omni_mdx_core_bg.js\": import0,\n };\n}\n\nfunction getArrayU8FromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);\n}\n\nfunction getStringFromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n return decodeText(ptr, len);\n}\n\nlet cachedUint8ArrayMemory0 = null;\nfunction getUint8ArrayMemory0() {\n if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {\n cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);\n }\n return cachedUint8ArrayMemory0;\n}\n\nfunction passArray8ToWasm0(arg, malloc) {\n const ptr = malloc(arg.length * 1, 1) >>> 0;\n getUint8ArrayMemory0().set(arg, ptr / 1);\n WASM_VECTOR_LEN = arg.length;\n return ptr;\n}\n\nfunction passStringToWasm0(arg, malloc, realloc) {\n if (realloc === undefined) {\n const buf = cachedTextEncoder.encode(arg);\n const ptr = malloc(buf.length, 1) >>> 0;\n getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);\n WASM_VECTOR_LEN = buf.length;\n return ptr;\n }\n\n let len = arg.length;\n let ptr = malloc(len, 1) >>> 0;\n\n const mem = getUint8ArrayMemory0();\n\n let offset = 0;\n\n for (; offset < len; offset++) {\n const code = arg.charCodeAt(offset);\n if (code > 0x7F) break;\n mem[ptr + offset] = code;\n }\n if (offset !== len) {\n if (offset !== 0) {\n arg = arg.slice(offset);\n }\n ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;\n const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);\n const ret = cachedTextEncoder.encodeInto(arg, view);\n\n offset += ret.written;\n ptr = realloc(ptr, len, offset, 1) >>> 0;\n }\n\n WASM_VECTOR_LEN = offset;\n return ptr;\n}\n\nfunction takeFromExternrefTable0(idx) {\n const value = wasm.__wbindgen_externrefs.get(idx);\n wasm.__externref_table_dealloc(idx);\n return value;\n}\n\nlet cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });\ncachedTextDecoder.decode();\nconst MAX_SAFARI_DECODE_BYTES = 2146435072;\nlet numBytesDecoded = 0;\nfunction decodeText(ptr, len) {\n numBytesDecoded += len;\n if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {\n cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });\n cachedTextDecoder.decode();\n numBytesDecoded = len;\n }\n return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));\n}\n\nconst cachedTextEncoder = new TextEncoder();\n\nif (!('encodeInto' in cachedTextEncoder)) {\n cachedTextEncoder.encodeInto = function (arg, view) {\n const buf = cachedTextEncoder.encode(arg);\n view.set(buf);\n return {\n read: arg.length,\n written: buf.length\n };\n };\n}\n\nlet WASM_VECTOR_LEN = 0;\n\nlet wasmModule, wasm;\nfunction __wbg_finalize_init(instance, module) {\n wasm = instance.exports;\n wasmModule = module;\n cachedUint8ArrayMemory0 = null;\n wasm.__wbindgen_start();\n return wasm;\n}\n\nasync function __wbg_load(module, imports) {\n if (typeof Response === 'function' && module instanceof Response) {\n if (typeof WebAssembly.instantiateStreaming === 'function') {\n try {\n return await WebAssembly.instantiateStreaming(module, imports);\n } catch (e) {\n const validResponse = module.ok && expectedResponseType(module.type);\n\n if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {\n console.warn(\"`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n\", e);\n\n } else { throw e; }\n }\n }\n\n const bytes = await module.arrayBuffer();\n return await WebAssembly.instantiate(bytes, imports);\n } else {\n const instance = await WebAssembly.instantiate(module, imports);\n\n if (instance instanceof WebAssembly.Instance) {\n return { instance, module };\n } else {\n return instance;\n }\n }\n\n function expectedResponseType(type) {\n switch (type) {\n case 'basic': case 'cors': case 'default': return true;\n }\n return false;\n }\n}\n\nfunction initSync(module) {\n if (wasm !== undefined) return wasm;\n\n\n if (module !== undefined) {\n if (Object.getPrototypeOf(module) === Object.prototype) {\n ({module} = module)\n } else {\n console.warn('using deprecated parameters for `initSync()`; pass a single object instead')\n }\n }\n\n const imports = __wbg_get_imports();\n if (!(module instanceof WebAssembly.Module)) {\n module = new WebAssembly.Module(module);\n }\n const instance = new WebAssembly.Instance(module, imports);\n return __wbg_finalize_init(instance, module);\n}\n\nasync function __wbg_init(module_or_path) {\n if (wasm !== undefined) return wasm;\n\n\n if (module_or_path !== undefined) {\n if (Object.getPrototypeOf(module_or_path) === Object.prototype) {\n ({module_or_path} = module_or_path)\n } else {\n console.warn('using deprecated parameters for the initialization function; pass a single object instead')\n }\n }\n\n if (module_or_path === undefined) {\n module_or_path = new URL('omni_mdx_core_bg.wasm', import.meta.url);\n }\n const imports = __wbg_get_imports();\n\n if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {\n module_or_path = fetch(module_or_path);\n }\n\n const { instance, module } = await __wbg_load(await module_or_path, imports);\n\n return __wbg_finalize_init(instance, module);\n}\n\nexport { initSync, __wbg_init as default };\n","\"use client\";\n\n/**\n * @toaq/omni-mdx/client\n *\n * Client-only entry point.\n * Use for live MDX editors, previews, or any fully client-side rendering.\n */\n\nexport { MDXClientRenderer } from \"./MDXClientRenderer\";\nexport { MDXErrorBoundary } from \"./MDXErrorBoundary\";\nexport { parseMdxClient as parseMdx } from \"./parse.client\";\nexport { MdxBinaryDecoder } from \"./utils/binaryDecoder\";\nexport type { AstNode, MDXComponents } from \"./types/MdxAST\";","\"use client\";\n\n/**\n * MDXClientRenderer.tsx\n *\n * Client Component — handles KaTeX hydration and interactive components.\n *\n * You generally do NOT use this directly.\n * Use <MDXServerRenderer> in Server Components and only register Client\n * Components (wrapped in \"use client\") for interactive parts (charts, tabs, etc.).\n *\n * Use this component ONLY when:\n * 1. You are in a page/layout that is entirely client-side (no RSC)\n * 2. You need live re-rendering (e.g. a live MDX editor/preview)\n *\n * For the live editor use case, import from '@toaq/omni-mdx/client'.\n */\n\nimport React, { ReactNode, useRef } from \"react\";\nimport katex from \"katex\";\nimport { MDXErrorBoundary } from \"./MDXErrorBoundary\";\nimport type { AstNode, MDXComponents } from \"./types/MdxAST\";\n\n\n\n// Attr resolver (client version handles expressions fully)\n\ntype AttrValueKind =\n | { kind: \"text\"; value: string }\n | { kind: \"expression\"; value: string }\n | { kind: \"boolean\" }\n | { kind: \"ast\"; value: AstNode[] };\n\nfunction resolveAttr(\n attr: AttrValueKind,\n components: MDXComponents,\n): React.ReactNode | string | boolean {\n switch (attr.kind) {\n case \"text\": return attr.value;\n case \"boolean\": return true;\n case \"expression\": {\n const raw = attr.value.trim();\n try { return JSON.parse(raw); } catch {}\n try { return new Function(`return (${raw})`)(); } catch {}\n return raw;\n }\n case \"ast\":\n return <MDXClientContent ast={attr.value} components={components} />;\n default:\n return undefined;\n }\n}\n\nfunction extractText(node: AstNode): string {\n if (node.node_type === \"text\") return node.content ?? \"\";\n if (node.content) return node.content;\n return (node.children ?? []).map(extractText).join(\"\");\n}\n\nconst HTML_TAGS = new Set([\n \"a\",\"abbr\",\"article\",\"aside\",\"b\",\"blockquote\",\"br\",\"caption\",\"cite\",\"code\",\n \"col\",\"colgroup\",\"dd\",\"del\",\"details\",\"dfn\",\"div\",\"dl\",\"dt\",\"em\",\"figcaption\",\n \"figure\",\"footer\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"header\",\"hr\",\"i\",\"img\",\"ins\",\n \"kbd\",\"li\",\"main\",\"mark\",\"nav\",\"ol\",\"p\",\"pre\",\"q\",\"s\",\"section\",\"small\",\"span\",\n \"strong\",\"sub\",\"summary\",\"sup\",\"table\",\"tbody\",\"td\",\"tfoot\",\"th\",\"thead\",\"tr\",\n \"u\",\"ul\",\"var\",\n]);\n\nfunction renderNode(\n node: AstNode,\n index: number,\n components: MDXComponents,\n): ReactNode {\n const key = `${node.node_type}-${index}`;\n\n if (node.node_type === \"text\") return node.content ?? null;\n\n if (node.node_type === \"fragment\") {\n return (\n <React.Fragment key={key}>\n {node.children?.map((c, i) => renderNode(c, i, components))}\n </React.Fragment>\n );\n }\n\n // Math — rendered directly via KaTeX (static import)\n if (node.node_type === \"InlineMath\") {\n const formula = extractText(node);\n try {\n const html = katex.renderToString(formula, { displayMode: false, throwOnError: false, output: \"html\" });\n return <span key={key} className=\"math math-inline\" dangerouslySetInnerHTML={{ __html: html }} />;\n } catch {\n return <span key={key} className=\"math math-inline\">{formula}</span>;\n }\n }\n if (node.node_type === \"BlockMath\") {\n const formula = extractText(node);\n try {\n const html = katex.renderToString(formula, { displayMode: true, throwOnError: false, output: \"html\" });\n return <div key={key} className=\"math math-display\" dangerouslySetInnerHTML={{ __html: html }} />;\n } catch {\n return <div key={key} className=\"math math-display\">{formula}</div>;\n }\n }\n\n const resolvedProps: Record<string, any> = {};\n if (node.attributes) {\n const attrs = typeof node.attributes === \"string\" \n ? JSON.parse(node.attributes) \n : node.attributes;\n\n for (const [k, v] of Object.entries(attrs)) {\n resolvedProps[k] = resolveAttr(v as AttrValueKind, components);\n }\n }\n\n const renderedChildren = node.children?.length\n ? node.children.map((c, i) => renderNode(c, i, components))\n : (node.content ?? undefined);\n\n const Custom = components[node.node_type];\n if (Custom) {\n return (\n <MDXErrorBoundary key={key} componentName={node.node_type}>\n <Custom {...resolvedProps}>\n {renderedChildren}\n </Custom>\n </MDXErrorBoundary>\n );\n }\n\n if (HTML_TAGS.has(node.node_type)) {\n const Tag = node.node_type as any;\n return <Tag key={key} {...resolvedProps}>{renderedChildren}</Tag>;\n }\n\n if (process.env.NODE_ENV === \"development\") {\n console.warn(`[toaq-oss/omni-mdx] Unknown component: <${node.node_type}>`);\n }\n return (\n <div key={key} data-missing-component={node.node_type} className=\"mdx-missing-component\">\n {renderedChildren}\n </div>\n );\n}\n\nfunction MDXClientContent({\n ast,\n components,\n}: {\n ast: AstNode[];\n components: MDXComponents;\n}) {\n return <>{ast.map((node, i) => renderNode(node, i, components))}</>;\n}\n\ninterface MDXClientRendererProps {\n /** AST from parseMdx() — must be JSON-serialisable (pass via Server Component). */\n ast: AstNode[];\n /** Component registry — same shape as MDX_COMPONENTS. */\n components?: MDXComponents;\n}\n\nexport function MDXClientRenderer({\n ast,\n components = {},\n}: MDXClientRendererProps) {\n const rootRef = useRef<HTMLDivElement>(null);\n\n if (!ast || !Array.isArray(ast)) return null;\n\n return (\n <div className=\"omni-mdx-root\">\n <MDXClientContent ast={ast} components={components} />\n </div>\n );\n}","\"use client\";\nimport { Component, ErrorInfo, ReactNode } from 'react';\n\ninterface Props {\n children: ReactNode;\n /** The name of the MDX component being rendered (e.g., 'Chart', 'SplitLayout') */\n componentName?: string;\n}\n\ninterface State {\n hasError: boolean;\n error: Error | null;\n}\n\n/**\n * A dedicated Error Boundary for MDX rendering.\n *\n * If a React component injected via MDX crashes (e.g., due to a data parsing error \n * inside a <Chart />), this boundary intercepts the error. This prevents the \n * entire React tree from unmounting and displays a clean fallback UI to \n * isolate the defective component.\n */\nexport class MDXErrorBoundary extends Component<Props, State> {\n constructor(props: Props) {\n super(props);\n this.state = { hasError: false, error: null };\n }\n\n /**\n * Updates the state when an error occurs to trigger the fallback UI rendering.\n */\n static getDerivedStateFromError(error: Error): State {\n return { hasError: true, error };\n }\n\n /**\n * Intercepts the error and its contextual information.\n * This is the ideal place to hook into monitoring tools (like Sentry or Datadog) \n * for production environments.\n */\n componentDidCatch(error: Error, errorInfo: ErrorInfo) {\n console.error(\n `[MDXErrorBoundary] Error caught in component <${this.props.componentName || 'Unknown'}>:\\n`,\n error,\n errorInfo.componentStack\n );\n }\n \n render() {\n if (this.state.hasError) {\n // Fallback UI: A clean, isolated container that doesn't break the main layout\n return (\n <div style={{ padding: '1rem', border: '2px solid #ef4444', backgroundColor: '#fef2f2', borderRadius: '0.5rem', margin: '1rem 0' }}>\n <h3 style={{ color: '#b91c1c', fontWeight: 'bold', margin: 0 }}>\n Render Error : {this.props.componentName || 'Unknown Component'}\n </h3>\n <p style={{ color: '#dc2626', fontFamily: 'monospace', fontSize: '0.875rem' }}>\n {this.state.error?.message}\n </p>\n </div>\n );\n }\n return this.props.children;\n }\n}","import type { AstNode, AttrValueKind } from \"../types/MdxAST\";\n\nconst NODE_TEXT = 0x01;\nconst NODE_ELEMENT = 0x02;\n\nconst ATTR_TEXT = 0x10;\nconst ATTR_EXPRESSION = 0x11;\nconst ATTR_BOOLEAN = 0x12;\nconst ATTR_AST = 0x13;\n\nexport class MdxBinaryDecoder {\n private view: DataView;\n private buffer: Uint8Array;\n private offset: number = 0;\n private decoder = new TextDecoder(\"utf-8\");\n private stringCache = new Map<string, string>();\n\n constructor(buffer: Uint8Array) {\n this.buffer = buffer;\n this.view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);\n }\n\n public decode(): AstNode[] {\n const rootCount = this.readU32();\n const nodes: AstNode[] = [];\n for (let i = 0; i < rootCount; i++) {\n nodes.push(this.decodeNode());\n }\n return nodes;\n }\n\n private decodeNode(): AstNode {\n const type = this.readU8();\n\n if (type === NODE_TEXT) {\n return {\n node_type: \"text\",\n content: this.readStringU32(),\n };\n }\n\n if (type === NODE_ELEMENT) {\n const node_type = this.readStringU16();\n const self_closing = this.readU8() === 1;\n const attrCount = this.readU16();\n \n let attributes: Record<string, AttrValueKind> | undefined = undefined;\n \n if (attrCount > 0) {\n attributes = {};\n for (let i = 0; i < attrCount; i++) {\n const key = this.readStringU16();\n const attrKind = this.readU8();\n \n if (attrKind === ATTR_TEXT) {\n attributes[key] = { kind: \"text\", value: this.readStringU32() };\n } else if (attrKind === ATTR_EXPRESSION) {\n attributes[key] = { kind: \"expression\", value: this.readStringU32() };\n } else if (attrKind === ATTR_BOOLEAN) {\n attributes[key] = { kind: \"boolean\" };\n } else if (attrKind === ATTR_AST) {\n const subNodeCount = this.readU32();\n const subNodes: AstNode[] = [];\n for (let j = 0; j < subNodeCount; j++) {\n subNodes.push(this.decodeNode());\n }\n attributes[key] = { kind: \"ast\", value: subNodes };\n }\n }\n }\n\n const childCount = this.readU32();\n const children: AstNode[] = [];\n if (childCount > 0) {\n for (let i = 0; i < childCount; i++) {\n children.push(this.decodeNode());\n }\n }\n\n return {\n node_type,\n self_closing,\n attributes,\n children,\n };\n }\n\n throw new Error(`[@toaq-oss/omni-mdx] Unknown binary opcode: ${type} at offset ${this.offset}`);\n }\n\n private readU8(): number {\n const val = this.view.getUint8(this.offset);\n this.offset += 1;\n return val;\n }\n\n private readU16(): number {\n const val = this.view.getUint16(this.offset, true);\n this.offset += 2;\n return val;\n }\n\n private readU32(): number {\n const val = this.view.getUint32(this.offset, true);\n this.offset += 4;\n return val;\n }\n\n private readStringU16(): string {\n const len = this.readU16();\n const str = this.decoder.decode(this.buffer.subarray(this.offset, this.offset + len));\n this.offset += len;\n\n let cached = this.stringCache.get(str);\n if (cached) return cached;\n this.stringCache.set(str, str);\n return str;\n }\n\n private readStringU32(): string {\n const len = this.readU32();\n const str = this.decoder.decode(this.buffer.subarray(this.offset, this.offset + len));\n this.offset += len;\n return str;\n }\n}","// parse.client.ts\n//\n// Client-side MDX parser using WASM (--target web build).\n// Designed for live editors and fully client-side rendering contexts.\n// Never runs on the server — returns [] immediately if called server-side.\n\nimport type { AstNode } from \"./types/MdxAST\";\nimport { MdxBinaryDecoder } from \"./utils/binaryDecoder\";\n\nlet initPromise: Promise<(mdx: Uint8Array) => Uint8Array> | null = null;\n\nfunction getClientParser(): Promise<(mdx: Uint8Array) => Uint8Array> {\n if (!initPromise) {\n initPromise = (async () => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const wasm: any = await import(\"../wasm/omni_mdx_core.js\");\n\n if (typeof wasm.default === \"function\") {\n const wasmUrl = new URL(\"./omni_mdx_core_bg.wasm\", import.meta.url);\n await wasm.default(wasmUrl);\n }\n\n return (mdx: Uint8Array): Uint8Array => wasm.parse_to_binary(mdx);\n })();\n }\n return initPromise;\n}\n\nfunction normalizeToUint8Array(input: any): Uint8Array {\n if (input instanceof Uint8Array) {\n return input;\n }\n if (typeof input === \"string\") {\n return new TextEncoder().encode(input);\n }\n if (input && typeof input === 'object' && input.type === 'Buffer' && Array.isArray(input.data)) {\n return new Uint8Array(input.data);\n }\n return new TextEncoder().encode(String(input));\n}\n\nexport async function parseMdxClient(mdx: string | Uint8Array): Promise<AstNode[]> {\n if (typeof window === \"undefined\") return [];\n\n try {\n const parse = await getClientParser();\n const inputBuffer = normalizeToUint8Array(mdx);\n const binaryAst = parse(inputBuffer);\n const decoder = new MdxBinaryDecoder(binaryAst);\n return decoder.decode();\n } catch (err) {\n const errorMessage = err instanceof Error ? err.message : String(err);\n \n throw new Error(`Syntax error in MDX: ${errorMessage}`);\n }\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWO,SAAS,kBAAkB,OAAO;AACrC,MAAI;AACJ,MAAI;AACJ,MAAI;AACA,UAAM,OAAO,kBAAkB,OAAO,KAAK,mBAAmB,KAAK,kBAAkB;AACrF,UAAM,OAAO;AACb,UAAM,MAAM,KAAK,kBAAkB,MAAM,IAAI;AAC7C,QAAI,OAAO,IAAI,CAAC;AAChB,QAAI,OAAO,IAAI,CAAC;AAChB,QAAI,IAAI,CAAC,GAAG;AACR,aAAO;AAAG,aAAO;AACjB,YAAM,wBAAwB,IAAI,CAAC,CAAC;AAAA,IACxC;AACA,kBAAc;AACd,kBAAc;AACd,WAAO,mBAAmB,MAAM,IAAI;AAAA,EACxC,UAAE;AACE,SAAK,gBAAgB,aAAa,aAAa,CAAC;AAAA,EACpD;AACJ;AAUO,SAAS,yBAAyB,OAAO;AAC5C,MAAI;AACJ,MAAI;AACJ,MAAI;AACA,UAAM,OAAO,kBAAkB,OAAO,KAAK,mBAAmB,KAAK,kBAAkB;AACrF,UAAM,OAAO;AACb,UAAM,MAAM,KAAK,yBAAyB,MAAM,IAAI;AACpD,QAAI,OAAO,IAAI,CAAC;AACh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A,MAAK,gBAAgB,GAAG;AAAA,IAClE,GAAG;AAAA,EACL;AACA,SAAO;AACT;AAEA,SAAS,sBAAsB,OAAwB;AACrD,MAAI,iBAAiB,YAAY;AAC/B,WAAO;AAAA,EACT;AACA,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO,IAAI,YAAY,EAAE,OAAO,KAAK;AAAA,EACvC;AACA,MAAI,SAAS,OAAO,UAAU,YAAY,MAAM,SAAS,YAAY,MAAM,QAAQ,MAAM,IAAI,GAAG;AAC9F,WAAO,IAAI,WAAW,MAAM,IAAI;AAAA,EAClC;AACA,SAAO,IAAI,YAAY,EAAE,OAAO,OAAO,KAAK,CAAC;AAC/C;AAEA,eAAsB,eAAe,KAA8C;AACjF,MAAI,OAAO,WAAW,YAAa,QAAO,CAAC;AAE3C,MAAI;AACF,UAAM,QAAQ,MAAM,gBAAgB;AACpC,UAAM,cAAc,sBAAsB,GAAG;AAC7C,UAAM,YAAY,MAAM,WAAW;AACnC,UAAM,UAAU,IAAI,iBAAiB,SAAS;AAC9C,WAAO,QAAQ,OAAO;AAAA,EACxB,SAAS,KAAK;AACZ,UAAM,eAAe,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAEpE,UAAM,IAAI,MAAM,wBAAwB,YAAY,EAAE;AAAA,EACxD;AACF;","names":["ptr","module","import_react","import_jsx_runtime","React","katex","import_meta","wasm"]}
1
+ {"version":3,"sources":["../wasm/omni_mdx_core.js","../src/client.ts","../src/MDXClientRenderer.tsx","../src/MDXErrorBoundary.tsx","../src/utils/basicStyles.tsx","../src/utils/binaryDecoder.ts","../src/parse.client.ts"],"sourcesContent":["/* @ts-self-types=\"./omni_mdx_core.d.ts\" */\n\n/**\n * Compiles the raw MDX input into a minified JSON string representing the AST.\n *\n * This function is exposed directly to JavaScript via `wasm-bindgen`.\n * It returns a standard `JsError` if the parsing fails, ensuring that Node.js\n * or the browser can `try/catch` the error cleanly instead of encountering a WASM panic.\n * @param {string} input\n * @returns {string}\n */\nexport function parse_mdx_to_json(input) {\n let deferred3_0;\n let deferred3_1;\n try {\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.parse_mdx_to_json(ptr0, len0);\n var ptr2 = ret[0];\n var len2 = ret[1];\n if (ret[3]) {\n ptr2 = 0; len2 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred3_0 = ptr2;\n deferred3_1 = len2;\n return getStringFromWasm0(ptr2, len2);\n } finally {\n wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);\n }\n}\n\n/**\n * Compiles the raw MDX input into a pretty-printed JSON string.\n *\n * Useful for debugging, logging, or local development environments where\n * human-readable AST introspection is required.\n * @param {string} input\n * @returns {string}\n */\nexport function parse_mdx_to_json_pretty(input) {\n let deferred3_0;\n let deferred3_1;\n try {\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.parse_mdx_to_json_pretty(ptr0, len0);\n var ptr2 = ret[0];\n var len2 = ret[1];\n if (ret[3]) {\n ptr2 = 0; len2 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred3_0 = ptr2;\n deferred3_1 = len2;\n return getStringFromWasm0(ptr2, len2);\n } finally {\n wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);\n }\n}\n\n/**\n * Utility function exposed to JavaScript to fetch the compiled parser's version,\n * allowing the frontend package to verify WASM binary compatibility.\n * @returns {string}\n */\nexport function parse_mdx_version() {\n let deferred1_0;\n let deferred1_1;\n try {\n const ret = wasm.parse_mdx_version();\n deferred1_0 = ret[0];\n deferred1_1 = ret[1];\n return getStringFromWasm0(ret[0], ret[1]);\n } finally {\n wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);\n }\n}\n\n/**\n * @param {Uint8Array} mdx_input\n * @returns {Uint8Array}\n */\nexport function parse_to_binary(mdx_input) {\n const ptr0 = passArray8ToWasm0(mdx_input, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.parse_to_binary(ptr0, len0);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v2;\n}\n\nfunction __wbg_get_imports() {\n const import0 = {\n __proto__: null,\n __wbg_Error_83742b46f01ce22d: function(arg0, arg1) {\n const ret = Error(getStringFromWasm0(arg0, arg1));\n return ret;\n },\n __wbindgen_cast_0000000000000001: function(arg0, arg1) {\n // Cast intrinsic for `Ref(String) -> Externref`.\n const ret = getStringFromWasm0(arg0, arg1);\n return ret;\n },\n __wbindgen_init_externref_table: function() {\n const table = wasm.__wbindgen_externrefs;\n const offset = table.grow(4);\n table.set(0, undefined);\n table.set(offset + 0, undefined);\n table.set(offset + 1, null);\n table.set(offset + 2, true);\n table.set(offset + 3, false);\n },\n };\n return {\n __proto__: null,\n \"./omni_mdx_core_bg.js\": import0,\n };\n}\n\nfunction getArrayU8FromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);\n}\n\nfunction getStringFromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n return decodeText(ptr, len);\n}\n\nlet cachedUint8ArrayMemory0 = null;\nfunction getUint8ArrayMemory0() {\n if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {\n cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);\n }\n return cachedUint8ArrayMemory0;\n}\n\nfunction passArray8ToWasm0(arg, malloc) {\n const ptr = malloc(arg.length * 1, 1) >>> 0;\n getUint8ArrayMemory0().set(arg, ptr / 1);\n WASM_VECTOR_LEN = arg.length;\n return ptr;\n}\n\nfunction passStringToWasm0(arg, malloc, realloc) {\n if (realloc === undefined) {\n const buf = cachedTextEncoder.encode(arg);\n const ptr = malloc(buf.length, 1) >>> 0;\n getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);\n WASM_VECTOR_LEN = buf.length;\n return ptr;\n }\n\n let len = arg.length;\n let ptr = malloc(len, 1) >>> 0;\n\n const mem = getUint8ArrayMemory0();\n\n let offset = 0;\n\n for (; offset < len; offset++) {\n const code = arg.charCodeAt(offset);\n if (code > 0x7F) break;\n mem[ptr + offset] = code;\n }\n if (offset !== len) {\n if (offset !== 0) {\n arg = arg.slice(offset);\n }\n ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;\n const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);\n const ret = cachedTextEncoder.encodeInto(arg, view);\n\n offset += ret.written;\n ptr = realloc(ptr, len, offset, 1) >>> 0;\n }\n\n WASM_VECTOR_LEN = offset;\n return ptr;\n}\n\nfunction takeFromExternrefTable0(idx) {\n const value = wasm.__wbindgen_externrefs.get(idx);\n wasm.__externref_table_dealloc(idx);\n return value;\n}\n\nlet cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });\ncachedTextDecoder.decode();\nconst MAX_SAFARI_DECODE_BYTES = 2146435072;\nlet numBytesDecoded = 0;\nfunction decodeText(ptr, len) {\n numBytesDecoded += len;\n if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {\n cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });\n cachedTextDecoder.decode();\n numBytesDecoded = len;\n }\n return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));\n}\n\nconst cachedTextEncoder = new TextEncoder();\n\nif (!('encodeInto' in cachedTextEncoder)) {\n cachedTextEncoder.encodeInto = function (arg, view) {\n const buf = cachedTextEncoder.encode(arg);\n view.set(buf);\n return {\n read: arg.length,\n written: buf.length\n };\n };\n}\n\nlet WASM_VECTOR_LEN = 0;\n\nlet wasmModule, wasm;\nfunction __wbg_finalize_init(instance, module) {\n wasm = instance.exports;\n wasmModule = module;\n cachedUint8ArrayMemory0 = null;\n wasm.__wbindgen_start();\n return wasm;\n}\n\nasync function __wbg_load(module, imports) {\n if (typeof Response === 'function' && module instanceof Response) {\n if (typeof WebAssembly.instantiateStreaming === 'function') {\n try {\n return await WebAssembly.instantiateStreaming(module, imports);\n } catch (e) {\n const validResponse = module.ok && expectedResponseType(module.type);\n\n if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {\n console.warn(\"`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n\", e);\n\n } else { throw e; }\n }\n }\n\n const bytes = await module.arrayBuffer();\n return await WebAssembly.instantiate(bytes, imports);\n } else {\n const instance = await WebAssembly.instantiate(module, imports);\n\n if (instance instanceof WebAssembly.Instance) {\n return { instance, module };\n } else {\n return instance;\n }\n }\n\n function expectedResponseType(type) {\n switch (type) {\n case 'basic': case 'cors': case 'default': return true;\n }\n return false;\n }\n}\n\nfunction initSync(module) {\n if (wasm !== undefined) return wasm;\n\n\n if (module !== undefined) {\n if (Object.getPrototypeOf(module) === Object.prototype) {\n ({module} = module)\n } else {\n console.warn('using deprecated parameters for `initSync()`; pass a single object instead')\n }\n }\n\n const imports = __wbg_get_imports();\n if (!(module instanceof WebAssembly.Module)) {\n module = new WebAssembly.Module(module);\n }\n const instance = new WebAssembly.Instance(module, imports);\n return __wbg_finalize_init(instance, module);\n}\n\nasync function __wbg_init(module_or_path) {\n if (wasm !== undefined) return wasm;\n\n\n if (module_or_path !== undefined) {\n if (Object.getPrototypeOf(module_or_path) === Object.prototype) {\n ({module_or_path} = module_or_path)\n } else {\n console.warn('using deprecated parameters for the initialization function; pass a single object instead')\n }\n }\n\n if (module_or_path === undefined) {\n module_or_path = new URL('omni_mdx_core_bg.wasm', import.meta.url);\n }\n const imports = __wbg_get_imports();\n\n if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {\n module_or_path = fetch(module_or_path);\n }\n\n const { instance, module } = await __wbg_load(await module_or_path, imports);\n\n return __wbg_finalize_init(instance, module);\n}\n\nexport { initSync, __wbg_init as default };\n","\"use client\";\n\n/**\n * @toaq/omni-mdx/client\n *\n * Client-only entry point.\n * Use for live MDX editors, previews, or any fully client-side rendering.\n */\n\nexport { MDXClientRenderer } from \"./MDXClientRenderer\";\nexport { MDXErrorBoundary } from \"./MDXErrorBoundary\";\nexport { parseMdxClient as parseMdx } from \"./parse.client\";\nexport { MdxBinaryDecoder } from \"./utils/binaryDecoder\";\nexport type { AstNode, MDXComponents } from \"./types/MdxAST\";","\"use client\";\n\n/**\n * MDXClientRenderer.tsx\n *\n * Client Component — handles KaTeX hydration and interactive components.\n *\n * You generally do NOT use this directly.\n * Use <MDXServerRenderer> in Server Components and only register Client\n * Components (wrapped in \"use client\") for interactive parts (charts, tabs, etc.).\n *\n * Use this component ONLY when:\n * 1. You are in a page/layout that is entirely client-side (no RSC)\n * 2. You need live re-rendering (e.g. a live MDX editor/preview)\n *\n * For the live editor use case, import from '@toaq/omni-mdx/client'.\n */\n\nimport React, { ReactNode, useRef } from \"react\";\nimport katex from \"katex\";\nimport { MDXErrorBoundary } from \"./MDXErrorBoundary\";\nimport type { AstNode, MDXComponents } from \"./types/MdxAST\";\nimport { BASIC_STYLES } from \"./utils/basicStyles\";\n\n\n// Attr resolver (client version handles expressions fully)\n\ntype AttrValueKind =\n | { kind: \"text\"; value: string }\n | { kind: \"expression\"; value: string }\n | { kind: \"boolean\" }\n | { kind: \"ast\"; value: AstNode[] };\n\nfunction resolveAttr(\n attr: AttrValueKind,\n components: MDXComponents,\n): React.ReactNode | string | boolean {\n switch (attr.kind) {\n case \"text\": return attr.value;\n case \"boolean\": return true;\n case \"expression\": {\n const raw = attr.value.trim();\n try { return JSON.parse(raw); } catch {}\n try { return new Function(`return (${raw})`)(); } catch {}\n return raw;\n }\n case \"ast\":\n return <MDXClientContent ast={attr.value} components={components} />;\n default:\n return undefined;\n }\n}\n\nfunction extractText(node: AstNode): string {\n if (node.node_type === \"text\") return node.content ?? \"\";\n if (node.content) return node.content;\n return (node.children ?? []).map(extractText).join(\"\");\n}\n\nconst HTML_TAGS = new Set([\n \"a\",\"abbr\",\"article\",\"aside\",\"b\",\"blockquote\",\"br\",\"caption\",\"cite\",\"code\",\n \"col\",\"colgroup\",\"dd\",\"del\",\"details\",\"dfn\",\"div\",\"dl\",\"dt\",\"em\",\"figcaption\",\n \"figure\",\"footer\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"header\",\"hr\",\"i\",\"img\",\"ins\",\n \"kbd\",\"li\",\"main\",\"mark\",\"nav\",\"ol\",\"p\",\"pre\",\"q\",\"s\",\"section\",\"small\",\"span\",\n \"strong\",\"sub\",\"summary\",\"sup\",\"table\",\"tbody\",\"td\",\"tfoot\",\"th\",\"thead\",\"tr\",\n \"u\",\"ul\",\"var\",\n]);\n\nfunction renderNode(\n node: AstNode,\n index: number,\n components: MDXComponents,\n): ReactNode {\n const key = `${node.node_type}-${index}`;\n\n if (node.node_type === \"text\") return node.content ?? null;\n\n if (node.node_type === \"fragment\") {\n return (\n <React.Fragment key={key}>\n {node.children?.map((c, i) => renderNode(c, i, components))}\n </React.Fragment>\n );\n }\n\n // Math — rendered directly via KaTeX (static import)\n if (node.node_type === \"InlineMath\") {\n const formula = extractText(node);\n try {\n const html = katex.renderToString(formula, { displayMode: false, throwOnError: false, output: \"html\" });\n return <span key={key} className=\"math math-inline\" dangerouslySetInnerHTML={{ __html: html }} />;\n } catch {\n return <span key={key} className=\"math math-inline\">{formula}</span>;\n }\n }\n if (node.node_type === \"BlockMath\") {\n const formula = extractText(node);\n try {\n const html = katex.renderToString(formula, { displayMode: true, throwOnError: false, output: \"html\" });\n return <div key={key} className=\"math math-display\" dangerouslySetInnerHTML={{ __html: html }} />;\n } catch {\n return <div key={key} className=\"math math-display\">{formula}</div>;\n }\n }\n\n const resolvedProps: Record<string, any> = {};\n if (node.attributes) {\n const attrs = typeof node.attributes === \"string\" \n ? JSON.parse(node.attributes) \n : node.attributes;\n\n for (const [k, v] of Object.entries(attrs)) {\n resolvedProps[k] = resolveAttr(v as AttrValueKind, components);\n }\n }\n\n const renderedChildren = node.children?.length\n ? node.children.map((c, i) => renderNode(c, i, components))\n : (node.content ?? undefined);\n\n const Custom = components[node.node_type];\n if (Custom) {\n return (\n <MDXErrorBoundary key={key} componentName={node.node_type}>\n <Custom {...resolvedProps}>\n {renderedChildren}\n </Custom>\n </MDXErrorBoundary>\n );\n }\n\n if (HTML_TAGS.has(node.node_type)) {\n const Tag = node.node_type as any;\n return <Tag key={key} {...resolvedProps}>{renderedChildren}</Tag>;\n }\n\n if (process.env.NODE_ENV === \"development\") {\n console.warn(`[toaq-oss/omni-mdx] Unknown component: <${node.node_type}>`);\n }\n return (\n <div key={key} data-missing-component={node.node_type} className=\"mdx-missing-component\">\n {renderedChildren}\n </div>\n );\n}\n\nfunction MDXClientContent({\n ast,\n components,\n}: {\n ast: AstNode[];\n components: MDXComponents;\n}) {\n return <>{ast.map((node, i) => renderNode(node, i, components))}</>;\n}\n\ninterface MDXClientRendererProps {\n /** AST from parseMdx() — must be JSON-serialisable (pass via Server Component). */\n ast: AstNode[];\n /** Component registry — same shape as MDX_COMPONENTS. */\n components?: MDXComponents;\n}\n\nexport function MDXClientRenderer({\n ast,\n components = {},\n}: MDXClientRendererProps) {\n const rootRef = useRef<HTMLDivElement>(null);\n\n if (!ast || !Array.isArray(ast)) return null;\n\n const finalComponents = {\n ...BASIC_STYLES,\n ...components\n };\n\n return (\n <div className=\"omni-mdx-root\">\n <MDXClientContent ast={ast} components={finalComponents} />\n </div>\n );\n}","\"use client\";\nimport { Component, ErrorInfo, ReactNode } from 'react';\n\ninterface Props {\n children: ReactNode;\n /** The name of the MDX component being rendered (e.g., 'Chart', 'SplitLayout') */\n componentName?: string;\n}\n\ninterface State {\n hasError: boolean;\n error: Error | null;\n}\n\n/**\n * A dedicated Error Boundary for MDX rendering.\n *\n * If a React component injected via MDX crashes (e.g., due to a data parsing error \n * inside a <Chart />), this boundary intercepts the error. This prevents the \n * entire React tree from unmounting and displays a clean fallback UI to \n * isolate the defective component.\n */\nexport class MDXErrorBoundary extends Component<Props, State> {\n constructor(props: Props) {\n super(props);\n this.state = { hasError: false, error: null };\n }\n\n /**\n * Updates the state when an error occurs to trigger the fallback UI rendering.\n */\n static getDerivedStateFromError(error: Error): State {\n return { hasError: true, error };\n }\n\n /**\n * Intercepts the error and its contextual information.\n * This is the ideal place to hook into monitoring tools (like Sentry or Datadog) \n * for production environments.\n */\n componentDidCatch(error: Error, errorInfo: ErrorInfo) {\n console.error(\n `[MDXErrorBoundary] Error caught in component <${this.props.componentName || 'Unknown'}>:\\n`,\n error,\n errorInfo.componentStack\n );\n }\n \n render() {\n if (this.state.hasError) {\n // Fallback UI: A clean, isolated container that doesn't break the main layout\n return (\n <div style={{ padding: '1rem', border: '2px solid #ef4444', backgroundColor: '#fef2f2', borderRadius: '0.5rem', margin: '1rem 0' }}>\n <h3 style={{ color: '#b91c1c', fontWeight: 'bold', margin: 0 }}>\n Render Error : {this.props.componentName || 'Unknown Component'}\n </h3>\n <p style={{ color: '#dc2626', fontFamily: 'monospace', fontSize: '0.875rem' }}>\n {this.state.error?.message}\n </p>\n </div>\n );\n }\n return this.props.children;\n }\n}","import React from \"react\";\n\n// Styles defined to be usable in fallback condition.\nexport const BASIC_STYLES: Record<string, React.FC<any>> = {\n h1: (props) => <h1 className=\"text-3xl font-bold tracking-tight text-white mt-8 mb-4\" {...props} />,\n h2: (props) => <h2 className=\"text-2xl font-semibold tracking-tight text-neutral-100 mt-6 mb-3 border-b border-white/5 pb-2\" {...props} />,\n h3: (props) => <h3 className=\"text-xl font-medium text-neutral-200 mt-4 mb-2\" {...props} />,\n h4: (props) => <h4 className=\"text-lg font-medium text-neutral-300 mt-4 mb-2\" {...props} />,\n p: (props) => <p className=\"text-base leading-7 text-neutral-400 mb-4\" {...props} />,\n ul: (props) => <ul className=\"list-disc list-inside mb-4 space-y-1 text-neutral-400\" {...props} />,\n ol: (props) => <ol className=\"list-decimal list-inside mb-4 space-y-1 text-neutral-400\" {...props} />,\n li: (props) => <li className=\"ml-4\" {...props} />,\n code: (props) => {\n return <code className=\"inline-code bg-white/10 px-1.5 py-0.5 rounded text-pink-400 font-mono text-sm\" {...props} />;\n },\n blockquote: (props) => <blockquote className=\"border-l-4 border-blue-500/50 pl-4 italic text-neutral-500 my-6\" {...props} />,\n hr: () => <hr className=\"border-white/5 my-8\" />,\n table: (props) => <div className=\"overflow-x-auto mb-6\"><table className=\"w-full text-sm text-left border-collapse\" {...props} /></div>,\n th: (props) => <th className=\"border-b border-white/10 p-2 font-semibold text-neutral-200\" {...props} />,\n td: (props) => <td className=\"border-b border-white/5 p-2 text-neutral-400\" {...props} />,\n img: (props) => <img className=\"rounded-xl border border-white/10 my-8 mx-auto max-w-full h-auto\" {...props} />,\n a: (props) => <a className=\"text-blue-400 hover:text-blue-300 underline underline-offset-4 decoration-blue-500/30 transition-colors\" {...props} />,\n};","import type { AstNode, AttrValueKind } from \"../types/MdxAST\";\n\nconst NODE_TEXT = 0x01;\nconst NODE_ELEMENT = 0x02;\n\nconst ATTR_TEXT = 0x10;\nconst ATTR_EXPRESSION = 0x11;\nconst ATTR_BOOLEAN = 0x12;\nconst ATTR_AST = 0x13;\n\nexport class MdxBinaryDecoder {\n private view: DataView;\n private buffer: Uint8Array;\n private offset: number = 0;\n private decoder = new TextDecoder(\"utf-8\");\n private stringCache = new Map<string, string>();\n\n constructor(buffer: Uint8Array) {\n this.buffer = buffer;\n this.view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);\n }\n\n public decode(): AstNode[] {\n const rootCount = this.readU32();\n const nodes: AstNode[] = [];\n for (let i = 0; i < rootCount; i++) {\n nodes.push(this.decodeNode());\n }\n return nodes;\n }\n\n private decodeNode(): AstNode {\n const type = this.readU8();\n\n if (type === NODE_TEXT) {\n return {\n node_type: \"text\",\n content: this.readStringU32(),\n };\n }\n\n if (type === NODE_ELEMENT) {\n const node_type = this.readStringU16();\n const self_closing = this.readU8() === 1;\n const attrCount = this.readU16();\n \n let attributes: Record<string, AttrValueKind> | undefined = undefined;\n \n if (attrCount > 0) {\n attributes = {};\n for (let i = 0; i < attrCount; i++) {\n const key = this.readStringU16();\n const attrKind = this.readU8();\n \n if (attrKind === ATTR_TEXT) {\n attributes[key] = { kind: \"text\", value: this.readStringU32() };\n } else if (attrKind === ATTR_EXPRESSION) {\n attributes[key] = { kind: \"expression\", value: this.readStringU32() };\n } else if (attrKind === ATTR_BOOLEAN) {\n attributes[key] = { kind: \"boolean\" };\n } else if (attrKind === ATTR_AST) {\n const subNodeCount = this.readU32();\n const subNodes: AstNode[] = [];\n for (let j = 0; j < subNodeCount; j++) {\n subNodes.push(this.decodeNode());\n }\n attributes[key] = { kind: \"ast\", value: subNodes };\n }\n }\n }\n\n const childCount = this.readU32();\n const children: AstNode[] = [];\n if (childCount > 0) {\n for (let i = 0; i < childCount; i++) {\n children.push(this.decodeNode());\n }\n }\n\n return {\n node_type,\n self_closing,\n attributes,\n children,\n };\n }\n\n throw new Error(`[@toaq-oss/omni-mdx] Unknown binary opcode: ${type} at offset ${this.offset}`);\n }\n\n private readU8(): number {\n const val = this.view.getUint8(this.offset);\n this.offset += 1;\n return val;\n }\n\n private readU16(): number {\n const val = this.view.getUint16(this.offset, true);\n this.offset += 2;\n return val;\n }\n\n private readU32(): number {\n const val = this.view.getUint32(this.offset, true);\n this.offset += 4;\n return val;\n }\n\n private readStringU16(): string {\n const len = this.readU16();\n const str = this.decoder.decode(this.buffer.subarray(this.offset, this.offset + len));\n this.offset += len;\n\n let cached = this.stringCache.get(str);\n if (cached) return cached;\n this.stringCache.set(str, str);\n return str;\n }\n\n private readStringU32(): string {\n const len = this.readU32();\n const str = this.decoder.decode(this.buffer.subarray(this.offset, this.offset + len));\n this.offset += len;\n return str;\n }\n}","// parse.client.ts\n//\n// Client-side MDX parser using WASM (--target web build).\n// Designed for live editors and fully client-side rendering contexts.\n// Never runs on the server — returns [] immediately if called server-side.\n\nimport type { AstNode } from \"./types/MdxAST\";\nimport { MdxBinaryDecoder } from \"./utils/binaryDecoder\";\n\nlet initPromise: Promise<(mdx: Uint8Array) => Uint8Array> | null = null;\n\nfunction getClientParser(): Promise<(mdx: Uint8Array) => Uint8Array> {\n if (!initPromise) {\n initPromise = (async () => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const wasm: any = await import(\"../wasm/omni_mdx_core.js\");\n\n if (typeof wasm.default === \"function\") {\n const wasmUrl = new URL(\"./omni_mdx_core_bg.wasm\", import.meta.url);\n await wasm.default(wasmUrl);\n }\n\n return (mdx: Uint8Array): Uint8Array => wasm.parse_to_binary(mdx);\n })();\n }\n return initPromise;\n}\n\nfunction normalizeToUint8Array(input: any): Uint8Array {\n if (input instanceof Uint8Array) {\n return input;\n }\n if (typeof input === \"string\") {\n return new TextEncoder().encode(input);\n }\n if (input && typeof input === 'object' && input.type === 'Buffer' && Array.isArray(input.data)) {\n return new Uint8Array(input.data);\n }\n return new TextEncoder().encode(String(input));\n}\n\nexport async function parseMdxClient(mdx: string | Uint8Array): Promise<AstNode[]> {\n if (typeof window === \"undefined\") return [];\n\n try {\n const parse = await getClientParser();\n const inputBuffer = normalizeToUint8Array(mdx);\n const binaryAst = parse(inputBuffer);\n const decoder = new MdxBinaryDecoder(binaryAst);\n return decoder.decode();\n } catch (err) {\n const errorMessage = err instanceof Error ? err.message : String(err);\n \n throw new Error(`Syntax error in MDX: ${errorMessage}`);\n }\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWO,SAAS,kBAAkB,OAAO;AACrC,MAAI;AACJ,MAAI;AACJ,MAAI;AACA,UAAM,OAAO,kBAAkB,OAAO,KAAK,mBAAmB,KAAK,kBAAkB;AACrF,UAAM,OAAO;AACb,U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iB,SAAS;AAC9C,WAAO,QAAQ,OAAO;AAAA,EACxB,SAAS,KAAK;AACZ,UAAM,eAAe,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAEpE,UAAM,IAAI,MAAM,wBAAwB,YAAY,EAAE;AAAA,EACxD;AACF;","names":["ptr","module","import_react","import_jsx_runtime","import_jsx_runtime","React","katex","import_meta","wasm"]}
@@ -0,0 +1,81 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { Component, ReactNode, ErrorInfo } from 'react';
3
+
4
+ // AST types (mirror Rust output exactly)
5
+
6
+ type AttrValueKind =
7
+ | { kind: "text"; value: string }
8
+ | { kind: "expression"; value: string }
9
+ | { kind: "boolean" }
10
+ | { kind: "ast"; value: AstNode[] };
11
+
12
+ interface AstNode {
13
+ node_type: string;
14
+ content?: string;
15
+ self_closing?: boolean;
16
+ child_count?: number;
17
+ attributes?: Record<string, AttrValueKind> | string;
18
+ children?: AstNode[];
19
+ }
20
+
21
+ type MDXComponents = Record<string, React.ComponentType<any>>;
22
+
23
+ interface MDXClientRendererProps {
24
+ /** AST from parseMdx() — must be JSON-serialisable (pass via Server Component). */
25
+ ast: AstNode[];
26
+ /** Component registry — same shape as MDX_COMPONENTS. */
27
+ components?: MDXComponents;
28
+ }
29
+ declare function MDXClientRenderer({ ast, components, }: MDXClientRendererProps): react_jsx_runtime.JSX.Element | null;
30
+
31
+ interface Props {
32
+ children: ReactNode;
33
+ /** The name of the MDX component being rendered (e.g., 'Chart', 'SplitLayout') */
34
+ componentName?: string;
35
+ }
36
+ interface State {
37
+ hasError: boolean;
38
+ error: Error | null;
39
+ }
40
+ /**
41
+ * A dedicated Error Boundary for MDX rendering.
42
+ *
43
+ * If a React component injected via MDX crashes (e.g., due to a data parsing error
44
+ * inside a <Chart />), this boundary intercepts the error. This prevents the
45
+ * entire React tree from unmounting and displays a clean fallback UI to
46
+ * isolate the defective component.
47
+ */
48
+ declare class MDXErrorBoundary extends Component<Props, State> {
49
+ constructor(props: Props);
50
+ /**
51
+ * Updates the state when an error occurs to trigger the fallback UI rendering.
52
+ */
53
+ static getDerivedStateFromError(error: Error): State;
54
+ /**
55
+ * Intercepts the error and its contextual information.
56
+ * This is the ideal place to hook into monitoring tools (like Sentry or Datadog)
57
+ * for production environments.
58
+ */
59
+ componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
60
+ render(): string | number | boolean | Iterable<ReactNode> | react_jsx_runtime.JSX.Element | null | undefined;
61
+ }
62
+
63
+ declare function parseMdxClient(mdx: string | Uint8Array): Promise<AstNode[]>;
64
+
65
+ declare class MdxBinaryDecoder {
66
+ private view;
67
+ private buffer;
68
+ private offset;
69
+ private decoder;
70
+ private stringCache;
71
+ constructor(buffer: Uint8Array);
72
+ decode(): AstNode[];
73
+ private decodeNode;
74
+ private readU8;
75
+ private readU16;
76
+ private readU32;
77
+ private readStringU16;
78
+ private readStringU32;
79
+ }
80
+
81
+ export { type AstNode, MDXClientRenderer, type MDXComponents, MDXErrorBoundary, MdxBinaryDecoder, parseMdxClient as parseMdx };
@@ -0,0 +1,81 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { Component, ReactNode, ErrorInfo } from 'react';
3
+
4
+ // AST types (mirror Rust output exactly)
5
+
6
+ type AttrValueKind =
7
+ | { kind: "text"; value: string }
8
+ | { kind: "expression"; value: string }
9
+ | { kind: "boolean" }
10
+ | { kind: "ast"; value: AstNode[] };
11
+
12
+ interface AstNode {
13
+ node_type: string;
14
+ content?: string;
15
+ self_closing?: boolean;
16
+ child_count?: number;
17
+ attributes?: Record<string, AttrValueKind> | string;
18
+ children?: AstNode[];
19
+ }
20
+
21
+ type MDXComponents = Record<string, React.ComponentType<any>>;
22
+
23
+ interface MDXClientRendererProps {
24
+ /** AST from parseMdx() — must be JSON-serialisable (pass via Server Component). */
25
+ ast: AstNode[];
26
+ /** Component registry — same shape as MDX_COMPONENTS. */
27
+ components?: MDXComponents;
28
+ }
29
+ declare function MDXClientRenderer({ ast, components, }: MDXClientRendererProps): react_jsx_runtime.JSX.Element | null;
30
+
31
+ interface Props {
32
+ children: ReactNode;
33
+ /** The name of the MDX component being rendered (e.g., 'Chart', 'SplitLayout') */
34
+ componentName?: string;
35
+ }
36
+ interface State {
37
+ hasError: boolean;
38
+ error: Error | null;
39
+ }
40
+ /**
41
+ * A dedicated Error Boundary for MDX rendering.
42
+ *
43
+ * If a React component injected via MDX crashes (e.g., due to a data parsing error
44
+ * inside a <Chart />), this boundary intercepts the error. This prevents the
45
+ * entire React tree from unmounting and displays a clean fallback UI to
46
+ * isolate the defective component.
47
+ */
48
+ declare class MDXErrorBoundary extends Component<Props, State> {
49
+ constructor(props: Props);
50
+ /**
51
+ * Updates the state when an error occurs to trigger the fallback UI rendering.
52
+ */
53
+ static getDerivedStateFromError(error: Error): State;
54
+ /**
55
+ * Intercepts the error and its contextual information.
56
+ * This is the ideal place to hook into monitoring tools (like Sentry or Datadog)
57
+ * for production environments.
58
+ */
59
+ componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
60
+ render(): string | number | boolean | Iterable<ReactNode> | react_jsx_runtime.JSX.Element | null | undefined;
61
+ }
62
+
63
+ declare function parseMdxClient(mdx: string | Uint8Array): Promise<AstNode[]>;
64
+
65
+ declare class MdxBinaryDecoder {
66
+ private view;
67
+ private buffer;
68
+ private offset;
69
+ private decoder;
70
+ private stringCache;
71
+ constructor(buffer: Uint8Array);
72
+ decode(): AstNode[];
73
+ private decodeNode;
74
+ private readU8;
75
+ private readU16;
76
+ private readU32;
77
+ private readStringU16;
78
+ private readStringU32;
79
+ }
80
+
81
+ export { type AstNode, MDXClientRenderer, type MDXComponents, MDXErrorBoundary, MdxBinaryDecoder, parseMdxClient as parseMdx };
package/dist/client.js CHANGED
@@ -319,8 +319,31 @@ var MDXErrorBoundary = class extends Component {
319
319
  }
320
320
  };
321
321
 
322
+ // src/utils/basicStyles.tsx
323
+ import { jsx as jsx2 } from "react/jsx-runtime";
324
+ var BASIC_STYLES = {
325
+ h1: (props) => /* @__PURE__ */ jsx2("h1", { className: "text-3xl font-bold tracking-tight text-white mt-8 mb-4", ...props }),
326
+ h2: (props) => /* @__PURE__ */ jsx2("h2", { className: "text-2xl font-semibold tracking-tight text-neutral-100 mt-6 mb-3 border-b border-white/5 pb-2", ...props }),
327
+ h3: (props) => /* @__PURE__ */ jsx2("h3", { className: "text-xl font-medium text-neutral-200 mt-4 mb-2", ...props }),
328
+ h4: (props) => /* @__PURE__ */ jsx2("h4", { className: "text-lg font-medium text-neutral-300 mt-4 mb-2", ...props }),
329
+ p: (props) => /* @__PURE__ */ jsx2("p", { className: "text-base leading-7 text-neutral-400 mb-4", ...props }),
330
+ ul: (props) => /* @__PURE__ */ jsx2("ul", { className: "list-disc list-inside mb-4 space-y-1 text-neutral-400", ...props }),
331
+ ol: (props) => /* @__PURE__ */ jsx2("ol", { className: "list-decimal list-inside mb-4 space-y-1 text-neutral-400", ...props }),
332
+ li: (props) => /* @__PURE__ */ jsx2("li", { className: "ml-4", ...props }),
333
+ code: (props) => {
334
+ return /* @__PURE__ */ jsx2("code", { className: "inline-code bg-white/10 px-1.5 py-0.5 rounded text-pink-400 font-mono text-sm", ...props });
335
+ },
336
+ blockquote: (props) => /* @__PURE__ */ jsx2("blockquote", { className: "border-l-4 border-blue-500/50 pl-4 italic text-neutral-500 my-6", ...props }),
337
+ hr: () => /* @__PURE__ */ jsx2("hr", { className: "border-white/5 my-8" }),
338
+ table: (props) => /* @__PURE__ */ jsx2("div", { className: "overflow-x-auto mb-6", children: /* @__PURE__ */ jsx2("table", { className: "w-full text-sm text-left border-collapse", ...props }) }),
339
+ th: (props) => /* @__PURE__ */ jsx2("th", { className: "border-b border-white/10 p-2 font-semibold text-neutral-200", ...props }),
340
+ td: (props) => /* @__PURE__ */ jsx2("td", { className: "border-b border-white/5 p-2 text-neutral-400", ...props }),
341
+ img: (props) => /* @__PURE__ */ jsx2("img", { className: "rounded-xl border border-white/10 my-8 mx-auto max-w-full h-auto", ...props }),
342
+ a: (props) => /* @__PURE__ */ jsx2("a", { className: "text-blue-400 hover:text-blue-300 underline underline-offset-4 decoration-blue-500/30 transition-colors", ...props })
343
+ };
344
+
322
345
  // src/MDXClientRenderer.tsx
323
- import { Fragment, jsx as jsx2 } from "react/jsx-runtime";
346
+ import { Fragment, jsx as jsx3 } from "react/jsx-runtime";
324
347
  function resolveAttr(attr, components) {
325
348
  switch (attr.kind) {
326
349
  case "text":
@@ -340,7 +363,7 @@ function resolveAttr(attr, components) {
340
363
  return raw;
341
364
  }
342
365
  case "ast":
343
- return /* @__PURE__ */ jsx2(MDXClientContent, { ast: attr.value, components });
366
+ return /* @__PURE__ */ jsx3(MDXClientContent, { ast: attr.value, components });
344
367
  default:
345
368
  return void 0;
346
369
  }
@@ -417,24 +440,24 @@ function renderNode(node, index, components) {
417
440
  const key = `${node.node_type}-${index}`;
418
441
  if (node.node_type === "text") return node.content ?? null;
419
442
  if (node.node_type === "fragment") {
420
- return /* @__PURE__ */ jsx2(React.Fragment, { children: node.children?.map((c, i) => renderNode(c, i, components)) }, key);
443
+ return /* @__PURE__ */ jsx3(React.Fragment, { children: node.children?.map((c, i) => renderNode(c, i, components)) }, key);
421
444
  }
422
445
  if (node.node_type === "InlineMath") {
423
446
  const formula = extractText(node);
424
447
  try {
425
448
  const html = katex.renderToString(formula, { displayMode: false, throwOnError: false, output: "html" });
426
- return /* @__PURE__ */ jsx2("span", { className: "math math-inline", dangerouslySetInnerHTML: { __html: html } }, key);
449
+ return /* @__PURE__ */ jsx3("span", { className: "math math-inline", dangerouslySetInnerHTML: { __html: html } }, key);
427
450
  } catch {
428
- return /* @__PURE__ */ jsx2("span", { className: "math math-inline", children: formula }, key);
451
+ return /* @__PURE__ */ jsx3("span", { className: "math math-inline", children: formula }, key);
429
452
  }
430
453
  }
431
454
  if (node.node_type === "BlockMath") {
432
455
  const formula = extractText(node);
433
456
  try {
434
457
  const html = katex.renderToString(formula, { displayMode: true, throwOnError: false, output: "html" });
435
- return /* @__PURE__ */ jsx2("div", { className: "math math-display", dangerouslySetInnerHTML: { __html: html } }, key);
458
+ return /* @__PURE__ */ jsx3("div", { className: "math math-display", dangerouslySetInnerHTML: { __html: html } }, key);
436
459
  } catch {
437
- return /* @__PURE__ */ jsx2("div", { className: "math math-display", children: formula }, key);
460
+ return /* @__PURE__ */ jsx3("div", { className: "math math-display", children: formula }, key);
438
461
  }
439
462
  }
440
463
  const resolvedProps = {};
@@ -447,22 +470,22 @@ function renderNode(node, index, components) {
447
470
  const renderedChildren = node.children?.length ? node.children.map((c, i) => renderNode(c, i, components)) : node.content ?? void 0;
448
471
  const Custom = components[node.node_type];
449
472
  if (Custom) {
450
- return /* @__PURE__ */ jsx2(MDXErrorBoundary, { componentName: node.node_type, children: /* @__PURE__ */ jsx2(Custom, { ...resolvedProps, children: renderedChildren }) }, key);
473
+ return /* @__PURE__ */ jsx3(MDXErrorBoundary, { componentName: node.node_type, children: /* @__PURE__ */ jsx3(Custom, { ...resolvedProps, children: renderedChildren }) }, key);
451
474
  }
452
475
  if (HTML_TAGS.has(node.node_type)) {
453
476
  const Tag = node.node_type;
454
- return /* @__PURE__ */ jsx2(Tag, { ...resolvedProps, children: renderedChildren }, key);
477
+ return /* @__PURE__ */ jsx3(Tag, { ...resolvedProps, children: renderedChildren }, key);
455
478
  }
456
479
  if (true) {
457
480
  console.warn(`[toaq-oss/omni-mdx] Unknown component: <${node.node_type}>`);
458
481
  }
459
- return /* @__PURE__ */ jsx2("div", { "data-missing-component": node.node_type, className: "mdx-missing-component", children: renderedChildren }, key);
482
+ return /* @__PURE__ */ jsx3("div", { "data-missing-component": node.node_type, className: "mdx-missing-component", children: renderedChildren }, key);
460
483
  }
461
484
  function MDXClientContent({
462
485
  ast,
463
486
  components
464
487
  }) {
465
- return /* @__PURE__ */ jsx2(Fragment, { children: ast.map((node, i) => renderNode(node, i, components)) });
488
+ return /* @__PURE__ */ jsx3(Fragment, { children: ast.map((node, i) => renderNode(node, i, components)) });
466
489
  }
467
490
  function MDXClientRenderer({
468
491
  ast,
@@ -470,7 +493,11 @@ function MDXClientRenderer({
470
493
  }) {
471
494
  const rootRef = useRef(null);
472
495
  if (!ast || !Array.isArray(ast)) return null;
473
- return /* @__PURE__ */ jsx2("div", { className: "omni-mdx-root", children: /* @__PURE__ */ jsx2(MDXClientContent, { ast, components }) });
496
+ const finalComponents = {
497
+ ...BASIC_STYLES,
498
+ ...components
499
+ };
500
+ return /* @__PURE__ */ jsx3("div", { className: "omni-mdx-root", children: /* @__PURE__ */ jsx3(MDXClientContent, { ast, components: finalComponents }) });
474
501
  }
475
502
 
476
503
  // src/utils/binaryDecoder.ts
@@ -1 +1 @@
1
- {"version":3,"sources":["../wasm/omni_mdx_core.js","../src/MDXClientRenderer.tsx","../src/MDXErrorBoundary.tsx","../src/utils/binaryDecoder.ts","../src/parse.client.ts"],"sourcesContent":["/* @ts-self-types=\"./omni_mdx_core.d.ts\" */\n\n/**\n * Compiles the raw MDX input into a minified JSON string representing the AST.\n *\n * This function is exposed directly to JavaScript via `wasm-bindgen`.\n * It returns a standard `JsError` if the parsing fails, ensuring that Node.js\n * or the browser can `try/catch` the error cleanly instead of encountering a WASM panic.\n * @param {string} input\n * @returns {string}\n */\nexport function parse_mdx_to_json(input) {\n let deferred3_0;\n let deferred3_1;\n try {\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.parse_mdx_to_json(ptr0, len0);\n var ptr2 = ret[0];\n var len2 = ret[1];\n if (ret[3]) {\n ptr2 = 0; len2 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred3_0 = ptr2;\n deferred3_1 = len2;\n return getStringFromWasm0(ptr2, len2);\n } finally {\n wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);\n }\n}\n\n/**\n * Compiles the raw MDX input into a pretty-printed JSON string.\n *\n * Useful for debugging, logging, or local development environments where\n * human-readable AST introspection is required.\n * @param {string} input\n * @returns {string}\n */\nexport function parse_mdx_to_json_pretty(input) {\n let deferred3_0;\n let deferred3_1;\n try {\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.parse_mdx_to_json_pretty(ptr0, len0);\n var ptr2 = ret[0];\n var len2 = ret[1];\n if (ret[3]) {\n ptr2 = 0; len2 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred3_0 = ptr2;\n deferred3_1 = len2;\n return getStringFromWasm0(ptr2, len2);\n } finally {\n wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);\n }\n}\n\n/**\n * Utility function exposed to JavaScript to fetch the compiled parser's version,\n * allowing the frontend package to verify WASM binary compatibility.\n * @returns {string}\n */\nexport function parse_mdx_version() {\n let deferred1_0;\n let deferred1_1;\n try {\n const ret = wasm.parse_mdx_version();\n deferred1_0 = ret[0];\n deferred1_1 = ret[1];\n return getStringFromWasm0(ret[0], ret[1]);\n } finally {\n wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);\n }\n}\n\n/**\n * @param {Uint8Array} mdx_input\n * @returns {Uint8Array}\n */\nexport function parse_to_binary(mdx_input) {\n const ptr0 = passArray8ToWasm0(mdx_input, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.parse_to_binary(ptr0, len0);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v2;\n}\n\nfunction __wbg_get_imports() {\n const import0 = {\n __proto__: null,\n __wbg_Error_83742b46f01ce22d: function(arg0, arg1) {\n const ret = Error(getStringFromWasm0(arg0, arg1));\n return ret;\n },\n __wbindgen_cast_0000000000000001: function(arg0, arg1) {\n // Cast intrinsic for `Ref(String) -> Externref`.\n const ret = getStringFromWasm0(arg0, arg1);\n return ret;\n },\n __wbindgen_init_externref_table: function() {\n const table = wasm.__wbindgen_externrefs;\n const offset = table.grow(4);\n table.set(0, undefined);\n table.set(offset + 0, undefined);\n table.set(offset + 1, null);\n table.set(offset + 2, true);\n table.set(offset + 3, false);\n },\n };\n return {\n __proto__: null,\n \"./omni_mdx_core_bg.js\": import0,\n };\n}\n\nfunction getArrayU8FromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);\n}\n\nfunction getStringFromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n return decodeText(ptr, len);\n}\n\nlet cachedUint8ArrayMemory0 = null;\nfunction getUint8ArrayMemory0() {\n if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {\n cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);\n }\n return cachedUint8ArrayMemory0;\n}\n\nfunction passArray8ToWasm0(arg, malloc) {\n const ptr = malloc(arg.length * 1, 1) >>> 0;\n getUint8ArrayMemory0().set(arg, ptr / 1);\n WASM_VECTOR_LEN = arg.length;\n return ptr;\n}\n\nfunction passStringToWasm0(arg, malloc, realloc) {\n if (realloc === undefined) {\n const buf = cachedTextEncoder.encode(arg);\n const ptr = malloc(buf.length, 1) >>> 0;\n getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);\n WASM_VECTOR_LEN = buf.length;\n return ptr;\n }\n\n let len = arg.length;\n let ptr = malloc(len, 1) >>> 0;\n\n const mem = getUint8ArrayMemory0();\n\n let offset = 0;\n\n for (; offset < len; offset++) {\n const code = arg.charCodeAt(offset);\n if (code > 0x7F) break;\n mem[ptr + offset] = code;\n }\n if (offset !== len) {\n if (offset !== 0) {\n arg = arg.slice(offset);\n }\n ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;\n const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);\n const ret = cachedTextEncoder.encodeInto(arg, view);\n\n offset += ret.written;\n ptr = realloc(ptr, len, offset, 1) >>> 0;\n }\n\n WASM_VECTOR_LEN = offset;\n return ptr;\n}\n\nfunction takeFromExternrefTable0(idx) {\n const value = wasm.__wbindgen_externrefs.get(idx);\n wasm.__externref_table_dealloc(idx);\n return value;\n}\n\nlet cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });\ncachedTextDecoder.decode();\nconst MAX_SAFARI_DECODE_BYTES = 2146435072;\nlet numBytesDecoded = 0;\nfunction decodeText(ptr, len) {\n numBytesDecoded += len;\n if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {\n cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });\n cachedTextDecoder.decode();\n numBytesDecoded = len;\n }\n return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));\n}\n\nconst cachedTextEncoder = new TextEncoder();\n\nif (!('encodeInto' in cachedTextEncoder)) {\n cachedTextEncoder.encodeInto = function (arg, view) {\n const buf = cachedTextEncoder.encode(arg);\n view.set(buf);\n return {\n read: arg.length,\n written: buf.length\n };\n };\n}\n\nlet WASM_VECTOR_LEN = 0;\n\nlet wasmModule, wasm;\nfunction __wbg_finalize_init(instance, module) {\n wasm = instance.exports;\n wasmModule = module;\n cachedUint8ArrayMemory0 = null;\n wasm.__wbindgen_start();\n return wasm;\n}\n\nasync function __wbg_load(module, imports) {\n if (typeof Response === 'function' && module instanceof Response) {\n if (typeof WebAssembly.instantiateStreaming === 'function') {\n try {\n return await WebAssembly.instantiateStreaming(module, imports);\n } catch (e) {\n const validResponse = module.ok && expectedResponseType(module.type);\n\n if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {\n console.warn(\"`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n\", e);\n\n } else { throw e; }\n }\n }\n\n const bytes = await module.arrayBuffer();\n return await WebAssembly.instantiate(bytes, imports);\n } else {\n const instance = await WebAssembly.instantiate(module, imports);\n\n if (instance instanceof WebAssembly.Instance) {\n return { instance, module };\n } else {\n return instance;\n }\n }\n\n function expectedResponseType(type) {\n switch (type) {\n case 'basic': case 'cors': case 'default': return true;\n }\n return false;\n }\n}\n\nfunction initSync(module) {\n if (wasm !== undefined) return wasm;\n\n\n if (module !== undefined) {\n if (Object.getPrototypeOf(module) === Object.prototype) {\n ({module} = module)\n } else {\n console.warn('using deprecated parameters for `initSync()`; pass a single object instead')\n }\n }\n\n const imports = __wbg_get_imports();\n if (!(module instanceof WebAssembly.Module)) {\n module = new WebAssembly.Module(module);\n }\n const instance = new WebAssembly.Instance(module, imports);\n return __wbg_finalize_init(instance, module);\n}\n\nasync function __wbg_init(module_or_path) {\n if (wasm !== undefined) return wasm;\n\n\n if (module_or_path !== undefined) {\n if (Object.getPrototypeOf(module_or_path) === Object.prototype) {\n ({module_or_path} = module_or_path)\n } else {\n console.warn('using deprecated parameters for the initialization function; pass a single object instead')\n }\n }\n\n if (module_or_path === undefined) {\n module_or_path = new URL('omni_mdx_core_bg.wasm', import.meta.url);\n }\n const imports = __wbg_get_imports();\n\n if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {\n module_or_path = fetch(module_or_path);\n }\n\n const { instance, module } = await __wbg_load(await module_or_path, imports);\n\n return __wbg_finalize_init(instance, module);\n}\n\nexport { initSync, __wbg_init as default };\n","\"use client\";\n\n/**\n * MDXClientRenderer.tsx\n *\n * Client Component — handles KaTeX hydration and interactive components.\n *\n * You generally do NOT use this directly.\n * Use <MDXServerRenderer> in Server Components and only register Client\n * Components (wrapped in \"use client\") for interactive parts (charts, tabs, etc.).\n *\n * Use this component ONLY when:\n * 1. You are in a page/layout that is entirely client-side (no RSC)\n * 2. You need live re-rendering (e.g. a live MDX editor/preview)\n *\n * For the live editor use case, import from '@toaq/omni-mdx/client'.\n */\n\nimport React, { ReactNode, useRef } from \"react\";\nimport katex from \"katex\";\nimport { MDXErrorBoundary } from \"./MDXErrorBoundary\";\nimport type { AstNode, MDXComponents } from \"./types/MdxAST\";\n\n\n\n// Attr resolver (client version handles expressions fully)\n\ntype AttrValueKind =\n | { kind: \"text\"; value: string }\n | { kind: \"expression\"; value: string }\n | { kind: \"boolean\" }\n | { kind: \"ast\"; value: AstNode[] };\n\nfunction resolveAttr(\n attr: AttrValueKind,\n components: MDXComponents,\n): React.ReactNode | string | boolean {\n switch (attr.kind) {\n case \"text\": return attr.value;\n case \"boolean\": return true;\n case \"expression\": {\n const raw = attr.value.trim();\n try { return JSON.parse(raw); } catch {}\n try { return new Function(`return (${raw})`)(); } catch {}\n return raw;\n }\n case \"ast\":\n return <MDXClientContent ast={attr.value} components={components} />;\n default:\n return undefined;\n }\n}\n\nfunction extractText(node: AstNode): string {\n if (node.node_type === \"text\") return node.content ?? \"\";\n if (node.content) return node.content;\n return (node.children ?? []).map(extractText).join(\"\");\n}\n\nconst HTML_TAGS = new Set([\n \"a\",\"abbr\",\"article\",\"aside\",\"b\",\"blockquote\",\"br\",\"caption\",\"cite\",\"code\",\n \"col\",\"colgroup\",\"dd\",\"del\",\"details\",\"dfn\",\"div\",\"dl\",\"dt\",\"em\",\"figcaption\",\n \"figure\",\"footer\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"header\",\"hr\",\"i\",\"img\",\"ins\",\n \"kbd\",\"li\",\"main\",\"mark\",\"nav\",\"ol\",\"p\",\"pre\",\"q\",\"s\",\"section\",\"small\",\"span\",\n \"strong\",\"sub\",\"summary\",\"sup\",\"table\",\"tbody\",\"td\",\"tfoot\",\"th\",\"thead\",\"tr\",\n \"u\",\"ul\",\"var\",\n]);\n\nfunction renderNode(\n node: AstNode,\n index: number,\n components: MDXComponents,\n): ReactNode {\n const key = `${node.node_type}-${index}`;\n\n if (node.node_type === \"text\") return node.content ?? null;\n\n if (node.node_type === \"fragment\") {\n return (\n <React.Fragment key={key}>\n {node.children?.map((c, i) => renderNode(c, i, components))}\n </React.Fragment>\n );\n }\n\n // Math — rendered directly via KaTeX (static import)\n if (node.node_type === \"InlineMath\") {\n const formula = extractText(node);\n try {\n const html = katex.renderToString(formula, { displayMode: false, throwOnError: false, output: \"html\" });\n return <span key={key} className=\"math math-inline\" dangerouslySetInnerHTML={{ __html: html }} />;\n } catch {\n return <span key={key} className=\"math math-inline\">{formula}</span>;\n }\n }\n if (node.node_type === \"BlockMath\") {\n const formula = extractText(node);\n try {\n const html = katex.renderToString(formula, { displayMode: true, throwOnError: false, output: \"html\" });\n return <div key={key} className=\"math math-display\" dangerouslySetInnerHTML={{ __html: html }} />;\n } catch {\n return <div key={key} className=\"math math-display\">{formula}</div>;\n }\n }\n\n const resolvedProps: Record<string, any> = {};\n if (node.attributes) {\n const attrs = typeof node.attributes === \"string\" \n ? JSON.parse(node.attributes) \n : node.attributes;\n\n for (const [k, v] of Object.entries(attrs)) {\n resolvedProps[k] = resolveAttr(v as AttrValueKind, components);\n }\n }\n\n const renderedChildren = node.children?.length\n ? node.children.map((c, i) => renderNode(c, i, components))\n : (node.content ?? undefined);\n\n const Custom = components[node.node_type];\n if (Custom) {\n return (\n <MDXErrorBoundary key={key} componentName={node.node_type}>\n <Custom {...resolvedProps}>\n {renderedChildren}\n </Custom>\n </MDXErrorBoundary>\n );\n }\n\n if (HTML_TAGS.has(node.node_type)) {\n const Tag = node.node_type as any;\n return <Tag key={key} {...resolvedProps}>{renderedChildren}</Tag>;\n }\n\n if (process.env.NODE_ENV === \"development\") {\n console.warn(`[toaq-oss/omni-mdx] Unknown component: <${node.node_type}>`);\n }\n return (\n <div key={key} data-missing-component={node.node_type} className=\"mdx-missing-component\">\n {renderedChildren}\n </div>\n );\n}\n\nfunction MDXClientContent({\n ast,\n components,\n}: {\n ast: AstNode[];\n components: MDXComponents;\n}) {\n return <>{ast.map((node, i) => renderNode(node, i, components))}</>;\n}\n\ninterface MDXClientRendererProps {\n /** AST from parseMdx() — must be JSON-serialisable (pass via Server Component). */\n ast: AstNode[];\n /** Component registry — same shape as MDX_COMPONENTS. */\n components?: MDXComponents;\n}\n\nexport function MDXClientRenderer({\n ast,\n components = {},\n}: MDXClientRendererProps) {\n const rootRef = useRef<HTMLDivElement>(null);\n\n if (!ast || !Array.isArray(ast)) return null;\n\n return (\n <div className=\"omni-mdx-root\">\n <MDXClientContent ast={ast} components={components} />\n </div>\n );\n}","\"use client\";\nimport { Component, ErrorInfo, ReactNode } from 'react';\n\ninterface Props {\n children: ReactNode;\n /** The name of the MDX component being rendered (e.g., 'Chart', 'SplitLayout') */\n componentName?: string;\n}\n\ninterface State {\n hasError: boolean;\n error: Error | null;\n}\n\n/**\n * A dedicated Error Boundary for MDX rendering.\n *\n * If a React component injected via MDX crashes (e.g., due to a data parsing error \n * inside a <Chart />), this boundary intercepts the error. This prevents the \n * entire React tree from unmounting and displays a clean fallback UI to \n * isolate the defective component.\n */\nexport class MDXErrorBoundary extends Component<Props, State> {\n constructor(props: Props) {\n super(props);\n this.state = { hasError: false, error: null };\n }\n\n /**\n * Updates the state when an error occurs to trigger the fallback UI rendering.\n */\n static getDerivedStateFromError(error: Error): State {\n return { hasError: true, error };\n }\n\n /**\n * Intercepts the error and its contextual information.\n * This is the ideal place to hook into monitoring tools (like Sentry or Datadog) \n * for production environments.\n */\n componentDidCatch(error: Error, errorInfo: ErrorInfo) {\n console.error(\n `[MDXErrorBoundary] Error caught in component <${this.props.componentName || 'Unknown'}>:\\n`,\n error,\n errorInfo.componentStack\n );\n }\n \n render() {\n if (this.state.hasError) {\n // Fallback UI: A clean, isolated container that doesn't break the main layout\n return (\n <div style={{ padding: '1rem', border: '2px solid #ef4444', backgroundColor: '#fef2f2', borderRadius: '0.5rem', margin: '1rem 0' }}>\n <h3 style={{ color: '#b91c1c', fontWeight: 'bold', margin: 0 }}>\n Render Error : {this.props.componentName || 'Unknown Component'}\n </h3>\n <p style={{ color: '#dc2626', fontFamily: 'monospace', fontSize: '0.875rem' }}>\n {this.state.error?.message}\n </p>\n </div>\n );\n }\n return this.props.children;\n }\n}","import type { AstNode, AttrValueKind } from \"../types/MdxAST\";\n\nconst NODE_TEXT = 0x01;\nconst NODE_ELEMENT = 0x02;\n\nconst ATTR_TEXT = 0x10;\nconst ATTR_EXPRESSION = 0x11;\nconst ATTR_BOOLEAN = 0x12;\nconst ATTR_AST = 0x13;\n\nexport class MdxBinaryDecoder {\n private view: DataView;\n private buffer: Uint8Array;\n private offset: number = 0;\n private decoder = new TextDecoder(\"utf-8\");\n private stringCache = new Map<string, string>();\n\n constructor(buffer: Uint8Array) {\n this.buffer = buffer;\n this.view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);\n }\n\n public decode(): AstNode[] {\n const rootCount = this.readU32();\n const nodes: AstNode[] = [];\n for (let i = 0; i < rootCount; i++) {\n nodes.push(this.decodeNode());\n }\n return nodes;\n }\n\n private decodeNode(): AstNode {\n const type = this.readU8();\n\n if (type === NODE_TEXT) {\n return {\n node_type: \"text\",\n content: this.readStringU32(),\n };\n }\n\n if (type === NODE_ELEMENT) {\n const node_type = this.readStringU16();\n const self_closing = this.readU8() === 1;\n const attrCount = this.readU16();\n \n let attributes: Record<string, AttrValueKind> | undefined = undefined;\n \n if (attrCount > 0) {\n attributes = {};\n for (let i = 0; i < attrCount; i++) {\n const key = this.readStringU16();\n const attrKind = this.readU8();\n \n if (attrKind === ATTR_TEXT) {\n attributes[key] = { kind: \"text\", value: this.readStringU32() };\n } else if (attrKind === ATTR_EXPRESSION) {\n attributes[key] = { kind: \"expression\", value: this.readStringU32() };\n } else if (attrKind === ATTR_BOOLEAN) {\n attributes[key] = { kind: \"boolean\" };\n } else if (attrKind === ATTR_AST) {\n const subNodeCount = this.readU32();\n const subNodes: AstNode[] = [];\n for (let j = 0; j < subNodeCount; j++) {\n subNodes.push(this.decodeNode());\n }\n attributes[key] = { kind: \"ast\", value: subNodes };\n }\n }\n }\n\n const childCount = this.readU32();\n const children: AstNode[] = [];\n if (childCount > 0) {\n for (let i = 0; i < childCount; i++) {\n children.push(this.decodeNode());\n }\n }\n\n return {\n node_type,\n self_closing,\n attributes,\n children,\n };\n }\n\n throw new Error(`[@toaq-oss/omni-mdx] Unknown binary opcode: ${type} at offset ${this.offset}`);\n }\n\n private readU8(): number {\n const val = this.view.getUint8(this.offset);\n this.offset += 1;\n return val;\n }\n\n private readU16(): number {\n const val = this.view.getUint16(this.offset, true);\n this.offset += 2;\n return val;\n }\n\n private readU32(): number {\n const val = this.view.getUint32(this.offset, true);\n this.offset += 4;\n return val;\n }\n\n private readStringU16(): string {\n const len = this.readU16();\n const str = this.decoder.decode(this.buffer.subarray(this.offset, this.offset + len));\n this.offset += len;\n\n let cached = this.stringCache.get(str);\n if (cached) return cached;\n this.stringCache.set(str, str);\n return str;\n }\n\n private readStringU32(): string {\n const len = this.readU32();\n const str = this.decoder.decode(this.buffer.subarray(this.offset, this.offset + len));\n this.offset += len;\n return str;\n }\n}","// parse.client.ts\n//\n// Client-side MDX parser using WASM (--target web build).\n// Designed for live editors and fully client-side rendering contexts.\n// Never runs on the server — returns [] immediately if called server-side.\n\nimport type { AstNode } from \"./types/MdxAST\";\nimport { MdxBinaryDecoder } from \"./utils/binaryDecoder\";\n\nlet initPromise: Promise<(mdx: Uint8Array) => Uint8Array> | null = null;\n\nfunction getClientParser(): Promise<(mdx: Uint8Array) => Uint8Array> {\n if (!initPromise) {\n initPromise = (async () => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const wasm: any = await import(\"../wasm/omni_mdx_core.js\");\n\n if (typeof wasm.default === \"function\") {\n const wasmUrl = new URL(\"./omni_mdx_core_bg.wasm\", import.meta.url);\n await wasm.default(wasmUrl);\n }\n\n return (mdx: Uint8Array): Uint8Array => wasm.parse_to_binary(mdx);\n })();\n }\n return initPromise;\n}\n\nfunction normalizeToUint8Array(input: any): Uint8Array {\n if (input instanceof Uint8Array) {\n return input;\n }\n if (typeof input === \"string\") {\n return new TextEncoder().encode(input);\n }\n if (input && typeof input === 'object' && input.type === 'Buffer' && Array.isArray(input.data)) {\n return new Uint8Array(input.data);\n }\n return new TextEncoder().encode(String(input));\n}\n\nexport async function parseMdxClient(mdx: string | Uint8Array): Promise<AstNode[]> {\n if (typeof window === \"undefined\") return [];\n\n try {\n const parse = await getClientParser();\n const inputBuffer = normalizeToUint8Array(mdx);\n const binaryAst = parse(inputBuffer);\n const decoder = new MdxBinaryDecoder(binaryAst);\n return decoder.decode();\n } catch (err) {\n const errorMessage = err instanceof Error ? err.message : String(err);\n \n throw new Error(`Syntax error in MDX: ${errorMessage}`);\n }\n}"],"mappings":";;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWO,SAAS,kBAAkB,OAAO;AACrC,MAAI;AACJ,MAAI;AACJ,MAAI;AACA,UAAM,OAAO,kBAAkB,OAAO,KAAK,mBAAmB,KAAK,kBAAkB;AACrF,UAAM,OAAO;AACb,UAAM,MAAM,KAAK,kBAAkB,MAAM,IAAI;AAC7C,QAAI,OAAO,IAAI,CAAC;AAChB,QAAI,OAAO,IAAI,CAAC;AAChB,QAAI,IAAI,CAAC,GAAG;AACR,aAAO;AAAG,aAAO;AACjB,YAAM,wBAAwB,IAAI,CAAC,CAAC;AAAA,IACxC;AACA,kBAAc;AACd,kBAAc;AACd,WAAO,mBAAmB,MAAM,IAAI;AAAA,EACxC,UAAE;AACE,SAAK,gBAAgB,aAAa,aAAa,CAAC;AAAA,EACpD;AACJ;AAUO,SAAS,yBAAyB,OAAO;AAC5C,MAAI;AACJ,MAAI;AACJ,MAAI;AACA,UAAM,OAAO,kBAAkB,OAAO,KAAK,mBAAmB,KAAK,kBAAkB;AACrF,UAAM,OAAO;AACb,UAAM,MAAM,KAAK,yBAAyB,MAAM,IAAI;AACpD,QAAI,OAAO,IAAI,CAAC;AAChB,QAAI,OAAO,IAAI,CAAC;AAChB,QAAI,IAAI,CAAC,GAAG;AACR,aAAO;AAAG,aAAO;AACjB,YAAM,wBAAwB,IAAI,CAAC,CAAC;AAAA,IACxC;AAC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;AACA,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO,IAAI,YAAY,EAAE,OAAO,KAAK;AAAA,EACvC;AACA,MAAI,SAAS,OAAO,UAAU,YAAY,MAAM,SAAS,YAAY,MAAM,QAAQ,MAAM,IAAI,GAAG;AAC9F,WAAO,IAAI,WAAW,MAAM,IAAI;AAAA,EAClC;AACA,SAAO,IAAI,YAAY,EAAE,OAAO,OAAO,KAAK,CAAC;AAC/C;AAEA,eAAsB,eAAe,KAA8C;AACjF,MAAI,OAAO,WAAW,YAAa,QAAO,CAAC;AAE3C,MAAI;AACF,UAAM,QAAQ,MAAM,gBAAgB;AACpC,UAAM,cAAc,sBAAsB,GAAG;AAC7C,UAAM,YAAY,MAAM,WAAW;AACnC,UAAM,UAAU,IAAI,iBAAiB,SAAS;AAC9C,WAAO,QAAQ,OAAO;AAAA,EACxB,SAAS,KAAK;AACZ,UAAM,eAAe,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAEpE,UAAM,IAAI,MAAM,wBAAwB,YAAY,EAAE;AAAA,EACxD;AACF;","names":["ptr","jsx","wasm"]}
1
+ {"version":3,"sources":["../wasm/omni_mdx_core.js","../src/MDXClientRenderer.tsx","../src/MDXErrorBoundary.tsx","../src/utils/basicStyles.tsx","../src/utils/binaryDecoder.ts","../src/parse.client.ts"],"sourcesContent":["/* @ts-self-types=\"./omni_mdx_core.d.ts\" */\n\n/**\n * Compiles the raw MDX input into a minified JSON string representing the AST.\n *\n * This function is exposed directly to JavaScript via `wasm-bindgen`.\n * It returns a standard `JsError` if the parsing fails, ensuring that Node.js\n * or the browser can `try/catch` the error cleanly instead of encountering a WASM panic.\n * @param {string} input\n * @returns {string}\n */\nexport function parse_mdx_to_json(input) {\n let deferred3_0;\n let deferred3_1;\n try {\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.parse_mdx_to_json(ptr0, len0);\n var ptr2 = ret[0];\n var len2 = ret[1];\n if (ret[3]) {\n ptr2 = 0; len2 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred3_0 = ptr2;\n deferred3_1 = len2;\n return getStringFromWasm0(ptr2, len2);\n } finally {\n wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);\n }\n}\n\n/**\n * Compiles the raw MDX input into a pretty-printed JSON string.\n *\n * Useful for debugging, logging, or local development environments where\n * human-readable AST introspection is required.\n * @param {string} input\n * @returns {string}\n */\nexport function parse_mdx_to_json_pretty(input) {\n let deferred3_0;\n let deferred3_1;\n try {\n const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.parse_mdx_to_json_pretty(ptr0, len0);\n var ptr2 = ret[0];\n var len2 = ret[1];\n if (ret[3]) {\n ptr2 = 0; len2 = 0;\n throw takeFromExternrefTable0(ret[2]);\n }\n deferred3_0 = ptr2;\n deferred3_1 = len2;\n return getStringFromWasm0(ptr2, len2);\n } finally {\n wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);\n }\n}\n\n/**\n * Utility function exposed to JavaScript to fetch the compiled parser's version,\n * allowing the frontend package to verify WASM binary compatibility.\n * @returns {string}\n */\nexport function parse_mdx_version() {\n let deferred1_0;\n let deferred1_1;\n try {\n const ret = wasm.parse_mdx_version();\n deferred1_0 = ret[0];\n deferred1_1 = ret[1];\n return getStringFromWasm0(ret[0], ret[1]);\n } finally {\n wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);\n }\n}\n\n/**\n * @param {Uint8Array} mdx_input\n * @returns {Uint8Array}\n */\nexport function parse_to_binary(mdx_input) {\n const ptr0 = passArray8ToWasm0(mdx_input, wasm.__wbindgen_malloc);\n const len0 = WASM_VECTOR_LEN;\n const ret = wasm.parse_to_binary(ptr0, len0);\n if (ret[3]) {\n throw takeFromExternrefTable0(ret[2]);\n }\n var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();\n wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);\n return v2;\n}\n\nfunction __wbg_get_imports() {\n const import0 = {\n __proto__: null,\n __wbg_Error_83742b46f01ce22d: function(arg0, arg1) {\n const ret = Error(getStringFromWasm0(arg0, arg1));\n return ret;\n },\n __wbindgen_cast_0000000000000001: function(arg0, arg1) {\n // Cast intrinsic for `Ref(String) -> Externref`.\n const ret = getStringFromWasm0(arg0, arg1);\n return ret;\n },\n __wbindgen_init_externref_table: function() {\n const table = wasm.__wbindgen_externrefs;\n const offset = table.grow(4);\n table.set(0, undefined);\n table.set(offset + 0, undefined);\n table.set(offset + 1, null);\n table.set(offset + 2, true);\n table.set(offset + 3, false);\n },\n };\n return {\n __proto__: null,\n \"./omni_mdx_core_bg.js\": import0,\n };\n}\n\nfunction getArrayU8FromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);\n}\n\nfunction getStringFromWasm0(ptr, len) {\n ptr = ptr >>> 0;\n return decodeText(ptr, len);\n}\n\nlet cachedUint8ArrayMemory0 = null;\nfunction getUint8ArrayMemory0() {\n if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {\n cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);\n }\n return cachedUint8ArrayMemory0;\n}\n\nfunction passArray8ToWasm0(arg, malloc) {\n const ptr = malloc(arg.length * 1, 1) >>> 0;\n getUint8ArrayMemory0().set(arg, ptr / 1);\n WASM_VECTOR_LEN = arg.length;\n return ptr;\n}\n\nfunction passStringToWasm0(arg, malloc, realloc) {\n if (realloc === undefined) {\n const buf = cachedTextEncoder.encode(arg);\n const ptr = malloc(buf.length, 1) >>> 0;\n getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);\n WASM_VECTOR_LEN = buf.length;\n return ptr;\n }\n\n let len = arg.length;\n let ptr = malloc(len, 1) >>> 0;\n\n const mem = getUint8ArrayMemory0();\n\n let offset = 0;\n\n for (; offset < len; offset++) {\n const code = arg.charCodeAt(offset);\n if (code > 0x7F) break;\n mem[ptr + offset] = code;\n }\n if (offset !== len) {\n if (offset !== 0) {\n arg = arg.slice(offset);\n }\n ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;\n const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);\n const ret = cachedTextEncoder.encodeInto(arg, view);\n\n offset += ret.written;\n ptr = realloc(ptr, len, offset, 1) >>> 0;\n }\n\n WASM_VECTOR_LEN = offset;\n return ptr;\n}\n\nfunction takeFromExternrefTable0(idx) {\n const value = wasm.__wbindgen_externrefs.get(idx);\n wasm.__externref_table_dealloc(idx);\n return value;\n}\n\nlet cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });\ncachedTextDecoder.decode();\nconst MAX_SAFARI_DECODE_BYTES = 2146435072;\nlet numBytesDecoded = 0;\nfunction decodeText(ptr, len) {\n numBytesDecoded += len;\n if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {\n cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });\n cachedTextDecoder.decode();\n numBytesDecoded = len;\n }\n return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));\n}\n\nconst cachedTextEncoder = new TextEncoder();\n\nif (!('encodeInto' in cachedTextEncoder)) {\n cachedTextEncoder.encodeInto = function (arg, view) {\n const buf = cachedTextEncoder.encode(arg);\n view.set(buf);\n return {\n read: arg.length,\n written: buf.length\n };\n };\n}\n\nlet WASM_VECTOR_LEN = 0;\n\nlet wasmModule, wasm;\nfunction __wbg_finalize_init(instance, module) {\n wasm = instance.exports;\n wasmModule = module;\n cachedUint8ArrayMemory0 = null;\n wasm.__wbindgen_start();\n return wasm;\n}\n\nasync function __wbg_load(module, imports) {\n if (typeof Response === 'function' && module instanceof Response) {\n if (typeof WebAssembly.instantiateStreaming === 'function') {\n try {\n return await WebAssembly.instantiateStreaming(module, imports);\n } catch (e) {\n const validResponse = module.ok && expectedResponseType(module.type);\n\n if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {\n console.warn(\"`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n\", e);\n\n } else { throw e; }\n }\n }\n\n const bytes = await module.arrayBuffer();\n return await WebAssembly.instantiate(bytes, imports);\n } else {\n const instance = await WebAssembly.instantiate(module, imports);\n\n if (instance instanceof WebAssembly.Instance) {\n return { instance, module };\n } else {\n return instance;\n }\n }\n\n function expectedResponseType(type) {\n switch (type) {\n case 'basic': case 'cors': case 'default': return true;\n }\n return false;\n }\n}\n\nfunction initSync(module) {\n if (wasm !== undefined) return wasm;\n\n\n if (module !== undefined) {\n if (Object.getPrototypeOf(module) === Object.prototype) {\n ({module} = module)\n } else {\n console.warn('using deprecated parameters for `initSync()`; pass a single object instead')\n }\n }\n\n const imports = __wbg_get_imports();\n if (!(module instanceof WebAssembly.Module)) {\n module = new WebAssembly.Module(module);\n }\n const instance = new WebAssembly.Instance(module, imports);\n return __wbg_finalize_init(instance, module);\n}\n\nasync function __wbg_init(module_or_path) {\n if (wasm !== undefined) return wasm;\n\n\n if (module_or_path !== undefined) {\n if (Object.getPrototypeOf(module_or_path) === Object.prototype) {\n ({module_or_path} = module_or_path)\n } else {\n console.warn('using deprecated parameters for the initialization function; pass a single object instead')\n }\n }\n\n if (module_or_path === undefined) {\n module_or_path = new URL('omni_mdx_core_bg.wasm', import.meta.url);\n }\n const imports = __wbg_get_imports();\n\n if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {\n module_or_path = fetch(module_or_path);\n }\n\n const { instance, module } = await __wbg_load(await module_or_path, imports);\n\n return __wbg_finalize_init(instance, module);\n}\n\nexport { initSync, __wbg_init as default };\n","\"use client\";\n\n/**\n * MDXClientRenderer.tsx\n *\n * Client Component — handles KaTeX hydration and interactive components.\n *\n * You generally do NOT use this directly.\n * Use <MDXServerRenderer> in Server Components and only register Client\n * Components (wrapped in \"use client\") for interactive parts (charts, tabs, etc.).\n *\n * Use this component ONLY when:\n * 1. You are in a page/layout that is entirely client-side (no RSC)\n * 2. You need live re-rendering (e.g. a live MDX editor/preview)\n *\n * For the live editor use case, import from '@toaq/omni-mdx/client'.\n */\n\nimport React, { ReactNode, useRef } from \"react\";\nimport katex from \"katex\";\nimport { MDXErrorBoundary } from \"./MDXErrorBoundary\";\nimport type { AstNode, MDXComponents } from \"./types/MdxAST\";\nimport { BASIC_STYLES } from \"./utils/basicStyles\";\n\n\n// Attr resolver (client version handles expressions fully)\n\ntype AttrValueKind =\n | { kind: \"text\"; value: string }\n | { kind: \"expression\"; value: string }\n | { kind: \"boolean\" }\n | { kind: \"ast\"; value: AstNode[] };\n\nfunction resolveAttr(\n attr: AttrValueKind,\n components: MDXComponents,\n): React.ReactNode | string | boolean {\n switch (attr.kind) {\n case \"text\": return attr.value;\n case \"boolean\": return true;\n case \"expression\": {\n const raw = attr.value.trim();\n try { return JSON.parse(raw); } catch {}\n try { return new Function(`return (${raw})`)(); } catch {}\n return raw;\n }\n case \"ast\":\n return <MDXClientContent ast={attr.value} components={components} />;\n default:\n return undefined;\n }\n}\n\nfunction extractText(node: AstNode): string {\n if (node.node_type === \"text\") return node.content ?? \"\";\n if (node.content) return node.content;\n return (node.children ?? []).map(extractText).join(\"\");\n}\n\nconst HTML_TAGS = new Set([\n \"a\",\"abbr\",\"article\",\"aside\",\"b\",\"blockquote\",\"br\",\"caption\",\"cite\",\"code\",\n \"col\",\"colgroup\",\"dd\",\"del\",\"details\",\"dfn\",\"div\",\"dl\",\"dt\",\"em\",\"figcaption\",\n \"figure\",\"footer\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"header\",\"hr\",\"i\",\"img\",\"ins\",\n \"kbd\",\"li\",\"main\",\"mark\",\"nav\",\"ol\",\"p\",\"pre\",\"q\",\"s\",\"section\",\"small\",\"span\",\n \"strong\",\"sub\",\"summary\",\"sup\",\"table\",\"tbody\",\"td\",\"tfoot\",\"th\",\"thead\",\"tr\",\n \"u\",\"ul\",\"var\",\n]);\n\nfunction renderNode(\n node: AstNode,\n index: number,\n components: MDXComponents,\n): ReactNode {\n const key = `${node.node_type}-${index}`;\n\n if (node.node_type === \"text\") return node.content ?? null;\n\n if (node.node_type === \"fragment\") {\n return (\n <React.Fragment key={key}>\n {node.children?.map((c, i) => renderNode(c, i, components))}\n </React.Fragment>\n );\n }\n\n // Math — rendered directly via KaTeX (static import)\n if (node.node_type === \"InlineMath\") {\n const formula = extractText(node);\n try {\n const html = katex.renderToString(formula, { displayMode: false, throwOnError: false, output: \"html\" });\n return <span key={key} className=\"math math-inline\" dangerouslySetInnerHTML={{ __html: html }} />;\n } catch {\n return <span key={key} className=\"math math-inline\">{formula}</span>;\n }\n }\n if (node.node_type === \"BlockMath\") {\n const formula = extractText(node);\n try {\n const html = katex.renderToString(formula, { displayMode: true, throwOnError: false, output: \"html\" });\n return <div key={key} className=\"math math-display\" dangerouslySetInnerHTML={{ __html: html }} />;\n } catch {\n return <div key={key} className=\"math math-display\">{formula}</div>;\n }\n }\n\n const resolvedProps: Record<string, any> = {};\n if (node.attributes) {\n const attrs = typeof node.attributes === \"string\" \n ? JSON.parse(node.attributes) \n : node.attributes;\n\n for (const [k, v] of Object.entries(attrs)) {\n resolvedProps[k] = resolveAttr(v as AttrValueKind, components);\n }\n }\n\n const renderedChildren = node.children?.length\n ? node.children.map((c, i) => renderNode(c, i, components))\n : (node.content ?? undefined);\n\n const Custom = components[node.node_type];\n if (Custom) {\n return (\n <MDXErrorBoundary key={key} componentName={node.node_type}>\n <Custom {...resolvedProps}>\n {renderedChildren}\n </Custom>\n </MDXErrorBoundary>\n );\n }\n\n if (HTML_TAGS.has(node.node_type)) {\n const Tag = node.node_type as any;\n return <Tag key={key} {...resolvedProps}>{renderedChildren}</Tag>;\n }\n\n if (process.env.NODE_ENV === \"development\") {\n console.warn(`[toaq-oss/omni-mdx] Unknown component: <${node.node_type}>`);\n }\n return (\n <div key={key} data-missing-component={node.node_type} className=\"mdx-missing-component\">\n {renderedChildren}\n </div>\n );\n}\n\nfunction MDXClientContent({\n ast,\n components,\n}: {\n ast: AstNode[];\n components: MDXComponents;\n}) {\n return <>{ast.map((node, i) => renderNode(node, i, components))}</>;\n}\n\ninterface MDXClientRendererProps {\n /** AST from parseMdx() — must be JSON-serialisable (pass via Server Component). */\n ast: AstNode[];\n /** Component registry — same shape as MDX_COMPONENTS. */\n components?: MDXComponents;\n}\n\nexport function MDXClientRenderer({\n ast,\n components = {},\n}: MDXClientRendererProps) {\n const rootRef = useRef<HTMLDivElement>(null);\n\n if (!ast || !Array.isArray(ast)) return null;\n\n const finalComponents = {\n ...BASIC_STYLES,\n ...components\n };\n\n return (\n <div className=\"omni-mdx-root\">\n <MDXClientContent ast={ast} components={finalComponents} />\n </div>\n );\n}","\"use client\";\nimport { Component, ErrorInfo, ReactNode } from 'react';\n\ninterface Props {\n children: ReactNode;\n /** The name of the MDX component being rendered (e.g., 'Chart', 'SplitLayout') */\n componentName?: string;\n}\n\ninterface State {\n hasError: boolean;\n error: Error | null;\n}\n\n/**\n * A dedicated Error Boundary for MDX rendering.\n *\n * If a React component injected via MDX crashes (e.g., due to a data parsing error \n * inside a <Chart />), this boundary intercepts the error. This prevents the \n * entire React tree from unmounting and displays a clean fallback UI to \n * isolate the defective component.\n */\nexport class MDXErrorBoundary extends Component<Props, State> {\n constructor(props: Props) {\n super(props);\n this.state = { hasError: false, error: null };\n }\n\n /**\n * Updates the state when an error occurs to trigger the fallback UI rendering.\n */\n static getDerivedStateFromError(error: Error): State {\n return { hasError: true, error };\n }\n\n /**\n * Intercepts the error and its contextual information.\n * This is the ideal place to hook into monitoring tools (like Sentry or Datadog) \n * for production environments.\n */\n componentDidCatch(error: Error, errorInfo: ErrorInfo) {\n console.error(\n `[MDXErrorBoundary] Error caught in component <${this.props.componentName || 'Unknown'}>:\\n`,\n error,\n errorInfo.componentStack\n );\n }\n \n render() {\n if (this.state.hasError) {\n // Fallback UI: A clean, isolated container that doesn't break the main layout\n return (\n <div style={{ padding: '1rem', border: '2px solid #ef4444', backgroundColor: '#fef2f2', borderRadius: '0.5rem', margin: '1rem 0' }}>\n <h3 style={{ color: '#b91c1c', fontWeight: 'bold', margin: 0 }}>\n Render Error : {this.props.componentName || 'Unknown Component'}\n </h3>\n <p style={{ color: '#dc2626', fontFamily: 'monospace', fontSize: '0.875rem' }}>\n {this.state.error?.message}\n </p>\n </div>\n );\n }\n return this.props.children;\n }\n}","import React from \"react\";\n\n// Styles defined to be usable in fallback condition.\nexport const BASIC_STYLES: Record<string, React.FC<any>> = {\n h1: (props) => <h1 className=\"text-3xl font-bold tracking-tight text-white mt-8 mb-4\" {...props} />,\n h2: (props) => <h2 className=\"text-2xl font-semibold tracking-tight text-neutral-100 mt-6 mb-3 border-b border-white/5 pb-2\" {...props} />,\n h3: (props) => <h3 className=\"text-xl font-medium text-neutral-200 mt-4 mb-2\" {...props} />,\n h4: (props) => <h4 className=\"text-lg font-medium text-neutral-300 mt-4 mb-2\" {...props} />,\n p: (props) => <p className=\"text-base leading-7 text-neutral-400 mb-4\" {...props} />,\n ul: (props) => <ul className=\"list-disc list-inside mb-4 space-y-1 text-neutral-400\" {...props} />,\n ol: (props) => <ol className=\"list-decimal list-inside mb-4 space-y-1 text-neutral-400\" {...props} />,\n li: (props) => <li className=\"ml-4\" {...props} />,\n code: (props) => {\n return <code className=\"inline-code bg-white/10 px-1.5 py-0.5 rounded text-pink-400 font-mono text-sm\" {...props} />;\n },\n blockquote: (props) => <blockquote className=\"border-l-4 border-blue-500/50 pl-4 italic text-neutral-500 my-6\" {...props} />,\n hr: () => <hr className=\"border-white/5 my-8\" />,\n table: (props) => <div className=\"overflow-x-auto mb-6\"><table className=\"w-full text-sm text-left border-collapse\" {...props} /></div>,\n th: (props) => <th className=\"border-b border-white/10 p-2 font-semibold text-neutral-200\" {...props} />,\n td: (props) => <td className=\"border-b border-white/5 p-2 text-neutral-400\" {...props} />,\n img: (props) => <img className=\"rounded-xl border border-white/10 my-8 mx-auto max-w-full h-auto\" {...props} />,\n a: (props) => <a className=\"text-blue-400 hover:text-blue-300 underline underline-offset-4 decoration-blue-500/30 transition-colors\" {...props} />,\n};","import type { AstNode, AttrValueKind } from \"../types/MdxAST\";\n\nconst NODE_TEXT = 0x01;\nconst NODE_ELEMENT = 0x02;\n\nconst ATTR_TEXT = 0x10;\nconst ATTR_EXPRESSION = 0x11;\nconst ATTR_BOOLEAN = 0x12;\nconst ATTR_AST = 0x13;\n\nexport class MdxBinaryDecoder {\n private view: DataView;\n private buffer: Uint8Array;\n private offset: number = 0;\n private decoder = new TextDecoder(\"utf-8\");\n private stringCache = new Map<string, string>();\n\n constructor(buffer: Uint8Array) {\n this.buffer = buffer;\n this.view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);\n }\n\n public decode(): AstNode[] {\n const rootCount = this.readU32();\n const nodes: AstNode[] = [];\n for (let i = 0; i < rootCount; i++) {\n nodes.push(this.decodeNode());\n }\n return nodes;\n }\n\n private decodeNode(): AstNode {\n const type = this.readU8();\n\n if (type === NODE_TEXT) {\n return {\n node_type: \"text\",\n content: this.readStringU32(),\n };\n }\n\n if (type === NODE_ELEMENT) {\n const node_type = this.readStringU16();\n const self_closing = this.readU8() === 1;\n const attrCount = this.readU16();\n \n let attributes: Record<string, AttrValueKind> | undefined = undefined;\n \n if (attrCount > 0) {\n attributes = {};\n for (let i = 0; i < attrCount; i++) {\n const key = this.readStringU16();\n const attrKind = this.readU8();\n \n if (attrKind === ATTR_TEXT) {\n attributes[key] = { kind: \"text\", value: this.readStringU32() };\n } else if (attrKind === ATTR_EXPRESSION) {\n attributes[key] = { kind: \"expression\", value: this.readStringU32() };\n } else if (attrKind === ATTR_BOOLEAN) {\n attributes[key] = { kind: \"boolean\" };\n } else if (attrKind === ATTR_AST) {\n const subNodeCount = this.readU32();\n const subNodes: AstNode[] = [];\n for (let j = 0; j < subNodeCount; j++) {\n subNodes.push(this.decodeNode());\n }\n attributes[key] = { kind: \"ast\", value: subNodes };\n }\n }\n }\n\n const childCount = this.readU32();\n const children: AstNode[] = [];\n if (childCount > 0) {\n for (let i = 0; i < childCount; i++) {\n children.push(this.decodeNode());\n }\n }\n\n return {\n node_type,\n self_closing,\n attributes,\n children,\n };\n }\n\n throw new Error(`[@toaq-oss/omni-mdx] Unknown binary opcode: ${type} at offset ${this.offset}`);\n }\n\n private readU8(): number {\n const val = this.view.getUint8(this.offset);\n this.offset += 1;\n return val;\n }\n\n private readU16(): number {\n const val = this.view.getUint16(this.offset, true);\n this.offset += 2;\n return val;\n }\n\n private readU32(): number {\n const val = this.view.getUint32(this.offset, true);\n this.offset += 4;\n return val;\n }\n\n private readStringU16(): string {\n const len = this.readU16();\n const str = this.decoder.decode(this.buffer.subarray(this.offset, this.offset + len));\n this.offset += len;\n\n let cached = this.stringCache.get(str);\n if (cached) return cached;\n this.stringCache.set(str, str);\n return str;\n }\n\n private readStringU32(): string {\n const len = this.readU32();\n const str = this.decoder.decode(this.buffer.subarray(this.offset, this.offset + len));\n this.offset += len;\n return str;\n }\n}","// parse.client.ts\n//\n// Client-side MDX parser using WASM (--target web build).\n// Designed for live editors and fully client-side rendering contexts.\n// Never runs on the server — returns [] immediately if called server-side.\n\nimport type { AstNode } from \"./types/MdxAST\";\nimport { MdxBinaryDecoder } from \"./utils/binaryDecoder\";\n\nlet initPromise: Promise<(mdx: Uint8Array) => Uint8Array> | null = null;\n\nfunction getClientParser(): Promise<(mdx: Uint8Array) => Uint8Array> {\n if (!initPromise) {\n initPromise = (async () => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const wasm: any = await import(\"../wasm/omni_mdx_core.js\");\n\n if (typeof wasm.default === \"function\") {\n const wasmUrl = new URL(\"./omni_mdx_core_bg.wasm\", import.meta.url);\n await wasm.default(wasmUrl);\n }\n\n return (mdx: Uint8Array): Uint8Array => wasm.parse_to_binary(mdx);\n })();\n }\n return initPromise;\n}\n\nfunction normalizeToUint8Array(input: any): Uint8Array {\n if (input instanceof Uint8Array) {\n return input;\n }\n if (typeof input === \"string\") {\n return new TextEncoder().encode(input);\n }\n if (input && typeof input === 'object' && input.type === 'Buffer' && Array.isArray(input.data)) {\n return new Uint8Array(input.data);\n }\n return new TextEncoder().encode(String(input));\n}\n\nexport async function parseMdxClient(mdx: string | Uint8Array): Promise<AstNode[]> {\n if (typeof window === \"undefined\") return [];\n\n try {\n const parse = await getClientParser();\n const inputBuffer = normalizeToUint8Array(mdx);\n const binaryAst = parse(inputBuffer);\n const decoder = new MdxBinaryDecoder(binaryAst);\n return decoder.decode();\n } catch (err) {\n const errorMessage = err instanceof Error ? err.message : String(err);\n \n throw new Error(`Syntax error in MDX: ${errorMessage}`);\n }\n}"],"mappings":";;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWO,SAAS,kBAAkB,OAAO;AACrC,MAAI;AACJ,MAAI;AACJ,MAAI;AACA,UAAM,OAAO,kBAAkB,OAAO,KAAK,mBAAmB,KAAK,kBAAkB;AACrF,UAAM,OAAO;AACb,UAAM,MAAM,KAAK,kBAAkB,MAAM,IAAI;AAC7C,QAAI,OAAO,IAAI,CAAC;AAChB,QAAI,OAAO,IAAI,CAAC;AAChB,QAAI,IAAI,CAAC,GAAG;AACR,aAAO;AAAG,aAAO;AACjB,YAAM,wBAAwB,IAAI,CAAC,CAAC;AAAA,IACxC;AACA,kBAAc;AACd,kBAAc;AACd,WAAO,mBAAmB,MAAM,IAAI;AAAA,EACxC,UAAE;AACE,SAAK,gBAAgB,aAAa,aAAa,CAAC;AAAA,EACpD;AACJ;AAUO,SAAS,yBAAyB,OAAO;AAC5C,MAAI;AACJ,MAAI;AACJ,MAAI;AACA,UAAM,OAAO,kBAAkB,OAAO,KAAK,mBAAmB,KAAK,kBAAkB;AACrF,UAAM,OAAO;AACb,UAAM,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;AACnE,MAAI,CAAC,aAAa;AAChB,mBAAe,YAAY;AAEzB,YAAMC,QAAY,MAAM;AAExB,UAAI,OAAOA,MAAK,YAAY,YAAY;AACtC,cAAM,UAAU,IAAI,IAAI,2BAA2B,YAAY,GAAG;AAClE,cAAMA,MAAK,QAAQ,OAAO;AAAA,MAC5B;AAEA,aAAO,CAAC,QAAgCA,MAAK,gBAAgB,GAAG;AAAA,IAClE,GAAG;AAAA,EACL;AACA,SAAO;AACT;AAEA,SAAS,sBAAsB,OAAwB;AACrD,MAAI,iBAAiB,YAAY;AAC/B,WAAO;AAAA,EACT;AACA,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO,IAAI,YAAY,EAAE,OAAO,KAAK;AAAA,EACvC;AACA,MAAI,SAAS,OAAO,UAAU,YAAY,MAAM,SAAS,YAAY,MAAM,QAAQ,MAAM,IAAI,GAAG;AAC9F,WAAO,IAAI,WAAW,MAAM,IAAI;AAAA,EAClC;AACA,SAAO,IAAI,YAAY,EAAE,OAAO,OAAO,KAAK,CAAC;AAC/C;AAEA,eAAsB,eAAe,KAA8C;AACjF,MAAI,OAAO,WAAW,YAAa,QAAO,CAAC;AAE3C,MAAI;AACF,UAAM,QAAQ,MAAM,gBAAgB;AACpC,UAAM,cAAc,sBAAsB,GAAG;AAC7C,UAAM,YAAY,MAAM,WAAW;AACnC,UAAM,UAAU,IAAI,iBAAiB,SAAS;AAC9C,WAAO,QAAQ,OAAO;AAAA,EACxB,SAAS,KAAK;AACZ,UAAM,eAAe,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAEpE,UAAM,IAAI,MAAM,wBAAwB,YAAY,EAAE;AAAA,EACxD;AACF;","names":["ptr","jsx","jsx","wasm"]}
Binary file
package/dist/server.js CHANGED
@@ -306,7 +306,32 @@ var MDXParseError = class extends Error {
306
306
  // src/MDXServerRenderer.tsx
307
307
  import React from "react";
308
308
  import katex from "katex";
309
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
309
+
310
+ // src/utils/basicStyles.tsx
311
+ import { jsx } from "react/jsx-runtime";
312
+ var BASIC_STYLES = {
313
+ h1: (props) => /* @__PURE__ */ jsx("h1", { className: "text-3xl font-bold tracking-tight text-white mt-8 mb-4", ...props }),
314
+ h2: (props) => /* @__PURE__ */ jsx("h2", { className: "text-2xl font-semibold tracking-tight text-neutral-100 mt-6 mb-3 border-b border-white/5 pb-2", ...props }),
315
+ h3: (props) => /* @__PURE__ */ jsx("h3", { className: "text-xl font-medium text-neutral-200 mt-4 mb-2", ...props }),
316
+ h4: (props) => /* @__PURE__ */ jsx("h4", { className: "text-lg font-medium text-neutral-300 mt-4 mb-2", ...props }),
317
+ p: (props) => /* @__PURE__ */ jsx("p", { className: "text-base leading-7 text-neutral-400 mb-4", ...props }),
318
+ ul: (props) => /* @__PURE__ */ jsx("ul", { className: "list-disc list-inside mb-4 space-y-1 text-neutral-400", ...props }),
319
+ ol: (props) => /* @__PURE__ */ jsx("ol", { className: "list-decimal list-inside mb-4 space-y-1 text-neutral-400", ...props }),
320
+ li: (props) => /* @__PURE__ */ jsx("li", { className: "ml-4", ...props }),
321
+ code: (props) => {
322
+ return /* @__PURE__ */ jsx("code", { className: "inline-code bg-white/10 px-1.5 py-0.5 rounded text-pink-400 font-mono text-sm", ...props });
323
+ },
324
+ blockquote: (props) => /* @__PURE__ */ jsx("blockquote", { className: "border-l-4 border-blue-500/50 pl-4 italic text-neutral-500 my-6", ...props }),
325
+ hr: () => /* @__PURE__ */ jsx("hr", { className: "border-white/5 my-8" }),
326
+ table: (props) => /* @__PURE__ */ jsx("div", { className: "overflow-x-auto mb-6", children: /* @__PURE__ */ jsx("table", { className: "w-full text-sm text-left border-collapse", ...props }) }),
327
+ th: (props) => /* @__PURE__ */ jsx("th", { className: "border-b border-white/10 p-2 font-semibold text-neutral-200", ...props }),
328
+ td: (props) => /* @__PURE__ */ jsx("td", { className: "border-b border-white/5 p-2 text-neutral-400", ...props }),
329
+ img: (props) => /* @__PURE__ */ jsx("img", { className: "rounded-xl border border-white/10 my-8 mx-auto max-w-full h-auto", ...props }),
330
+ a: (props) => /* @__PURE__ */ jsx("a", { className: "text-blue-400 hover:text-blue-300 underline underline-offset-4 decoration-blue-500/30 transition-colors", ...props })
331
+ };
332
+
333
+ // src/MDXServerRenderer.tsx
334
+ import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
310
335
  function resolveAttr(attr, components) {
311
336
  switch (attr.kind) {
312
337
  case "text":
@@ -326,7 +351,7 @@ function resolveAttr(attr, components) {
326
351
  return raw;
327
352
  }
328
353
  case "ast":
329
- return /* @__PURE__ */ jsx(
354
+ return /* @__PURE__ */ jsx2(
330
355
  MDXServerRenderer,
331
356
  {
332
357
  ast: attr.value,
@@ -421,7 +446,7 @@ function renderNode(node, index, components) {
421
446
  return node.content ?? null;
422
447
  }
423
448
  if (node.node_type === "fragment") {
424
- return /* @__PURE__ */ jsx(React.Fragment, { children: renderChildren(node, components) }, key);
449
+ return /* @__PURE__ */ jsx2(React.Fragment, { children: renderChildren(node, components) }, key);
425
450
  }
426
451
  if (node.node_type === "InlineMath") {
427
452
  const formula = extractText(node);
@@ -431,7 +456,7 @@ function renderNode(node, index, components) {
431
456
  throwOnError: false,
432
457
  output: "html"
433
458
  });
434
- return /* @__PURE__ */ jsx(
459
+ return /* @__PURE__ */ jsx2(
435
460
  "span",
436
461
  {
437
462
  className: "math math-inline",
@@ -440,7 +465,7 @@ function renderNode(node, index, components) {
440
465
  key
441
466
  );
442
467
  } catch {
443
- return /* @__PURE__ */ jsx("span", { className: "math math-inline", children: formula }, key);
468
+ return /* @__PURE__ */ jsx2("span", { className: "math math-inline", children: formula }, key);
444
469
  }
445
470
  }
446
471
  if (node.node_type === "BlockMath") {
@@ -451,7 +476,7 @@ function renderNode(node, index, components) {
451
476
  throwOnError: false,
452
477
  output: "html"
453
478
  });
454
- return /* @__PURE__ */ jsx(
479
+ return /* @__PURE__ */ jsx2(
455
480
  "div",
456
481
  {
457
482
  className: "math math-display",
@@ -460,7 +485,7 @@ function renderNode(node, index, components) {
460
485
  key
461
486
  );
462
487
  } catch {
463
- return /* @__PURE__ */ jsx("div", { className: "math math-display", children: formula }, key);
488
+ return /* @__PURE__ */ jsx2("div", { className: "math math-display", children: formula }, key);
464
489
  }
465
490
  }
466
491
  const resolvedProps = {};
@@ -474,7 +499,7 @@ function renderNode(node, index, components) {
474
499
  const Custom = components[node.node_type];
475
500
  if (Custom) {
476
501
  try {
477
- return /* @__PURE__ */ jsx(Custom, { ...resolvedProps, children: renderedChildren }, key);
502
+ return /* @__PURE__ */ jsx2(Custom, { ...resolvedProps, children: renderedChildren }, key);
478
503
  } catch (err) {
479
504
  if (process.env.NODE_ENV === "development") {
480
505
  console.error(`[toaq-oss/omni-mdx] Server render failed for <${node.node_type}>:`, err);
@@ -491,7 +516,7 @@ function renderNode(node, index, components) {
491
516
  node.node_type,
492
517
  ">"
493
518
  ] }),
494
- process.env.NODE_ENV === "development" && /* @__PURE__ */ jsx("pre", { style: { color: "#dc2626", fontSize: "0.875rem", marginTop: "0.5rem" }, children: String(err) })
519
+ process.env.NODE_ENV === "development" && /* @__PURE__ */ jsx2("pre", { style: { color: "#dc2626", fontSize: "0.875rem", marginTop: "0.5rem" }, children: String(err) })
495
520
  ]
496
521
  },
497
522
  key
@@ -503,10 +528,10 @@ function renderNode(node, index, components) {
503
528
  const hasThead = firstChild?.node_type === "thead";
504
529
  const theadNode = hasThead ? firstChild : null;
505
530
  const bodyRows = hasThead ? node.children.slice(1) : node.children ?? [];
506
- const theadEl = theadNode ? /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: theadNode.children?.map(
531
+ const theadEl = theadNode ? /* @__PURE__ */ jsx2("thead", { children: /* @__PURE__ */ jsx2("tr", { children: theadNode.children?.map(
507
532
  (cell, i) => renderNode({ ...cell, node_type: "th" }, i, components)
508
533
  ) }) }, "thead") : null;
509
- const tbodyEl = bodyRows.length > 0 ? /* @__PURE__ */ jsx("tbody", { children: bodyRows.map((row, i) => renderNode(row, i, components)) }, "tbody") : null;
534
+ const tbodyEl = bodyRows.length > 0 ? /* @__PURE__ */ jsx2("tbody", { children: bodyRows.map((row, i) => renderNode(row, i, components)) }, "tbody") : null;
510
535
  return /* @__PURE__ */ jsxs("table", { ...resolvedProps, children: [
511
536
  theadEl,
512
537
  tbodyEl
@@ -514,18 +539,18 @@ function renderNode(node, index, components) {
514
539
  }
515
540
  if (node.node_type === "pre") {
516
541
  const rawText = extractText(node);
517
- return /* @__PURE__ */ jsx("pre", { ...resolvedProps, children: /* @__PURE__ */ jsx("code", { children: rawText }) }, key);
542
+ return /* @__PURE__ */ jsx2("pre", { ...resolvedProps, children: /* @__PURE__ */ jsx2("code", { children: rawText }) }, key);
518
543
  }
519
544
  if (HTML_TAGS.has(node.node_type)) {
520
545
  const Tag = node.node_type;
521
- return /* @__PURE__ */ jsx(Tag, { ...resolvedProps, children: renderedChildren }, key);
546
+ return /* @__PURE__ */ jsx2(Tag, { ...resolvedProps, children: renderedChildren }, key);
522
547
  }
523
548
  if (process.env.NODE_ENV === "development") {
524
549
  console.warn(
525
550
  `[toaq-oss/omni-mdx] Unknown component: <${node.node_type}>. Register it via MDX_COMPONENTS or add it to your components prop.`
526
551
  );
527
552
  }
528
- return /* @__PURE__ */ jsx("div", { "data-missing-component": node.node_type, className: "mdx-missing-component", children: renderedChildren }, key);
553
+ return /* @__PURE__ */ jsx2("div", { "data-missing-component": node.node_type, className: "mdx-missing-component", children: renderedChildren }, key);
529
554
  }
530
555
  function renderChildren(node, components) {
531
556
  if (!node.children?.length) return [];
@@ -536,9 +561,13 @@ function MDXServerRenderer({
536
561
  components = {}
537
562
  }) {
538
563
  if (!ast || !Array.isArray(ast)) {
539
- return /* @__PURE__ */ jsx(Fragment, {});
564
+ return /* @__PURE__ */ jsx2(Fragment, {});
540
565
  }
541
- return /* @__PURE__ */ jsx("div", { className: "omni-mdx-root", children: ast.map((node, i) => renderNode(node, i, components)) });
566
+ const finalComponents = {
567
+ ...BASIC_STYLES,
568
+ ...components
569
+ };
570
+ return /* @__PURE__ */ jsx2("div", { className: "omni-mdx-root", children: ast.map((node, i) => renderNode(node, i, finalComponents)) });
542
571
  }
543
572
  export {
544
573
  MDXParseError,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/parse.server.ts","../src/utils/binaryDecoder.ts","../src/MDXServerRenderer.tsx"],"sourcesContent":["import type { AstNode } from \"./types/MdxAST\";\nimport { createRequire } from \"module\";\nimport { fileURLToPath } from \"url\";\nimport { dirname, resolve } from \"path\";\nimport { MdxBinaryDecoder } from \"./utils/binaryDecoder\";\nimport { MdxInput } from \"./types/MdxInput\";\n\ndeclare const __non_webpack_require__: NodeRequire | undefined;\n\nconst _require = createRequire(import.meta.url);\nconst nativeRequire: NodeRequire =\n typeof __non_webpack_require__ !== \"undefined\"\n ? __non_webpack_require__\n : _require;\n\nlet _nativeModule: any = null;\n\nfunction getNativeModuleSync():any {\n if (_nativeModule) return _nativeModule;\n\n const platformPackages = [\n \"@toaq-oss/omni-mdx-darwin-arm64\",\n \"@toaq-oss/omni-mdx-darwin-x64\",\n \"@toaq-oss/omni-mdx-linux-x64-gnu\",\n \"@toaq-oss/omni-mdx-win32-x64-msvc\",\n ];\n\n for (const pkg of platformPackages) {\n try {\n const native = nativeRequire(pkg);\n if (\n typeof native.parseToBinary === \"function\" ||\n typeof native.parse_to_binary === \"function\" ||\n typeof native.parseToJson === \"function\" ||\n typeof native.parse_to_json === \"function\"\n ) {\n _nativeModule = native;\n return _nativeModule;\n }\n } catch { /* not installed on this platform */ }\n }\n\n // Local Fallback\n try {\n const __dir = dirname(fileURLToPath(import.meta.url));\n const nativeDir = resolve(__dir, \"../native\");\n const fs = nativeRequire(\"fs\") as typeof import(\"fs\");\n\n if (fs.existsSync(nativeDir)) {\n const files = fs.readdirSync(nativeDir).filter((f: string) => f.endsWith(\".node\"));\n const platform = process.platform ?? \"\";\n const arch = process.arch ?? \"\";\n const match = files.find((f: string) => f.includes(platform) && f.includes(arch))\n ?? files[0];\n\n if (match) {\n const native = nativeRequire(resolve(nativeDir, match));\n _nativeModule = native;\n if (typeof native.parseToJson === \"function\") {\n return _nativeModule;\n } else if (typeof native.parse_to_json === \"function\") {\n return _nativeModule;\n }\n }\n }\n } catch { /* native/ missing */ }\n\n throw new Error(\n `[toaq-oss/omni-mdx] Native parser not found for this platform.\\n` +\n ` Tried npm packages: ${platformPackages.join(\", \")}\\n` +\n ` ➜ Install the prebuilt package (once published):\\n` +\n ` npm install @toaq-oss/omni-mdx-darwin-arm64 # Mac M1/M2\\n` +\n ` npm install @toaq-oss/omni-mdx-linux-x64-gnu # Linux/Vercel\\n` +\n ` npm install @toaq-oss/omni-mdx-win32-x64-msvc # Windows\\n`\n );\n}\n\nfunction getParseFn(native: any): (mdx: string | Buffer | Uint8Array) => any {\n if (typeof native.parseToBinary === \"function\") return native.parseToBinary;\n if (typeof native.parse_to_binary === \"function\") return native.parse_to_binary;\n if (typeof native.parse === \"function\") return native.parse;\n if (typeof native.parseToJson === \"function\") return native.parseToJson;\n if (typeof native.parse_to_json === \"function\") return native.parse_to_json;\n\n throw new Error(\"[toaq-oss/omni-mdx] Native parser lacks a valid parse function.\");\n}\n\nfunction normalizeToBuffer(input: any): Buffer {\n if (Buffer.isBuffer(input)) return input;\n if (input instanceof Uint8Array) return Buffer.from(input.buffer, input.byteOffset, input.byteLength);\n if (input && typeof input === 'object' && input.type === 'Buffer' && Array.isArray(input.data)) {\n return Buffer.from(input.data);\n }\n return Buffer.from(String(input), 'utf-8');\n}\n\nexport async function parseMdx(mdx: MdxInput): Promise<AstNode[]> {\n const native = getNativeModuleSync();\n let result: any;\n \n try {\n if (typeof mdx === 'string') {\n const parseStr = native.parse || native.parseToJson || native.parse_to_json;\n if (!parseStr) throw new Error(\"Native string parser missing.\");\n result = parseStr(mdx);\n } else {\n const buf = normalizeToBuffer(mdx);\n const parseBin = native.parseToBinary || native.parse_to_binary;\n \n if (parseBin) {\n result = parseBin(buf);\n } else {\n const parseStr = native.parse || native.parseToJson || native.parse_to_json;\n result = parseStr(buf.toString('utf-8'));\n }\n }\n } catch (err: any) {\n const sourceSnippet = typeof mdx === 'string' ? mdx.slice(0, 50) : \"Binary Data\";\n throw new MDXParseError(err?.message ?? String(err), sourceSnippet);\n }\n \n\n if (result instanceof Uint8Array || Buffer.isBuffer(result)) {\n const decoder = new MdxBinaryDecoder(result);\n return decoder.decode();\n }\n\n if (typeof result === \"string\") {\n try { return JSON.parse(result) as AstNode[]; } catch { throw new Error(\"Invalid JSON string.\"); }\n }\n\n if (typeof result === \"object\" && result !== null) {\n if (typeof result.toJson === \"function\") {\n try {\n const jsonString = result.toJson();\n return JSON.parse(jsonString) as AstNode[];\n } catch (e) {\n throw new Error(\"[toaq-oss/omni-mdx] Failed to serialize MdxAst to JSON.\");\n }\n }\n \n if (typeof result.to_json === \"function\") {\n try { return JSON.parse(result.to_json()) as AstNode[]; } catch (e) {}\n }\n \n if (Array.isArray(result)) return result as AstNode[];\n }\n\n throw new Error(\"[toaq-oss/omni-mdx] Unrecognized return format from Rust parser. Available properties: \" + Object.keys(result.__proto__ || result).join(\", \"));\n}\n\nexport function parseMdxSync(mdx: MdxInput): AstNode[] {\n const native = getNativeModuleSync();\n let result: any;\n\n try {\n if (typeof mdx === 'string') {\n const parseStr = native.parse || native.parseToJson || native.parse_to_json;\n result = parseStr(mdx);\n } else {\n const buf = normalizeToBuffer(mdx);\n const parseBin = native.parseToBinary || native.parse_to_binary;\n if (parseBin) {\n result = parseBin(buf);\n } else {\n const parseStr = native.parse || native.parseToJson || native.parse_to_json;\n result = parseStr(buf.toString('utf-8'));\n }\n }\n } catch (err: any) {\n const sourceSnippet = typeof mdx === 'string' ? mdx.slice(0, 50) : \"Binary Data\";\n throw new MDXParseError(err?.message ?? String(err), sourceSnippet);\n }\n\n if (result instanceof Uint8Array || Buffer.isBuffer(result)) {\n const decoder = new MdxBinaryDecoder(result);\n return decoder.decode();\n }\n \n if (typeof result === \"string\") {\n try { return JSON.parse(result) as AstNode[]; } catch { throw new Error(\"Invalid JSON\"); }\n }\n\n if (typeof result === \"object\" && result !== null && typeof result.toJson === \"function\") {\n try { return JSON.parse(result.toJson()) as AstNode[]; } catch { throw new Error(\"Invalid JSON\"); }\n }\n\n if (typeof result === \"object\" && result !== null && typeof result.to_json === \"function\") {\n try { return JSON.parse(result.to_json()) as AstNode[]; } catch { throw new Error(\"Invalid JSON\"); }\n }\n\n throw new Error(\"[toaq-oss/omni-mdx] Unrecognized return format from Rust parser.\");\n}\n\nexport async function compileToJsx(mdx: MdxInput): Promise<string> {\n const native = getNativeModuleSync();\n const compileFn = native.compileToJsx || native.compile_to_jsx;\n \n if (typeof compileFn !== \"function\") {\n throw new Error(\"[toaq-oss/omni-mdx] compileToJsx is not supported by this native module version.\");\n }\n \n try {\n const buf = normalizeToBuffer(mdx);\n return compileFn(buf);\n } catch (err: any) {\n throw new MDXParseError(err?.message ?? String(err), \"Binary Data\");\n }\n}\n\nexport function compileToJsxSync(mdx: MdxInput): string {\n const native = getNativeModuleSync();\n const compileFn = native.compileToJsx || native.compile_to_jsx;\n \n if (typeof compileFn !== \"function\") {\n throw new Error(\"[toaq-oss/omni-mdx] compileToJsx is not supported by this native module version.\");\n }\n \n try {\n const buf = normalizeToBuffer(mdx);\n return compileFn(buf);\n } catch (err: any) {\n throw new MDXParseError(err?.message ?? String(err), \"Binary Data\");\n }\n}\n\nexport class MDXParseError extends Error {\n readonly source: string;\n constructor(message: string, source: string) {\n super(`MDX parse error: ${message}`);\n this.name = \"MDXParseError\";\n this.source = source;\n }\n}","import type { AstNode, AttrValueKind } from \"../types/MdxAST\";\n\nconst NODE_TEXT = 0x01;\nconst NODE_ELEMENT = 0x02;\n\nconst ATTR_TEXT = 0x10;\nconst ATTR_EXPRESSION = 0x11;\nconst ATTR_BOOLEAN = 0x12;\nconst ATTR_AST = 0x13;\n\nexport class MdxBinaryDecoder {\n private view: DataView;\n private buffer: Uint8Array;\n private offset: number = 0;\n private decoder = new TextDecoder(\"utf-8\");\n private stringCache = new Map<string, string>();\n\n constructor(buffer: Uint8Array) {\n this.buffer = buffer;\n this.view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);\n }\n\n public decode(): AstNode[] {\n const rootCount = this.readU32();\n const nodes: AstNode[] = [];\n for (let i = 0; i < rootCount; i++) {\n nodes.push(this.decodeNode());\n }\n return nodes;\n }\n\n private decodeNode(): AstNode {\n const type = this.readU8();\n\n if (type === NODE_TEXT) {\n return {\n node_type: \"text\",\n content: this.readStringU32(),\n };\n }\n\n if (type === NODE_ELEMENT) {\n const node_type = this.readStringU16();\n const self_closing = this.readU8() === 1;\n const attrCount = this.readU16();\n \n let attributes: Record<string, AttrValueKind> | undefined = undefined;\n \n if (attrCount > 0) {\n attributes = {};\n for (let i = 0; i < attrCount; i++) {\n const key = this.readStringU16();\n const attrKind = this.readU8();\n \n if (attrKind === ATTR_TEXT) {\n attributes[key] = { kind: \"text\", value: this.readStringU32() };\n } else if (attrKind === ATTR_EXPRESSION) {\n attributes[key] = { kind: \"expression\", value: this.readStringU32() };\n } else if (attrKind === ATTR_BOOLEAN) {\n attributes[key] = { kind: \"boolean\" };\n } else if (attrKind === ATTR_AST) {\n const subNodeCount = this.readU32();\n const subNodes: AstNode[] = [];\n for (let j = 0; j < subNodeCount; j++) {\n subNodes.push(this.decodeNode());\n }\n attributes[key] = { kind: \"ast\", value: subNodes };\n }\n }\n }\n\n const childCount = this.readU32();\n const children: AstNode[] = [];\n if (childCount > 0) {\n for (let i = 0; i < childCount; i++) {\n children.push(this.decodeNode());\n }\n }\n\n return {\n node_type,\n self_closing,\n attributes,\n children,\n };\n }\n\n throw new Error(`[@toaq-oss/omni-mdx] Unknown binary opcode: ${type} at offset ${this.offset}`);\n }\n\n private readU8(): number {\n const val = this.view.getUint8(this.offset);\n this.offset += 1;\n return val;\n }\n\n private readU16(): number {\n const val = this.view.getUint16(this.offset, true);\n this.offset += 2;\n return val;\n }\n\n private readU32(): number {\n const val = this.view.getUint32(this.offset, true);\n this.offset += 4;\n return val;\n }\n\n private readStringU16(): string {\n const len = this.readU16();\n const str = this.decoder.decode(this.buffer.subarray(this.offset, this.offset + len));\n this.offset += len;\n\n let cached = this.stringCache.get(str);\n if (cached) return cached;\n this.stringCache.set(str, str);\n return str;\n }\n\n private readStringU32(): string {\n const len = this.readU32();\n const str = this.decoder.decode(this.buffer.subarray(this.offset, this.offset + len));\n this.offset += len;\n return str;\n }\n}","/**\n * MDXServerRenderer.tsx\n *\n * React Server Component — renders an MDX AST on the server.\n * No \"use client\" — safe for Next.js SSR, SSG, and ISR.\n *\n * Drop-in replacement for <MDXRemote source={...} components={MDX_COMPONENTS} />\n *\n * Usage in a Server Component (page.tsx):\n *\n * import { MDXServerRenderer, parseMdx } from '@toaq/omni-mdx/server';\n * import { MDX_COMPONENTS } from './MDXComponents';\n *\n * export default async function Page() {\n * const ast = await parseMdx(mdxString);\n * return <MDXServerRenderer ast={ast} components={MDX_COMPONENTS} />;\n * }\n */\n\nimport React, { ReactNode, JSX } from \"react\";\nimport katex from \"katex\";\nimport type { AttrValueKind, AstNode, MDXComponents } from \"./types/MdxAST\";\n/**\n * Converts a raw AttrValueKind from the Rust AST into a React-usable prop value.\n * text → string\n * expression → attempt JSON/JS parse, fallback to string\n * boolean → true\n * ast → <MDXServerRenderer ast={...} components={...} />\n */\nfunction resolveAttr(\n attr: AttrValueKind,\n components: MDXComponents,\n): React.ReactNode | string | boolean {\n switch (attr.kind) {\n case \"text\":\n return attr.value;\n\n case \"boolean\":\n return true;\n\n case \"expression\": {\n const raw = attr.value.trim();\n // Try JSON first (safe), then JS expression as last resort\n try { return JSON.parse(raw); } catch {}\n try { return new Function(`return (${raw})`)(); } catch {}\n return raw;\n }\n\n case \"ast\":\n return (\n <MDXServerRenderer\n ast={attr.value}\n components={components}\n />\n );\n\n default:\n return undefined;\n }\n}\n\nconst HTML_TAGS = new Set([\n \"a\",\"abbr\",\"address\",\"article\",\"aside\",\"b\",\"bdi\",\"bdo\",\"blockquote\",\"br\",\n \"caption\",\"cite\",\"code\",\"col\",\"colgroup\",\"data\",\"dd\",\"del\",\"details\",\"dfn\",\n \"div\",\"dl\",\"dt\",\"em\",\"figcaption\",\"figure\",\"footer\",\"h1\",\"h2\",\"h3\",\"h4\",\n \"h5\",\"h6\",\"header\",\"hr\",\"i\",\"img\",\"ins\",\"kbd\",\"li\",\"main\",\"mark\",\"nav\",\"ol\",\n \"p\",\"pre\",\"q\",\"rp\",\"rt\",\"ruby\",\"s\",\"samp\",\"section\",\"small\",\"span\",\"strong\",\n \"sub\",\"summary\",\"sup\",\"table\",\"tbody\",\"td\",\"tfoot\",\"th\",\"thead\",\"time\",\"tr\",\n \"u\",\"ul\",\"var\",\"wbr\",\n]);\n\nfunction extractText(node: AstNode): string {\n if (node.node_type === \"text\") return node.content ?? \"\";\n if (node.content) return node.content;\n return (node.children ?? []).map(extractText).join(\"\");\n}\n\nfunction renderNode(\n node: AstNode,\n index: number,\n components: MDXComponents,\n): ReactNode {\n const key = `${node.node_type}-${index}`;\n\n if (node.node_type === \"text\") {\n return node.content ?? null;\n }\n\n if (node.node_type === \"fragment\") {\n return (\n <React.Fragment key={key}>\n {renderChildren(node, components)}\n </React.Fragment>\n );\n }\n\n // Math — server-side rendering via KaTeX (static HTML, no client-side JavaScript)\n if (node.node_type === \"InlineMath\") {\n const formula = extractText(node);\n\n try {\n const html = katex.renderToString(formula, {\n displayMode: false,\n throwOnError: false,\n output: \"html\",\n });\n return (\n <span\n key={key}\n className=\"math math-inline\"\n dangerouslySetInnerHTML={{ __html: html }}\n />\n );\n } catch {\n return <span key={key} className=\"math math-inline\">{formula}</span>;\n }\n }\n\n if (node.node_type === \"BlockMath\") {\n const formula = extractText(node);\n\n try {\n const html = katex.renderToString(formula, {\n displayMode: true,\n throwOnError: false,\n output: \"html\",\n });\n return (\n <div\n key={key}\n className=\"math math-display\"\n dangerouslySetInnerHTML={{ __html: html }}\n />\n );\n } catch {\n return <div key={key} className=\"math math-display\">{formula}</div>;\n }\n }\n\n // Resolve props from AST attributes\n const resolvedProps: Record<string, any> = {};\n if (node.attributes) {\n const attrs = typeof node.attributes === \"string\" \n ? JSON.parse(node.attributes) \n : node.attributes;\n\n for (const [k, v] of Object.entries(attrs)) {\n resolvedProps[k] = resolveAttr(v as AttrValueKind, components);\n }\n }\n\n const renderedChildren = node.children && node.children.length > 0\n ? renderChildren(node, components)\n : (node.content ?? undefined);\n\n // Custom registered component\n const Custom = components[node.node_type];\n if (Custom) {\n try {\n return (\n <Custom key={key} {...resolvedProps}>\n {renderedChildren}\n </Custom>\n );\n } catch (err) {\n if (process.env.NODE_ENV === \"development\") {\n console.error(`[toaq-oss/omni-mdx] Server render failed for <${node.node_type}>:`, err);\n }\n return (\n <div\n key={key}\n className=\"mdx-component-error\"\n data-component={node.node_type}\n style={{ padding: \"1rem\", border: \"2px solid #ef4444\", borderRadius: \"0.5rem\", margin: \"1rem 0\", background: \"#fef2f2\" }}\n >\n <strong style={{ color: \"#b91c1c\" }}>Render error: &lt;{node.node_type}&gt;</strong>\n {process.env.NODE_ENV === \"development\" && (\n <pre style={{ color: \"#dc2626\", fontSize: \"0.875rem\", marginTop: \"0.5rem\" }}>\n {String(err)}\n </pre>\n )}\n </div>\n );\n }\n }\n\n if (node.node_type === \"table\") {\n const firstChild = node.children?.[0];\n const hasThead = firstChild?.node_type === \"thead\";\n const theadNode = hasThead ? firstChild : null;\n const bodyRows = hasThead ? node.children!.slice(1) : node.children ?? [];\n\n const theadEl = theadNode ? (\n <thead key=\"thead\">\n <tr>\n {theadNode.children?.map((cell, i) =>\n renderNode({ ...cell, node_type: \"th\" }, i, components)\n )}\n </tr>\n </thead>\n ) : null;\n\n const tbodyEl = bodyRows.length > 0 ? (\n <tbody key=\"tbody\">\n {bodyRows.map((row, i) => renderNode(row, i, components))}\n </tbody>\n ) : null;\n\n return <table key={key} {...resolvedProps}>{theadEl}{tbodyEl}</table>;\n }\n\n if (node.node_type === \"pre\") {\n const rawText = extractText(node);\n return <pre key={key} {...resolvedProps}><code>{rawText}</code></pre>;\n }\n\n if (HTML_TAGS.has(node.node_type)) {\n const Tag = node.node_type as keyof JSX.IntrinsicElements;\n return (\n <Tag key={key} {...resolvedProps}>\n {renderedChildren}\n </Tag>\n );\n }\n\n if (process.env.NODE_ENV === \"development\") {\n console.warn(\n `[toaq-oss/omni-mdx] Unknown component: <${node.node_type}>. ` +\n `Register it via MDX_COMPONENTS or add it to your components prop.`\n );\n }\n return (\n <div key={key} data-missing-component={node.node_type} className=\"mdx-missing-component\">\n {renderedChildren}\n </div>\n );\n}\n\nfunction renderChildren(node: AstNode, components: MDXComponents): ReactNode[] {\n if (!node.children?.length) return [];\n return node.children.map((child, i) => renderNode(child, i, components));\n}\n\ninterface MDXServerRendererProps {\n /** AST produced by parseMdx() — JSON-serialisable. */\n ast: AstNode[];\n /**\n * Component registry. Keys are JSX tag names (e.g. \"Note\", \"Details\").\n * Values are React components (Server or Client).\n *\n * Server Components render on the server (recommended for static content).\n * Client Components receive \"use client\" and hydrate in the browser.\n */\n components?: MDXComponents;\n}\n\nexport function MDXServerRenderer({\n ast,\n components = {},\n}: MDXServerRendererProps): JSX.Element {\n if (!ast || !Array.isArray(ast)) {\n return <></>;\n }\n\n return (\n <div className=\"omni-mdx-root\">\n {ast.map((node, i) => renderNode(node, i, components))}\n </div>\n );\n}"],"mappings":";AACA,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAC9B,SAAS,SAAS,eAAe;;;ACDjC,IAAM,YAAY;AAClB,IAAM,eAAe;AAErB,IAAM,YAAY;AAClB,IAAM,kBAAkB;AACxB,IAAM,eAAe;AACrB,IAAM,WAAW;AAEV,IAAM,mBAAN,MAAuB;AAAA,EAO5B,YAAY,QAAoB;AAJhC,SAAQ,SAAiB;AACzB,SAAQ,UAAU,IAAI,YAAY,OAAO;AACzC,SAAQ,cAAc,oBAAI,IAAoB;AAG5C,SAAK,SAAS;AACd,SAAK,OAAO,IAAI,SAAS,O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YAAQ;AAAA,MACN,2CAA2C,KAAK,SAAS;AAAA,IAE3D;AAAA,EACF;AACA,SACE,oBAAC,SAAc,0BAAwB,KAAK,WAAW,WAAU,yBAC9D,8BADO,GAEV;AAEJ;AAEA,SAAS,eAAe,MAAe,YAAwC;AAC7E,MAAI,CAAC,KAAK,UAAU,OAAQ,QAAO,CAAC;AACpC,SAAO,KAAK,SAAS,IAAI,CAAC,OAAO,MAAM,WAAW,OAAO,GAAG,UAAU,CAAC;AACzE;AAeO,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA,aAAa,CAAC;AAChB,GAAwC;AACtC,MAAI,CAAC,OAAO,CAAC,MAAM,QAAQ,GAAG,GAAG;AAC/B,WAAO,gCAAE;AAAA,EACX;AAEA,SACE,oBAAC,SAAI,WAAU,iBACZ,cAAI,IAAI,CAAC,MAAM,MAAM,WAAW,MAAM,GAAG,UAAU,CAAC,GACvD;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../src/parse.server.ts","../src/utils/binaryDecoder.ts","../src/MDXServerRenderer.tsx","../src/utils/basicStyles.tsx"],"sourcesContent":["import type { AstNode } from \"./types/MdxAST\";\nimport { createRequire } from \"module\";\nimport { fileURLToPath } from \"url\";\nimport { dirname, resolve } from \"path\";\nimport { MdxBinaryDecoder } from \"./utils/binaryDecoder\";\nimport { MdxInput } from \"./types/MdxInput\";\n\ndeclare const __non_webpack_require__: NodeRequire | undefined;\n\nconst _require = createRequire(import.meta.url);\nconst nativeRequire: NodeRequire =\n typeof __non_webpack_require__ !== \"undefined\"\n ? __non_webpack_require__\n : _require;\n\nlet _nativeModule: any = null;\n\nfunction getNativeModuleSync():any {\n if (_nativeModule) return _nativeModule;\n\n const platformPackages = [\n \"@toaq-oss/omni-mdx-darwin-arm64\",\n \"@toaq-oss/omni-mdx-darwin-x64\",\n \"@toaq-oss/omni-mdx-linux-x64-gnu\",\n \"@toaq-oss/omni-mdx-win32-x64-msvc\",\n ];\n\n for (const pkg of platformPackages) {\n try {\n const native = nativeRequire(pkg);\n if (\n typeof native.parseToBinary === \"function\" ||\n typeof native.parse_to_binary === \"function\" ||\n typeof native.parseToJson === \"function\" ||\n typeof native.parse_to_json === \"function\"\n ) {\n _nativeModule = native;\n return _nativeModule;\n }\n } catch { /* not installed on this platform */ }\n }\n\n // Local Fallback\n try {\n const __dir = dirname(fileURLToPath(import.meta.url));\n const nativeDir = resolve(__dir, \"../native\");\n const fs = nativeRequire(\"fs\") as typeof import(\"fs\");\n\n if (fs.existsSync(nativeDir)) {\n const files = fs.readdirSync(nativeDir).filter((f: string) => f.endsWith(\".node\"));\n const platform = process.platform ?? \"\";\n const arch = process.arch ?? \"\";\n const match = files.find((f: string) => f.includes(platform) && f.includes(arch))\n ?? files[0];\n\n if (match) {\n const native = nativeRequire(resolve(nativeDir, match));\n _nativeModule = native;\n if (typeof native.parseToJson === \"function\") {\n return _nativeModule;\n } else if (typeof native.parse_to_json === \"function\") {\n return _nativeModule;\n }\n }\n }\n } catch { /* native/ missing */ }\n\n throw new Error(\n `[toaq-oss/omni-mdx] Native parser not found for this platform.\\n` +\n ` Tried npm packages: ${platformPackages.join(\", \")}\\n` +\n ` ➜ Install the prebuilt package (once published):\\n` +\n ` npm install @toaq-oss/omni-mdx-darwin-arm64 # Mac M1/M2\\n` +\n ` npm install @toaq-oss/omni-mdx-linux-x64-gnu # Linux/Vercel\\n` +\n ` npm install @toaq-oss/omni-mdx-win32-x64-msvc # Windows\\n`\n );\n}\n\nfunction getParseFn(native: any): (mdx: string | Buffer | Uint8Array) => any {\n if (typeof native.parseToBinary === \"function\") return native.parseToBinary;\n if (typeof native.parse_to_binary === \"function\") return native.parse_to_binary;\n if (typeof native.parse === \"function\") return native.parse;\n if (typeof native.parseToJson === \"function\") return native.parseToJson;\n if (typeof native.parse_to_json === \"function\") return native.parse_to_json;\n\n throw new Error(\"[toaq-oss/omni-mdx] Native parser lacks a valid parse function.\");\n}\n\nfunction normalizeToBuffer(input: any): Buffer {\n if (Buffer.isBuffer(input)) return input;\n if (input instanceof Uint8Array) return Buffer.from(input.buffer, input.byteOffset, input.byteLength);\n if (input && typeof input === 'object' && input.type === 'Buffer' && Array.isArray(input.data)) {\n return Buffer.from(input.data);\n }\n return Buffer.from(String(input), 'utf-8');\n}\n\nexport async function parseMdx(mdx: MdxInput): Promise<AstNode[]> {\n const native = getNativeModuleSync();\n let result: any;\n \n try {\n if (typeof mdx === 'string') {\n const parseStr = native.parse || native.parseToJson || native.parse_to_json;\n if (!parseStr) throw new Error(\"Native string parser missing.\");\n result = parseStr(mdx);\n } else {\n const buf = normalizeToBuffer(mdx);\n const parseBin = native.parseToBinary || native.parse_to_binary;\n \n if (parseBin) {\n result = parseBin(buf);\n } else {\n const parseStr = native.parse || native.parseToJson || native.parse_to_json;\n result = parseStr(buf.toString('utf-8'));\n }\n }\n } catch (err: any) {\n const sourceSnippet = typeof mdx === 'string' ? mdx.slice(0, 50) : \"Binary Data\";\n throw new MDXParseError(err?.message ?? String(err), sourceSnippet);\n }\n \n\n if (result instanceof Uint8Array || Buffer.isBuffer(result)) {\n const decoder = new MdxBinaryDecoder(result);\n return decoder.decode();\n }\n\n if (typeof result === \"string\") {\n try { return JSON.parse(result) as AstNode[]; } catch { throw new Error(\"Invalid JSON string.\"); }\n }\n\n if (typeof result === \"object\" && result !== null) {\n if (typeof result.toJson === \"function\") {\n try {\n const jsonString = result.toJson();\n return JSON.parse(jsonString) as AstNode[];\n } catch (e) {\n throw new Error(\"[toaq-oss/omni-mdx] Failed to serialize MdxAst to JSON.\");\n }\n }\n \n if (typeof result.to_json === \"function\") {\n try { return JSON.parse(result.to_json()) as AstNode[]; } catch (e) {}\n }\n \n if (Array.isArray(result)) return result as AstNode[];\n }\n\n throw new Error(\"[toaq-oss/omni-mdx] Unrecognized return format from Rust parser. Available properties: \" + Object.keys(result.__proto__ || result).join(\", \"));\n}\n\nexport function parseMdxSync(mdx: MdxInput): AstNode[] {\n const native = getNativeModuleSync();\n let result: any;\n\n try {\n if (typeof mdx === 'string') {\n const parseStr = native.parse || native.parseToJson || native.parse_to_json;\n result = parseStr(mdx);\n } else {\n const buf = normalizeToBuffer(mdx);\n const parseBin = native.parseToBinary || native.parse_to_binary;\n if (parseBin) {\n result = parseBin(buf);\n } else {\n const parseStr = native.parse || native.parseToJson || native.parse_to_json;\n result = parseStr(buf.toString('utf-8'));\n }\n }\n } catch (err: any) {\n const sourceSnippet = typeof mdx === 'string' ? mdx.slice(0, 50) : \"Binary Data\";\n throw new MDXParseError(err?.message ?? String(err), sourceSnippet);\n }\n\n if (result instanceof Uint8Array || Buffer.isBuffer(result)) {\n const decoder = new MdxBinaryDecoder(result);\n return decoder.decode();\n }\n \n if (typeof result === \"string\") {\n try { return JSON.parse(result) as AstNode[]; } catch { throw new Error(\"Invalid JSON\"); }\n }\n\n if (typeof result === \"object\" && result !== null && typeof result.toJson === \"function\") {\n try { return JSON.parse(result.toJson()) as AstNode[]; } catch { throw new Error(\"Invalid JSON\"); }\n }\n\n if (typeof result === \"object\" && result !== null && typeof result.to_json === \"function\") {\n try { return JSON.parse(result.to_json()) as AstNode[]; } catch { throw new Error(\"Invalid JSON\"); }\n }\n\n throw new Error(\"[toaq-oss/omni-mdx] Unrecognized return format from Rust parser.\");\n}\n\nexport async function compileToJsx(mdx: MdxInput): Promise<string> {\n const native = getNativeModuleSync();\n const compileFn = native.compileToJsx || native.compile_to_jsx;\n \n if (typeof compileFn !== \"function\") {\n throw new Error(\"[toaq-oss/omni-mdx] compileToJsx is not supported by this native module version.\");\n }\n \n try {\n const buf = normalizeToBuffer(mdx);\n return compileFn(buf);\n } catch (err: any) {\n throw new MDXParseError(err?.message ?? String(err), \"Binary Data\");\n }\n}\n\nexport function compileToJsxSync(mdx: MdxInput): string {\n const native = getNativeModuleSync();\n const compileFn = native.compileToJsx || native.compile_to_jsx;\n \n if (typeof compileFn !== \"function\") {\n throw new Error(\"[toaq-oss/omni-mdx] compileToJsx is not supported by this native module version.\");\n }\n \n try {\n const buf = normalizeToBuffer(mdx);\n return compileFn(buf);\n } catch (err: any) {\n throw new MDXParseError(err?.message ?? String(err), \"Binary Data\");\n }\n}\n\nexport class MDXParseError extends Error {\n readonly source: string;\n constructor(message: string, source: string) {\n super(`MDX parse error: ${message}`);\n this.name = \"MDXParseError\";\n this.source = source;\n }\n}","import type { AstNode, AttrValueKind } from \"../types/MdxAST\";\n\nconst NODE_TEXT = 0x01;\nconst NODE_ELEMENT = 0x02;\n\nconst ATTR_TEXT = 0x10;\nconst ATTR_EXPRESSION = 0x11;\nconst ATTR_BOOLEAN = 0x12;\nconst ATTR_AST = 0x13;\n\nexport class MdxBinaryDecoder {\n private view: DataView;\n private buffer: Uint8Array;\n private offset: number = 0;\n private decoder = new TextDecoder(\"utf-8\");\n private stringCache = new Map<string, string>();\n\n constructor(buffer: Uint8Array) {\n this.buffer = buffer;\n this.view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);\n }\n\n public decode(): AstNode[] {\n const rootCount = this.readU32();\n const nodes: AstNode[] = [];\n for (let i = 0; i < rootCount; i++) {\n nodes.push(this.decodeNode());\n }\n return nodes;\n }\n\n private decodeNode(): AstNode {\n const type = this.readU8();\n\n if (type === NODE_TEXT) {\n return {\n node_type: \"text\",\n content: this.readStringU32(),\n };\n }\n\n if (type === NODE_ELEMENT) {\n const node_type = this.readStringU16();\n const self_closing = this.readU8() === 1;\n const attrCount = this.readU16();\n \n let attributes: Record<string, AttrValueKind> | undefined = undefined;\n \n if (attrCount > 0) {\n attributes = {};\n for (let i = 0; i < attrCount; i++) {\n const key = this.readStringU16();\n const attrKind = this.readU8();\n \n if (attrKind === ATTR_TEXT) {\n attributes[key] = { kind: \"text\", value: this.readStringU32() };\n } else if (attrKind === ATTR_EXPRESSION) {\n attributes[key] = { kind: \"expression\", value: this.readStringU32() };\n } else if (attrKind === ATTR_BOOLEAN) {\n attributes[key] = { kind: \"boolean\" };\n } else if (attrKind === ATTR_AST) {\n const subNodeCount = this.readU32();\n const subNodes: AstNode[] = [];\n for (let j = 0; j < subNodeCount; j++) {\n subNodes.push(this.decodeNode());\n }\n attributes[key] = { kind: \"ast\", value: subNodes };\n }\n }\n }\n\n const childCount = this.readU32();\n const children: AstNode[] = [];\n if (childCount > 0) {\n for (let i = 0; i < childCount; i++) {\n children.push(this.decodeNode());\n }\n }\n\n return {\n node_type,\n self_closing,\n attributes,\n children,\n };\n }\n\n throw new Error(`[@toaq-oss/omni-mdx] Unknown binary opcode: ${type} at offset ${this.offset}`);\n }\n\n private readU8(): number {\n const val = this.view.getUint8(this.offset);\n this.offset += 1;\n return val;\n }\n\n private readU16(): number {\n const val = this.view.getUint16(this.offset, true);\n this.offset += 2;\n return val;\n }\n\n private readU32(): number {\n const val = this.view.getUint32(this.offset, true);\n this.offset += 4;\n return val;\n }\n\n private readStringU16(): string {\n const len = this.readU16();\n const str = this.decoder.decode(this.buffer.subarray(this.offset, this.offset + len));\n this.offset += len;\n\n let cached = this.stringCache.get(str);\n if (cached) return cached;\n this.stringCache.set(str, str);\n return str;\n }\n\n private readStringU32(): string {\n const len = this.readU32();\n const str = this.decoder.decode(this.buffer.subarray(this.offset, this.offset + len));\n this.offset += len;\n return str;\n }\n}","/**\n * MDXServerRenderer.tsx\n *\n * React Server Component — renders an MDX AST on the server.\n * No \"use client\" — safe for Next.js SSR, SSG, and ISR.\n *\n * Drop-in replacement for <MDXRemote source={...} components={MDX_COMPONENTS} />\n *\n * Usage in a Server Component (page.tsx):\n *\n * import { MDXServerRenderer, parseMdx } from '@toaq/omni-mdx/server';\n * import { MDX_COMPONENTS } from './MDXComponents';\n *\n * export default async function Page() {\n * const ast = await parseMdx(mdxString);\n * return <MDXServerRenderer ast={ast} components={MDX_COMPONENTS} />;\n * }\n */\n\nimport React, { ReactNode, JSX } from \"react\";\nimport katex from \"katex\";\nimport type { AttrValueKind, AstNode, MDXComponents } from \"./types/MdxAST\";\nimport { BASIC_STYLES } from \"./utils/basicStyles\";\n\n/**\n * Converts a raw AttrValueKind from the Rust AST into a React-usable prop value.\n * text → string\n * expression → attempt JSON/JS parse, fallback to string\n * boolean → true\n * ast → <MDXServerRenderer ast={...} components={...} />\n */\nfunction resolveAttr(\n attr: AttrValueKind,\n components: MDXComponents,\n): React.ReactNode | string | boolean {\n switch (attr.kind) {\n case \"text\":\n return attr.value;\n\n case \"boolean\":\n return true;\n\n case \"expression\": {\n const raw = attr.value.trim();\n // Try JSON first (safe), then JS expression as last resort\n try { return JSON.parse(raw); } catch {}\n try { return new Function(`return (${raw})`)(); } catch {}\n return raw;\n }\n\n case \"ast\":\n return (\n <MDXServerRenderer\n ast={attr.value}\n components={components}\n />\n );\n\n default:\n return undefined;\n }\n}\n\nconst HTML_TAGS = new Set([\n \"a\",\"abbr\",\"address\",\"article\",\"aside\",\"b\",\"bdi\",\"bdo\",\"blockquote\",\"br\",\n \"caption\",\"cite\",\"code\",\"col\",\"colgroup\",\"data\",\"dd\",\"del\",\"details\",\"dfn\",\n \"div\",\"dl\",\"dt\",\"em\",\"figcaption\",\"figure\",\"footer\",\"h1\",\"h2\",\"h3\",\"h4\",\n \"h5\",\"h6\",\"header\",\"hr\",\"i\",\"img\",\"ins\",\"kbd\",\"li\",\"main\",\"mark\",\"nav\",\"ol\",\n \"p\",\"pre\",\"q\",\"rp\",\"rt\",\"ruby\",\"s\",\"samp\",\"section\",\"small\",\"span\",\"strong\",\n \"sub\",\"summary\",\"sup\",\"table\",\"tbody\",\"td\",\"tfoot\",\"th\",\"thead\",\"time\",\"tr\",\n \"u\",\"ul\",\"var\",\"wbr\",\n]);\n\nfunction extractText(node: AstNode): string {\n if (node.node_type === \"text\") return node.content ?? \"\";\n if (node.content) return node.content;\n return (node.children ?? []).map(extractText).join(\"\");\n}\n\nfunction renderNode(\n node: AstNode,\n index: number,\n components: MDXComponents,\n): ReactNode {\n const key = `${node.node_type}-${index}`;\n\n if (node.node_type === \"text\") {\n return node.content ?? null;\n }\n\n if (node.node_type === \"fragment\") {\n return (\n <React.Fragment key={key}>\n {renderChildren(node, components)}\n </React.Fragment>\n );\n }\n\n // Math — server-side rendering via KaTeX (static HTML, no client-side JavaScript)\n if (node.node_type === \"InlineMath\") {\n const formula = extractText(node);\n\n try {\n const html = katex.renderToString(formula, {\n displayMode: false,\n throwOnError: false,\n output: \"html\",\n });\n return (\n <span\n key={key}\n className=\"math math-inline\"\n dangerouslySetInnerHTML={{ __html: html }}\n />\n );\n } catch {\n return <span key={key} className=\"math math-inline\">{formula}</span>;\n }\n }\n\n if (node.node_type === \"BlockMath\") {\n const formula = extractText(node);\n\n try {\n const html = katex.renderToString(formula, {\n displayMode: true,\n throwOnError: false,\n output: \"html\",\n });\n return (\n <div\n key={key}\n className=\"math math-display\"\n dangerouslySetInnerHTML={{ __html: html }}\n />\n );\n } catch {\n return <div key={key} className=\"math math-display\">{formula}</div>;\n }\n }\n\n // Resolve props from AST attributes\n const resolvedProps: Record<string, any> = {};\n if (node.attributes) {\n const attrs = typeof node.attributes === \"string\" \n ? JSON.parse(node.attributes) \n : node.attributes;\n\n for (const [k, v] of Object.entries(attrs)) {\n resolvedProps[k] = resolveAttr(v as AttrValueKind, components);\n }\n }\n\n const renderedChildren = node.children && node.children.length > 0\n ? renderChildren(node, components)\n : (node.content ?? undefined);\n\n // Custom registered component\n const Custom = components[node.node_type];\n if (Custom) {\n try {\n return (\n <Custom key={key} {...resolvedProps}>\n {renderedChildren}\n </Custom>\n );\n } catch (err) {\n if (process.env.NODE_ENV === \"development\") {\n console.error(`[toaq-oss/omni-mdx] Server render failed for <${node.node_type}>:`, err);\n }\n return (\n <div\n key={key}\n className=\"mdx-component-error\"\n data-component={node.node_type}\n style={{ padding: \"1rem\", border: \"2px solid #ef4444\", borderRadius: \"0.5rem\", margin: \"1rem 0\", background: \"#fef2f2\" }}\n >\n <strong style={{ color: \"#b91c1c\" }}>Render error: &lt;{node.node_type}&gt;</strong>\n {process.env.NODE_ENV === \"development\" && (\n <pre style={{ color: \"#dc2626\", fontSize: \"0.875rem\", marginTop: \"0.5rem\" }}>\n {String(err)}\n </pre>\n )}\n </div>\n );\n }\n }\n\n if (node.node_type === \"table\") {\n const firstChild = node.children?.[0];\n const hasThead = firstChild?.node_type === \"thead\";\n const theadNode = hasThead ? firstChild : null;\n const bodyRows = hasThead ? node.children!.slice(1) : node.children ?? [];\n\n const theadEl = theadNode ? (\n <thead key=\"thead\">\n <tr>\n {theadNode.children?.map((cell, i) =>\n renderNode({ ...cell, node_type: \"th\" }, i, components)\n )}\n </tr>\n </thead>\n ) : null;\n\n const tbodyEl = bodyRows.length > 0 ? (\n <tbody key=\"tbody\">\n {bodyRows.map((row, i) => renderNode(row, i, components))}\n </tbody>\n ) : null;\n\n return <table key={key} {...resolvedProps}>{theadEl}{tbodyEl}</table>;\n }\n\n if (node.node_type === \"pre\") {\n const rawText = extractText(node);\n return <pre key={key} {...resolvedProps}><code>{rawText}</code></pre>;\n }\n\n if (HTML_TAGS.has(node.node_type)) {\n const Tag = node.node_type as keyof JSX.IntrinsicElements;\n return (\n <Tag key={key} {...resolvedProps}>\n {renderedChildren}\n </Tag>\n );\n }\n\n if (process.env.NODE_ENV === \"development\") {\n console.warn(\n `[toaq-oss/omni-mdx] Unknown component: <${node.node_type}>. ` +\n `Register it via MDX_COMPONENTS or add it to your components prop.`\n );\n }\n return (\n <div key={key} data-missing-component={node.node_type} className=\"mdx-missing-component\">\n {renderedChildren}\n </div>\n );\n}\n\nfunction renderChildren(node: AstNode, components: MDXComponents): ReactNode[] {\n if (!node.children?.length) return [];\n return node.children.map((child, i) => renderNode(child, i, components));\n}\n\ninterface MDXServerRendererProps {\n /** AST produced by parseMdx() — JSON-serialisable. */\n ast: AstNode[];\n /**\n * Component registry. Keys are JSX tag names (e.g. \"Note\", \"Details\").\n * Values are React components (Server or Client).\n *\n * Server Components render on the server (recommended for static content).\n * Client Components receive \"use client\" and hydrate in the browser.\n */\n components?: MDXComponents;\n}\n\nexport function MDXServerRenderer({\n ast,\n components = {},\n}: MDXServerRendererProps): JSX.Element {\n if (!ast || !Array.isArray(ast)) {\n return <></>;\n }\n\n const finalComponents = {\n ...BASIC_STYLES,\n ...components\n };\n\n return (\n <div className=\"omni-mdx-root\">\n {ast.map((node, i) => renderNode(node, i, finalComponents))}\n </div>\n );\n}","import React from \"react\";\n\n// Styles defined to be usable in fallback condition.\nexport const BASIC_STYLES: Record<string, React.FC<any>> = {\n h1: (props) => <h1 className=\"text-3xl font-bold tracking-tight text-white mt-8 mb-4\" {...props} />,\n h2: (props) => <h2 className=\"text-2xl font-semibold tracking-tight text-neutral-100 mt-6 mb-3 border-b border-white/5 pb-2\" {...props} />,\n h3: (props) => <h3 className=\"text-xl font-medium text-neutral-200 mt-4 mb-2\" {...props} />,\n h4: (props) => <h4 className=\"text-lg font-medium text-neutral-300 mt-4 mb-2\" {...props} />,\n p: (props) => <p className=\"text-base leading-7 text-neutral-400 mb-4\" {...props} />,\n ul: (props) => <ul className=\"list-disc list-inside mb-4 space-y-1 text-neutral-400\" {...props} />,\n ol: (props) => <ol className=\"list-decimal list-inside mb-4 space-y-1 text-neutral-400\" {...props} />,\n li: (props) => <li className=\"ml-4\" {...props} />,\n code: (props) => {\n return <code className=\"inline-code bg-white/10 px-1.5 py-0.5 rounded text-pink-400 font-mono text-sm\" {...props} />;\n },\n blockquote: (props) => <blockquote className=\"border-l-4 border-blue-500/50 pl-4 italic text-neutral-500 my-6\" {...props} />,\n hr: () => <hr className=\"border-white/5 my-8\" />,\n table: (props) => <div className=\"overflow-x-auto mb-6\"><table className=\"w-full text-sm text-left border-collapse\" {...props} /></div>,\n th: (props) => <th className=\"border-b border-white/10 p-2 font-semibold text-neutral-200\" {...props} />,\n td: (props) => <td className=\"border-b border-white/5 p-2 text-neutral-400\" {...props} />,\n img: (props) => <img className=\"rounded-xl border border-white/10 my-8 mx-auto max-w-full h-auto\" {...props} />,\n a: (props) => <a className=\"text-blue-400 hover:text-blue-300 underline underline-offset-4 decoration-blue-500/30 transition-colors\" {...props} />,\n};"],"mappings":";AACA,SAAS,qBAAqB;AAC9B,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for Next.js \u2014 Rust core, RSC-compatible",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -10,13 +10,16 @@
10
10
  },
11
11
  "exports": {
12
12
  ".": {
13
+ "types": "./dist/index.d.ts",
13
14
  "import": "./dist/index.js",
14
15
  "require": "./dist/index.cjs"
15
16
  },
16
17
  "./server": {
18
+ "types": "./dist/server.d.ts",
17
19
  "import": "./dist/server.js"
18
20
  },
19
21
  "./client": {
22
+ "types": "./dist/client.d.ts",
20
23
  "import": "./dist/client.js",
21
24
  "require": "./dist/client.cjs"
22
25
  },