fumadocs-mdx 12.0.0 → 12.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/bin.cjs +102 -84
  2. package/dist/bin.js +1 -1
  3. package/dist/bun/index.cjs +156 -130
  4. package/dist/bun/index.js +8 -8
  5. package/dist/chunk-ADR6R7HM.js +29 -0
  6. package/dist/{chunk-3M4SHY6K.js → chunk-FSZMKRVH.js} +1 -1
  7. package/dist/{chunk-POXTQZ4D.js → chunk-LGYVNESJ.js} +2 -6
  8. package/dist/chunk-LMG6UWCL.js +167 -0
  9. package/dist/{chunk-SWNOXPYJ.js → chunk-QAUWMR5D.js} +6 -6
  10. package/dist/{chunk-KGUBBRL6.js → chunk-SP7CHRTS.js} +9 -37
  11. package/dist/{chunk-YC25YEBF.js → chunk-U4MQ44TS.js} +1 -1
  12. package/dist/chunk-XMFLD5J6.js +30 -0
  13. package/dist/{chunk-TLD6JMT6.js → chunk-ZX7TM4AR.js} +4 -2
  14. package/dist/config/index.cjs +84 -56
  15. package/dist/config/index.js +2 -2
  16. package/dist/load-UUXLUBHL.js +9 -0
  17. package/dist/loader-mdx.cjs +217 -174
  18. package/dist/loader-mdx.js +7 -7
  19. package/dist/next/index.cjs +128 -108
  20. package/dist/next/index.js +39 -53
  21. package/dist/node/loader.cjs +152 -109
  22. package/dist/node/loader.js +6 -7
  23. package/dist/postinstall-SCSXM4IM.js +10 -0
  24. package/dist/{preset-WFEORCAB.js → preset-ZMP6U62C.js} +1 -1
  25. package/dist/runtime/next/async.cjs +117 -65
  26. package/dist/runtime/next/async.d.cts +1 -1
  27. package/dist/runtime/next/async.d.ts +1 -1
  28. package/dist/runtime/next/async.js +15 -8
  29. package/dist/runtime/next/index.d.cts +2 -2
  30. package/dist/runtime/next/index.d.ts +2 -2
  31. package/dist/{types-DLIAvrgC.d.ts → types-CFlQxTN8.d.ts} +4 -5
  32. package/dist/{types-Dl8HLbm5.d.cts → types-DkGjw-Uo.d.cts} +4 -5
  33. package/dist/vite/index.cjs +177 -145
  34. package/dist/vite/index.d.cts +1 -0
  35. package/dist/vite/index.d.ts +1 -0
  36. package/dist/vite/index.js +14 -19
  37. package/dist/{watcher-4NDMOH4R.js → watcher-HGOH3APP.js} +1 -1
  38. package/package.json +15 -11
  39. package/dist/chunk-KTDVTBMH.js +0 -139
  40. package/dist/postinstall-U7VROOY7.js +0 -9
@@ -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 path8 = __toESM(require("path"), 1);
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/utils/count-lines.ts
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 baseProcessor = (0, import_unified.unified)().use(import_mdx_plugins.remarkHeading);
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
- for (const node of root.children) {
434
- if (node.type === "mdxJsxFlowElement" && node.name === "section" && node.attributes.some(
435
- (attr) => attr.type === "mdxJsxAttribute" && attr.name === "id" && attr.value === section
436
- )) {
437
- nodes = node.children;
438
- break;
439
- }
440
- if (node.type === "heading" && node.data?.hProperties?.id === section) {
441
- nodes = [node];
442
- continue;
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 (!nodes) continue;
445
- if (node.type === "heading") break;
446
- nodes.push(node);
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 processor = (data._getProcessor ?? getDefaultProcessor)(
553
+ const parser = (data._getProcessor ?? getDefaultProcessor)(
480
554
  ext === ".mdx" ? "mdx" : "md"
481
555
  );
482
- let parsed = await baseProcessor.run(
483
- processor.parse(fumaMatter(content).content)
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(parsed, heading);
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
- parsed = extracted;
571
+ mdast = extracted;
492
572
  }
493
- await update(parsed, path3.dirname(file), data);
494
- return parsed;
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
- tree,
500
- ["mdxJsxFlowElement", "mdxJsxTextElement"],
501
- (_node, _, parent) => {
502
- const node = _node;
503
- if (node.name !== TagName) return;
504
- const params = {};
505
- const specifier = flattenNode(node);
506
- if (specifier.length === 0) return "skip";
507
- for (const attr of node.attributes) {
508
- if (attr.type === "mdxJsxAttribute" && (typeof attr.value === "string" || attr.value === null)) {
509
- params[attr.name] = attr.value;
510
- }
511
- }
512
- const { file: relativePath, section } = parseSpecifier(specifier);
513
- const file = path3.resolve(
514
- "cwd" in params ? process.cwd() : directory,
515
- relativePath
516
- );
517
- queue.push(
518
- embedContent(file, section, params, data).then((replace) => {
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
- // @ts-expect-error - from https://github.com/remarkjs/remark/blob/main/packages/remark-stringify/lib/index.js
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
- // src/utils/config.ts
773
- var fs3 = __toESM(require("fs/promises"), 1);
774
- var path5 = __toESM(require("path"), 1);
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
- if (build) await compileConfig(configPath, outDir);
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-loader.ts
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 import_node_url2 = require("url");
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 import_node_path4 = __toESM(require("path"), 1);
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 import_node_path5 = __toESM(require("path"), 1);
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 ? import_node_path5.default.join(outDir, outFile) : outFile,
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(path9, query, value) {
873
- const isJson = path9.endsWith(".json");
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: path9, source: value },
897
- `invalid data in ${path9}`
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 outDir = process.cwd();
923
- const outFile = "source.generated.ts";
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 = path8.extname(file);
968
+ const ext = path9.extname(file);
937
969
  try {
938
970
  if ([".yaml", ".json"].includes(ext))
939
971
  return await transformMeta(file, query, value);
@@ -9,6 +9,7 @@ interface PluginOptions {
9
9
  * @defaultValue true
10
10
  */
11
11
  generateIndexFile?: boolean | {
12
+ out?: string;
12
13
  /**
13
14
  * add `.js` extensions to imports, needed for ESM without bundler resolution
14
15
  */
@@ -9,6 +9,7 @@ interface PluginOptions {
9
9
  * @defaultValue true
10
10
  */
11
11
  generateIndexFile?: boolean | {
12
+ out?: string;
12
13
  /**
13
14
  * add `.js` extensions to imports, needed for ESM without bundler resolution
14
15
  */
@@ -1,25 +1,27 @@
1
1
  import {
2
2
  entry,
3
3
  postInstall
4
- } from "../chunk-TLD6JMT6.js";
4
+ } from "../chunk-ZX7TM4AR.js";
5
5
  import "../chunk-6Y5JDZHD.js";
6
+ import "../chunk-LGYVNESJ.js";
6
7
  import {
7
8
  toVite
8
9
  } from "../chunk-VXEBLM4X.js";
9
10
  import {
10
- createMdxLoader,
11
- resolvedConfig
12
- } from "../chunk-KGUBBRL6.js";
11
+ createMdxLoader
12
+ } from "../chunk-SP7CHRTS.js";
13
13
  import {
14
14
  ValidationError,
15
15
  validate
16
16
  } from "../chunk-IQAEAI4P.js";
17
- import "../chunk-POXTQZ4D.js";
18
- import "../chunk-SWNOXPYJ.js";
19
- import "../chunk-KTDVTBMH.js";
17
+ import {
18
+ resolvedConfig
19
+ } from "../chunk-XMFLD5J6.js";
20
20
  import {
21
21
  buildConfig
22
- } from "../chunk-YC25YEBF.js";
22
+ } from "../chunk-U4MQ44TS.js";
23
+ import "../chunk-QAUWMR5D.js";
24
+ import "../chunk-LMG6UWCL.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 outDir = process.cwd();
89
- const outFile = "source.generated.ts";
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("?");
@@ -1,4 +1,4 @@
1
- // src/map/watcher.ts
1
+ // src/next/map/watcher.ts
2
2
  import { FSWatcher } from "chokidar";
3
3
  function watcher(configPath, config, ignored) {
4
4
  const watcher2 = new FSWatcher({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-mdx",
3
- "version": "12.0.0",
3
+ "version": "12.0.1",
4
4
  "description": "The built-in source for Fumadocs",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -61,10 +61,10 @@
61
61
  "@mdx-js/mdx": "^3.1.1",
62
62
  "@standard-schema/spec": "^1.0.0",
63
63
  "chokidar": "^4.0.3",
64
- "esbuild": "^0.25.9",
64
+ "esbuild": "^0.25.10",
65
65
  "estree-util-value-to-estree": "^3.4.0",
66
66
  "js-yaml": "^4.1.0",
67
- "lru-cache": "^11.2.1",
67
+ "lru-cache": "^11.2.2",
68
68
  "mdast-util-to-markdown": "^2.1.2",
69
69
  "picocolors": "^1.1.1",
70
70
  "remark-mdx": "^3.1.1",
@@ -73,25 +73,29 @@
73
73
  "tinyglobby": "^0.2.15",
74
74
  "unified": "^11.0.5",
75
75
  "unist-util-visit": "^5.0.0",
76
- "zod": "^4.1.8"
76
+ "zod": "^4.1.11"
77
77
  },
78
78
  "devDependencies": {
79
- "@types/bun": "^1.2.21",
79
+ "@types/bun": "^1.2.22",
80
80
  "@types/js-yaml": "^4.0.9",
81
81
  "@types/mdast": "^4.0.3",
82
82
  "@types/mdx": "^2.0.13",
83
- "@types/node": "^24.3.3",
83
+ "@types/node": "^24.5.2",
84
84
  "@types/react": "^19.1.13",
85
+ "mdast-util-directive": "^3.1.0",
85
86
  "mdast-util-mdx-jsx": "^3.2.0",
86
- "next": "^15.5.3",
87
+ "next": "^15.5.4",
87
88
  "react": "^19.1.1",
88
- "rollup": "^4.50.1",
89
+ "remark": "^15.0.1",
90
+ "remark-directive": "^4.0.0",
91
+ "remark-stringify": "^11.0.0",
92
+ "rollup": "^4.52.2",
89
93
  "vfile": "^6.0.3",
90
- "vite": "^7.1.5",
94
+ "vite": "^7.1.7",
91
95
  "webpack": "^5.101.3",
92
- "@fumadocs/mdx-remote": "1.4.0",
93
96
  "eslint-config-custom": "0.0.0",
94
- "fumadocs-core": "15.7.13",
97
+ "@fumadocs/mdx-remote": "1.4.0",
98
+ "fumadocs-core": "15.8.0",
95
99
  "tsconfig": "0.0.0"
96
100
  },
97
101
  "peerDependencies": {