fumadocs-mdx 12.0.3 → 13.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.
Files changed (80) hide show
  1. package/dist/bin.cjs +1033 -308
  2. package/dist/bin.js +4 -4
  3. package/dist/build-mdx-BHG-_uxo.d.cts +53 -0
  4. package/dist/build-mdx-CzrQDBRZ.d.ts +53 -0
  5. package/dist/bun/index.cjs +92 -28
  6. package/dist/bun/index.js +6 -7
  7. package/dist/{chunk-QAUWMR5D.js → chunk-3J3WL7WN.js} +23 -5
  8. package/dist/chunk-4MAYA5QX.js +44 -0
  9. package/dist/{chunk-RMDXSZYE.js → chunk-CEA6MYJU.js} +13 -8
  10. package/dist/{chunk-IQAEAI4P.js → chunk-HI62EXSB.js} +63 -2
  11. package/dist/{chunk-46UPKP5R.js → chunk-II3H5ZVZ.js} +5 -5
  12. package/dist/{chunk-LGYVNESJ.js → chunk-JVZFH6ND.js} +6 -22
  13. package/dist/{chunk-LMG6UWCL.js → chunk-K5ZLPEIQ.js} +56 -16
  14. package/dist/{chunk-OMAMTKDE.js → chunk-KILFIBVW.js} +3 -12
  15. package/dist/chunk-NVRDCY6Z.js +30 -0
  16. package/dist/{chunk-VXEBLM4X.js → chunk-XV5Z4BFL.js} +1 -1
  17. package/dist/config/index.cjs +56 -16
  18. package/dist/config/index.d.cts +2 -1
  19. package/dist/config/index.d.ts +2 -1
  20. package/dist/config/index.js +1 -1
  21. package/dist/{define-DJbJduHy.d.ts → define-BCNh3n4O.d.cts} +40 -16
  22. package/dist/{define-DJbJduHy.d.cts → define-bck_EB4t.d.ts} +40 -16
  23. package/dist/index.cjs +0 -109
  24. package/dist/index.d.cts +73 -12
  25. package/dist/index.d.ts +73 -12
  26. package/dist/index.js +0 -11
  27. package/dist/{load-UUXLUBHL.js → load-MNG3CLET.js} +1 -3
  28. package/dist/loader-mdx.cjs +153 -60
  29. package/dist/loader-mdx.d.cts +1 -0
  30. package/dist/loader-mdx.d.ts +1 -0
  31. package/dist/loader-mdx.js +23 -9
  32. package/dist/next/index.cjs +213 -181
  33. package/dist/next/index.d.cts +2 -11
  34. package/dist/next/index.d.ts +2 -11
  35. package/dist/next/index.js +145 -117
  36. package/dist/node/loader.cjs +128 -70
  37. package/dist/node/loader.js +14 -9
  38. package/dist/plugins/index.cjs +78 -0
  39. package/dist/plugins/index.d.cts +7 -0
  40. package/dist/plugins/index.d.ts +7 -0
  41. package/dist/plugins/index.js +6 -0
  42. package/dist/plugins/json-schema.cjs +61 -0
  43. package/dist/plugins/json-schema.d.cts +16 -0
  44. package/dist/plugins/json-schema.d.ts +16 -0
  45. package/dist/plugins/json-schema.js +40 -0
  46. package/dist/remark-postprocess-K233ZVBK.d.cts +22 -0
  47. package/dist/remark-postprocess-K233ZVBK.d.ts +22 -0
  48. package/dist/runtime/next/async.cjs +108 -70
  49. package/dist/runtime/next/async.d.cts +9 -6
  50. package/dist/runtime/next/async.d.ts +9 -6
  51. package/dist/runtime/next/async.js +9 -19
  52. package/dist/runtime/next/index.cjs +25 -14
  53. package/dist/runtime/next/index.d.cts +11 -8
  54. package/dist/runtime/next/index.d.ts +11 -8
  55. package/dist/runtime/next/index.js +2 -2
  56. package/dist/runtime/vite/browser.cjs +7 -3
  57. package/dist/runtime/vite/browser.d.cts +56 -7
  58. package/dist/runtime/vite/browser.d.ts +56 -7
  59. package/dist/runtime/vite/browser.js +2 -1
  60. package/dist/runtime/vite/server.cjs +40 -34
  61. package/dist/runtime/vite/server.d.cts +13 -10
  62. package/dist/runtime/vite/server.d.ts +13 -10
  63. package/dist/runtime/vite/server.js +8 -23
  64. package/dist/{types-TeHjsmja.d.ts → types-1cCFEzWt.d.ts} +3 -10
  65. package/dist/{types-BRx1QsIJ.d.cts → types-D5NhXTJY.d.cts} +3 -10
  66. package/dist/vite/index.cjs +386 -224
  67. package/dist/vite/index.d.cts +23 -10
  68. package/dist/vite/index.d.ts +23 -10
  69. package/dist/vite/index.js +211 -37
  70. package/dist/{watcher-HGOH3APP.js → watcher-WXJDWRZY.js} +1 -1
  71. package/package.json +28 -15
  72. package/dist/browser-BupUnhpC.d.ts +0 -98
  73. package/dist/browser-R0x9IPaQ.d.cts +0 -98
  74. package/dist/chunk-ADR6R7HM.js +0 -29
  75. package/dist/chunk-XMFLD5J6.js +0 -30
  76. package/dist/chunk-ZLCSVXCD.js +0 -10
  77. package/dist/chunk-ZX7TM4AR.js +0 -127
  78. package/dist/postinstall-SCSXM4IM.js +0 -10
  79. package/dist/shared-CfiiRctw.d.ts +0 -70
  80. package/dist/shared-fFqiuWJC.d.cts +0 -70
package/dist/index.cjs CHANGED
@@ -1,14 +1,8 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
6
  var __copyProps = (to, from, except, desc) => {
13
7
  if (from && typeof from === "object" || typeof from === "function") {
14
8
  for (let key of __getOwnPropNames(from))
@@ -17,111 +11,8 @@ var __copyProps = (to, from, except, desc) => {
17
11
  }
18
12
  return to;
19
13
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
14
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
15
 
30
16
  // src/index.ts
31
17
  var index_exports = {};
32
- __export(index_exports, {
33
- _runtime: () => _runtime,
34
- createMDXSource: () => createMDXSource,
35
- resolveFiles: () => resolveFiles
36
- });
37
18
  module.exports = __toCommonJS(index_exports);
38
-
39
- // src/runtime/next/index.ts
40
- var fs = __toESM(require("fs/promises"), 1);
41
-
42
- // src/runtime/shared.ts
43
- function missingProcessedMarkdown() {
44
- throw new Error(
45
- "getText('processed') requires `includeProcessedMarkdown` to be enabled in your collection config."
46
- );
47
- }
48
-
49
- // src/runtime/next/index.ts
50
- var _runtime = {
51
- doc(files) {
52
- return files.map((file) => {
53
- const data = file.data;
54
- const filePath = file.info.fullPath;
55
- return {
56
- info: file.info,
57
- _exports: data,
58
- body: data.default,
59
- lastModified: data.lastModified,
60
- toc: data.toc,
61
- structuredData: data.structuredData,
62
- extractedReferences: data.extractedReferences,
63
- ...data.frontmatter,
64
- async getText(type) {
65
- if (type === "raw") {
66
- return (await fs.readFile(filePath)).toString();
67
- }
68
- if (typeof data._markdown !== "string") missingProcessedMarkdown();
69
- return data._markdown;
70
- }
71
- };
72
- });
73
- },
74
- meta(files) {
75
- return files.map((file) => {
76
- return {
77
- info: file.info,
78
- ...file.data
79
- };
80
- });
81
- },
82
- docs(docs, metas) {
83
- const parsedDocs = this.doc(docs);
84
- const parsedMetas = this.meta(metas);
85
- return {
86
- docs: parsedDocs,
87
- meta: parsedMetas,
88
- toFumadocsSource() {
89
- return createMDXSource(parsedDocs, parsedMetas);
90
- }
91
- };
92
- }
93
- };
94
- function createMDXSource(docs, meta = []) {
95
- return {
96
- files: resolveFiles({
97
- docs,
98
- meta
99
- })
100
- };
101
- }
102
- function resolveFiles({ docs, meta }) {
103
- const outputs = [];
104
- for (const entry of docs) {
105
- outputs.push({
106
- type: "page",
107
- absolutePath: entry.info.fullPath,
108
- path: entry.info.path,
109
- data: entry
110
- });
111
- }
112
- for (const entry of meta) {
113
- outputs.push({
114
- type: "meta",
115
- absolutePath: entry.info.fullPath,
116
- path: entry.info.path,
117
- data: entry
118
- });
119
- }
120
- return outputs;
121
- }
122
- // Annotate the CommonJS export names for ESM import in node:
123
- 0 && (module.exports = {
124
- _runtime,
125
- createMDXSource,
126
- resolveFiles
127
- });
package/dist/index.d.cts CHANGED
@@ -1,13 +1,74 @@
1
- export { A as AsyncDocCollectionEntry, D as DocCollectionEntry, a as DocData, b as DocMethods, F as FileInfo, M as MetaCollectionEntry, m as missingProcessedMarkdown } from './shared-fFqiuWJC.cjs';
2
- export { AnyCollectionEntry, _runtime, createMDXSource, resolveFiles } from './runtime/next/index.cjs';
3
- export { E as ExtractedReference } from './define-DJbJduHy.cjs';
4
- export { c as AsyncDocOut, A as AsyncRuntimeFile, D as DocOut, M as MetaOut, a as Runtime, R as RuntimeAsync, b as RuntimeFile } from './types-BRx1QsIJ.cjs';
5
- import 'fumadocs-core/mdx-plugins';
6
- import 'fumadocs-core/server';
7
- import 'react';
8
- import 'mdx/types';
9
- import 'fumadocs-core/source';
10
- import '@standard-schema/spec';
1
+ import { StructuredData } from 'fumadocs-core/mdx-plugins';
2
+ import { TOCItemType } from 'fumadocs-core/toc';
3
+ import { MDXContent } from 'mdx/types';
4
+ import { E as ExtractedReference } from './remark-postprocess-K233ZVBK.cjs';
5
+ import { Root } from 'mdast';
6
+ import { C as CompiledMDXProperties } from './build-mdx-BHG-_uxo.cjs';
11
7
  import '@mdx-js/mdx';
12
- import 'unified';
13
- import 'zod';
8
+ import 'react';
9
+
10
+ interface FileInfo {
11
+ /**
12
+ * virtualized path for Source API
13
+ */
14
+ path: string;
15
+ /**
16
+ * the file path in file system
17
+ */
18
+ fullPath: string;
19
+ }
20
+ interface DocData {
21
+ /**
22
+ * Compiled MDX content (as component)
23
+ */
24
+ body: MDXContent;
25
+ /**
26
+ * table of contents generated from content.
27
+ */
28
+ toc: TOCItemType[];
29
+ /**
30
+ * structured data for document search indexing.
31
+ */
32
+ structuredData: StructuredData;
33
+ /**
34
+ * Raw exports from the compiled MDX file.
35
+ */
36
+ _exports: Record<string, unknown>;
37
+ /**
38
+ * Last modified date of document file, obtained from version control.
39
+ *
40
+ * Only available when `lastModifiedTime` is enabled on global config.
41
+ */
42
+ lastModified?: Date;
43
+ /**
44
+ * extracted references (e.g. hrefs, paths), useful for analyzing relationships between pages.
45
+ */
46
+ extractedReferences?: ExtractedReference[];
47
+ }
48
+ interface DocMethods {
49
+ /**
50
+ * file info
51
+ */
52
+ info: FileInfo;
53
+ /**
54
+ * get document as text.
55
+ *
56
+ * - `type: raw` - read the original content from file system.
57
+ * - `type: processed` - get the processed Markdown content, only available when `includeProcessedMarkdown` is enabled on collection config.
58
+ */
59
+ getText: (type: 'raw' | 'processed') => Promise<string>;
60
+ getMDAST: () => Promise<Root>;
61
+ }
62
+ type MetaCollectionEntry<Data> = Data & {
63
+ /**
64
+ * file info
65
+ */
66
+ info: FileInfo;
67
+ };
68
+ type DocCollectionEntry<Frontmatter> = DocData & DocMethods & Frontmatter;
69
+ type AsyncDocCollectionEntry<Frontmatter> = DocMethods & {
70
+ load: () => Promise<DocData>;
71
+ } & Frontmatter;
72
+ declare function createDocMethods(info: FileInfo, load: () => Promise<CompiledMDXProperties<any>>): DocMethods;
73
+
74
+ export { type AsyncDocCollectionEntry, type DocCollectionEntry, type DocData, type DocMethods, ExtractedReference, type FileInfo, type MetaCollectionEntry, createDocMethods };
package/dist/index.d.ts CHANGED
@@ -1,13 +1,74 @@
1
- export { A as AsyncDocCollectionEntry, D as DocCollectionEntry, a as DocData, b as DocMethods, F as FileInfo, M as MetaCollectionEntry, m as missingProcessedMarkdown } from './shared-CfiiRctw.js';
2
- export { AnyCollectionEntry, _runtime, createMDXSource, resolveFiles } from './runtime/next/index.js';
3
- export { E as ExtractedReference } from './define-DJbJduHy.js';
4
- export { c as AsyncDocOut, A as AsyncRuntimeFile, D as DocOut, M as MetaOut, a as Runtime, R as RuntimeAsync, b as RuntimeFile } from './types-TeHjsmja.js';
5
- import 'fumadocs-core/mdx-plugins';
6
- import 'fumadocs-core/server';
7
- import 'react';
8
- import 'mdx/types';
9
- import 'fumadocs-core/source';
10
- import '@standard-schema/spec';
1
+ import { StructuredData } from 'fumadocs-core/mdx-plugins';
2
+ import { TOCItemType } from 'fumadocs-core/toc';
3
+ import { MDXContent } from 'mdx/types';
4
+ import { E as ExtractedReference } from './remark-postprocess-K233ZVBK.js';
5
+ import { Root } from 'mdast';
6
+ import { C as CompiledMDXProperties } from './build-mdx-CzrQDBRZ.js';
11
7
  import '@mdx-js/mdx';
12
- import 'unified';
13
- import 'zod';
8
+ import 'react';
9
+
10
+ interface FileInfo {
11
+ /**
12
+ * virtualized path for Source API
13
+ */
14
+ path: string;
15
+ /**
16
+ * the file path in file system
17
+ */
18
+ fullPath: string;
19
+ }
20
+ interface DocData {
21
+ /**
22
+ * Compiled MDX content (as component)
23
+ */
24
+ body: MDXContent;
25
+ /**
26
+ * table of contents generated from content.
27
+ */
28
+ toc: TOCItemType[];
29
+ /**
30
+ * structured data for document search indexing.
31
+ */
32
+ structuredData: StructuredData;
33
+ /**
34
+ * Raw exports from the compiled MDX file.
35
+ */
36
+ _exports: Record<string, unknown>;
37
+ /**
38
+ * Last modified date of document file, obtained from version control.
39
+ *
40
+ * Only available when `lastModifiedTime` is enabled on global config.
41
+ */
42
+ lastModified?: Date;
43
+ /**
44
+ * extracted references (e.g. hrefs, paths), useful for analyzing relationships between pages.
45
+ */
46
+ extractedReferences?: ExtractedReference[];
47
+ }
48
+ interface DocMethods {
49
+ /**
50
+ * file info
51
+ */
52
+ info: FileInfo;
53
+ /**
54
+ * get document as text.
55
+ *
56
+ * - `type: raw` - read the original content from file system.
57
+ * - `type: processed` - get the processed Markdown content, only available when `includeProcessedMarkdown` is enabled on collection config.
58
+ */
59
+ getText: (type: 'raw' | 'processed') => Promise<string>;
60
+ getMDAST: () => Promise<Root>;
61
+ }
62
+ type MetaCollectionEntry<Data> = Data & {
63
+ /**
64
+ * file info
65
+ */
66
+ info: FileInfo;
67
+ };
68
+ type DocCollectionEntry<Frontmatter> = DocData & DocMethods & Frontmatter;
69
+ type AsyncDocCollectionEntry<Frontmatter> = DocMethods & {
70
+ load: () => Promise<DocData>;
71
+ } & Frontmatter;
72
+ declare function createDocMethods(info: FileInfo, load: () => Promise<CompiledMDXProperties<any>>): DocMethods;
73
+
74
+ export { type AsyncDocCollectionEntry, type DocCollectionEntry, type DocData, type DocMethods, ExtractedReference, type FileInfo, type MetaCollectionEntry, createDocMethods };
package/dist/index.js CHANGED
@@ -1,11 +0,0 @@
1
- import {
2
- _runtime,
3
- createMDXSource,
4
- resolveFiles
5
- } from "./chunk-OMAMTKDE.js";
6
- import "./chunk-ZLCSVXCD.js";
7
- export {
8
- _runtime,
9
- createMDXSource,
10
- resolveFiles
11
- };
@@ -1,9 +1,7 @@
1
1
  import {
2
- getConfigHash,
3
2
  loadConfig
4
- } from "./chunk-LGYVNESJ.js";
3
+ } from "./chunk-JVZFH6ND.js";
5
4
  import "./chunk-U4MQ44TS.js";
6
5
  export {
7
- getConfigHash,
8
6
  loadConfig
9
7
  };