fumadocs-mdx 11.6.10 → 11.7.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.
Files changed (36) hide show
  1. package/dist/{chunk-64MMPGML.js → chunk-2CSSQTP6.js} +1 -10
  2. package/dist/{chunk-SXOJYWZ3.js → chunk-2KBRPMAM.js} +1 -1
  3. package/dist/{chunk-6PDS7MUA.js → chunk-C5INPAZJ.js} +4 -4
  4. package/dist/{chunk-DRVUBK5B.js → chunk-GWR7KMRU.js} +13 -1
  5. package/dist/chunk-JPPCALFT.js +34 -0
  6. package/dist/{chunk-OTM6WYMS.js → chunk-ZOWJF3OH.js} +7 -7
  7. package/dist/config/index.cjs +6 -19
  8. package/dist/config/index.d.cts +3 -7
  9. package/dist/config/index.d.ts +3 -7
  10. package/dist/config/index.js +8 -12
  11. package/dist/define-CCrinVBZ.d.cts +109 -0
  12. package/dist/define-CCrinVBZ.d.ts +109 -0
  13. package/dist/index.d.cts +6 -7
  14. package/dist/index.d.ts +6 -7
  15. package/dist/loader-mdx.cjs +156 -135
  16. package/dist/loader-mdx.js +7 -10
  17. package/dist/mdx-options-UDV5WEFU.js +6 -0
  18. package/dist/next/index.cjs +197 -54
  19. package/dist/next/index.js +7 -30
  20. package/dist/runtime/async.cjs +167 -15
  21. package/dist/runtime/async.d.cts +5 -6
  22. package/dist/runtime/async.d.ts +5 -6
  23. package/dist/runtime/async.js +26 -17
  24. package/dist/runtime/vite.cjs +116 -0
  25. package/dist/runtime/vite.d.cts +47 -0
  26. package/dist/runtime/vite.d.ts +47 -0
  27. package/dist/runtime/vite.js +90 -0
  28. package/dist/{types-Dk7DhSKZ.d.ts → types-C0bKwtAx.d.ts} +38 -50
  29. package/dist/{types-ZwLebhOl.d.cts → types-CnslxmoO.d.cts} +38 -50
  30. package/dist/vite/index.cjs +384 -137
  31. package/dist/vite/index.d.cts +12 -3
  32. package/dist/vite/index.d.ts +12 -3
  33. package/dist/vite/index.js +177 -21
  34. package/package.json +20 -10
  35. package/dist/types-DvTNxAvo.d.cts +0 -217
  36. package/dist/types-DvTNxAvo.d.ts +0 -217
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __esm = (fn, res) => function __init() {
9
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
+ };
8
11
  var __export = (target, all) => {
9
12
  for (var name in all)
10
13
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -27,6 +30,134 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
30
  ));
28
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
32
 
33
+ // src/mdx-plugins/remark-exports.ts
34
+ function remarkMdxExport({ values }) {
35
+ return (tree, vfile) => {
36
+ for (const name of values) {
37
+ if (!(name in vfile.data)) return;
38
+ tree.children.unshift(getMdastExport(name, vfile.data[name]));
39
+ }
40
+ };
41
+ }
42
+ function getMdastExport(name, value) {
43
+ return {
44
+ type: "mdxjsEsm",
45
+ value: "",
46
+ data: {
47
+ estree: {
48
+ type: "Program",
49
+ sourceType: "module",
50
+ body: [
51
+ {
52
+ type: "ExportNamedDeclaration",
53
+ specifiers: [],
54
+ source: null,
55
+ declaration: {
56
+ type: "VariableDeclaration",
57
+ kind: "let",
58
+ declarations: [
59
+ {
60
+ type: "VariableDeclarator",
61
+ id: {
62
+ type: "Identifier",
63
+ name
64
+ },
65
+ init: (0, import_estree_util_value_to_estree.valueToEstree)(value)
66
+ }
67
+ ]
68
+ }
69
+ }
70
+ ]
71
+ }
72
+ }
73
+ };
74
+ }
75
+ var import_estree_util_value_to_estree;
76
+ var init_remark_exports = __esm({
77
+ "src/mdx-plugins/remark-exports.ts"() {
78
+ "use strict";
79
+ import_estree_util_value_to_estree = require("estree-util-value-to-estree");
80
+ }
81
+ });
82
+
83
+ // src/utils/mdx-options.ts
84
+ var mdx_options_exports = {};
85
+ __export(mdx_options_exports, {
86
+ getDefaultMDXOptions: () => getDefaultMDXOptions
87
+ });
88
+ function pluginOption(def, options = []) {
89
+ const list = def(Array.isArray(options) ? options : []).filter(
90
+ Boolean
91
+ );
92
+ if (typeof options === "function") {
93
+ return options(list);
94
+ }
95
+ return list;
96
+ }
97
+ function getDefaultMDXOptions({
98
+ valueToExport = [],
99
+ rehypeCodeOptions,
100
+ remarkImageOptions,
101
+ remarkHeadingOptions,
102
+ remarkStructureOptions,
103
+ remarkCodeTabOptions,
104
+ remarkNpmOptions,
105
+ ...mdxOptions
106
+ }) {
107
+ const mdxExports = [
108
+ "structuredData",
109
+ "frontmatter",
110
+ "lastModified",
111
+ ...valueToExport
112
+ ];
113
+ const remarkPlugins = pluginOption(
114
+ (v) => [
115
+ plugins.remarkGfm,
116
+ [
117
+ plugins.remarkHeading,
118
+ {
119
+ generateToc: false,
120
+ ...remarkHeadingOptions
121
+ }
122
+ ],
123
+ remarkImageOptions !== false && [plugins.remarkImage, remarkImageOptions],
124
+ "remarkCodeTab" in plugins && remarkCodeTabOptions !== false && [
125
+ plugins.remarkCodeTab,
126
+ remarkCodeTabOptions
127
+ ],
128
+ "remarkNpm" in plugins && remarkNpmOptions !== false && [plugins.remarkNpm, remarkNpmOptions],
129
+ ...v,
130
+ remarkStructureOptions !== false && [
131
+ plugins.remarkStructure,
132
+ remarkStructureOptions
133
+ ],
134
+ [remarkMdxExport, { values: mdxExports }]
135
+ ],
136
+ mdxOptions.remarkPlugins
137
+ );
138
+ const rehypePlugins = pluginOption(
139
+ (v) => [
140
+ rehypeCodeOptions !== false && [plugins.rehypeCode, rehypeCodeOptions],
141
+ ...v,
142
+ plugins.rehypeToc
143
+ ],
144
+ mdxOptions.rehypePlugins
145
+ );
146
+ return {
147
+ ...mdxOptions,
148
+ remarkPlugins,
149
+ rehypePlugins
150
+ };
151
+ }
152
+ var plugins;
153
+ var init_mdx_options = __esm({
154
+ "src/utils/mdx-options.ts"() {
155
+ "use strict";
156
+ plugins = __toESM(require("fumadocs-core/mdx-plugins"), 1);
157
+ init_remark_exports();
158
+ }
159
+ });
160
+
30
161
  // src/loader-mdx.ts
31
162
  var loader_mdx_exports = {};
32
163
  __export(loader_mdx_exports, {
@@ -68,11 +199,23 @@ function buildConfig(config) {
68
199
  null
69
200
  ];
70
201
  }
202
+ let cachedMdxOptions;
71
203
  return [
72
204
  null,
73
205
  {
74
206
  global: globalConfig,
75
- collections
207
+ collections,
208
+ async getDefaultMDXOptions() {
209
+ if (cachedMdxOptions) return cachedMdxOptions;
210
+ const input = this.global?.mdxOptions;
211
+ async function uncached() {
212
+ const options = typeof input === "function" ? await input() : input;
213
+ const { getDefaultMDXOptions: getDefaultMDXOptions2 } = await Promise.resolve().then(() => (init_mdx_options(), mdx_options_exports));
214
+ if (options?.preset === "minimal") return options;
215
+ return getDefaultMDXOptions2(options ?? {});
216
+ }
217
+ return cachedMdxOptions = uncached();
218
+ }
76
219
  }
77
220
  ];
78
221
  }
@@ -222,10 +365,10 @@ ${e instanceof Error ? e.message : String(e)}`
222
365
  // src/utils/build-mdx.ts
223
366
  var cache2 = /* @__PURE__ */ new Map();
224
367
  async function buildMDX(cacheKey, source, options) {
225
- const { filePath, frontmatter, data, ...rest } = options;
368
+ const { filePath, frontmatter, data, _compiler, ...rest } = options;
226
369
  let format = options.format;
227
- if (!format && filePath) {
228
- format = filePath.endsWith(".mdx") ? "mdx" : "md";
370
+ if (filePath) {
371
+ format ??= filePath.endsWith(".mdx") ? "mdx" : "md";
229
372
  }
230
373
  format ??= "mdx";
231
374
  const key = `${cacheKey}:${format}`;
@@ -245,7 +388,7 @@ async function buildMDX(cacheKey, source, options) {
245
388
  data: {
246
389
  ...data,
247
390
  frontmatter,
248
- _compiler: options._compiler
391
+ _compiler
249
392
  }
250
393
  });
251
394
  }
@@ -290,20 +433,20 @@ var frontmatterSchema = import_zod.z.object({
290
433
  icon: import_zod.z.string().optional(),
291
434
  full: import_zod.z.boolean().optional(),
292
435
  // Fumadocs OpenAPI generated
293
- _openapi: import_zod.z.object({}).passthrough().optional()
436
+ _openapi: import_zod.z.looseObject({}).optional()
294
437
  });
295
438
  var ValidationError = class extends Error {
296
439
  constructor(message, issues) {
297
- super(message);
440
+ super(
441
+ `${message}:
442
+ ${issues.map((issue) => ` ${issue.path}: ${issue.message}`).join("\n")}`
443
+ );
444
+ this.title = message;
298
445
  this.issues = issues;
299
446
  }
300
- toString() {
301
- return `${this.message}:
302
- ${this.issues.map((issue) => ` ${issue.path}: ${issue.message}`).join("\n")}`;
303
- }
304
447
  toStringFormatted() {
305
448
  return [
306
- import_picocolors.default.bold(`[MDX] ${this.message}:`),
449
+ import_picocolors.default.bold(`[MDX] ${this.title}:`),
307
450
  ...this.issues.map(
308
451
  (issue) => import_picocolors.default.redBright(
309
452
  `- ${import_picocolors.default.bold(issue.path?.join(".") ?? "*")}: ${issue.message}`
@@ -337,128 +480,6 @@ function countLines(s) {
337
480
  return num;
338
481
  }
339
482
 
340
- // src/utils/mdx-options.ts
341
- var plugins = __toESM(require("fumadocs-core/mdx-plugins"), 1);
342
-
343
- // src/mdx-plugins/remark-exports.ts
344
- var import_estree_util_value_to_estree = require("estree-util-value-to-estree");
345
- function remarkMdxExport({ values }) {
346
- return (tree, vfile) => {
347
- for (const name of values) {
348
- if (!(name in vfile.data)) return;
349
- tree.children.unshift(getMdastExport(name, vfile.data[name]));
350
- }
351
- };
352
- }
353
- function getMdastExport(name, value) {
354
- return {
355
- type: "mdxjsEsm",
356
- value: "",
357
- data: {
358
- estree: {
359
- type: "Program",
360
- sourceType: "module",
361
- body: [
362
- {
363
- type: "ExportNamedDeclaration",
364
- specifiers: [],
365
- source: null,
366
- declaration: {
367
- type: "VariableDeclaration",
368
- kind: "let",
369
- declarations: [
370
- {
371
- type: "VariableDeclarator",
372
- id: {
373
- type: "Identifier",
374
- name
375
- },
376
- init: (0, import_estree_util_value_to_estree.valueToEstree)(value)
377
- }
378
- ]
379
- }
380
- }
381
- ]
382
- }
383
- }
384
- };
385
- }
386
-
387
- // src/utils/mdx-options.ts
388
- function pluginOption(def, options = []) {
389
- const list = def(Array.isArray(options) ? options : []).filter(
390
- Boolean
391
- );
392
- if (typeof options === "function") {
393
- return options(list);
394
- }
395
- return list;
396
- }
397
- function getDefaultMDXOptions({
398
- valueToExport = [],
399
- rehypeCodeOptions,
400
- remarkImageOptions,
401
- remarkHeadingOptions,
402
- remarkStructureOptions,
403
- remarkCodeTabOptions,
404
- remarkNpmOptions,
405
- ...mdxOptions
406
- }) {
407
- const mdxExports = [
408
- "structuredData",
409
- "frontmatter",
410
- "lastModified",
411
- ...valueToExport
412
- ];
413
- const remarkPlugins = pluginOption(
414
- (v) => [
415
- plugins.remarkGfm,
416
- [
417
- plugins.remarkHeading,
418
- {
419
- generateToc: false,
420
- ...remarkHeadingOptions
421
- }
422
- ],
423
- remarkImageOptions !== false && [plugins.remarkImage, remarkImageOptions],
424
- "remarkCodeTab" in plugins && remarkCodeTabOptions !== false && [
425
- plugins.remarkCodeTab,
426
- remarkCodeTabOptions
427
- ],
428
- "remarkNpm" in plugins && remarkNpmOptions !== false && [plugins.remarkNpm, remarkNpmOptions],
429
- ...v,
430
- remarkStructureOptions !== false && [
431
- plugins.remarkStructure,
432
- remarkStructureOptions
433
- ],
434
- [remarkMdxExport, { values: mdxExports }]
435
- ],
436
- mdxOptions.remarkPlugins
437
- );
438
- const rehypePlugins = pluginOption(
439
- (v) => [
440
- rehypeCodeOptions !== false && [plugins.rehypeCode, rehypeCodeOptions],
441
- ...v,
442
- plugins.rehypeToc
443
- ],
444
- mdxOptions.rehypePlugins
445
- );
446
- return {
447
- ...mdxOptions,
448
- remarkPlugins,
449
- rehypePlugins
450
- };
451
- }
452
- async function loadDefaultOptions(config) {
453
- const input = config.global?.mdxOptions;
454
- config._mdx_loader ??= {};
455
- const mdxLoader = config._mdx_loader;
456
- if (!mdxLoader.cachedOptions) {
457
- mdxLoader.cachedOptions = typeof input === "function" ? getDefaultMDXOptions(await input()) : getDefaultMDXOptions(input ?? {});
458
- }
459
- return mdxLoader.cachedOptions;
460
- }
461
-
462
483
  // src/loader-mdx.ts
463
484
  async function loader(source, callback) {
464
485
  this.cacheable(true);
@@ -477,7 +498,7 @@ async function loader(source, callback) {
477
498
  collection = void 0;
478
499
  }
479
500
  let data = matter.data;
480
- const mdxOptions = collection?.mdxOptions ?? await loadDefaultOptions(config);
501
+ const mdxOptions = collection?.mdxOptions ?? await config.getDefaultMDXOptions();
481
502
  if (collection?.schema) {
482
503
  try {
483
504
  data = await validate(
@@ -2,20 +2,17 @@ import {
2
2
  getConfigHash,
3
3
  getGitTimestamp,
4
4
  loadConfig
5
- } from "./chunk-SXOJYWZ3.js";
6
- import {
7
- ValidationError,
8
- validate
9
- } from "./chunk-OTM6WYMS.js";
5
+ } from "./chunk-2KBRPMAM.js";
10
6
  import {
11
7
  buildMDX,
12
8
  countLines
13
- } from "./chunk-6PDS7MUA.js";
9
+ } from "./chunk-C5INPAZJ.js";
10
+ import "./chunk-GWR7KMRU.js";
14
11
  import {
15
- loadDefaultOptions
16
- } from "./chunk-64MMPGML.js";
12
+ ValidationError,
13
+ validate
14
+ } from "./chunk-ZOWJF3OH.js";
17
15
  import "./chunk-AVMO2SRO.js";
18
- import "./chunk-DRVUBK5B.js";
19
16
  import {
20
17
  fumaMatter
21
18
  } from "./chunk-KVWX6THC.js";
@@ -40,7 +37,7 @@ async function loader(source, callback) {
40
37
  collection = void 0;
41
38
  }
42
39
  let data = matter.data;
43
- const mdxOptions = collection?.mdxOptions ?? await loadDefaultOptions(config);
40
+ const mdxOptions = collection?.mdxOptions ?? await config.getDefaultMDXOptions();
44
41
  if (collection?.schema) {
45
42
  try {
46
43
  data = await validate(
@@ -0,0 +1,6 @@
1
+ import {
2
+ getDefaultMDXOptions
3
+ } from "./chunk-2CSSQTP6.js";
4
+ export {
5
+ getDefaultMDXOptions
6
+ };