fumadocs-mdx 11.9.1 → 11.10.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 (52) hide show
  1. package/dist/bin.cjs +1063 -0
  2. package/dist/bin.d.cts +1 -0
  3. package/dist/bin.d.ts +1 -0
  4. package/dist/bin.js +16 -0
  5. package/dist/{browser-CyU2Yl7A.d.cts → browser-B2G8uAF2.d.cts} +1 -1
  6. package/dist/{browser-DEsQvNRx.d.ts → browser-DrH7tKRi.d.ts} +1 -1
  7. package/dist/bun/index.cjs +669 -0
  8. package/dist/bun/index.d.cts +8 -0
  9. package/dist/bun/index.d.ts +8 -0
  10. package/dist/bun/index.js +53 -0
  11. package/dist/chunk-6Y5JDZHD.js +65 -0
  12. package/dist/chunk-CNKI574E.js +82 -0
  13. package/dist/{chunk-GX3THK2Q.js → chunk-IQAEAI4P.js} +25 -25
  14. package/dist/chunk-QJCCVMBJ.js +151 -0
  15. package/dist/{chunk-NUDEC6C5.js → chunk-UOOPSLFY.js} +1 -1
  16. package/dist/{chunk-COQ4VMK2.js → chunk-XXSKWWMB.js} +28 -61
  17. package/dist/config/index.d.cts +1 -1
  18. package/dist/config/index.d.ts +1 -1
  19. package/dist/config/zod-3.d.cts +1 -1
  20. package/dist/config/zod-3.d.ts +1 -1
  21. package/dist/{define-DnJzAZrj.d.cts → define-BH4bnHQl.d.cts} +6 -0
  22. package/dist/{define-DnJzAZrj.d.ts → define-BH4bnHQl.d.ts} +6 -0
  23. package/dist/loader-mdx.cjs +345 -265
  24. package/dist/loader-mdx.js +12 -80
  25. package/dist/next/index.cjs +15 -130
  26. package/dist/next/index.js +15 -33
  27. package/dist/node/loader.cjs +748 -0
  28. package/dist/node/loader.d.cts +5 -0
  29. package/dist/node/loader.d.ts +5 -0
  30. package/dist/node/loader.js +24 -0
  31. package/dist/postinstall-XV4WSHZP.js +9 -0
  32. package/dist/runtime/{async.cjs → next/async.cjs} +4 -4
  33. package/dist/runtime/{async.d.cts → next/async.d.cts} +3 -3
  34. package/dist/runtime/{async.d.ts → next/async.d.ts} +3 -3
  35. package/dist/runtime/{async.js → next/async.js} +6 -6
  36. package/dist/{index.cjs → runtime/next/index.cjs} +4 -6
  37. package/dist/{index.d.cts → runtime/next/index.d.cts} +3 -3
  38. package/dist/{index.d.ts → runtime/next/index.d.ts} +3 -3
  39. package/dist/{index.js → runtime/next/index.js} +1 -1
  40. package/dist/runtime/vite/browser.d.cts +2 -2
  41. package/dist/runtime/vite/browser.d.ts +2 -2
  42. package/dist/runtime/vite/server.d.cts +3 -3
  43. package/dist/runtime/vite/server.d.ts +3 -3
  44. package/dist/{types-WSHJKA8L.d.ts → types-DN9KrG7R.d.ts} +1 -1
  45. package/dist/{types-BmVgoqsr.d.cts → types-DT83Ijs6.d.cts} +1 -1
  46. package/dist/vite/index.cjs +440 -276
  47. package/dist/vite/index.d.cts +4 -1
  48. package/dist/vite/index.d.ts +4 -1
  49. package/dist/vite/index.js +19 -81
  50. package/package.json +24 -17
  51. package/bin.js +0 -5
  52. package/dist/chunk-UCY7OBZG.js +0 -12
@@ -1,5 +1,7 @@
1
1
  import { Plugin } from 'vite';
2
2
 
3
+ declare function postInstall(configPath?: string, outDir?: string, addJsExtension?: boolean): Promise<void>;
4
+
3
5
  interface PluginOptions {
4
6
  /**
5
7
  * Automatically generate index files for accessing files with `import.meta.glob`.
@@ -17,6 +19,7 @@ interface PluginOptions {
17
19
  */
18
20
  configPath?: string;
19
21
  }
22
+
20
23
  declare function mdx(config: Record<string, unknown>, options?: PluginOptions): Plugin;
21
24
 
22
- export { type PluginOptions, mdx as default };
25
+ export { type PluginOptions, mdx as default, postInstall };
@@ -1,5 +1,7 @@
1
1
  import { Plugin } from 'vite';
2
2
 
3
+ declare function postInstall(configPath?: string, outDir?: string, addJsExtension?: boolean): Promise<void>;
4
+
3
5
  interface PluginOptions {
4
6
  /**
5
7
  * Automatically generate index files for accessing files with `import.meta.glob`.
@@ -17,6 +19,7 @@ interface PluginOptions {
17
19
  */
18
20
  configPath?: string;
19
21
  }
22
+
20
23
  declare function mdx(config: Record<string, unknown>, options?: PluginOptions): Plugin;
21
24
 
22
- export { type PluginOptions, mdx as default };
25
+ export { type PluginOptions, mdx as default, postInstall };
@@ -1,42 +1,40 @@
1
1
  import {
2
- countLines
3
- } from "../chunk-UCY7OBZG.js";
2
+ entry,
3
+ postInstall
4
+ } from "../chunk-XXSKWWMB.js";
5
+ import "../chunk-6Y5JDZHD.js";
4
6
  import {
5
- entry
6
- } from "../chunk-COQ4VMK2.js";
7
+ toVite
8
+ } from "../chunk-CNKI574E.js";
9
+ import {
10
+ createMdxLoader,
11
+ resolvedConfig
12
+ } from "../chunk-QJCCVMBJ.js";
13
+ import "../chunk-QQWCBFFE.js";
14
+ import "../chunk-SVTXMVLQ.js";
7
15
  import {
8
16
  ValidationError,
9
- getGitTimestamp,
10
17
  validate
11
- } from "../chunk-GX3THK2Q.js";
12
- import {
13
- buildMDX
14
- } from "../chunk-QQWCBFFE.js";
15
- import "../chunk-SVTXMVLQ.js";
18
+ } from "../chunk-IQAEAI4P.js";
19
+ import "../chunk-766EAFX6.js";
16
20
  import {
17
21
  buildConfig
18
22
  } from "../chunk-QVZ7JH4H.js";
19
- import {
20
- fumaMatter
21
- } from "../chunk-VWJKRQZR.js";
23
+ import "../chunk-VWJKRQZR.js";
22
24
 
23
25
  // src/vite/index.ts
24
26
  import {
25
27
  mergeConfig
26
28
  } from "vite";
27
29
  import { parse } from "querystring";
28
- import { z } from "zod";
29
30
  import * as fs from "fs/promises";
30
31
  import * as path from "path";
31
32
  import { load } from "js-yaml";
32
33
  var FumadocsDeps = ["fumadocs-core", "fumadocs-ui", "fumadocs-openapi"];
33
- var querySchema = z.object({
34
- only: z.literal(["frontmatter", "all"]).default("all"),
35
- collection: z.string().optional()
36
- }).loose();
37
34
  function mdx(config, options = {}) {
38
35
  const { generateIndexFile = true, configPath = "source.config.ts" } = options;
39
36
  const loaded = buildConfig(config);
37
+ const mdxLoader = toVite(createMdxLoader(resolvedConfig(loaded)));
40
38
  async function transformMeta(path2, query, value) {
41
39
  const isJson = path2.endsWith(".json");
42
40
  const parsed = parse(query);
@@ -69,67 +67,6 @@ function mdx(config, options = {}) {
69
67
  map: null
70
68
  };
71
69
  }
72
- async function transformContent(file, query, value) {
73
- const matter = fumaMatter(value);
74
- const isDevelopment = this.environment.mode === "dev";
75
- const parsed = querySchema.parse(parse(query));
76
- const collection = parsed.collection ? loaded.collections.get(parsed.collection) : void 0;
77
- let schema;
78
- let mdxOptions;
79
- switch (collection?.type) {
80
- case "doc":
81
- mdxOptions = collection.mdxOptions;
82
- schema = collection.schema;
83
- break;
84
- case "docs":
85
- mdxOptions = collection.docs.mdxOptions;
86
- schema = collection.docs.schema;
87
- break;
88
- }
89
- if (schema) {
90
- matter.data = await validate(
91
- schema,
92
- matter.data,
93
- {
94
- source: value,
95
- path: file
96
- },
97
- `invalid frontmatter in ${file}`
98
- );
99
- }
100
- if (parsed.only === "frontmatter") {
101
- return {
102
- code: `export const frontmatter = ${JSON.stringify(matter.data)}`,
103
- map: null
104
- };
105
- }
106
- const data = {};
107
- if (loaded.global.lastModifiedTime === "git") {
108
- data.lastModified = (await getGitTimestamp(file))?.getTime();
109
- }
110
- mdxOptions ??= await loaded.getDefaultMDXOptions();
111
- const lineOffset = isDevelopment ? countLines(matter.matter) : 0;
112
- const compiled = await buildMDX(
113
- parsed.collection ?? "global",
114
- "\n".repeat(lineOffset) + matter.content,
115
- {
116
- development: isDevelopment,
117
- ...mdxOptions,
118
- data,
119
- filePath: file,
120
- frontmatter: matter.data,
121
- _compiler: {
122
- addDependency: (file2) => {
123
- this.addWatchFile(file2);
124
- }
125
- }
126
- }
127
- );
128
- return {
129
- code: String(compiled.value),
130
- map: compiled.map
131
- };
132
- }
133
70
  return {
134
71
  name: "fumadocs-mdx",
135
72
  // needed, otherwise other plugins will be executed before our `transform`.
@@ -167,7 +104,7 @@ function mdx(config, options = {}) {
167
104
  if ([".yaml", ".json"].includes(ext))
168
105
  return await transformMeta(file, query, value);
169
106
  if ([".md", ".mdx"].includes(ext))
170
- return await transformContent.call(this, file, query, value);
107
+ return await mdxLoader.call(this, file, query, value);
171
108
  } catch (e) {
172
109
  if (e instanceof ValidationError) {
173
110
  throw new Error(e.toStringFormatted());
@@ -178,5 +115,6 @@ function mdx(config, options = {}) {
178
115
  };
179
116
  }
180
117
  export {
181
- mdx as default
118
+ mdx as default,
119
+ postInstall
182
120
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-mdx",
3
- "version": "11.9.1",
3
+ "version": "11.10.1",
4
4
  "description": "The built-in source for Fumadocs",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -33,28 +33,34 @@
33
33
  "types": "./dist/vite/index.d.ts",
34
34
  "require": "./dist/vite/index.cjs"
35
35
  },
36
+ ".": {
37
+ "import": "./dist/runtime/next/index.js",
38
+ "types": "./dist/runtime/next/index.d.ts"
39
+ },
36
40
  "./runtime/async": {
37
- "import": "./dist/runtime/async.js",
38
- "types": "./dist/runtime/async.d.ts"
41
+ "import": "./dist/runtime/next/async.js",
42
+ "types": "./dist/runtime/next/async.d.ts"
39
43
  },
40
44
  "./runtime/vite": {
41
45
  "browser": "./dist/runtime/vite/browser.js",
42
46
  "import": "./dist/runtime/vite/server.js",
43
47
  "types": "./dist/runtime/vite/server.d.ts"
44
48
  },
45
- ".": {
46
- "import": "./dist/index.js",
47
- "types": "./dist/index.d.ts",
48
- "require": "./dist/index.cjs"
49
+ "./node/loader": {
50
+ "import": "./dist/node/loader.js",
51
+ "types": "./dist/node/loader.d.ts"
52
+ },
53
+ "./bun": {
54
+ "import": "./dist/bun/index.js",
55
+ "types": "./dist/bun/index.d.ts"
49
56
  }
50
57
  },
51
58
  "main": "./dist/index.js",
52
59
  "types": "./dist/index.d.ts",
53
- "bin": "./bin.js",
60
+ "bin": "./dist/bin.js",
54
61
  "files": [
55
62
  "dist/*",
56
- "loader-mdx.cjs",
57
- "bin.js"
63
+ "loader-mdx.cjs"
58
64
  ],
59
65
  "dependencies": {
60
66
  "@mdx-js/mdx": "^3.1.1",
@@ -71,25 +77,26 @@
71
77
  "tinyglobby": "^0.2.15",
72
78
  "unified": "^11.0.5",
73
79
  "unist-util-visit": "^5.0.0",
74
- "zod": "^4.1.5"
80
+ "zod": "^4.1.8"
75
81
  },
76
82
  "devDependencies": {
83
+ "@types/bun": "^1.2.21",
77
84
  "@types/js-yaml": "^4.0.9",
78
85
  "@types/mdast": "^4.0.3",
79
86
  "@types/mdx": "^2.0.13",
80
- "@types/node": "^24.3.1",
81
- "@types/react": "^19.1.12",
87
+ "@types/node": "^24.3.3",
88
+ "@types/react": "^19.1.13",
82
89
  "mdast-util-mdx-jsx": "^3.2.0",
83
- "next": "^15.5.2",
90
+ "next": "^15.5.3",
84
91
  "react": "^19.1.1",
85
92
  "rollup": "^4.50.1",
86
93
  "vfile": "^6.0.3",
87
94
  "vite": "^7.1.5",
88
95
  "webpack": "^5.101.3",
89
- "tsconfig": "0.0.0",
90
- "eslint-config-custom": "0.0.0",
91
96
  "@fumadocs/mdx-remote": "1.4.0",
92
- "fumadocs-core": "15.7.11"
97
+ "eslint-config-custom": "0.0.0",
98
+ "fumadocs-core": "15.7.13",
99
+ "tsconfig": "0.0.0"
93
100
  },
94
101
  "peerDependencies": {
95
102
  "@fumadocs/mdx-remote": "^1.4.0",
package/bin.js DELETED
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { postInstall } from './dist/next/index.js';
4
-
5
- void postInstall(process.argv[2], process.argv[3]);
@@ -1,12 +0,0 @@
1
- // src/utils/count-lines.ts
2
- function countLines(s) {
3
- let num = 0;
4
- for (const c of s) {
5
- if (c === "\n") num++;
6
- }
7
- return num;
8
- }
9
-
10
- export {
11
- countLines
12
- };