fumadocs-mdx 11.10.0 → 12.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 +953 -0
- package/dist/bin.d.cts +1 -0
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +16 -0
- package/dist/{browser-B2G8uAF2.d.cts → browser-D5lvL8vv.d.ts} +51 -4
- package/dist/{browser-DrH7tKRi.d.ts → browser-DjWADqp8.d.cts} +51 -4
- package/dist/bun/index.cjs +129 -109
- package/dist/bun/index.js +9 -6
- package/dist/chunk-3M4SHY6K.js +80 -0
- package/dist/chunk-6Y5JDZHD.js +65 -0
- package/dist/{chunk-NUDEC6C5.js → chunk-AUOOMFAI.js} +28 -22
- package/dist/chunk-IQAEAI4P.js +66 -0
- package/dist/{chunk-5XJM5RPV.js → chunk-KGUBBRL6.js} +13 -13
- package/dist/{chunk-SVTXMVLQ.js → chunk-KTDVTBMH.js} +1 -1
- package/dist/chunk-POXTQZ4D.js +60 -0
- package/dist/chunk-SWNOXPYJ.js +142 -0
- package/dist/{chunk-COQ4VMK2.js → chunk-TLD6JMT6.js} +28 -61
- package/dist/{chunk-NVX3U5YE.js → chunk-VXEBLM4X.js} +2 -2
- package/dist/{chunk-QVZ7JH4H.js → chunk-YC25YEBF.js} +1 -1
- package/dist/chunk-ZLCSVXCD.js +10 -0
- package/dist/config/index.cjs +18 -97
- package/dist/config/index.d.cts +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.js +48 -9
- package/dist/{define-BH4bnHQl.d.cts → define--6HQ1ehX.d.cts} +18 -3
- package/dist/{define-BH4bnHQl.d.ts → define--6HQ1ehX.d.ts} +18 -3
- package/dist/loader-mdx.cjs +127 -139
- package/dist/loader-mdx.js +7 -6
- package/dist/next/index.cjs +44 -269
- package/dist/next/index.js +30 -46
- package/dist/node/loader.cjs +131 -143
- package/dist/node/loader.js +7 -6
- package/dist/postinstall-U7VROOY7.js +9 -0
- package/dist/{mdx-options-T73E4LQB.js → preset-WFEORCAB.js} +1 -1
- package/dist/runtime/{async.cjs → next/async.cjs} +202 -154
- package/dist/runtime/{async.d.cts → next/async.d.cts} +3 -3
- package/dist/runtime/{async.d.ts → next/async.d.ts} +3 -3
- package/dist/runtime/next/async.js +92 -0
- package/dist/{index.cjs → runtime/next/index.cjs} +35 -26
- package/dist/runtime/next/index.d.cts +30 -0
- package/dist/runtime/next/index.d.ts +30 -0
- package/dist/{index.js → runtime/next/index.js} +2 -1
- package/dist/runtime/vite/browser.d.cts +2 -3
- package/dist/runtime/vite/browser.d.ts +2 -3
- package/dist/runtime/vite/server.cjs +67 -21
- package/dist/runtime/vite/server.d.cts +14 -28
- package/dist/runtime/vite/server.d.ts +14 -28
- package/dist/runtime/vite/server.js +61 -21
- package/dist/shared-0QIuV0XZ.d.ts +70 -0
- package/dist/shared-CqgMnt9h.d.cts +70 -0
- package/dist/{types-DN9KrG7R.d.ts → types-DLIAvrgC.d.ts} +6 -32
- package/dist/{types-DT83Ijs6.d.cts → types-Dl8HLbm5.d.cts} +6 -32
- package/dist/vite/index.cjs +201 -123
- package/dist/vite/index.d.cts +4 -1
- package/dist/vite/index.d.ts +4 -1
- package/dist/vite/index.js +13 -9
- package/package.json +11 -17
- package/bin.js +0 -5
- package/dist/build-mdx-DnC1jKvn.d.cts +0 -46
- package/dist/build-mdx-DnC1jKvn.d.ts +0 -46
- package/dist/chunk-2HKRTQYP.js +0 -154
- package/dist/chunk-GBMFGEC7.js +0 -57
- package/dist/chunk-QQWCBFFE.js +0 -40
- package/dist/chunk-SMSNZ6N5.js +0 -155
- package/dist/config/zod-3.cjs +0 -422
- package/dist/config/zod-3.d.cts +0 -53
- package/dist/config/zod-3.d.ts +0 -53
- package/dist/config/zod-3.js +0 -40
- package/dist/index.d.cts +0 -26
- package/dist/index.d.ts +0 -26
- package/dist/runtime/async.js +0 -72
package/dist/loader-mdx.cjs
CHANGED
|
@@ -30,86 +30,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
30
|
));
|
|
31
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
32
|
|
|
33
|
-
// src/mdx
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}) {
|
|
37
|
-
return (tree, file) => {
|
|
38
|
-
let title;
|
|
39
|
-
const urls = [];
|
|
40
|
-
(0, import_unist_util_visit2.visit)(tree, ["heading", "link"], (node) => {
|
|
41
|
-
if (node.type === "heading" && node.depth === 1) {
|
|
42
|
-
title = flattenNode2(node);
|
|
43
|
-
}
|
|
44
|
-
if (node.type !== "link") return;
|
|
45
|
-
urls.push({
|
|
46
|
-
href: node.url
|
|
47
|
-
});
|
|
48
|
-
return "skip";
|
|
49
|
-
});
|
|
50
|
-
if (title) {
|
|
51
|
-
file.data.frontmatter ??= {};
|
|
52
|
-
if (!file.data.frontmatter.title) file.data.frontmatter.title = title;
|
|
53
|
-
}
|
|
54
|
-
file.data.extractedReferences = urls;
|
|
55
|
-
for (const name of injectExports) {
|
|
56
|
-
if (!(name in file.data)) continue;
|
|
57
|
-
tree.children.unshift(getMdastExport(name, file.data[name]));
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
function flattenNode2(node) {
|
|
62
|
-
if ("children" in node)
|
|
63
|
-
return node.children.map((child) => flattenNode2(child)).join("");
|
|
64
|
-
if ("value" in node) return node.value;
|
|
65
|
-
return "";
|
|
66
|
-
}
|
|
67
|
-
function getMdastExport(name, value) {
|
|
68
|
-
return {
|
|
69
|
-
type: "mdxjsEsm",
|
|
70
|
-
value: "",
|
|
71
|
-
data: {
|
|
72
|
-
estree: {
|
|
73
|
-
type: "Program",
|
|
74
|
-
sourceType: "module",
|
|
75
|
-
body: [
|
|
76
|
-
{
|
|
77
|
-
type: "ExportNamedDeclaration",
|
|
78
|
-
attributes: [],
|
|
79
|
-
specifiers: [],
|
|
80
|
-
source: null,
|
|
81
|
-
declaration: {
|
|
82
|
-
type: "VariableDeclaration",
|
|
83
|
-
kind: "let",
|
|
84
|
-
declarations: [
|
|
85
|
-
{
|
|
86
|
-
type: "VariableDeclarator",
|
|
87
|
-
id: {
|
|
88
|
-
type: "Identifier",
|
|
89
|
-
name
|
|
90
|
-
},
|
|
91
|
-
init: (0, import_estree_util_value_to_estree.valueToEstree)(value)
|
|
92
|
-
}
|
|
93
|
-
]
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
]
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
var import_unist_util_visit2, import_estree_util_value_to_estree;
|
|
102
|
-
var init_remark_postprocess = __esm({
|
|
103
|
-
"src/mdx-plugins/remark-postprocess.ts"() {
|
|
104
|
-
"use strict";
|
|
105
|
-
import_unist_util_visit2 = require("unist-util-visit");
|
|
106
|
-
import_estree_util_value_to_estree = require("estree-util-value-to-estree");
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
// src/utils/mdx-options.ts
|
|
111
|
-
var mdx_options_exports = {};
|
|
112
|
-
__export(mdx_options_exports, {
|
|
33
|
+
// src/mdx/preset.ts
|
|
34
|
+
var preset_exports = {};
|
|
35
|
+
__export(preset_exports, {
|
|
113
36
|
getDefaultMDXOptions: () => getDefaultMDXOptions
|
|
114
37
|
});
|
|
115
38
|
function pluginOption(def, options = []) {
|
|
@@ -132,13 +55,6 @@ function getDefaultMDXOptions({
|
|
|
132
55
|
_withoutBundler = false,
|
|
133
56
|
...mdxOptions
|
|
134
57
|
}) {
|
|
135
|
-
const mdxExports = [
|
|
136
|
-
"structuredData",
|
|
137
|
-
"extractedReferences",
|
|
138
|
-
"frontmatter",
|
|
139
|
-
"lastModified",
|
|
140
|
-
...valueToExport
|
|
141
|
-
];
|
|
142
58
|
const remarkPlugins = pluginOption(
|
|
143
59
|
(v) => [
|
|
144
60
|
plugins.remarkGfm,
|
|
@@ -166,10 +82,15 @@ function getDefaultMDXOptions({
|
|
|
166
82
|
plugins.remarkStructure,
|
|
167
83
|
remarkStructureOptions
|
|
168
84
|
],
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
85
|
+
() => {
|
|
86
|
+
return (_, file) => {
|
|
87
|
+
file.data["mdx-export"] ??= [];
|
|
88
|
+
for (const name of valueToExport) {
|
|
89
|
+
if (name in file.data)
|
|
90
|
+
file.data["mdx-export"].push({ name, value: file.data[name] });
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
173
94
|
],
|
|
174
95
|
mdxOptions.remarkPlugins
|
|
175
96
|
);
|
|
@@ -189,11 +110,10 @@ function getDefaultMDXOptions({
|
|
|
189
110
|
};
|
|
190
111
|
}
|
|
191
112
|
var plugins;
|
|
192
|
-
var
|
|
193
|
-
"src/
|
|
113
|
+
var init_preset = __esm({
|
|
114
|
+
"src/mdx/preset.ts"() {
|
|
194
115
|
"use strict";
|
|
195
116
|
plugins = __toESM(require("fumadocs-core/mdx-plugins"), 1);
|
|
196
|
-
init_remark_postprocess();
|
|
197
117
|
}
|
|
198
118
|
});
|
|
199
119
|
|
|
@@ -290,10 +210,10 @@ function countLines(s) {
|
|
|
290
210
|
return num;
|
|
291
211
|
}
|
|
292
212
|
|
|
293
|
-
// src/
|
|
213
|
+
// src/mdx/build-mdx.ts
|
|
294
214
|
var import_mdx = require("@mdx-js/mdx");
|
|
295
215
|
|
|
296
|
-
// src/mdx
|
|
216
|
+
// src/mdx/remark-include.ts
|
|
297
217
|
var import_unified = require("unified");
|
|
298
218
|
var import_unist_util_visit = require("unist-util-visit");
|
|
299
219
|
var path2 = __toESM(require("path"), 1);
|
|
@@ -425,7 +345,90 @@ function getDefaultProcessor(format) {
|
|
|
425
345
|
return mdProcessor.use(import_remark_mdx.default);
|
|
426
346
|
}
|
|
427
347
|
|
|
428
|
-
// src/
|
|
348
|
+
// src/mdx/remark-postprocess.ts
|
|
349
|
+
var import_unist_util_visit2 = require("unist-util-visit");
|
|
350
|
+
var import_mdast_util_to_markdown = require("mdast-util-to-markdown");
|
|
351
|
+
var import_estree_util_value_to_estree = require("estree-util-value-to-estree");
|
|
352
|
+
function remarkPostprocess({
|
|
353
|
+
includeProcessedMarkdown = false,
|
|
354
|
+
valueToExport = []
|
|
355
|
+
} = {}) {
|
|
356
|
+
return (tree, file) => {
|
|
357
|
+
let title;
|
|
358
|
+
const urls = [];
|
|
359
|
+
(0, import_unist_util_visit2.visit)(tree, ["heading", "link"], (node) => {
|
|
360
|
+
if (node.type === "heading" && node.depth === 1) {
|
|
361
|
+
title = flattenNode2(node);
|
|
362
|
+
}
|
|
363
|
+
if (node.type !== "link") return;
|
|
364
|
+
urls.push({
|
|
365
|
+
href: node.url
|
|
366
|
+
});
|
|
367
|
+
return "skip";
|
|
368
|
+
});
|
|
369
|
+
if (title) {
|
|
370
|
+
file.data.frontmatter ??= {};
|
|
371
|
+
if (!file.data.frontmatter.title) file.data.frontmatter.title = title;
|
|
372
|
+
}
|
|
373
|
+
file.data.extractedReferences = urls;
|
|
374
|
+
if (includeProcessedMarkdown) {
|
|
375
|
+
file.data._markdown = (0, import_mdast_util_to_markdown.toMarkdown)(tree, {
|
|
376
|
+
...this.data("settings"),
|
|
377
|
+
// @ts-expect-error - from https://github.com/remarkjs/remark/blob/main/packages/remark-stringify/lib/index.js
|
|
378
|
+
extensions: this.data("toMarkdownExtensions") || []
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
for (const { name, value } of file.data["mdx-export"] ?? []) {
|
|
382
|
+
tree.children.unshift(getMdastExport(name, value));
|
|
383
|
+
}
|
|
384
|
+
for (const name of valueToExport) {
|
|
385
|
+
if (!(name in file.data)) continue;
|
|
386
|
+
tree.children.unshift(getMdastExport(name, file.data[name]));
|
|
387
|
+
}
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
function getMdastExport(name, value) {
|
|
391
|
+
return {
|
|
392
|
+
type: "mdxjsEsm",
|
|
393
|
+
value: "",
|
|
394
|
+
data: {
|
|
395
|
+
estree: {
|
|
396
|
+
type: "Program",
|
|
397
|
+
sourceType: "module",
|
|
398
|
+
body: [
|
|
399
|
+
{
|
|
400
|
+
type: "ExportNamedDeclaration",
|
|
401
|
+
attributes: [],
|
|
402
|
+
specifiers: [],
|
|
403
|
+
source: null,
|
|
404
|
+
declaration: {
|
|
405
|
+
type: "VariableDeclaration",
|
|
406
|
+
kind: "let",
|
|
407
|
+
declarations: [
|
|
408
|
+
{
|
|
409
|
+
type: "VariableDeclarator",
|
|
410
|
+
id: {
|
|
411
|
+
type: "Identifier",
|
|
412
|
+
name
|
|
413
|
+
},
|
|
414
|
+
init: (0, import_estree_util_value_to_estree.valueToEstree)(value)
|
|
415
|
+
}
|
|
416
|
+
]
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
]
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
function flattenNode2(node) {
|
|
425
|
+
if ("children" in node)
|
|
426
|
+
return node.children.map((child) => flattenNode2(child)).join("");
|
|
427
|
+
if ("value" in node) return node.value;
|
|
428
|
+
return "";
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// src/mdx/build-mdx.ts
|
|
429
432
|
var cache2 = /* @__PURE__ */ new Map();
|
|
430
433
|
async function buildMDX(cacheKey, source, options) {
|
|
431
434
|
const { filePath, frontmatter, data, _compiler, ...rest } = options;
|
|
@@ -436,7 +439,24 @@ async function buildMDX(cacheKey, source, options) {
|
|
|
436
439
|
processor = (0, import_mdx.createProcessor)({
|
|
437
440
|
outputFormat: "program",
|
|
438
441
|
...rest,
|
|
439
|
-
remarkPlugins: [
|
|
442
|
+
remarkPlugins: [
|
|
443
|
+
remarkInclude,
|
|
444
|
+
...rest.remarkPlugins ?? [],
|
|
445
|
+
[
|
|
446
|
+
remarkPostprocess,
|
|
447
|
+
{
|
|
448
|
+
...options.postprocess,
|
|
449
|
+
valueToExport: [
|
|
450
|
+
...options.postprocess?.valueToExport ?? [],
|
|
451
|
+
"structuredData",
|
|
452
|
+
"extractedReferences",
|
|
453
|
+
"frontmatter",
|
|
454
|
+
"lastModified",
|
|
455
|
+
"_markdown"
|
|
456
|
+
]
|
|
457
|
+
}
|
|
458
|
+
]
|
|
459
|
+
],
|
|
440
460
|
format
|
|
441
461
|
});
|
|
442
462
|
cache2.set(key, processor);
|
|
@@ -492,21 +512,18 @@ function createMdxLoader(configLoader) {
|
|
|
492
512
|
if (cached && cached.hash === generateCacheHash(value)) return cached;
|
|
493
513
|
}
|
|
494
514
|
const collection = parsed.collection ? loaded.collections.get(parsed.collection) : void 0;
|
|
495
|
-
let
|
|
496
|
-
let mdxOptions;
|
|
515
|
+
let docCollection;
|
|
497
516
|
switch (collection?.type) {
|
|
498
517
|
case "doc":
|
|
499
|
-
|
|
500
|
-
schema = collection.schema;
|
|
518
|
+
docCollection = collection;
|
|
501
519
|
break;
|
|
502
520
|
case "docs":
|
|
503
|
-
|
|
504
|
-
schema = collection.docs.schema;
|
|
521
|
+
docCollection = collection.docs;
|
|
505
522
|
break;
|
|
506
523
|
}
|
|
507
|
-
if (schema) {
|
|
524
|
+
if (docCollection?.schema) {
|
|
508
525
|
matter.data = await validate(
|
|
509
|
-
schema,
|
|
526
|
+
docCollection.schema,
|
|
510
527
|
matter.data,
|
|
511
528
|
{
|
|
512
529
|
source: value,
|
|
@@ -531,7 +548,8 @@ function createMdxLoader(configLoader) {
|
|
|
531
548
|
"\n".repeat(lineOffset) + matter.content,
|
|
532
549
|
{
|
|
533
550
|
development: isDevelopment,
|
|
534
|
-
...mdxOptions ?? await loaded.getDefaultMDXOptions(),
|
|
551
|
+
...docCollection?.mdxOptions ?? await loaded.getDefaultMDXOptions(),
|
|
552
|
+
postprocess: docCollection?.postprocess,
|
|
535
553
|
data,
|
|
536
554
|
filePath,
|
|
537
555
|
frontmatter: matter.data,
|
|
@@ -600,7 +618,7 @@ function buildConfig(config) {
|
|
|
600
618
|
const input = this.global.mdxOptions;
|
|
601
619
|
async function uncached() {
|
|
602
620
|
const options = typeof input === "function" ? await input() : input;
|
|
603
|
-
const { getDefaultMDXOptions: getDefaultMDXOptions2 } = await Promise.resolve().then(() => (
|
|
621
|
+
const { getDefaultMDXOptions: getDefaultMDXOptions2 } = await Promise.resolve().then(() => (init_preset(), preset_exports));
|
|
604
622
|
if (options?.preset === "minimal") return options;
|
|
605
623
|
return getDefaultMDXOptions2({
|
|
606
624
|
...options,
|
|
@@ -616,35 +634,6 @@ function buildConfig(config) {
|
|
|
616
634
|
|
|
617
635
|
// src/utils/config.ts
|
|
618
636
|
var cache3 = null;
|
|
619
|
-
async function isZod3() {
|
|
620
|
-
try {
|
|
621
|
-
const content = JSON.parse(
|
|
622
|
-
(await fs3.readFile("node_modules/zod/package.json")).toString()
|
|
623
|
-
);
|
|
624
|
-
const version = content.version;
|
|
625
|
-
return typeof version === "string" && version.startsWith("3.");
|
|
626
|
-
} catch {
|
|
627
|
-
return false;
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
function createCompatZodPlugin() {
|
|
631
|
-
return {
|
|
632
|
-
name: "replace-zod-import",
|
|
633
|
-
async setup(build) {
|
|
634
|
-
const usingZod3 = await isZod3();
|
|
635
|
-
if (!usingZod3) return;
|
|
636
|
-
console.warn(
|
|
637
|
-
"[Fumadocs MDX] Noticed Zod v3 in your node_modules, we recommend upgrading to Zod v4 for better compatibility."
|
|
638
|
-
);
|
|
639
|
-
build.onResolve({ filter: /^fumadocs-mdx\/config$/ }, () => {
|
|
640
|
-
return {
|
|
641
|
-
path: "fumadocs-mdx/config/zod-3",
|
|
642
|
-
external: true
|
|
643
|
-
};
|
|
644
|
-
});
|
|
645
|
-
}
|
|
646
|
-
};
|
|
647
|
-
}
|
|
648
637
|
async function compileConfig(configPath, outDir) {
|
|
649
638
|
const { build } = await import("esbuild");
|
|
650
639
|
const transformed = await build({
|
|
@@ -656,7 +645,6 @@ async function compileConfig(configPath, outDir) {
|
|
|
656
645
|
platform: "node",
|
|
657
646
|
format: "esm",
|
|
658
647
|
packages: "external",
|
|
659
|
-
plugins: [createCompatZodPlugin()],
|
|
660
648
|
outExtension: {
|
|
661
649
|
".js": ".mjs"
|
|
662
650
|
},
|
|
@@ -712,7 +700,7 @@ function toWebpack(loader2) {
|
|
|
712
700
|
try {
|
|
713
701
|
const result = await loader2({
|
|
714
702
|
filePath: this.resourcePath,
|
|
715
|
-
query: (0, import_node_querystring.parse)(this.resourceQuery),
|
|
703
|
+
query: (0, import_node_querystring.parse)(this.resourceQuery.slice(1)),
|
|
716
704
|
source,
|
|
717
705
|
development: this.mode === "development",
|
|
718
706
|
compiler: this
|
package/dist/loader-mdx.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
toWebpack
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-VXEBLM4X.js";
|
|
4
4
|
import {
|
|
5
5
|
createMdxLoader,
|
|
6
6
|
dynamicConfig
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-KGUBBRL6.js";
|
|
8
|
+
import "./chunk-IQAEAI4P.js";
|
|
9
|
+
import "./chunk-POXTQZ4D.js";
|
|
10
|
+
import "./chunk-SWNOXPYJ.js";
|
|
11
|
+
import "./chunk-KTDVTBMH.js";
|
|
12
|
+
import "./chunk-YC25YEBF.js";
|
|
12
13
|
import "./chunk-VWJKRQZR.js";
|
|
13
14
|
|
|
14
15
|
// src/loader-mdx.ts
|