@toaq-oss/omni-mdx 0.1.12 → 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/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
CHANGED
|
@@ -38,7 +38,8 @@ __export(omni_mdx_core_exports, {
|
|
|
38
38
|
initSync: () => initSync,
|
|
39
39
|
parse_mdx_to_json: () => parse_mdx_to_json,
|
|
40
40
|
parse_mdx_to_json_pretty: () => parse_mdx_to_json_pretty,
|
|
41
|
-
parse_mdx_version: () => parse_mdx_version
|
|
41
|
+
parse_mdx_version: () => parse_mdx_version,
|
|
42
|
+
parse_to_binary: () => parse_to_binary
|
|
42
43
|
});
|
|
43
44
|
function parse_mdx_to_json(input) {
|
|
44
45
|
let deferred3_0;
|
|
@@ -94,6 +95,17 @@ function parse_mdx_version() {
|
|
|
94
95
|
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
95
96
|
}
|
|
96
97
|
}
|
|
98
|
+
function parse_to_binary(mdx_input) {
|
|
99
|
+
const ptr0 = passArray8ToWasm0(mdx_input, wasm.__wbindgen_malloc);
|
|
100
|
+
const len0 = WASM_VECTOR_LEN;
|
|
101
|
+
const ret = wasm.parse_to_binary(ptr0, len0);
|
|
102
|
+
if (ret[3]) {
|
|
103
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
104
|
+
}
|
|
105
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
106
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
107
|
+
return v2;
|
|
108
|
+
}
|
|
97
109
|
function __wbg_get_imports() {
|
|
98
110
|
const import0 = {
|
|
99
111
|
__proto__: null,
|
|
@@ -101,6 +113,10 @@ function __wbg_get_imports() {
|
|
|
101
113
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
102
114
|
return ret;
|
|
103
115
|
},
|
|
116
|
+
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
117
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
118
|
+
return ret;
|
|
119
|
+
},
|
|
104
120
|
__wbindgen_init_externref_table: function() {
|
|
105
121
|
const table = wasm.__wbindgen_externrefs;
|
|
106
122
|
const offset = table.grow(4);
|
|
@@ -116,6 +132,10 @@ function __wbg_get_imports() {
|
|
|
116
132
|
"./omni_mdx_core_bg.js": import0
|
|
117
133
|
};
|
|
118
134
|
}
|
|
135
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
136
|
+
ptr = ptr >>> 0;
|
|
137
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
138
|
+
}
|
|
119
139
|
function getStringFromWasm0(ptr, len) {
|
|
120
140
|
ptr = ptr >>> 0;
|
|
121
141
|
return decodeText(ptr, len);
|
|
@@ -126,6 +146,12 @@ function getUint8ArrayMemory0() {
|
|
|
126
146
|
}
|
|
127
147
|
return cachedUint8ArrayMemory0;
|
|
128
148
|
}
|
|
149
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
150
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
151
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
152
|
+
WASM_VECTOR_LEN = arg.length;
|
|
153
|
+
return ptr;
|
|
154
|
+
}
|
|
129
155
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
130
156
|
if (realloc === void 0) {
|
|
131
157
|
const buf = cachedTextEncoder.encode(arg);
|
|
@@ -276,6 +302,7 @@ var client_exports = {};
|
|
|
276
302
|
__export(client_exports, {
|
|
277
303
|
MDXClientRenderer: () => MDXClientRenderer,
|
|
278
304
|
MDXErrorBoundary: () => MDXErrorBoundary,
|
|
305
|
+
MdxBinaryDecoder: () => MdxBinaryDecoder,
|
|
279
306
|
parseMdx: () => parseMdxClient
|
|
280
307
|
});
|
|
281
308
|
module.exports = __toCommonJS(client_exports);
|
|
@@ -472,6 +499,111 @@ function MDXClientRenderer({
|
|
|
472
499
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "omni-mdx-root", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(MDXClientContent, { ast, components }) });
|
|
473
500
|
}
|
|
474
501
|
|
|
502
|
+
// src/utils/binaryDecoder.ts
|
|
503
|
+
var NODE_TEXT = 1;
|
|
504
|
+
var NODE_ELEMENT = 2;
|
|
505
|
+
var ATTR_TEXT = 16;
|
|
506
|
+
var ATTR_EXPRESSION = 17;
|
|
507
|
+
var ATTR_BOOLEAN = 18;
|
|
508
|
+
var ATTR_AST = 19;
|
|
509
|
+
var MdxBinaryDecoder = class {
|
|
510
|
+
constructor(buffer) {
|
|
511
|
+
this.offset = 0;
|
|
512
|
+
this.decoder = new TextDecoder("utf-8");
|
|
513
|
+
this.stringCache = /* @__PURE__ */ new Map();
|
|
514
|
+
this.buffer = buffer;
|
|
515
|
+
this.view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
516
|
+
}
|
|
517
|
+
decode() {
|
|
518
|
+
const rootCount = this.readU32();
|
|
519
|
+
const nodes = [];
|
|
520
|
+
for (let i = 0; i < rootCount; i++) {
|
|
521
|
+
nodes.push(this.decodeNode());
|
|
522
|
+
}
|
|
523
|
+
return nodes;
|
|
524
|
+
}
|
|
525
|
+
decodeNode() {
|
|
526
|
+
const type = this.readU8();
|
|
527
|
+
if (type === NODE_TEXT) {
|
|
528
|
+
return {
|
|
529
|
+
node_type: "text",
|
|
530
|
+
content: this.readStringU32()
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
if (type === NODE_ELEMENT) {
|
|
534
|
+
const node_type = this.readStringU16();
|
|
535
|
+
const self_closing = this.readU8() === 1;
|
|
536
|
+
const attrCount = this.readU16();
|
|
537
|
+
let attributes = void 0;
|
|
538
|
+
if (attrCount > 0) {
|
|
539
|
+
attributes = {};
|
|
540
|
+
for (let i = 0; i < attrCount; i++) {
|
|
541
|
+
const key = this.readStringU16();
|
|
542
|
+
const attrKind = this.readU8();
|
|
543
|
+
if (attrKind === ATTR_TEXT) {
|
|
544
|
+
attributes[key] = { kind: "text", value: this.readStringU32() };
|
|
545
|
+
} else if (attrKind === ATTR_EXPRESSION) {
|
|
546
|
+
attributes[key] = { kind: "expression", value: this.readStringU32() };
|
|
547
|
+
} else if (attrKind === ATTR_BOOLEAN) {
|
|
548
|
+
attributes[key] = { kind: "boolean" };
|
|
549
|
+
} else if (attrKind === ATTR_AST) {
|
|
550
|
+
const subNodeCount = this.readU32();
|
|
551
|
+
const subNodes = [];
|
|
552
|
+
for (let j = 0; j < subNodeCount; j++) {
|
|
553
|
+
subNodes.push(this.decodeNode());
|
|
554
|
+
}
|
|
555
|
+
attributes[key] = { kind: "ast", value: subNodes };
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
const childCount = this.readU32();
|
|
560
|
+
const children = [];
|
|
561
|
+
if (childCount > 0) {
|
|
562
|
+
for (let i = 0; i < childCount; i++) {
|
|
563
|
+
children.push(this.decodeNode());
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
return {
|
|
567
|
+
node_type,
|
|
568
|
+
self_closing,
|
|
569
|
+
attributes,
|
|
570
|
+
children
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
throw new Error(`[Omni-Core] Unknown binary opcode: ${type} at offset ${this.offset}`);
|
|
574
|
+
}
|
|
575
|
+
readU8() {
|
|
576
|
+
const val = this.view.getUint8(this.offset);
|
|
577
|
+
this.offset += 1;
|
|
578
|
+
return val;
|
|
579
|
+
}
|
|
580
|
+
readU16() {
|
|
581
|
+
const val = this.view.getUint16(this.offset, true);
|
|
582
|
+
this.offset += 2;
|
|
583
|
+
return val;
|
|
584
|
+
}
|
|
585
|
+
readU32() {
|
|
586
|
+
const val = this.view.getUint32(this.offset, true);
|
|
587
|
+
this.offset += 4;
|
|
588
|
+
return val;
|
|
589
|
+
}
|
|
590
|
+
readStringU16() {
|
|
591
|
+
const len = this.readU16();
|
|
592
|
+
const str = this.decoder.decode(this.buffer.subarray(this.offset, this.offset + len));
|
|
593
|
+
this.offset += len;
|
|
594
|
+
let cached = this.stringCache.get(str);
|
|
595
|
+
if (cached) return cached;
|
|
596
|
+
this.stringCache.set(str, str);
|
|
597
|
+
return str;
|
|
598
|
+
}
|
|
599
|
+
readStringU32() {
|
|
600
|
+
const len = this.readU32();
|
|
601
|
+
const str = this.decoder.decode(this.buffer.subarray(this.offset, this.offset + len));
|
|
602
|
+
this.offset += len;
|
|
603
|
+
return str;
|
|
604
|
+
}
|
|
605
|
+
};
|
|
606
|
+
|
|
475
607
|
// src/parse.client.ts
|
|
476
608
|
var import_meta2 = {};
|
|
477
609
|
var _parseClient = null;
|
|
@@ -482,15 +614,17 @@ async function getClientParser() {
|
|
|
482
614
|
const wasmUrl = new URL("./omni_mdx_core_bg.wasm", import_meta2.url);
|
|
483
615
|
await wasm2.default(wasmUrl);
|
|
484
616
|
}
|
|
485
|
-
_parseClient = (mdx) => wasm2.
|
|
617
|
+
_parseClient = (mdx) => wasm2.parse_to_binary(mdx);
|
|
486
618
|
return _parseClient;
|
|
487
619
|
}
|
|
488
620
|
async function parseMdxClient(mdx) {
|
|
489
621
|
if (typeof window === "undefined") return [];
|
|
490
622
|
try {
|
|
491
623
|
const parse = await getClientParser();
|
|
492
|
-
const
|
|
493
|
-
|
|
624
|
+
const inputBuffer = typeof mdx === "string" ? new TextEncoder().encode(mdx) : mdx;
|
|
625
|
+
const binaryAst = parse(inputBuffer);
|
|
626
|
+
const decoder = new MdxBinaryDecoder(binaryAst);
|
|
627
|
+
return decoder.decode();
|
|
494
628
|
} catch (err) {
|
|
495
629
|
console.error("[omni-mdx] WASM client parse error:", err);
|
|
496
630
|
return [];
|
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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AEA,SAAS,iBAAiB;AAAA,EACxB;AAAA,EACA;AACF,GAGG;AACD,SAAO,6EAAG,cAAI,IAAI,CAAC,MAAM,MAAM,WAAW,MAAM,GAAG,UAAU,CAAC,GAAE;AAClE;AASO,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA,aAAa,CAAC;AAChB,GAA2B;AACzB,QAAM,cAAU,sBAAuB,IAAI;AAE3C,MAAI,CAAC,OAAO,CAAC,MAAM,QAAQ,GAAG,EAAG,QAAO;AAExC,SACE,6CAAC,SAAI,WAAU,iBACb,uDAAC,oBAAiB,KAAU,YAAwB,GACtD;AAEJ;;;AE1KA,IAAAC,eAAA;AAQA,IAAI,eAAiD;AAErD,eAAe,kBAAoD;AACjE,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,QAAwBA,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","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) {\n console.error(\"[omni-mdx] WASM client parse error:\", err);\n return [];\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,KAA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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,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;AAOO,SAAS,oBAAoB;AAChC,MAAI;AACJ,MAAI;AAC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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":";;;;;;;;;;;;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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;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 {
|
package/dist/server.js
CHANGED
|
@@ -14,6 +14,7 @@ var MdxBinaryDecoder = class {
|
|
|
14
14
|
constructor(buffer) {
|
|
15
15
|
this.offset = 0;
|
|
16
16
|
this.decoder = new TextDecoder("utf-8");
|
|
17
|
+
this.stringCache = /* @__PURE__ */ new Map();
|
|
17
18
|
this.buffer = buffer;
|
|
18
19
|
this.view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
19
20
|
}
|
|
@@ -94,6 +95,9 @@ var MdxBinaryDecoder = class {
|
|
|
94
95
|
const len = this.readU16();
|
|
95
96
|
const str = this.decoder.decode(this.buffer.subarray(this.offset, this.offset + len));
|
|
96
97
|
this.offset += len;
|
|
98
|
+
let cached = this.stringCache.get(str);
|
|
99
|
+
if (cached) return cached;
|
|
100
|
+
this.stringCache.set(str, str);
|
|
97
101
|
return str;
|
|
98
102
|
}
|
|
99
103
|
readStringU32() {
|
|
@@ -119,10 +123,7 @@ function getNativeModuleSync() {
|
|
|
119
123
|
for (const pkg of platformPackages) {
|
|
120
124
|
try {
|
|
121
125
|
const native = nativeRequire(pkg);
|
|
122
|
-
if (typeof native.parseToJson === "function") {
|
|
123
|
-
_nativeModule = native;
|
|
124
|
-
return _nativeModule;
|
|
125
|
-
} else if (typeof native.parse_to_json === "function") {
|
|
126
|
+
if (typeof native.parseToBinary === "function" || typeof native.parse_to_binary === "function" || typeof native.parseToJson === "function" || typeof native.parse_to_json === "function") {
|
|
126
127
|
_nativeModule = native;
|
|
127
128
|
return _nativeModule;
|
|
128
129
|
}
|
|
@@ -161,9 +162,11 @@ function getNativeModuleSync() {
|
|
|
161
162
|
);
|
|
162
163
|
}
|
|
163
164
|
function getParseFn(native) {
|
|
165
|
+
if (typeof native.parseToBinary === "function") return native.parseToBinary;
|
|
166
|
+
if (typeof native.parse_to_binary === "function") return native.parse_to_binary;
|
|
167
|
+
if (typeof native.parse === "function") return native.parse;
|
|
164
168
|
if (typeof native.parseToJson === "function") return native.parseToJson;
|
|
165
169
|
if (typeof native.parse_to_json === "function") return native.parse_to_json;
|
|
166
|
-
if (typeof native.parse === "function") return native.parse;
|
|
167
170
|
throw new Error("[toaq-oss/omni-mdx] Native parser lacks a valid parse function.");
|
|
168
171
|
}
|
|
169
172
|
async function parseMdx(mdx) {
|
|
@@ -173,7 +176,8 @@ async function parseMdx(mdx) {
|
|
|
173
176
|
try {
|
|
174
177
|
result = parse(mdx);
|
|
175
178
|
} catch (err) {
|
|
176
|
-
|
|
179
|
+
const sourceSnippet = typeof mdx === "string" ? mdx.slice(0, 50) : "Binary Data";
|
|
180
|
+
throw new MDXParseError(err?.message ?? String(err), sourceSnippet);
|
|
177
181
|
}
|
|
178
182
|
if (result instanceof Uint8Array || Buffer.isBuffer(result)) {
|
|
179
183
|
const decoder = new MdxBinaryDecoder(result);
|
|
@@ -212,7 +216,8 @@ function parseMdxSync(mdx) {
|
|
|
212
216
|
try {
|
|
213
217
|
result = parse(mdx);
|
|
214
218
|
} catch (err) {
|
|
215
|
-
|
|
219
|
+
const sourceSnippet = typeof mdx === "string" ? mdx.slice(0, 50) : "Binary Data";
|
|
220
|
+
throw new MDXParseError(err?.message ?? String(err), sourceSnippet);
|
|
216
221
|
}
|
|
217
222
|
if (result instanceof Uint8Array || Buffer.isBuffer(result)) {
|
|
218
223
|
const decoder = new MdxBinaryDecoder(result);
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/parse.server.ts","../src/utils/binaryDecoder.ts","../src/MDXServerRenderer.tsx"],"sourcesContent":["import type { AstNode } from \"./MDXServerRenderer\";\nimport { createRequire } from \"module\";\nimport { fileURLToPath } from \"url\";\nimport { dirname, resolve } from \"path\";\nimport { MdxBinaryDecoder } from \"./utils/binaryDecoder\";\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 (typeof native.parseToJson === \"function\") {\n _nativeModule = native;\n return _nativeModule;\n } else if (typeof native.parse_to_json === \"function\") {\n _nativeModule = native;\n return _nativeModule;\n }\n } catch { /* not installed on this platform */ }\n }\n\n // Fallback local\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) => any {\n if (typeof native.parseToJson === \"function\") return native.parseToJson;\n if (typeof native.parse_to_json === \"function\") return native.parse_to_json;\n if (typeof native.parse === \"function\") return native.parse;\n throw new Error(\"[toaq-oss/omni-mdx] Native parser lacks a valid parse function.\");\n}\n\nexport async function parseMdx(mdx: string): Promise<AstNode[]> {\n const native = getNativeModuleSync();\n const parse = getParseFn(native);\n let result: any;\n \n try {\n result = parse(mdx);\n } catch (err: any) {\n throw new MDXParseError(err?.message ?? String(err), mdx);\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: string): AstNode[] {\n const native = getNativeModuleSync();\n const parse = getParseFn(native);\n\n let result: any;\n try {\n result = parse(mdx);\n } catch (err: any) {\n throw new MDXParseError(err?.message ?? String(err), mdx);\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: string): Promise<string> {\n const native = getNativeModuleSync();\n \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 return compileFn(mdx);\n } catch (err: any) {\n throw new MDXParseError(err?.message ?? String(err), mdx);\n }\n}\n\nexport function compileToJsxSync(mdx: string): string {\n const native = getNativeModuleSync();\n \n const compileFn = native.compileToJsx || native.compile_to_jsx;\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 return compileFn(mdx);\n } catch (err: any) {\n throw new MDXParseError(err?.message ?? String(err), mdx);\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 \"../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\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 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\";\n\n// AST types (mirror Rust output exactly)\n\nexport type AttrValueKind =\n | { kind: \"text\"; value: string }\n | { kind: \"expression\"; value: string }\n | { kind: \"boolean\" }\n | { kind: \"ast\"; value: AstNode[] };\n\nexport interface AstNode {\n node_type: string;\n content?: string;\n self_closing?: boolean;\n child_count?: number; // Rendu optionnel\n attributes?: Record<string, AttrValueKind> | string; // Accepte l'objet binaire ou la string\n children?: AstNode[];\n}\n\nexport type MDXComponents = Record<string, React.ComponentType<any>>;\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 try {\n const html = katex.renderToString(node.content ?? \"\", {\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\">{node.content}</span>;\n }\n }\n\n if (node.node_type === \"BlockMath\") {\n try {\n const html = katex.renderToString(node.content ?? \"\", {\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\">{node.content}</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: <{node.node_type}></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,EAM5B,YAAY,QAAoB;AAHhC,SAAQ,SAAiB;AACzB,SAAQ,UAAU,IAAI,YAAY,OAAO;AAGvC,SAAK,SAAS;AACd,SAAK,OAAO,IAAI,SAAS,OAAO,QAAQ,OAAO,YAAY,OAAO,UAAU;AAAA,EAC9E;AAAA,EAEO,SAAoB;AACzB,UAAM,YAAY,KAAK,QAAQ;AAC/B,UAAM,QAAmB,CAAC;AAC1B,aAAS,IAAI,GAAG,IAAI,WAAW,KAAK;AAClC,YAAM,KAAK,KAAK,WAAW,CAAC;AAAA,IAC9B;AACA,WAAO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AEA,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"],"sourcesContent":["import type { AstNode } from \"./MDXServerRenderer\";\nimport { createRequire } from \"module\";\nimport { fileURLToPath } from \"url\";\nimport { dirname, resolve } from \"path\";\nimport { MdxBinaryDecoder } from \"./utils/binaryDecoder\";\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 // Fallback local\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\nexport async function parseMdx(mdx: string | Buffer | Uint8Array): Promise<AstNode[]> {\n const native = getNativeModuleSync();\n const parse = getParseFn(native);\n let result: any;\n \n try {\n result = parse(mdx);\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: string | Buffer | Uint8Array): AstNode[] {\n const native = getNativeModuleSync();\n const parse = getParseFn(native);\n\n let result: any;\n try {\n result = parse(mdx);\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: string): Promise<string> {\n const native = getNativeModuleSync();\n \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 return compileFn(mdx);\n } catch (err: any) {\n throw new MDXParseError(err?.message ?? String(err), mdx);\n }\n}\n\nexport function compileToJsxSync(mdx: string): string {\n const native = getNativeModuleSync();\n \n const compileFn = native.compileToJsx || native.compile_to_jsx;\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 return compileFn(mdx);\n } catch (err: any) {\n throw new MDXParseError(err?.message ?? String(err), mdx);\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 \"../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}","/**\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\";\n\n// AST types (mirror Rust output exactly)\n\nexport type AttrValueKind =\n | { kind: \"text\"; value: string }\n | { kind: \"expression\"; value: string }\n | { kind: \"boolean\" }\n | { kind: \"ast\"; value: AstNode[] };\n\nexport interface AstNode {\n node_type: string;\n content?: string;\n self_closing?: boolean;\n child_count?: number; // Rendu optionnel\n attributes?: Record<string, AttrValueKind> | string; // Accepte l'objet binaire ou la string\n children?: AstNode[];\n}\n\nexport type MDXComponents = Record<string, React.ComponentType<any>>;\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 try {\n const html = katex.renderToString(node.content ?? \"\", {\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\">{node.content}</span>;\n }\n }\n\n if (node.node_type === \"BlockMath\") {\n try {\n const html = katex.renderToString(node.content ?? \"\", {\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\">{node.content}</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: <{node.node_type}></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,OAAO,QAAQ,OAAO,YAAY,OAAO,UAAU;AAAA,EAC9E;AAAA,EAEO,SAAoB;AACzB,UAAM,YAAY,KAAK,QAAQ;AAC/B,UAAM,QAAmB,CAAC;AAC1B,aAAS,IAAI,GAAG,IAAI,WAAW,KAAK;AAClC,YAAM,KAAK,KAAK,WAAW,CAAC;AAAA,IAC9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Ae,8BAAC,UAAM,mBAAQ,KAAvC,GAA8C;AAAA,EACjE;AAEA,MAAI,UAAU,IAAI,KAAK,SAAS,GAAG;AACjC,UAAM,MAAM,KAAK;AACjB,WACE,oBAAC,OAAe,GAAG,eAChB,8BADO,GAEV;AAAA,EAEJ;AAEA,MAAI,QAAQ,IAAI,aAAa,eAAe;AAC1C,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":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toaq-oss/omni-mdx",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"description": "MDX parser + renderer for Next.js \u2014 Rust core, RSC-compatible",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"typecheck": "tsc --noEmit"
|
|
37
37
|
},
|
|
38
38
|
"optionalDependencies": {
|
|
39
|
-
"@toaq-oss/omni-mdx-darwin-arm64": "0.2.
|
|
40
|
-
"@toaq-oss/omni-mdx-darwin-x64": "0.2.
|
|
41
|
-
"@toaq-oss/omni-mdx-linux-x64-gnu": "0.2.
|
|
42
|
-
"@toaq-oss/omni-mdx-win32-x64-msvc": "0.2.
|
|
39
|
+
"@toaq-oss/omni-mdx-darwin-arm64": "0.2.5",
|
|
40
|
+
"@toaq-oss/omni-mdx-darwin-x64": "0.2.5",
|
|
41
|
+
"@toaq-oss/omni-mdx-linux-x64-gnu": "0.2.5",
|
|
42
|
+
"@toaq-oss/omni-mdx-win32-x64-msvc": "0.2.5"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"react": ">=18.0.0"
|