@stream-mdx/react 0.4.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/CHANGELOG.md +385 -4
  2. package/README.md +141 -16
  3. package/dist/blocks-renderer-DAOBFBfi.d.ts +29 -0
  4. package/dist/blocks-renderer-DQEL1kJW.d.cts +29 -0
  5. package/dist/components/bottom-stick-scroll-area.cjs +268 -0
  6. package/dist/components/bottom-stick-scroll-area.d.cts +36 -0
  7. package/dist/components/bottom-stick-scroll-area.d.ts +36 -0
  8. package/dist/components/bottom-stick-scroll-area.mjs +249 -0
  9. package/dist/components/diff-renderer.cjs +86 -0
  10. package/dist/components/diff-renderer.d.cts +11 -0
  11. package/dist/components/diff-renderer.d.ts +11 -0
  12. package/dist/components/diff-renderer.mjs +66 -0
  13. package/dist/components/index.cjs +2879 -1295
  14. package/dist/components/index.d.cts +9 -2
  15. package/dist/components/index.d.ts +9 -2
  16. package/dist/components/index.mjs +2842 -1277
  17. package/dist/components/katex-math.cjs +220 -0
  18. package/dist/components/katex-math.d.cts +10 -0
  19. package/dist/components/katex-math.d.ts +10 -0
  20. package/dist/components/katex-math.mjs +188 -0
  21. package/dist/contexts/math-tracker.cjs +240 -521
  22. package/dist/contexts/math-tracker.mjs +235 -513
  23. package/dist/index-Cmne1yUK.d.cts +723 -0
  24. package/dist/index-D7dyyu3q.d.ts +723 -0
  25. package/dist/index.cjs +13180 -5640
  26. package/dist/index.d.cts +72 -40
  27. package/dist/index.d.ts +72 -40
  28. package/dist/index.mjs +12587 -5038
  29. package/dist/math/display-wrapper.cjs +7 -15
  30. package/dist/math/display-wrapper.d.cts +2 -2
  31. package/dist/math/display-wrapper.d.ts +2 -2
  32. package/dist/math/display-wrapper.mjs +2 -6
  33. package/dist/node-views-Bpc6Gkgl.d.cts +13 -0
  34. package/dist/node-views-DpnYdaAS.d.ts +13 -0
  35. package/dist/renderer/hooks.cjs +35 -20
  36. package/dist/renderer/hooks.d.cts +22 -1
  37. package/dist/renderer/hooks.d.ts +22 -1
  38. package/dist/renderer/hooks.mjs +27 -12
  39. package/dist/renderer/patch-batching.cjs +7 -8
  40. package/dist/renderer/patch-batching.d.cts +1 -1
  41. package/dist/renderer/patch-batching.d.ts +1 -1
  42. package/dist/renderer/patch-batching.mjs +2 -1
  43. package/dist/renderer/patch-coalescing.cjs +5 -8
  44. package/dist/renderer/patch-commit-scheduler.cjs +160 -326
  45. package/dist/renderer/patch-commit-scheduler.d.cts +28 -4
  46. package/dist/renderer/patch-commit-scheduler.d.ts +28 -4
  47. package/dist/renderer/patch-commit-scheduler.mjs +157 -318
  48. package/dist/renderer/store.cjs +3847 -1099
  49. package/dist/renderer/store.d.cts +111 -3
  50. package/dist/renderer/store.d.ts +111 -3
  51. package/dist/renderer/store.mjs +3847 -1085
  52. package/dist/renderer/virtualized-code.cjs +415 -71
  53. package/dist/renderer/virtualized-code.d.cts +24 -23
  54. package/dist/renderer/virtualized-code.d.ts +24 -23
  55. package/dist/renderer/virtualized-code.mjs +409 -62
  56. package/dist/renderer.cjs +10939 -3974
  57. package/dist/renderer.d.cts +100 -29
  58. package/dist/renderer.d.ts +100 -29
  59. package/dist/renderer.mjs +10711 -3697
  60. package/dist/server-regions-CPLHGli0.d.cts +32 -0
  61. package/dist/server-regions-mUhyoKi7.d.ts +32 -0
  62. package/dist/server.cjs +10286 -3365
  63. package/dist/server.d.cts +17 -247
  64. package/dist/server.d.ts +17 -247
  65. package/dist/server.mjs +10565 -3619
  66. package/dist/{streaming-markdown-DOc2uLiP.d.ts → streaming-markdown-yELbJxyH.d.ts} +51 -55
  67. package/dist/{streaming-markdown-D-JcByd9.d.cts → streaming-markdown-zVwFuaJG.d.cts} +51 -55
  68. package/dist/streaming-markdown.cjs +11828 -4879
  69. package/dist/streaming-markdown.d.cts +9 -2
  70. package/dist/streaming-markdown.d.ts +9 -2
  71. package/dist/streaming-markdown.mjs +11820 -4821
  72. package/dist/trusted-mdx/index.cjs +833 -0
  73. package/dist/trusted-mdx/index.d.cts +11 -0
  74. package/dist/trusted-mdx/index.d.ts +11 -0
  75. package/dist/trusted-mdx/index.mjs +807 -0
  76. package/dist/trusted-mdx/native-children-slot.cjs +45 -0
  77. package/dist/trusted-mdx/native-children-slot.d.cts +11 -0
  78. package/dist/trusted-mdx/native-children-slot.d.ts +11 -0
  79. package/dist/trusted-mdx/native-children-slot.mjs +24 -0
  80. package/dist/trusted-mdx/server.cjs +752 -0
  81. package/dist/trusted-mdx/server.d.cts +24 -0
  82. package/dist/trusted-mdx/server.d.ts +24 -0
  83. package/dist/trusted-mdx/server.mjs +724 -0
  84. package/dist/trusted-mdx-contract-ElKpkDI5.d.cts +113 -0
  85. package/dist/trusted-mdx-contract-ElKpkDI5.d.ts +113 -0
  86. package/dist/utils/inline-html.cjs +246 -147
  87. package/dist/utils/inline-html.d.cts +39 -6
  88. package/dist/utils/inline-html.d.ts +39 -6
  89. package/dist/utils/inline-html.mjs +237 -134
  90. package/package.json +52 -18
  91. package/shadcn/README.md +28 -0
  92. package/shadcn/bottom-stick-scroll-area.tsx +358 -0
  93. package/dist/index-D2MYusAM.d.cts +0 -248
  94. package/dist/index-D2MYusAM.d.ts +0 -248
  95. package/dist/mdx-client.cjs +0 -408
  96. package/dist/mdx-client.d.cts +0 -113
  97. package/dist/mdx-client.d.ts +0 -113
  98. package/dist/mdx-client.mjs +0 -369
  99. package/dist/mdx-coordinator.cjs +0 -563
  100. package/dist/mdx-coordinator.d.cts +0 -21
  101. package/dist/mdx-coordinator.d.ts +0 -21
  102. package/dist/mdx-coordinator.mjs +0 -529
  103. package/dist/renderer/node-views.cjs +0 -1642
  104. package/dist/renderer/node-views.d.cts +0 -12
  105. package/dist/renderer/node-views.d.ts +0 -12
  106. package/dist/renderer/node-views.mjs +0 -1616
@@ -1,113 +0,0 @@
1
- import { Block } from '@stream-mdx/core';
2
- import React from 'react';
3
-
4
- type CompiledFetchOptions = {
5
- signal?: AbortSignal;
6
- };
7
- /**
8
- * MDX compilation client
9
- */
10
- declare class MDXClient {
11
- private compileEndpoint;
12
- private cache;
13
- private inlineModules;
14
- private compiledCache;
15
- private compiledInflight;
16
- constructor(compileEndpoint?: string);
17
- /**
18
- * Compile MDX block on server
19
- */
20
- compile(block: Block): Promise<CompiledMDX>;
21
- private getCompiledInternal;
22
- /**
23
- * Get compiled MDX by reference
24
- */
25
- getCompiled(ref: {
26
- id: string;
27
- }): Promise<CompiledMDX>;
28
- getCompiled(ref: {
29
- id: string;
30
- }, options: CompiledFetchOptions): Promise<CompiledMDX>;
31
- /**
32
- * Clear compilation cache
33
- */
34
- clearCache(): void;
35
- registerInlineModule(compiled: CompiledMDX): void;
36
- clearInlineModules(): void;
37
- /**
38
- * Actual compilation implementation
39
- */
40
- private doCompile;
41
- private fetchCompiled;
42
- private cloneCompiled;
43
- }
44
- /**
45
- * Compiled MDX result
46
- */
47
- interface CompiledMDX {
48
- id: string;
49
- code: string;
50
- dependencies: string[];
51
- cached?: boolean;
52
- timestamp?: number;
53
- }
54
- /**
55
- * MDX component factory
56
- */
57
- declare class MDXComponentFactory {
58
- private components;
59
- private mdxClient;
60
- private baseComponents;
61
- private customComponents;
62
- constructor(mdxClient: MDXClient);
63
- registerInlineModule(module: CompiledMDX): void;
64
- /**
65
- * Create React component from compiled MDX
66
- */
67
- createComponent(ref: {
68
- id: string;
69
- }): Promise<React.ComponentType>;
70
- /**
71
- * Safely evaluate compiled MDX code
72
- */
73
- private evaluateCompiledMDX;
74
- /**
75
- * Create safe evaluation context for MDX
76
- */
77
- private createEvaluationContext;
78
- private resolveEvaluatedModule;
79
- private getComponents;
80
- /**
81
- * Register or replace custom MDX components
82
- */
83
- registerComponents(components: Record<string, React.ComponentType | undefined>, options?: {
84
- replace?: boolean;
85
- }): void;
86
- /**
87
- * Get base MDX components
88
- */
89
- private createBaseComponents;
90
- /**
91
- * Clear component cache
92
- */
93
- clearCache(): void;
94
- clearCustomComponents(): void;
95
- }
96
- /**
97
- * Get or create global MDX client
98
- */
99
- declare function getMDXClient(compileEndpoint?: string): MDXClient;
100
- /**
101
- * Get or create global component factory
102
- */
103
- declare function getMDXComponentFactory(compileEndpoint?: string): MDXComponentFactory;
104
- declare function registerMDXComponents(components: Record<string, React.ComponentType | undefined>, options?: {
105
- replace?: boolean;
106
- }): void;
107
- declare function registerInlineMdxModule(compiled: {
108
- id: string;
109
- code: string;
110
- dependencies?: string[];
111
- }): void;
112
-
113
- export { type CompiledMDX, MDXClient, MDXComponentFactory, getMDXClient, getMDXComponentFactory, registerInlineMdxModule, registerMDXComponents };
@@ -1,113 +0,0 @@
1
- import { Block } from '@stream-mdx/core';
2
- import React from 'react';
3
-
4
- type CompiledFetchOptions = {
5
- signal?: AbortSignal;
6
- };
7
- /**
8
- * MDX compilation client
9
- */
10
- declare class MDXClient {
11
- private compileEndpoint;
12
- private cache;
13
- private inlineModules;
14
- private compiledCache;
15
- private compiledInflight;
16
- constructor(compileEndpoint?: string);
17
- /**
18
- * Compile MDX block on server
19
- */
20
- compile(block: Block): Promise<CompiledMDX>;
21
- private getCompiledInternal;
22
- /**
23
- * Get compiled MDX by reference
24
- */
25
- getCompiled(ref: {
26
- id: string;
27
- }): Promise<CompiledMDX>;
28
- getCompiled(ref: {
29
- id: string;
30
- }, options: CompiledFetchOptions): Promise<CompiledMDX>;
31
- /**
32
- * Clear compilation cache
33
- */
34
- clearCache(): void;
35
- registerInlineModule(compiled: CompiledMDX): void;
36
- clearInlineModules(): void;
37
- /**
38
- * Actual compilation implementation
39
- */
40
- private doCompile;
41
- private fetchCompiled;
42
- private cloneCompiled;
43
- }
44
- /**
45
- * Compiled MDX result
46
- */
47
- interface CompiledMDX {
48
- id: string;
49
- code: string;
50
- dependencies: string[];
51
- cached?: boolean;
52
- timestamp?: number;
53
- }
54
- /**
55
- * MDX component factory
56
- */
57
- declare class MDXComponentFactory {
58
- private components;
59
- private mdxClient;
60
- private baseComponents;
61
- private customComponents;
62
- constructor(mdxClient: MDXClient);
63
- registerInlineModule(module: CompiledMDX): void;
64
- /**
65
- * Create React component from compiled MDX
66
- */
67
- createComponent(ref: {
68
- id: string;
69
- }): Promise<React.ComponentType>;
70
- /**
71
- * Safely evaluate compiled MDX code
72
- */
73
- private evaluateCompiledMDX;
74
- /**
75
- * Create safe evaluation context for MDX
76
- */
77
- private createEvaluationContext;
78
- private resolveEvaluatedModule;
79
- private getComponents;
80
- /**
81
- * Register or replace custom MDX components
82
- */
83
- registerComponents(components: Record<string, React.ComponentType | undefined>, options?: {
84
- replace?: boolean;
85
- }): void;
86
- /**
87
- * Get base MDX components
88
- */
89
- private createBaseComponents;
90
- /**
91
- * Clear component cache
92
- */
93
- clearCache(): void;
94
- clearCustomComponents(): void;
95
- }
96
- /**
97
- * Get or create global MDX client
98
- */
99
- declare function getMDXClient(compileEndpoint?: string): MDXClient;
100
- /**
101
- * Get or create global component factory
102
- */
103
- declare function getMDXComponentFactory(compileEndpoint?: string): MDXComponentFactory;
104
- declare function registerMDXComponents(components: Record<string, React.ComponentType | undefined>, options?: {
105
- replace?: boolean;
106
- }): void;
107
- declare function registerInlineMdxModule(compiled: {
108
- id: string;
109
- code: string;
110
- dependencies?: string[];
111
- }): void;
112
-
113
- export { type CompiledMDX, MDXClient, MDXComponentFactory, getMDXClient, getMDXComponentFactory, registerInlineMdxModule, registerMDXComponents };
@@ -1,369 +0,0 @@
1
- "use client";
2
-
3
- // src/mdx-client.ts
4
- import React from "react";
5
- import * as ReactJsxRuntime from "react/jsx-runtime";
6
- var withClassName = (tag, className) => {
7
- return (props) => React.createElement(tag, { className, ...props });
8
- };
9
- function assignMdxChildKey(child, index) {
10
- if (child == null) return child;
11
- if (Array.isArray(child)) {
12
- return child.map((entry, subIndex) => assignMdxChildKey(entry, `${index}-${subIndex}`));
13
- }
14
- if (React.isValidElement(child)) {
15
- if (child.key !== null && child.key !== void 0) {
16
- return child;
17
- }
18
- return React.cloneElement(child, { key: index });
19
- }
20
- return child;
21
- }
22
- var MDXClient = class {
23
- constructor(compileEndpoint = "/api/mdx-compile-v2") {
24
- this.cache = /* @__PURE__ */ new Map();
25
- this.inlineModules = /* @__PURE__ */ new Map();
26
- this.compiledCache = /* @__PURE__ */ new Map();
27
- this.compiledInflight = /* @__PURE__ */ new Map();
28
- this.compileEndpoint = compileEndpoint;
29
- }
30
- /**
31
- * Compile MDX block on server
32
- */
33
- async compile(block) {
34
- if (block.type !== "mdx") {
35
- throw new Error("Block is not MDX type");
36
- }
37
- const cacheKey = block.id;
38
- const cachedPromise = this.cache.get(cacheKey);
39
- if (cachedPromise) {
40
- return cachedPromise;
41
- }
42
- const compilationPromise = this.doCompile(block);
43
- this.cache.set(cacheKey, compilationPromise);
44
- try {
45
- const result = await compilationPromise;
46
- return result;
47
- } catch (error) {
48
- this.cache.delete(cacheKey);
49
- throw error;
50
- }
51
- }
52
- async getCompiledInternal(ref) {
53
- const inline = this.inlineModules.get(ref.id);
54
- if (inline) {
55
- return this.cloneCompiled(inline);
56
- }
57
- const cached = this.compiledCache.get(ref.id);
58
- if (cached) {
59
- return this.cloneCompiled(cached);
60
- }
61
- const inflight = this.compiledInflight.get(ref.id);
62
- if (inflight) {
63
- const resolved = await inflight;
64
- return this.cloneCompiled(resolved);
65
- }
66
- const fetchPromise = this.fetchCompiled(ref);
67
- this.compiledInflight.set(ref.id, fetchPromise);
68
- try {
69
- const data = await fetchPromise;
70
- this.compiledCache.set(ref.id, data);
71
- return this.cloneCompiled(data);
72
- } finally {
73
- this.compiledInflight.delete(ref.id);
74
- }
75
- }
76
- async getCompiled(ref, options) {
77
- if (options?.signal) {
78
- const inline = this.inlineModules.get(ref.id);
79
- if (inline) {
80
- return this.cloneCompiled(inline);
81
- }
82
- const cached = this.compiledCache.get(ref.id);
83
- if (cached) {
84
- return this.cloneCompiled(cached);
85
- }
86
- const data = await this.fetchCompiled(ref, options);
87
- this.compiledCache.set(ref.id, data);
88
- return this.cloneCompiled(data);
89
- }
90
- return this.getCompiledInternal(ref);
91
- }
92
- /**
93
- * Clear compilation cache
94
- */
95
- clearCache() {
96
- this.cache.clear();
97
- this.compiledCache.clear();
98
- this.compiledInflight.clear();
99
- }
100
- registerInlineModule(compiled) {
101
- this.inlineModules.set(compiled.id, {
102
- ...compiled,
103
- dependencies: Array.isArray(compiled.dependencies) ? [...compiled.dependencies] : []
104
- });
105
- }
106
- clearInlineModules() {
107
- this.inlineModules.clear();
108
- }
109
- /**
110
- * Actual compilation implementation
111
- */
112
- async doCompile(block) {
113
- const response = await fetch(this.compileEndpoint, {
114
- method: "POST",
115
- headers: {
116
- "Content-Type": "application/json"
117
- },
118
- body: JSON.stringify({
119
- content: block.payload.raw,
120
- blockId: block.id
121
- })
122
- });
123
- if (!response.ok) {
124
- const error = await response.json().catch(() => ({ error: "Unknown error" }));
125
- throw new Error(`MDX compilation failed: ${error.error || response.statusText}`);
126
- }
127
- const data = await response.json();
128
- return {
129
- id: data.id,
130
- code: data.code,
131
- dependencies: data.dependencies || [],
132
- cached: data.cached || false
133
- };
134
- }
135
- async fetchCompiled(ref, options) {
136
- const response = await fetch(`${this.compileEndpoint}?id=${ref.id}`, {
137
- signal: options?.signal
138
- });
139
- if (!response.ok) {
140
- throw new Error(`Failed to get compiled MDX: ${response.statusText}`);
141
- }
142
- const data = await response.json();
143
- return {
144
- id: data.id,
145
- code: data.code,
146
- dependencies: data.dependencies || [],
147
- timestamp: data.timestamp
148
- };
149
- }
150
- cloneCompiled(compiled) {
151
- return {
152
- ...compiled,
153
- dependencies: Array.isArray(compiled.dependencies) ? [...compiled.dependencies] : []
154
- };
155
- }
156
- };
157
- var MDXComponentFactory = class {
158
- constructor(mdxClient) {
159
- this.components = /* @__PURE__ */ new Map();
160
- this.customComponents = /* @__PURE__ */ new Map();
161
- this.mdxClient = mdxClient;
162
- this.baseComponents = this.createBaseComponents();
163
- }
164
- registerInlineModule(module) {
165
- this.mdxClient.registerInlineModule(module);
166
- this.components.delete(module.id);
167
- }
168
- /**
169
- * Create React component from compiled MDX
170
- */
171
- async createComponent(ref) {
172
- const cached = this.components.get(ref.id);
173
- if (cached) {
174
- return cached;
175
- }
176
- const compiled = await this.mdxClient.getCompiled(ref);
177
- const component = this.evaluateCompiledMDX(compiled);
178
- this.components.set(ref.id, component);
179
- return component;
180
- }
181
- /**
182
- * Safely evaluate compiled MDX code
183
- */
184
- evaluateCompiledMDX(compiled) {
185
- try {
186
- const context = this.createEvaluationContext();
187
- const argNames = Object.keys(context);
188
- const argValues = Object.values(context);
189
- const moduleExports = new Function(...argNames, compiled.code)(...argValues);
190
- const MDXComponent = this.resolveEvaluatedModule(moduleExports);
191
- return (props) => {
192
- const registryComponents = this.getComponents();
193
- const incomingComponents = props?.components;
194
- const mergedComponents = incomingComponents ? { ...registryComponents, ...incomingComponents } : registryComponents;
195
- return React.createElement(MDXComponent, {
196
- ...props,
197
- components: mergedComponents
198
- });
199
- };
200
- } catch (error) {
201
- console.error("Failed to evaluate MDX:", error);
202
- return () => React.createElement(
203
- "div",
204
- {
205
- className: "mdx-error"
206
- },
207
- `MDX Error: ${error instanceof Error ? error.message : "Unknown error"}`
208
- );
209
- }
210
- }
211
- /**
212
- * Create safe evaluation context for MDX
213
- */
214
- createEvaluationContext() {
215
- const runtime = ReactJsxRuntime;
216
- const createElementWithChildren = (type, props, key) => {
217
- const baseProps = props ?? {};
218
- const finalProps = key === void 0 || key === null ? baseProps : { ...baseProps, key };
219
- if (Array.isArray(finalProps.children)) {
220
- finalProps.children = finalProps.children.map((child, index) => assignMdxChildKey(child, index));
221
- }
222
- return React.createElement(type, finalProps);
223
- };
224
- const runtimeJsx = typeof runtime.jsx === "function" ? runtime.jsx.bind(runtime) : createElementWithChildren;
225
- const runtimeJsxs = typeof runtime.jsxs === "function" ? runtime.jsxs.bind(runtime) : createElementWithChildren;
226
- const runtimeJsxDEV = typeof runtime.jsxDEV === "function" ? runtime.jsxDEV.bind(runtime) : (type, props, key, ..._rest) => createElementWithChildren(type, props, key);
227
- const jsxRuntime = {
228
- jsx: runtimeJsx,
229
- jsxs: runtimeJsxs,
230
- jsxDEV: runtimeJsxDEV,
231
- Fragment: runtime.Fragment ?? React.Fragment
232
- };
233
- return {
234
- __mdx_runtime: jsxRuntime,
235
- React,
236
- Fragment: React.Fragment,
237
- useState: React.useState,
238
- useEffect: React.useEffect,
239
- useMemo: React.useMemo,
240
- useCallback: React.useCallback,
241
- useRef: React.useRef,
242
- useContext: React.useContext,
243
- useReducer: React.useReducer,
244
- useLayoutEffect: React.useLayoutEffect,
245
- console: {
246
- log: console.log,
247
- warn: console.warn,
248
- error: console.error
249
- }
250
- };
251
- }
252
- resolveEvaluatedModule(output) {
253
- if (!output) {
254
- throw new Error("Compiled MDX module returned no exports");
255
- }
256
- if (typeof output === "function") {
257
- return output;
258
- }
259
- if (typeof output.default === "function") {
260
- return output.default;
261
- }
262
- if (typeof output.MDXContent === "function") {
263
- return output.MDXContent;
264
- }
265
- throw new Error("Compiled MDX module did not export a component");
266
- }
267
- getComponents() {
268
- if (this.customComponents.size === 0) {
269
- return { ...this.baseComponents };
270
- }
271
- const merged = { ...this.baseComponents };
272
- for (const [key, component] of this.customComponents) {
273
- merged[key] = component;
274
- }
275
- return merged;
276
- }
277
- /**
278
- * Register or replace custom MDX components
279
- */
280
- registerComponents(components, options) {
281
- if (options?.replace) {
282
- this.customComponents.clear();
283
- }
284
- for (const [key, component] of Object.entries(components)) {
285
- if (!component) continue;
286
- this.customComponents.set(key, component);
287
- }
288
- }
289
- /**
290
- * Get base MDX components
291
- */
292
- createBaseComponents() {
293
- return {
294
- // Standard HTML elements
295
- h1: withClassName("h1", "mdx-h1"),
296
- h2: withClassName("h2", "mdx-h2"),
297
- h3: withClassName("h3", "mdx-h3"),
298
- h4: withClassName("h4", "mdx-h4"),
299
- h5: withClassName("h5", "mdx-h5"),
300
- h6: withClassName("h6", "mdx-h6"),
301
- p: withClassName("p", "mdx-p"),
302
- strong: withClassName("strong", "mdx-strong"),
303
- em: withClassName("em", "mdx-em"),
304
- code: withClassName("code", "mdx-code"),
305
- pre: withClassName("pre", "mdx-pre"),
306
- ul: withClassName("ul", "mdx-ul"),
307
- ol: withClassName("ol", "mdx-ol"),
308
- li: withClassName("li", "mdx-li"),
309
- blockquote: withClassName("blockquote", "mdx-blockquote"),
310
- a: (props) => React.createElement("a", {
311
- className: "mdx-link",
312
- target: props.href?.startsWith("http") ? "_blank" : void 0,
313
- rel: props.href?.startsWith("http") ? "noopener noreferrer" : void 0,
314
- ...props
315
- }),
316
- img: (props) => React.createElement("img", { className: "mdx-img", ...props }),
317
- table: withClassName("table", "mdx-table"),
318
- thead: withClassName("thead", "mdx-thead"),
319
- tbody: withClassName("tbody", "mdx-tbody"),
320
- tr: withClassName("tr", "mdx-tr"),
321
- th: withClassName("th", "mdx-th"),
322
- td: withClassName("td", "mdx-td")
323
- };
324
- }
325
- /**
326
- * Clear component cache
327
- */
328
- clearCache() {
329
- this.components.clear();
330
- }
331
- clearCustomComponents() {
332
- this.customComponents.clear();
333
- }
334
- };
335
- var globalMDXClient = null;
336
- var globalComponentFactory = null;
337
- function getMDXClient(compileEndpoint) {
338
- if (!globalMDXClient) {
339
- globalMDXClient = new MDXClient(compileEndpoint);
340
- }
341
- return globalMDXClient;
342
- }
343
- function getMDXComponentFactory(compileEndpoint) {
344
- if (!globalComponentFactory) {
345
- const client = getMDXClient(compileEndpoint);
346
- globalComponentFactory = new MDXComponentFactory(client);
347
- }
348
- return globalComponentFactory;
349
- }
350
- function registerMDXComponents(components, options) {
351
- const factory = getMDXComponentFactory();
352
- factory.registerComponents(components, options);
353
- }
354
- function registerInlineMdxModule(compiled) {
355
- const factory = getMDXComponentFactory();
356
- factory.registerInlineModule({
357
- id: compiled.id,
358
- code: compiled.code,
359
- dependencies: compiled.dependencies ?? []
360
- });
361
- }
362
- export {
363
- MDXClient,
364
- MDXComponentFactory,
365
- getMDXClient,
366
- getMDXComponentFactory,
367
- registerInlineMdxModule,
368
- registerMDXComponents
369
- };