fumadocs-mdx 11.7.4 → 11.7.5

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 (38) hide show
  1. package/dist/{chunk-PQCNPAD3.js → chunk-3XN4P23K.js} +9 -6
  2. package/dist/chunk-GBMFGEC7.js +57 -0
  3. package/dist/{chunk-ZOWJF3OH.js → chunk-GX3THK2Q.js} +25 -20
  4. package/dist/{chunk-2CSSQTP6.js → chunk-GYWPPGFD.js} +9 -1
  5. package/dist/chunk-HWSF4OGZ.js +42 -0
  6. package/dist/chunk-UCY7OBZG.js +12 -0
  7. package/dist/{chunk-JFNBRKRV.js → chunk-XVL4ZQFK.js} +12 -6
  8. package/dist/{chunk-4CGSOZUZ.js → chunk-XZR5QXVY.js} +32 -2
  9. package/dist/config/index.cjs +19 -9
  10. package/dist/config/index.d.cts +2 -2
  11. package/dist/config/index.d.ts +2 -2
  12. package/dist/config/index.js +8 -36
  13. package/dist/config/zod-3.cjs +371 -0
  14. package/dist/config/zod-3.d.cts +53 -0
  15. package/dist/config/zod-3.d.ts +53 -0
  16. package/dist/config/zod-3.js +40 -0
  17. package/dist/{define-E6TRBwBQ.d.cts → define-DnJzAZrj.d.cts} +3 -2
  18. package/dist/{define-E6TRBwBQ.d.ts → define-DnJzAZrj.d.ts} +3 -2
  19. package/dist/index.d.cts +3 -3
  20. package/dist/index.d.ts +3 -3
  21. package/dist/loader-mdx.cjs +81 -48
  22. package/dist/loader-mdx.js +8 -8
  23. package/dist/{mdx-options-UDV5WEFU.js → mdx-options-3NB74EMB.js} +1 -1
  24. package/dist/next/index.cjs +52 -25
  25. package/dist/next/index.js +4 -6
  26. package/dist/runtime/async.cjs +162 -124
  27. package/dist/runtime/async.d.cts +3 -3
  28. package/dist/runtime/async.d.ts +3 -3
  29. package/dist/runtime/async.js +26 -43
  30. package/dist/runtime/vite.d.cts +2 -2
  31. package/dist/runtime/vite.d.ts +2 -2
  32. package/dist/{types-DiL328cG.d.ts → types-C-WXTx1W.d.cts} +2 -2
  33. package/dist/{types-Lh_-Uuix.d.cts → types-CU9nn_je.d.ts} +2 -2
  34. package/dist/vite/index.cjs +52 -49
  35. package/dist/vite/index.js +8 -8
  36. package/package.json +12 -7
  37. package/dist/chunk-2K55VKP6.js +0 -49
  38. package/dist/chunk-VUEZTR2H.js +0 -26
@@ -102,6 +102,7 @@ function getDefaultMDXOptions({
102
102
  remarkStructureOptions,
103
103
  remarkCodeTabOptions,
104
104
  remarkNpmOptions,
105
+ _withoutBundler = false,
105
106
  ...mdxOptions
106
107
  }) {
107
108
  const mdxExports = [
@@ -120,7 +121,13 @@ function getDefaultMDXOptions({
120
121
  ...remarkHeadingOptions
121
122
  }
122
123
  ],
123
- remarkImageOptions !== false && [plugins.remarkImage, remarkImageOptions],
124
+ remarkImageOptions !== false && [
125
+ plugins.remarkImage,
126
+ {
127
+ ...remarkImageOptions,
128
+ useImport: _withoutBundler ? false : remarkImageOptions?.useImport
129
+ }
130
+ ],
124
131
  "remarkCodeTab" in plugins && remarkCodeTabOptions !== false && [
125
132
  plugins.remarkCodeTab,
126
133
  remarkCodeTabOptions
@@ -145,6 +152,7 @@ function getDefaultMDXOptions({
145
152
  );
146
153
  return {
147
154
  ...mdxOptions,
155
+ outputFormat: _withoutBundler ? "function-body" : mdxOptions.outputFormat,
148
156
  remarkPlugins,
149
157
  rehypePlugins
150
158
  };
@@ -191,20 +199,26 @@ function buildConfig(config) {
191
199
  `Unknown export "${k}", you can only export collections from source configuration file.`
192
200
  );
193
201
  }
194
- let cachedMdxOptions;
202
+ const mdxOptionsCache = /* @__PURE__ */ new Map();
195
203
  return {
196
204
  global: globalConfig,
197
205
  collections,
198
- async getDefaultMDXOptions() {
199
- if (cachedMdxOptions) return cachedMdxOptions;
206
+ async getDefaultMDXOptions(mode = "default") {
207
+ const cached = mdxOptionsCache.get(mode);
208
+ if (cached) return cached;
200
209
  const input = this.global.mdxOptions;
201
210
  async function uncached() {
202
211
  const options = typeof input === "function" ? await input() : input;
203
212
  const { getDefaultMDXOptions: getDefaultMDXOptions2 } = await Promise.resolve().then(() => (init_mdx_options(), mdx_options_exports));
204
213
  if (options?.preset === "minimal") return options;
205
- return getDefaultMDXOptions2(options ?? {});
214
+ return getDefaultMDXOptions2({
215
+ ...options,
216
+ _withoutBundler: mode === "remote"
217
+ });
206
218
  }
207
- return cachedMdxOptions = uncached();
219
+ const result = uncached();
220
+ mdxOptionsCache.set(mode, result);
221
+ return result;
208
222
  }
209
223
  };
210
224
  }
@@ -262,7 +276,7 @@ function extractSection(root, section) {
262
276
  }
263
277
  function remarkInclude() {
264
278
  const TagName = "include";
265
- async function update(tree, directory, processor, compiler) {
279
+ async function update(tree, directory, data) {
266
280
  const queue = [];
267
281
  (0, import_unist_util_visit.visit)(
268
282
  tree,
@@ -290,7 +304,7 @@ function remarkInclude() {
290
304
  const asCode = params.lang || !file.endsWith(".md") && !file.endsWith(".mdx");
291
305
  queue.push(
292
306
  fs.readFile(targetPath).then((buffer) => buffer.toString()).then(async (content) => {
293
- compiler?.addDependency(targetPath);
307
+ data._compiler?.addDependency(targetPath);
294
308
  if (asCode) {
295
309
  const lang = params.lang ?? path.extname(file).slice(1);
296
310
  Object.assign(node, {
@@ -302,6 +316,9 @@ function remarkInclude() {
302
316
  });
303
317
  return;
304
318
  }
319
+ const processor = data._processor ? data._processor.getProcessor(
320
+ targetPath.endsWith(".md") ? "md" : "mdx"
321
+ ) : this;
305
322
  let parsed = processor.parse(fumaMatter(content).content);
306
323
  if (section) {
307
324
  const extracted = extractSection(parsed, section);
@@ -311,11 +328,11 @@ function remarkInclude() {
311
328
  );
312
329
  parsed = extracted;
313
330
  }
314
- await update(
331
+ await update.call(
332
+ processor,
315
333
  parsed,
316
334
  path.dirname(targetPath),
317
- processor,
318
- compiler
335
+ data
319
336
  );
320
337
  Object.assign(
321
338
  parent && parent.type === "paragraph" ? parent : node,
@@ -335,7 +352,7 @@ ${e instanceof Error ? e.message : String(e)}`,
335
352
  await Promise.all(queue);
336
353
  }
337
354
  return async (tree, file) => {
338
- await update(tree, path.dirname(file.path), this, file.data._compiler);
355
+ await update.call(this, tree, path.dirname(file.path), file.data);
339
356
  };
340
357
  }
341
358
 
@@ -343,29 +360,32 @@ ${e instanceof Error ? e.message : String(e)}`,
343
360
  var cache = /* @__PURE__ */ new Map();
344
361
  async function buildMDX(cacheKey, source, options) {
345
362
  const { filePath, frontmatter, data, _compiler, ...rest } = options;
346
- let format = options.format;
347
- if (filePath) {
348
- format ??= filePath.endsWith(".mdx") ? "mdx" : "md";
349
- }
350
- format ??= "mdx";
351
- const key = `${cacheKey}:${format}`;
352
- let cached = cache.get(key);
353
- if (!cached) {
354
- cached = (0, import_mdx.createProcessor)({
355
- outputFormat: "program",
356
- ...rest,
357
- remarkPlugins: [remarkInclude, ...rest.remarkPlugins ?? []],
358
- format
359
- });
360
- cache.set(key, cached);
363
+ function getProcessor(format) {
364
+ const key = `${cacheKey}:${format}`;
365
+ let processor = cache.get(key);
366
+ if (!processor) {
367
+ processor = (0, import_mdx.createProcessor)({
368
+ outputFormat: "program",
369
+ ...rest,
370
+ remarkPlugins: [remarkInclude, ...rest.remarkPlugins ?? []],
371
+ format
372
+ });
373
+ cache.set(key, processor);
374
+ }
375
+ return processor;
361
376
  }
362
- return cached.process({
377
+ return getProcessor(
378
+ options.format ?? filePath.endsWith(".mdx") ? "mdx" : "md"
379
+ ).process({
363
380
  value: source,
364
381
  path: filePath,
365
382
  data: {
366
383
  ...data,
367
384
  frontmatter,
368
- _compiler
385
+ _compiler,
386
+ _processor: {
387
+ getProcessor
388
+ }
369
389
  }
370
390
  });
371
391
  }
@@ -382,25 +402,8 @@ function countLines(s) {
382
402
  return num;
383
403
  }
384
404
 
385
- // src/utils/schema.ts
386
- var import_zod = require("zod");
405
+ // src/utils/validation.ts
387
406
  var import_picocolors = __toESM(require("picocolors"), 1);
388
- var metaSchema = import_zod.z.object({
389
- title: import_zod.z.string().optional(),
390
- pages: import_zod.z.array(import_zod.z.string()).optional(),
391
- description: import_zod.z.string().optional(),
392
- root: import_zod.z.boolean().optional(),
393
- defaultOpen: import_zod.z.boolean().optional(),
394
- icon: import_zod.z.string().optional()
395
- });
396
- var frontmatterSchema = import_zod.z.object({
397
- title: import_zod.z.string(),
398
- description: import_zod.z.string().optional(),
399
- icon: import_zod.z.string().optional(),
400
- full: import_zod.z.boolean().optional(),
401
- // Fumadocs OpenAPI generated
402
- _openapi: import_zod.z.looseObject({}).optional()
403
- });
404
407
  var ValidationError = class extends Error {
405
408
  constructor(message, issues) {
406
409
  super(
@@ -438,7 +441,7 @@ async function validate(schema, data, context, errorMessage) {
438
441
  }
439
442
 
440
443
  // src/vite/index.ts
441
- var import_zod2 = require("zod");
444
+ var import_zod = require("zod");
442
445
 
443
446
  // src/utils/import-formatter.ts
444
447
  var import_node_path = __toESM(require("path"), 1);
@@ -537,7 +540,7 @@ async function getGitTimestamp(file) {
537
540
  }
538
541
 
539
542
  // src/vite/index.ts
540
- var onlySchema = import_zod2.z.literal(["frontmatter", "all"]);
543
+ var onlySchema = import_zod.z.literal(["frontmatter", "all"]);
541
544
  function mdx(config, options = {}) {
542
545
  const { generateIndexFile = true, configPath = "source.config.ts" } = options;
543
546
  const loaded = buildConfig(config);
@@ -1,23 +1,23 @@
1
1
  import {
2
- buildMDX,
3
2
  countLines
4
- } from "../chunk-2K55VKP6.js";
3
+ } from "../chunk-UCY7OBZG.js";
4
+ import {
5
+ buildMDX
6
+ } from "../chunk-HWSF4OGZ.js";
7
+ import "../chunk-3XN4P23K.js";
5
8
  import {
6
9
  getGlobPatterns,
7
10
  ident,
8
11
  toImportPath
9
12
  } from "../chunk-OWZSTKKX.js";
10
- import {
11
- getGitTimestamp
12
- } from "../chunk-VUEZTR2H.js";
13
13
  import {
14
14
  ValidationError,
15
+ getGitTimestamp,
15
16
  validate
16
- } from "../chunk-ZOWJF3OH.js";
17
- import "../chunk-PQCNPAD3.js";
17
+ } from "../chunk-GX3THK2Q.js";
18
18
  import {
19
19
  buildConfig
20
- } from "../chunk-JFNBRKRV.js";
20
+ } from "../chunk-XVL4ZQFK.js";
21
21
  import {
22
22
  fumaMatter
23
23
  } from "../chunk-KVWX6THC.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-mdx",
3
- "version": "11.7.4",
3
+ "version": "11.7.5",
4
4
  "description": "The built-in source for Fumadocs",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -18,6 +18,11 @@
18
18
  "types": "./dist/config/index.d.ts",
19
19
  "require": "./dist/config/index.cjs"
20
20
  },
21
+ "./config/zod-3": {
22
+ "import": "./dist/config/zod-3.js",
23
+ "types": "./dist/config/zod-3.d.ts",
24
+ "require": "./dist/config/zod-3.cjs"
25
+ },
21
26
  "./next": {
22
27
  "import": "./dist/next/index.js",
23
28
  "types": "./dist/next/index.d.ts",
@@ -62,13 +67,13 @@
62
67
  "tinyexec": "^1.0.1",
63
68
  "tinyglobby": "^0.2.14",
64
69
  "unist-util-visit": "^5.0.0",
65
- "zod": "^4.0.15"
70
+ "zod": "^4.0.17"
66
71
  },
67
72
  "devDependencies": {
68
73
  "@types/js-yaml": "^4.0.9",
69
74
  "@types/mdast": "^4.0.3",
70
75
  "@types/mdx": "^2.0.13",
71
- "@types/node": "^24.2.0",
76
+ "@types/node": "^24.2.1",
72
77
  "@types/react": "^19.1.9",
73
78
  "mdast-util-mdx-jsx": "^3.2.0",
74
79
  "next": "^15.4.6",
@@ -76,12 +81,12 @@
76
81
  "rollup": "^4.46.2",
77
82
  "unified": "^11.0.5",
78
83
  "vfile": "^6.0.3",
79
- "vite": "^7.1.0",
84
+ "vite": "^7.1.1",
80
85
  "webpack": "^5.101.0",
81
- "fumadocs-core": "15.6.9",
86
+ "fumadocs-core": "15.6.10",
82
87
  "eslint-config-custom": "0.0.0",
83
- "tsconfig": "0.0.0",
84
- "@fumadocs/mdx-remote": "1.4.0"
88
+ "@fumadocs/mdx-remote": "1.4.0",
89
+ "tsconfig": "0.0.0"
85
90
  },
86
91
  "peerDependencies": {
87
92
  "@fumadocs/mdx-remote": "^1.4.0",
@@ -1,49 +0,0 @@
1
- import {
2
- remarkInclude
3
- } from "./chunk-PQCNPAD3.js";
4
-
5
- // src/utils/build-mdx.ts
6
- import { createProcessor } from "@mdx-js/mdx";
7
- var cache = /* @__PURE__ */ new Map();
8
- async function buildMDX(cacheKey, source, options) {
9
- const { filePath, frontmatter, data, _compiler, ...rest } = options;
10
- let format = options.format;
11
- if (filePath) {
12
- format ??= filePath.endsWith(".mdx") ? "mdx" : "md";
13
- }
14
- format ??= "mdx";
15
- const key = `${cacheKey}:${format}`;
16
- let cached = cache.get(key);
17
- if (!cached) {
18
- cached = createProcessor({
19
- outputFormat: "program",
20
- ...rest,
21
- remarkPlugins: [remarkInclude, ...rest.remarkPlugins ?? []],
22
- format
23
- });
24
- cache.set(key, cached);
25
- }
26
- return cached.process({
27
- value: source,
28
- path: filePath,
29
- data: {
30
- ...data,
31
- frontmatter,
32
- _compiler
33
- }
34
- });
35
- }
36
-
37
- // src/utils/count-lines.ts
38
- function countLines(s) {
39
- let num = 0;
40
- for (const c of s) {
41
- if (c === "\n") num++;
42
- }
43
- return num;
44
- }
45
-
46
- export {
47
- buildMDX,
48
- countLines
49
- };
@@ -1,26 +0,0 @@
1
- // src/utils/git-timestamp.ts
2
- import path from "path";
3
- import { x } from "tinyexec";
4
- var cache = /* @__PURE__ */ new Map();
5
- async function getGitTimestamp(file) {
6
- const cached = cache.get(file);
7
- if (cached) return cached;
8
- try {
9
- const out = await x(
10
- "git",
11
- ["log", "-1", '--pretty="%ai"', path.relative(process.cwd(), file)],
12
- {
13
- throwOnError: true
14
- }
15
- );
16
- const time = new Date(out.stdout);
17
- cache.set(file, time);
18
- return time;
19
- } catch {
20
- return;
21
- }
22
- }
23
-
24
- export {
25
- getGitTimestamp
26
- };