@toaq-oss/omni-mdx 0.1.22 → 0.1.23
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.d.cts +81 -0
- package/dist/client.d.ts +81 -0
- package/package.json +4 -1
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { Component, ReactNode, ErrorInfo } from 'react';
|
|
3
|
+
|
|
4
|
+
// AST types (mirror Rust output exactly)
|
|
5
|
+
|
|
6
|
+
type AttrValueKind =
|
|
7
|
+
| { kind: "text"; value: string }
|
|
8
|
+
| { kind: "expression"; value: string }
|
|
9
|
+
| { kind: "boolean" }
|
|
10
|
+
| { kind: "ast"; value: AstNode[] };
|
|
11
|
+
|
|
12
|
+
interface AstNode {
|
|
13
|
+
node_type: string;
|
|
14
|
+
content?: string;
|
|
15
|
+
self_closing?: boolean;
|
|
16
|
+
child_count?: number;
|
|
17
|
+
attributes?: Record<string, AttrValueKind> | string;
|
|
18
|
+
children?: AstNode[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
type MDXComponents = Record<string, React.ComponentType<any>>;
|
|
22
|
+
|
|
23
|
+
interface MDXClientRendererProps {
|
|
24
|
+
/** AST from parseMdx() — must be JSON-serialisable (pass via Server Component). */
|
|
25
|
+
ast: AstNode[];
|
|
26
|
+
/** Component registry — same shape as MDX_COMPONENTS. */
|
|
27
|
+
components?: MDXComponents;
|
|
28
|
+
}
|
|
29
|
+
declare function MDXClientRenderer({ ast, components, }: MDXClientRendererProps): react_jsx_runtime.JSX.Element | null;
|
|
30
|
+
|
|
31
|
+
interface Props {
|
|
32
|
+
children: ReactNode;
|
|
33
|
+
/** The name of the MDX component being rendered (e.g., 'Chart', 'SplitLayout') */
|
|
34
|
+
componentName?: string;
|
|
35
|
+
}
|
|
36
|
+
interface State {
|
|
37
|
+
hasError: boolean;
|
|
38
|
+
error: Error | null;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A dedicated Error Boundary for MDX rendering.
|
|
42
|
+
*
|
|
43
|
+
* If a React component injected via MDX crashes (e.g., due to a data parsing error
|
|
44
|
+
* inside a <Chart />), this boundary intercepts the error. This prevents the
|
|
45
|
+
* entire React tree from unmounting and displays a clean fallback UI to
|
|
46
|
+
* isolate the defective component.
|
|
47
|
+
*/
|
|
48
|
+
declare class MDXErrorBoundary extends Component<Props, State> {
|
|
49
|
+
constructor(props: Props);
|
|
50
|
+
/**
|
|
51
|
+
* Updates the state when an error occurs to trigger the fallback UI rendering.
|
|
52
|
+
*/
|
|
53
|
+
static getDerivedStateFromError(error: Error): State;
|
|
54
|
+
/**
|
|
55
|
+
* Intercepts the error and its contextual information.
|
|
56
|
+
* This is the ideal place to hook into monitoring tools (like Sentry or Datadog)
|
|
57
|
+
* for production environments.
|
|
58
|
+
*/
|
|
59
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
60
|
+
render(): string | number | boolean | Iterable<ReactNode> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
declare function parseMdxClient(mdx: string | Uint8Array): Promise<AstNode[]>;
|
|
64
|
+
|
|
65
|
+
declare class MdxBinaryDecoder {
|
|
66
|
+
private view;
|
|
67
|
+
private buffer;
|
|
68
|
+
private offset;
|
|
69
|
+
private decoder;
|
|
70
|
+
private stringCache;
|
|
71
|
+
constructor(buffer: Uint8Array);
|
|
72
|
+
decode(): AstNode[];
|
|
73
|
+
private decodeNode;
|
|
74
|
+
private readU8;
|
|
75
|
+
private readU16;
|
|
76
|
+
private readU32;
|
|
77
|
+
private readStringU16;
|
|
78
|
+
private readStringU32;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export { type AstNode, MDXClientRenderer, type MDXComponents, MDXErrorBoundary, MdxBinaryDecoder, parseMdxClient as parseMdx };
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { Component, ReactNode, ErrorInfo } from 'react';
|
|
3
|
+
|
|
4
|
+
// AST types (mirror Rust output exactly)
|
|
5
|
+
|
|
6
|
+
type AttrValueKind =
|
|
7
|
+
| { kind: "text"; value: string }
|
|
8
|
+
| { kind: "expression"; value: string }
|
|
9
|
+
| { kind: "boolean" }
|
|
10
|
+
| { kind: "ast"; value: AstNode[] };
|
|
11
|
+
|
|
12
|
+
interface AstNode {
|
|
13
|
+
node_type: string;
|
|
14
|
+
content?: string;
|
|
15
|
+
self_closing?: boolean;
|
|
16
|
+
child_count?: number;
|
|
17
|
+
attributes?: Record<string, AttrValueKind> | string;
|
|
18
|
+
children?: AstNode[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
type MDXComponents = Record<string, React.ComponentType<any>>;
|
|
22
|
+
|
|
23
|
+
interface MDXClientRendererProps {
|
|
24
|
+
/** AST from parseMdx() — must be JSON-serialisable (pass via Server Component). */
|
|
25
|
+
ast: AstNode[];
|
|
26
|
+
/** Component registry — same shape as MDX_COMPONENTS. */
|
|
27
|
+
components?: MDXComponents;
|
|
28
|
+
}
|
|
29
|
+
declare function MDXClientRenderer({ ast, components, }: MDXClientRendererProps): react_jsx_runtime.JSX.Element | null;
|
|
30
|
+
|
|
31
|
+
interface Props {
|
|
32
|
+
children: ReactNode;
|
|
33
|
+
/** The name of the MDX component being rendered (e.g., 'Chart', 'SplitLayout') */
|
|
34
|
+
componentName?: string;
|
|
35
|
+
}
|
|
36
|
+
interface State {
|
|
37
|
+
hasError: boolean;
|
|
38
|
+
error: Error | null;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A dedicated Error Boundary for MDX rendering.
|
|
42
|
+
*
|
|
43
|
+
* If a React component injected via MDX crashes (e.g., due to a data parsing error
|
|
44
|
+
* inside a <Chart />), this boundary intercepts the error. This prevents the
|
|
45
|
+
* entire React tree from unmounting and displays a clean fallback UI to
|
|
46
|
+
* isolate the defective component.
|
|
47
|
+
*/
|
|
48
|
+
declare class MDXErrorBoundary extends Component<Props, State> {
|
|
49
|
+
constructor(props: Props);
|
|
50
|
+
/**
|
|
51
|
+
* Updates the state when an error occurs to trigger the fallback UI rendering.
|
|
52
|
+
*/
|
|
53
|
+
static getDerivedStateFromError(error: Error): State;
|
|
54
|
+
/**
|
|
55
|
+
* Intercepts the error and its contextual information.
|
|
56
|
+
* This is the ideal place to hook into monitoring tools (like Sentry or Datadog)
|
|
57
|
+
* for production environments.
|
|
58
|
+
*/
|
|
59
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
60
|
+
render(): string | number | boolean | Iterable<ReactNode> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
declare function parseMdxClient(mdx: string | Uint8Array): Promise<AstNode[]>;
|
|
64
|
+
|
|
65
|
+
declare class MdxBinaryDecoder {
|
|
66
|
+
private view;
|
|
67
|
+
private buffer;
|
|
68
|
+
private offset;
|
|
69
|
+
private decoder;
|
|
70
|
+
private stringCache;
|
|
71
|
+
constructor(buffer: Uint8Array);
|
|
72
|
+
decode(): AstNode[];
|
|
73
|
+
private decodeNode;
|
|
74
|
+
private readU8;
|
|
75
|
+
private readU16;
|
|
76
|
+
private readU32;
|
|
77
|
+
private readStringU16;
|
|
78
|
+
private readStringU32;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export { type AstNode, MDXClientRenderer, type MDXComponents, MDXErrorBoundary, MdxBinaryDecoder, parseMdxClient as parseMdx };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toaq-oss/omni-mdx",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.23",
|
|
4
4
|
"description": "MDX parser + renderer for Next.js \u2014 Rust core, RSC-compatible",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -10,13 +10,16 @@
|
|
|
10
10
|
},
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
13
14
|
"import": "./dist/index.js",
|
|
14
15
|
"require": "./dist/index.cjs"
|
|
15
16
|
},
|
|
16
17
|
"./server": {
|
|
18
|
+
"types": "./dist/server.d.ts",
|
|
17
19
|
"import": "./dist/server.js"
|
|
18
20
|
},
|
|
19
21
|
"./client": {
|
|
22
|
+
"types": "./dist/client.d.ts",
|
|
20
23
|
"import": "./dist/client.js",
|
|
21
24
|
"require": "./dist/client.cjs"
|
|
22
25
|
},
|