@stream-mdx/react 0.5.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 (99) hide show
  1. package/CHANGELOG.md +371 -0
  2. package/README.md +79 -4
  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 +117 -193
  6. package/dist/components/bottom-stick-scroll-area.mjs +112 -183
  7. package/dist/components/diff-renderer.cjs +86 -0
  8. package/dist/components/diff-renderer.d.cts +11 -0
  9. package/dist/components/diff-renderer.d.ts +11 -0
  10. package/dist/components/diff-renderer.mjs +66 -0
  11. package/dist/components/index.cjs +2761 -1508
  12. package/dist/components/index.d.cts +7 -2
  13. package/dist/components/index.d.ts +7 -2
  14. package/dist/components/index.mjs +2730 -1493
  15. package/dist/components/katex-math.cjs +220 -0
  16. package/dist/components/katex-math.d.cts +10 -0
  17. package/dist/components/katex-math.d.ts +10 -0
  18. package/dist/components/katex-math.mjs +188 -0
  19. package/dist/contexts/math-tracker.cjs +240 -521
  20. package/dist/contexts/math-tracker.mjs +235 -513
  21. package/dist/index-Cmne1yUK.d.cts +723 -0
  22. package/dist/index-D7dyyu3q.d.ts +723 -0
  23. package/dist/index.cjs +13029 -6475
  24. package/dist/index.d.cts +69 -39
  25. package/dist/index.d.ts +69 -39
  26. package/dist/index.mjs +13007 -6442
  27. package/dist/math/display-wrapper.cjs +7 -15
  28. package/dist/math/display-wrapper.d.cts +2 -2
  29. package/dist/math/display-wrapper.d.ts +2 -2
  30. package/dist/math/display-wrapper.mjs +2 -6
  31. package/dist/node-views-Bpc6Gkgl.d.cts +13 -0
  32. package/dist/node-views-DpnYdaAS.d.ts +13 -0
  33. package/dist/renderer/hooks.cjs +35 -20
  34. package/dist/renderer/hooks.d.cts +22 -1
  35. package/dist/renderer/hooks.d.ts +22 -1
  36. package/dist/renderer/hooks.mjs +27 -12
  37. package/dist/renderer/patch-batching.cjs +5 -8
  38. package/dist/renderer/patch-coalescing.cjs +5 -8
  39. package/dist/renderer/patch-commit-scheduler.cjs +138 -356
  40. package/dist/renderer/patch-commit-scheduler.d.cts +13 -1
  41. package/dist/renderer/patch-commit-scheduler.d.ts +13 -1
  42. package/dist/renderer/patch-commit-scheduler.mjs +133 -348
  43. package/dist/renderer/store.cjs +3775 -1373
  44. package/dist/renderer/store.d.cts +108 -3
  45. package/dist/renderer/store.d.ts +108 -3
  46. package/dist/renderer/store.mjs +3778 -1362
  47. package/dist/renderer/virtualized-code.cjs +415 -71
  48. package/dist/renderer/virtualized-code.d.cts +24 -23
  49. package/dist/renderer/virtualized-code.d.ts +24 -23
  50. package/dist/renderer/virtualized-code.mjs +409 -62
  51. package/dist/renderer.cjs +10655 -4334
  52. package/dist/renderer.d.cts +98 -29
  53. package/dist/renderer.d.ts +98 -29
  54. package/dist/renderer.mjs +10582 -4212
  55. package/dist/server-regions-CPLHGli0.d.cts +32 -0
  56. package/dist/server-regions-mUhyoKi7.d.ts +32 -0
  57. package/dist/server.cjs +10195 -3872
  58. package/dist/server.d.cts +17 -252
  59. package/dist/server.d.ts +17 -252
  60. package/dist/server.mjs +9997 -3649
  61. package/dist/{streaming-markdown-CEI9eDZm.d.ts → streaming-markdown-yELbJxyH.d.ts} +49 -55
  62. package/dist/{streaming-markdown-DRisClXb.d.cts → streaming-markdown-zVwFuaJG.d.cts} +49 -55
  63. package/dist/streaming-markdown.cjs +11660 -5378
  64. package/dist/streaming-markdown.d.cts +7 -2
  65. package/dist/streaming-markdown.d.ts +7 -2
  66. package/dist/streaming-markdown.mjs +11679 -5347
  67. package/dist/trusted-mdx/index.cjs +833 -0
  68. package/dist/trusted-mdx/index.d.cts +11 -0
  69. package/dist/trusted-mdx/index.d.ts +11 -0
  70. package/dist/trusted-mdx/index.mjs +807 -0
  71. package/dist/trusted-mdx/native-children-slot.cjs +45 -0
  72. package/dist/trusted-mdx/native-children-slot.d.cts +11 -0
  73. package/dist/trusted-mdx/native-children-slot.d.ts +11 -0
  74. package/dist/trusted-mdx/native-children-slot.mjs +24 -0
  75. package/dist/trusted-mdx/server.cjs +752 -0
  76. package/dist/trusted-mdx/server.d.cts +24 -0
  77. package/dist/trusted-mdx/server.d.ts +24 -0
  78. package/dist/trusted-mdx/server.mjs +724 -0
  79. package/dist/trusted-mdx-contract-ElKpkDI5.d.cts +113 -0
  80. package/dist/trusted-mdx-contract-ElKpkDI5.d.ts +113 -0
  81. package/dist/utils/inline-html.cjs +246 -147
  82. package/dist/utils/inline-html.d.cts +37 -6
  83. package/dist/utils/inline-html.d.ts +37 -6
  84. package/dist/utils/inline-html.mjs +237 -134
  85. package/package.json +41 -18
  86. package/dist/index-BVhp_pcF.d.ts +0 -251
  87. package/dist/index-EaeouYp2.d.cts +0 -251
  88. package/dist/mdx-client.cjs +0 -408
  89. package/dist/mdx-client.d.cts +0 -113
  90. package/dist/mdx-client.d.ts +0 -113
  91. package/dist/mdx-client.mjs +0 -369
  92. package/dist/mdx-coordinator.cjs +0 -584
  93. package/dist/mdx-coordinator.d.cts +0 -21
  94. package/dist/mdx-coordinator.d.ts +0 -21
  95. package/dist/mdx-coordinator.mjs +0 -550
  96. package/dist/renderer/node-views.cjs +0 -1887
  97. package/dist/renderer/node-views.d.cts +0 -14
  98. package/dist/renderer/node-views.d.ts +0 -14
  99. package/dist/renderer/node-views.mjs +0 -1861
@@ -1,408 +0,0 @@
1
- "use client";
2
- "use strict";
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
20
- };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
-
31
- // src/mdx-client.ts
32
- var mdx_client_exports = {};
33
- __export(mdx_client_exports, {
34
- MDXClient: () => MDXClient,
35
- MDXComponentFactory: () => MDXComponentFactory,
36
- getMDXClient: () => getMDXClient,
37
- getMDXComponentFactory: () => getMDXComponentFactory,
38
- registerInlineMdxModule: () => registerInlineMdxModule,
39
- registerMDXComponents: () => registerMDXComponents
40
- });
41
- module.exports = __toCommonJS(mdx_client_exports);
42
- var import_react = __toESM(require("react"), 1);
43
- var ReactJsxRuntime = __toESM(require("react/jsx-runtime"), 1);
44
- var withClassName = (tag, className) => {
45
- return (props) => import_react.default.createElement(tag, { className, ...props });
46
- };
47
- function assignMdxChildKey(child, index) {
48
- if (child == null) return child;
49
- if (Array.isArray(child)) {
50
- return child.map((entry, subIndex) => assignMdxChildKey(entry, `${index}-${subIndex}`));
51
- }
52
- if (import_react.default.isValidElement(child)) {
53
- if (child.key !== null && child.key !== void 0) {
54
- return child;
55
- }
56
- return import_react.default.cloneElement(child, { key: index });
57
- }
58
- return child;
59
- }
60
- var MDXClient = class {
61
- constructor(compileEndpoint = "/api/mdx-compile-v2") {
62
- this.cache = /* @__PURE__ */ new Map();
63
- this.inlineModules = /* @__PURE__ */ new Map();
64
- this.compiledCache = /* @__PURE__ */ new Map();
65
- this.compiledInflight = /* @__PURE__ */ new Map();
66
- this.compileEndpoint = compileEndpoint;
67
- }
68
- /**
69
- * Compile MDX block on server
70
- */
71
- async compile(block) {
72
- if (block.type !== "mdx") {
73
- throw new Error("Block is not MDX type");
74
- }
75
- const cacheKey = `${block.id}\0${block.payload.raw ?? ""}`;
76
- const cachedPromise = this.cache.get(cacheKey);
77
- if (cachedPromise) {
78
- return cachedPromise;
79
- }
80
- const compilationPromise = this.doCompile(block);
81
- this.cache.set(cacheKey, compilationPromise);
82
- try {
83
- const result = await compilationPromise;
84
- return result;
85
- } catch (error) {
86
- this.cache.delete(cacheKey);
87
- throw error;
88
- }
89
- }
90
- async getCompiledInternal(ref) {
91
- const inline = this.inlineModules.get(ref.id);
92
- if (inline) {
93
- return this.cloneCompiled(inline);
94
- }
95
- const cached = this.compiledCache.get(ref.id);
96
- if (cached) {
97
- return this.cloneCompiled(cached);
98
- }
99
- const inflight = this.compiledInflight.get(ref.id);
100
- if (inflight) {
101
- const resolved = await inflight;
102
- return this.cloneCompiled(resolved);
103
- }
104
- const fetchPromise = this.fetchCompiled(ref);
105
- this.compiledInflight.set(ref.id, fetchPromise);
106
- try {
107
- const data = await fetchPromise;
108
- this.compiledCache.set(ref.id, data);
109
- return this.cloneCompiled(data);
110
- } finally {
111
- this.compiledInflight.delete(ref.id);
112
- }
113
- }
114
- async getCompiled(ref, options) {
115
- if (options?.signal) {
116
- const inline = this.inlineModules.get(ref.id);
117
- if (inline) {
118
- return this.cloneCompiled(inline);
119
- }
120
- const cached = this.compiledCache.get(ref.id);
121
- if (cached) {
122
- return this.cloneCompiled(cached);
123
- }
124
- const data = await this.fetchCompiled(ref, options);
125
- this.compiledCache.set(ref.id, data);
126
- return this.cloneCompiled(data);
127
- }
128
- return this.getCompiledInternal(ref);
129
- }
130
- /**
131
- * Clear compilation cache
132
- */
133
- clearCache() {
134
- this.cache.clear();
135
- this.compiledCache.clear();
136
- this.compiledInflight.clear();
137
- }
138
- registerInlineModule(compiled) {
139
- this.inlineModules.set(compiled.id, {
140
- ...compiled,
141
- dependencies: Array.isArray(compiled.dependencies) ? [...compiled.dependencies] : []
142
- });
143
- }
144
- clearInlineModules() {
145
- this.inlineModules.clear();
146
- }
147
- /**
148
- * Actual compilation implementation
149
- */
150
- async doCompile(block) {
151
- const response = await fetch(this.compileEndpoint, {
152
- method: "POST",
153
- headers: {
154
- "Content-Type": "application/json"
155
- },
156
- body: JSON.stringify({
157
- content: block.payload.raw,
158
- blockId: block.id
159
- })
160
- });
161
- if (!response.ok) {
162
- const error = await response.json().catch(() => ({ error: "Unknown error" }));
163
- throw new Error(`MDX compilation failed: ${error.error || response.statusText}`);
164
- }
165
- const data = await response.json();
166
- return {
167
- id: data.id,
168
- code: data.code,
169
- dependencies: data.dependencies || [],
170
- cached: data.cached || false
171
- };
172
- }
173
- async fetchCompiled(ref, options) {
174
- const response = await fetch(`${this.compileEndpoint}?id=${ref.id}`, {
175
- signal: options?.signal
176
- });
177
- if (!response.ok) {
178
- throw new Error(`Failed to get compiled MDX: ${response.statusText}`);
179
- }
180
- const data = await response.json();
181
- return {
182
- id: data.id,
183
- code: data.code,
184
- dependencies: data.dependencies || [],
185
- timestamp: data.timestamp
186
- };
187
- }
188
- cloneCompiled(compiled) {
189
- return {
190
- ...compiled,
191
- dependencies: Array.isArray(compiled.dependencies) ? [...compiled.dependencies] : []
192
- };
193
- }
194
- };
195
- var MDXComponentFactory = class {
196
- constructor(mdxClient) {
197
- this.components = /* @__PURE__ */ new Map();
198
- this.customComponents = /* @__PURE__ */ new Map();
199
- this.mdxClient = mdxClient;
200
- this.baseComponents = this.createBaseComponents();
201
- }
202
- registerInlineModule(module2) {
203
- this.mdxClient.registerInlineModule(module2);
204
- this.components.delete(module2.id);
205
- }
206
- /**
207
- * Create React component from compiled MDX
208
- */
209
- async createComponent(ref) {
210
- const cached = this.components.get(ref.id);
211
- if (cached) {
212
- return cached;
213
- }
214
- const compiled = await this.mdxClient.getCompiled(ref);
215
- const component = this.evaluateCompiledMDX(compiled);
216
- this.components.set(ref.id, component);
217
- return component;
218
- }
219
- /**
220
- * Safely evaluate compiled MDX code
221
- */
222
- evaluateCompiledMDX(compiled) {
223
- try {
224
- const context = this.createEvaluationContext();
225
- const argNames = Object.keys(context);
226
- const argValues = Object.values(context);
227
- const moduleExports = new Function(...argNames, compiled.code)(...argValues);
228
- const MDXComponent = this.resolveEvaluatedModule(moduleExports);
229
- return (props) => {
230
- const registryComponents = this.getComponents();
231
- const incomingComponents = props?.components;
232
- const mergedComponents = incomingComponents ? { ...registryComponents, ...incomingComponents } : registryComponents;
233
- return import_react.default.createElement(MDXComponent, {
234
- ...props,
235
- components: mergedComponents
236
- });
237
- };
238
- } catch (error) {
239
- console.error("Failed to evaluate MDX:", error);
240
- return () => import_react.default.createElement(
241
- "div",
242
- {
243
- className: "mdx-error"
244
- },
245
- `MDX Error: ${error instanceof Error ? error.message : "Unknown error"}`
246
- );
247
- }
248
- }
249
- /**
250
- * Create safe evaluation context for MDX
251
- */
252
- createEvaluationContext() {
253
- const runtime = ReactJsxRuntime;
254
- const createElementWithChildren = (type, props, key) => {
255
- const baseProps = props ?? {};
256
- const finalProps = key === void 0 || key === null ? baseProps : { ...baseProps, key };
257
- if (Array.isArray(finalProps.children)) {
258
- finalProps.children = finalProps.children.map((child, index) => assignMdxChildKey(child, index));
259
- }
260
- return import_react.default.createElement(type, finalProps);
261
- };
262
- const runtimeJsx = typeof runtime.jsx === "function" ? runtime.jsx.bind(runtime) : createElementWithChildren;
263
- const runtimeJsxs = typeof runtime.jsxs === "function" ? runtime.jsxs.bind(runtime) : createElementWithChildren;
264
- const runtimeJsxDEV = typeof runtime.jsxDEV === "function" ? runtime.jsxDEV.bind(runtime) : (type, props, key, ..._rest) => createElementWithChildren(type, props, key);
265
- const jsxRuntime = {
266
- jsx: runtimeJsx,
267
- jsxs: runtimeJsxs,
268
- jsxDEV: runtimeJsxDEV,
269
- Fragment: runtime.Fragment ?? import_react.default.Fragment
270
- };
271
- return {
272
- __mdx_runtime: jsxRuntime,
273
- React: import_react.default,
274
- Fragment: import_react.default.Fragment,
275
- useState: import_react.default.useState,
276
- useEffect: import_react.default.useEffect,
277
- useMemo: import_react.default.useMemo,
278
- useCallback: import_react.default.useCallback,
279
- useRef: import_react.default.useRef,
280
- useContext: import_react.default.useContext,
281
- useReducer: import_react.default.useReducer,
282
- useLayoutEffect: import_react.default.useLayoutEffect,
283
- console: {
284
- log: console.log,
285
- warn: console.warn,
286
- error: console.error
287
- }
288
- };
289
- }
290
- resolveEvaluatedModule(output) {
291
- if (!output) {
292
- throw new Error("Compiled MDX module returned no exports");
293
- }
294
- if (typeof output === "function") {
295
- return output;
296
- }
297
- if (typeof output.default === "function") {
298
- return output.default;
299
- }
300
- if (typeof output.MDXContent === "function") {
301
- return output.MDXContent;
302
- }
303
- throw new Error("Compiled MDX module did not export a component");
304
- }
305
- getComponents() {
306
- if (this.customComponents.size === 0) {
307
- return { ...this.baseComponents };
308
- }
309
- const merged = { ...this.baseComponents };
310
- for (const [key, component] of this.customComponents) {
311
- merged[key] = component;
312
- }
313
- return merged;
314
- }
315
- /**
316
- * Register or replace custom MDX components
317
- */
318
- registerComponents(components, options) {
319
- if (options?.replace) {
320
- this.customComponents.clear();
321
- }
322
- for (const [key, component] of Object.entries(components)) {
323
- if (!component) continue;
324
- this.customComponents.set(key, component);
325
- }
326
- }
327
- /**
328
- * Get base MDX components
329
- */
330
- createBaseComponents() {
331
- return {
332
- // Standard HTML elements
333
- h1: withClassName("h1", "mdx-h1"),
334
- h2: withClassName("h2", "mdx-h2"),
335
- h3: withClassName("h3", "mdx-h3"),
336
- h4: withClassName("h4", "mdx-h4"),
337
- h5: withClassName("h5", "mdx-h5"),
338
- h6: withClassName("h6", "mdx-h6"),
339
- p: withClassName("p", "mdx-p"),
340
- strong: withClassName("strong", "mdx-strong"),
341
- em: withClassName("em", "mdx-em"),
342
- code: withClassName("code", "mdx-code"),
343
- pre: withClassName("pre", "mdx-pre"),
344
- ul: withClassName("ul", "mdx-ul"),
345
- ol: withClassName("ol", "mdx-ol"),
346
- li: withClassName("li", "mdx-li"),
347
- blockquote: withClassName("blockquote", "mdx-blockquote"),
348
- a: (props) => import_react.default.createElement("a", {
349
- className: "mdx-link",
350
- target: props.href?.startsWith("http") ? "_blank" : void 0,
351
- rel: props.href?.startsWith("http") ? "noopener noreferrer" : void 0,
352
- ...props
353
- }),
354
- img: (props) => import_react.default.createElement("img", { className: "mdx-img", ...props }),
355
- table: withClassName("table", "mdx-table"),
356
- thead: withClassName("thead", "mdx-thead"),
357
- tbody: withClassName("tbody", "mdx-tbody"),
358
- tr: withClassName("tr", "mdx-tr"),
359
- th: withClassName("th", "mdx-th"),
360
- td: withClassName("td", "mdx-td")
361
- };
362
- }
363
- /**
364
- * Clear component cache
365
- */
366
- clearCache() {
367
- this.components.clear();
368
- }
369
- clearCustomComponents() {
370
- this.customComponents.clear();
371
- }
372
- };
373
- var globalMDXClient = null;
374
- var globalComponentFactory = null;
375
- function getMDXClient(compileEndpoint) {
376
- if (!globalMDXClient) {
377
- globalMDXClient = new MDXClient(compileEndpoint);
378
- }
379
- return globalMDXClient;
380
- }
381
- function getMDXComponentFactory(compileEndpoint) {
382
- if (!globalComponentFactory) {
383
- const client = getMDXClient(compileEndpoint);
384
- globalComponentFactory = new MDXComponentFactory(client);
385
- }
386
- return globalComponentFactory;
387
- }
388
- function registerMDXComponents(components, options) {
389
- const factory = getMDXComponentFactory();
390
- factory.registerComponents(components, options);
391
- }
392
- function registerInlineMdxModule(compiled) {
393
- const factory = getMDXComponentFactory();
394
- factory.registerInlineModule({
395
- id: compiled.id,
396
- code: compiled.code,
397
- dependencies: compiled.dependencies ?? []
398
- });
399
- }
400
- // Annotate the CommonJS export names for ESM import in node:
401
- 0 && (module.exports = {
402
- MDXClient,
403
- MDXComponentFactory,
404
- getMDXClient,
405
- getMDXComponentFactory,
406
- registerInlineMdxModule,
407
- registerMDXComponents
408
- });
@@ -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 };