fumadocs-mdx 13.0.7 → 14.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 (104) hide show
  1. package/dist/bin.cjs +927 -904
  2. package/dist/bin.js +3 -3
  3. package/dist/build-mdx-6UAK5FF5.js +8 -0
  4. package/dist/bun/index.cjs +592 -481
  5. package/dist/bun/index.d.cts +3 -2
  6. package/dist/bun/index.d.ts +3 -2
  7. package/dist/bun/index.js +12 -12
  8. package/dist/chunk-4JSFLXXT.js +8 -0
  9. package/dist/chunk-5UMZCWKV.js +17 -0
  10. package/dist/chunk-5YXP7JLN.js +138 -0
  11. package/dist/{chunk-2E2JCOSO.js → chunk-6NISOLQ6.js} +16 -44
  12. package/dist/chunk-7L2KNF6B.js +180 -0
  13. package/dist/chunk-E5DJTSIM.js +86 -0
  14. package/dist/{chunk-K5ZLPEIQ.js → chunk-FBLMK4RS.js} +9 -6
  15. package/dist/{chunk-QXHN25N3.js → chunk-OXSRIWQW.js} +7 -8
  16. package/dist/chunk-PKI7ZDA5.js +29 -0
  17. package/dist/{chunk-3J3WL7WN.js → chunk-SLY7WXTX.js} +71 -58
  18. package/dist/{chunk-ETIN2W7C.js → chunk-SRSRFOVI.js} +22 -19
  19. package/dist/chunk-TYJDYTKH.js +85 -0
  20. package/dist/chunk-XHJCLBZ4.js +406 -0
  21. package/dist/{chunk-2HXTGJBI.js → chunk-ZY6UZ7NH.js} +22 -19
  22. package/dist/config/index.cjs +79 -71
  23. package/dist/config/index.d.cts +2 -1
  24. package/dist/config/index.d.ts +2 -1
  25. package/dist/config/index.js +5 -5
  26. package/dist/index-BlVBvy-z.d.ts +8 -0
  27. package/dist/{core-HkAVGq_a.d.cts → index-D7JdSMpp.d.cts} +99 -61
  28. package/dist/{core-HkAVGq_a.d.ts → index-D7JdSMpp.d.ts} +99 -61
  29. package/dist/index-P2NNUkHn.d.cts +8 -0
  30. package/dist/index.d.cts +3 -74
  31. package/dist/index.d.ts +3 -74
  32. package/dist/load-from-file-I3ALLIVB.js +8 -0
  33. package/dist/next/index.cjs +698 -476
  34. package/dist/next/index.d.cts +11 -1
  35. package/dist/next/index.d.ts +11 -1
  36. package/dist/next/index.js +78 -281
  37. package/dist/node/loader.cjs +705 -603
  38. package/dist/node/loader.js +10 -11
  39. package/dist/plugins/index-file.cjs +471 -0
  40. package/dist/plugins/index-file.d.cts +29 -0
  41. package/dist/plugins/index-file.d.ts +29 -0
  42. package/dist/plugins/index-file.js +8 -0
  43. package/dist/plugins/json-schema.d.cts +3 -2
  44. package/dist/plugins/json-schema.d.ts +3 -2
  45. package/dist/plugins/last-modified.cjs +75 -0
  46. package/dist/plugins/last-modified.d.cts +27 -0
  47. package/dist/plugins/last-modified.d.ts +27 -0
  48. package/dist/plugins/last-modified.js +44 -0
  49. package/dist/runtime/{vite/browser.cjs → browser.cjs} +40 -53
  50. package/dist/runtime/browser.d.cts +50 -0
  51. package/dist/runtime/browser.d.ts +50 -0
  52. package/dist/runtime/browser.js +68 -0
  53. package/dist/runtime/dynamic.cjs +985 -0
  54. package/dist/runtime/dynamic.d.cts +27 -0
  55. package/dist/runtime/dynamic.d.ts +27 -0
  56. package/dist/runtime/dynamic.js +78 -0
  57. package/dist/runtime/server.cjs +173 -0
  58. package/dist/runtime/server.d.cts +161 -0
  59. package/dist/runtime/server.d.ts +161 -0
  60. package/dist/runtime/server.js +8 -0
  61. package/dist/vite/index.cjs +935 -639
  62. package/dist/vite/index.d.cts +12 -22
  63. package/dist/vite/index.d.ts +12 -22
  64. package/dist/vite/index.js +30 -221
  65. package/dist/webpack/mdx.cjs +614 -515
  66. package/dist/webpack/mdx.d.cts +9 -1
  67. package/dist/webpack/mdx.d.ts +9 -1
  68. package/dist/webpack/mdx.js +12 -17
  69. package/dist/webpack/meta.cjs +328 -234
  70. package/dist/webpack/meta.d.cts +9 -1
  71. package/dist/webpack/meta.d.ts +9 -1
  72. package/dist/webpack/meta.js +13 -15
  73. package/package.json +15 -32
  74. package/dist/build-mdx-BnJhW5O1.d.cts +0 -53
  75. package/dist/build-mdx-DNzfRRlY.d.ts +0 -53
  76. package/dist/chunk-2AQRQXSO.js +0 -119
  77. package/dist/chunk-4757L6ST.js +0 -77
  78. package/dist/chunk-CXA4JO4Z.js +0 -45
  79. package/dist/chunk-FSZMKRVH.js +0 -80
  80. package/dist/chunk-II3H5ZVZ.js +0 -77
  81. package/dist/chunk-KILFIBVW.js +0 -75
  82. package/dist/chunk-NVRDCY6Z.js +0 -30
  83. package/dist/chunk-VUEZTR2H.js +0 -26
  84. package/dist/index-D7s7kCc2.d.cts +0 -7
  85. package/dist/index-D7s7kCc2.d.ts +0 -7
  86. package/dist/load-from-file-AVYOFOI7.js +0 -7
  87. package/dist/preset-ZMP6U62C.js +0 -6
  88. package/dist/runtime/next/async.cjs +0 -760
  89. package/dist/runtime/next/async.d.cts +0 -19
  90. package/dist/runtime/next/async.d.ts +0 -19
  91. package/dist/runtime/next/async.js +0 -86
  92. package/dist/runtime/next/index.cjs +0 -136
  93. package/dist/runtime/next/index.d.cts +0 -33
  94. package/dist/runtime/next/index.d.ts +0 -33
  95. package/dist/runtime/next/index.js +0 -11
  96. package/dist/runtime/vite/browser.d.cts +0 -59
  97. package/dist/runtime/vite/browser.d.ts +0 -59
  98. package/dist/runtime/vite/browser.js +0 -11
  99. package/dist/runtime/vite/server.cjs +0 -243
  100. package/dist/runtime/vite/server.d.cts +0 -30
  101. package/dist/runtime/vite/server.d.ts +0 -30
  102. package/dist/runtime/vite/server.js +0 -111
  103. package/dist/types-By6wKOnT.d.cts +0 -45
  104. package/dist/types-DgD5Omj2.d.ts +0 -45
@@ -0,0 +1,27 @@
1
+ import * as fumadocs_core_source from 'fumadocs-core/source';
2
+ import { FileInfo, AsyncDocCollectionEntry, AsyncDocsCollectionEntry } from './server.cjs';
3
+ import { C as CoreOptions, D as DocCollection, b as DocsCollection } from '../index-D7JdSMpp.cjs';
4
+ import * as _standard_schema_spec from '@standard-schema/spec';
5
+ import 'fumadocs-core/mdx-plugins';
6
+ import 'fumadocs-core/toc';
7
+ import 'mdx/types';
8
+ import 'mdast';
9
+ import '@mdx-js/mdx';
10
+ import 'react';
11
+ import 'unified';
12
+ import 'zod';
13
+ import 'chokidar';
14
+ import 'vfile';
15
+
16
+ interface LazyEntry<Data = unknown> {
17
+ info: FileInfo;
18
+ data: Data;
19
+ hash?: string;
20
+ }
21
+ type CreateDynamic<Config> = ReturnType<typeof fromConfigDynamic<Config>>;
22
+ declare function fromConfigDynamic<Config>(configExports: Config, coreOptions: CoreOptions): Promise<{
23
+ doc<Name extends keyof Config>(name: Name, base: string, entries: LazyEntry<unknown>[]): Promise<Config[Name] extends DocCollection<infer Schema extends _standard_schema_spec.StandardSchemaV1<unknown, unknown>> | DocsCollection<infer Schema extends _standard_schema_spec.StandardSchemaV1<unknown, unknown>, _standard_schema_spec.StandardSchemaV1<unknown, unknown>> ? AsyncDocCollectionEntry<_standard_schema_spec.StandardSchemaV1.InferOutput<Schema>>[] : never>;
24
+ docs<Name extends keyof Config>(name: Name, base: string, meta: Record<string, unknown>, entries: LazyEntry<unknown>[]): Promise<Config[Name] extends DocsCollection<infer Page extends _standard_schema_spec.StandardSchemaV1<unknown, unknown>, infer Meta extends _standard_schema_spec.StandardSchemaV1<unknown, unknown>> ? _standard_schema_spec.StandardSchemaV1.InferOutput<Page> extends fumadocs_core_source.PageData ? _standard_schema_spec.StandardSchemaV1.InferOutput<Meta> extends fumadocs_core_source.MetaData ? AsyncDocsCollectionEntry<_standard_schema_spec.StandardSchemaV1.InferOutput<Page>, _standard_schema_spec.StandardSchemaV1.InferOutput<Meta>> : never : never : never>;
25
+ }>;
26
+
27
+ export { type CreateDynamic, type LazyEntry, fromConfigDynamic };
@@ -0,0 +1,27 @@
1
+ import * as fumadocs_core_source from 'fumadocs-core/source';
2
+ import { FileInfo, AsyncDocCollectionEntry, AsyncDocsCollectionEntry } from './server.js';
3
+ import { C as CoreOptions, D as DocCollection, b as DocsCollection } from '../index-D7JdSMpp.js';
4
+ import * as _standard_schema_spec from '@standard-schema/spec';
5
+ import 'fumadocs-core/mdx-plugins';
6
+ import 'fumadocs-core/toc';
7
+ import 'mdx/types';
8
+ import 'mdast';
9
+ import '@mdx-js/mdx';
10
+ import 'react';
11
+ import 'unified';
12
+ import 'zod';
13
+ import 'chokidar';
14
+ import 'vfile';
15
+
16
+ interface LazyEntry<Data = unknown> {
17
+ info: FileInfo;
18
+ data: Data;
19
+ hash?: string;
20
+ }
21
+ type CreateDynamic<Config> = ReturnType<typeof fromConfigDynamic<Config>>;
22
+ declare function fromConfigDynamic<Config>(configExports: Config, coreOptions: CoreOptions): Promise<{
23
+ doc<Name extends keyof Config>(name: Name, base: string, entries: LazyEntry<unknown>[]): Promise<Config[Name] extends DocCollection<infer Schema extends _standard_schema_spec.StandardSchemaV1<unknown, unknown>> | DocsCollection<infer Schema extends _standard_schema_spec.StandardSchemaV1<unknown, unknown>, _standard_schema_spec.StandardSchemaV1<unknown, unknown>> ? AsyncDocCollectionEntry<_standard_schema_spec.StandardSchemaV1.InferOutput<Schema>>[] : never>;
24
+ docs<Name extends keyof Config>(name: Name, base: string, meta: Record<string, unknown>, entries: LazyEntry<unknown>[]): Promise<Config[Name] extends DocsCollection<infer Page extends _standard_schema_spec.StandardSchemaV1<unknown, unknown>, infer Meta extends _standard_schema_spec.StandardSchemaV1<unknown, unknown>> ? _standard_schema_spec.StandardSchemaV1.InferOutput<Page> extends fumadocs_core_source.PageData ? _standard_schema_spec.StandardSchemaV1.InferOutput<Meta> extends fumadocs_core_source.MetaData ? AsyncDocsCollectionEntry<_standard_schema_spec.StandardSchemaV1.InferOutput<Page>, _standard_schema_spec.StandardSchemaV1.InferOutput<Meta>> : never : never : never>;
25
+ }>;
26
+
27
+ export { type CreateDynamic, type LazyEntry, fromConfigDynamic };
@@ -0,0 +1,78 @@
1
+ import {
2
+ buildMDX
3
+ } from "../chunk-SLY7WXTX.js";
4
+ import {
5
+ fromConfig
6
+ } from "../chunk-5YXP7JLN.js";
7
+ import "../chunk-FBLMK4RS.js";
8
+ import {
9
+ buildConfig
10
+ } from "../chunk-ZY6UZ7NH.js";
11
+ import "../chunk-E5DJTSIM.js";
12
+ import {
13
+ createCore
14
+ } from "../chunk-7L2KNF6B.js";
15
+ import "../chunk-PKI7ZDA5.js";
16
+ import {
17
+ fumaMatter
18
+ } from "../chunk-VWJKRQZR.js";
19
+
20
+ // src/runtime/dynamic.ts
21
+ import { executeMdx } from "@fumadocs/mdx-remote/client";
22
+ import { pathToFileURL } from "url";
23
+ import fs from "fs/promises";
24
+ async function fromConfigDynamic(configExports, coreOptions) {
25
+ const core = await createCore(coreOptions).init({
26
+ config: buildConfig(configExports)
27
+ });
28
+ const create = fromConfig();
29
+ function getDocCollection(name) {
30
+ const collection = core.getConfig().getCollection(name);
31
+ if (!collection) return;
32
+ if (collection.type === "docs") return collection.docs;
33
+ else if (collection.type === "doc") return collection;
34
+ }
35
+ function convertLazyEntries(collection, entries) {
36
+ const head = {};
37
+ const body = {};
38
+ async function compile({ info, data }) {
39
+ let content = (await fs.readFile(info.fullPath)).toString();
40
+ content = fumaMatter(content).content;
41
+ const compiled = await buildMDX(core, collection, {
42
+ filePath: info.fullPath,
43
+ source: content,
44
+ frontmatter: data,
45
+ isDevelopment: false,
46
+ environment: "runtime"
47
+ });
48
+ return await executeMdx(String(compiled.value), {
49
+ baseUrl: pathToFileURL(info.fullPath)
50
+ });
51
+ }
52
+ for (const entry of entries) {
53
+ head[entry.info.path] = () => entry.data;
54
+ let cachedResult;
55
+ body[entry.info.path] = () => cachedResult ??= compile(entry);
56
+ }
57
+ return { head, body };
58
+ }
59
+ return {
60
+ async doc(name, base, entries) {
61
+ const collection = getDocCollection(name);
62
+ if (!collection)
63
+ throw new Error(`the doc collection ${name} doesn't exist.`);
64
+ const { head, body } = convertLazyEntries(collection, entries);
65
+ return create.docLazy(name, base, head, body);
66
+ },
67
+ async docs(name, base, meta, entries) {
68
+ const collection = getDocCollection(name);
69
+ if (!collection)
70
+ throw new Error(`the doc collection ${name} doesn't exist.`);
71
+ const docs = convertLazyEntries(collection, entries);
72
+ return create.docsLazy(name, base, meta, docs.head, docs.body);
73
+ }
74
+ };
75
+ }
76
+ export {
77
+ fromConfigDynamic
78
+ };
@@ -0,0 +1,173 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/runtime/server.ts
31
+ var server_exports = {};
32
+ __export(server_exports, {
33
+ fromConfig: () => fromConfig,
34
+ toFumadocsSource: () => toFumadocsSource
35
+ });
36
+ module.exports = __toCommonJS(server_exports);
37
+ var path = __toESM(require("path"), 1);
38
+ function fromConfig() {
39
+ function fileInfo(file, base) {
40
+ if (file.startsWith("./")) {
41
+ file = file.slice(2);
42
+ }
43
+ return {
44
+ path: file,
45
+ fullPath: path.join(base, file)
46
+ };
47
+ }
48
+ function mapDocData(entry) {
49
+ return {
50
+ body: entry.default,
51
+ toc: entry.toc,
52
+ extractedReferences: entry.extractedReferences,
53
+ structuredData: entry.structuredData,
54
+ lastModified: entry.lastModified,
55
+ _exports: entry
56
+ };
57
+ }
58
+ return {
59
+ async doc(_name, base, glob) {
60
+ const out = await Promise.all(
61
+ Object.entries(glob).map(async ([k, v]) => {
62
+ const data = typeof v === "function" ? await v() : v;
63
+ return {
64
+ ...mapDocData(data),
65
+ ...data.frontmatter,
66
+ ...createDocMethods(fileInfo(k, base), () => data)
67
+ };
68
+ })
69
+ );
70
+ return out;
71
+ },
72
+ async docLazy(_name, base, head, body) {
73
+ const out = await Promise.all(
74
+ Object.entries(head).map(async ([k, v]) => {
75
+ const data = typeof v === "function" ? await v() : v;
76
+ const content = body[k];
77
+ return {
78
+ ...data,
79
+ ...createDocMethods(fileInfo(k, base), content),
80
+ async load() {
81
+ return mapDocData(await content());
82
+ }
83
+ };
84
+ })
85
+ );
86
+ return out;
87
+ },
88
+ async meta(_name, base, glob) {
89
+ const out = await Promise.all(
90
+ Object.entries(glob).map(async ([k, v]) => {
91
+ const data = typeof v === "function" ? await v() : v;
92
+ return {
93
+ info: fileInfo(k, base),
94
+ ...data
95
+ };
96
+ })
97
+ );
98
+ return out;
99
+ },
100
+ async docs(name, base, metaGlob, docGlob) {
101
+ const entry = {
102
+ docs: await this.doc(name, base, docGlob),
103
+ meta: await this.meta(name, base, metaGlob),
104
+ toFumadocsSource() {
105
+ return toFumadocsSource(this.docs, this.meta);
106
+ }
107
+ };
108
+ return entry;
109
+ },
110
+ async docsLazy(name, base, metaGlob, docHeadGlob, docBodyGlob) {
111
+ const entry = {
112
+ docs: await this.docLazy(name, base, docHeadGlob, docBodyGlob),
113
+ meta: await this.meta(name, base, metaGlob),
114
+ toFumadocsSource() {
115
+ return toFumadocsSource(this.docs, this.meta);
116
+ }
117
+ };
118
+ return entry;
119
+ }
120
+ };
121
+ }
122
+ function toFumadocsSource(pages, metas) {
123
+ const files = [];
124
+ for (const entry of pages) {
125
+ files.push({
126
+ type: "page",
127
+ path: entry.info.path,
128
+ absolutePath: entry.info.fullPath,
129
+ data: entry
130
+ });
131
+ }
132
+ for (const entry of metas) {
133
+ files.push({
134
+ type: "meta",
135
+ path: entry.info.path,
136
+ absolutePath: entry.info.fullPath,
137
+ data: entry
138
+ });
139
+ }
140
+ return {
141
+ files
142
+ };
143
+ }
144
+ function createDocMethods(info, load) {
145
+ return {
146
+ info,
147
+ async getText(type) {
148
+ if (type === "raw") {
149
+ const fs = await import("fs/promises");
150
+ return (await fs.readFile(info.fullPath)).toString();
151
+ }
152
+ const data = await load();
153
+ if (typeof data._markdown !== "string")
154
+ throw new Error(
155
+ "getText('processed') requires `includeProcessedMarkdown` to be enabled in your collection config."
156
+ );
157
+ return data._markdown;
158
+ },
159
+ async getMDAST() {
160
+ const data = await load();
161
+ if (!data._mdast)
162
+ throw new Error(
163
+ "getMDAST() requires `includeMDAST` to be enabled in your collection config."
164
+ );
165
+ return JSON.parse(data._mdast);
166
+ }
167
+ };
168
+ }
169
+ // Annotate the CommonJS export names for ESM import in node:
170
+ 0 && (module.exports = {
171
+ fromConfig,
172
+ toFumadocsSource
173
+ });
@@ -0,0 +1,161 @@
1
+ import { PageData, MetaData, Source } from 'fumadocs-core/source';
2
+ import { StructuredData } from 'fumadocs-core/mdx-plugins';
3
+ import { TOCItemType } from 'fumadocs-core/toc';
4
+ import { MDXProps, MDXContent } from 'mdx/types';
5
+ import { E as ExtractedReference, D as DocCollection, b as DocsCollection, M as MetaCollection } from '../index-D7JdSMpp.cjs';
6
+ import { Root } from 'mdast';
7
+ import { StandardSchemaV1 } from '@standard-schema/spec';
8
+ import { createProcessor } from '@mdx-js/mdx';
9
+ import { FC } from 'react';
10
+ import 'unified';
11
+ import 'zod';
12
+ import 'chokidar';
13
+ import 'vfile';
14
+
15
+ type Processor = ReturnType<typeof createProcessor>;
16
+ interface CompilerOptions {
17
+ addDependency: (file: string) => void;
18
+ }
19
+ interface CompiledMDXProperties<Frontmatter = Record<string, unknown>> {
20
+ frontmatter: Frontmatter;
21
+ structuredData: StructuredData;
22
+ toc: TOCItemType[];
23
+ default: FC<MDXProps>;
24
+ /**
25
+ * Added by the `last-modified` plugin.
26
+ */
27
+ lastModified?: Date;
28
+ /**
29
+ * Enable from `postprocess` option.
30
+ */
31
+ extractedReferences?: ExtractedReference[];
32
+ /**
33
+ * Enable from `postprocess` option.
34
+ */
35
+ _markdown?: string;
36
+ /**
37
+ * Enable from `postprocess` option.
38
+ */
39
+ _mdast?: string;
40
+ }
41
+ interface FumadocsDataMap {
42
+ /**
43
+ * [Fumadocs MDX] raw frontmatter, you can modify it
44
+ */
45
+ frontmatter?: Record<string, unknown>;
46
+ /**
47
+ * [Fumadocs MDX] additional ESM exports to write
48
+ */
49
+ 'mdx-export'?: {
50
+ name: string;
51
+ value: unknown;
52
+ }[];
53
+ /**
54
+ * [Fumadocs MDX] The compiler object from loader
55
+ */
56
+ _compiler?: CompilerOptions;
57
+ /**
58
+ * [Fumadocs MDX] get internal processor, do not use this on user land.
59
+ */
60
+ _getProcessor?: (format: 'md' | 'mdx') => Processor;
61
+ }
62
+ declare module 'vfile' {
63
+ interface DataMap extends FumadocsDataMap {
64
+ }
65
+ }
66
+
67
+ interface FileInfo {
68
+ /**
69
+ * virtualized path for Source API
70
+ */
71
+ path: string;
72
+ /**
73
+ * the file path in file system
74
+ */
75
+ fullPath: string;
76
+ }
77
+ interface DocData {
78
+ /**
79
+ * Compiled MDX content (as component)
80
+ */
81
+ body: MDXContent;
82
+ /**
83
+ * table of contents generated from content.
84
+ */
85
+ toc: TOCItemType[];
86
+ /**
87
+ * structured data for document search indexing.
88
+ */
89
+ structuredData: StructuredData;
90
+ /**
91
+ * Raw exports from the compiled MDX file.
92
+ */
93
+ _exports: Record<string, unknown>;
94
+ /**
95
+ * Last modified date of document file, obtained from version control.
96
+ *
97
+ * Added by the `last-modified` plugin.
98
+ */
99
+ lastModified?: Date;
100
+ /**
101
+ * extracted references (e.g. hrefs, paths), useful for analyzing relationships between pages.
102
+ */
103
+ extractedReferences?: ExtractedReference[];
104
+ }
105
+ interface DocMethods {
106
+ /**
107
+ * file info
108
+ */
109
+ info: FileInfo;
110
+ /**
111
+ * get document as text.
112
+ *
113
+ * - `type: raw` - read the original content from file system.
114
+ * - `type: processed` - get the processed Markdown content, only available when `includeProcessedMarkdown` is enabled on collection config.
115
+ */
116
+ getText: (type: 'raw' | 'processed') => Promise<string>;
117
+ getMDAST: () => Promise<Root>;
118
+ }
119
+ interface MetaMethods {
120
+ /**
121
+ * file info
122
+ */
123
+ info: FileInfo;
124
+ }
125
+ type MetaCollectionEntry<Data> = Data & MetaMethods;
126
+ type DocCollectionEntry<Frontmatter> = DocData & DocMethods & Frontmatter;
127
+ type AsyncDocCollectionEntry<Frontmatter> = DocMethods & {
128
+ load: () => Promise<DocData>;
129
+ } & Frontmatter;
130
+ type CompiledMDXFile<Frontmatter> = CompiledMDXProperties<Frontmatter> & Record<string, unknown>;
131
+ interface DocsCollectionEntry<Frontmatter extends PageData, Meta extends MetaData> {
132
+ docs: DocCollectionEntry<Frontmatter>[];
133
+ meta: MetaCollectionEntry<Meta>[];
134
+ toFumadocsSource: () => Source<{
135
+ pageData: DocCollectionEntry<Frontmatter>;
136
+ metaData: MetaCollectionEntry<Meta>;
137
+ }>;
138
+ }
139
+ interface AsyncDocsCollectionEntry<Frontmatter extends PageData, Meta extends MetaData> {
140
+ docs: AsyncDocCollectionEntry<Frontmatter>[];
141
+ meta: MetaCollectionEntry<Meta>[];
142
+ toFumadocsSource: () => Source<{
143
+ pageData: AsyncDocCollectionEntry<Frontmatter>;
144
+ metaData: MetaCollectionEntry<Meta>;
145
+ }>;
146
+ }
147
+ type AwaitableGlobEntries<T> = Record<string, T | (() => Promise<T>)>;
148
+ type ServerCreate<Config> = ReturnType<typeof fromConfig<Config>>;
149
+ declare function fromConfig<Config>(): {
150
+ doc<Name extends keyof Config>(_name: Name, base: string, glob: AwaitableGlobEntries<unknown>): Promise<Config[Name] extends DocCollection<infer Schema extends StandardSchemaV1<unknown, unknown>> | DocsCollection<infer Schema extends StandardSchemaV1<unknown, unknown>, StandardSchemaV1<unknown, unknown>> ? DocCollectionEntry<StandardSchemaV1.InferOutput<Schema>>[] : never>;
151
+ docLazy<Name extends keyof Config>(_name: Name, base: string, head: AwaitableGlobEntries<unknown>, body: Record<string, () => Promise<unknown>>): Promise<Config[Name] extends DocCollection<infer Schema extends StandardSchemaV1<unknown, unknown>> | DocsCollection<infer Schema extends StandardSchemaV1<unknown, unknown>, StandardSchemaV1<unknown, unknown>> ? AsyncDocCollectionEntry<StandardSchemaV1.InferOutput<Schema>>[] : never>;
152
+ meta<Name extends keyof Config>(_name: Name, base: string, glob: AwaitableGlobEntries<unknown>): Promise<Config[Name] extends MetaCollection<infer Schema extends StandardSchemaV1<unknown, unknown>> | DocsCollection<StandardSchemaV1<unknown, unknown>, infer Schema extends StandardSchemaV1<unknown, unknown>> ? MetaCollectionEntry<StandardSchemaV1.InferOutput<Schema>>[] : never>;
153
+ docs<Name extends keyof Config>(name: Name, base: string, metaGlob: AwaitableGlobEntries<unknown>, docGlob: AwaitableGlobEntries<unknown>): Promise<Config[Name] extends DocsCollection<infer Page extends StandardSchemaV1<unknown, unknown>, infer Meta extends StandardSchemaV1<unknown, unknown>> ? StandardSchemaV1.InferOutput<Page> extends PageData ? StandardSchemaV1.InferOutput<Meta> extends MetaData ? DocsCollectionEntry<StandardSchemaV1.InferOutput<Page>, StandardSchemaV1.InferOutput<Meta>> : never : never : never>;
154
+ docsLazy<Name extends keyof Config>(name: Name, base: string, metaGlob: AwaitableGlobEntries<unknown>, docHeadGlob: AwaitableGlobEntries<unknown>, docBodyGlob: Record<string, () => Promise<unknown>>): Promise<Config[Name] extends DocsCollection<infer Page extends StandardSchemaV1<unknown, unknown>, infer Meta extends StandardSchemaV1<unknown, unknown>> ? StandardSchemaV1.InferOutput<Page> extends PageData ? StandardSchemaV1.InferOutput<Meta> extends MetaData ? AsyncDocsCollectionEntry<StandardSchemaV1.InferOutput<Page>, StandardSchemaV1.InferOutput<Meta>> : never : never : never>;
155
+ };
156
+ declare function toFumadocsSource<Page extends DocMethods & PageData, Meta extends MetaMethods & MetaData>(pages: Page[], metas: Meta[]): Source<{
157
+ pageData: Page;
158
+ metaData: Meta;
159
+ }>;
160
+
161
+ export { type AsyncDocCollectionEntry, type AsyncDocsCollectionEntry, type CompiledMDXFile, type DocCollectionEntry, type DocData, type DocMethods, type DocsCollectionEntry, type FileInfo, type MetaCollectionEntry, type MetaMethods, type ServerCreate, fromConfig, toFumadocsSource };
@@ -0,0 +1,161 @@
1
+ import { PageData, MetaData, Source } from 'fumadocs-core/source';
2
+ import { StructuredData } from 'fumadocs-core/mdx-plugins';
3
+ import { TOCItemType } from 'fumadocs-core/toc';
4
+ import { MDXProps, MDXContent } from 'mdx/types';
5
+ import { E as ExtractedReference, D as DocCollection, b as DocsCollection, M as MetaCollection } from '../index-D7JdSMpp.js';
6
+ import { Root } from 'mdast';
7
+ import { StandardSchemaV1 } from '@standard-schema/spec';
8
+ import { createProcessor } from '@mdx-js/mdx';
9
+ import { FC } from 'react';
10
+ import 'unified';
11
+ import 'zod';
12
+ import 'chokidar';
13
+ import 'vfile';
14
+
15
+ type Processor = ReturnType<typeof createProcessor>;
16
+ interface CompilerOptions {
17
+ addDependency: (file: string) => void;
18
+ }
19
+ interface CompiledMDXProperties<Frontmatter = Record<string, unknown>> {
20
+ frontmatter: Frontmatter;
21
+ structuredData: StructuredData;
22
+ toc: TOCItemType[];
23
+ default: FC<MDXProps>;
24
+ /**
25
+ * Added by the `last-modified` plugin.
26
+ */
27
+ lastModified?: Date;
28
+ /**
29
+ * Enable from `postprocess` option.
30
+ */
31
+ extractedReferences?: ExtractedReference[];
32
+ /**
33
+ * Enable from `postprocess` option.
34
+ */
35
+ _markdown?: string;
36
+ /**
37
+ * Enable from `postprocess` option.
38
+ */
39
+ _mdast?: string;
40
+ }
41
+ interface FumadocsDataMap {
42
+ /**
43
+ * [Fumadocs MDX] raw frontmatter, you can modify it
44
+ */
45
+ frontmatter?: Record<string, unknown>;
46
+ /**
47
+ * [Fumadocs MDX] additional ESM exports to write
48
+ */
49
+ 'mdx-export'?: {
50
+ name: string;
51
+ value: unknown;
52
+ }[];
53
+ /**
54
+ * [Fumadocs MDX] The compiler object from loader
55
+ */
56
+ _compiler?: CompilerOptions;
57
+ /**
58
+ * [Fumadocs MDX] get internal processor, do not use this on user land.
59
+ */
60
+ _getProcessor?: (format: 'md' | 'mdx') => Processor;
61
+ }
62
+ declare module 'vfile' {
63
+ interface DataMap extends FumadocsDataMap {
64
+ }
65
+ }
66
+
67
+ interface FileInfo {
68
+ /**
69
+ * virtualized path for Source API
70
+ */
71
+ path: string;
72
+ /**
73
+ * the file path in file system
74
+ */
75
+ fullPath: string;
76
+ }
77
+ interface DocData {
78
+ /**
79
+ * Compiled MDX content (as component)
80
+ */
81
+ body: MDXContent;
82
+ /**
83
+ * table of contents generated from content.
84
+ */
85
+ toc: TOCItemType[];
86
+ /**
87
+ * structured data for document search indexing.
88
+ */
89
+ structuredData: StructuredData;
90
+ /**
91
+ * Raw exports from the compiled MDX file.
92
+ */
93
+ _exports: Record<string, unknown>;
94
+ /**
95
+ * Last modified date of document file, obtained from version control.
96
+ *
97
+ * Added by the `last-modified` plugin.
98
+ */
99
+ lastModified?: Date;
100
+ /**
101
+ * extracted references (e.g. hrefs, paths), useful for analyzing relationships between pages.
102
+ */
103
+ extractedReferences?: ExtractedReference[];
104
+ }
105
+ interface DocMethods {
106
+ /**
107
+ * file info
108
+ */
109
+ info: FileInfo;
110
+ /**
111
+ * get document as text.
112
+ *
113
+ * - `type: raw` - read the original content from file system.
114
+ * - `type: processed` - get the processed Markdown content, only available when `includeProcessedMarkdown` is enabled on collection config.
115
+ */
116
+ getText: (type: 'raw' | 'processed') => Promise<string>;
117
+ getMDAST: () => Promise<Root>;
118
+ }
119
+ interface MetaMethods {
120
+ /**
121
+ * file info
122
+ */
123
+ info: FileInfo;
124
+ }
125
+ type MetaCollectionEntry<Data> = Data & MetaMethods;
126
+ type DocCollectionEntry<Frontmatter> = DocData & DocMethods & Frontmatter;
127
+ type AsyncDocCollectionEntry<Frontmatter> = DocMethods & {
128
+ load: () => Promise<DocData>;
129
+ } & Frontmatter;
130
+ type CompiledMDXFile<Frontmatter> = CompiledMDXProperties<Frontmatter> & Record<string, unknown>;
131
+ interface DocsCollectionEntry<Frontmatter extends PageData, Meta extends MetaData> {
132
+ docs: DocCollectionEntry<Frontmatter>[];
133
+ meta: MetaCollectionEntry<Meta>[];
134
+ toFumadocsSource: () => Source<{
135
+ pageData: DocCollectionEntry<Frontmatter>;
136
+ metaData: MetaCollectionEntry<Meta>;
137
+ }>;
138
+ }
139
+ interface AsyncDocsCollectionEntry<Frontmatter extends PageData, Meta extends MetaData> {
140
+ docs: AsyncDocCollectionEntry<Frontmatter>[];
141
+ meta: MetaCollectionEntry<Meta>[];
142
+ toFumadocsSource: () => Source<{
143
+ pageData: AsyncDocCollectionEntry<Frontmatter>;
144
+ metaData: MetaCollectionEntry<Meta>;
145
+ }>;
146
+ }
147
+ type AwaitableGlobEntries<T> = Record<string, T | (() => Promise<T>)>;
148
+ type ServerCreate<Config> = ReturnType<typeof fromConfig<Config>>;
149
+ declare function fromConfig<Config>(): {
150
+ doc<Name extends keyof Config>(_name: Name, base: string, glob: AwaitableGlobEntries<unknown>): Promise<Config[Name] extends DocCollection<infer Schema extends StandardSchemaV1<unknown, unknown>> | DocsCollection<infer Schema extends StandardSchemaV1<unknown, unknown>, StandardSchemaV1<unknown, unknown>> ? DocCollectionEntry<StandardSchemaV1.InferOutput<Schema>>[] : never>;
151
+ docLazy<Name extends keyof Config>(_name: Name, base: string, head: AwaitableGlobEntries<unknown>, body: Record<string, () => Promise<unknown>>): Promise<Config[Name] extends DocCollection<infer Schema extends StandardSchemaV1<unknown, unknown>> | DocsCollection<infer Schema extends StandardSchemaV1<unknown, unknown>, StandardSchemaV1<unknown, unknown>> ? AsyncDocCollectionEntry<StandardSchemaV1.InferOutput<Schema>>[] : never>;
152
+ meta<Name extends keyof Config>(_name: Name, base: string, glob: AwaitableGlobEntries<unknown>): Promise<Config[Name] extends MetaCollection<infer Schema extends StandardSchemaV1<unknown, unknown>> | DocsCollection<StandardSchemaV1<unknown, unknown>, infer Schema extends StandardSchemaV1<unknown, unknown>> ? MetaCollectionEntry<StandardSchemaV1.InferOutput<Schema>>[] : never>;
153
+ docs<Name extends keyof Config>(name: Name, base: string, metaGlob: AwaitableGlobEntries<unknown>, docGlob: AwaitableGlobEntries<unknown>): Promise<Config[Name] extends DocsCollection<infer Page extends StandardSchemaV1<unknown, unknown>, infer Meta extends StandardSchemaV1<unknown, unknown>> ? StandardSchemaV1.InferOutput<Page> extends PageData ? StandardSchemaV1.InferOutput<Meta> extends MetaData ? DocsCollectionEntry<StandardSchemaV1.InferOutput<Page>, StandardSchemaV1.InferOutput<Meta>> : never : never : never>;
154
+ docsLazy<Name extends keyof Config>(name: Name, base: string, metaGlob: AwaitableGlobEntries<unknown>, docHeadGlob: AwaitableGlobEntries<unknown>, docBodyGlob: Record<string, () => Promise<unknown>>): Promise<Config[Name] extends DocsCollection<infer Page extends StandardSchemaV1<unknown, unknown>, infer Meta extends StandardSchemaV1<unknown, unknown>> ? StandardSchemaV1.InferOutput<Page> extends PageData ? StandardSchemaV1.InferOutput<Meta> extends MetaData ? AsyncDocsCollectionEntry<StandardSchemaV1.InferOutput<Page>, StandardSchemaV1.InferOutput<Meta>> : never : never : never>;
155
+ };
156
+ declare function toFumadocsSource<Page extends DocMethods & PageData, Meta extends MetaMethods & MetaData>(pages: Page[], metas: Meta[]): Source<{
157
+ pageData: Page;
158
+ metaData: Meta;
159
+ }>;
160
+
161
+ export { type AsyncDocCollectionEntry, type AsyncDocsCollectionEntry, type CompiledMDXFile, type DocCollectionEntry, type DocData, type DocMethods, type DocsCollectionEntry, type FileInfo, type MetaCollectionEntry, type MetaMethods, type ServerCreate, fromConfig, toFumadocsSource };
@@ -0,0 +1,8 @@
1
+ import {
2
+ fromConfig,
3
+ toFumadocsSource
4
+ } from "../chunk-5YXP7JLN.js";
5
+ export {
6
+ fromConfig,
7
+ toFumadocsSource
8
+ };