fumadocs-mdx 12.0.3 → 13.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.
- package/dist/bin.cjs +1033 -308
- package/dist/bin.js +4 -4
- package/dist/build-mdx-BHG-_uxo.d.cts +53 -0
- package/dist/build-mdx-CzrQDBRZ.d.ts +53 -0
- package/dist/bun/index.cjs +92 -28
- package/dist/bun/index.js +6 -7
- package/dist/{chunk-QAUWMR5D.js → chunk-3J3WL7WN.js} +23 -5
- package/dist/chunk-4MAYA5QX.js +44 -0
- package/dist/{chunk-RMDXSZYE.js → chunk-CEA6MYJU.js} +13 -8
- package/dist/{chunk-IQAEAI4P.js → chunk-HI62EXSB.js} +63 -2
- package/dist/{chunk-46UPKP5R.js → chunk-II3H5ZVZ.js} +5 -5
- package/dist/{chunk-LGYVNESJ.js → chunk-JVZFH6ND.js} +6 -22
- package/dist/{chunk-LMG6UWCL.js → chunk-K5ZLPEIQ.js} +56 -16
- package/dist/{chunk-OMAMTKDE.js → chunk-KILFIBVW.js} +3 -12
- package/dist/chunk-NVRDCY6Z.js +30 -0
- package/dist/{chunk-VXEBLM4X.js → chunk-XV5Z4BFL.js} +1 -1
- package/dist/config/index.cjs +56 -16
- package/dist/config/index.d.cts +2 -1
- package/dist/config/index.d.ts +2 -1
- package/dist/config/index.js +1 -1
- package/dist/{define-DJbJduHy.d.ts → define-BCNh3n4O.d.cts} +40 -16
- package/dist/{define-DJbJduHy.d.cts → define-bck_EB4t.d.ts} +40 -16
- package/dist/index.cjs +0 -109
- package/dist/index.d.cts +73 -12
- package/dist/index.d.ts +73 -12
- package/dist/index.js +0 -11
- package/dist/{load-UUXLUBHL.js → load-MNG3CLET.js} +1 -3
- package/dist/loader-mdx.cjs +153 -60
- package/dist/loader-mdx.d.cts +1 -0
- package/dist/loader-mdx.d.ts +1 -0
- package/dist/loader-mdx.js +23 -9
- package/dist/next/index.cjs +213 -181
- package/dist/next/index.d.cts +2 -11
- package/dist/next/index.d.ts +2 -11
- package/dist/next/index.js +145 -117
- package/dist/node/loader.cjs +128 -70
- package/dist/node/loader.js +14 -9
- package/dist/plugins/index.cjs +78 -0
- package/dist/plugins/index.d.cts +7 -0
- package/dist/plugins/index.d.ts +7 -0
- package/dist/plugins/index.js +6 -0
- package/dist/plugins/json-schema.cjs +61 -0
- package/dist/plugins/json-schema.d.cts +16 -0
- package/dist/plugins/json-schema.d.ts +16 -0
- package/dist/plugins/json-schema.js +40 -0
- package/dist/remark-postprocess-K233ZVBK.d.cts +22 -0
- package/dist/remark-postprocess-K233ZVBK.d.ts +22 -0
- package/dist/runtime/next/async.cjs +108 -70
- package/dist/runtime/next/async.d.cts +9 -6
- package/dist/runtime/next/async.d.ts +9 -6
- package/dist/runtime/next/async.js +9 -19
- package/dist/runtime/next/index.cjs +25 -14
- package/dist/runtime/next/index.d.cts +11 -8
- package/dist/runtime/next/index.d.ts +11 -8
- package/dist/runtime/next/index.js +2 -2
- package/dist/runtime/vite/browser.cjs +7 -3
- package/dist/runtime/vite/browser.d.cts +56 -7
- package/dist/runtime/vite/browser.d.ts +56 -7
- package/dist/runtime/vite/browser.js +2 -1
- package/dist/runtime/vite/server.cjs +40 -34
- package/dist/runtime/vite/server.d.cts +13 -10
- package/dist/runtime/vite/server.d.ts +13 -10
- package/dist/runtime/vite/server.js +8 -23
- package/dist/{types-TeHjsmja.d.ts → types-1cCFEzWt.d.ts} +3 -10
- package/dist/{types-BRx1QsIJ.d.cts → types-D5NhXTJY.d.cts} +3 -10
- package/dist/vite/index.cjs +386 -224
- package/dist/vite/index.d.cts +23 -10
- package/dist/vite/index.d.ts +23 -10
- package/dist/vite/index.js +211 -37
- package/dist/{watcher-HGOH3APP.js → watcher-WXJDWRZY.js} +1 -1
- package/package.json +28 -15
- package/dist/browser-BupUnhpC.d.ts +0 -98
- package/dist/browser-R0x9IPaQ.d.cts +0 -98
- package/dist/chunk-ADR6R7HM.js +0 -29
- package/dist/chunk-XMFLD5J6.js +0 -30
- package/dist/chunk-ZLCSVXCD.js +0 -10
- package/dist/chunk-ZX7TM4AR.js +0 -127
- package/dist/postinstall-SCSXM4IM.js +0 -10
- package/dist/shared-CfiiRctw.d.ts +0 -70
- package/dist/shared-fFqiuWJC.d.cts +0 -70
package/dist/vite/index.d.cts
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import { Plugin } from 'vite';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
interface IndexFileOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Runtime compat fallbacks for Vite specific APIs
|
|
6
|
+
*
|
|
7
|
+
* - `bun`: use Bun-specific APIs.
|
|
8
|
+
* - `node`: use Node.js APIs.
|
|
9
|
+
* - `false` (default): no fallback.
|
|
10
|
+
*/
|
|
11
|
+
runtime?: 'bun' | 'node' | false;
|
|
12
|
+
/**
|
|
13
|
+
* add `.js` extensions to imports, needed for ESM without bundler resolution
|
|
14
|
+
*/
|
|
15
|
+
addJsExtension?: boolean;
|
|
16
|
+
}
|
|
4
17
|
|
|
5
18
|
interface PluginOptions {
|
|
6
19
|
/**
|
|
@@ -8,13 +21,7 @@ interface PluginOptions {
|
|
|
8
21
|
*
|
|
9
22
|
* @defaultValue true
|
|
10
23
|
*/
|
|
11
|
-
generateIndexFile?: boolean |
|
|
12
|
-
out?: string;
|
|
13
|
-
/**
|
|
14
|
-
* add `.js` extensions to imports, needed for ESM without bundler resolution
|
|
15
|
-
*/
|
|
16
|
-
addJsExtension?: boolean;
|
|
17
|
-
};
|
|
24
|
+
generateIndexFile?: boolean | IndexFileOptions;
|
|
18
25
|
/**
|
|
19
26
|
* @defaultValue source.config.ts
|
|
20
27
|
*/
|
|
@@ -25,8 +32,14 @@ interface PluginOptions {
|
|
|
25
32
|
* @defaultValue true
|
|
26
33
|
*/
|
|
27
34
|
updateViteConfig?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Output directory of generated files
|
|
37
|
+
*
|
|
38
|
+
* @defaultValue '.source'
|
|
39
|
+
*/
|
|
40
|
+
outDir?: string;
|
|
28
41
|
}
|
|
29
|
-
|
|
30
|
-
declare function
|
|
42
|
+
declare function mdx(config: Record<string, unknown>, pluginOptions?: PluginOptions): Promise<Plugin>;
|
|
43
|
+
declare function postInstall(configPath?: string, pluginOptions?: PluginOptions): Promise<void>;
|
|
31
44
|
|
|
32
45
|
export { type PluginOptions, mdx as default, postInstall };
|
package/dist/vite/index.d.ts
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import { Plugin } from 'vite';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
interface IndexFileOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Runtime compat fallbacks for Vite specific APIs
|
|
6
|
+
*
|
|
7
|
+
* - `bun`: use Bun-specific APIs.
|
|
8
|
+
* - `node`: use Node.js APIs.
|
|
9
|
+
* - `false` (default): no fallback.
|
|
10
|
+
*/
|
|
11
|
+
runtime?: 'bun' | 'node' | false;
|
|
12
|
+
/**
|
|
13
|
+
* add `.js` extensions to imports, needed for ESM without bundler resolution
|
|
14
|
+
*/
|
|
15
|
+
addJsExtension?: boolean;
|
|
16
|
+
}
|
|
4
17
|
|
|
5
18
|
interface PluginOptions {
|
|
6
19
|
/**
|
|
@@ -8,13 +21,7 @@ interface PluginOptions {
|
|
|
8
21
|
*
|
|
9
22
|
* @defaultValue true
|
|
10
23
|
*/
|
|
11
|
-
generateIndexFile?: boolean |
|
|
12
|
-
out?: string;
|
|
13
|
-
/**
|
|
14
|
-
* add `.js` extensions to imports, needed for ESM without bundler resolution
|
|
15
|
-
*/
|
|
16
|
-
addJsExtension?: boolean;
|
|
17
|
-
};
|
|
24
|
+
generateIndexFile?: boolean | IndexFileOptions;
|
|
18
25
|
/**
|
|
19
26
|
* @defaultValue source.config.ts
|
|
20
27
|
*/
|
|
@@ -25,8 +32,14 @@ interface PluginOptions {
|
|
|
25
32
|
* @defaultValue true
|
|
26
33
|
*/
|
|
27
34
|
updateViteConfig?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Output directory of generated files
|
|
37
|
+
*
|
|
38
|
+
* @defaultValue '.source'
|
|
39
|
+
*/
|
|
40
|
+
outDir?: string;
|
|
28
41
|
}
|
|
29
|
-
|
|
30
|
-
declare function
|
|
42
|
+
declare function mdx(config: Record<string, unknown>, pluginOptions?: PluginOptions): Promise<Plugin>;
|
|
43
|
+
declare function postInstall(configPath?: string, pluginOptions?: PluginOptions): Promise<void>;
|
|
31
44
|
|
|
32
45
|
export { type PluginOptions, mdx as default, postInstall };
|
package/dist/vite/index.js
CHANGED
|
@@ -1,48 +1,195 @@
|
|
|
1
|
-
import {
|
|
2
|
-
entry,
|
|
3
|
-
postInstall
|
|
4
|
-
} from "../chunk-ZX7TM4AR.js";
|
|
5
|
-
import "../chunk-6Y5JDZHD.js";
|
|
6
|
-
import "../chunk-LGYVNESJ.js";
|
|
7
|
-
import {
|
|
8
|
-
buildConfig
|
|
9
|
-
} from "../chunk-U4MQ44TS.js";
|
|
10
1
|
import {
|
|
11
2
|
toVite
|
|
12
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-XV5Z4BFL.js";
|
|
4
|
+
import {
|
|
5
|
+
getGlobPatterns,
|
|
6
|
+
ident,
|
|
7
|
+
toImportPath
|
|
8
|
+
} from "../chunk-6Y5JDZHD.js";
|
|
13
9
|
import {
|
|
14
10
|
createMdxLoader
|
|
15
|
-
} from "../chunk-
|
|
16
|
-
import "../chunk-
|
|
17
|
-
import "../chunk-
|
|
11
|
+
} from "../chunk-CEA6MYJU.js";
|
|
12
|
+
import "../chunk-3J3WL7WN.js";
|
|
13
|
+
import "../chunk-K5ZLPEIQ.js";
|
|
14
|
+
import {
|
|
15
|
+
buildConfig
|
|
16
|
+
} from "../chunk-U4MQ44TS.js";
|
|
18
17
|
import {
|
|
19
18
|
ValidationError,
|
|
19
|
+
findConfigFile,
|
|
20
|
+
resolvedConfig,
|
|
20
21
|
validate
|
|
21
|
-
} from "../chunk-
|
|
22
|
-
import {
|
|
23
|
-
resolvedConfig
|
|
24
|
-
} from "../chunk-XMFLD5J6.js";
|
|
22
|
+
} from "../chunk-HI62EXSB.js";
|
|
25
23
|
import "../chunk-VWJKRQZR.js";
|
|
24
|
+
import {
|
|
25
|
+
createPluginHandler
|
|
26
|
+
} from "../chunk-4MAYA5QX.js";
|
|
26
27
|
|
|
27
28
|
// src/vite/index.ts
|
|
28
29
|
import {
|
|
29
30
|
mergeConfig
|
|
30
31
|
} from "vite";
|
|
31
32
|
import { parse } from "querystring";
|
|
32
|
-
import * as
|
|
33
|
-
import * as path from "path";
|
|
33
|
+
import * as path3 from "path";
|
|
34
34
|
import { load } from "js-yaml";
|
|
35
|
+
|
|
36
|
+
// src/utils/glob-import.ts
|
|
37
|
+
import { globSync } from "tinyglobby";
|
|
38
|
+
import path from "path";
|
|
39
|
+
import { pathToFileURL } from "url";
|
|
40
|
+
function generateGlobImport(patterns, options) {
|
|
41
|
+
let code = "{";
|
|
42
|
+
const result = globSync(patterns, {
|
|
43
|
+
cwd: options.base
|
|
44
|
+
});
|
|
45
|
+
for (const item of result) {
|
|
46
|
+
const fullPath = path.join(options.base, item);
|
|
47
|
+
const url = pathToFileURL(fullPath);
|
|
48
|
+
for (const [k, v] of Object.entries(options.query ?? {})) {
|
|
49
|
+
url.searchParams.set(k, v);
|
|
50
|
+
}
|
|
51
|
+
let line = `${JSON.stringify(item)}: () => import(${JSON.stringify(url.href)})`;
|
|
52
|
+
if (options.import) {
|
|
53
|
+
line += `.then(mod => mod[${JSON.stringify(options.import)}])`;
|
|
54
|
+
}
|
|
55
|
+
code += `${line}, `;
|
|
56
|
+
}
|
|
57
|
+
code += "}";
|
|
58
|
+
return code;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// src/plugins/vite.ts
|
|
62
|
+
import path2 from "path";
|
|
63
|
+
function vite(options) {
|
|
64
|
+
let config;
|
|
65
|
+
return {
|
|
66
|
+
config(v) {
|
|
67
|
+
config = v;
|
|
68
|
+
},
|
|
69
|
+
emit() {
|
|
70
|
+
console.log("[Fumadocs MDX] Generating index files");
|
|
71
|
+
return [
|
|
72
|
+
{
|
|
73
|
+
path: "index.ts",
|
|
74
|
+
content: indexFile(this.configPath, this.outDir, config, options)
|
|
75
|
+
}
|
|
76
|
+
];
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function indexFile(configPath, outDir, config, options) {
|
|
81
|
+
const { addJsExtension = false, runtime } = options;
|
|
82
|
+
const lines = [
|
|
83
|
+
'/// <reference types="vite/client" />',
|
|
84
|
+
`import { fromConfig } from 'fumadocs-mdx/runtime/vite';`,
|
|
85
|
+
`import type * as Config from '${toImportPath(configPath, {
|
|
86
|
+
relativeTo: outDir,
|
|
87
|
+
jsExtension: addJsExtension
|
|
88
|
+
})}';`,
|
|
89
|
+
"",
|
|
90
|
+
`export const create = fromConfig<typeof Config>();`
|
|
91
|
+
];
|
|
92
|
+
function docs(name, collection) {
|
|
93
|
+
const obj = [
|
|
94
|
+
ident(`doc: ${doc(name, collection.docs)}`),
|
|
95
|
+
ident(`meta: ${meta(name, collection.meta)}`)
|
|
96
|
+
].join(",\n");
|
|
97
|
+
return `{
|
|
98
|
+
${obj}
|
|
99
|
+
}`;
|
|
100
|
+
}
|
|
101
|
+
function doc(name, collection) {
|
|
102
|
+
const patterns = getGlobPatterns(collection);
|
|
103
|
+
const base = getGlobBase(collection);
|
|
104
|
+
const docGlob = generateGlob(patterns, {
|
|
105
|
+
query: {
|
|
106
|
+
collection: name
|
|
107
|
+
},
|
|
108
|
+
base
|
|
109
|
+
});
|
|
110
|
+
if (collection.async) {
|
|
111
|
+
const headBlob = generateGlob(patterns, {
|
|
112
|
+
query: {
|
|
113
|
+
only: "frontmatter",
|
|
114
|
+
collection: name
|
|
115
|
+
},
|
|
116
|
+
import: "frontmatter",
|
|
117
|
+
base
|
|
118
|
+
});
|
|
119
|
+
return `create.docLazy("${name}", "${base}", ${headBlob}, ${docGlob})`;
|
|
120
|
+
}
|
|
121
|
+
return `create.doc("${name}", "${base}", ${docGlob})`;
|
|
122
|
+
}
|
|
123
|
+
function meta(name, collection) {
|
|
124
|
+
const patterns = getGlobPatterns(collection);
|
|
125
|
+
const base = getGlobBase(collection);
|
|
126
|
+
return `create.meta("${name}", "${base}", ${generateGlob(patterns, {
|
|
127
|
+
import: "default",
|
|
128
|
+
base,
|
|
129
|
+
query: {
|
|
130
|
+
collection: name
|
|
131
|
+
}
|
|
132
|
+
})})`;
|
|
133
|
+
}
|
|
134
|
+
function generateGlob(patterns, options2) {
|
|
135
|
+
patterns = mapGlobPatterns(patterns);
|
|
136
|
+
if (runtime === "node" || runtime === "bun") {
|
|
137
|
+
return generateGlobImport(patterns, options2);
|
|
138
|
+
} else {
|
|
139
|
+
return `import.meta.glob(${JSON.stringify(patterns)}, ${JSON.stringify(
|
|
140
|
+
{
|
|
141
|
+
...options2,
|
|
142
|
+
base: path2.relative(outDir, options2.base)
|
|
143
|
+
},
|
|
144
|
+
null,
|
|
145
|
+
2
|
|
146
|
+
)})`;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
for (const [name, collection] of config.collections.entries()) {
|
|
150
|
+
let body;
|
|
151
|
+
if (collection.type === "docs") {
|
|
152
|
+
body = docs(name, collection);
|
|
153
|
+
} else if (collection.type === "meta") {
|
|
154
|
+
body = meta(name, collection);
|
|
155
|
+
} else {
|
|
156
|
+
body = doc(name, collection);
|
|
157
|
+
}
|
|
158
|
+
lines.push("");
|
|
159
|
+
lines.push(`export const ${name} = ${body};`);
|
|
160
|
+
}
|
|
161
|
+
return lines.join("\n");
|
|
162
|
+
}
|
|
163
|
+
function mapGlobPatterns(patterns) {
|
|
164
|
+
return patterns.map(enforceRelative);
|
|
165
|
+
}
|
|
166
|
+
function enforceRelative(file) {
|
|
167
|
+
if (file.startsWith("./")) return file;
|
|
168
|
+
if (file.startsWith("/")) return `.${file}`;
|
|
169
|
+
return `./${file}`;
|
|
170
|
+
}
|
|
171
|
+
function getGlobBase(collection) {
|
|
172
|
+
let dir = collection.dir;
|
|
173
|
+
if (Array.isArray(dir)) {
|
|
174
|
+
if (dir.length !== 1)
|
|
175
|
+
throw new Error(
|
|
176
|
+
`[Fumadocs MDX] Vite Plugin doesn't support multiple \`dir\` for a collection at the moment.`
|
|
177
|
+
);
|
|
178
|
+
dir = dir[0];
|
|
179
|
+
}
|
|
180
|
+
return enforceRelative(dir);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// src/vite/index.ts
|
|
35
184
|
var FumadocsDeps = ["fumadocs-core", "fumadocs-ui", "fumadocs-openapi"];
|
|
36
|
-
function mdx(config,
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
} = options;
|
|
42
|
-
const loaded = buildConfig(config);
|
|
185
|
+
async function mdx(config, pluginOptions = {}) {
|
|
186
|
+
const options = applyDefaults(pluginOptions);
|
|
187
|
+
const { updateViteConfig } = options;
|
|
188
|
+
const pluginHandler = createVitePluginHandler(options);
|
|
189
|
+
const loaded = await pluginHandler.init(buildConfig(config));
|
|
43
190
|
const mdxLoader = toVite(createMdxLoader(resolvedConfig(loaded)));
|
|
44
|
-
async function transformMeta(
|
|
45
|
-
const isJson =
|
|
191
|
+
async function transformMeta(path4, query, value) {
|
|
192
|
+
const isJson = path4.endsWith(".json");
|
|
46
193
|
const parsed = parse(query);
|
|
47
194
|
const collection = parsed.collection ? loaded.collections.get(parsed.collection) : void 0;
|
|
48
195
|
if (!collection) return null;
|
|
@@ -65,8 +212,8 @@ function mdx(config, options = {}) {
|
|
|
65
212
|
const out = await validate(
|
|
66
213
|
schema,
|
|
67
214
|
data,
|
|
68
|
-
{ path:
|
|
69
|
-
`invalid data in ${
|
|
215
|
+
{ path: path4, source: value },
|
|
216
|
+
`invalid data in ${path4}`
|
|
70
217
|
);
|
|
71
218
|
return {
|
|
72
219
|
code: isJson ? JSON.stringify(out) : `export default ${JSON.stringify(out)}`,
|
|
@@ -90,16 +237,11 @@ function mdx(config, options = {}) {
|
|
|
90
237
|
});
|
|
91
238
|
},
|
|
92
239
|
async buildStart() {
|
|
93
|
-
|
|
94
|
-
const { out = "source.generated.ts", addJsExtension } = typeof generateIndexFile === "object" ? generateIndexFile : {};
|
|
95
|
-
console.log("[Fumadocs MDX] Generating index files");
|
|
96
|
-
const dir = path.dirname(out);
|
|
97
|
-
await fs.mkdir(dir, { recursive: true });
|
|
98
|
-
await fs.writeFile(out, entry(configPath, loaded, dir, addJsExtension));
|
|
240
|
+
await pluginHandler.emitAndWrite();
|
|
99
241
|
},
|
|
100
242
|
async transform(value, id) {
|
|
101
243
|
const [file, query = ""] = id.split("?");
|
|
102
|
-
const ext =
|
|
244
|
+
const ext = path3.extname(file);
|
|
103
245
|
try {
|
|
104
246
|
if ([".yaml", ".json"].includes(ext))
|
|
105
247
|
return await transformMeta(file, query, value);
|
|
@@ -114,6 +256,38 @@ function mdx(config, options = {}) {
|
|
|
114
256
|
}
|
|
115
257
|
};
|
|
116
258
|
}
|
|
259
|
+
async function postInstall(configPath = findConfigFile(), pluginOptions = {}) {
|
|
260
|
+
const { loadConfig } = await import("../load-MNG3CLET.js");
|
|
261
|
+
const options = applyDefaults(pluginOptions);
|
|
262
|
+
const pluginHandler = createVitePluginHandler(options);
|
|
263
|
+
await pluginHandler.init(await loadConfig(configPath, options.outDir, true));
|
|
264
|
+
await pluginHandler.emitAndWrite();
|
|
265
|
+
console.log("[MDX] types generated");
|
|
266
|
+
}
|
|
267
|
+
function createVitePluginHandler({
|
|
268
|
+
configPath,
|
|
269
|
+
outDir,
|
|
270
|
+
generateIndexFile
|
|
271
|
+
}) {
|
|
272
|
+
return createPluginHandler(
|
|
273
|
+
{
|
|
274
|
+
environment: "vite",
|
|
275
|
+
configPath,
|
|
276
|
+
outDir
|
|
277
|
+
},
|
|
278
|
+
[
|
|
279
|
+
generateIndexFile !== false && vite(typeof generateIndexFile === "object" ? generateIndexFile : {})
|
|
280
|
+
]
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
function applyDefaults(options) {
|
|
284
|
+
return {
|
|
285
|
+
updateViteConfig: options.updateViteConfig ?? true,
|
|
286
|
+
generateIndexFile: options.generateIndexFile ?? true,
|
|
287
|
+
configPath: options.configPath ?? "source.config.ts",
|
|
288
|
+
outDir: options.outDir ?? ".source"
|
|
289
|
+
};
|
|
290
|
+
}
|
|
117
291
|
export {
|
|
118
292
|
mdx as default,
|
|
119
293
|
postInstall
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-mdx",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.0.0",
|
|
4
4
|
"description": "The built-in source for Fumadocs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
@@ -45,6 +45,14 @@
|
|
|
45
45
|
"import": "./dist/runtime/vite/server.js",
|
|
46
46
|
"types": "./dist/runtime/vite/server.d.ts"
|
|
47
47
|
},
|
|
48
|
+
"./runtime/vite.server": {
|
|
49
|
+
"import": "./dist/runtime/vite/server.js",
|
|
50
|
+
"types": "./dist/runtime/vite/server.d.ts"
|
|
51
|
+
},
|
|
52
|
+
"./runtime/vite.browser": {
|
|
53
|
+
"import": "./dist/runtime/vite/browser.js",
|
|
54
|
+
"types": "./dist/runtime/vite/browser.d.ts"
|
|
55
|
+
},
|
|
48
56
|
"./node/loader": {
|
|
49
57
|
"import": "./dist/node/loader.js",
|
|
50
58
|
"types": "./dist/node/loader.d.ts"
|
|
@@ -52,6 +60,10 @@
|
|
|
52
60
|
"./bun": {
|
|
53
61
|
"import": "./dist/bun/index.js",
|
|
54
62
|
"types": "./dist/bun/index.d.ts"
|
|
63
|
+
},
|
|
64
|
+
"./plugins/*": {
|
|
65
|
+
"import": "./dist/plugins/*.js",
|
|
66
|
+
"types": "./dist/plugins/*.d.ts"
|
|
55
67
|
}
|
|
56
68
|
},
|
|
57
69
|
"main": "./dist/index.js",
|
|
@@ -65,8 +77,8 @@
|
|
|
65
77
|
"@mdx-js/mdx": "^3.1.1",
|
|
66
78
|
"@standard-schema/spec": "^1.0.0",
|
|
67
79
|
"chokidar": "^4.0.3",
|
|
68
|
-
"esbuild": "^0.25.
|
|
69
|
-
"estree-util-value-to-estree": "^3.4.
|
|
80
|
+
"esbuild": "^0.25.11",
|
|
81
|
+
"estree-util-value-to-estree": "^3.4.1",
|
|
70
82
|
"js-yaml": "^4.1.0",
|
|
71
83
|
"lru-cache": "^11.2.2",
|
|
72
84
|
"mdast-util-to-markdown": "^2.1.2",
|
|
@@ -76,36 +88,37 @@
|
|
|
76
88
|
"tinyexec": "^1.0.1",
|
|
77
89
|
"tinyglobby": "^0.2.15",
|
|
78
90
|
"unified": "^11.0.5",
|
|
91
|
+
"unist-util-remove-position": "^5.0.0",
|
|
79
92
|
"unist-util-visit": "^5.0.0",
|
|
80
|
-
"zod": "^4.1.
|
|
93
|
+
"zod": "^4.1.12"
|
|
81
94
|
},
|
|
82
95
|
"devDependencies": {
|
|
83
|
-
"@types/bun": "^1.
|
|
96
|
+
"@types/bun": "^1.3.0",
|
|
84
97
|
"@types/js-yaml": "^4.0.9",
|
|
85
98
|
"@types/mdast": "^4.0.4",
|
|
86
99
|
"@types/mdx": "^2.0.13",
|
|
87
|
-
"@types/node": "^24.
|
|
88
|
-
"@types/react": "^19.2.
|
|
100
|
+
"@types/node": "^24.9.1",
|
|
101
|
+
"@types/react": "^19.2.2",
|
|
89
102
|
"mdast-util-directive": "^3.1.0",
|
|
90
103
|
"mdast-util-mdx-jsx": "^3.2.0",
|
|
91
|
-
"next": "
|
|
104
|
+
"next": "16.0.0",
|
|
92
105
|
"react": "^19.2.0",
|
|
93
106
|
"remark": "^15.0.1",
|
|
94
107
|
"remark-directive": "^4.0.0",
|
|
95
108
|
"remark-stringify": "^11.0.0",
|
|
96
|
-
"rollup": "^4.52.
|
|
109
|
+
"rollup": "^4.52.5",
|
|
97
110
|
"vfile": "^6.0.3",
|
|
98
|
-
"vite": "^7.1.
|
|
99
|
-
"webpack": "^5.102.
|
|
100
|
-
"@fumadocs/mdx-remote": "1.4.
|
|
111
|
+
"vite": "^7.1.11",
|
|
112
|
+
"webpack": "^5.102.1",
|
|
113
|
+
"@fumadocs/mdx-remote": "1.4.3",
|
|
101
114
|
"eslint-config-custom": "0.0.0",
|
|
102
|
-
"fumadocs-core": "
|
|
115
|
+
"fumadocs-core": "16.0.0",
|
|
103
116
|
"tsconfig": "0.0.0"
|
|
104
117
|
},
|
|
105
118
|
"peerDependencies": {
|
|
106
119
|
"@fumadocs/mdx-remote": "^1.4.0",
|
|
107
|
-
"fumadocs-core": "^
|
|
108
|
-
"next": "^15.3.0",
|
|
120
|
+
"fumadocs-core": "^15.0.0 || ^16.0.0",
|
|
121
|
+
"next": "^15.3.0 || ^16.0.0",
|
|
109
122
|
"react": "*",
|
|
110
123
|
"vite": "6.x.x || 7.x.x"
|
|
111
124
|
},
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { createProcessor } from '@mdx-js/mdx';
|
|
2
|
-
import { StructuredData } from 'fumadocs-core/mdx-plugins';
|
|
3
|
-
import { TableOfContents } from 'fumadocs-core/server';
|
|
4
|
-
import { FC, ReactNode } from 'react';
|
|
5
|
-
import { MDXProps } from 'mdx/types';
|
|
6
|
-
import { E as ExtractedReference, a as DocCollection, b as DocsCollection, M as MetaCollection } from './define-DJbJduHy.js';
|
|
7
|
-
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
8
|
-
|
|
9
|
-
type Processor = ReturnType<typeof createProcessor>;
|
|
10
|
-
interface CompilerOptions {
|
|
11
|
-
addDependency: (file: string) => void;
|
|
12
|
-
}
|
|
13
|
-
interface CompiledMDXProperties<Frontmatter = Record<string, unknown>> {
|
|
14
|
-
frontmatter: Frontmatter;
|
|
15
|
-
structuredData: StructuredData;
|
|
16
|
-
toc: TableOfContents;
|
|
17
|
-
default: FC<MDXProps>;
|
|
18
|
-
/**
|
|
19
|
-
* Only available when `lastModifiedTime` is enabled on MDX loader
|
|
20
|
-
*/
|
|
21
|
-
lastModified?: Date;
|
|
22
|
-
extractedReferences?: ExtractedReference[];
|
|
23
|
-
_markdown?: string;
|
|
24
|
-
}
|
|
25
|
-
interface FumadocsDataMap {
|
|
26
|
-
/**
|
|
27
|
-
* [Fumadocs MDX] raw frontmatter, you can modify it
|
|
28
|
-
*/
|
|
29
|
-
frontmatter?: Record<string, unknown>;
|
|
30
|
-
/**
|
|
31
|
-
* [Fumadocs MDX] additional ESM exports to write
|
|
32
|
-
*/
|
|
33
|
-
'mdx-export'?: {
|
|
34
|
-
name: string;
|
|
35
|
-
value: unknown;
|
|
36
|
-
}[];
|
|
37
|
-
extractedReferences: ExtractedReference[];
|
|
38
|
-
/**
|
|
39
|
-
* [Fumadocs MDX] The compiler object from loader
|
|
40
|
-
*/
|
|
41
|
-
_compiler?: CompilerOptions;
|
|
42
|
-
_getProcessor?: (format: 'md' | 'mdx') => Processor;
|
|
43
|
-
/**
|
|
44
|
-
* [Fumadocs MDX] Processed Markdown content before `remark-rehype`.
|
|
45
|
-
*/
|
|
46
|
-
_markdown?: string;
|
|
47
|
-
}
|
|
48
|
-
declare module 'vfile' {
|
|
49
|
-
interface DataMap extends FumadocsDataMap {
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
type CompiledMDXFile<Frontmatter> = CompiledMDXProperties<Frontmatter> & Record<string, unknown>;
|
|
54
|
-
type DocMap<Frontmatter> = Record<string, (() => Promise<CompiledMDXFile<Frontmatter>>) & {
|
|
55
|
-
base: string;
|
|
56
|
-
}>;
|
|
57
|
-
type MetaMap<Data> = Record<string, (() => Promise<Data>) & {
|
|
58
|
-
base: string;
|
|
59
|
-
}>;
|
|
60
|
-
interface LazyDocMap<Frontmatter> {
|
|
61
|
-
base: string;
|
|
62
|
-
head: Record<string, () => Promise<Frontmatter>>;
|
|
63
|
-
body: Record<string, () => Promise<CompiledMDXFile<Frontmatter>>>;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
interface BaseCreate<Config> {
|
|
67
|
-
doc: <Name extends keyof Config>(name: Name, base: string, glob: Record<string, () => Promise<unknown>>) => Config[Name] extends DocCollection<infer Schema> | DocsCollection<infer Schema> ? DocMap<StandardSchemaV1.InferOutput<Schema>> : never;
|
|
68
|
-
docLazy: <Name extends keyof Config>(name: Name, base: string, headGlob: Record<string, () => Promise<unknown>>, bodyGlob: Record<string, () => Promise<unknown>>) => Config[Name] extends DocCollection<infer Schema> | DocsCollection<infer Schema> ? LazyDocMap<StandardSchemaV1.InferOutput<Schema>> : never;
|
|
69
|
-
meta: <Name extends keyof Config>(name: Name, base: string, glob: Record<string, () => Promise<unknown>>) => Config[Name] extends MetaCollection<infer Schema> | DocsCollection<StandardSchemaV1, infer Schema> ? MetaMap<StandardSchemaV1.InferOutput<Schema>> : never;
|
|
70
|
-
}
|
|
71
|
-
declare function fromConfigBase<Config>(): BaseCreate<Config>;
|
|
72
|
-
|
|
73
|
-
interface ClientLoaderOptions<Frontmatter, Props> {
|
|
74
|
-
/**
|
|
75
|
-
* Loader ID (usually your collection name)
|
|
76
|
-
*
|
|
77
|
-
* The code splitting strategy of frameworks like Tanstack Start may duplicate `createClientLoader()` into different chunks.
|
|
78
|
-
*
|
|
79
|
-
* We use loader ID to share cache between multiple instances of client loader.
|
|
80
|
-
*
|
|
81
|
-
* @defaultValue ''
|
|
82
|
-
*/
|
|
83
|
-
id?: string;
|
|
84
|
-
component: (loaded: CompiledMDXFile<Frontmatter>, props: Props) => ReactNode;
|
|
85
|
-
}
|
|
86
|
-
type ClientRenderer<Props> = Record<string, FC<Props>>;
|
|
87
|
-
interface ClientLoader<Frontmatter, Props> {
|
|
88
|
-
preload: (path: string) => Promise<CompiledMDXFile<Frontmatter>>;
|
|
89
|
-
/**
|
|
90
|
-
* Get a component that renders content with `React.lazy`
|
|
91
|
-
*/
|
|
92
|
-
getComponent: (path: string) => FC<Props>;
|
|
93
|
-
getRenderer: () => ClientRenderer<Props>;
|
|
94
|
-
}
|
|
95
|
-
declare function createClientLoader<Frontmatter, Props = object>(files: Record<string, () => Promise<CompiledMDXFile<Frontmatter>>>, options: ClientLoaderOptions<Frontmatter, Props>): ClientLoader<Frontmatter, Props>;
|
|
96
|
-
declare function toClientRenderer<Frontmatter, Props = object>(files: Record<string, () => Promise<CompiledMDXFile<Frontmatter>>>, component: (loaded: CompiledMDXFile<Frontmatter>, props: Props) => ReactNode): ClientRenderer<Props>;
|
|
97
|
-
|
|
98
|
-
export { type BaseCreate as B, type ClientLoader as C, type DocMap as D, type LazyDocMap as L, type MetaMap as M, type ClientLoaderOptions as a, type CompiledMDXFile as b, createClientLoader as c, fromConfigBase as f, toClientRenderer as t };
|