fumadocs-mdx 12.0.0 → 12.0.2
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 +103 -85
- package/dist/bin.js +1 -1
- package/dist/{browser-D5lvL8vv.d.ts → browser-BupUnhpC.d.ts} +1 -1
- package/dist/{browser-DjWADqp8.d.cts → browser-R0x9IPaQ.d.cts} +1 -1
- package/dist/bun/index.cjs +156 -130
- package/dist/bun/index.js +10 -10
- package/dist/chunk-ADR6R7HM.js +29 -0
- package/dist/{chunk-3M4SHY6K.js → chunk-FSZMKRVH.js} +1 -1
- package/dist/{chunk-POXTQZ4D.js → chunk-LGYVNESJ.js} +2 -6
- package/dist/chunk-LMG6UWCL.js +167 -0
- package/dist/{chunk-SWNOXPYJ.js → chunk-QAUWMR5D.js} +6 -6
- package/dist/{chunk-KGUBBRL6.js → chunk-RMDXSZYE.js} +11 -39
- package/dist/{chunk-YC25YEBF.js → chunk-U4MQ44TS.js} +1 -1
- package/dist/chunk-XMFLD5J6.js +30 -0
- package/dist/{chunk-TLD6JMT6.js → chunk-ZX7TM4AR.js} +4 -2
- package/dist/config/index.cjs +84 -56
- package/dist/config/index.d.cts +2 -6
- package/dist/config/index.d.ts +2 -6
- package/dist/config/index.js +2 -2
- package/dist/{define--6HQ1ehX.d.cts → define-DJbJduHy.d.cts} +15 -15
- package/dist/{define--6HQ1ehX.d.ts → define-DJbJduHy.d.ts} +15 -15
- package/dist/index.cjs +127 -0
- package/dist/index.d.cts +13 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +11 -0
- package/dist/load-UUXLUBHL.js +9 -0
- package/dist/loader-mdx.cjs +217 -174
- package/dist/loader-mdx.js +7 -7
- package/dist/next/index.cjs +129 -109
- package/dist/next/index.js +40 -54
- package/dist/node/loader.cjs +152 -109
- package/dist/node/loader.js +6 -7
- package/dist/postinstall-SCSXM4IM.js +10 -0
- package/dist/{preset-WFEORCAB.js → preset-ZMP6U62C.js} +1 -1
- package/dist/runtime/next/async.cjs +117 -65
- package/dist/runtime/next/async.d.cts +3 -3
- package/dist/runtime/next/async.d.ts +3 -3
- package/dist/runtime/next/async.js +15 -8
- package/dist/runtime/next/index.d.cts +8 -8
- package/dist/runtime/next/index.d.ts +8 -8
- package/dist/runtime/vite/browser.d.cts +2 -2
- package/dist/runtime/vite/browser.d.ts +2 -2
- package/dist/runtime/vite/server.d.cts +5 -5
- package/dist/runtime/vite/server.d.ts +5 -5
- package/dist/{shared-CqgMnt9h.d.cts → shared-Cnm1afPW.d.cts} +3 -2
- package/dist/{shared-0QIuV0XZ.d.ts → shared-DpXxElc1.d.ts} +3 -2
- package/dist/{types-DLIAvrgC.d.ts → types-CbLt05Gc.d.cts} +7 -8
- package/dist/{types-Dl8HLbm5.d.cts → types-Ci6BA1tA.d.ts} +7 -8
- package/dist/vite/index.cjs +177 -145
- package/dist/vite/index.d.cts +1 -0
- package/dist/vite/index.d.ts +1 -0
- package/dist/vite/index.js +15 -20
- package/dist/{watcher-4NDMOH4R.js → watcher-HGOH3APP.js} +1 -1
- package/package.json +23 -15
- package/dist/chunk-KTDVTBMH.js +0 -139
- package/dist/postinstall-U7VROOY7.js +0 -9
package/dist/vite/index.cjs
CHANGED
|
@@ -30,7 +30,7 @@ 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/preset.ts
|
|
33
|
+
// src/loaders/mdx/preset.ts
|
|
34
34
|
var preset_exports = {};
|
|
35
35
|
__export(preset_exports, {
|
|
36
36
|
getDefaultMDXOptions: () => getDefaultMDXOptions
|
|
@@ -111,21 +111,12 @@ function getDefaultMDXOptions({
|
|
|
111
111
|
}
|
|
112
112
|
var plugins;
|
|
113
113
|
var init_preset = __esm({
|
|
114
|
-
"src/mdx/preset.ts"() {
|
|
114
|
+
"src/loaders/mdx/preset.ts"() {
|
|
115
115
|
"use strict";
|
|
116
116
|
plugins = __toESM(require("fumadocs-core/mdx-plugins"), 1);
|
|
117
117
|
}
|
|
118
118
|
});
|
|
119
119
|
|
|
120
|
-
// src/vite/index.ts
|
|
121
|
-
var vite_exports = {};
|
|
122
|
-
__export(vite_exports, {
|
|
123
|
-
default: () => mdx,
|
|
124
|
-
postInstall: () => postInstall
|
|
125
|
-
});
|
|
126
|
-
module.exports = __toCommonJS(vite_exports);
|
|
127
|
-
var import_vite = require("vite");
|
|
128
|
-
|
|
129
120
|
// src/config/build.ts
|
|
130
121
|
function buildConfig(config) {
|
|
131
122
|
const collections = /* @__PURE__ */ new Map();
|
|
@@ -175,8 +166,69 @@ function buildConfig(config) {
|
|
|
175
166
|
}
|
|
176
167
|
};
|
|
177
168
|
}
|
|
169
|
+
var init_build = __esm({
|
|
170
|
+
"src/config/build.ts"() {
|
|
171
|
+
"use strict";
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
// src/loaders/config/load.ts
|
|
176
|
+
async function compileConfig(configPath, outDir) {
|
|
177
|
+
const { build } = await import("esbuild");
|
|
178
|
+
const transformed = await build({
|
|
179
|
+
entryPoints: [{ in: configPath, out: "source.config" }],
|
|
180
|
+
bundle: true,
|
|
181
|
+
outdir: outDir,
|
|
182
|
+
target: "node20",
|
|
183
|
+
write: true,
|
|
184
|
+
platform: "node",
|
|
185
|
+
format: "esm",
|
|
186
|
+
packages: "external",
|
|
187
|
+
outExtension: {
|
|
188
|
+
".js": ".mjs"
|
|
189
|
+
},
|
|
190
|
+
allowOverwrite: true
|
|
191
|
+
});
|
|
192
|
+
if (transformed.errors.length > 0) {
|
|
193
|
+
throw new Error("failed to compile configuration file");
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
async function loadConfig(configPath, outDir, hash, build = false) {
|
|
197
|
+
if (cache3 && cache3.hash === hash) {
|
|
198
|
+
return await cache3.config;
|
|
199
|
+
}
|
|
200
|
+
if (build) await compileConfig(configPath, outDir);
|
|
201
|
+
const url = (0, import_node_url2.pathToFileURL)(path7.resolve(outDir, "source.config.mjs"));
|
|
202
|
+
const config = import(`${url.href}?hash=${hash}`).then((loaded) => {
|
|
203
|
+
return buildConfig(
|
|
204
|
+
// every call to `loadConfig` will cause the previous cache to be ignored
|
|
205
|
+
loaded
|
|
206
|
+
);
|
|
207
|
+
});
|
|
208
|
+
if (hash) cache3 = { config, hash };
|
|
209
|
+
return await config;
|
|
210
|
+
}
|
|
211
|
+
var fs4, path7, import_node_url2, cache3;
|
|
212
|
+
var init_load = __esm({
|
|
213
|
+
"src/loaders/config/load.ts"() {
|
|
214
|
+
"use strict";
|
|
215
|
+
fs4 = __toESM(require("fs/promises"), 1);
|
|
216
|
+
path7 = __toESM(require("path"), 1);
|
|
217
|
+
import_node_url2 = require("url");
|
|
218
|
+
init_build();
|
|
219
|
+
cache3 = null;
|
|
220
|
+
}
|
|
221
|
+
});
|
|
178
222
|
|
|
179
223
|
// src/vite/index.ts
|
|
224
|
+
var vite_exports = {};
|
|
225
|
+
__export(vite_exports, {
|
|
226
|
+
default: () => mdx,
|
|
227
|
+
postInstall: () => postInstall
|
|
228
|
+
});
|
|
229
|
+
module.exports = __toCommonJS(vite_exports);
|
|
230
|
+
var import_vite = require("vite");
|
|
231
|
+
init_build();
|
|
180
232
|
var import_node_querystring2 = require("querystring");
|
|
181
233
|
|
|
182
234
|
// src/utils/validation.ts
|
|
@@ -219,7 +271,7 @@ async function validate(schema, data, context, errorMessage) {
|
|
|
219
271
|
|
|
220
272
|
// src/vite/index.ts
|
|
221
273
|
var fs6 = __toESM(require("fs/promises"), 1);
|
|
222
|
-
var
|
|
274
|
+
var path9 = __toESM(require("path"), 1);
|
|
223
275
|
var import_js_yaml2 = require("js-yaml");
|
|
224
276
|
|
|
225
277
|
// src/utils/import-formatter.ts
|
|
@@ -393,19 +445,10 @@ async function getGitTimestamp(file) {
|
|
|
393
445
|
}
|
|
394
446
|
}
|
|
395
447
|
|
|
396
|
-
// src/
|
|
397
|
-
function countLines(s) {
|
|
398
|
-
let num = 0;
|
|
399
|
-
for (const c of s) {
|
|
400
|
-
if (c === "\n") num++;
|
|
401
|
-
}
|
|
402
|
-
return num;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
// src/mdx/build-mdx.ts
|
|
448
|
+
// src/loaders/mdx/build-mdx.ts
|
|
406
449
|
var import_mdx = require("@mdx-js/mdx");
|
|
407
450
|
|
|
408
|
-
// src/mdx/remark-include.ts
|
|
451
|
+
// src/loaders/mdx/remark-include.ts
|
|
409
452
|
var import_unified = require("unified");
|
|
410
453
|
var import_unist_util_visit = require("unist-util-visit");
|
|
411
454
|
var path3 = __toESM(require("path"), 1);
|
|
@@ -413,7 +456,28 @@ var fs = __toESM(require("fs/promises"), 1);
|
|
|
413
456
|
var import_remark_parse = __toESM(require("remark-parse"), 1);
|
|
414
457
|
var import_remark_mdx = __toESM(require("remark-mdx"), 1);
|
|
415
458
|
var import_mdx_plugins = require("fumadocs-core/mdx-plugins");
|
|
416
|
-
var
|
|
459
|
+
var ElementLikeTypes = [
|
|
460
|
+
"mdxJsxFlowElement",
|
|
461
|
+
"mdxJsxTextElement",
|
|
462
|
+
"containerDirective",
|
|
463
|
+
"textDirective",
|
|
464
|
+
"leafDirective"
|
|
465
|
+
];
|
|
466
|
+
function isElementLike(node) {
|
|
467
|
+
return ElementLikeTypes.includes(node.type);
|
|
468
|
+
}
|
|
469
|
+
function parseElementAttributes(element) {
|
|
470
|
+
if (Array.isArray(element.attributes)) {
|
|
471
|
+
const attributes = {};
|
|
472
|
+
for (const attr of element.attributes) {
|
|
473
|
+
if (attr.type === "mdxJsxAttribute" && (typeof attr.value === "string" || attr.value === null)) {
|
|
474
|
+
attributes[attr.name] = attr.value;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
return attributes;
|
|
478
|
+
}
|
|
479
|
+
return element.attributes ?? {};
|
|
480
|
+
}
|
|
417
481
|
function flattenNode(node) {
|
|
418
482
|
if ("children" in node)
|
|
419
483
|
return node.children.map((child) => flattenNode(child)).join("");
|
|
@@ -430,21 +494,31 @@ function parseSpecifier(specifier) {
|
|
|
430
494
|
}
|
|
431
495
|
function extractSection(root, section) {
|
|
432
496
|
let nodes;
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
497
|
+
let capturingHeadingContent = false;
|
|
498
|
+
(0, import_unist_util_visit.visit)(root, (node) => {
|
|
499
|
+
if (node.type === "heading") {
|
|
500
|
+
if (capturingHeadingContent) {
|
|
501
|
+
return false;
|
|
502
|
+
}
|
|
503
|
+
if (node.data?.hProperties?.id === section) {
|
|
504
|
+
capturingHeadingContent = true;
|
|
505
|
+
nodes = [node];
|
|
506
|
+
return "skip";
|
|
507
|
+
}
|
|
508
|
+
return;
|
|
443
509
|
}
|
|
444
|
-
if (
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
510
|
+
if (capturingHeadingContent) {
|
|
511
|
+
nodes?.push(node);
|
|
512
|
+
return "skip";
|
|
513
|
+
}
|
|
514
|
+
if (isElementLike(node) && node.name === "section") {
|
|
515
|
+
const attributes = parseElementAttributes(node);
|
|
516
|
+
if (attributes.id === section) {
|
|
517
|
+
nodes = node.children;
|
|
518
|
+
return false;
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
});
|
|
448
522
|
if (nodes)
|
|
449
523
|
return {
|
|
450
524
|
type: "root",
|
|
@@ -476,55 +550,52 @@ ${e instanceof Error ? e.message : String(e)}`,
|
|
|
476
550
|
data: {}
|
|
477
551
|
};
|
|
478
552
|
}
|
|
479
|
-
const
|
|
553
|
+
const parser = (data._getProcessor ?? getDefaultProcessor)(
|
|
480
554
|
ext === ".mdx" ? "mdx" : "md"
|
|
481
555
|
);
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
556
|
+
const parsed = fumaMatter(content);
|
|
557
|
+
let mdast = parser.parse({
|
|
558
|
+
path: file,
|
|
559
|
+
value: parsed.content,
|
|
560
|
+
data: { frontmatter: parsed.data }
|
|
561
|
+
});
|
|
485
562
|
if (heading) {
|
|
486
|
-
const extracted = extractSection(
|
|
563
|
+
const extracted = extractSection(
|
|
564
|
+
await (0, import_unified.unified)().use(import_mdx_plugins.remarkHeading).run(mdast),
|
|
565
|
+
heading
|
|
566
|
+
);
|
|
487
567
|
if (!extracted)
|
|
488
568
|
throw new Error(
|
|
489
|
-
`Cannot find section ${heading} in ${file}, make sure you have encapsulated the section in a <section id="${heading}"> tag.`
|
|
569
|
+
`Cannot find section ${heading} in ${file}, make sure you have encapsulated the section in a <section id="${heading}"> tag, or a :::section directive with remark-directive configured.`
|
|
490
570
|
);
|
|
491
|
-
|
|
571
|
+
mdast = extracted;
|
|
492
572
|
}
|
|
493
|
-
await update(
|
|
494
|
-
return
|
|
573
|
+
await update(mdast, path3.dirname(file), data);
|
|
574
|
+
return mdast;
|
|
495
575
|
}
|
|
496
576
|
async function update(tree, directory, data) {
|
|
497
577
|
const queue = [];
|
|
498
|
-
(0, import_unist_util_visit.visit)(
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
Object.assign(
|
|
520
|
-
parent && parent.type === "paragraph" ? parent : node,
|
|
521
|
-
replace
|
|
522
|
-
);
|
|
523
|
-
})
|
|
524
|
-
);
|
|
525
|
-
return "skip";
|
|
526
|
-
}
|
|
527
|
-
);
|
|
578
|
+
(0, import_unist_util_visit.visit)(tree, ElementLikeTypes, (_node, _, parent) => {
|
|
579
|
+
const node = _node;
|
|
580
|
+
if (node.name !== TagName) return;
|
|
581
|
+
const specifier = flattenNode(node);
|
|
582
|
+
if (specifier.length === 0) return "skip";
|
|
583
|
+
const attributes = parseElementAttributes(node);
|
|
584
|
+
const { file: relativePath, section } = parseSpecifier(specifier);
|
|
585
|
+
const file = path3.resolve(
|
|
586
|
+
"cwd" in attributes ? process.cwd() : directory,
|
|
587
|
+
relativePath
|
|
588
|
+
);
|
|
589
|
+
queue.push(
|
|
590
|
+
embedContent(file, section, attributes, data).then((replace) => {
|
|
591
|
+
Object.assign(
|
|
592
|
+
parent && parent.type === "paragraph" ? parent : node,
|
|
593
|
+
replace
|
|
594
|
+
);
|
|
595
|
+
})
|
|
596
|
+
);
|
|
597
|
+
return "skip";
|
|
598
|
+
});
|
|
528
599
|
await Promise.all(queue);
|
|
529
600
|
}
|
|
530
601
|
return async (tree, file) => {
|
|
@@ -537,7 +608,7 @@ function getDefaultProcessor(format) {
|
|
|
537
608
|
return mdProcessor.use(import_remark_mdx.default);
|
|
538
609
|
}
|
|
539
610
|
|
|
540
|
-
// src/mdx/remark-postprocess.ts
|
|
611
|
+
// src/loaders/mdx/remark-postprocess.ts
|
|
541
612
|
var import_unist_util_visit2 = require("unist-util-visit");
|
|
542
613
|
var import_mdast_util_to_markdown = require("mdast-util-to-markdown");
|
|
543
614
|
var import_estree_util_value_to_estree = require("estree-util-value-to-estree");
|
|
@@ -566,7 +637,7 @@ function remarkPostprocess({
|
|
|
566
637
|
if (includeProcessedMarkdown) {
|
|
567
638
|
file.data._markdown = (0, import_mdast_util_to_markdown.toMarkdown)(tree, {
|
|
568
639
|
...this.data("settings"),
|
|
569
|
-
//
|
|
640
|
+
// from https://github.com/remarkjs/remark/blob/main/packages/remark-stringify/lib/index.js
|
|
570
641
|
extensions: this.data("toMarkdownExtensions") || []
|
|
571
642
|
});
|
|
572
643
|
}
|
|
@@ -620,7 +691,7 @@ function flattenNode2(node) {
|
|
|
620
691
|
return "";
|
|
621
692
|
}
|
|
622
693
|
|
|
623
|
-
// src/mdx/build-mdx.ts
|
|
694
|
+
// src/loaders/mdx/build-mdx.ts
|
|
624
695
|
var cache2 = /* @__PURE__ */ new Map();
|
|
625
696
|
async function buildMDX(cacheKey, source, options) {
|
|
626
697
|
const { filePath, frontmatter, data, _compiler, ...rest } = options;
|
|
@@ -656,7 +727,7 @@ async function buildMDX(cacheKey, source, options) {
|
|
|
656
727
|
return processor;
|
|
657
728
|
}
|
|
658
729
|
return getProcessor(
|
|
659
|
-
options.format ?? filePath.endsWith(".mdx") ? "mdx" : "md"
|
|
730
|
+
options.format ?? (filePath.endsWith(".mdx") ? "mdx" : "md")
|
|
660
731
|
).process({
|
|
661
732
|
value: source,
|
|
662
733
|
path: filePath,
|
|
@@ -669,7 +740,7 @@ async function buildMDX(cacheKey, source, options) {
|
|
|
669
740
|
});
|
|
670
741
|
}
|
|
671
742
|
|
|
672
|
-
// src/loaders/mdx.ts
|
|
743
|
+
// src/loaders/mdx/index.ts
|
|
673
744
|
var import_zod = require("zod");
|
|
674
745
|
var import_promises = __toESM(require("fs/promises"), 1);
|
|
675
746
|
var import_node_path3 = __toESM(require("path"), 1);
|
|
@@ -768,52 +839,19 @@ function createMdxLoader(configLoader) {
|
|
|
768
839
|
function generateCacheHash(input) {
|
|
769
840
|
return (0, import_node_crypto.createHash)("md5").update(input).digest("hex");
|
|
770
841
|
}
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
var import_node_url = require("url");
|
|
776
|
-
function findConfigFile() {
|
|
777
|
-
return path5.resolve("source.config.ts");
|
|
778
|
-
}
|
|
779
|
-
var cache3 = null;
|
|
780
|
-
async function compileConfig(configPath, outDir) {
|
|
781
|
-
const { build } = await import("esbuild");
|
|
782
|
-
const transformed = await build({
|
|
783
|
-
entryPoints: [{ in: configPath, out: "source.config" }],
|
|
784
|
-
bundle: true,
|
|
785
|
-
outdir: outDir,
|
|
786
|
-
target: "node20",
|
|
787
|
-
write: true,
|
|
788
|
-
platform: "node",
|
|
789
|
-
format: "esm",
|
|
790
|
-
packages: "external",
|
|
791
|
-
outExtension: {
|
|
792
|
-
".js": ".mjs"
|
|
793
|
-
},
|
|
794
|
-
allowOverwrite: true
|
|
795
|
-
});
|
|
796
|
-
if (transformed.errors.length > 0) {
|
|
797
|
-
throw new Error("failed to compile configuration file");
|
|
798
|
-
}
|
|
799
|
-
}
|
|
800
|
-
async function loadConfig(configPath, outDir, hash, build = false) {
|
|
801
|
-
if (cache3 && cache3.hash === hash) {
|
|
802
|
-
return await cache3.config;
|
|
842
|
+
function countLines(s) {
|
|
843
|
+
let num = 0;
|
|
844
|
+
for (const c of s) {
|
|
845
|
+
if (c === "\n") num++;
|
|
803
846
|
}
|
|
804
|
-
|
|
805
|
-
const url = (0, import_node_url.pathToFileURL)(path5.resolve(outDir, "source.config.mjs"));
|
|
806
|
-
const config = import(`${url.href}?hash=${hash}`).then((loaded) => {
|
|
807
|
-
return buildConfig(
|
|
808
|
-
// every call to `loadConfig` will cause the previous cache to be ignored
|
|
809
|
-
loaded
|
|
810
|
-
);
|
|
811
|
-
});
|
|
812
|
-
if (hash) cache3 = { config, hash };
|
|
813
|
-
return await config;
|
|
847
|
+
return num;
|
|
814
848
|
}
|
|
815
849
|
|
|
816
|
-
// src/loaders/config
|
|
850
|
+
// src/loaders/config/index.ts
|
|
851
|
+
var import_node_path4 = __toESM(require("path"), 1);
|
|
852
|
+
function findConfigFile() {
|
|
853
|
+
return import_node_path4.default.resolve("source.config.ts");
|
|
854
|
+
}
|
|
817
855
|
function resolvedConfig(loaded) {
|
|
818
856
|
return {
|
|
819
857
|
getConfig() {
|
|
@@ -823,10 +861,10 @@ function resolvedConfig(loaded) {
|
|
|
823
861
|
}
|
|
824
862
|
|
|
825
863
|
// src/loaders/adapter.ts
|
|
826
|
-
var
|
|
864
|
+
var import_node_url = require("url");
|
|
827
865
|
var import_promises2 = __toESM(require("fs/promises"), 1);
|
|
828
866
|
var import_node_querystring = require("querystring");
|
|
829
|
-
var
|
|
867
|
+
var import_node_path5 = __toESM(require("path"), 1);
|
|
830
868
|
function toVite(loader) {
|
|
831
869
|
return async function(file, query, value) {
|
|
832
870
|
const result = await loader({
|
|
@@ -848,8 +886,9 @@ function toVite(loader) {
|
|
|
848
886
|
}
|
|
849
887
|
|
|
850
888
|
// src/vite/postinstall.ts
|
|
889
|
+
init_load();
|
|
851
890
|
var import_promises3 = __toESM(require("fs/promises"), 1);
|
|
852
|
-
var
|
|
891
|
+
var import_node_path6 = __toESM(require("path"), 1);
|
|
853
892
|
async function postInstall(configPath = findConfigFile(), outDir, addJsExtension = false) {
|
|
854
893
|
const config = await loadConfig(configPath, "node_modules", void 0, true);
|
|
855
894
|
const outFile = "source.generated.ts";
|
|
@@ -857,7 +896,7 @@ async function postInstall(configPath = findConfigFile(), outDir, addJsExtension
|
|
|
857
896
|
await import_promises3.default.mkdir(outDir, { recursive: true });
|
|
858
897
|
}
|
|
859
898
|
await import_promises3.default.writeFile(
|
|
860
|
-
outDir ?
|
|
899
|
+
outDir ? import_node_path6.default.join(outDir, outFile) : outFile,
|
|
861
900
|
entry(configPath, config, outDir ?? process.cwd(), addJsExtension)
|
|
862
901
|
);
|
|
863
902
|
console.log("[MDX] types generated");
|
|
@@ -869,8 +908,8 @@ function mdx(config, options = {}) {
|
|
|
869
908
|
const { generateIndexFile = true, configPath = "source.config.ts" } = options;
|
|
870
909
|
const loaded = buildConfig(config);
|
|
871
910
|
const mdxLoader = toVite(createMdxLoader(resolvedConfig(loaded)));
|
|
872
|
-
async function transformMeta(
|
|
873
|
-
const isJson =
|
|
911
|
+
async function transformMeta(path10, query, value) {
|
|
912
|
+
const isJson = path10.endsWith(".json");
|
|
874
913
|
const parsed = (0, import_node_querystring2.parse)(query);
|
|
875
914
|
const collection = parsed.collection ? loaded.collections.get(parsed.collection) : void 0;
|
|
876
915
|
if (!collection) return null;
|
|
@@ -893,8 +932,8 @@ function mdx(config, options = {}) {
|
|
|
893
932
|
const out = await validate(
|
|
894
933
|
schema,
|
|
895
934
|
data,
|
|
896
|
-
{ path:
|
|
897
|
-
`invalid data in ${
|
|
935
|
+
{ path: path10, source: value },
|
|
936
|
+
`invalid data in ${path10}`
|
|
898
937
|
);
|
|
899
938
|
return {
|
|
900
939
|
code: isJson ? JSON.stringify(out) : `export default ${JSON.stringify(out)}`,
|
|
@@ -918,22 +957,15 @@ function mdx(config, options = {}) {
|
|
|
918
957
|
},
|
|
919
958
|
async buildStart() {
|
|
920
959
|
if (!generateIndexFile) return;
|
|
960
|
+
const { out = "source.generated.ts", addJsExtension } = typeof generateIndexFile === "object" ? generateIndexFile : {};
|
|
921
961
|
console.log("[Fumadocs MDX] Generating index files");
|
|
922
|
-
const
|
|
923
|
-
|
|
924
|
-
await fs6.writeFile(
|
|
925
|
-
path8.join(outDir, outFile),
|
|
926
|
-
entry(
|
|
927
|
-
configPath,
|
|
928
|
-
loaded,
|
|
929
|
-
outDir,
|
|
930
|
-
typeof generateIndexFile === "object" ? generateIndexFile.addJsExtension : void 0
|
|
931
|
-
)
|
|
932
|
-
);
|
|
962
|
+
const dir = path9.dirname(out);
|
|
963
|
+
await fs6.mkdir(dir, { recursive: true });
|
|
964
|
+
await fs6.writeFile(out, entry(configPath, loaded, dir, addJsExtension));
|
|
933
965
|
},
|
|
934
966
|
async transform(value, id) {
|
|
935
967
|
const [file, query = ""] = id.split("?");
|
|
936
|
-
const ext =
|
|
968
|
+
const ext = path9.extname(file);
|
|
937
969
|
try {
|
|
938
970
|
if ([".yaml", ".json"].includes(ext))
|
|
939
971
|
return await transformMeta(file, query, value);
|
package/dist/vite/index.d.cts
CHANGED
package/dist/vite/index.d.ts
CHANGED
package/dist/vite/index.js
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
import {
|
|
2
2
|
entry,
|
|
3
3
|
postInstall
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-ZX7TM4AR.js";
|
|
5
5
|
import "../chunk-6Y5JDZHD.js";
|
|
6
|
+
import "../chunk-LGYVNESJ.js";
|
|
7
|
+
import {
|
|
8
|
+
buildConfig
|
|
9
|
+
} from "../chunk-U4MQ44TS.js";
|
|
6
10
|
import {
|
|
7
11
|
toVite
|
|
8
12
|
} from "../chunk-VXEBLM4X.js";
|
|
9
13
|
import {
|
|
10
|
-
createMdxLoader
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
createMdxLoader
|
|
15
|
+
} from "../chunk-RMDXSZYE.js";
|
|
16
|
+
import "../chunk-QAUWMR5D.js";
|
|
17
|
+
import "../chunk-LMG6UWCL.js";
|
|
13
18
|
import {
|
|
14
19
|
ValidationError,
|
|
15
20
|
validate
|
|
16
21
|
} from "../chunk-IQAEAI4P.js";
|
|
17
|
-
import "../chunk-POXTQZ4D.js";
|
|
18
|
-
import "../chunk-SWNOXPYJ.js";
|
|
19
|
-
import "../chunk-KTDVTBMH.js";
|
|
20
22
|
import {
|
|
21
|
-
|
|
22
|
-
} from "../chunk-
|
|
23
|
+
resolvedConfig
|
|
24
|
+
} from "../chunk-XMFLD5J6.js";
|
|
23
25
|
import "../chunk-VWJKRQZR.js";
|
|
24
26
|
|
|
25
27
|
// src/vite/index.ts
|
|
@@ -84,18 +86,11 @@ function mdx(config, options = {}) {
|
|
|
84
86
|
},
|
|
85
87
|
async buildStart() {
|
|
86
88
|
if (!generateIndexFile) return;
|
|
89
|
+
const { out = "source.generated.ts", addJsExtension } = typeof generateIndexFile === "object" ? generateIndexFile : {};
|
|
87
90
|
console.log("[Fumadocs MDX] Generating index files");
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
await fs.writeFile(
|
|
91
|
-
path.join(outDir, outFile),
|
|
92
|
-
entry(
|
|
93
|
-
configPath,
|
|
94
|
-
loaded,
|
|
95
|
-
outDir,
|
|
96
|
-
typeof generateIndexFile === "object" ? generateIndexFile.addJsExtension : void 0
|
|
97
|
-
)
|
|
98
|
-
);
|
|
91
|
+
const dir = path.dirname(out);
|
|
92
|
+
await fs.mkdir(dir, { recursive: true });
|
|
93
|
+
await fs.writeFile(out, entry(configPath, loaded, dir, addJsExtension));
|
|
99
94
|
},
|
|
100
95
|
async transform(value, id) {
|
|
101
96
|
const [file, query = ""] = id.split("?");
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-mdx",
|
|
3
|
-
"version": "12.0.
|
|
3
|
+
"version": "12.0.2",
|
|
4
4
|
"description": "The built-in source for Fumadocs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NextJs",
|
|
7
7
|
"Docs"
|
|
8
8
|
],
|
|
9
|
-
"homepage": "https://fumadocs.
|
|
9
|
+
"homepage": "https://fumadocs.dev",
|
|
10
10
|
"repository": "github:fuma-nama/fumadocs",
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"author": "Fuma Nama",
|
|
@@ -29,6 +29,10 @@
|
|
|
29
29
|
"require": "./dist/vite/index.cjs"
|
|
30
30
|
},
|
|
31
31
|
".": {
|
|
32
|
+
"import": "./dist/index.js",
|
|
33
|
+
"types": "./dist/index.d.ts"
|
|
34
|
+
},
|
|
35
|
+
"./runtime/next": {
|
|
32
36
|
"import": "./dist/runtime/next/index.js",
|
|
33
37
|
"types": "./dist/runtime/next/index.d.ts"
|
|
34
38
|
},
|
|
@@ -61,10 +65,10 @@
|
|
|
61
65
|
"@mdx-js/mdx": "^3.1.1",
|
|
62
66
|
"@standard-schema/spec": "^1.0.0",
|
|
63
67
|
"chokidar": "^4.0.3",
|
|
64
|
-
"esbuild": "^0.25.
|
|
68
|
+
"esbuild": "^0.25.10",
|
|
65
69
|
"estree-util-value-to-estree": "^3.4.0",
|
|
66
70
|
"js-yaml": "^4.1.0",
|
|
67
|
-
"lru-cache": "^11.2.
|
|
71
|
+
"lru-cache": "^11.2.2",
|
|
68
72
|
"mdast-util-to-markdown": "^2.1.2",
|
|
69
73
|
"picocolors": "^1.1.1",
|
|
70
74
|
"remark-mdx": "^3.1.1",
|
|
@@ -73,25 +77,29 @@
|
|
|
73
77
|
"tinyglobby": "^0.2.15",
|
|
74
78
|
"unified": "^11.0.5",
|
|
75
79
|
"unist-util-visit": "^5.0.0",
|
|
76
|
-
"zod": "^4.1.
|
|
80
|
+
"zod": "^4.1.11"
|
|
77
81
|
},
|
|
78
82
|
"devDependencies": {
|
|
79
|
-
"@types/bun": "^1.2.
|
|
83
|
+
"@types/bun": "^1.2.23",
|
|
80
84
|
"@types/js-yaml": "^4.0.9",
|
|
81
85
|
"@types/mdast": "^4.0.3",
|
|
82
86
|
"@types/mdx": "^2.0.13",
|
|
83
|
-
"@types/node": "^24.
|
|
84
|
-
"@types/react": "^19.
|
|
87
|
+
"@types/node": "^24.6.2",
|
|
88
|
+
"@types/react": "^19.2.0",
|
|
89
|
+
"mdast-util-directive": "^3.1.0",
|
|
85
90
|
"mdast-util-mdx-jsx": "^3.2.0",
|
|
86
|
-
"next": "^15.5.
|
|
87
|
-
"react": "^19.
|
|
88
|
-
"
|
|
91
|
+
"next": "^15.5.4",
|
|
92
|
+
"react": "^19.2.0",
|
|
93
|
+
"remark": "^15.0.1",
|
|
94
|
+
"remark-directive": "^4.0.0",
|
|
95
|
+
"remark-stringify": "^11.0.0",
|
|
96
|
+
"rollup": "^4.52.3",
|
|
89
97
|
"vfile": "^6.0.3",
|
|
90
|
-
"vite": "^7.1.
|
|
91
|
-
"webpack": "^5.
|
|
92
|
-
"@fumadocs/mdx-remote": "1.4.
|
|
98
|
+
"vite": "^7.1.8",
|
|
99
|
+
"webpack": "^5.102.0",
|
|
100
|
+
"@fumadocs/mdx-remote": "1.4.1",
|
|
93
101
|
"eslint-config-custom": "0.0.0",
|
|
94
|
-
"fumadocs-core": "15.
|
|
102
|
+
"fumadocs-core": "15.8.3",
|
|
95
103
|
"tsconfig": "0.0.0"
|
|
96
104
|
},
|
|
97
105
|
"peerDependencies": {
|