fumadocs-mdx 11.6.11 → 11.7.1

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 (34) hide show
  1. package/dist/{chunk-64MMPGML.js → chunk-2CSSQTP6.js} +1 -10
  2. package/dist/{chunk-SXOJYWZ3.js → chunk-2KBRPMAM.js} +1 -1
  3. package/dist/{chunk-6PDS7MUA.js → chunk-C5INPAZJ.js} +4 -4
  4. package/dist/{chunk-DRVUBK5B.js → chunk-GWR7KMRU.js} +13 -1
  5. package/dist/chunk-OWZSTKKX.js +58 -0
  6. package/dist/{chunk-22SBT5SQ.js → chunk-ZOWJF3OH.js} +6 -6
  7. package/dist/config/index.cjs +4 -19
  8. package/dist/config/index.d.cts +3 -7
  9. package/dist/config/index.d.ts +3 -7
  10. package/dist/config/index.js +7 -13
  11. package/dist/{types-DVeuYiq5.d.cts → define-CCrinVBZ.d.cts} +37 -119
  12. package/dist/{types-DVeuYiq5.d.ts → define-CCrinVBZ.d.ts} +37 -119
  13. package/dist/index.d.cts +6 -7
  14. package/dist/index.d.ts +6 -7
  15. package/dist/loader-mdx.cjs +155 -134
  16. package/dist/loader-mdx.js +7 -10
  17. package/dist/mdx-options-UDV5WEFU.js +6 -0
  18. package/dist/next/index.cjs +253 -85
  19. package/dist/next/index.js +49 -63
  20. package/dist/runtime/async.cjs +167 -15
  21. package/dist/runtime/async.d.cts +5 -6
  22. package/dist/runtime/async.d.ts +5 -6
  23. package/dist/runtime/async.js +24 -15
  24. package/dist/runtime/vite.cjs +150 -0
  25. package/dist/runtime/vite.d.cts +71 -0
  26. package/dist/runtime/vite.d.ts +71 -0
  27. package/dist/runtime/vite.js +123 -0
  28. package/dist/{types-HIdjlLo0.d.ts → types-C0bKwtAx.d.ts} +38 -50
  29. package/dist/{types-BcUhOIxN.d.cts → types-CnslxmoO.d.cts} +38 -50
  30. package/dist/vite/index.cjs +385 -134
  31. package/dist/vite/index.d.cts +12 -3
  32. package/dist/vite/index.d.ts +12 -3
  33. package/dist/vite/index.js +165 -20
  34. package/package.json +20 -10
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __esm = (fn, res) => function __init() {
9
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
+ };
8
11
  var __export = (target, all) => {
9
12
  for (var name in all)
10
13
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -27,6 +30,134 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
30
  ));
28
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
32
 
33
+ // src/mdx-plugins/remark-exports.ts
34
+ function remarkMdxExport({ values }) {
35
+ return (tree, vfile) => {
36
+ for (const name of values) {
37
+ if (!(name in vfile.data)) return;
38
+ tree.children.unshift(getMdastExport(name, vfile.data[name]));
39
+ }
40
+ };
41
+ }
42
+ function getMdastExport(name, value) {
43
+ return {
44
+ type: "mdxjsEsm",
45
+ value: "",
46
+ data: {
47
+ estree: {
48
+ type: "Program",
49
+ sourceType: "module",
50
+ body: [
51
+ {
52
+ type: "ExportNamedDeclaration",
53
+ specifiers: [],
54
+ source: null,
55
+ declaration: {
56
+ type: "VariableDeclaration",
57
+ kind: "let",
58
+ declarations: [
59
+ {
60
+ type: "VariableDeclarator",
61
+ id: {
62
+ type: "Identifier",
63
+ name
64
+ },
65
+ init: (0, import_estree_util_value_to_estree.valueToEstree)(value)
66
+ }
67
+ ]
68
+ }
69
+ }
70
+ ]
71
+ }
72
+ }
73
+ };
74
+ }
75
+ var import_estree_util_value_to_estree;
76
+ var init_remark_exports = __esm({
77
+ "src/mdx-plugins/remark-exports.ts"() {
78
+ "use strict";
79
+ import_estree_util_value_to_estree = require("estree-util-value-to-estree");
80
+ }
81
+ });
82
+
83
+ // src/utils/mdx-options.ts
84
+ var mdx_options_exports = {};
85
+ __export(mdx_options_exports, {
86
+ getDefaultMDXOptions: () => getDefaultMDXOptions
87
+ });
88
+ function pluginOption(def, options = []) {
89
+ const list = def(Array.isArray(options) ? options : []).filter(
90
+ Boolean
91
+ );
92
+ if (typeof options === "function") {
93
+ return options(list);
94
+ }
95
+ return list;
96
+ }
97
+ function getDefaultMDXOptions({
98
+ valueToExport = [],
99
+ rehypeCodeOptions,
100
+ remarkImageOptions,
101
+ remarkHeadingOptions,
102
+ remarkStructureOptions,
103
+ remarkCodeTabOptions,
104
+ remarkNpmOptions,
105
+ ...mdxOptions
106
+ }) {
107
+ const mdxExports = [
108
+ "structuredData",
109
+ "frontmatter",
110
+ "lastModified",
111
+ ...valueToExport
112
+ ];
113
+ const remarkPlugins = pluginOption(
114
+ (v) => [
115
+ plugins.remarkGfm,
116
+ [
117
+ plugins.remarkHeading,
118
+ {
119
+ generateToc: false,
120
+ ...remarkHeadingOptions
121
+ }
122
+ ],
123
+ remarkImageOptions !== false && [plugins.remarkImage, remarkImageOptions],
124
+ "remarkCodeTab" in plugins && remarkCodeTabOptions !== false && [
125
+ plugins.remarkCodeTab,
126
+ remarkCodeTabOptions
127
+ ],
128
+ "remarkNpm" in plugins && remarkNpmOptions !== false && [plugins.remarkNpm, remarkNpmOptions],
129
+ ...v,
130
+ remarkStructureOptions !== false && [
131
+ plugins.remarkStructure,
132
+ remarkStructureOptions
133
+ ],
134
+ [remarkMdxExport, { values: mdxExports }]
135
+ ],
136
+ mdxOptions.remarkPlugins
137
+ );
138
+ const rehypePlugins = pluginOption(
139
+ (v) => [
140
+ rehypeCodeOptions !== false && [plugins.rehypeCode, rehypeCodeOptions],
141
+ ...v,
142
+ plugins.rehypeToc
143
+ ],
144
+ mdxOptions.rehypePlugins
145
+ );
146
+ return {
147
+ ...mdxOptions,
148
+ remarkPlugins,
149
+ rehypePlugins
150
+ };
151
+ }
152
+ var plugins;
153
+ var init_mdx_options = __esm({
154
+ "src/utils/mdx-options.ts"() {
155
+ "use strict";
156
+ plugins = __toESM(require("fumadocs-core/mdx-plugins"), 1);
157
+ init_remark_exports();
158
+ }
159
+ });
160
+
30
161
  // src/runtime/async.ts
31
162
  var async_exports = {};
32
163
  __export(async_exports, {
@@ -231,34 +362,55 @@ function buildConfig(config) {
231
362
  null
232
363
  ];
233
364
  }
365
+ let cachedMdxOptions;
234
366
  return [
235
367
  null,
236
368
  {
237
369
  global: globalConfig,
238
- collections
370
+ collections,
371
+ async getDefaultMDXOptions() {
372
+ if (cachedMdxOptions) return cachedMdxOptions;
373
+ const input = this.global?.mdxOptions;
374
+ async function uncached() {
375
+ const options = typeof input === "function" ? await input() : input;
376
+ const { getDefaultMDXOptions: getDefaultMDXOptions2 } = await Promise.resolve().then(() => (init_mdx_options(), mdx_options_exports));
377
+ if (options?.preset === "minimal") return options;
378
+ return getDefaultMDXOptions2(options ?? {});
379
+ }
380
+ return cachedMdxOptions = uncached();
381
+ }
239
382
  }
240
383
  ];
241
384
  }
242
385
 
243
386
  // src/runtime/async.ts
244
387
  async function initCompiler(config, collection) {
245
- let mdxOptions;
246
388
  const col = config.collections.get(collection);
247
- if (col?.type === "doc") mdxOptions = col.mdxOptions;
248
- else if (col?.type === "docs")
249
- mdxOptions = col.docs?.mdxOptions;
250
- if (!mdxOptions) {
251
- config._mdx_async ??= {};
252
- const async = config._mdx_async;
253
- const globalConfig = config.global;
254
- if (globalConfig && !async.cachedMdxOptions) {
255
- async.cachedMdxOptions = typeof globalConfig.mdxOptions === "function" ? await globalConfig.mdxOptions() : globalConfig.mdxOptions;
256
- }
257
- mdxOptions = async.cachedMdxOptions;
389
+ switch (col?.type) {
390
+ case "doc":
391
+ if (col.mdxOptions)
392
+ return (0, import_mdx_remote.createCompiler)({
393
+ preset: "minimal",
394
+ ...col.mdxOptions
395
+ });
396
+ break;
397
+ case "docs":
398
+ if (col.docs.mdxOptions)
399
+ return (0, import_mdx_remote.createCompiler)({
400
+ preset: "minimal",
401
+ ...col.docs.mdxOptions
402
+ });
403
+ break;
404
+ }
405
+ let defaultMdxOptions = config.global?.mdxOptions;
406
+ if (typeof defaultMdxOptions === "function")
407
+ defaultMdxOptions = await defaultMdxOptions();
408
+ if (defaultMdxOptions?.preset === "minimal") {
409
+ return (0, import_mdx_remote.createCompiler)(defaultMdxOptions);
258
410
  }
259
- const remarkPlugins = mdxOptions?.remarkPlugins ?? [];
411
+ const remarkPlugins = defaultMdxOptions?.remarkPlugins ?? [];
260
412
  return (0, import_mdx_remote.createCompiler)({
261
- ...mdxOptions,
413
+ ...defaultMdxOptions,
262
414
  remarkPlugins: (v) => typeof remarkPlugins === "function" ? [remarkInclude, ...remarkPlugins(v), import_mdx_plugins.remarkStructure] : [remarkInclude, ...v, ...remarkPlugins, import_mdx_plugins.remarkStructure]
263
415
  });
264
416
  }
@@ -1,15 +1,14 @@
1
- import { a as RuntimeAsync } from '../types-BcUhOIxN.cjs';
2
- import { L as LoadedConfig } from '../types-DVeuYiq5.cjs';
1
+ import { L as LoadedConfig, a as RuntimeAsync } from '../types-CnslxmoO.cjs';
3
2
  import '@standard-schema/spec';
4
3
  import 'fumadocs-core/source';
5
- import 'mdx/types';
4
+ import '../define-CCrinVBZ.cjs';
5
+ import 'zod';
6
6
  import 'fumadocs-core/mdx-plugins';
7
- import 'fumadocs-core/server';
8
7
  import '@mdx-js/mdx';
9
8
  import 'unified';
10
9
  import 'react';
11
- import 'zod';
12
- import '@fumadocs/mdx-remote';
10
+ import 'mdx/types';
11
+ import 'fumadocs-core/server';
13
12
 
14
13
  declare function buildConfig(config: Record<string, unknown>): [err: string, value: null] | [err: null, value: LoadedConfig];
15
14
 
@@ -1,15 +1,14 @@
1
- import { a as RuntimeAsync } from '../types-HIdjlLo0.js';
2
- import { L as LoadedConfig } from '../types-DVeuYiq5.js';
1
+ import { L as LoadedConfig, a as RuntimeAsync } from '../types-C0bKwtAx.js';
3
2
  import '@standard-schema/spec';
4
3
  import 'fumadocs-core/source';
5
- import 'mdx/types';
4
+ import '../define-CCrinVBZ.js';
5
+ import 'zod';
6
6
  import 'fumadocs-core/mdx-plugins';
7
- import 'fumadocs-core/server';
8
7
  import '@mdx-js/mdx';
9
8
  import 'unified';
10
9
  import 'react';
11
- import 'zod';
12
- import '@fumadocs/mdx-remote';
10
+ import 'mdx/types';
11
+ import 'fumadocs-core/server';
13
12
 
14
13
  declare function buildConfig(config: Record<string, unknown>): [err: string, value: null] | [err: null, value: LoadedConfig];
15
14
 
@@ -4,7 +4,7 @@ import {
4
4
  } from "../chunk-NUDEC6C5.js";
5
5
  import {
6
6
  buildConfig
7
- } from "../chunk-DRVUBK5B.js";
7
+ } from "../chunk-GWR7KMRU.js";
8
8
  import {
9
9
  remarkInclude
10
10
  } from "../chunk-AVMO2SRO.js";
@@ -16,23 +16,32 @@ import {
16
16
  remarkStructure
17
17
  } from "fumadocs-core/mdx-plugins";
18
18
  async function initCompiler(config, collection) {
19
- let mdxOptions;
20
19
  const col = config.collections.get(collection);
21
- if (col?.type === "doc") mdxOptions = col.mdxOptions;
22
- else if (col?.type === "docs")
23
- mdxOptions = col.docs?.mdxOptions;
24
- if (!mdxOptions) {
25
- config._mdx_async ??= {};
26
- const async = config._mdx_async;
27
- const globalConfig = config.global;
28
- if (globalConfig && !async.cachedMdxOptions) {
29
- async.cachedMdxOptions = typeof globalConfig.mdxOptions === "function" ? await globalConfig.mdxOptions() : globalConfig.mdxOptions;
30
- }
31
- mdxOptions = async.cachedMdxOptions;
20
+ switch (col?.type) {
21
+ case "doc":
22
+ if (col.mdxOptions)
23
+ return createCompiler({
24
+ preset: "minimal",
25
+ ...col.mdxOptions
26
+ });
27
+ break;
28
+ case "docs":
29
+ if (col.docs.mdxOptions)
30
+ return createCompiler({
31
+ preset: "minimal",
32
+ ...col.docs.mdxOptions
33
+ });
34
+ break;
32
35
  }
33
- const remarkPlugins = mdxOptions?.remarkPlugins ?? [];
36
+ let defaultMdxOptions = config.global?.mdxOptions;
37
+ if (typeof defaultMdxOptions === "function")
38
+ defaultMdxOptions = await defaultMdxOptions();
39
+ if (defaultMdxOptions?.preset === "minimal") {
40
+ return createCompiler(defaultMdxOptions);
41
+ }
42
+ const remarkPlugins = defaultMdxOptions?.remarkPlugins ?? [];
34
43
  return createCompiler({
35
- ...mdxOptions,
44
+ ...defaultMdxOptions,
36
45
  remarkPlugins: (v) => typeof remarkPlugins === "function" ? [remarkInclude, ...remarkPlugins(v), remarkStructure] : [remarkInclude, ...v, ...remarkPlugins, remarkStructure]
37
46
  });
38
47
  }
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/runtime/vite.ts
21
+ var vite_exports = {};
22
+ __export(vite_exports, {
23
+ createClientLoader: () => createClientLoader,
24
+ fromConfig: () => fromConfig,
25
+ toClientRenderer: () => toClientRenderer
26
+ });
27
+ module.exports = __toCommonJS(vite_exports);
28
+ var import_react = require("react");
29
+ function fromConfig() {
30
+ function normalize(entries) {
31
+ const out = {};
32
+ for (const k in entries) {
33
+ const mappedK = k.startsWith("./") ? k.slice(2) : k;
34
+ out[mappedK] = entries[k];
35
+ }
36
+ return out;
37
+ }
38
+ function mapPageData(entry) {
39
+ const { toc, structuredData } = entry;
40
+ return {
41
+ ...entry.frontmatter,
42
+ default: entry.default,
43
+ toc,
44
+ structuredData,
45
+ _exports: entry
46
+ };
47
+ }
48
+ return {
49
+ doc(_, glob) {
50
+ return normalize(glob);
51
+ },
52
+ meta(_, glob) {
53
+ return normalize(glob);
54
+ },
55
+ docs(_, { doc, meta }) {
56
+ return {
57
+ doc: normalize(doc),
58
+ meta: normalize(meta)
59
+ };
60
+ },
61
+ source(doc, meta) {
62
+ const virtualFiles = [];
63
+ for (const [file, content] of Object.entries(doc)) {
64
+ virtualFiles.push({
65
+ type: "page",
66
+ path: file,
67
+ data: mapPageData(content)
68
+ });
69
+ }
70
+ for (const [file, content] of Object.entries(meta)) {
71
+ virtualFiles.push({
72
+ type: "meta",
73
+ path: file,
74
+ data: content
75
+ });
76
+ }
77
+ return {
78
+ files: virtualFiles
79
+ };
80
+ },
81
+ async sourceAsync(doc, meta) {
82
+ const virtualFiles = [];
83
+ for (const [file, content] of Object.entries(doc)) {
84
+ virtualFiles.push({
85
+ type: "page",
86
+ path: file,
87
+ data: mapPageData(await content())
88
+ });
89
+ }
90
+ for (const [file, content] of Object.entries(meta)) {
91
+ virtualFiles.push({
92
+ type: "meta",
93
+ path: file,
94
+ data: await content()
95
+ });
96
+ }
97
+ return {
98
+ files: virtualFiles
99
+ };
100
+ }
101
+ };
102
+ }
103
+ var loaderStore = /* @__PURE__ */ new Map();
104
+ function createClientLoader(files, options) {
105
+ const { id = "", component } = options;
106
+ const store = loaderStore.get(id) ?? {
107
+ preloaded: /* @__PURE__ */ new Map()
108
+ };
109
+ loaderStore.set(id, store);
110
+ let renderer;
111
+ return {
112
+ async preload(path) {
113
+ const loaded = await files[path]();
114
+ store.preloaded.set(path, loaded);
115
+ return loaded;
116
+ },
117
+ getComponent(path) {
118
+ renderer ??= toClientRenderer(files, component, {
119
+ cache: store.preloaded
120
+ });
121
+ return renderer[path];
122
+ }
123
+ };
124
+ }
125
+ function toClientRenderer(files, component, options = {}) {
126
+ const { cache } = options;
127
+ const renderer = {};
128
+ for (const k in files) {
129
+ const OnDemand = (0, import_react.lazy)(async () => {
130
+ const loaded = await files[k]();
131
+ return { default: (props) => component(loaded, props) };
132
+ });
133
+ if (cache) {
134
+ renderer[k] = (props) => {
135
+ const cached = cache.get(k);
136
+ if (!cached) return (0, import_react.createElement)(OnDemand, props);
137
+ return component(cached, props);
138
+ };
139
+ } else {
140
+ renderer[k] = OnDemand;
141
+ }
142
+ }
143
+ return renderer;
144
+ }
145
+ // Annotate the CommonJS export names for ESM import in node:
146
+ 0 && (module.exports = {
147
+ createClientLoader,
148
+ fromConfig,
149
+ toClientRenderer
150
+ });
@@ -0,0 +1,71 @@
1
+ import { TableOfContents } from 'fumadocs-core/server';
2
+ import { FC, ReactNode } from 'react';
3
+ import { MDXProps } from 'mdx/types';
4
+ import { StructuredData } from 'fumadocs-core/mdx-plugins';
5
+ import { D as DocCollection, M as MetaCollection, a as DocsCollection } from '../define-CCrinVBZ.cjs';
6
+ import { StandardSchemaV1 } from '@standard-schema/spec';
7
+ import { PageData, MetaData, Source } from 'fumadocs-core/source';
8
+ import 'zod';
9
+ import '@mdx-js/mdx';
10
+ import 'unified';
11
+
12
+ type CompiledMDXFile<Frontmatter> = {
13
+ frontmatter: Frontmatter;
14
+ toc: TableOfContents;
15
+ default: FC<MDXProps>;
16
+ structuredData: StructuredData;
17
+ } & Record<string, unknown>;
18
+ type MDXFileToPageData<Frontmatter> = Frontmatter & {
19
+ toc: TableOfContents;
20
+ default: FC<MDXProps>;
21
+ structuredData: StructuredData;
22
+ _exports: Record<string, unknown>;
23
+ };
24
+ type AttachGlobValue<GlobValue, Attach> = GlobValue extends () => Promise<unknown> ? () => Promise<Attach> : Attach;
25
+ declare function fromConfig<Config>(): {
26
+ doc: <Name extends keyof Config, GlobValue>(name: Name, glob: Record<string, GlobValue>) => Config[Name] extends DocCollection<infer Schema> ? Record<string, AttachGlobValue<GlobValue, CompiledMDXFile<StandardSchemaV1.InferOutput<Schema>>>> : never;
27
+ meta: <Name extends keyof Config, GlobValue>(name: Name, glob: Record<string, GlobValue>) => Config[Name] extends MetaCollection<infer Schema> ? AttachGlobValue<GlobValue, StandardSchemaV1.InferOutput<Schema>> : never;
28
+ docs: <Name extends keyof Config, DocGlobValue, MetaGlobValue>(name: Name, options: {
29
+ meta: Record<string, MetaGlobValue>;
30
+ doc: Record<string, DocGlobValue>;
31
+ }) => Config[Name] extends DocsCollection<infer DocSchema, infer MetaSchema> ? {
32
+ doc: Record<string, AttachGlobValue<DocGlobValue, CompiledMDXFile<StandardSchemaV1.InferOutput<DocSchema>>>>;
33
+ meta: Record<string, AttachGlobValue<MetaGlobValue, StandardSchemaV1.InferOutput<MetaSchema>>>;
34
+ } : never;
35
+ source: <DocOut extends PageData, MetaOut extends MetaData>(doc: Record<string, CompiledMDXFile<DocOut>>, meta: Record<string, MetaOut>) => Source<{
36
+ pageData: MDXFileToPageData<DocOut>;
37
+ metaData: MetaOut;
38
+ }>;
39
+ sourceAsync: <DocOut extends PageData, MetaOut extends MetaData>(doc: Record<string, () => Promise<CompiledMDXFile<DocOut>>>, meta: Record<string, () => Promise<MetaOut>>) => Promise<Source<{
40
+ pageData: MDXFileToPageData<DocOut>;
41
+ metaData: MetaOut;
42
+ }>>;
43
+ };
44
+ interface ClientLoaderOptions<Frontmatter, Props> {
45
+ /**
46
+ * Loader ID (usually your collection name)
47
+ *
48
+ * The code splitting strategy of frameworks like Tanstack Start may duplicate `createClientLoader()` into different chunks.
49
+ *
50
+ * We use loader ID to share cache between multiple instances of client loader.
51
+ *
52
+ * @defaultValue ''
53
+ */
54
+ id?: string;
55
+ component: (loaded: CompiledMDXFile<Frontmatter>, props: Props) => ReactNode;
56
+ }
57
+ interface ClientLoader<Frontmatter, Props> {
58
+ preload: (path: string) => Promise<CompiledMDXFile<Frontmatter>>;
59
+ /**
60
+ * Get a component that renders content with `React.lazy`
61
+ */
62
+ getComponent: (path: string) => FC<Props>;
63
+ }
64
+ declare function createClientLoader<Frontmatter, Props = object>(files: Record<string, () => Promise<CompiledMDXFile<Frontmatter>>>, options: ClientLoaderOptions<Frontmatter, Props>): ClientLoader<Frontmatter, Props>;
65
+ interface ClientRendererOptions<Frontmatter> {
66
+ cache?: Map<string, CompiledMDXFile<Frontmatter>>;
67
+ }
68
+ type ClientRenderer<Props> = Record<string, FC<Props>>;
69
+ declare function toClientRenderer<Frontmatter, Props = object>(files: Record<string, () => Promise<CompiledMDXFile<Frontmatter>>>, component: (loaded: CompiledMDXFile<Frontmatter>, props: Props) => ReactNode, options?: ClientRendererOptions<Frontmatter>): ClientRenderer<Props>;
70
+
71
+ export { type ClientLoader, type ClientLoaderOptions, type ClientRendererOptions, type CompiledMDXFile, createClientLoader, fromConfig, toClientRenderer };
@@ -0,0 +1,71 @@
1
+ import { TableOfContents } from 'fumadocs-core/server';
2
+ import { FC, ReactNode } from 'react';
3
+ import { MDXProps } from 'mdx/types';
4
+ import { StructuredData } from 'fumadocs-core/mdx-plugins';
5
+ import { D as DocCollection, M as MetaCollection, a as DocsCollection } from '../define-CCrinVBZ.js';
6
+ import { StandardSchemaV1 } from '@standard-schema/spec';
7
+ import { PageData, MetaData, Source } from 'fumadocs-core/source';
8
+ import 'zod';
9
+ import '@mdx-js/mdx';
10
+ import 'unified';
11
+
12
+ type CompiledMDXFile<Frontmatter> = {
13
+ frontmatter: Frontmatter;
14
+ toc: TableOfContents;
15
+ default: FC<MDXProps>;
16
+ structuredData: StructuredData;
17
+ } & Record<string, unknown>;
18
+ type MDXFileToPageData<Frontmatter> = Frontmatter & {
19
+ toc: TableOfContents;
20
+ default: FC<MDXProps>;
21
+ structuredData: StructuredData;
22
+ _exports: Record<string, unknown>;
23
+ };
24
+ type AttachGlobValue<GlobValue, Attach> = GlobValue extends () => Promise<unknown> ? () => Promise<Attach> : Attach;
25
+ declare function fromConfig<Config>(): {
26
+ doc: <Name extends keyof Config, GlobValue>(name: Name, glob: Record<string, GlobValue>) => Config[Name] extends DocCollection<infer Schema> ? Record<string, AttachGlobValue<GlobValue, CompiledMDXFile<StandardSchemaV1.InferOutput<Schema>>>> : never;
27
+ meta: <Name extends keyof Config, GlobValue>(name: Name, glob: Record<string, GlobValue>) => Config[Name] extends MetaCollection<infer Schema> ? AttachGlobValue<GlobValue, StandardSchemaV1.InferOutput<Schema>> : never;
28
+ docs: <Name extends keyof Config, DocGlobValue, MetaGlobValue>(name: Name, options: {
29
+ meta: Record<string, MetaGlobValue>;
30
+ doc: Record<string, DocGlobValue>;
31
+ }) => Config[Name] extends DocsCollection<infer DocSchema, infer MetaSchema> ? {
32
+ doc: Record<string, AttachGlobValue<DocGlobValue, CompiledMDXFile<StandardSchemaV1.InferOutput<DocSchema>>>>;
33
+ meta: Record<string, AttachGlobValue<MetaGlobValue, StandardSchemaV1.InferOutput<MetaSchema>>>;
34
+ } : never;
35
+ source: <DocOut extends PageData, MetaOut extends MetaData>(doc: Record<string, CompiledMDXFile<DocOut>>, meta: Record<string, MetaOut>) => Source<{
36
+ pageData: MDXFileToPageData<DocOut>;
37
+ metaData: MetaOut;
38
+ }>;
39
+ sourceAsync: <DocOut extends PageData, MetaOut extends MetaData>(doc: Record<string, () => Promise<CompiledMDXFile<DocOut>>>, meta: Record<string, () => Promise<MetaOut>>) => Promise<Source<{
40
+ pageData: MDXFileToPageData<DocOut>;
41
+ metaData: MetaOut;
42
+ }>>;
43
+ };
44
+ interface ClientLoaderOptions<Frontmatter, Props> {
45
+ /**
46
+ * Loader ID (usually your collection name)
47
+ *
48
+ * The code splitting strategy of frameworks like Tanstack Start may duplicate `createClientLoader()` into different chunks.
49
+ *
50
+ * We use loader ID to share cache between multiple instances of client loader.
51
+ *
52
+ * @defaultValue ''
53
+ */
54
+ id?: string;
55
+ component: (loaded: CompiledMDXFile<Frontmatter>, props: Props) => ReactNode;
56
+ }
57
+ interface ClientLoader<Frontmatter, Props> {
58
+ preload: (path: string) => Promise<CompiledMDXFile<Frontmatter>>;
59
+ /**
60
+ * Get a component that renders content with `React.lazy`
61
+ */
62
+ getComponent: (path: string) => FC<Props>;
63
+ }
64
+ declare function createClientLoader<Frontmatter, Props = object>(files: Record<string, () => Promise<CompiledMDXFile<Frontmatter>>>, options: ClientLoaderOptions<Frontmatter, Props>): ClientLoader<Frontmatter, Props>;
65
+ interface ClientRendererOptions<Frontmatter> {
66
+ cache?: Map<string, CompiledMDXFile<Frontmatter>>;
67
+ }
68
+ type ClientRenderer<Props> = Record<string, FC<Props>>;
69
+ declare function toClientRenderer<Frontmatter, Props = object>(files: Record<string, () => Promise<CompiledMDXFile<Frontmatter>>>, component: (loaded: CompiledMDXFile<Frontmatter>, props: Props) => ReactNode, options?: ClientRendererOptions<Frontmatter>): ClientRenderer<Props>;
70
+
71
+ export { type ClientLoader, type ClientLoaderOptions, type ClientRendererOptions, type CompiledMDXFile, createClientLoader, fromConfig, toClientRenderer };