@toaq-oss/omni-mdx 0.1.11 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +88 -169
- package/dist/client.cjs +138 -4
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +18 -2
- package/dist/client.d.ts +18 -2
- package/dist/client.js +138 -4
- package/dist/client.js.map +1 -1
- package/dist/omni_mdx_core_bg.wasm +0 -0
- package/dist/server.d.ts +2 -2
- package/dist/server.js +12 -7
- package/dist/server.js.map +1 -1
- package/package.json +5 -5
package/dist/client.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../wasm/omni_mdx_core.js","../src/client.ts","../src/MDXClientRenderer.tsx","../src/MDXErrorBoundary.tsx","../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\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_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 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 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 type { AstNode, MDXComponents } from \"./MDXServerRenderer\";","\"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, useEffect, useRef, useState } from \"react\";\nimport katex from \"katex\";\nimport { MDXErrorBoundary } from \"./MDXErrorBoundary\";\nimport type { AstNode, MDXComponents } from \"./MDXServerRenderer\";\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\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 try {\n const html = katex.renderToString(node.content ?? \"\", { 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\">{node.content}</span>;\n }\n }\n if (node.node_type === \"BlockMath\") {\n try {\n const html = katex.renderToString(node.content ?? \"\", { 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\">{node.content}</div>;\n }\n }\n\n const resolvedProps: Record<string, any> = {};\n if (node.attributes) {\n // 1. Sécurisation : si c'est une string (depuis N-API Rust), on la parse\n const attrs = typeof node.attributes === \"string\" \n ? JSON.parse(node.attributes) \n : node.attributes;\n\n // 2. Itération sur l'objet parsé\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}","// 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 \"./MDXServerRenderer\";\n\nlet _parseClient: ((mdx: string) => string) | null = null;\n\nasync function getClientParser(): Promise<(mdx: string) => string> {\n if (_parseClient) return _parseClient;\n\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 _parseClient = (mdx: string): string => wasm.parse_mdx_to_json(mdx);\n return _parseClient!;\n}\n\nexport async function parseMdxClient(mdx: string): Promise<AstNode[]> {\n if (typeof window === \"undefined\") return [];\n\n try {\n const parse = await getClientParser();\n const json = parse(mdx);\n return JSON.parse(json) as AstNode[];\n } catch (err) {\n console.error(\"[omni-mdx] WASM client parse error:\", err);\n return [];\n }\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;AACA,kBAAc;AACd,kBAAc;AACd,WAAO,mBAAmB,MAAM,IAAI;AAAA,EACxC,UAAE;AACE,SAAK,gBAAgB,aAAa,aAAa,CAAC;AAAA,EACpD;AACJ;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AAuC,GAAG;AACxD,WAAO,CAAC;AAAA,EACV;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/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 \"./MDXServerRenderer\";","\"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, useEffect, useRef, useState } from \"react\";\nimport katex from \"katex\";\nimport { MDXErrorBoundary } from \"./MDXErrorBoundary\";\nimport type { AstNode, MDXComponents } from \"./MDXServerRenderer\";\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\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 try {\n const html = katex.renderToString(node.content ?? \"\", { 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\">{node.content}</span>;\n }\n }\n if (node.node_type === \"BlockMath\") {\n try {\n const html = katex.renderToString(node.content ?? \"\", { 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\">{node.content}</div>;\n }\n }\n\n const resolvedProps: Record<string, any> = {};\n if (node.attributes) {\n // 1. Sécurisation : si c'est une string (depuis N-API Rust), on la parse\n const attrs = typeof node.attributes === \"string\" \n ? JSON.parse(node.attributes) \n : node.attributes;\n\n // 2. Itération sur l'objet parsé\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 \"../MDXServerRenderer\";\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(`[Omni-Core] 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 \"./MDXServerRenderer\";\nimport { MdxBinaryDecoder } from \"./utils/binaryDecoder\";\n\nlet _parseClient: ((mdx: Uint8Array) => Uint8Array) | null = null;\n\nasync function getClientParser(): Promise<(mdx: Uint8Array) => Uint8Array> {\n if (_parseClient) return _parseClient;\n\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 _parseClient = (mdx: Uint8Array): Uint8Array => wasm.parse_to_binary(mdx);\n return _parseClient!;\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 = typeof mdx === \"string\" \n ? new TextEncoder().encode(mdx) \n : mdx;\n const binaryAst = parse(inputBuffer);\n const decoder = new MdxBinaryDecoder(binaryAst);\n return decoder.decode();\n } catch (err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AG,CAAC;AACpF,SAAK,UAAU;AAEf,QAAI,SAAS,KAAK,YAAY,IAAI,GAAG;AACrC,QAAI,OAAQ,QAAO;AACnB,SAAK,YAAY,IAAI,KAAK,GAAG;AAC7B,WAAO;AAAA,EACT;AAAA,EAEQ,gBAAwB;AAC9B,UAAM,MAAM,KAAK,QAAQ;AACzB,UAAM,MAAM,KAAK,QAAQ,OAAO,KAAK,OAAO,SAAS,KAAK,QAAQ,KAAK,SAAS,GAAG,CAAC;AACpF,SAAK,UAAU;AACf,WAAO;AAAA,EACT;AACF;;;AC7HA,IAAAC,eAAA;AASA,IAAI,eAAyD;AAE7D,eAAe,kBAA4D;AACzE,MAAI,aAAc,QAAO;AAGzB,QAAMC,QAAY,MAAM;AAExB,MAAI,OAAOA,MAAK,YAAY,YAAY;AACtC,UAAM,UAAU,IAAI,IAAI,2BAA2BD,aAAY,GAAG;AAClE,UAAMC,MAAK,QAAQ,OAAO;AAAA,EAC5B;AAEA,iBAAe,CAAC,QAAgCA,MAAK,gBAAgB,GAAG;AACxE,SAAO;AACT;AAEA,eAAsB,eAAe,KAA8C;AACjF,MAAI,OAAO,WAAW,YAAa,QAAO,CAAC;AAE3C,MAAI;AACF,UAAM,QAAQ,MAAM,gBAAgB;AACpC,UAAM,cAAc,OAAO,QAAQ,WAC/B,IAAI,YAAY,EAAE,OAAO,GAAG,IAC5B;AACJ,UAAM,YAAY,MAAM,WAAW;AACnC,UAAM,UAAU,IAAI,iBAAiB,SAAS;AAC9C,WAAO,QAAQ,OAAO;AAAA,EACxB,SAAS,KAAK;AACZ,YAAQ,MAAM,uCAAuC,GAAG;AACxD,WAAO,CAAC;AAAA,EACV;AACF;","names":["ptr","module","import_react","import_jsx_runtime","React","katex","import_meta","wasm"]}
|
package/dist/client.d.cts
CHANGED
|
@@ -82,6 +82,22 @@ declare class MDXErrorBoundary extends Component<Props, State> {
|
|
|
82
82
|
render(): string | number | boolean | Iterable<ReactNode> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
declare function parseMdxClient(mdx: string): Promise<AstNode[]>;
|
|
85
|
+
declare function parseMdxClient(mdx: string | Uint8Array): Promise<AstNode[]>;
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
declare class MdxBinaryDecoder {
|
|
88
|
+
private view;
|
|
89
|
+
private buffer;
|
|
90
|
+
private offset;
|
|
91
|
+
private decoder;
|
|
92
|
+
private stringCache;
|
|
93
|
+
constructor(buffer: Uint8Array);
|
|
94
|
+
decode(): AstNode[];
|
|
95
|
+
private decodeNode;
|
|
96
|
+
private readU8;
|
|
97
|
+
private readU16;
|
|
98
|
+
private readU32;
|
|
99
|
+
private readStringU16;
|
|
100
|
+
private readStringU32;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export { type AstNode, MDXClientRenderer, type MDXComponents, MDXErrorBoundary, MdxBinaryDecoder, parseMdxClient as parseMdx };
|
package/dist/client.d.ts
CHANGED
|
@@ -82,6 +82,22 @@ declare class MDXErrorBoundary extends Component<Props, State> {
|
|
|
82
82
|
render(): string | number | boolean | Iterable<ReactNode> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
declare function parseMdxClient(mdx: string): Promise<AstNode[]>;
|
|
85
|
+
declare function parseMdxClient(mdx: string | Uint8Array): Promise<AstNode[]>;
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
declare class MdxBinaryDecoder {
|
|
88
|
+
private view;
|
|
89
|
+
private buffer;
|
|
90
|
+
private offset;
|
|
91
|
+
private decoder;
|
|
92
|
+
private stringCache;
|
|
93
|
+
constructor(buffer: Uint8Array);
|
|
94
|
+
decode(): AstNode[];
|
|
95
|
+
private decodeNode;
|
|
96
|
+
private readU8;
|
|
97
|
+
private readU16;
|
|
98
|
+
private readU32;
|
|
99
|
+
private readStringU16;
|
|
100
|
+
private readStringU32;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export { type AstNode, MDXClientRenderer, type MDXComponents, MDXErrorBoundary, MdxBinaryDecoder, parseMdxClient as parseMdx };
|
package/dist/client.js
CHANGED
|
@@ -16,7 +16,8 @@ __export(omni_mdx_core_exports, {
|
|
|
16
16
|
initSync: () => initSync,
|
|
17
17
|
parse_mdx_to_json: () => parse_mdx_to_json,
|
|
18
18
|
parse_mdx_to_json_pretty: () => parse_mdx_to_json_pretty,
|
|
19
|
-
parse_mdx_version: () => parse_mdx_version
|
|
19
|
+
parse_mdx_version: () => parse_mdx_version,
|
|
20
|
+
parse_to_binary: () => parse_to_binary
|
|
20
21
|
});
|
|
21
22
|
function parse_mdx_to_json(input) {
|
|
22
23
|
let deferred3_0;
|
|
@@ -72,6 +73,17 @@ function parse_mdx_version() {
|
|
|
72
73
|
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
73
74
|
}
|
|
74
75
|
}
|
|
76
|
+
function parse_to_binary(mdx_input) {
|
|
77
|
+
const ptr0 = passArray8ToWasm0(mdx_input, wasm.__wbindgen_malloc);
|
|
78
|
+
const len0 = WASM_VECTOR_LEN;
|
|
79
|
+
const ret = wasm.parse_to_binary(ptr0, len0);
|
|
80
|
+
if (ret[3]) {
|
|
81
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
82
|
+
}
|
|
83
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
84
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
85
|
+
return v2;
|
|
86
|
+
}
|
|
75
87
|
function __wbg_get_imports() {
|
|
76
88
|
const import0 = {
|
|
77
89
|
__proto__: null,
|
|
@@ -79,6 +91,10 @@ function __wbg_get_imports() {
|
|
|
79
91
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
80
92
|
return ret;
|
|
81
93
|
},
|
|
94
|
+
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
95
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
96
|
+
return ret;
|
|
97
|
+
},
|
|
82
98
|
__wbindgen_init_externref_table: function() {
|
|
83
99
|
const table = wasm.__wbindgen_externrefs;
|
|
84
100
|
const offset = table.grow(4);
|
|
@@ -94,6 +110,10 @@ function __wbg_get_imports() {
|
|
|
94
110
|
"./omni_mdx_core_bg.js": import0
|
|
95
111
|
};
|
|
96
112
|
}
|
|
113
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
114
|
+
ptr = ptr >>> 0;
|
|
115
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
116
|
+
}
|
|
97
117
|
function getStringFromWasm0(ptr, len) {
|
|
98
118
|
ptr = ptr >>> 0;
|
|
99
119
|
return decodeText(ptr, len);
|
|
@@ -104,6 +124,12 @@ function getUint8ArrayMemory0() {
|
|
|
104
124
|
}
|
|
105
125
|
return cachedUint8ArrayMemory0;
|
|
106
126
|
}
|
|
127
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
128
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
129
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
130
|
+
WASM_VECTOR_LEN = arg.length;
|
|
131
|
+
return ptr;
|
|
132
|
+
}
|
|
107
133
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
108
134
|
if (realloc === void 0) {
|
|
109
135
|
const buf = cachedTextEncoder.encode(arg);
|
|
@@ -440,6 +466,111 @@ function MDXClientRenderer({
|
|
|
440
466
|
return /* @__PURE__ */ jsx2("div", { className: "omni-mdx-root", children: /* @__PURE__ */ jsx2(MDXClientContent, { ast, components }) });
|
|
441
467
|
}
|
|
442
468
|
|
|
469
|
+
// src/utils/binaryDecoder.ts
|
|
470
|
+
var NODE_TEXT = 1;
|
|
471
|
+
var NODE_ELEMENT = 2;
|
|
472
|
+
var ATTR_TEXT = 16;
|
|
473
|
+
var ATTR_EXPRESSION = 17;
|
|
474
|
+
var ATTR_BOOLEAN = 18;
|
|
475
|
+
var ATTR_AST = 19;
|
|
476
|
+
var MdxBinaryDecoder = class {
|
|
477
|
+
constructor(buffer) {
|
|
478
|
+
this.offset = 0;
|
|
479
|
+
this.decoder = new TextDecoder("utf-8");
|
|
480
|
+
this.stringCache = /* @__PURE__ */ new Map();
|
|
481
|
+
this.buffer = buffer;
|
|
482
|
+
this.view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
483
|
+
}
|
|
484
|
+
decode() {
|
|
485
|
+
const rootCount = this.readU32();
|
|
486
|
+
const nodes = [];
|
|
487
|
+
for (let i = 0; i < rootCount; i++) {
|
|
488
|
+
nodes.push(this.decodeNode());
|
|
489
|
+
}
|
|
490
|
+
return nodes;
|
|
491
|
+
}
|
|
492
|
+
decodeNode() {
|
|
493
|
+
const type = this.readU8();
|
|
494
|
+
if (type === NODE_TEXT) {
|
|
495
|
+
return {
|
|
496
|
+
node_type: "text",
|
|
497
|
+
content: this.readStringU32()
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
if (type === NODE_ELEMENT) {
|
|
501
|
+
const node_type = this.readStringU16();
|
|
502
|
+
const self_closing = this.readU8() === 1;
|
|
503
|
+
const attrCount = this.readU16();
|
|
504
|
+
let attributes = void 0;
|
|
505
|
+
if (attrCount > 0) {
|
|
506
|
+
attributes = {};
|
|
507
|
+
for (let i = 0; i < attrCount; i++) {
|
|
508
|
+
const key = this.readStringU16();
|
|
509
|
+
const attrKind = this.readU8();
|
|
510
|
+
if (attrKind === ATTR_TEXT) {
|
|
511
|
+
attributes[key] = { kind: "text", value: this.readStringU32() };
|
|
512
|
+
} else if (attrKind === ATTR_EXPRESSION) {
|
|
513
|
+
attributes[key] = { kind: "expression", value: this.readStringU32() };
|
|
514
|
+
} else if (attrKind === ATTR_BOOLEAN) {
|
|
515
|
+
attributes[key] = { kind: "boolean" };
|
|
516
|
+
} else if (attrKind === ATTR_AST) {
|
|
517
|
+
const subNodeCount = this.readU32();
|
|
518
|
+
const subNodes = [];
|
|
519
|
+
for (let j = 0; j < subNodeCount; j++) {
|
|
520
|
+
subNodes.push(this.decodeNode());
|
|
521
|
+
}
|
|
522
|
+
attributes[key] = { kind: "ast", value: subNodes };
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
const childCount = this.readU32();
|
|
527
|
+
const children = [];
|
|
528
|
+
if (childCount > 0) {
|
|
529
|
+
for (let i = 0; i < childCount; i++) {
|
|
530
|
+
children.push(this.decodeNode());
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
return {
|
|
534
|
+
node_type,
|
|
535
|
+
self_closing,
|
|
536
|
+
attributes,
|
|
537
|
+
children
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
throw new Error(`[Omni-Core] Unknown binary opcode: ${type} at offset ${this.offset}`);
|
|
541
|
+
}
|
|
542
|
+
readU8() {
|
|
543
|
+
const val = this.view.getUint8(this.offset);
|
|
544
|
+
this.offset += 1;
|
|
545
|
+
return val;
|
|
546
|
+
}
|
|
547
|
+
readU16() {
|
|
548
|
+
const val = this.view.getUint16(this.offset, true);
|
|
549
|
+
this.offset += 2;
|
|
550
|
+
return val;
|
|
551
|
+
}
|
|
552
|
+
readU32() {
|
|
553
|
+
const val = this.view.getUint32(this.offset, true);
|
|
554
|
+
this.offset += 4;
|
|
555
|
+
return val;
|
|
556
|
+
}
|
|
557
|
+
readStringU16() {
|
|
558
|
+
const len = this.readU16();
|
|
559
|
+
const str = this.decoder.decode(this.buffer.subarray(this.offset, this.offset + len));
|
|
560
|
+
this.offset += len;
|
|
561
|
+
let cached = this.stringCache.get(str);
|
|
562
|
+
if (cached) return cached;
|
|
563
|
+
this.stringCache.set(str, str);
|
|
564
|
+
return str;
|
|
565
|
+
}
|
|
566
|
+
readStringU32() {
|
|
567
|
+
const len = this.readU32();
|
|
568
|
+
const str = this.decoder.decode(this.buffer.subarray(this.offset, this.offset + len));
|
|
569
|
+
this.offset += len;
|
|
570
|
+
return str;
|
|
571
|
+
}
|
|
572
|
+
};
|
|
573
|
+
|
|
443
574
|
// src/parse.client.ts
|
|
444
575
|
var _parseClient = null;
|
|
445
576
|
async function getClientParser() {
|
|
@@ -449,15 +580,17 @@ async function getClientParser() {
|
|
|
449
580
|
const wasmUrl = new URL("./omni_mdx_core_bg.wasm", import.meta.url);
|
|
450
581
|
await wasm2.default(wasmUrl);
|
|
451
582
|
}
|
|
452
|
-
_parseClient = (mdx) => wasm2.
|
|
583
|
+
_parseClient = (mdx) => wasm2.parse_to_binary(mdx);
|
|
453
584
|
return _parseClient;
|
|
454
585
|
}
|
|
455
586
|
async function parseMdxClient(mdx) {
|
|
456
587
|
if (typeof window === "undefined") return [];
|
|
457
588
|
try {
|
|
458
589
|
const parse = await getClientParser();
|
|
459
|
-
const
|
|
460
|
-
|
|
590
|
+
const inputBuffer = typeof mdx === "string" ? new TextEncoder().encode(mdx) : mdx;
|
|
591
|
+
const binaryAst = parse(inputBuffer);
|
|
592
|
+
const decoder = new MdxBinaryDecoder(binaryAst);
|
|
593
|
+
return decoder.decode();
|
|
461
594
|
} catch (err) {
|
|
462
595
|
console.error("[omni-mdx] WASM client parse error:", err);
|
|
463
596
|
return [];
|
|
@@ -466,6 +599,7 @@ async function parseMdxClient(mdx) {
|
|
|
466
599
|
export {
|
|
467
600
|
MDXClientRenderer,
|
|
468
601
|
MDXErrorBoundary,
|
|
602
|
+
MdxBinaryDecoder,
|
|
469
603
|
parseMdxClient as parseMdx
|
|
470
604
|
};
|
|
471
605
|
//# sourceMappingURL=client.js.map
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../wasm/omni_mdx_core.js","../src/MDXClientRenderer.tsx","../src/MDXErrorBoundary.tsx","../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\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_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 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 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, useEffect, useRef, useState } from \"react\";\nimport katex from \"katex\";\nimport { MDXErrorBoundary } from \"./MDXErrorBoundary\";\nimport type { AstNode, MDXComponents } from \"./MDXServerRenderer\";\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\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 try {\n const html = katex.renderToString(node.content ?? \"\", { 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\">{node.content}</span>;\n }\n }\n if (node.node_type === \"BlockMath\") {\n try {\n const html = katex.renderToString(node.content ?? \"\", { 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\">{node.content}</div>;\n }\n }\n\n const resolvedProps: Record<string, any> = {};\n if (node.attributes) {\n // 1. Sécurisation : si c'est une string (depuis N-API Rust), on la parse\n const attrs = typeof node.attributes === \"string\" \n ? JSON.parse(node.attributes) \n : node.attributes;\n\n // 2. Itération sur l'objet parsé\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}","// 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 \"./MDXServerRenderer\";\n\nlet _parseClient: ((mdx: string) => string) | null = null;\n\nasync function getClientParser(): Promise<(mdx: string) => string> {\n if (_parseClient) return _parseClient;\n\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 _parseClient = (mdx: string): string => wasm.parse_mdx_to_json(mdx);\n return _parseClient!;\n}\n\nexport async function parseMdxClient(mdx: string): Promise<AstNode[]> {\n if (typeof window === \"undefined\") return [];\n\n try {\n const parse = await getClientParser();\n const json = parse(mdx);\n return JSON.parse(json) as AstNode[];\n } catch (err) {\n console.error(\"[omni-mdx] WASM client parse error:\", err);\n return [];\n }\n}"],"mappings":";;;;;;;;;;;;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,C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MAAK,kBAAkB,GAAG;AAClE,SAAO;AACT;AAEA,eAAsB,eAAe,KAAiC;AACpE,MAAI,OAAO,WAAW,YAAa,QAAO,CAAC;AAE3C,MAAI;AACF,UAAM,QAAQ,MAAM,gBAAgB;AACpC,UAAM,OAAQ,MAAM,GAAG;AACvB,WAAO,KAAK,MAAM,IAAI;AAAA,EACxB,SAAS,KAAK;AACZ,YAAQ,MAAM,uCAAuC,GAAG;AACxD,WAAO,CAAC;AAAA,EACV;AACF;","names":["ptr","jsx","wasm"]}
|
|
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, useEffect, useRef, useState } from \"react\";\nimport katex from \"katex\";\nimport { MDXErrorBoundary } from \"./MDXErrorBoundary\";\nimport type { AstNode, MDXComponents } from \"./MDXServerRenderer\";\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\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 try {\n const html = katex.renderToString(node.content ?? \"\", { 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\">{node.content}</span>;\n }\n }\n if (node.node_type === \"BlockMath\") {\n try {\n const html = katex.renderToString(node.content ?? \"\", { 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\">{node.content}</div>;\n }\n }\n\n const resolvedProps: Record<string, any> = {};\n if (node.attributes) {\n // 1. Sécurisation : si c'est une string (depuis N-API Rust), on la parse\n const attrs = typeof node.attributes === \"string\" \n ? JSON.parse(node.attributes) \n : node.attributes;\n\n // 2. Itération sur l'objet parsé\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 \"../MDXServerRenderer\";\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(`[Omni-Core] 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 \"./MDXServerRenderer\";\nimport { MdxBinaryDecoder } from \"./utils/binaryDecoder\";\n\nlet _parseClient: ((mdx: Uint8Array) => Uint8Array) | null = null;\n\nasync function getClientParser(): Promise<(mdx: Uint8Array) => Uint8Array> {\n if (_parseClient) return _parseClient;\n\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 _parseClient = (mdx: Uint8Array): Uint8Array => wasm.parse_to_binary(mdx);\n return _parseClient!;\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 = typeof mdx === \"string\" \n ? new TextEncoder().encode(mdx) \n : mdx;\n const binaryAst = parse(inputBuffer);\n const decoder = new MdxBinaryDecoder(binaryAst);\n return decoder.decode();\n } catch (err) {\n console.error(\"[omni-mdx] WASM client parse error:\", err);\n return [];\n }\n}"],"mappings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QAAI,OAAQ,QAAO;AACnB,SAAK,YAAY,IAAI,KAAK,GAAG;AAC7B,WAAO;AAAA,EACT;AAAA,EAEQ,gBAAwB;AAC9B,UAAM,MAAM,KAAK,QAAQ;AACzB,UAAM,MAAM,KAAK,QAAQ,OAAO,KAAK,OAAO,SAAS,KAAK,QAAQ,KAAK,SAAS,GAAG,CAAC;AACpF,SAAK,UAAU;AACf,WAAO;AAAA,EACT;AACF;;;ACpHA,IAAI,eAAyD;AAE7D,eAAe,kBAA4D;AACzE,MAAI,aAAc,QAAO;AAGzB,QAAMC,QAAY,MAAM;AAExB,MAAI,OAAOA,MAAK,YAAY,YAAY;AACtC,UAAM,UAAU,IAAI,IAAI,2BAA2B,YAAY,GAAG;AAClE,UAAMA,MAAK,QAAQ,OAAO;AAAA,EAC5B;AAEA,iBAAe,CAAC,QAAgCA,MAAK,gBAAgB,GAAG;AACxE,SAAO;AACT;AAEA,eAAsB,eAAe,KAA8C;AACjF,MAAI,OAAO,WAAW,YAAa,QAAO,CAAC;AAE3C,MAAI;AACF,UAAM,QAAQ,MAAM,gBAAgB;AACpC,UAAM,cAAc,OAAO,QAAQ,WAC/B,IAAI,YAAY,EAAE,OAAO,GAAG,IAC5B;AACJ,UAAM,YAAY,MAAM,WAAW;AACnC,UAAM,UAAU,IAAI,iBAAiB,SAAS;AAC9C,WAAO,QAAQ,OAAO;AAAA,EACxB,SAAS,KAAK;AACZ,YAAQ,MAAM,uCAAuC,GAAG;AACxD,WAAO,CAAC;AAAA,EACV;AACF;","names":["ptr","jsx","wasm"]}
|
|
Binary file
|
package/dist/server.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { A as AstNode } from './MDXServerRenderer-D8_r2yxv.js';
|
|
|
2
2
|
export { a as AttrValueKind, M as MDXComponents, b as MDXServerRenderer } from './MDXServerRenderer-D8_r2yxv.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
|
|
5
|
-
declare function parseMdx(mdx: string): Promise<AstNode[]>;
|
|
6
|
-
declare function parseMdxSync(mdx: string): AstNode[];
|
|
5
|
+
declare function parseMdx(mdx: string | Buffer | Uint8Array): Promise<AstNode[]>;
|
|
6
|
+
declare function parseMdxSync(mdx: string | Buffer | Uint8Array): AstNode[];
|
|
7
7
|
declare function compileToJsx(mdx: string): Promise<string>;
|
|
8
8
|
declare function compileToJsxSync(mdx: string): string;
|
|
9
9
|
declare class MDXParseError extends Error {
|